@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.
Files changed (61) hide show
  1. package/dist/es2017/content/_internal.js +151 -30
  2. package/dist/es2017/content/_internal.js.map +1 -1
  3. package/dist/es2017/content/compose.js +607 -0
  4. package/dist/es2017/content/compose.js.map +1 -0
  5. package/dist/es2017/content/get-family.js +42 -0
  6. package/dist/es2017/content/get-family.js.map +1 -0
  7. package/dist/es2017/content/index.js +42 -468
  8. package/dist/es2017/content/index.js.map +1 -1
  9. package/dist/es2017/core/types/IHubContentEnrichments.js +1 -0
  10. package/dist/es2017/core/types/IHubContentEnrichments.js.map +1 -0
  11. package/dist/es2017/core/types/IServerEnrichments.js +1 -0
  12. package/dist/es2017/core/types/IServerEnrichments.js.map +1 -0
  13. package/dist/es2017/core/types/index.js +2 -1
  14. package/dist/es2017/core/types/index.js.map +1 -1
  15. package/dist/esm/content/_internal.js +153 -30
  16. package/dist/esm/content/_internal.js.map +1 -1
  17. package/dist/esm/content/compose.js +600 -0
  18. package/dist/esm/content/compose.js.map +1 -0
  19. package/dist/esm/content/get-family.js +42 -0
  20. package/dist/esm/content/get-family.js.map +1 -0
  21. package/dist/esm/content/index.js +44 -476
  22. package/dist/esm/content/index.js.map +1 -1
  23. package/dist/esm/core/types/IHubContentEnrichments.js +1 -0
  24. package/dist/esm/core/types/IHubContentEnrichments.js.map +1 -0
  25. package/dist/esm/core/types/IServerEnrichments.js +1 -0
  26. package/dist/esm/core/types/IServerEnrichments.js.map +1 -0
  27. package/dist/esm/core/types/index.js +2 -1
  28. package/dist/esm/core/types/index.js.map +1 -1
  29. package/dist/node/content/_internal.js +155 -31
  30. package/dist/node/content/_internal.js.map +1 -1
  31. package/dist/node/content/compose.js +612 -0
  32. package/dist/node/content/compose.js.map +1 -0
  33. package/dist/node/content/get-family.js +46 -0
  34. package/dist/node/content/get-family.js.map +1 -0
  35. package/dist/node/content/index.js +48 -477
  36. package/dist/node/content/index.js.map +1 -1
  37. package/dist/node/core/types/IHubContentEnrichments.js +3 -0
  38. package/dist/node/core/types/IHubContentEnrichments.js.map +1 -0
  39. package/dist/node/core/types/{IContentEnrichments.js → IServerEnrichments.js} +1 -1
  40. package/dist/node/core/types/IServerEnrichments.js.map +1 -0
  41. package/dist/node/core/types/index.js +2 -1
  42. package/dist/node/core/types/index.js.map +1 -1
  43. package/dist/types/content/_internal.d.ts +57 -22
  44. package/dist/types/content/compose.d.ts +115 -0
  45. package/dist/types/content/get-family.d.ts +7 -0
  46. package/dist/types/content/index.d.ts +4 -86
  47. package/dist/types/core/types/IHubContent.d.ts +4 -2
  48. package/dist/types/core/types/IHubContentEnrichments.d.ts +15 -0
  49. package/dist/types/core/types/IHubItemEntity.d.ts +1 -1
  50. package/dist/types/core/types/{IContentEnrichments.d.ts → IServerEnrichments.d.ts} +3 -2
  51. package/dist/types/core/types/index.d.ts +2 -1
  52. package/dist/umd/common.umd.js +910 -555
  53. package/dist/umd/common.umd.js.map +1 -1
  54. package/dist/umd/common.umd.min.js +1 -1
  55. package/dist/umd/common.umd.min.js.map +1 -1
  56. package/package.json +1 -1
  57. package/dist/es2017/core/types/IContentEnrichments.js +0 -1
  58. package/dist/es2017/core/types/IContentEnrichments.js.map +0 -1
  59. package/dist/esm/core/types/IContentEnrichments.js +0 -1
  60. package/dist/esm/core/types/IContentEnrichments.js.map +0 -1
  61. package/dist/node/core/types/IContentEnrichments.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-family.js","sourceRoot":"","sources":["../../../src/content/get-family.ts"],"names":[],"mappings":";;;AACA,gDAA+C;AAE/C,2BAA2B;AAC3B,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,MAAM,SAAS,GAAQ;QACrB,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,UAAU;KACrB,CAAC;IACF,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,IAAI,MAAM,CAAC;IACX,8EAA8E;IAC9E,mVAAmV;IACnV,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE;QAClC,KAAK,eAAe;YAClB,MAAM,GAAG,SAAS,CAAC;YACnB,MAAM;QACR,KAAK,iBAAiB,CAAC;QACvB,KAAK,cAAc;YACjB,sDAAsD;YACtD,MAAM,GAAG,KAAK,CAAC;YACf,MAAM;QACR,KAAK,iBAAiB;YACpB,MAAM,GAAG,UAAU,CAAC;YACpB,MAAM;QACR,KAAK,aAAa,CAAC;QACnB,KAAK,6BAA6B,CAAC;QACnC,KAAK,iBAAiB;YACpB,MAAM,GAAG,SAAS,CAAC;YACnB,MAAM;QACR;YACE,oCAAoC;YACpC,MAAM,GAAG,kBAAkB,CAAC,2BAAa,CAAC,IAAI,CAAC,CAAC,CAAC;KACpD;IACD,OAAO,MAAmB,CAAC;AAC7B,CAAC;AA1BD,8BA0BC"}
