@esri/hub-common 9.21.2 → 9.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/content/_fetch.js +87 -0
- package/dist/es2017/content/_fetch.js.map +1 -0
- package/dist/es2017/content/_internal.js +75 -3
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +59 -22
- package/dist/es2017/content/compose.js.map +1 -1
- package/dist/es2017/content/fetch.js +109 -0
- package/dist/es2017/content/fetch.js.map +1 -0
- package/dist/es2017/content/index.js +9 -80
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/content/slugs.js +63 -0
- package/dist/es2017/content/slugs.js.map +1 -0
- package/dist/es2017/content/types.js +1 -0
- package/dist/es2017/content/types.js.map +1 -0
- package/dist/es2017/items/_enrichments.js +176 -0
- package/dist/es2017/items/_enrichments.js.map +1 -0
- package/dist/esm/content/_fetch.js +102 -0
- package/dist/esm/content/_fetch.js.map +1 -0
- package/dist/esm/content/_internal.js +75 -3
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +60 -21
- package/dist/esm/content/compose.js.map +1 -1
- package/dist/esm/content/fetch.js +177 -0
- package/dist/esm/content/fetch.js.map +1 -0
- package/dist/esm/content/index.js +9 -80
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/content/slugs.js +63 -0
- package/dist/esm/content/slugs.js.map +1 -0
- package/dist/esm/content/types.js +1 -0
- package/dist/esm/content/types.js.map +1 -0
- package/dist/esm/items/_enrichments.js +177 -0
- package/dist/esm/items/_enrichments.js.map +1 -0
- package/dist/node/content/_fetch.js +90 -0
- package/dist/node/content/_fetch.js.map +1 -0
- package/dist/node/content/_internal.js +76 -4
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +59 -22
- package/dist/node/content/compose.js.map +1 -1
- package/dist/node/content/fetch.js +112 -0
- package/dist/node/content/fetch.js.map +1 -0
- package/dist/node/content/index.js +11 -86
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/content/slugs.js +70 -0
- package/dist/node/content/slugs.js.map +1 -0
- package/dist/node/content/types.js +3 -0
- package/dist/node/content/types.js.map +1 -0
- package/dist/node/items/_enrichments.js +179 -0
- package/dist/node/items/_enrichments.js.map +1 -0
- package/dist/types/content/_fetch.d.ts +60 -0
- package/dist/types/content/_internal.d.ts +79 -0
- package/dist/types/content/compose.d.ts +31 -0
- package/dist/types/content/fetch.d.ts +24 -0
- package/dist/types/content/index.d.ts +4 -41
- package/dist/types/content/slugs.d.ts +34 -0
- package/dist/types/content/types.d.ts +7 -0
- package/dist/types/core/types/IHubContent.d.ts +4 -0
- package/dist/types/items/_enrichments.d.ts +24 -0
- package/dist/umd/common.umd.js +2238 -836
- 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 +2 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setContentSiteUrls = exports.getContentSiteUrls = exports.setContentHubId = exports.getContentTypeLabel = exports.setContentType = exports.datasetToItem = exports.datasetToContent = exports.itemToContent = exports.getItemHubType = exports.
|
|
3
|
+
exports.setContentSiteUrls = exports.getContentSiteUrls = exports.setContentHubId = exports.getContentTypeLabel = exports.setContentType = exports.datasetToItem = exports.datasetToContent = exports.itemToContent = exports.getItemHubType = exports.getContentIdentifier = exports.getTypeCategories = exports.getTypes = exports.getCategory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const collections_1 = require("../collections");
|
|
6
6
|
const categories_1 = require("../categories");
|
|
7
|
-
const extent_1 = require("../extent");
|
|
8
7
|
const utils_1 = require("../utils");
|
|
9
8
|
const objects_1 = require("../objects");
|
|
10
9
|
const urls_1 = require("../urls");
|
|
@@ -12,9 +11,13 @@ const _internal_1 = require("./_internal");
|
|
|
12
11
|
const util_1 = require("../util");
|
|
13
12
|
const compose_1 = require("./compose");
|
|
14
13
|
const get_family_1 = require("./get-family");
|
|
14
|
+
const slugs_1 = require("./slugs");
|
|
15
15
|
// re-export functions used in this file
|
|
16
16
|
tslib_1.__exportStar(require("./compose"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./get-family"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./slugs"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./fetch"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
18
21
|
// TODO: remove this at next breaking version
|
|
19
22
|
/**
|
|
20
23
|
* ```js
|
|
@@ -124,78 +127,13 @@ function getContentIdentifier(content, site) {
|
|
|
124
127
|
}
|
|
125
128
|
else {
|
|
126
129
|
// Use shortened slug if the slug's namespace is the same as the orgKey
|
|
127
|
-
slug = removeContextFromSlug(content.slug, orgKey);
|
|
130
|
+
slug = slugs_1.removeContextFromSlug(content.slug, orgKey);
|
|
128
131
|
}
|
|
129
132
|
return slug;
|
|
130
133
|
}
|
|
131
134
|
return content.hubId || content.id;
|
|
132
135
|
}
|
|
133
136
|
exports.getContentIdentifier = getContentIdentifier;
|
|
134
|
-
//////////////////////
|
|
135
|
-
// Slug Helpers
|
|
136
|
-
//////////////////////
|
|
137
|
-
/**
|
|
138
|
-
* Parse item ID and layer ID (if any) from dataset record ID
|
|
139
|
-
*
|
|
140
|
-
* @param datasetId Hub API dataset record id ({itemId}_{layerId} or {itemId})
|
|
141
|
-
* @returns A hash with the `itemId` and `layerId` (if any)
|
|
142
|
-
*/
|
|
143
|
-
function parseDatasetId(datasetId) {
|
|
144
|
-
const [itemId, layerId] = datasetId ? datasetId.split("_") : [];
|
|
145
|
-
return { itemId, layerId };
|
|
146
|
-
}
|
|
147
|
-
exports.parseDatasetId = parseDatasetId;
|
|
148
|
-
/**
|
|
149
|
-
* Determine if an identifier is a Hub API slug
|
|
150
|
-
*
|
|
151
|
-
* @param identifier Hub API slug ({orgKey}::{title-as-slug} or {title-as-slug})
|
|
152
|
-
* or record id ((itemId}_{layerId} or {itemId})
|
|
153
|
-
* @returns true if the identifier is valid _and_ is **not** a record id
|
|
154
|
-
*/
|
|
155
|
-
function isSlug(identifier) {
|
|
156
|
-
const { itemId } = parseDatasetId(identifier);
|
|
157
|
-
if (!itemId || utils_1.isGuid(itemId)) {
|
|
158
|
-
// it's either invalid, or an item id, or a dataset id
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
// otherwise assume it's a slug
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
exports.isSlug = isSlug;
|
|
165
|
-
/**
|
|
166
|
-
* Add a context (prefix) to slug if it doesn't already have one
|
|
167
|
-
*
|
|
168
|
-
* @param slug Hub API slug (with or without context)
|
|
169
|
-
* @param context usually a portal's orgKey
|
|
170
|
-
* @returns slug with context ({context}::{slug})
|
|
171
|
-
*/
|
|
172
|
-
function addContextToSlug(slug, context) {
|
|
173
|
-
// the slug has an org key already e.g. dc::crime-incidents
|
|
174
|
-
if (/.+::.+/.test(slug)) {
|
|
175
|
-
return slug;
|
|
176
|
-
// the slug belongs to the org that owns the site e.g. crime-incidents
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
return `${context}::${slug}`;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
exports.addContextToSlug = addContextToSlug;
|
|
183
|
-
/**
|
|
184
|
-
* Remove context (prefix) from a slug
|
|
185
|
-
*
|
|
186
|
-
* @param slug Hub API slug with context
|
|
187
|
-
* @param context usually a portal's orgKey
|
|
188
|
-
* @returns slug without context
|
|
189
|
-
*/
|
|
190
|
-
function removeContextFromSlug(slug, context) {
|
|
191
|
-
if (context && slug.match(`${context}::`)) {
|
|
192
|
-
return slug.split(`${context}::`)[1];
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
return slug;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.removeContextFromSlug = removeContextFromSlug;
|
|
199
137
|
/**
|
|
200
138
|
* DEPRECATED: Use getFamily() instead.
|
|
201
139
|
*
|
|
@@ -243,7 +181,7 @@ function datasetToContent(dataset) {
|
|
|
243
181
|
// map and feature server enrichments
|
|
244
182
|
server, layers, layer, recordCount, statistics,
|
|
245
183
|
// additional attributes needed
|
|
246
|
-
extent,
|
|
184
|
+
extent, searchDescription, } = dataset.attributes;
|
|
247
185
|
// get the layerId from the layer
|
|
248
186
|
const layerId = layer && layer.id;
|
|
249
187
|
// re-assemble the org as an enrichment
|
|
@@ -253,7 +191,7 @@ function datasetToContent(dataset) {
|
|
|
253
191
|
extent: orgExtent,
|
|
254
192
|
};
|
|
255
193
|
// compose a content out of the above
|
|
256
|
-
|
|
194
|
+
return compose_1.composeContent(item, {
|
|
257
195
|
layerId,
|
|
258
196
|
slug,
|
|
259
197
|
errors,
|
|
@@ -265,23 +203,10 @@ function datasetToContent(dataset) {
|
|
|
265
203
|
layers,
|
|
266
204
|
recordCount,
|
|
267
205
|
boundary,
|
|
206
|
+
extent,
|
|
207
|
+
searchDescription,
|
|
268
208
|
statistics,
|
|
269
209
|
});
|
|
270
|
-
// TODO: need to add searchDescription logic to composeContent()
|
|
271
|
-
// or fetch it as a Hub enrichment like boundary
|
|
272
|
-
if (searchDescription) {
|
|
273
|
-
// overwrite default summary (from snippet) w/ search description
|
|
274
|
-
content.summary = searchDescription;
|
|
275
|
-
}
|
|
276
|
-
// TODO: need to add extent logic to composeContent()
|
|
277
|
-
// or fetch it as a Hub enrichment like boundary
|
|
278
|
-
if (!extent_1.isBBox(item.extent) && extent && extent_1.isBBox(extent.coordinates)) {
|
|
279
|
-
// we fall back to the extent derived by the API
|
|
280
|
-
// which prefers layer or service extents and ultimately
|
|
281
|
-
// falls back to the org's extent
|
|
282
|
-
content.extent = extent.coordinates;
|
|
283
|
-
}
|
|
284
|
-
return content;
|
|
285
210
|
}
|
|
286
211
|
exports.datasetToContent = datasetToContent;
|
|
287
212
|
/**
|
|
@@ -300,7 +225,7 @@ function datasetToItem(dataset) {
|
|
|
300
225
|
return;
|
|
301
226
|
}
|
|
302
227
|
// parse item id
|
|
303
|
-
const { itemId } = parseDatasetId(id);
|
|
228
|
+
const { itemId } = slugs_1.parseDatasetId(id);
|
|
304
229
|
// read item properties from attributes
|
|
305
230
|
// NOTE: we attempt to read all item properties
|
|
306
231
|
// even though some may not be currently returned
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content/index.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content/index.ts"],"names":[],"mappings":";;;;AAIA,gDAA+C;AAC/C,8CAA4D;AAE5D,oCAAoC;AAEpC,wCAAqC;AACrC,kCAAgD;AAChD,2CAA4D;AAC5D,kCAAmC;AACnC,uCAImB;AACnB,6CAAyC;AACzC,mCAAgE;AAGhE,wCAAwC;AACxC,oDAA0B;AAC1B,uDAA6B;AAC7B,kDAAwB;AACxB,kDAAwB;AACxB,kDAAwB;AAExB,6CAA6C;AAC7C;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAAC,WAAmB,EAAE;IAC/C,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CACV,iFAAiF,CAClF,CAAC;IACF,8BAA8B;IAC9B,MAAM,UAAU,GAAG,2BAAa,CAAC,QAAQ,CAAC,CAAC;IAC3C,8BAA8B;IAC9B,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;AACxD,CAAC;AATD,kCASC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,QAAQ,CAAC,WAAmB,EAAE;IAC5C,OAAO,uBAAa,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAC/C,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAAC,OAAY,EAAE;IAC9C,MAAM,IAAI,GAAW,2BAA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qBAAqB,GAAG,CAC5B,OAAoB,EACpB,cAAuB,EACvB,EAAE;IACF,OAAO,6BAAiB,CACtB,OAAO,CAAC,IAAI,EACZ,cAAc,IAAI,OAAO,CAAC,UAAU,EACpC,OAAO,CAAC,YAAY,CACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeContextFromSlug = exports.addContextToSlug = exports.isSlug = exports.parseDatasetId = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
//////////////////////
|
|
6
|
+
// Slug Helpers
|
|
7
|
+
//////////////////////
|
|
8
|
+
/**
|
|
9
|
+
* Parse item ID and layer ID (if any) from dataset record ID
|
|
10
|
+
*
|
|
11
|
+
* @param datasetId Hub API dataset record id ({itemId}_{layerId} or {itemId})
|
|
12
|
+
* @returns A hash with the `itemId` and `layerId` (if any)
|
|
13
|
+
*/
|
|
14
|
+
function parseDatasetId(datasetId) {
|
|
15
|
+
const [itemId, layerId] = datasetId ? datasetId.split("_") : [];
|
|
16
|
+
return { itemId, layerId };
|
|
17
|
+
}
|
|
18
|
+
exports.parseDatasetId = parseDatasetId;
|
|
19
|
+
/**
|
|
20
|
+
* Determine if an identifier is a Hub API slug
|
|
21
|
+
*
|
|
22
|
+
* @param identifier Hub API slug ({orgKey}::{title-as-slug} or {title-as-slug})
|
|
23
|
+
* or record id ((itemId}_{layerId} or {itemId})
|
|
24
|
+
* @returns true if the identifier is valid _and_ is **not** a record id
|
|
25
|
+
*/
|
|
26
|
+
function isSlug(identifier) {
|
|
27
|
+
const { itemId } = parseDatasetId(identifier);
|
|
28
|
+
if (!itemId || utils_1.isGuid(itemId)) {
|
|
29
|
+
// it's either invalid, or an item id, or a dataset id
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// otherwise assume it's a slug
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
exports.isSlug = isSlug;
|
|
36
|
+
/**
|
|
37
|
+
* Add a context (prefix) to slug if it doesn't already have one
|
|
38
|
+
*
|
|
39
|
+
* @param slug Hub API slug (with or without context)
|
|
40
|
+
* @param context usually a portal's orgKey
|
|
41
|
+
* @returns slug with context ({context}::{slug})
|
|
42
|
+
*/
|
|
43
|
+
function addContextToSlug(slug, context) {
|
|
44
|
+
// the slug has an org key already e.g. dc::crime-incidents
|
|
45
|
+
if (/.+::.+/.test(slug)) {
|
|
46
|
+
return slug;
|
|
47
|
+
// the slug belongs to the org that owns the site e.g. crime-incidents
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return `${context}::${slug}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.addContextToSlug = addContextToSlug;
|
|
54
|
+
/**
|
|
55
|
+
* Remove context (prefix) from a slug
|
|
56
|
+
*
|
|
57
|
+
* @param slug Hub API slug with context
|
|
58
|
+
* @param context usually a portal's orgKey
|
|
59
|
+
* @returns slug without context
|
|
60
|
+
*/
|
|
61
|
+
function removeContextFromSlug(slug, context) {
|
|
62
|
+
if (context && slug.match(`${context}::`)) {
|
|
63
|
+
return slug.split(`${context}::`)[1];
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return slug;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.removeContextFromSlug = removeContextFromSlug;
|
|
70
|
+
//# sourceMappingURL=slugs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugs.js","sourceRoot":"","sources":["../../../src/content/slugs.ts"],"names":[],"mappings":";;;AAAA,oCAAkC;AAElC,sBAAsB;AACtB,eAAe;AACf,sBAAsB;AAEtB;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,SAAiB;IAI9C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAND,wCAMC;AAED;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,UAAkB;IACvC,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,IAAI,cAAM,CAAC,MAAM,CAAC,EAAE;QAC7B,sDAAsD;QACtD,OAAO,KAAK,CAAC;KACd;IACD,+BAA+B;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC;AARD,wBAQC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,IAAY,EAAE,OAAe;IAC5D,2DAA2D;IAC3D,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACvB,OAAO,IAAI,CAAC;QACZ,sEAAsE;KACvE;SAAM;QACL,OAAO,GAAG,OAAO,KAAK,IAAI,EAAE,CAAC;KAC9B;AACH,CAAC;AARD,4CAQC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,OAAe;IACjE,IAAI,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,EAAE;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAND,sDAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/content/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchItemEnrichments = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const arcgis_rest_feature_layer_1 = require("@esri/arcgis-rest-feature-layer");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const OperationStack_1 = require("../OperationStack");
|
|
8
|
+
// TODO: move these functions here under /items
|
|
9
|
+
const arcgis_rest_portal_2 = require("@esri/arcgis-rest-portal");
|
|
10
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
11
|
+
function parseMetadataXml(metadataXml) {
|
|
12
|
+
const opts = {
|
|
13
|
+
// options for fastXmlParser to read tag attrs
|
|
14
|
+
ignoreAttributes: false,
|
|
15
|
+
attributeNamePrefix: "@_",
|
|
16
|
+
textNodeName: "#value",
|
|
17
|
+
};
|
|
18
|
+
return fast_xml_parser_1.parse(metadataXml, opts);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Fetch an [item's metadata](https://doc.arcgis.com/en/arcgis-online/manage-data/metadata.htm) from a portal
|
|
22
|
+
* and parse and return it as JSON
|
|
23
|
+
* @param id item id
|
|
24
|
+
* @param requestOptions
|
|
25
|
+
*/
|
|
26
|
+
function fetchContentMetadata(id, requestOptions) {
|
|
27
|
+
return arcgis_rest_portal_2.getItemMetadata(id, requestOptions)
|
|
28
|
+
.then((metadataXml) => parseMetadataXml(metadataXml))
|
|
29
|
+
.catch(() => {
|
|
30
|
+
// many items don't have metadata and the request will 404
|
|
31
|
+
// in these cases we don't want to treat it as an error
|
|
32
|
+
// content.metadata === null signals to consumers that
|
|
33
|
+
// we attempted to fetch the metadata, but it doesn't exist
|
|
34
|
+
// TODO: we should probably still throw the error if it's not a 404
|
|
35
|
+
return null;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const enrichGroupIds = (input) => {
|
|
39
|
+
const { data, stack, requestOptions } = input;
|
|
40
|
+
const opId = stack.start("enrichGroupIds");
|
|
41
|
+
return arcgis_rest_portal_1.getItemGroups(data.item.id, requestOptions)
|
|
42
|
+
.then((response) => {
|
|
43
|
+
const { admin, member, other } = response;
|
|
44
|
+
const groupIds = [...admin, ...member, ...other].map((group) => group.id);
|
|
45
|
+
stack.finish(opId);
|
|
46
|
+
return {
|
|
47
|
+
data: Object.assign(Object.assign({}, data), { groupIds }),
|
|
48
|
+
stack,
|
|
49
|
+
requestOptions,
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => handleEnrichmentError(error, input, opId));
|
|
53
|
+
};
|
|
54
|
+
const enrichMetadata = (input) => {
|
|
55
|
+
const { data, stack, requestOptions } = input;
|
|
56
|
+
const opId = stack.start("enrichMetadata");
|
|
57
|
+
return fetchContentMetadata(data.item.id, requestOptions).then((metadata) => {
|
|
58
|
+
stack.finish(opId);
|
|
59
|
+
return {
|
|
60
|
+
data: Object.assign(Object.assign({}, data), { metadata }),
|
|
61
|
+
stack,
|
|
62
|
+
requestOptions,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
// TODO: currently fetchContentMetadata will never throw, but
|
|
66
|
+
// if we update it to throw for non-404 errors, need to uncomment this:
|
|
67
|
+
// .catch((error) => handleEnrichmentError(error, input, opId));
|
|
68
|
+
};
|
|
69
|
+
const enrichOwnerUser = (input) => {
|
|
70
|
+
const { data, stack, requestOptions } = input;
|
|
71
|
+
const opId = stack.start("enrichOwner");
|
|
72
|
+
// w/o the : any here, I get a compile error about
|
|
73
|
+
// .authentication being incompatible w/ UserSession
|
|
74
|
+
const options = Object.assign({ username: data.item.owner }, requestOptions);
|
|
75
|
+
return arcgis_rest_portal_1.getUser(options)
|
|
76
|
+
.then((ownerUser) => {
|
|
77
|
+
stack.finish(opId);
|
|
78
|
+
return {
|
|
79
|
+
data: Object.assign(Object.assign({}, data), { ownerUser }),
|
|
80
|
+
stack,
|
|
81
|
+
requestOptions,
|
|
82
|
+
};
|
|
83
|
+
})
|
|
84
|
+
.catch((error) => handleEnrichmentError(error, input, opId));
|
|
85
|
+
};
|
|
86
|
+
const enrichData = (input) => {
|
|
87
|
+
const { data, stack, requestOptions } = input;
|
|
88
|
+
const opId = stack.start("enrichData");
|
|
89
|
+
return arcgis_rest_portal_1.getItemData(data.item.id, requestOptions)
|
|
90
|
+
.then((itemData) => {
|
|
91
|
+
stack.finish(opId);
|
|
92
|
+
return { data: Object.assign(Object.assign({}, data), { data: itemData }), stack, requestOptions };
|
|
93
|
+
})
|
|
94
|
+
.catch((error) => handleEnrichmentError(error, input, opId));
|
|
95
|
+
};
|
|
96
|
+
const enrichServer = (input) => {
|
|
97
|
+
const { data, stack, requestOptions } = input;
|
|
98
|
+
const opId = stack.start("enrichServer");
|
|
99
|
+
const url = data.item.url;
|
|
100
|
+
const options = Object.assign(Object.assign({}, requestOptions), { url });
|
|
101
|
+
return arcgis_rest_feature_layer_1.getService(options)
|
|
102
|
+
.then((server) => {
|
|
103
|
+
stack.finish(opId);
|
|
104
|
+
return { data: Object.assign(Object.assign({}, data), { server }), stack, requestOptions };
|
|
105
|
+
})
|
|
106
|
+
.catch((error) => handleEnrichmentError(error, input, opId));
|
|
107
|
+
};
|
|
108
|
+
const enrichLayers = (input) => {
|
|
109
|
+
const { data, stack, requestOptions } = input;
|
|
110
|
+
const opId = stack.start("enrichLayers");
|
|
111
|
+
const url = data.item.url;
|
|
112
|
+
const options = Object.assign(Object.assign({}, requestOptions), { url });
|
|
113
|
+
return (arcgis_rest_feature_layer_1.getAllLayersAndTables(options)
|
|
114
|
+
// merge layers and tables into a single array
|
|
115
|
+
// and filter out any group layers
|
|
116
|
+
.then((response) => {
|
|
117
|
+
const merged = [...response.layers, ...response.tables];
|
|
118
|
+
return merged.filter((layer) => layer.type !== "Group Layer");
|
|
119
|
+
})
|
|
120
|
+
.then((layers) => {
|
|
121
|
+
stack.finish(opId);
|
|
122
|
+
return { data: Object.assign(Object.assign({}, data), { layers }), stack, requestOptions };
|
|
123
|
+
})
|
|
124
|
+
.catch((error) => handleEnrichmentError(error, input, opId)));
|
|
125
|
+
};
|
|
126
|
+
// add the error to the content.errors,
|
|
127
|
+
// log current stack operation as finished with an error
|
|
128
|
+
// and return output that can be piped into the next operation
|
|
129
|
+
const handleEnrichmentError = (error, input, opId) => {
|
|
130
|
+
const { data, stack, requestOptions } = input;
|
|
131
|
+
stack.finish(opId, { error });
|
|
132
|
+
const message = typeof error === "string"
|
|
133
|
+
? /* istanbul ignore next our tests only throw Error objects */
|
|
134
|
+
error
|
|
135
|
+
: error.message;
|
|
136
|
+
const errors = data.errors || [];
|
|
137
|
+
errors.push({
|
|
138
|
+
// NOTE: for now we just return the message and type "Other"
|
|
139
|
+
// but we could later introspect for HTTP or AGO errors
|
|
140
|
+
// and/or return the status code if available
|
|
141
|
+
type: "Other",
|
|
142
|
+
message,
|
|
143
|
+
});
|
|
144
|
+
return { data: Object.assign(Object.assign({}, data), { errors }), stack, requestOptions };
|
|
145
|
+
};
|
|
146
|
+
const enrichmentOperations = {
|
|
147
|
+
groupIds: enrichGroupIds,
|
|
148
|
+
metadata: enrichMetadata,
|
|
149
|
+
ownerUser: enrichOwnerUser,
|
|
150
|
+
// TOOD: org
|
|
151
|
+
data: enrichData,
|
|
152
|
+
server: enrichServer,
|
|
153
|
+
layers: enrichLayers,
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Fetch enrichments for an item
|
|
157
|
+
* @param item
|
|
158
|
+
* @param enrichments the list of enrichments to fetch
|
|
159
|
+
* @param requestOptions
|
|
160
|
+
* @returns an object with the item and enrichments
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
exports.fetchItemEnrichments = (item, enrichments, requestOptions) => {
|
|
164
|
+
// create a pipeline of enrichment operations
|
|
165
|
+
const operations = enrichments.reduce((ops, enrichment) => {
|
|
166
|
+
const operation = enrichmentOperations[enrichment];
|
|
167
|
+
// only include the enrichments that we know how to fetch
|
|
168
|
+
operation && ops.push(operation);
|
|
169
|
+
return ops;
|
|
170
|
+
}, []);
|
|
171
|
+
const pipeline = utils_1.createOperationPipeline(operations);
|
|
172
|
+
// execute pipeline and return the item and enrichments
|
|
173
|
+
return pipeline({
|
|
174
|
+
data: { item },
|
|
175
|
+
stack: new OperationStack_1.default(),
|
|
176
|
+
requestOptions,
|
|
177
|
+
}).then((output) => output.data);
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=_enrichments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_enrichments.js","sourceRoot":"","sources":["../../../src/items/_enrichments.ts"],"names":[],"mappings":";;;AAAA,iEAKkC;AAClC,+EAGyC;AAGzC,oCAA8D;AAC9D,sDAA+C;AAC/C,+CAA+C;AAC/C,iEAA2D;AAC3D,qDAAwC;AAoBxC,SAAS,gBAAgB,CAAC,WAAmB;IAC3C,MAAM,IAAI,GAAG;QACX,8CAA8C;QAC9C,gBAAgB,EAAE,KAAK;QACvB,mBAAmB,EAAE,IAAI;QACzB,YAAY,EAAE,QAAQ;KACvB,CAAC;IACF,OAAO,uBAAK,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAC3B,EAAU,EACV,cAAmC;IAEnC,OAAO,oCAAe,CAAC,EAAE,EAAE,cAAc,CAAC;SACvC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;SACpD,KAAK,CAAC,GAAG,EAAE;QACV,0DAA0D;QAC1D,uDAAuD;QACvD,sDAAsD;QACtD,2DAA2D;QAC3D,mEAAmE;QACnE,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,cAAc,GAAG,CACrB,KAAqC,EACI,EAAE;IAC3C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC3C,OAAO,kCAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,CAAC;SAC/C,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACj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EACX,WAAqC,EACrC,cAAmC,EACnC,EAAE;IACF,6CAA6C;IAC7C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACnD,yDAAyD;QACzD,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,QAAQ,GAAG,+BAAuB,CAAsB,UAAU,CAAC,CAAC;IAC1E,uDAAuD;IACvD,OAAO,QAAQ,CAAC;QACd,IAAI,EAAE,EAAE,IAAI,EAAE;QACd,KAAK,EAAE,IAAI,wBAAc,EAAE;QAC3B,cAAc;KACf,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { IItem } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { ItemOrServerEnrichment } from "../items/_enrichments";
|
|
3
|
+
import { BBox, IHubRequestOptions, IHubGeography } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* get the default list of enrichments to fetch for content
|
|
6
|
+
* @param item
|
|
7
|
+
* @returns the default list of enrichments to fetch for content
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export declare const getContentEnrichments: (item: IItem) => ItemOrServerEnrichment[];
|
|
11
|
+
/**
|
|
12
|
+
* The extent returned by the Hub API
|
|
13
|
+
*/
|
|
14
|
+
export interface IHubExtent {
|
|
15
|
+
coordinates?: BBox;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The set of enrichments that we fetch from the Hub API
|
|
19
|
+
*/
|
|
20
|
+
export interface IDatasetEnrichments {
|
|
21
|
+
itemId: string;
|
|
22
|
+
layerId?: number;
|
|
23
|
+
slug?: string;
|
|
24
|
+
/**
|
|
25
|
+
* boundary will default to the item extent
|
|
26
|
+
* but can be overwritten by enrichments from the Hub API (inline)
|
|
27
|
+
* or fetched from a location such as /resources/boundary.json
|
|
28
|
+
*/
|
|
29
|
+
boundary?: IHubGeography;
|
|
30
|
+
/**
|
|
31
|
+
* Either the item's extent, or the item's
|
|
32
|
+
* layer or server's extent converted to a lat/lng coordinate pair
|
|
33
|
+
*/
|
|
34
|
+
extent?: IHubExtent;
|
|
35
|
+
/**
|
|
36
|
+
* The appropriate summary to show for the item, coming from either
|
|
37
|
+
* the item's data (for pages or initiatives) or the item's description
|
|
38
|
+
*/
|
|
39
|
+
searchDescription?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Pre-computed field statistics (min, max, average, etc)
|
|
42
|
+
*/
|
|
43
|
+
statistics?: any;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* fetch enrichment from the Hub API by slug
|
|
47
|
+
* @param slug
|
|
48
|
+
* @param requestOptions
|
|
49
|
+
* @returns enrichments from the Hub API (slug, boundary, statistic, etc)
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
export declare const fetchHubEnrichmentsBySlug: (slug: string, requestOptions: IHubRequestOptions) => Promise<IDatasetEnrichments>;
|
|
53
|
+
/**
|
|
54
|
+
* fetch enrichment from the Hub API by id
|
|
55
|
+
* @param slug
|
|
56
|
+
* @param requestOptions
|
|
57
|
+
* @returns enrichments from the Hub API (slug, boundary, statistic, etc)
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
export declare const fetchHubEnrichmentsById: (hubId: string, requestOptions: IHubRequestOptions) => Promise<IDatasetEnrichments>;
|