@esri/hub-common 9.18.0 → 9.19.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/content/_internal.js +151 -30
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +607 -0
- package/dist/es2017/content/compose.js.map +1 -0
- package/dist/es2017/content/get-family.js +42 -0
- package/dist/es2017/content/get-family.js.map +1 -0
- package/dist/es2017/content/index.js +42 -468
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/core/types/IHubContentEnrichments.js +1 -0
- package/dist/es2017/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/es2017/core/types/IServerEnrichments.js +1 -0
- package/dist/es2017/core/types/IServerEnrichments.js.map +1 -0
- package/dist/es2017/core/types/index.js +2 -1
- package/dist/es2017/core/types/index.js.map +1 -1
- package/dist/esm/content/_internal.js +153 -30
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +600 -0
- package/dist/esm/content/compose.js.map +1 -0
- package/dist/esm/content/get-family.js +42 -0
- package/dist/esm/content/get-family.js.map +1 -0
- package/dist/esm/content/index.js +44 -476
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/core/types/IHubContentEnrichments.js +1 -0
- package/dist/esm/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/esm/core/types/IServerEnrichments.js +1 -0
- package/dist/esm/core/types/IServerEnrichments.js.map +1 -0
- package/dist/esm/core/types/index.js +2 -1
- package/dist/esm/core/types/index.js.map +1 -1
- package/dist/node/content/_internal.js +155 -31
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +612 -0
- package/dist/node/content/compose.js.map +1 -0
- package/dist/node/content/get-family.js +46 -0
- package/dist/node/content/get-family.js.map +1 -0
- package/dist/node/content/index.js +48 -477
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/core/types/IHubContentEnrichments.js +3 -0
- package/dist/node/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/node/core/types/{IContentEnrichments.js → IServerEnrichments.js} +1 -1
- package/dist/node/core/types/IServerEnrichments.js.map +1 -0
- package/dist/node/core/types/index.js +2 -1
- package/dist/node/core/types/index.js.map +1 -1
- package/dist/types/content/_internal.d.ts +57 -22
- package/dist/types/content/compose.d.ts +115 -0
- package/dist/types/content/get-family.d.ts +7 -0
- package/dist/types/content/index.d.ts +4 -86
- package/dist/types/core/types/IHubContent.d.ts +4 -2
- package/dist/types/core/types/IHubContentEnrichments.d.ts +15 -0
- package/dist/types/core/types/IHubItemEntity.d.ts +1 -1
- package/dist/types/core/types/{IContentEnrichments.d.ts → IServerEnrichments.d.ts} +3 -2
- package/dist/types/core/types/index.d.ts +2 -1
- package/dist/umd/common.umd.js +910 -555
- 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/core/types/IContentEnrichments.js +0 -1
- package/dist/es2017/core/types/IContentEnrichments.js.map +0 -1
- package/dist/esm/core/types/IContentEnrichments.js +0 -1
- package/dist/esm/core/types/IContentEnrichments.js.map +0 -1
- package/dist/node/core/types/IContentEnrichments.js.map +0 -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.18.0 - Tue Feb 22 2022 17:58:02 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -5850,6 +5850,27 @@
|
|
|
5850
5850
|
"Workflow Manager Package",
|
|
5851
5851
|
];
|
|
5852
5852
|
var site$1 = ["Hub Site Application", "Site Application"];
|
|
5853
|
+
/**
|
|
5854
|
+
* ```js
|
|
5855
|
+
* import { getCollection } from "@esri/hub-common";
|
|
5856
|
+
* //
|
|
5857
|
+
* getCollection('Feature Layer')
|
|
5858
|
+
* > 'dataset'
|
|
5859
|
+
* ```
|
|
5860
|
+
* Get the Hub collection for a given item type
|
|
5861
|
+
* @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
|
|
5862
|
+
* @returns the Hub collection of a given item type.
|
|
5863
|
+
*/
|
|
5864
|
+
var getCollection = function (type) {
|
|
5865
|
+
if (!type) {
|
|
5866
|
+
return;
|
|
5867
|
+
}
|
|
5868
|
+
var lowerCaseType = type.toLocaleLowerCase();
|
|
5869
|
+
return Object.keys(collections).find(function (key) {
|
|
5870
|
+
var collectionTypes = collections[key];
|
|
5871
|
+
return collectionTypes.some(function (t) { return t.toLocaleLowerCase() === lowerCaseType; });
|
|
5872
|
+
});
|
|
5873
|
+
};
|
|
5853
5874
|
// TODO: remove this at the next breaking change
|
|
5854
5875
|
// it's only here to support deprecated categories
|
|
5855
5876
|
var collections = {
|
|
@@ -6084,6 +6105,252 @@
|
|
|
6084
6105
|
};
|
|
6085
6106
|
};
|
|
6086
6107
|
|
|
6108
|
+
// private helper functions
|
|
6109
|
+
function collectionToFamily(collection) {
|
|
6110
|
+
var overrides = {
|
|
6111
|
+
other: "content",
|
|
6112
|
+
solution: "template",
|
|
6113
|
+
};
|
|
6114
|
+
return overrides[collection] || collection;
|
|
6115
|
+
}
|
|
6116
|
+
/**
|
|
6117
|
+
* return the Hub family given an item's type
|
|
6118
|
+
* @param type item type
|
|
6119
|
+
* @returns Hub family
|
|
6120
|
+
*/
|
|
6121
|
+
function getFamily(type) {
|
|
6122
|
+
var family;
|
|
6123
|
+
// override default behavior for the rows that are highlighted in yellow here:
|
|
6124
|
+
// https://esriis.sharepoint.com/:x:/r/sites/ArcGISHub/_layouts/15/Doc.aspx?sourcedoc=%7BADA1C9DC-4F6C-4DE4-92C6-693EF9571CFA%7D&file=Hub%20Routes.xlsx&nav=MTBfe0VENEREQzI4LUZFMDctNEI0Ri04NjcyLThCQUE2MTA0MEZGRn1fezIwMTIwMEJFLTA4MEQtNEExRC05QzA4LTE5MTAzOUQwMEE1RH0&action=default&mobileredirect=true&cid=df1c874b-c367-4cea-bc13-7bebfad3f2ac
|
|
6125
|
+
switch ((type || "").toLowerCase()) {
|
|
6126
|
+
case "image service":
|
|
6127
|
+
family = "dataset";
|
|
6128
|
+
break;
|
|
6129
|
+
case "feature service":
|
|
6130
|
+
case "raster layer":
|
|
6131
|
+
// TODO: check if feature service has > 1 layer first?
|
|
6132
|
+
family = "map";
|
|
6133
|
+
break;
|
|
6134
|
+
case "microsoft excel":
|
|
6135
|
+
family = "document";
|
|
6136
|
+
break;
|
|
6137
|
+
case "cad drawing":
|
|
6138
|
+
case "feature collection template":
|
|
6139
|
+
case "report template":
|
|
6140
|
+
family = "content";
|
|
6141
|
+
break;
|
|
6142
|
+
default:
|
|
6143
|
+
// by default derive from collection
|
|
6144
|
+
family = collectionToFamily(getCollection(type));
|
|
6145
|
+
}
|
|
6146
|
+
return family;
|
|
6147
|
+
}
|
|
6148
|
+
|
|
6149
|
+
// TODO: this needs to be able to handle "automatic"
|
|
6150
|
+
var getContentBoundary = function (item) {
|
|
6151
|
+
var _a;
|
|
6152
|
+
var extent = item.extent;
|
|
6153
|
+
var isValidItemExtent = isBBox(extent);
|
|
6154
|
+
// user specified provenance is stored in item.properties
|
|
6155
|
+
var provenance = ((_a = item.properties) === null || _a === void 0 ? void 0 : _a.boundary) ||
|
|
6156
|
+
// but we default to item if the item has an extent
|
|
6157
|
+
(isValidItemExtent ? "item" : undefined);
|
|
6158
|
+
var geometry;
|
|
6159
|
+
switch (provenance) {
|
|
6160
|
+
case "item":
|
|
6161
|
+
geometry = isValidItemExtent ? bBoxToPolygon(extent) : null;
|
|
6162
|
+
break;
|
|
6163
|
+
case "none":
|
|
6164
|
+
geometry = null;
|
|
6165
|
+
break;
|
|
6166
|
+
// TODO: handle other provenances
|
|
6167
|
+
}
|
|
6168
|
+
// TODO: derive and return center
|
|
6169
|
+
return {
|
|
6170
|
+
provenance: provenance,
|
|
6171
|
+
geometry: geometry,
|
|
6172
|
+
};
|
|
6173
|
+
};
|
|
6174
|
+
// when no request options are provided, the underlying
|
|
6175
|
+
// request functions assume that we are online in production
|
|
6176
|
+
// so we only want use enterprise logic if isPortal is explicitly defined
|
|
6177
|
+
var isPortal = function (requestOptions) {
|
|
6178
|
+
return requestOptions && requestOptions.isPortal;
|
|
6179
|
+
};
|
|
6180
|
+
/**
|
|
6181
|
+
* Returns whether or not an item is a proxied csv
|
|
6182
|
+
*
|
|
6183
|
+
* @param item
|
|
6184
|
+
* @param requestOptions Hub Request Options (including whether we're in portal)
|
|
6185
|
+
* @returns
|
|
6186
|
+
*/
|
|
6187
|
+
var isProxiedCSV = function (item, requestOptions) {
|
|
6188
|
+
return !isPortal(requestOptions) &&
|
|
6189
|
+
item.access === "public" &&
|
|
6190
|
+
item.type === "CSV" &&
|
|
6191
|
+
item.size <= 5000000;
|
|
6192
|
+
};
|
|
6193
|
+
var getHubRelativeUrl = function (type, identifier, typeKeywords) {
|
|
6194
|
+
// solution types have their own logic
|
|
6195
|
+
var contentUrl = getSolutionUrl(type, identifier, typeKeywords);
|
|
6196
|
+
if (!contentUrl) {
|
|
6197
|
+
var family = getFamily(type);
|
|
6198
|
+
var familiesWithPluralizedRoute = [
|
|
6199
|
+
"app",
|
|
6200
|
+
"dataset",
|
|
6201
|
+
"document",
|
|
6202
|
+
"map",
|
|
6203
|
+
"template",
|
|
6204
|
+
];
|
|
6205
|
+
// default to the catchall content route
|
|
6206
|
+
var path = "/content";
|
|
6207
|
+
if (family === "feedback") {
|
|
6208
|
+
// the exception
|
|
6209
|
+
path = "/feedback/surveys";
|
|
6210
|
+
}
|
|
6211
|
+
else if (isPageType(type)) {
|
|
6212
|
+
// pages are in the document family,
|
|
6213
|
+
// but instead of showing the page's metadata on /documents/about
|
|
6214
|
+
// but we render the page on the pages route
|
|
6215
|
+
path = "/pages";
|
|
6216
|
+
}
|
|
6217
|
+
else if (familiesWithPluralizedRoute.indexOf(family) > -1) {
|
|
6218
|
+
// the rule: route name is plural of family name
|
|
6219
|
+
path = "/" + family + "s";
|
|
6220
|
+
}
|
|
6221
|
+
contentUrl = path + "/" + identifier;
|
|
6222
|
+
}
|
|
6223
|
+
return contentUrl;
|
|
6224
|
+
};
|
|
6225
|
+
var isPageType = function (type) {
|
|
6226
|
+
return ["Hub Page", "Site Page"].includes(type);
|
|
6227
|
+
};
|
|
6228
|
+
var getSolutionUrl = function (type, identifier, typeKeywords) {
|
|
6229
|
+
var hubUrl;
|
|
6230
|
+
if (type === "Solution") {
|
|
6231
|
+
// NOTE: as per the above spreadsheet,
|
|
6232
|
+
// solution types are now in the Template family
|
|
6233
|
+
// but we don't send them to the route for initiative templates
|
|
6234
|
+
if ((typeKeywords === null || typeKeywords === void 0 ? void 0 : typeKeywords.indexOf("Deployed")) > 0) {
|
|
6235
|
+
// deployed solutions go to the generic content route
|
|
6236
|
+
hubUrl = "/content/" + identifier;
|
|
6237
|
+
}
|
|
6238
|
+
// others go to the solution about route
|
|
6239
|
+
hubUrl = "/templates/" + identifier + "/about";
|
|
6240
|
+
}
|
|
6241
|
+
return hubUrl;
|
|
6242
|
+
};
|
|
6243
|
+
function getMetadataPath(identifier) {
|
|
6244
|
+
// NOTE: i have verified that this will work regardless of the "Metadata Style" set on the org
|
|
6245
|
+
var metadataPaths = {
|
|
6246
|
+
updateFrequency: "metadata.dataIdInfo.resMaint.maintFreq.MaintFreqCd.@_value",
|
|
6247
|
+
reviseDate: "metadata.dataIdInfo.idCitation.date.reviseDate",
|
|
6248
|
+
pubDate: "metadata.dataIdInfo.idCitation.date.pubDate",
|
|
6249
|
+
createDate: "metadata.dataIdInfo.idCitation.date.createDate",
|
|
6250
|
+
metadataUpdateFrequency: "metadata.mdMaint.maintFreq.MaintFreqCd.@_value",
|
|
6251
|
+
metadataUpdatedDate: "metadata.mdDateSt",
|
|
6252
|
+
};
|
|
6253
|
+
return metadataPaths[identifier];
|
|
6254
|
+
}
|
|
6255
|
+
function getValueFromMetadata(metadata, identifier) {
|
|
6256
|
+
var path = getMetadataPath(identifier);
|
|
6257
|
+
return path && getProp(metadata, path);
|
|
6258
|
+
}
|
|
6259
|
+
var DatePrecision;
|
|
6260
|
+
(function (DatePrecision) {
|
|
6261
|
+
DatePrecision["Year"] = "year";
|
|
6262
|
+
DatePrecision["Month"] = "month";
|
|
6263
|
+
DatePrecision["Day"] = "day";
|
|
6264
|
+
DatePrecision["Time"] = "time";
|
|
6265
|
+
})(DatePrecision || (DatePrecision = {}));
|
|
6266
|
+
/**
|
|
6267
|
+
* Parses an ISO8601 date string into a date and a precision.
|
|
6268
|
+
* This is because a) if somone entered 2018, we want to respect that and not treat it as the same as 2018-01-01
|
|
6269
|
+
* and b) you cannot naively call new Date with an ISO 8601 string that does not include time information
|
|
6270
|
+
* For example, when I, here in mountain time, do new Date('2018').getFullYear() I get "2017".
|
|
6271
|
+
* This is because when you do not provide time or timezone info, UTC is assumed, so new Date('2018') is 2018-01-01T00:00:00 in UTC
|
|
6272
|
+
* which is actually 7 hours earlier here in mountain time.
|
|
6273
|
+
*
|
|
6274
|
+
* @param {string} isoString
|
|
6275
|
+
* @return { date: Date, precision: DatePrecision }
|
|
6276
|
+
*/
|
|
6277
|
+
function parseISODateString(isoString) {
|
|
6278
|
+
isoString = "" + isoString;
|
|
6279
|
+
var date;
|
|
6280
|
+
var precision;
|
|
6281
|
+
if (/^\d{4}$/.test(isoString)) {
|
|
6282
|
+
// yyyy
|
|
6283
|
+
date = new Date(+isoString, 0, 1);
|
|
6284
|
+
precision = DatePrecision.Year;
|
|
6285
|
+
}
|
|
6286
|
+
else if (/^\d{4}-\d{1,2}$/.test(isoString)) {
|
|
6287
|
+
// yyyy-mm
|
|
6288
|
+
var parts = isoString.split("-");
|
|
6289
|
+
date = new Date(+parts[0], +parts[1] - 1, 1);
|
|
6290
|
+
precision = DatePrecision.Month;
|
|
6291
|
+
}
|
|
6292
|
+
else if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(isoString)) {
|
|
6293
|
+
// yyyy-mm-dd
|
|
6294
|
+
var parts = isoString.split("-");
|
|
6295
|
+
date = new Date(+parts[0], +parts[1] - 1, +parts[2]);
|
|
6296
|
+
precision = DatePrecision.Day;
|
|
6297
|
+
}
|
|
6298
|
+
else if (!Number.isNaN(Date.parse(isoString))) {
|
|
6299
|
+
// any other string parsable to a valid date
|
|
6300
|
+
date = new Date(isoString);
|
|
6301
|
+
precision = isoString.includes("T")
|
|
6302
|
+
? DatePrecision.Time
|
|
6303
|
+
: DatePrecision.Day;
|
|
6304
|
+
}
|
|
6305
|
+
return date && precision && { date: date, precision: precision };
|
|
6306
|
+
}
|
|
6307
|
+
var getServerSpatialReference = function (server, layer) {
|
|
6308
|
+
var _a;
|
|
6309
|
+
var layerSpatialReference = (_a = layer === null || layer === void 0 ? void 0 : layer.extent) === null || _a === void 0 ? void 0 : _a.spatialReference;
|
|
6310
|
+
return layerSpatialReference || (server === null || server === void 0 ? void 0 : server.spatialReference);
|
|
6311
|
+
};
|
|
6312
|
+
// NOTE: IItem has spatialRefernce: ISpatialReference, but
|
|
6313
|
+
// the portal REST API returns spatialReference as as string
|
|
6314
|
+
// that is always either WKID like "102100" or
|
|
6315
|
+
// WKT like "NAD_1983_HARN_StatePlane_Hawaii_3_FIPS_5103_Feet"
|
|
6316
|
+
// so we coerce those string into a ISpatialReference object
|
|
6317
|
+
var getItemSpatialReference = function (item) {
|
|
6318
|
+
var spatialReference = item.spatialReference;
|
|
6319
|
+
if (!spatialReference || typeof spatialReference === "object") {
|
|
6320
|
+
// no need to try and transform this into an ISpatialReference
|
|
6321
|
+
return spatialReference;
|
|
6322
|
+
}
|
|
6323
|
+
// otherwise it _should_ be a string (if coming form the REST API)
|
|
6324
|
+
// but we force it in case it was set to a number somewhere outside of TS
|
|
6325
|
+
var spatialReferenceString = spatialReference + "";
|
|
6326
|
+
var wkid = parseInt(spatialReferenceString, 10);
|
|
6327
|
+
return isNaN(wkid)
|
|
6328
|
+
? // string is not a number, assume it is WKT
|
|
6329
|
+
{ wkt: spatialReferenceString }
|
|
6330
|
+
: //
|
|
6331
|
+
{ wkid: wkid };
|
|
6332
|
+
};
|
|
6333
|
+
|
|
6334
|
+
/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.
|
|
6335
|
+
* Apache-2.0 */
|
|
6336
|
+
var serviceRegex = new RegExp(/.+(?:map|feature|image)server/i);
|
|
6337
|
+
/**
|
|
6338
|
+
* Return the service url. If not matched, returns what was passed in
|
|
6339
|
+
*/
|
|
6340
|
+
function parseServiceUrl(url) {
|
|
6341
|
+
var match = url.match(serviceRegex);
|
|
6342
|
+
if (match) {
|
|
6343
|
+
return match[0];
|
|
6344
|
+
}
|
|
6345
|
+
else {
|
|
6346
|
+
return stripQueryString(url);
|
|
6347
|
+
}
|
|
6348
|
+
}
|
|
6349
|
+
function stripQueryString(url) {
|
|
6350
|
+
var stripped = url.split('?')[0];
|
|
6351
|
+
return cleanUrl(stripped);
|
|
6352
|
+
}
|
|
6353
|
+
|
|
6087
6354
|
var STANDARD_LICENSES = [
|
|
6088
6355
|
{
|
|
6089
6356
|
type: "CC0-1.0",
|
|
@@ -6380,116 +6647,313 @@
|
|
|
6380
6647
|
}
|
|
6381
6648
|
|
|
6382
6649
|
/**
|
|
6383
|
-
*
|
|
6384
|
-
*
|
|
6385
|
-
*
|
|
6386
|
-
*
|
|
6387
|
-
*
|
|
6388
|
-
*
|
|
6389
|
-
* It's probably a good pattern to add functions here first and then
|
|
6390
|
-
* move them to index.ts only when they are needed by a consumer.
|
|
6650
|
+
* Get the fully qualified URL for an item's thumbnail
|
|
6651
|
+
* @param item w/ id, thumbnail, and access
|
|
6652
|
+
* @param portalUrlOrObject a portal base or API URL, a portal object, or request options containing either of those
|
|
6653
|
+
* @param optionsOrToken options including width and/or token for the current user's session; will only be appended as a query parameter if the item's access is **not** `public`
|
|
6654
|
+
* @returns URL to the item's thumbnail, defaults to `https://www.arcgis.com/sharing/rest/content/items/{item.id}/info/{item.thumbnail}`. Returns `null` if the item does not have a thumbnail assigned.
|
|
6391
6655
|
*/
|
|
6656
|
+
function getItemThumbnailUrl(item, portalUrlOrObject, optionsOrToken) {
|
|
6657
|
+
if (!item || !item.thumbnail) {
|
|
6658
|
+
// TODO: handle image types by returning the image (item data) itself?
|
|
6659
|
+
return null;
|
|
6660
|
+
}
|
|
6661
|
+
// tslint:disable-next-line prefer-const
|
|
6662
|
+
var _a = optionsOrToken || {}, token = _a.token, width = _a.width;
|
|
6663
|
+
// TODO: at the next breaking change drop support for passing token as string
|
|
6664
|
+
if (!token && typeof optionsOrToken === "string") {
|
|
6665
|
+
token = optionsOrToken;
|
|
6666
|
+
}
|
|
6667
|
+
var itemApiUrl = getItemApiUrl(item, portalUrlOrObject, token);
|
|
6668
|
+
var _b = itemApiUrl.split("?"), baseUrl = _b[0], search = _b[1];
|
|
6669
|
+
var searchParams = new URLSearchParams(search);
|
|
6670
|
+
searchParams.delete("f");
|
|
6671
|
+
if (width) {
|
|
6672
|
+
searchParams.append("w", width + "");
|
|
6673
|
+
}
|
|
6674
|
+
var newSearch = searchParams.toString();
|
|
6675
|
+
var url = baseUrl + "/info/" + item.thumbnail;
|
|
6676
|
+
return newSearch ? url + "?" + newSearch : url;
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6679
|
+
// helper fns - move this to _internal if needed elsewhere
|
|
6680
|
+
var getOnlyQueryLayer = function (layers) {
|
|
6681
|
+
var layer = layers && layers.length === 1 && layers[0];
|
|
6682
|
+
return layer && layer.capabilities.includes("Query") && layer;
|
|
6683
|
+
};
|
|
6684
|
+
var shouldUseLayerInfo = function (layer, layers, url) {
|
|
6685
|
+
return (layer &&
|
|
6686
|
+
layers &&
|
|
6687
|
+
layers.length > 1 &&
|
|
6688
|
+
// we use item info instead of layer info for single layer items
|
|
6689
|
+
!getLayerIdFromUrl(url));
|
|
6690
|
+
};
|
|
6392
6691
|
/**
|
|
6393
|
-
*
|
|
6394
|
-
*
|
|
6395
|
-
* @
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6692
|
+
* The possible values for updateFrequency
|
|
6693
|
+
*
|
|
6694
|
+
* @enum {string}
|
|
6695
|
+
*/
|
|
6696
|
+
exports.UpdateFrequency = void 0;
|
|
6697
|
+
(function (UpdateFrequency) {
|
|
6698
|
+
UpdateFrequency["Continual"] = "continual";
|
|
6699
|
+
UpdateFrequency["Daily"] = "daily";
|
|
6700
|
+
UpdateFrequency["Weekly"] = "weekly";
|
|
6701
|
+
UpdateFrequency["Fortnightly"] = "fortnightly";
|
|
6702
|
+
UpdateFrequency["Monthly"] = "monthly";
|
|
6703
|
+
UpdateFrequency["Quarterly"] = "quarterly";
|
|
6704
|
+
UpdateFrequency["Biannually"] = "biannually";
|
|
6705
|
+
UpdateFrequency["Annually"] = "annually";
|
|
6706
|
+
UpdateFrequency["AsNeeded"] = "as-needed";
|
|
6707
|
+
UpdateFrequency["Irregular"] = "irregular";
|
|
6708
|
+
UpdateFrequency["NotPlanned"] = "not-planned";
|
|
6709
|
+
UpdateFrequency["Unknown"] = "unknown";
|
|
6710
|
+
UpdateFrequency["Semimonthly"] = "semimonthly";
|
|
6711
|
+
})(exports.UpdateFrequency || (exports.UpdateFrequency = {}));
|
|
6712
|
+
var getUpdateFrequencyFromMetadata = function (metadata, identifier) {
|
|
6713
|
+
var updateFrequencyMap = {
|
|
6714
|
+
"001": exports.UpdateFrequency.Continual,
|
|
6715
|
+
"002": exports.UpdateFrequency.Daily,
|
|
6716
|
+
"003": exports.UpdateFrequency.Weekly,
|
|
6717
|
+
"004": exports.UpdateFrequency.Fortnightly,
|
|
6718
|
+
"005": exports.UpdateFrequency.Monthly,
|
|
6719
|
+
"006": exports.UpdateFrequency.Quarterly,
|
|
6720
|
+
"007": exports.UpdateFrequency.Biannually,
|
|
6721
|
+
"008": exports.UpdateFrequency.Annually,
|
|
6722
|
+
"009": exports.UpdateFrequency.AsNeeded,
|
|
6723
|
+
"010": exports.UpdateFrequency.Irregular,
|
|
6724
|
+
"011": exports.UpdateFrequency.NotPlanned,
|
|
6725
|
+
"012": exports.UpdateFrequency.Unknown,
|
|
6726
|
+
"013": exports.UpdateFrequency.Semimonthly,
|
|
6727
|
+
};
|
|
6728
|
+
return updateFrequencyMap[getValueFromMetadata(metadata, identifier || "updateFrequency")];
|
|
6405
6729
|
};
|
|
6406
|
-
var
|
|
6407
|
-
var
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
var
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
geometry = null;
|
|
6422
|
-
break;
|
|
6423
|
-
// TODO: handle other provenances
|
|
6424
|
-
}
|
|
6425
|
-
// TODO: derive and return center
|
|
6730
|
+
var getDateInfoFromMetadata = function (metadata, identifier) {
|
|
6731
|
+
var metadataDateInfo = parseISODateString(getValueFromMetadata(metadata, identifier));
|
|
6732
|
+
return (metadataDateInfo && __assign(__assign({}, metadataDateInfo), { source: "metadata." + getMetadataPath(identifier) }));
|
|
6733
|
+
};
|
|
6734
|
+
var getLastEditDateInfo = function (content, layerOrServer) {
|
|
6735
|
+
var source = layerOrServer + ".editingInfo.lastEditDate";
|
|
6736
|
+
var lastEditDate = getProp(content, source);
|
|
6737
|
+
return (lastEditDate && {
|
|
6738
|
+
date: new Date(lastEditDate),
|
|
6739
|
+
source: source,
|
|
6740
|
+
// NOTE: this default was taken from _enrichDates
|
|
6741
|
+
precision: DatePrecision.Day,
|
|
6742
|
+
});
|
|
6743
|
+
};
|
|
6744
|
+
var getItemDateInfo = function (item, createdOrModified) {
|
|
6426
6745
|
return {
|
|
6427
|
-
|
|
6428
|
-
|
|
6746
|
+
date: new Date(item[createdOrModified]),
|
|
6747
|
+
// NOTE: this was set to Day in _enrichDates()
|
|
6748
|
+
// but I wonder if it should be Time instead?
|
|
6749
|
+
precision: DatePrecision.Day,
|
|
6750
|
+
source: "item." + createdOrModified,
|
|
6429
6751
|
};
|
|
6430
6752
|
};
|
|
6431
|
-
var
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
item.access === "public" &&
|
|
6442
|
-
item.type === "CSV" &&
|
|
6443
|
-
item.size <= MAX_SIZE;
|
|
6753
|
+
var getUpdatedDateInfo = function (item, options) {
|
|
6754
|
+
return (
|
|
6755
|
+
// prefer metadata revise date
|
|
6756
|
+
getDateInfoFromMetadata(options.metadata, "reviseDate") ||
|
|
6757
|
+
// then layer last edit date
|
|
6758
|
+
getLastEditDateInfo(options, "layer") ||
|
|
6759
|
+
// then server last edit date
|
|
6760
|
+
getLastEditDateInfo(options, "server") ||
|
|
6761
|
+
// fall back to item modified date
|
|
6762
|
+
getItemDateInfo(item, "modified"));
|
|
6444
6763
|
};
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
}
|
|
6454
|
-
var
|
|
6455
|
-
|
|
6764
|
+
var getPublishedDateInfo = function (item, metadata) {
|
|
6765
|
+
return (
|
|
6766
|
+
// prefer metadata publish date
|
|
6767
|
+
getDateInfoFromMetadata(metadata, "pubDate") ||
|
|
6768
|
+
// then metadata create date
|
|
6769
|
+
getDateInfoFromMetadata(metadata, "createDate") ||
|
|
6770
|
+
// fall back to item created date
|
|
6771
|
+
getItemDateInfo(item, "created"));
|
|
6772
|
+
};
|
|
6773
|
+
var getMetadataUpdatedDateInfo = function (item, metadata) {
|
|
6774
|
+
// prefer date from metadata
|
|
6775
|
+
return (getDateInfoFromMetadata(metadata, "metadataUpdatedDate") ||
|
|
6776
|
+
// default to when the item was last modified
|
|
6777
|
+
getItemDateInfo(item, "modified"));
|
|
6778
|
+
};
|
|
6779
|
+
// public API
|
|
6456
6780
|
/**
|
|
6457
|
-
*
|
|
6458
|
-
*
|
|
6459
|
-
*
|
|
6460
|
-
* getCategory('Feature Layer')
|
|
6461
|
-
* > 'dataset'
|
|
6462
|
-
* ```
|
|
6463
|
-
* **DEPRECATED: Use getCollection() instead**
|
|
6464
|
-
* returns the Hub category for a given item type
|
|
6465
|
-
* @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
|
|
6466
|
-
* @returns the category of a given item type.
|
|
6781
|
+
* DEPRECATED: Compute the content type icon based on the content type
|
|
6782
|
+
* @param content type
|
|
6783
|
+
* @returns content type icon
|
|
6467
6784
|
*/
|
|
6468
|
-
function
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6785
|
+
var getContentTypeIcon = function (contentType) {
|
|
6786
|
+
var _a;
|
|
6787
|
+
var type = camelize(contentType || "");
|
|
6788
|
+
var iconMap = {
|
|
6789
|
+
appbuilderExtension: "file",
|
|
6790
|
+
appbuilderWidgetPackage: "widgets-source",
|
|
6791
|
+
application: "web",
|
|
6792
|
+
applicationConfiguration: "app-gear",
|
|
6793
|
+
arcgisProMap: "desktop",
|
|
6794
|
+
cadDrawing: "file-cad",
|
|
6795
|
+
cityEngineWebScene: "urban-model",
|
|
6796
|
+
codeAttachment: "file-code",
|
|
6797
|
+
codeSample: "file-code",
|
|
6798
|
+
colorSet: "palette",
|
|
6799
|
+
contentCategorySet: "label",
|
|
6800
|
+
csv: "file-csv",
|
|
6801
|
+
cSV: "file-csv",
|
|
6802
|
+
cSVCollection: "file-csv",
|
|
6803
|
+
dashboard: "dashboard",
|
|
6804
|
+
desktopApplication: "desktop",
|
|
6805
|
+
documentLink: "link",
|
|
6806
|
+
excaliburImageryProject: "file",
|
|
6807
|
+
explorerMap: "file",
|
|
6808
|
+
exportPackage: "file",
|
|
6809
|
+
featureCollection: "data",
|
|
6810
|
+
featureCollectionTemplate: "file",
|
|
6811
|
+
featureLayer: "data",
|
|
6812
|
+
featureService: "collection",
|
|
6813
|
+
fileGeodatabase: "data",
|
|
6814
|
+
form: "survey",
|
|
6815
|
+
geocodingService: "file",
|
|
6816
|
+
geodataService: "file",
|
|
6817
|
+
geometryService: "file",
|
|
6818
|
+
geopackage: "file",
|
|
6819
|
+
geoprocessingService: "file",
|
|
6820
|
+
globeLayer: "layers",
|
|
6821
|
+
globeService: "file",
|
|
6822
|
+
hubInitiative: "initiative",
|
|
6823
|
+
hubInitiativeTemplate: "initiative-template",
|
|
6824
|
+
hubPage: "browser",
|
|
6825
|
+
hubSiteApplication: "web",
|
|
6826
|
+
image: "file-image",
|
|
6827
|
+
imageService: "data",
|
|
6828
|
+
insightsModel: "file",
|
|
6829
|
+
insightsPage: "graph-moving-average",
|
|
6830
|
+
insightsTheme: "palette",
|
|
6831
|
+
insightsWorkbook: "graph-moving-average",
|
|
6832
|
+
iWorkPages: "file-text",
|
|
6833
|
+
iWorkKeynote: "presentation",
|
|
6834
|
+
iWorkNumbers: "file-report",
|
|
6835
|
+
kML: "data",
|
|
6836
|
+
kMLCollection: "data",
|
|
6837
|
+
layer: "layers",
|
|
6838
|
+
layerPackage: "layers",
|
|
6839
|
+
layerTemplate: "file",
|
|
6840
|
+
locatorPackage: "file",
|
|
6841
|
+
mapArea: "file",
|
|
6842
|
+
mapDocument: "map-contents",
|
|
6843
|
+
mapImageLayer: "collection",
|
|
6844
|
+
mapPackage: "file",
|
|
6845
|
+
mapService: "collection",
|
|
6846
|
+
microsoftExcel: "file-report",
|
|
6847
|
+
microsoftPowerpoint: "presentation",
|
|
6848
|
+
microsoftWord: "file-text",
|
|
6849
|
+
mission: "file",
|
|
6850
|
+
mobileMapPackage: "map-contents",
|
|
6851
|
+
nativeApplication: "mobile",
|
|
6852
|
+
nativeApplicationInstaller: "file",
|
|
6853
|
+
nativeApplicationTemplate: "file",
|
|
6854
|
+
mobileApplication: "mobile",
|
|
6855
|
+
networkAnalysisService: "file",
|
|
6856
|
+
notebook: "code",
|
|
6857
|
+
orientedImageryCatalog: "file",
|
|
6858
|
+
orthoMappingProject: "file",
|
|
6859
|
+
orthoMappingTemplate: "file",
|
|
6860
|
+
pDF: "file-pdf",
|
|
6861
|
+
quickCaptureProject: "mobile",
|
|
6862
|
+
rasterFunctionTemplate: "file",
|
|
6863
|
+
rasterLayer: "map",
|
|
6864
|
+
realTimeAnalytic: "file",
|
|
6865
|
+
relationalDatabaseConnection: "file",
|
|
6866
|
+
reportTemplate: "file",
|
|
6867
|
+
sceneLayer: "data",
|
|
6868
|
+
sceneService: "urban-model",
|
|
6869
|
+
serviceDefinition: "file",
|
|
6870
|
+
shapefile: "data",
|
|
6871
|
+
solution: "puzzle-piece",
|
|
6872
|
+
sqliteGeodatabase: "file",
|
|
6873
|
+
statisticalDataCollection: "file",
|
|
6874
|
+
storymap: "tour",
|
|
6875
|
+
storyMap: "tour",
|
|
6876
|
+
storymapTheme: "palette",
|
|
6877
|
+
symbolSet: "file",
|
|
6878
|
+
table: "table",
|
|
6879
|
+
urbanModel: "urban-model",
|
|
6880
|
+
vectorTilePackage: "file-shape",
|
|
6881
|
+
vectorTileService: "map",
|
|
6882
|
+
visioDocument: "conditional-rules",
|
|
6883
|
+
webExperience: "apps",
|
|
6884
|
+
webMap: "map",
|
|
6885
|
+
webMappingApplication: "apps",
|
|
6886
|
+
webScene: "urban-model",
|
|
6887
|
+
wfs: "map",
|
|
6888
|
+
wFS: "map",
|
|
6889
|
+
wMS: "map",
|
|
6890
|
+
wMTS: "map",
|
|
6891
|
+
workflowManagerService: "file",
|
|
6892
|
+
workforceProject: "list-check",
|
|
6893
|
+
};
|
|
6894
|
+
return (_a = iconMap[type]) !== null && _a !== void 0 ? _a : "file";
|
|
6895
|
+
};
|
|
6896
|
+
/**
|
|
6897
|
+
* get portal URLs (home, API, data, and thumbnail) for an item
|
|
6898
|
+
*
|
|
6899
|
+
* @param item Item
|
|
6900
|
+
* @param requestOptions Request options
|
|
6901
|
+
* @returns a hash with the portal URLs
|
|
6902
|
+
* @export
|
|
6488
6903
|
*/
|
|
6489
|
-
function
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6904
|
+
var getPortalUrls = function (item, requestOptions) {
|
|
6905
|
+
var authentication = requestOptions.authentication;
|
|
6906
|
+
var token = authentication && authentication.token;
|
|
6907
|
+
// add properties that depend on portal
|
|
6908
|
+
var portalHome = getItemHomeUrl(item.id, requestOptions);
|
|
6909
|
+
// the URL of the item's Portal API end point
|
|
6910
|
+
var portalApi = getItemApiUrl(item, requestOptions, token);
|
|
6911
|
+
// the URL of the item's data API end point
|
|
6912
|
+
var portalData = getItemDataUrl(item, requestOptions, token);
|
|
6913
|
+
// the full URL of the thumbnail
|
|
6914
|
+
var thumbnail = getItemThumbnailUrl(item, requestOptions, {
|
|
6915
|
+
token: token,
|
|
6916
|
+
});
|
|
6917
|
+
return {
|
|
6918
|
+
portalHome: portalHome,
|
|
6919
|
+
portalApi: portalApi,
|
|
6920
|
+
portalData: portalData,
|
|
6921
|
+
thumbnail: thumbnail,
|
|
6922
|
+
};
|
|
6923
|
+
};
|
|
6924
|
+
/**
|
|
6925
|
+
* If an item is a proxied csv, returns the url for the proxying feature layer.
|
|
6926
|
+
* If the item is not a proxied csv, returns undefined.
|
|
6927
|
+
*
|
|
6928
|
+
* @param item
|
|
6929
|
+
* @param requestOptions Hub Request Options (including whether we're in portal)
|
|
6930
|
+
* @returns
|
|
6931
|
+
*/
|
|
6932
|
+
var getProxyUrl = function (item, requestOptions) {
|
|
6933
|
+
var result;
|
|
6934
|
+
if (isProxiedCSV(item, requestOptions)) {
|
|
6935
|
+
result = getHubApiUrl(requestOptions) + "/datasets/" + item.id + "_0/FeatureServer/0";
|
|
6936
|
+
}
|
|
6937
|
+
return result;
|
|
6938
|
+
};
|
|
6939
|
+
/**
|
|
6940
|
+
* parse layer id from a service URL
|
|
6941
|
+
* @param {string} url
|
|
6942
|
+
* @returns {string} layer id
|
|
6943
|
+
*/
|
|
6944
|
+
var getLayerIdFromUrl = function (url) {
|
|
6945
|
+
var endsWithNumberSegmentRegEx = /\/\d+$/;
|
|
6946
|
+
var matched = url && url.match(endsWithNumberSegmentRegEx);
|
|
6947
|
+
return matched && matched[0].slice(1);
|
|
6948
|
+
};
|
|
6949
|
+
/**
|
|
6950
|
+
* Case-insensitive check if the type is "Feature Service"
|
|
6951
|
+
* @param {string} type - item's type
|
|
6952
|
+
* @returns {boolean}
|
|
6953
|
+
*/
|
|
6954
|
+
var isFeatureService = function (type) {
|
|
6955
|
+
return type && type.toLowerCase() === "feature service";
|
|
6956
|
+
};
|
|
6493
6957
|
/**
|
|
6494
6958
|
* ```js
|
|
6495
6959
|
* import { normalizeItemType } from "@esri/hub-common";
|
|
@@ -6525,76 +6989,6 @@
|
|
|
6525
6989
|
}
|
|
6526
6990
|
return ret;
|
|
6527
6991
|
}
|
|
6528
|
-
/**
|
|
6529
|
-
* ```js
|
|
6530
|
-
* import { getTypeCategories } from "@esri/hub-common";
|
|
6531
|
-
* //
|
|
6532
|
-
* getTypeCategories(item)
|
|
6533
|
-
* > [ 'Hub Site Application' ]
|
|
6534
|
-
* ```
|
|
6535
|
-
* @param item Item object.
|
|
6536
|
-
* @returns typeCategory of the input item.
|
|
6537
|
-
*
|
|
6538
|
-
*/
|
|
6539
|
-
function getTypeCategories(item) {
|
|
6540
|
-
if (item === void 0) { item = {}; }
|
|
6541
|
-
var type = normalizeItemType(item);
|
|
6542
|
-
var category = getCategory(type);
|
|
6543
|
-
if (category) {
|
|
6544
|
-
// upper case first letter and return as element in array for backwards compatibility
|
|
6545
|
-
var chars = Array.from(category);
|
|
6546
|
-
chars[0] = chars[0].toUpperCase();
|
|
6547
|
-
return [chars.join("")];
|
|
6548
|
-
}
|
|
6549
|
-
else {
|
|
6550
|
-
return ["Other"];
|
|
6551
|
-
}
|
|
6552
|
-
}
|
|
6553
|
-
/**
|
|
6554
|
-
* ```js
|
|
6555
|
-
* import { getCollection } from "@esri/hub-common";
|
|
6556
|
-
* //
|
|
6557
|
-
* getCollection('Feature Layer')
|
|
6558
|
-
* > 'dataset'
|
|
6559
|
-
* ```
|
|
6560
|
-
* Get the Hub collection for a given item type
|
|
6561
|
-
* @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
|
|
6562
|
-
* @returns the Hub collection of a given item type.
|
|
6563
|
-
*/
|
|
6564
|
-
function getCollection(itemType) {
|
|
6565
|
-
if (itemType === void 0) { itemType = ""; }
|
|
6566
|
-
if (cache[itemType]) {
|
|
6567
|
-
return cache[itemType];
|
|
6568
|
-
}
|
|
6569
|
-
for (var _i = 0, _a = Object.keys(collections); _i < _a.length; _i++) {
|
|
6570
|
-
var collection = _a[_i];
|
|
6571
|
-
for (var _b = 0, _c = collections[collection]; _b < _c.length; _b++) {
|
|
6572
|
-
var type = _c[_b];
|
|
6573
|
-
if (itemType.toLowerCase() === type.toLowerCase()) {
|
|
6574
|
-
cache[itemType] = collection;
|
|
6575
|
-
return collection;
|
|
6576
|
-
}
|
|
6577
|
-
}
|
|
6578
|
-
}
|
|
6579
|
-
}
|
|
6580
|
-
/**
|
|
6581
|
-
* Case-insensitive check if the type is "Feature Service"
|
|
6582
|
-
* @param {string} type - item's type
|
|
6583
|
-
* @returns {boolean}
|
|
6584
|
-
*/
|
|
6585
|
-
var isFeatureService = function (type) {
|
|
6586
|
-
return type && type.toLowerCase() === "feature service";
|
|
6587
|
-
};
|
|
6588
|
-
/**
|
|
6589
|
-
* parse layer id from a service URL
|
|
6590
|
-
* @param {string} url
|
|
6591
|
-
* @returns {string} layer id
|
|
6592
|
-
*/
|
|
6593
|
-
var getLayerIdFromUrl = function (url) {
|
|
6594
|
-
var endsWithNumberSegmentRegEx = /\/\d+$/;
|
|
6595
|
-
var matched = url && url.match(endsWithNumberSegmentRegEx);
|
|
6596
|
-
return matched && matched[0].slice(1);
|
|
6597
|
-
};
|
|
6598
6992
|
/**
|
|
6599
6993
|
* return the layerId if we can tell that item is a single layer service
|
|
6600
6994
|
* @param {*} item from AGO
|
|
@@ -6606,6 +7000,7 @@
|
|
|
6606
7000
|
// but have not verified that, nor that we should alway return '0' in that case
|
|
6607
7001
|
return (getLayerIdFromUrl(item.url) ||
|
|
6608
7002
|
(isFeatureService(item.type) &&
|
|
7003
|
+
item.typeKeywords &&
|
|
6609
7004
|
includes(item.typeKeywords, "Singlelayer") &&
|
|
6610
7005
|
"0"));
|
|
6611
7006
|
};
|
|
@@ -6623,6 +7018,313 @@
|
|
|
6623
7018
|
var layerId = getItemLayerId(item);
|
|
6624
7019
|
return layerId ? id + "_" + layerId : id;
|
|
6625
7020
|
};
|
|
7021
|
+
/**
|
|
7022
|
+
* Splits item category strings at slashes and discards the "Categories" keyword
|
|
7023
|
+
*
|
|
7024
|
+
* ```
|
|
7025
|
+
* ["/Categories/Boundaries", "/Categories/Planning and cadastre/Property records", "/Categories/Structure"]
|
|
7026
|
+
* ```
|
|
7027
|
+
* Should end up being
|
|
7028
|
+
* ```
|
|
7029
|
+
* ["Boundaries", "Planning and cadastre", "Property records", "Structure"]
|
|
7030
|
+
* ```
|
|
7031
|
+
*
|
|
7032
|
+
* @param categories - an array of strings
|
|
7033
|
+
* @private
|
|
7034
|
+
*/
|
|
7035
|
+
function parseItemCategories(categories) {
|
|
7036
|
+
if (!categories)
|
|
7037
|
+
return categories;
|
|
7038
|
+
var exclude = ["categories", ""];
|
|
7039
|
+
var parsed = categories.map(function (cat) { return cat.split("/"); });
|
|
7040
|
+
var flattened = parsed.reduce(function (acc, arr, _) { return __spreadArrays(acc, arr); }, []);
|
|
7041
|
+
return flattened.filter(function (cat) { return !includes(exclude, cat.toLowerCase()); });
|
|
7042
|
+
}
|
|
7043
|
+
/**
|
|
7044
|
+
* Compose a new content object out of an item, enrichments, and context
|
|
7045
|
+
* @param item
|
|
7046
|
+
* @param options any enrichments, current state (selected layerId), or context (requestOptions)
|
|
7047
|
+
* @returns new content object
|
|
7048
|
+
*/
|
|
7049
|
+
var composeContent = function (item, options) {
|
|
7050
|
+
// extract enrichments and context out of the options
|
|
7051
|
+
var _a = options || {}, slug = _a.slug, requestOptions = _a.requestOptions, data = _a.data, metadata = _a.metadata, groupIds = _a.groupIds, ownerUser = _a.ownerUser, org = _a.org, errors = _a.errors, server = _a.server, layers = _a.layers, recordCount = _a.recordCount, boundary = _a.boundary, statistics = _a.statistics;
|
|
7052
|
+
// set common variables that we will use in the derived properties below
|
|
7053
|
+
// if item refers to a layer we always want to use that layer id
|
|
7054
|
+
// otherwise use the layer id that was passed in (if any)
|
|
7055
|
+
var _layerIdFromUrl = getLayerIdFromUrl(item.url);
|
|
7056
|
+
var layerId = _layerIdFromUrl
|
|
7057
|
+
? parseInt(_layerIdFromUrl, 10)
|
|
7058
|
+
: options === null || options === void 0 ? void 0 : options.layerId;
|
|
7059
|
+
var layer = layers &&
|
|
7060
|
+
(!isNil(layerId)
|
|
7061
|
+
? // find the explicitly set layer id
|
|
7062
|
+
layers.find(function (_layer) { return _layer.id === layerId; })
|
|
7063
|
+
: // for feature servers with a single layer always show the layer
|
|
7064
|
+
isFeatureService(item.type) && getOnlyQueryLayer(layers));
|
|
7065
|
+
// NOTE: we only set hubId for public items in online
|
|
7066
|
+
var _canUseHubApi = !isPortal(requestOptions) && item.access === "public";
|
|
7067
|
+
var hubId = _canUseHubApi
|
|
7068
|
+
? layer
|
|
7069
|
+
? item.id + "_" + layer.id
|
|
7070
|
+
: getItemHubId(item)
|
|
7071
|
+
: undefined;
|
|
7072
|
+
var identifier = slug || hubId || item.id;
|
|
7073
|
+
// whether or not we should show layer info for name, description, etc
|
|
7074
|
+
var _shouldUseLayerInfo = shouldUseLayerInfo(layer, layers, item.url);
|
|
7075
|
+
var name = _shouldUseLayerInfo ? layer.name : item.title;
|
|
7076
|
+
var _layerDescription = _shouldUseLayerInfo && layer.description;
|
|
7077
|
+
// so much depends on type
|
|
7078
|
+
var type = layer
|
|
7079
|
+
? // use layer type (Feature Layer, Table, etc) for layer content
|
|
7080
|
+
layer.type
|
|
7081
|
+
: // otherwise use the normalized item type
|
|
7082
|
+
normalizeItemType(item);
|
|
7083
|
+
// all the urls
|
|
7084
|
+
var urls = __assign({ relative: getHubRelativeUrl(type, identifier, item.typeKeywords) }, (requestOptions && getPortalUrls(item, requestOptions)));
|
|
7085
|
+
var _proxyUrl = getProxyUrl(item, requestOptions);
|
|
7086
|
+
// NOTE: I'd rather not compute these date values up front,
|
|
7087
|
+
// but they are used by several getters below, so we do it here only once
|
|
7088
|
+
var _updatedDateInfo = getUpdatedDateInfo(item, {
|
|
7089
|
+
metadata: metadata,
|
|
7090
|
+
layer: layer,
|
|
7091
|
+
server: server,
|
|
7092
|
+
});
|
|
7093
|
+
var _publishedDateInfo = getPublishedDateInfo(item, metadata);
|
|
7094
|
+
var _metadataUpdatedDateInfo = getMetadataUpdatedDateInfo(item, metadata);
|
|
7095
|
+
// return all of the above composed into a content object
|
|
7096
|
+
return __assign(__assign({
|
|
7097
|
+
// a reference to underlying item
|
|
7098
|
+
item: item }, item), {
|
|
7099
|
+
// item enrichments
|
|
7100
|
+
slug: slug,
|
|
7101
|
+
data: data,
|
|
7102
|
+
metadata: metadata,
|
|
7103
|
+
groupIds: groupIds,
|
|
7104
|
+
ownerUser: ownerUser,
|
|
7105
|
+
org: org, errors: errors || [],
|
|
7106
|
+
// server enrichments
|
|
7107
|
+
server: server,
|
|
7108
|
+
layers: layers,
|
|
7109
|
+
recordCount: recordCount,
|
|
7110
|
+
// enrichments from the Hub API (boundary is below)
|
|
7111
|
+
statistics: statistics,
|
|
7112
|
+
// derived properties
|
|
7113
|
+
// NOTE: in the getters below you can **not** use `this`
|
|
7114
|
+
// these are not meant to provide live updating computed props
|
|
7115
|
+
// their purpose is to avoid computing all these values above
|
|
7116
|
+
// especially where we want to defer computation of less used props
|
|
7117
|
+
hubId: hubId,
|
|
7118
|
+
identifier: identifier, get isProxied() {
|
|
7119
|
+
return !!_proxyUrl;
|
|
7120
|
+
}, layer: layer,
|
|
7121
|
+
name: name, get title() {
|
|
7122
|
+
return name;
|
|
7123
|
+
},
|
|
7124
|
+
get description() {
|
|
7125
|
+
return _layerDescription || item.description;
|
|
7126
|
+
}, type: type, get family() {
|
|
7127
|
+
return getFamily(type);
|
|
7128
|
+
}, get url() {
|
|
7129
|
+
return _proxyUrl
|
|
7130
|
+
? _proxyUrl
|
|
7131
|
+
: _shouldUseLayerInfo
|
|
7132
|
+
? parseServiceUrl(item.url) + "/" + layer.id
|
|
7133
|
+
: item.url;
|
|
7134
|
+
}, get categories() {
|
|
7135
|
+
return parseItemCategories(item.categories);
|
|
7136
|
+
},
|
|
7137
|
+
get actionLinks() {
|
|
7138
|
+
return item.properties && item.properties.links;
|
|
7139
|
+
},
|
|
7140
|
+
get hubActions() {
|
|
7141
|
+
return item.properties && item.properties.actions;
|
|
7142
|
+
},
|
|
7143
|
+
get isDownloadable() {
|
|
7144
|
+
return isDownloadable(item);
|
|
7145
|
+
},
|
|
7146
|
+
get structuredLicense() {
|
|
7147
|
+
return getStructuredLicense(item.licenseInfo);
|
|
7148
|
+
},
|
|
7149
|
+
get permissions() {
|
|
7150
|
+
return {
|
|
7151
|
+
visibility: item.access,
|
|
7152
|
+
control: item.itemControl || "view",
|
|
7153
|
+
};
|
|
7154
|
+
},
|
|
7155
|
+
get boundary() {
|
|
7156
|
+
// TODO: need to be able to handle automatic w/ additional enrichment
|
|
7157
|
+
// that could for example fetch the concave hull from the Hub API or resources
|
|
7158
|
+
return boundary || getContentBoundary(item);
|
|
7159
|
+
},
|
|
7160
|
+
get summary() {
|
|
7161
|
+
return _layerDescription
|
|
7162
|
+
? _layerDescription
|
|
7163
|
+
: // TODO: this should use the logic for the Hub API's searchDescription
|
|
7164
|
+
// see: https://github.com/ArcGIS/hub-indexer/blob/b352cfded8221a967ac80447879d493db6476d7a/packages/duke/compose/dataset.js#L238-L250
|
|
7165
|
+
// TODO: can we strip HTML from description, and do we need to trim it to a X chars?
|
|
7166
|
+
item.snippet || item.description;
|
|
7167
|
+
}, urls: urls, get portalHomeUrl() {
|
|
7168
|
+
return urls.portalHome;
|
|
7169
|
+
},
|
|
7170
|
+
get portalDataUrl() {
|
|
7171
|
+
return urls.portalData;
|
|
7172
|
+
},
|
|
7173
|
+
get portalApiUrl() {
|
|
7174
|
+
return urls.portalApi;
|
|
7175
|
+
},
|
|
7176
|
+
get thumbnailUrl() {
|
|
7177
|
+
return urls.thumbnail;
|
|
7178
|
+
},
|
|
7179
|
+
/** The date the item was created */
|
|
7180
|
+
get createdDate() {
|
|
7181
|
+
return new Date(item.created);
|
|
7182
|
+
}, createdDateSource: "item.created", get updatedDate() {
|
|
7183
|
+
return _updatedDateInfo.date;
|
|
7184
|
+
},
|
|
7185
|
+
get updatedDateSource() {
|
|
7186
|
+
return _updatedDateInfo.source;
|
|
7187
|
+
},
|
|
7188
|
+
get updatedDatePrecision() {
|
|
7189
|
+
return _updatedDateInfo.precision;
|
|
7190
|
+
},
|
|
7191
|
+
get modified() {
|
|
7192
|
+
return _updatedDateInfo.date.getTime();
|
|
7193
|
+
},
|
|
7194
|
+
get publishedDate() {
|
|
7195
|
+
return _publishedDateInfo.date;
|
|
7196
|
+
},
|
|
7197
|
+
get publishedDateSource() {
|
|
7198
|
+
return _publishedDateInfo.source;
|
|
7199
|
+
},
|
|
7200
|
+
get publishedDatePrecision() {
|
|
7201
|
+
return _publishedDateInfo.precision;
|
|
7202
|
+
},
|
|
7203
|
+
get metadataUpdatedDate() {
|
|
7204
|
+
return _metadataUpdatedDateInfo.date;
|
|
7205
|
+
},
|
|
7206
|
+
get metadataUpdatedDateSource() {
|
|
7207
|
+
return _metadataUpdatedDateInfo.source;
|
|
7208
|
+
},
|
|
7209
|
+
get metadataUpdatedDatePrecision() {
|
|
7210
|
+
return _metadataUpdatedDateInfo.precision;
|
|
7211
|
+
},
|
|
7212
|
+
get updateFrequency() {
|
|
7213
|
+
return getUpdateFrequencyFromMetadata(metadata);
|
|
7214
|
+
},
|
|
7215
|
+
get metadataUpdateFrequency() {
|
|
7216
|
+
return getUpdateFrequencyFromMetadata(metadata, "metadataUpdateFrequency");
|
|
7217
|
+
},
|
|
7218
|
+
// TODO: add the publisher logic outlined here:
|
|
7219
|
+
// https://devtopia.esri.com/dc/hub/issues/2932#issuecomment-3276309
|
|
7220
|
+
get publisher() {
|
|
7221
|
+
return {
|
|
7222
|
+
name: item.owner,
|
|
7223
|
+
username: item.owner,
|
|
7224
|
+
};
|
|
7225
|
+
},
|
|
7226
|
+
// TODO: is metrics in use?
|
|
7227
|
+
get metrics() {
|
|
7228
|
+
return item.properties && item.properties.metrics;
|
|
7229
|
+
},
|
|
7230
|
+
get spatialReference() {
|
|
7231
|
+
// NOTE: I had to add || null just so packages/content/test/portal.test.ts would pass
|
|
7232
|
+
// we can remove that when that package is deprecated
|
|
7233
|
+
return (getItemSpatialReference(item) ||
|
|
7234
|
+
getServerSpatialReference(server, layer) ||
|
|
7235
|
+
null);
|
|
7236
|
+
},
|
|
7237
|
+
get orgId() {
|
|
7238
|
+
// NOTE: it's undocumented, but the portal API will return orgId for items... sometimes
|
|
7239
|
+
return org ? org.id : item.orgId;
|
|
7240
|
+
},
|
|
7241
|
+
// deprecated properties
|
|
7242
|
+
// TODO: should we add these in legacy wrappers
|
|
7243
|
+
// like itemToContent or datasetToContent instead?
|
|
7244
|
+
get contentTypeIcon() {
|
|
7245
|
+
/* tslint:disable no-console */
|
|
7246
|
+
console.warn(
|
|
7247
|
+
/* tslint:enable no-console */
|
|
7248
|
+
"DEPRECATED: it is now the responsibility of the consuming package to determine the icon");
|
|
7249
|
+
return getContentTypeIcon(type);
|
|
7250
|
+
},
|
|
7251
|
+
get license() {
|
|
7252
|
+
/* tslint:disable no-console */
|
|
7253
|
+
console.warn("DEPRECATED: use structuredLicense instead");
|
|
7254
|
+
/* tslint:enable no-console */
|
|
7255
|
+
return { name: "Custom License", description: item.accessInformation };
|
|
7256
|
+
},
|
|
7257
|
+
get hubType() {
|
|
7258
|
+
/* tslint:disable no-console */
|
|
7259
|
+
console.warn("DEPRECATED: use family instead");
|
|
7260
|
+
/* tslint:enable no-console */
|
|
7261
|
+
return getFamily(type);
|
|
7262
|
+
} });
|
|
7263
|
+
};
|
|
7264
|
+
|
|
7265
|
+
// TODO: remove this at next breaking version
|
|
7266
|
+
/**
|
|
7267
|
+
* ```js
|
|
7268
|
+
* import { getCategory } from "@esri/hub-common";
|
|
7269
|
+
* //
|
|
7270
|
+
* getCategory('Feature Layer')
|
|
7271
|
+
* > 'dataset'
|
|
7272
|
+
* ```
|
|
7273
|
+
* **DEPRECATED: Use getCollection() instead**
|
|
7274
|
+
* returns the Hub category for a given item type
|
|
7275
|
+
* @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
|
|
7276
|
+
* @returns the category of a given item type.
|
|
7277
|
+
*/
|
|
7278
|
+
function getCategory(itemType) {
|
|
7279
|
+
if (itemType === void 0) { itemType = ""; }
|
|
7280
|
+
/* tslint:disable no-console */
|
|
7281
|
+
console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v10.0.0");
|
|
7282
|
+
/* tslint:enable no-console */
|
|
7283
|
+
var collection = getCollection(itemType);
|
|
7284
|
+
// for backwards compatibility
|
|
7285
|
+
return collection === "feedback" ? "app" : collection;
|
|
7286
|
+
}
|
|
7287
|
+
/**
|
|
7288
|
+
* ```js
|
|
7289
|
+
* import { getTypes } from "@esri/hub-common";
|
|
7290
|
+
* //
|
|
7291
|
+
* getTypes('site')
|
|
7292
|
+
* > [ 'hub site application' ]
|
|
7293
|
+
* ```
|
|
7294
|
+
* To do.
|
|
7295
|
+
* @param category The ArcGIS Hub category.
|
|
7296
|
+
* @returns all the item types for the given category.
|
|
7297
|
+
*
|
|
7298
|
+
*/
|
|
7299
|
+
function getTypes(category) {
|
|
7300
|
+
if (category === void 0) { category = ""; }
|
|
7301
|
+
return categories[category.toLowerCase()];
|
|
7302
|
+
}
|
|
7303
|
+
/**
|
|
7304
|
+
* ```js
|
|
7305
|
+
* import { getTypeCategories } from "@esri/hub-common";
|
|
7306
|
+
* //
|
|
7307
|
+
* getTypeCategories(item)
|
|
7308
|
+
* > [ 'Hub Site Application' ]
|
|
7309
|
+
* ```
|
|
7310
|
+
* @param item Item object.
|
|
7311
|
+
* @returns typeCategory of the input item.
|
|
7312
|
+
*
|
|
7313
|
+
*/
|
|
7314
|
+
function getTypeCategories(item) {
|
|
7315
|
+
if (item === void 0) { item = {}; }
|
|
7316
|
+
var type = normalizeItemType(item);
|
|
7317
|
+
var category = getCategory(type);
|
|
7318
|
+
if (category) {
|
|
7319
|
+
// upper case first letter and return as element in array for backwards compatibility
|
|
7320
|
+
var chars = Array.from(category);
|
|
7321
|
+
chars[0] = chars[0].toUpperCase();
|
|
7322
|
+
return [chars.join("")];
|
|
7323
|
+
}
|
|
7324
|
+
else {
|
|
7325
|
+
return ["Other"];
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
6626
7328
|
/**
|
|
6627
7329
|
* ```js
|
|
6628
7330
|
* import { getContentIdentifier } from "@esri/hub-common";
|
|
@@ -6652,7 +7354,7 @@
|
|
|
6652
7354
|
// site data instead. Because this one is the original one that was used
|
|
6653
7355
|
// to create the page url (not mutable once created) and the slug (below)
|
|
6654
7356
|
// generated by the hub-indexer could simply change with page name.
|
|
6655
|
-
if (
|
|
7357
|
+
if (isPageType(content.type)) {
|
|
6656
7358
|
// check if the page is linked to the current site
|
|
6657
7359
|
var pages = getProp(site, "data.values.pages") || [];
|
|
6658
7360
|
// if so, return the page slug otherwise the page id
|
|
@@ -6736,60 +7438,6 @@
|
|
|
6736
7438
|
return slug;
|
|
6737
7439
|
}
|
|
6738
7440
|
}
|
|
6739
|
-
/**
|
|
6740
|
-
* Splits item category strings at slashes and discards the "Categories" keyword
|
|
6741
|
-
*
|
|
6742
|
-
* ```
|
|
6743
|
-
* ["/Categories/Boundaries", "/Categories/Planning and cadastre/Property records", "/Categories/Structure"]
|
|
6744
|
-
* ```
|
|
6745
|
-
* Should end up being
|
|
6746
|
-
* ```
|
|
6747
|
-
* ["Boundaries", "Planning and cadastre", "Property records", "Structure"]
|
|
6748
|
-
* ```
|
|
6749
|
-
*
|
|
6750
|
-
* @param categories - an array of strings
|
|
6751
|
-
* @private
|
|
6752
|
-
*/
|
|
6753
|
-
function parseItemCategories(categories) {
|
|
6754
|
-
if (!categories)
|
|
6755
|
-
return categories;
|
|
6756
|
-
var exclude = ["categories", ""];
|
|
6757
|
-
var parsed = categories.map(function (cat) { return cat.split("/"); });
|
|
6758
|
-
var flattened = parsed.reduce(function (acc, arr, _) { return __spreadArrays(acc, arr); }, []);
|
|
6759
|
-
return flattened.filter(function (cat) { return !includes(exclude, cat.toLowerCase()); });
|
|
6760
|
-
}
|
|
6761
|
-
/**
|
|
6762
|
-
* return the Hub family given an item's type
|
|
6763
|
-
* @param type item type
|
|
6764
|
-
* @returns Hub family
|
|
6765
|
-
*/
|
|
6766
|
-
function getFamily(type) {
|
|
6767
|
-
var family;
|
|
6768
|
-
// override default behavior for the rows that are highlighted in yellow here:
|
|
6769
|
-
// https://esriis.sharepoint.com/:x:/r/sites/ArcGISHub/_layouts/15/Doc.aspx?sourcedoc=%7BADA1C9DC-4F6C-4DE4-92C6-693EF9571CFA%7D&file=Hub%20Routes.xlsx&nav=MTBfe0VENEREQzI4LUZFMDctNEI0Ri04NjcyLThCQUE2MTA0MEZGRn1fezIwMTIwMEJFLTA4MEQtNEExRC05QzA4LTE5MTAzOUQwMEE1RH0&action=default&mobileredirect=true&cid=df1c874b-c367-4cea-bc13-7bebfad3f2ac
|
|
6770
|
-
switch ((type || "").toLowerCase()) {
|
|
6771
|
-
case "image service":
|
|
6772
|
-
family = "dataset";
|
|
6773
|
-
break;
|
|
6774
|
-
case "feature service":
|
|
6775
|
-
case "raster layer":
|
|
6776
|
-
// TODO: check if feature service has > 1 layer first?
|
|
6777
|
-
family = "map";
|
|
6778
|
-
break;
|
|
6779
|
-
case "microsoft excel":
|
|
6780
|
-
family = "document";
|
|
6781
|
-
break;
|
|
6782
|
-
case "cad drawing":
|
|
6783
|
-
case "feature collection template":
|
|
6784
|
-
case "report template":
|
|
6785
|
-
family = "content";
|
|
6786
|
-
break;
|
|
6787
|
-
default:
|
|
6788
|
-
// by default derive from collection
|
|
6789
|
-
family = collectionToFamily(getCollection(type));
|
|
6790
|
-
}
|
|
6791
|
-
return family;
|
|
6792
|
-
}
|
|
6793
7441
|
/**
|
|
6794
7442
|
* DEPRECATED: Use getFamily() instead.
|
|
6795
7443
|
*
|
|
@@ -6816,51 +7464,7 @@
|
|
|
6816
7464
|
* @export
|
|
6817
7465
|
*/
|
|
6818
7466
|
function itemToContent(item) {
|
|
6819
|
-
|
|
6820
|
-
var createdDateSource = "item.created";
|
|
6821
|
-
var properties = item.properties;
|
|
6822
|
-
var content = Object.assign({}, item, {
|
|
6823
|
-
identifier: item.id,
|
|
6824
|
-
// no server errors when fetching the item directly
|
|
6825
|
-
errors: [],
|
|
6826
|
-
// store a reference to the item
|
|
6827
|
-
item: item,
|
|
6828
|
-
// NOTE: this will overwrite any existing item.name, which is
|
|
6829
|
-
// The file name of the item for file types. Read-only.
|
|
6830
|
-
// presumably there to use as the default file name when downloading
|
|
6831
|
-
// we don't store item.name in the Hub API and we use name for title
|
|
6832
|
-
name: item.title,
|
|
6833
|
-
// TODO: hubType is no longer used, remove it at next breaking change
|
|
6834
|
-
hubType: getItemHubType(item),
|
|
6835
|
-
categories: parseItemCategories(item.categories),
|
|
6836
|
-
itemCategories: item.categories,
|
|
6837
|
-
// can we strip HTML from description, and do we need to trim it to a X chars?
|
|
6838
|
-
summary: item.snippet || item.description,
|
|
6839
|
-
publisher: {
|
|
6840
|
-
name: item.owner,
|
|
6841
|
-
username: item.owner,
|
|
6842
|
-
},
|
|
6843
|
-
permissions: {
|
|
6844
|
-
visibility: item.access,
|
|
6845
|
-
control: item.itemControl || "view",
|
|
6846
|
-
},
|
|
6847
|
-
// Hub app configuration metadata from item properties
|
|
6848
|
-
actionLinks: properties && properties.links,
|
|
6849
|
-
hubActions: properties && properties.actions,
|
|
6850
|
-
metrics: properties && properties.metrics,
|
|
6851
|
-
isDownloadable: isDownloadable(item),
|
|
6852
|
-
// default boundary from item.extent
|
|
6853
|
-
license: { name: "Custom License", description: item.accessInformation },
|
|
6854
|
-
// dates and sources we will enrich these later...
|
|
6855
|
-
createdDate: createdDate,
|
|
6856
|
-
createdDateSource: createdDateSource,
|
|
6857
|
-
publishedDate: createdDate,
|
|
6858
|
-
publishedDateSource: createdDateSource,
|
|
6859
|
-
updatedDate: new Date(item.modified),
|
|
6860
|
-
updatedDateSource: "item.modified",
|
|
6861
|
-
structuredLicense: getStructuredLicense(item.licenseInfo),
|
|
6862
|
-
});
|
|
6863
|
-
return setContentExtent(setContentType(content, item.type), item.extent);
|
|
7467
|
+
return composeContent(item);
|
|
6864
7468
|
}
|
|
6865
7469
|
/**
|
|
6866
7470
|
* Convert a Hub API dataset resource to Hub Content
|
|
@@ -6872,76 +7476,43 @@
|
|
|
6872
7476
|
function datasetToContent(dataset) {
|
|
6873
7477
|
// extract item from dataset, create content from the item
|
|
6874
7478
|
var item = datasetToItem(dataset);
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
//
|
|
6878
|
-
|
|
6879
|
-
// overwrite or add enrichments from Hub API
|
|
6880
|
-
var hubId = dataset.id, attributes = dataset.attributes;
|
|
6881
|
-
var
|
|
6882
|
-
// common enrichments
|
|
6883
|
-
errors = attributes.errors, boundary = attributes.boundary, extent = attributes.extent, metadata = attributes.metadata, modified = attributes.modified, modifiedProvenance = attributes.modifiedProvenance, slug = attributes.slug, searchDescription = attributes.searchDescription, groupIds = attributes.groupIds,
|
|
7479
|
+
// extract enrichments from attributes
|
|
7480
|
+
var _a = dataset.attributes,
|
|
7481
|
+
// item enrichments
|
|
7482
|
+
errors = _a.errors, boundary = _a.boundary, metadata = _a.metadata, slug = _a.slug, groupIds = _a.groupIds, orgId = _a.orgId, orgName = _a.orgName, organization = _a.organization, orgExtent = _a.orgExtent,
|
|
6884
7483
|
// map and feature server enrichments
|
|
6885
|
-
server =
|
|
6886
|
-
//
|
|
6887
|
-
|
|
6888
|
-
//
|
|
6889
|
-
|
|
6890
|
-
//
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
//
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
// setting this to null signals to enrichMetadata to skip this
|
|
6913
|
-
content.metadata = metadata || null;
|
|
6914
|
-
if (content.modified !== modified) {
|
|
6915
|
-
// capture the enriched modified date
|
|
6916
|
-
// NOTE: the item modified date is still available on content.item.modified
|
|
6917
|
-
content.modified = modified;
|
|
6918
|
-
content.updatedDate = new Date(modified);
|
|
6919
|
-
content.updatedDateSource = modifiedProvenance;
|
|
6920
|
-
}
|
|
6921
|
-
content.slug = slug;
|
|
7484
|
+
server = _a.server, layers = _a.layers, layer = _a.layer, recordCount = _a.recordCount, statistics = _a.statistics,
|
|
7485
|
+
// additional attributes needed
|
|
7486
|
+
searchDescription = _a.searchDescription;
|
|
7487
|
+
// get the layerId from the layer
|
|
7488
|
+
var layerId = layer && layer.id;
|
|
7489
|
+
// re-assemble the org as an enrichment
|
|
7490
|
+
var org = orgId && {
|
|
7491
|
+
id: orgId,
|
|
7492
|
+
name: orgName || organization,
|
|
7493
|
+
extent: orgExtent,
|
|
7494
|
+
};
|
|
7495
|
+
// compose a content out of the above
|
|
7496
|
+
var content = composeContent(item, {
|
|
7497
|
+
layerId: layerId,
|
|
7498
|
+
slug: slug,
|
|
7499
|
+
errors: errors,
|
|
7500
|
+
// setting this to null signals to enrichMetadata to skip this
|
|
7501
|
+
metadata: metadata || null,
|
|
7502
|
+
groupIds: groupIds,
|
|
7503
|
+
org: org,
|
|
7504
|
+
server: server,
|
|
7505
|
+
layers: layers,
|
|
7506
|
+
recordCount: recordCount,
|
|
7507
|
+
boundary: boundary,
|
|
7508
|
+
statistics: statistics,
|
|
7509
|
+
});
|
|
7510
|
+
// TODO: need to add searchDescription logic to composeContent()
|
|
6922
7511
|
if (searchDescription) {
|
|
6923
7512
|
// overwrite default summary (from snippet) w/ search description
|
|
6924
7513
|
content.summary = searchDescription;
|
|
6925
7514
|
}
|
|
6926
|
-
content
|
|
6927
|
-
// server enrichments
|
|
6928
|
-
content.server = server;
|
|
6929
|
-
content.layers = layers;
|
|
6930
|
-
// layer enrichments
|
|
6931
|
-
content.layer = layer;
|
|
6932
|
-
content.recordCount = recordCount;
|
|
6933
|
-
content.statistics = statistics;
|
|
6934
|
-
// org enrichments
|
|
6935
|
-
if (orgId) {
|
|
6936
|
-
content.org = {
|
|
6937
|
-
id: orgId,
|
|
6938
|
-
name: orgName || organization,
|
|
6939
|
-
extent: orgExtent,
|
|
6940
|
-
};
|
|
6941
|
-
}
|
|
6942
|
-
// return a content with updated hubId and type
|
|
6943
|
-
// along w/ related properties like identifier, family, etc
|
|
6944
|
-
return setContentType(setContentHubId(content, hubId), type);
|
|
7515
|
+
return content;
|
|
6945
7516
|
}
|
|
6946
7517
|
/**
|
|
6947
7518
|
* Convert a Hub API dataset resource to a portal item
|
|
@@ -7072,122 +7643,6 @@
|
|
|
7072
7643
|
relative: getContentRelativeUrl(updated),
|
|
7073
7644
|
});
|
|
7074
7645
|
};
|
|
7075
|
-
/**
|
|
7076
|
-
* Compute the content type icon based on the content type
|
|
7077
|
-
* @param content type
|
|
7078
|
-
* @returns content type icon
|
|
7079
|
-
*/
|
|
7080
|
-
var getContentTypeIcon = function (contentType) {
|
|
7081
|
-
var _a;
|
|
7082
|
-
var type = camelize(contentType || "");
|
|
7083
|
-
var iconMap = {
|
|
7084
|
-
appbuilderExtension: "file",
|
|
7085
|
-
appbuilderWidgetPackage: "widgets-source",
|
|
7086
|
-
application: "web",
|
|
7087
|
-
applicationConfiguration: "app-gear",
|
|
7088
|
-
arcgisProMap: "desktop",
|
|
7089
|
-
cadDrawing: "file-cad",
|
|
7090
|
-
cityEngineWebScene: "urban-model",
|
|
7091
|
-
codeAttachment: "file-code",
|
|
7092
|
-
codeSample: "file-code",
|
|
7093
|
-
colorSet: "palette",
|
|
7094
|
-
contentCategorySet: "label",
|
|
7095
|
-
csv: "file-csv",
|
|
7096
|
-
cSV: "file-csv",
|
|
7097
|
-
cSVCollection: "file-csv",
|
|
7098
|
-
dashboard: "dashboard",
|
|
7099
|
-
desktopApplication: "desktop",
|
|
7100
|
-
documentLink: "link",
|
|
7101
|
-
excaliburImageryProject: "file",
|
|
7102
|
-
explorerMap: "file",
|
|
7103
|
-
exportPackage: "file",
|
|
7104
|
-
featureCollection: "data",
|
|
7105
|
-
featureCollectionTemplate: "file",
|
|
7106
|
-
featureLayer: "data",
|
|
7107
|
-
featureService: "collection",
|
|
7108
|
-
fileGeodatabase: "data",
|
|
7109
|
-
form: "survey",
|
|
7110
|
-
geocodingService: "file",
|
|
7111
|
-
geodataService: "file",
|
|
7112
|
-
geometryService: "file",
|
|
7113
|
-
geopackage: "file",
|
|
7114
|
-
geoprocessingService: "file",
|
|
7115
|
-
globeLayer: "layers",
|
|
7116
|
-
globeService: "file",
|
|
7117
|
-
hubInitiative: "initiative",
|
|
7118
|
-
hubInitiativeTemplate: "initiative-template",
|
|
7119
|
-
hubPage: "browser",
|
|
7120
|
-
hubSiteApplication: "web",
|
|
7121
|
-
image: "file-image",
|
|
7122
|
-
imageService: "data",
|
|
7123
|
-
insightsModel: "file",
|
|
7124
|
-
insightsPage: "graph-moving-average",
|
|
7125
|
-
insightsTheme: "palette",
|
|
7126
|
-
insightsWorkbook: "graph-moving-average",
|
|
7127
|
-
iWorkPages: "file-text",
|
|
7128
|
-
iWorkKeynote: "presentation",
|
|
7129
|
-
iWorkNumbers: "file-report",
|
|
7130
|
-
kML: "data",
|
|
7131
|
-
kMLCollection: "data",
|
|
7132
|
-
layer: "layers",
|
|
7133
|
-
layerPackage: "layers",
|
|
7134
|
-
layerTemplate: "file",
|
|
7135
|
-
locatorPackage: "file",
|
|
7136
|
-
mapArea: "file",
|
|
7137
|
-
mapDocument: "map-contents",
|
|
7138
|
-
mapImageLayer: "collection",
|
|
7139
|
-
mapPackage: "file",
|
|
7140
|
-
mapService: "collection",
|
|
7141
|
-
microsoftExcel: "file-report",
|
|
7142
|
-
microsoftPowerpoint: "presentation",
|
|
7143
|
-
microsoftWord: "file-text",
|
|
7144
|
-
mission: "file",
|
|
7145
|
-
mobileMapPackage: "map-contents",
|
|
7146
|
-
nativeApplication: "mobile",
|
|
7147
|
-
nativeApplicationInstaller: "file",
|
|
7148
|
-
nativeApplicationTemplate: "file",
|
|
7149
|
-
mobileApplication: "mobile",
|
|
7150
|
-
networkAnalysisService: "file",
|
|
7151
|
-
notebook: "code",
|
|
7152
|
-
orientedImageryCatalog: "file",
|
|
7153
|
-
orthoMappingProject: "file",
|
|
7154
|
-
orthoMappingTemplate: "file",
|
|
7155
|
-
pDF: "file-pdf",
|
|
7156
|
-
quickCaptureProject: "mobile",
|
|
7157
|
-
rasterFunctionTemplate: "file",
|
|
7158
|
-
rasterLayer: "map",
|
|
7159
|
-
realTimeAnalytic: "file",
|
|
7160
|
-
relationalDatabaseConnection: "file",
|
|
7161
|
-
reportTemplate: "file",
|
|
7162
|
-
sceneLayer: "data",
|
|
7163
|
-
sceneService: "urban-model",
|
|
7164
|
-
serviceDefinition: "file",
|
|
7165
|
-
shapefile: "data",
|
|
7166
|
-
solution: "puzzle-piece",
|
|
7167
|
-
sqliteGeodatabase: "file",
|
|
7168
|
-
statisticalDataCollection: "file",
|
|
7169
|
-
storymap: "tour",
|
|
7170
|
-
storyMap: "tour",
|
|
7171
|
-
storymapTheme: "palette",
|
|
7172
|
-
symbolSet: "file",
|
|
7173
|
-
table: "table",
|
|
7174
|
-
urbanModel: "urban-model",
|
|
7175
|
-
vectorTilePackage: "file-shape",
|
|
7176
|
-
vectorTileService: "map",
|
|
7177
|
-
visioDocument: "conditional-rules",
|
|
7178
|
-
webExperience: "apps",
|
|
7179
|
-
webMap: "map",
|
|
7180
|
-
webMappingApplication: "apps",
|
|
7181
|
-
webScene: "urban-model",
|
|
7182
|
-
wfs: "map",
|
|
7183
|
-
wFS: "map",
|
|
7184
|
-
wMS: "map",
|
|
7185
|
-
wMTS: "map",
|
|
7186
|
-
workflowManagerService: "file",
|
|
7187
|
-
workforceProject: "list-check",
|
|
7188
|
-
};
|
|
7189
|
-
return (_a = iconMap[type]) !== null && _a !== void 0 ? _a : "file";
|
|
7190
|
-
};
|
|
7191
7646
|
/**
|
|
7192
7647
|
* Compute the content type label
|
|
7193
7648
|
* @param contentType
|
|
@@ -7252,78 +7707,7 @@
|
|
|
7252
7707
|
return __assign(__assign({}, content), { urls: urls });
|
|
7253
7708
|
};
|
|
7254
7709
|
var getContentRelativeUrl = function (content, siteIdentifier) {
|
|
7255
|
-
|
|
7256
|
-
// prefer site specific identifier if passed in
|
|
7257
|
-
var identifier = siteIdentifier || content.identifier;
|
|
7258
|
-
// solution types have their own logic
|
|
7259
|
-
var contentUrl = getSolutionUrl(content);
|
|
7260
|
-
if (!contentUrl) {
|
|
7261
|
-
var pluralizedFamilies = [
|
|
7262
|
-
"app",
|
|
7263
|
-
"dataset",
|
|
7264
|
-
"document",
|
|
7265
|
-
"map",
|
|
7266
|
-
"template",
|
|
7267
|
-
];
|
|
7268
|
-
// default to the catchall content route
|
|
7269
|
-
var path = "/content";
|
|
7270
|
-
if (content.family === "feedback") {
|
|
7271
|
-
// exception
|
|
7272
|
-
path = "/feedback/surveys";
|
|
7273
|
-
}
|
|
7274
|
-
else if (isPageContent(content)) {
|
|
7275
|
-
// pages are in the document family,
|
|
7276
|
-
// but instead of showing the page's metadata on /documents/about
|
|
7277
|
-
// but we render the page on the pages route
|
|
7278
|
-
path = "/pages";
|
|
7279
|
-
}
|
|
7280
|
-
else if (pluralizedFamilies.indexOf(family) > -1) {
|
|
7281
|
-
// the rule
|
|
7282
|
-
path = "/" + family + "s";
|
|
7283
|
-
}
|
|
7284
|
-
contentUrl = path + "/" + identifier;
|
|
7285
|
-
}
|
|
7286
|
-
return contentUrl;
|
|
7287
|
-
};
|
|
7288
|
-
var getSolutionUrl = function (content) {
|
|
7289
|
-
var _a;
|
|
7290
|
-
var hubUrl;
|
|
7291
|
-
var type = content.type, identifier = content.identifier;
|
|
7292
|
-
if (type === "Solution") {
|
|
7293
|
-
// NOTE: as per the above spreadsheet,
|
|
7294
|
-
// solution types are now in the Template family
|
|
7295
|
-
// but we don't send them to the route for initiative templates
|
|
7296
|
-
if (((_a = content.typeKeywords) === null || _a === void 0 ? void 0 : _a.indexOf("Deployed")) > 0) {
|
|
7297
|
-
// deployed solutions go to the generic content route
|
|
7298
|
-
hubUrl = "/content/" + identifier;
|
|
7299
|
-
}
|
|
7300
|
-
// others go to the solution about route
|
|
7301
|
-
hubUrl = "/templates/" + identifier + "/about";
|
|
7302
|
-
}
|
|
7303
|
-
return hubUrl;
|
|
7304
|
-
};
|
|
7305
|
-
// page helpers
|
|
7306
|
-
// TODO: we check both "Hub Page" and "Site Page" because we don't know whether the site is a portal or not
|
|
7307
|
-
// In the future, the site object will have a site.isPortal() function that we can leverage
|
|
7308
|
-
// instead of hardcoding the types here.
|
|
7309
|
-
var isPageContent = function (content) {
|
|
7310
|
-
return includes(["Hub Page", "Site Page"], content.type);
|
|
7311
|
-
};
|
|
7312
|
-
// proxied csv helpers
|
|
7313
|
-
/**
|
|
7314
|
-
* If an item is a proxied csv, returns the url for the proxying feature layer.
|
|
7315
|
-
* If the item is not a proxied csv, returns undefined.
|
|
7316
|
-
*
|
|
7317
|
-
* @param item
|
|
7318
|
-
* @param requestOptions Hub Request Options (including whether we're in portal)
|
|
7319
|
-
* @returns
|
|
7320
|
-
*/
|
|
7321
|
-
var getProxyUrl = function (item, requestOptions) {
|
|
7322
|
-
var result;
|
|
7323
|
-
if (isProxiedCSV(item, requestOptions)) {
|
|
7324
|
-
result = requestOptions.hubApiUrl + "/datasets/" + item.id + "_0/FeatureServer/0";
|
|
7325
|
-
}
|
|
7326
|
-
return result;
|
|
7710
|
+
return getHubRelativeUrl(content.type, siteIdentifier || content.identifier, content.typeKeywords);
|
|
7327
7711
|
};
|
|
7328
7712
|
|
|
7329
7713
|
/**
|
|
@@ -9991,36 +10375,6 @@
|
|
|
9991
10375
|
});
|
|
9992
10376
|
}
|
|
9993
10377
|
|
|
9994
|
-
/**
|
|
9995
|
-
* Get the fully qualified URL for an item's thumbnail
|
|
9996
|
-
* @param item w/ id, thumbnail, and access
|
|
9997
|
-
* @param portalUrlOrObject a portal base or API URL, a portal object, or request options containing either of those
|
|
9998
|
-
* @param optionsOrToken options including width and/or token for the current user's session; will only be appended as a query parameter if the item's access is **not** `public`
|
|
9999
|
-
* @returns URL to the item's thumbnail, defaults to `https://www.arcgis.com/sharing/rest/content/items/{item.id}/info/{item.thumbnail}`. Returns `null` if the item does not have a thumbnail assigned.
|
|
10000
|
-
*/
|
|
10001
|
-
function getItemThumbnailUrl(item, portalUrlOrObject, optionsOrToken) {
|
|
10002
|
-
if (!item || !item.thumbnail) {
|
|
10003
|
-
// TODO: handle image types by returning the image (item data) itself?
|
|
10004
|
-
return null;
|
|
10005
|
-
}
|
|
10006
|
-
// tslint:disable-next-line prefer-const
|
|
10007
|
-
var _a = optionsOrToken || {}, token = _a.token, width = _a.width;
|
|
10008
|
-
// TODO: at the next breaking change drop support for passing token as string
|
|
10009
|
-
if (!token && typeof optionsOrToken === "string") {
|
|
10010
|
-
token = optionsOrToken;
|
|
10011
|
-
}
|
|
10012
|
-
var itemApiUrl = getItemApiUrl(item, portalUrlOrObject, token);
|
|
10013
|
-
var _b = itemApiUrl.split("?"), baseUrl = _b[0], search = _b[1];
|
|
10014
|
-
var searchParams = new URLSearchParams(search);
|
|
10015
|
-
searchParams.delete("f");
|
|
10016
|
-
if (width) {
|
|
10017
|
-
searchParams.append("w", width + "");
|
|
10018
|
-
}
|
|
10019
|
-
var newSearch = searchParams.toString();
|
|
10020
|
-
var url = baseUrl + "/info/" + item.thumbnail;
|
|
10021
|
-
return newSearch ? url + "?" + newSearch : url;
|
|
10022
|
-
}
|
|
10023
|
-
|
|
10024
10378
|
/**
|
|
10025
10379
|
* Given an item, return an array of assets that includes
|
|
10026
10380
|
* all the resources, as well as the thumbnail
|
|
@@ -12739,6 +13093,7 @@
|
|
|
12739
13093
|
exports.cloneObject = cloneObject$1;
|
|
12740
13094
|
exports.completeOAuth2 = completeOAuth2;
|
|
12741
13095
|
exports.compose = compose;
|
|
13096
|
+
exports.composeContent = composeContent;
|
|
12742
13097
|
exports.constructSlug = constructSlug;
|
|
12743
13098
|
exports.convertContentDefinitionToFilter = convertContentDefinitionToFilter;
|
|
12744
13099
|
exports.convertContentFilterToSearchOptions = convertContentFilterToSearchOptions;
|
|
@@ -12791,7 +13146,6 @@
|
|
|
12791
13146
|
exports.flattenArray = flattenArray;
|
|
12792
13147
|
exports.generateRandomString = generateRandomString;
|
|
12793
13148
|
exports.getCategory = getCategory;
|
|
12794
|
-
exports.getCollection = getCollection;
|
|
12795
13149
|
exports.getContentIdentifier = getContentIdentifier;
|
|
12796
13150
|
exports.getContentSiteUrls = getContentSiteUrls;
|
|
12797
13151
|
exports.getContentTypeIcon = getContentTypeIcon;
|
|
@@ -12828,6 +13182,7 @@
|
|
|
12828
13182
|
exports.getPortalApiUrl = getPortalApiUrl;
|
|
12829
13183
|
exports.getPortalBaseFromOrgUrl = getPortalBaseFromOrgUrl;
|
|
12830
13184
|
exports.getPortalUrl = getPortalUrl;
|
|
13185
|
+
exports.getPortalUrls = getPortalUrls;
|
|
12831
13186
|
exports.getProp = getProp;
|
|
12832
13187
|
exports.getProps = getProps;
|
|
12833
13188
|
exports.getProxyUrl = getProxyUrl;
|