@@ -1,24 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProxyUrl = exports.setContentSiteUrls = exports.getContentSiteUrls = exports.setContentHubId = exports.getContentTypeLabel = exports.getContentTypeIcon = exports.setContentType = exports.datasetToItem = exports.datasetToContent = exports.itemToContent = exports.getItemHubType = exports.getFamily = exports.parseItemCategories = exports.removeContextFromSlug = exports.addContextToSlug = exports.isSlug = exports.parseDatasetId = exports.getContentIdentifier = exports.getItemHubId = exports.getItemLayerId = exports.getLayerIdFromUrl = exports.isFeatureService = exports.getCollection = exports.getTypeCategories = exports.normalizeItemType = exports.getTypes = exports.getCategory = void 0;
3
+ exports.setContentSiteUrls = exports.getContentSiteUrls = exports.setContentHubId = exports.getContentTypeLabel = exports.setContentType = exports.datasetToItem = exports.datasetToContent = exports.itemToContent = exports.getItemHubType = exports.removeContextFromSlug = exports.addContextToSlug = exports.isSlug = exports.parseDatasetId = exports.getContentIdentifier = exports.getTypeCategories = exports.getTypes = exports.getCategory = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const collections_1 = require("../collections");
5
6
  const categories_1 = require("../categories");
6
- const extent_1 = require("../extent");
7
7
  const utils_1 = require("../utils");
8
8
  const objects_1 = require("../objects");
9
- const get_structured_license_1 = require("../items/get-structured-license");
10
9
  const urls_1 = require("../urls");
11
10
  const _internal_1 = require("./_internal");
12
11
  const util_1 = require("../util");
13
- // private helper functions
14
- function collectionToFamily(collection) {
15
- const overrides = {
16
- other: "content",
17
- solution: "template",
18
- };
19
- return overrides[collection] || collection;
20
- }
21
- const cache = {};
12
+ const compose_1 = require("./compose");
13
+ const get_family_1 = require("./get-family");
14
+ // re-export functions used in this file
15
+ tslib_1.__exportStar(require("./compose"), exports);
16
+ tslib_1.__exportStar(require("./get-family"), exports);
22
17
  // TODO: remove this at next breaking version
23
18
  /**
24
19
  * ```js
@@ -36,7 +31,7 @@ function getCategory(itemType = "") {
36
31
  /* tslint:disable no-console */
