@esri/hub-common 9.21.1 → 9.23.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/_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 +60 -21
- 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 -70
- 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 +61 -20
- 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 -70
- 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 +60 -21
- 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 -76
- 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 +2075 -662
- 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,6 +1,6 @@
|
|
|
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");
|
|
@@ -11,9 +11,13 @@ const _internal_1 = require("./_internal");
|
|
|
11
11
|
const util_1 = require("../util");
|
|
12
12
|
const compose_1 = require("./compose");
|
|
13
13
|
const get_family_1 = require("./get-family");
|
|
14
|
+
const slugs_1 = require("./slugs");
|
|
14
15
|
// re-export functions used in this file
|
|
15
16
|
tslib_1.__exportStar(require("./compose"), exports);
|
|
16
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);
|
|
17
21
|
// TODO: remove this at next breaking version
|
|
18
22
|
/**
|
|
19
23
|
* ```js
|
|
@@ -123,78 +127,13 @@ function getContentIdentifier(content, site) {
|
|
|
123
127
|
}
|
|
124
128
|
else {
|
|
125
129
|
// Use shortened slug if the slug's namespace is the same as the orgKey
|
|
126
|
-
slug = removeContextFromSlug(content.slug, orgKey);
|
|
130
|
+
slug = slugs_1.removeContextFromSlug(content.slug, orgKey);
|
|
127
131
|
}
|
|
128
132
|
return slug;
|
|
129
133
|
}
|
|
130
134
|
return content.hubId || content.id;
|
|
131
135
|
}
|
|
132
136
|
exports.getContentIdentifier = getContentIdentifier;
|
|
133
|
-
//////////////////////
|
|
134
|
-
// Slug Helpers
|
|
135
|
-
//////////////////////
|
|
136
|
-
/**
|
|
137
|
-
* Parse item ID and layer ID (if any) from dataset record ID
|
|
138
|
-
*
|
|
139
|
-
* @param datasetId Hub API dataset record id ({itemId}_{layerId} or {itemId})
|
|
140
|
-
* @returns A hash with the `itemId` and `layerId` (if any)
|
|
141
|
-
*/
|
|
142
|
-
function parseDatasetId(datasetId) {
|
|
143
|
-
const [itemId, layerId] = datasetId ? datasetId.split("_") : [];
|
|
144
|
-
return { itemId, layerId };
|
|
145
|
-
}
|
|
146
|
-
exports.parseDatasetId = parseDatasetId;
|
|
147
|
-
/**
|
|
148
|
-
* Determine if an identifier is a Hub API slug
|
|
149
|
-
*
|
|
150
|
-
* @param identifier Hub API slug ({orgKey}::{title-as-slug} or {title-as-slug})
|
|
151
|
-
* or record id ((itemId}_{layerId} or {itemId})
|
|
152
|
-
* @returns true if the identifier is valid _and_ is **not** a record id
|
|
153
|
-
*/
|
|
154
|
-
function isSlug(identifier) {
|
|
155
|
-
const { itemId } = parseDatasetId(identifier);
|
|
156
|
-
if (!itemId || utils_1.isGuid(itemId)) {
|
|
157
|
-
// it's either invalid, or an item id, or a dataset id
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
// otherwise assume it's a slug
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
exports.isSlug = isSlug;
|
|
164
|
-
/**
|
|
165
|
-
* Add a context (prefix) to slug if it doesn't already have one
|
|
166
|
-
*
|
|
167
|
-
* @param slug Hub API slug (with or without context)
|
|
168
|
-
* @param context usually a portal's orgKey
|
|
169
|
-
* @returns slug with context ({context}::{slug})
|
|
170
|
-
*/
|
|
171
|
-
function addContextToSlug(slug, context) {
|
|
172
|
-
// the slug has an org key already e.g. dc::crime-incidents
|
|
173
|
-
if (/.+::.+/.test(slug)) {
|
|
174
|
-
return slug;
|
|
175
|
-
// the slug belongs to the org that owns the site e.g. crime-incidents
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
return `${context}::${slug}`;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
exports.addContextToSlug = addContextToSlug;
|
|
182
|
-
/**
|
|
183
|
-
* Remove context (prefix) from a slug
|
|
184
|
-
*
|
|
185
|
-
* @param slug Hub API slug with context
|
|
186
|
-
* @param context usually a portal's orgKey
|
|
187
|
-
* @returns slug without context
|
|
188
|
-
*/
|
|
189
|
-
function removeContextFromSlug(slug, context) {
|
|
190
|
-
if (context && slug.match(`${context}::`)) {
|
|
191
|
-
return slug.split(`${context}::`)[1];
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
return slug;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
exports.removeContextFromSlug = removeContextFromSlug;
|
|
198
137
|
/**
|
|
199
138
|
* DEPRECATED: Use getFamily() instead.
|
|
200
139
|
*
|
|
@@ -242,7 +181,7 @@ function datasetToContent(dataset) {
|
|
|
242
181
|
// map and feature server enrichments
|
|
243
182
|
server, layers, layer, recordCount, statistics,
|
|
244
183
|
// additional attributes needed
|
|
245
|
-
searchDescription, } = dataset.attributes;
|
|
184
|
+
extent, searchDescription, } = dataset.attributes;
|
|
246
185
|
// get the layerId from the layer
|
|
247
186
|
const layerId = layer && layer.id;
|
|
248
187
|
// re-assemble the org as an enrichment
|
|
@@ -252,7 +191,7 @@ function datasetToContent(dataset) {
|
|
|
252
191
|
extent: orgExtent,
|
|
253
192
|
};
|
|
254
193
|
// compose a content out of the above
|
|
255
|
-
|
|
194
|
+
return compose_1.composeContent(item, {
|
|
256
195
|
layerId,
|
|
257
196
|
slug,
|
|
258
197
|
errors,
|
|
@@ -264,14 +203,10 @@ function datasetToContent(dataset) {
|
|
|
264
203
|
layers,
|
|
265
204
|
recordCount,
|
|
266
205
|
boundary,
|
|
206
|
+
extent,
|
|
207
|
+
searchDescription,
|
|
267
208
|
statistics,
|
|
268
209
|
});
|
|
269
|
-
// TODO: need to add searchDescription logic to composeContent()
|
|
270
|
-
if (searchDescription) {
|
|
271
|
-
// overwrite default summary (from snippet) w/ search description
|
|
272
|
-
content.summary = searchDescription;
|
|
273
|
-
}
|
|
274
|
-
return content;
|
|
275
210
|
}
|
|
276
211
|
exports.datasetToContent = datasetToContent;
|
|
277
212
|
/**
|
|
@@ -290,7 +225,7 @@ function datasetToItem(dataset) {
|
|
|
290
225
|
return;
|
|
291
226
|
}
|
|
292
227
|
// parse item id
|
|
293
|
-
const { itemId } = parseDatasetId(id);
|
|
228
|
+
const { itemId } = slugs_1.parseDatasetId(id);
|
|
294
229
|
// read item properties from attributes
|
|
295
230
|
// NOTE: we attempt to read all item properties
|
|
296
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":[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qBAAqB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAChE,mDAAmD;IACnD,MAAM,OAAO,GAAG,iBAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAC;IAEzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;;GAMG;AACU,QAAA,kBAAkB,GAAG,CAChC,OAAoB,EACpB,SAAiB,EACJ,EAAE;IACf,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,0BAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5E,2CAA2C;IAC3C,OAAO,iBAAiB,CAAC,OAAO,EAAE;QAChC,QAAQ;QACR,IAAI;KACL,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,cAAc;AACd,MAAM,iBAAiB,GAAG,CACxB,OAAoB,EACpB,OAA+B,EAClB,EAAE;IACf,6DAA6D;IAC7D,MAAM,IAAI,mCAAQ,OAAO,CAAC,IAAI,GAAK,OAAO,CAAE,CAAC;IAC7C,uCAAY,OAAO,KAAE,IAAI,IAAG;AAC9B,CAAC,CAAC;AAEF,MAAM,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,8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vD,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>;
|
|
@@ -19,6 +19,7 @@ import { IHubAdditionalResource } from "../core/types/IHubAdditionalResource";
|
|
|
19
19
|
* @param content original content
|
|
20
20
|
* @param boundary boundary provenance
|
|
21
21
|
* @returns
|
|
22
|
+
* @private
|
|
22
23
|
*/
|
|
23
24
|
export declare const setContentBoundary: (content: IHubContent, boundary: GeographyProvenance) => {
|
|
24
25
|
boundary: IHubGeography;
|
|
@@ -67,6 +68,9 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
|
|
|
67
68
|
layer?: Partial<ILayerDefinition>;
|
|
68
69
|
isProxied?: boolean;
|
|
69
70
|
additionalResources?: IHubAdditionalResource[];
|
|
71
|
+
viewDefinition?: {
|
|
72
|
+
definitionExpression?: string;
|
|
73
|
+
};
|
|
70
74
|
itemCategories?: string[];
|
|
71
75
|
normalizedType?: string;
|
|
72
76
|
orgId?: string;
|
|
@@ -109,18 +113,60 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
|
|
|
109
113
|
spatialReference?: ISpatialReference;
|
|
110
114
|
properties?: any;
|
|
111
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* get a content's boundary based on the item's boundary property
|
|
118
|
+
* @param item
|
|
119
|
+
* @returns
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
112
122
|
export declare const getContentBoundary: (item: IItem) => IHubGeography;
|
|
123
|
+
/**
|
|
124
|
+
* Determine if we are in an enterprise environment
|
|
125
|
+
* NOTE: when no request options are provided, the underlying
|
|
126
|
+
* request functions assume that we are online in production
|
|
127
|
+
* so we only want use enterprise logic if isPortal is explicitly defined
|
|
128
|
+
* @param requestOptions
|
|
129
|
+
* @returns
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
113
132
|
export declare const isPortal: (requestOptions?: IHubRequestOptions) => boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Determine if we can use the Hub API for an item, i.e.
|
|
135
|
+
* the item is public and we are not in an enterprise environment
|
|
136
|
+
* @param item
|
|
137
|
+
* @param requestOptions
|
|
138
|
+
* @returns
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
export declare const canUseHubApiForItem: (item: IItem, requestOptions?: IHubRequestOptions) => boolean;
|
|
114
142
|
/**
|
|
115
143
|
* Returns whether or not an item is a proxied csv
|
|
116
144
|
*
|
|
117
145
|
* @param item
|
|
118
146
|
* @param requestOptions Hub Request Options (including whether we're in portal)
|
|
119
147
|
* @returns
|
|
148
|
+
* @private
|
|
120
149
|
*/
|
|
121
150
|
export declare const isProxiedCSV: (item: IItem, requestOptions?: IHubRequestOptions) => boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Get the relative URL to use for the item in a hub site
|
|
153
|
+
* @param type
|
|
154
|
+
* @param identifier
|
|
155
|
+
* @param typeKeywords
|
|
156
|
+
* @returns
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
122
159
|
export declare const getHubRelativeUrl: (type: string, identifier: string, typeKeywords?: string[]) => string;
|
|
160
|
+
/**
|
|
161
|
+
* Is this content type a page?
|
|
162
|
+
* @param type
|
|
163
|
+
* @returns
|
|
164
|
+
* @private
|
|
165
|
+
*/
|
|
123
166
|
export declare const isPageType: (type: string) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* well known paths to formal metadata values
|
|
169
|
+
*/
|
|
124
170
|
export interface IMetadataPaths {
|
|
125
171
|
updateFrequency: string;
|
|
126
172
|
metadataUpdateFrequency: string;
|
|
@@ -129,8 +175,24 @@ export interface IMetadataPaths {
|
|
|
129
175
|
pubDate: string;
|
|
130
176
|
createDate: string;
|
|
131
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Get the path to a well known metadata value
|
|
180
|
+
* @param identifier identifier for well known metadata value
|
|
181
|
+
* @returns path to be used like get(metadata, path)
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
132
184
|
export declare function getMetadataPath(identifier: keyof IMetadataPaths): string;
|
|
185
|
+
/**
|
|
186
|
+
* Get a well known value from metadata
|
|
187
|
+
* @param metadata
|
|
188
|
+
* @param identifier identifier for well known metadata value
|
|
189
|
+
* @returns
|
|
190
|
+
* @private
|
|
191
|
+
*/
|
|
133
192
|
export declare function getValueFromMetadata(metadata: any, identifier: keyof IMetadataPaths): any;
|
|
193
|
+
/**
|
|
194
|
+
* Date precisions
|
|
195
|
+
*/
|
|
134
196
|
export declare enum DatePrecision {
|
|
135
197
|
Year = "year",
|
|
136
198
|
Month = "month",
|
|
@@ -147,12 +209,26 @@ export declare enum DatePrecision {
|
|
|
147
209
|
*
|
|
148
210
|
* @param {string} isoString
|
|
149
211
|
* @return { date: Date, precision: DatePrecision }
|
|
212
|
+
* @private
|
|
150
213
|
*/
|
|
151
214
|
export declare function parseISODateString(isoString: string): {
|
|
152
215
|
date: Date;
|
|
153
216
|
precision: DatePrecision;
|
|
154
217
|
};
|
|
218
|
+
/**
|
|
219
|
+
* Get the spatial reference from layer or server info
|
|
220
|
+
* @param server
|
|
221
|
+
* @param layer
|
|
222
|
+
* @returns
|
|
223
|
+
* @private
|
|
224
|
+
*/
|
|
155
225
|
export declare const getServerSpatialReference: (server: Partial<IFeatureServiceDefinition>, layer?: ILayerDefinition) => ISpatialReference;
|
|
226
|
+
/**
|
|
227
|
+
* Get the spatial reference as an object for an item
|
|
228
|
+
* @param item
|
|
229
|
+
* @returns spatial reference object
|
|
230
|
+
* @private
|
|
231
|
+
*/
|
|
156
232
|
export declare const getItemSpatialReference: (item: IItem) => ISpatialReference;
|
|
157
233
|
/**
|
|
158
234
|
* Data model for additional resources that are extracted
|
|
@@ -171,6 +247,7 @@ interface IAGOAdditionalResource {
|
|
|
171
247
|
* @param item
|
|
172
248
|
* @param metadata formal metadata
|
|
173
249
|
* @returns
|
|
250
|
+
* @private
|
|
174
251
|
*/
|
|
175
252
|
export declare const getAdditionalResources: (item: IItem, metadata?: any, requestOptions?: IHubRequestOptions) => IHubAdditionalResource[];
|
|
176
253
|
/**
|
|
@@ -181,6 +258,7 @@ export declare const getAdditionalResources: (item: IItem, metadata?: any, reque
|
|
|
181
258
|
* @param resource raw additional resource of an item
|
|
182
259
|
* @param item
|
|
183
260
|
* @returns
|
|
261
|
+
* @private
|
|
184
262
|
*/
|
|
185
263
|
export declare const isDataSourceOfItem: (resource: IAGOAdditionalResource, item: IItem) => boolean;
|
|
186
264
|
/**
|
|
@@ -193,6 +271,7 @@ export declare const isDataSourceOfItem: (resource: IAGOAdditionalResource, item
|
|
|
193
271
|
* @param item
|
|
194
272
|
* @param requestOptions IHubRequestOptions, including authentication
|
|
195
273
|
* @returns
|
|
274
|
+
* @private
|
|
196
275
|
*/
|
|
197
276
|
export declare const getAdditionalResourceUrl: (resource: IAGOAdditionalResource, item: IItem, requestOptions?: IHubRequestOptions) => string;
|
|
198
277
|
export {};
|