@esri/hub-common 20.16.3 → 20.16.4
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/esm/models/fetchModelFromItem.js +17 -1
- package/dist/esm/models/fetchModelFromItem.js.map +1 -1
- package/dist/node/models/fetchModelFromItem.js +19 -2
- package/dist/node/models/fetchModelFromItem.js.map +1 -1
- package/dist/types/models/fetchModelFromItem.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getItemData } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { includes } from "../utils";
|
|
2
3
|
/**
|
|
3
4
|
* Given an Item, fetch the data json and return an IModel
|
|
4
5
|
* @param item
|
|
@@ -6,10 +7,25 @@ import { getItemData } from "@esri/arcgis-rest-portal";
|
|
|
6
7
|
* @returns
|
|
7
8
|
*/
|
|
8
9
|
export async function fetchModelFromItem(item, requestOptions) {
|
|
9
|
-
const data =
|
|
10
|
+
const data = shouldFetchItemData(item)
|
|
11
|
+
? (await getItemData(item.id, requestOptions).catch(() => null))
|
|
12
|
+
: null;
|
|
10
13
|
return {
|
|
11
14
|
item,
|
|
12
15
|
data,
|
|
13
16
|
};
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Determine if we should attempt to fetch the item data
|
|
20
|
+
* @param item
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function shouldFetchItemData(item) {
|
|
24
|
+
// This function can and should be expanded as we discover
|
|
25
|
+
// more item types or families that should not attempt to
|
|
26
|
+
// fetch data for. Example: "Image Collection" will try
|
|
27
|
+
// to download the entire image collection to the browser
|
|
28
|
+
const typesToExclude = ["Image Collection"];
|
|
29
|
+
return !includes(typesToExclude, item.type);
|
|
30
|
+
}
|
|
15
31
|
//# sourceMappingURL=fetchModelFromItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchModelFromItem.js","sourceRoot":"","sources":["../../../src/models/fetchModelFromItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchModelFromItem.js","sourceRoot":"","sources":["../../../src/models/fetchModelFromItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAW,EACX,cAA+B;IAE/B,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;QACpC,CAAC,CAAE,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAG5D;QACJ,CAAC,CAAC,IAAI,CAAC;IACT,OAAO;QACL,IAAI;QACJ,IAAI;KACK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAW;IAC7C,0DAA0D;IAC1D,yDAAyD;IACzD,uDAAuD;IACvD,yDAAyD;IACzD,MAAM,cAAc,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchModelFromItem = void 0;
|
|
3
|
+
exports.shouldFetchItemData = exports.fetchModelFromItem = void 0;
|
|
4
4
|
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
5
6
|
/**
|
|
6
7
|
* Given an Item, fetch the data json and return an IModel
|
|
7
8
|
* @param item
|
|
@@ -9,11 +10,27 @@ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
|
9
10
|
* @returns
|
|
10
11
|
*/
|
|
11
12
|
async function fetchModelFromItem(item, requestOptions) {
|
|
12
|
-
const data =
|
|
13
|
+
const data = shouldFetchItemData(item)
|
|
14
|
+
? (await arcgis_rest_portal_1.getItemData(item.id, requestOptions).catch(() => null))
|
|
15
|
+
: null;
|
|
13
16
|
return {
|
|
14
17
|
item,
|
|
15
18
|
data,
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
exports.fetchModelFromItem = fetchModelFromItem;
|
|
22
|
+
/**
|
|
23
|
+
* Determine if we should attempt to fetch the item data
|
|
24
|
+
* @param item
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
function shouldFetchItemData(item) {
|
|
28
|
+
// This function can and should be expanded as we discover
|
|
29
|
+
// more item types or families that should not attempt to
|
|
30
|
+
// fetch data for. Example: "Image Collection" will try
|
|
31
|
+
// to download the entire image collection to the browser
|
|
32
|
+
const typesToExclude = ["Image Collection"];
|
|
33
|
+
return !utils_1.includes(typesToExclude, item.type);
|
|
34
|
+
}
|
|
35
|
+
exports.shouldFetchItemData = shouldFetchItemData;
|
|
19
36
|
//# sourceMappingURL=fetchModelFromItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchModelFromItem.js","sourceRoot":"","sources":["../../../src/models/fetchModelFromItem.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;
|
|
1
|
+
{"version":3,"file":"fetchModelFromItem.js","sourceRoot":"","sources":["../../../src/models/fetchModelFromItem.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D,oCAAoC;AAEpC;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CACtC,IAAW,EACX,cAA+B;IAE/B,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;QACpC,CAAC,CAAE,CAAC,MAAM,gCAAW,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAG5D;QACJ,CAAC,CAAC,IAAI,CAAC;IACT,OAAO;QACL,IAAI;QACJ,IAAI;KACK,CAAC;AACd,CAAC;AAdD,gDAcC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAW;IAC7C,0DAA0D;IAC1D,yDAAyD;IACzD,uDAAuD;IACvD,yDAAyD;IACzD,MAAM,cAAc,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC5C,OAAO,CAAC,gBAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAPD,kDAOC"}
|
|
@@ -8,3 +8,9 @@ import { IModel } from "../hub-types";
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export declare function fetchModelFromItem(item: IItem, requestOptions: IRequestOptions): Promise<IModel>;
|
|
11
|
+
/**
|
|
12
|
+
* Determine if we should attempt to fetch the item data
|
|
13
|
+
* @param item
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function shouldFetchItemData(item: IItem): boolean;
|