37
32
  console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v10.0.0");
38
33
  /* tslint:enable no-console */
39
- const collection = getCollection(itemType);
34
+ const collection = collections_1.getCollection(itemType);
40
35
  // for backwards compatibility
41
36
  return collection === "feedback" ? "app" : collection;
42
37
  }
@@ -57,41 +52,6 @@ function getTypes(category = "") {
57
52
  return categories_1.categories[category.toLowerCase()];
58
53
  }
59
54
  exports.getTypes = getTypes;
60
- /**
61
- * ```js
62
- * import { normalizeItemType } from "@esri/hub-common";
63
- * //
64
- * normalizeItemType(item)
65
- * > [ 'Hub Site Application' ]
66
- * ```
67
- * @param item Item object.
68
- * @returns type of the input item.
69
- *
70
- */
71
- function normalizeItemType(item = {}) {
72
- let ret = item.type;
73
- const typeKeywords = item.typeKeywords || [];
74
- if (item.type === "Site Application" ||
75
- (item.type === "Web Mapping Application" &&
76
- utils_1.includes(typeKeywords, "hubSite"))) {
77
- ret = "Hub Site Application";
78
- }
79
- if (item.type === "Site Page" ||
80
- (item.type === "Web Mapping Application" &&
81
- utils_1.includes(typeKeywords, "hubPage"))) {
82
- ret = "Hub Page";
83
- }
84
- if (item.type === "Hub Initiative" &&
85
- utils_1.includes(typeKeywords, "hubInitiativeTemplate")) {
86
- ret = "Hub Initiative Template";
87
- }
88
- if (item.type === "Web Mapping Application" &&
89
- utils_1.includes(typeKeywords, "hubSolutionTemplate")) {
90
- ret = "Solution";
91
- }
92
- return ret;
93
- }
94
- exports.normalizeItemType = normalizeItemType;
95
55
  /**
96
56
  * ```js
97
57
  * import { getTypeCategories } from "@esri/hub-common";
@@ -104,7 +64,7 @@ exports.normalizeItemType = normalizeItemType;
104
64
  *
105
65
  */
106
66
  function getTypeCategories(item = {}) {
107
- const type = normalizeItemType(item);
67
+ const type = compose_1.normalizeItemType(item);
108
68
  const category = getCategory(type);
109
69
  if (category) {
110
70
  // upper case first letter and return as element in array for backwards compatibility
@@ -117,77 +77,6 @@ function getTypeCategories(item = {}) {
117
77
  }
118
78
  }
119
79
  exports.getTypeCategories = getTypeCategories;
120
- /**
121
- * ```js
122
- * import { getCollection } from "@esri/hub-common";
123
- * //
124
- * getCollection('Feature Layer')
125
- * > 'dataset'
126
- * ```
127
- * Get the Hub collection for a given item type
128
- * @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
129
- * @returns the Hub collection of a given item type.
130
- */
131
- function getCollection(itemType = "") {
132
- if (cache[itemType]) {
133
- return cache[itemType];
134
- }
135
- for (const collection of Object.keys(collections_1.collections)) {
136
- for (const type of collections_1.collections[collection]) {
137
- if (itemType.toLowerCase() === type.toLowerCase()) {
138
- cache[itemType] = collection;
139
- return collection;
140
- }
141
- }
142
- }
143
- }
144
- exports.getCollection = getCollection;
145
- /**
146
- * Case-insensitive check if the type is "Feature Service"
147
- * @param {string} type - item's type
148
- * @returns {boolean}
149
- */
150
- exports.isFeatureService = (type) => {
151
- return type && type.toLowerCase() === "feature service";
152
- };
153
- /**
154
- * parse layer id from a service URL
155
- * @param {string} url
156
- * @returns {string} layer id
157
- */
158
- exports.getLayerIdFromUrl = (url) => {
159
- const endsWithNumberSegmentRegEx = /\/\d+$/;
160
- const matched = url && url.match(endsWithNumberSegmentRegEx);
161
- return matched && matched[0].slice(1);
162
- };
163
- /**
164
- * return the layerId if we can tell that item is a single layer service
165
- * @param {*} item from AGO
166
- * @returns {string} layer id
167
- */
168
- exports.getItemLayerId = (item) => {
169
- // try to parse it from the URL, but failing that we check for
170
- // the Singlelayer typeKeyword, which I think is set when you create the item in AGO
171
- // but have not verified that, nor that we should alway return '0' in that case
172
- return (exports.getLayerIdFromUrl(item.url) ||
173
- (exports.isFeatureService(item.type) &&
174
- utils_1.includes(item.typeKeywords, "Singlelayer") &&
175
- "0"));
176
- };
177
- /**
178
- * given an item, get the id to use w/ the Hub API
179
- * @param item
180
- * @returns Hub API id (hubId)
181
- */
182
- exports.getItemHubId = (item) => {
183
- if (item.access !== "public") {
184
- // the hub only indexes public items
185
- return;
186
- }
187
- const id = item.id;
188
- const layerId = exports.getItemLayerId(item);
189
- return layerId ? `${id}_${layerId}` : id;
190
- };
191
80
  /**
192
81
  * ```js
193
82
  * import { getContentIdentifier } from "@esri/hub-common";
@@ -217,7 +106,7 @@ function getContentIdentifier(content, site) {
217
106
  // site data instead. Because this one is the original one that was used
218
107
  // to create the page url (not mutable once created) and the slug (below)
219
108
  // generated by the hub-indexer could simply change with page name.
220
- if (isPageContent(content)) {
109
+ if (_internal_1.isPageType(content.type)) {
221
110
  // check if the page is linked to the current site
222
111
  const pages = objects_1.getProp(site, "data.values.pages") || [];
223
112
  // if so, return the page slug otherwise the page id
@@ -306,62 +195,6 @@ function removeContextFromSlug(slug, context) {
306
195
  }
307
196
  }
308
197
  exports.removeContextFromSlug = removeContextFromSlug;
309
- /**
310
- * Splits item category strings at slashes and discards the "Categories" keyword
311
- *
312
- * ```
313
- * ["/Categories/Boundaries", "/Categories/Planning and cadastre/Property records", "/Categories/Structure"]
314
- * ```
315
- * Should end up being
316
- * ```
317
- * ["Boundaries", "Planning and cadastre", "Property records", "Structure"]
318
- * ```
319
- *
320
- * @param categories - an array of strings
321
- * @private
322
- */
323
- function parseItemCategories(categories) {
324
- if (!categories)
325
- return categories;
326
- const exclude = ["categories", ""];
327
- const parsed = categories.map((cat) => cat.split("/"));
328
- const flattened = parsed.reduce((acc, arr, _) => [...acc, ...arr], []);
329
- return flattened.filter((cat) => !utils_1.includes(exclude, cat.toLowerCase()));
330
- }
331
- exports.parseItemCategories = parseItemCategories;
332
- /**
333
- * return the Hub family given an item's type
334
- * @param type item type
335
- * @returns Hub family
336
- */
337
- function getFamily(type) {
338
- let family;
339
- // override default behavior for the rows that are highlighted in yellow here:
340
- // 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
341
- switch ((type || "").toLowerCase()) {
342
- case "image service":
343
- family = "dataset";
344
- break;
345
- case "feature service":
346
- case "raster layer":
347
- // TODO: check if feature service has > 1 layer first?
348
- family = "map";
349
- break;
350
- case "microsoft excel":
351
- family = "document";
352
- break;
353
- case "cad drawing":
354
- case "feature collection template":
355
- case "report template":
356
- family = "content";
357
- break;
358
- default:
359
- // by default derive from collection
360
- family = collectionToFamily(getCollection(type));
361
- }
362
- return family;
363
- }
364
- exports.getFamily = getFamily;
365
198
  /**
366
199
  * DEPRECATED: Use getFamily() instead.
367
200
  *
@@ -376,9 +209,9 @@ function getItemHubType(itemOrType) {
376
209
  if (typeof itemOrType === "string") {
377
210
  itemOrType = { type: itemOrType };
378
211
  }
379
- const itemType = normalizeItemType(itemOrType);
212
+ const itemType = compose_1.normalizeItemType(itemOrType);
380
213
  // TODO: not all categories are Hub types, may need to validate
381
- return getCollection(itemType);
214
+ return collections_1.getCollection(itemType);
382
215
  }
383
216
  exports.getItemHubType = getItemHubType;
384
217
  /**
@@ -389,51 +222,7 @@ exports.getItemHubType = getItemHubType;
389
222
  * @export
390
223
  */
391
224
  function itemToContent(item) {
392
- const createdDate = new Date(item.created);
393
- const createdDateSource = "item.created";
394
- const properties = item.properties;
395
- const content = Object.assign({}, item, {
396
- identifier: item.id,
397
- // no server errors when fetching the item directly
398
- errors: [],
399
- // store a reference to the item
400
- item,
401
- // NOTE: this will overwrite any existing item.name, which is
402
- // The file name of the item for file types. Read-only.
403
- // presumably there to use as the default file name when downloading
404
- // we don't store item.name in the Hub API and we use name for title
405
- name: item.title,
406
- // TODO: hubType is no longer used, remove it at next breaking change
407
- hubType: getItemHubType(item),
408
- categories: parseItemCategories(item.categories),
409
- itemCategories: item.categories,
410
- // can we strip HTML from description, and do we need to trim it to a X chars?
411
- summary: item.snippet || item.description,
412
- publisher: {
413
- name: item.owner,
414
- username: item.owner,
415
- },
416
- permissions: {
417
- visibility: item.access,
418
- control: item.itemControl || "view",
419
- },
420
- // Hub app configuration metadata from item properties
421
- actionLinks: properties && properties.links,
422
- hubActions: properties && properties.actions,
423
- metrics: properties && properties.metrics,
424
- isDownloadable: categories_1.isDownloadable(item),
425
- // default boundary from item.extent
426
- license: { name: "Custom License", description: item.accessInformation },
427
- // dates and sources we will enrich these later...
428
- createdDate,
429
- createdDateSource,
430
- publishedDate: createdDate,
431
- publishedDateSource: createdDateSource,
432
- updatedDate: new Date(item.modified),
433
- updatedDateSource: "item.modified",
434
- structuredLicense: get_structured_license_1.getStructuredLicense(item.licenseInfo),
435
- });
436
- return _internal_1.setContentExtent(exports.setContentType(content, item.type), item.extent);
225
+ return compose_1.composeContent(item);
437
226
  }
438
227
  exports.itemToContent = itemToContent;
439
228
  /**
@@ -446,76 +235,43 @@ exports.itemToContent = itemToContent;
446
235
  function datasetToContent(dataset) {
447
236
  // extract item from dataset, create content from the item
448
237
  const item = datasetToItem(dataset);
449
- const content = itemToContent(item);
450
- // We remove these because the indexer doesn't actually
451
- // preserve the original item categories so this attribute is invalid
452
- delete content.itemCategories;
453
- // overwrite or add enrichments from Hub API
454
- const { id: hubId, attributes } = dataset;
238
+ // extract enrichments from attributes
455
239
  const {
456
- // common enrichments
457
- errors, boundary, extent, metadata, modified, modifiedProvenance, slug, searchDescription, groupIds,
240
+ // item enrichments
241
+ errors, boundary, metadata, slug, groupIds, orgId, orgName, organization, orgExtent,
458
242
  // map and feature server enrichments
459
- server, layers,
460
- // NOTE: the Hub API also returns the following server properties
461
- // but we should be able to get them from the above server object
462
- // currentVersion, capabilities, tileInfo, serviceSpatialReference
463
- // maxRecordCount, supportedQueryFormats, etc
464
- // feature and raster layer enrichments
465
- layer, recordCount, statistics,
466
- // NOTE: the Hub API also returns the following layer properties
467
- // but we should be able to get them from the above layer object
468
- // supportedQueryFormats, supportsAdvancedQueries, advancedQueryCapabilities, useStandardizedQueries
469
- // geometryType, objectIdField, displayField, fields,
470
- // org properties?
471
- orgId, orgName, organization, orgExtent,
472
- // NOTE: for layers and tables the Hub API returns the layer type
473
- // ("Feature Layer", "Table", "Raster Layer") instead of the item type
474
- type, } = attributes;
475
- // NOTE: we could throw or return if there are errors
476
- // to prevent type errors trying to read properties below
477
- content.errors = errors;
478
- // common enrichments
479
- content.boundary = boundary;
480
- if (!extent_1.isBBox(item.extent) && extent && extent_1.isBBox(extent.coordinates)) {
481
- // we fall back to the extent derived by the API
482
- // which prefers layer or service extents and ultimately
483
- // falls back to the org's extent
484
- content.extent = extent.coordinates;
485
- }
486
- // setting this to null signals to enrichMetadata to skip this
487
- content.metadata = metadata || null;
488
- if (content.modified !== modified) {
489
- // capture the enriched modified date
490
- // NOTE: the item modified date is still available on content.item.modified
491
- content.modified = modified;
492
- content.updatedDate = new Date(modified);
493
- content.updatedDateSource = modifiedProvenance;
494
- }
495
- content.slug = slug;
243
+ server, layers, layer, recordCount, statistics,
244
+ // additional attributes needed
245
+ searchDescription, } = dataset.attributes;
246
+ // get the layerId from the layer
247
+ const layerId = layer && layer.id;
248
+ // re-assemble the org as an enrichment
249
+ const org = orgId && {
250
+ id: orgId,
251
+ name: orgName || organization,
252
+ extent: orgExtent,
253
+ };
254
+ // compose a content out of the above
255
+ const content = compose_1.composeContent(item, {
256
+ layerId,
257
+ slug,
258
+ errors,
259
+ // setting this to null signals to enrichMetadata to skip this
260
+ metadata: metadata || null,
261
+ groupIds,
262
+ org,
263
+ server,
264
+ layers,
265
+ recordCount,
266
+ boundary,
267
+ statistics,
268
+ });
269
+ // TODO: need to add searchDescription logic to composeContent()
496
270
  if (searchDescription) {
497
271
  // overwrite default summary (from snippet) w/ search description
498
272
  content.summary = searchDescription;
499
273
  }
500
- content.groupIds = groupIds;
501
- // server enrichments
502
- content.server = server;
503
- content.layers = layers;
504
- // layer enrichments
505
- content.layer = layer;
506
- content.recordCount = recordCount;
507
- content.statistics = statistics;
508
- // org enrichments
509
- if (orgId) {
510
- content.org = {
511
- id: orgId,
512
- name: orgName || organization,
513
- extent: orgExtent,
514
- };
515
- }
516
- // return a content with updated hubId and type
517
- // along w/ related properties like identifier, family, etc
518
- return exports.setContentType(exports.setContentHubId(content, hubId), type);
274
+ return content;
519
275
  }
520
276
  exports.datasetToContent = datasetToContent;
521
277
  /**
@@ -633,9 +389,9 @@ exports.datasetToItem = datasetToItem;
633
389
  */
634
390
  exports.setContentType = (content, type) => {
635
391
  // get family and normalized type based on new type
636
- const normalizedType = normalizeItemType(Object.assign(Object.assign({}, content.item), { type }));
637
- const family = getFamily(normalizedType);
638
- const contentTypeIcon = exports.getContentTypeIcon(normalizedType);
392
+ const normalizedType = compose_1.normalizeItemType(Object.assign(Object.assign({}, content.item), { type }));
393
+ const family = get_family_1.getFamily(normalizedType);
394
+ const contentTypeIcon = compose_1.getContentTypeIcon(normalizedType);
639
395
  const contentTypeLabel = exports.getContentTypeLabel(normalizedType, content.isProxied);
640
396
  const updated = Object.assign(Object.assign({}, content), { type: normalizedType, family,
641
397
  // TODO: remove this at next breaking change now that it has been deprecated
@@ -648,122 +404,6 @@ exports.setContentType = (content, type) => {
648
404
  relative: getContentRelativeUrl(updated),
649
405
  });
650
406
  };
651
- /**
652
- * Compute the content type icon based on the content type
653
- * @param content type
654
- * @returns content type icon
655
- */
656
- exports.getContentTypeIcon = (contentType) => {
657
- var _a;
658
- const type = util_1.camelize(contentType || "");
659
- const iconMap = {
660
- appbuilderExtension: "file",
661
- appbuilderWidgetPackage: "widgets-source",
662
- application: "web",
663
- applicationConfiguration: "app-gear",
664
- arcgisProMap: "desktop",
665
- cadDrawing: "file-cad",
666
- cityEngineWebScene: "urban-model",
667
- codeAttachment: "file-code",
668
- codeSample: "file-code",
669
- colorSet: "palette",
670
- contentCategorySet: "label",
671
- csv: "file-csv",
672
- cSV: "file-csv",
673
- cSVCollection: "file-csv",
674
- dashboard: "dashboard",
675
- desktopApplication: "desktop",
676
- documentLink: "link",
677
- excaliburImageryProject: "file",
678
- explorerMap: "file",
679
- exportPackage: "file",
680
- featureCollection: "data",
681
- featureCollectionTemplate: "file",
682
- featureLayer: "data",
683
- featureService: "collection",
684
- fileGeodatabase: "data",
685
- form: "survey",
686
- geocodingService: "file",
687
- geodataService: "file",
688
- geometryService: "file",
689
- geopackage: "file",
690
- geoprocessingService: "file",
691
- globeLayer: "layers",
692
- globeService: "file",
693
- hubInitiative: "initiative",
694
- hubInitiativeTemplate: "initiative-template",
695
- hubPage: "browser",
696
- hubSiteApplication: "web",
697
- image: "file-image",
698
- imageService: "data",
699
- insightsModel: "file",
700
- insightsPage: "graph-moving-average",
701
- insightsTheme: "palette",
702
- insightsWorkbook: "graph-moving-average",
703
- iWorkPages: "file-text",
704
- iWorkKeynote: "presentation",
705
- iWorkNumbers: "file-report",
706
- kML: "data",
707
- kMLCollection: "data",
708
- layer: "layers",
709
- layerPackage: "layers",
710
- layerTemplate: "file",
711
- locatorPackage: "file",
712
- mapArea: "file",
713
- mapDocument: "map-contents",
714
- mapImageLayer: "collection",
715
- mapPackage: "file",
716
- mapService: "collection",
717
- microsoftExcel: "file-report",
718
- microsoftPowerpoint: "presentation",
719
- microsoftWord: "file-text",
720
- mission: "file",
721
- mobileMapPackage: "map-contents",
722
- nativeApplication: "mobile",
723
- nativeApplicationInstaller: "file",
724
- nativeApplicationTemplate: "file",
725
- mobileApplication: "mobile",
726
- networkAnalysisService: "file",
727
- notebook: "code",
728
- orientedImageryCatalog: "file",
729
- orthoMappingProject: "file",
730
- orthoMappingTemplate: "file",
731
- pDF: "file-pdf",
732
- quickCaptureProject: "mobile",
733
- rasterFunctionTemplate: "file",
734
- rasterLayer: "map",
735
- realTimeAnalytic: "file",
736
- relationalDatabaseConnection: "file",
737
- reportTemplate: "file",
738
- sceneLayer: "data",
739
- sceneService: "urban-model",
740
- serviceDefinition: "file",
741
- shapefile: "data",
742
- solution: "puzzle-piece",
743
- sqliteGeodatabase: "file",
744
- statisticalDataCollection: "file",
745
- storymap: "tour",
746
- storyMap: "tour",
747
- storymapTheme: "palette",
748
- symbolSet: "file",
749
- table: "table",
750
- urbanModel: "urban-model",
751
- vectorTilePackage: "file-shape",
752
- vectorTileService: "map",
753
- visioDocument: "conditional-rules",
754
- webExperience: "apps",
755
- webMap: "map",
756
- webMappingApplication: "apps",
757
- webScene: "urban-model",
758
- wfs: "map",
759
- wFS: "map",
760
- wMS: "map",
761
- wMTS: "map",
762
- workflowManagerService: "file",
763
- workforceProject: "list-check",
764
- };
765
- return (_a = iconMap[type]) !== null && _a !== void 0 ? _a : "file";
766
- };
767
407
  /**
768
408
  * Compute the content type label
769
409
  * @param contentType
@@ -828,75 +468,6 @@ const appendContentUrls = (content, newUrls) => {
828
468
  return Object.assign(Object.assign({}, content), { urls });
829
469
  };
830
470
  const getContentRelativeUrl = (content, siteIdentifier) => {
831
- const { family } = content;
832
- // prefer site specific identifier if passed in
833
- const identifier = siteIdentifier || content.identifier;
834
- // solution types have their own logic
835
- let contentUrl = getSolutionUrl(content);
836
- if (!contentUrl) {
837
- const pluralizedFamilies = [
838
- "app",
839
- "dataset",
840
- "document",
841
- "map",
842
- "template",
843
- ];
844
- // default to the catchall content route
845
- let path = "/content";
846
- if (content.family === "feedback") {
847
- // exception
848
- path = "/feedback/surveys";
849
- }
850
- else if (isPageContent(content)) {
851
- // pages are in the document family,
852
- // but instead of showing the page's metadata on /documents/about
853
- // but we render the page on the pages route
854
- path = "/pages";
855
- }
856
- else if (pluralizedFamilies.indexOf(family) > -1) {
857
- // the rule
858
- path = `/${family}s`;
859
- }
860
- contentUrl = `${path}/${identifier}`;
861
- }
862
- return contentUrl;
863
- };
864
- const getSolutionUrl = (content) => {
865
- var _a;
866
- let hubUrl;
867
- const { type, identifier } = content;
868
- if (type === "Solution") {
869
- // NOTE: as per the above spreadsheet,
870
- // solution types are now in the Template family
871
- // but we don't send them to the route for initiative templates
872
- if (((_a = content.typeKeywords) === null || _a === void 0 ? void 0 : _a.indexOf("Deployed")) > 0) {
873
- // deployed solutions go to the generic content route
874
- hubUrl = `/content/${identifier}`;
875
- }
876
- // others go to the solution about route
877
- hubUrl = `/templates/${identifier}/about`;
878
- }
879
- return hubUrl;
880
- };
881
- // page helpers
882
- // TODO: we check both "Hub Page" and "Site Page" because we don't know whether the site is a portal or not
883
- // In the future, the site object will have a site.isPortal() function that we can leverage
884
- // instead of hardcoding the types here.
885
- const isPageContent = (content) => utils_1.includes(["Hub Page", "Site Page"], content.type);
886
- // proxied csv helpers
887
- /**
888
- * If an item is a proxied csv, returns the url for the proxying feature layer.
889
- * If the item is not a proxied csv, returns undefined.
890
- *
891
- * @param item
892
- * @param requestOptions Hub Request Options (including whether we're in portal)
893
- * @returns
894
- */
895
- exports.getProxyUrl = (item, requestOptions) => {
896
- let result;
897
- if (_internal_1.isProxiedCSV(item, requestOptions)) {
898
- result = `${requestOptions.hubApiUrl}/datasets/${item.id}_0/FeatureServer/0`;
899
- }
900
- return result;
471
+ return _internal_1.getHubRelativeUrl(content.type, siteIdentifier || content.identifier, content.typeKeywords);
901
472
  };
902
473
  //# sourceMappingURL=index.js.map