@esri/hub-common 9.17.0 → 9.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/Hub.js +6 -10
- package/dist/es2017/Hub.js.map +1 -1
- package/dist/es2017/HubError.js +2 -1
- package/dist/es2017/HubError.js.map +1 -1
- package/dist/es2017/content/_internal.js +151 -30
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +607 -0
- package/dist/es2017/content/compose.js.map +1 -0
- package/dist/es2017/content/get-family.js +42 -0
- package/dist/es2017/content/get-family.js.map +1 -0
- package/dist/es2017/content/index.js +42 -468
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/core/types/IHubContentEnrichments.js +1 -0
- package/dist/es2017/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/es2017/core/types/IHubItemEntityManager.js +1 -0
- package/dist/es2017/core/types/IHubItemEntityManager.js.map +1 -0
- package/dist/es2017/core/types/IServerEnrichments.js +1 -0
- package/dist/es2017/core/types/IServerEnrichments.js.map +1 -0
- package/dist/es2017/core/types/index.js +2 -1
- package/dist/es2017/core/types/index.js.map +1 -1
- package/dist/es2017/items/index.js +1 -0
- package/dist/es2017/items/index.js.map +1 -1
- package/dist/es2017/items/setItemThumbnail.js +31 -0
- package/dist/es2017/items/setItemThumbnail.js.map +1 -0
- package/dist/es2017/items/slugs.js +39 -15
- package/dist/es2017/items/slugs.js.map +1 -1
- package/dist/es2017/models/index.js +13 -0
- package/dist/es2017/models/index.js.map +1 -1
- package/dist/es2017/projects/HubProjectManager.js +40 -4
- package/dist/es2017/projects/HubProjectManager.js.map +1 -1
- package/dist/es2017/projects/HubProjects.js +91 -18
- package/dist/es2017/projects/HubProjects.js.map +1 -1
- package/dist/esm/Hub.js +6 -10
- package/dist/esm/Hub.js.map +1 -1
- package/dist/esm/HubError.js +2 -1
- package/dist/esm/HubError.js.map +1 -1
- package/dist/esm/content/_internal.js +153 -30
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +600 -0
- package/dist/esm/content/compose.js.map +1 -0
- package/dist/esm/content/get-family.js +42 -0
- package/dist/esm/content/get-family.js.map +1 -0
- package/dist/esm/content/index.js +44 -476
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/core/types/IHubContentEnrichments.js +1 -0
- package/dist/esm/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/esm/core/types/IHubItemEntityManager.js +1 -0
- package/dist/esm/core/types/IHubItemEntityManager.js.map +1 -0
- package/dist/esm/core/types/IServerEnrichments.js +1 -0
- package/dist/esm/core/types/IServerEnrichments.js.map +1 -0
- package/dist/esm/core/types/index.js +2 -1
- package/dist/esm/core/types/index.js.map +1 -1
- package/dist/esm/items/index.js +1 -0
- package/dist/esm/items/index.js.map +1 -1
- package/dist/esm/items/setItemThumbnail.js +46 -0
- package/dist/esm/items/setItemThumbnail.js.map +1 -0
- package/dist/esm/items/slugs.js +39 -15
- package/dist/esm/items/slugs.js.map +1 -1
- package/dist/esm/models/index.js +23 -1
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/projects/HubProjectManager.js +58 -4
- package/dist/esm/projects/HubProjectManager.js.map +1 -1
- package/dist/esm/projects/HubProjects.js +100 -21
- package/dist/esm/projects/HubProjects.js.map +1 -1
- package/dist/node/Hub.js +6 -10
- package/dist/node/Hub.js.map +1 -1
- package/dist/node/HubError.js +5 -4
- package/dist/node/HubError.js.map +1 -1
- package/dist/node/content/_internal.js +155 -31
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +612 -0
- package/dist/node/content/compose.js.map +1 -0
- package/dist/node/content/get-family.js +46 -0
- package/dist/node/content/get-family.js.map +1 -0
- package/dist/node/content/index.js +48 -477
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/core/types/IHubContentEnrichments.js +3 -0
- package/dist/node/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/node/core/types/IHubItemEntityManager.js +3 -0
- package/dist/node/core/types/IHubItemEntityManager.js.map +1 -0
- package/dist/node/core/types/{IContentEnrichments.js → IServerEnrichments.js} +1 -1
- package/dist/node/core/types/IServerEnrichments.js.map +1 -0
- package/dist/node/core/types/index.js +2 -1
- package/dist/node/core/types/index.js.map +1 -1
- package/dist/node/items/index.js +1 -0
- package/dist/node/items/index.js.map +1 -1
- package/dist/node/items/setItemThumbnail.js +35 -0
- package/dist/node/items/setItemThumbnail.js.map +1 -0
- package/dist/node/items/slugs.js +42 -17
- package/dist/node/items/slugs.js.map +1 -1
- package/dist/node/models/index.js +15 -1
- package/dist/node/models/index.js.map +1 -1
- package/dist/node/projects/HubProjectManager.js +38 -2
- package/dist/node/projects/HubProjectManager.js.map +1 -1
- package/dist/node/projects/HubProjects.js +91 -17
- package/dist/node/projects/HubProjects.js.map +1 -1
- package/dist/types/Hub.d.ts +7 -11
- package/dist/types/HubError.d.ts +1 -1
- package/dist/types/content/_internal.d.ts +57 -22
- package/dist/types/content/compose.d.ts +115 -0
- package/dist/types/content/get-family.d.ts +7 -0
- package/dist/types/content/index.d.ts +4 -86
- package/dist/types/core/types/IHubContent.d.ts +4 -2
- package/dist/types/core/types/IHubContentEnrichments.d.ts +15 -0
- package/dist/types/core/types/IHubEntityManager.d.ts +16 -0
- package/dist/types/core/types/IHubItemEntity.d.ts +1 -1
- package/dist/types/core/types/IHubItemEntityManager.d.ts +15 -0
- package/dist/types/core/types/{IContentEnrichments.d.ts → IServerEnrichments.d.ts} +3 -2
- package/dist/types/core/types/index.d.ts +2 -1
- package/dist/types/items/index.d.ts +1 -0
- package/dist/types/items/setItemThumbnail.d.ts +9 -0
- package/dist/types/items/slugs.d.ts +20 -1
- package/dist/types/models/index.d.ts +8 -0
- package/dist/types/projects/HubProjectManager.d.ts +21 -3
- package/dist/types/projects/HubProjects.d.ts +3 -1
- package/dist/umd/common.umd.js +1238 -663
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/es2017/core/types/IContentEnrichments.js +0 -1
- package/dist/es2017/core/types/IContentEnrichments.js.map +0 -1
- package/dist/esm/core/types/IContentEnrichments.js +0 -1
- package/dist/esm/core/types/IContentEnrichments.js.map +0 -1
- package/dist/node/core/types/IContentEnrichments.js.map +0 -1
package/dist/es2017/Hub.js
CHANGED
|
@@ -12,21 +12,19 @@ import { HubProjectManager } from "./projects/HubProjectManager";
|
|
|
12
12
|
*
|
|
13
13
|
* myHub.context.currentUser //=> {username: "casey", ...} as IUser
|
|
14
14
|
*
|
|
15
|
-
* const
|
|
16
|
-
*
|
|
17
|
-
* const pavingProject = await projectStore.create({name: "12th Street Paving"});
|
|
15
|
+
* const pavingProject = await myHub.projects.create({name: "12th Street Paving"});
|
|
18
16
|
* pavingProject.summary = "This is the 2024 planned paving of 12th Street, between 8th and 11th Ave";
|
|
19
|
-
* await
|
|
17
|
+
* await myHub.projects.update(pavingProject);
|
|
20
18
|
* ```
|
|
21
19
|
*
|
|
22
|
-
* This is a convenience class. Hub
|
|
20
|
+
* This is a convenience class. Hub Managers can be created
|
|
23
21
|
* directly, or the underlying functions can be imported an used
|
|
24
22
|
* as need for scenarios where these class structures introduce
|
|
25
23
|
* unwanted complexity
|
|
26
24
|
*/
|
|
27
25
|
export class Hub {
|
|
28
26
|
/**
|
|
29
|
-
* Private so we can employ a factory function
|
|
27
|
+
* Private so we can employ a factory function to do
|
|
30
28
|
* async work during creation
|
|
31
29
|
* @param contextManager
|
|
32
30
|
*/
|
|
@@ -34,9 +32,7 @@ export class Hub {
|
|
|
34
32
|
this._contextManager = contextManager;
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
|
-
* Factory function to construct a new
|
|
38
|
-
*
|
|
39
|
-
* Note: Used so that we could do async actions in the ctor.
|
|
35
|
+
* Factory function to construct a new Hub instance.
|
|
40
36
|
* @param contextManager
|
|
41
37
|
* @returns
|
|
42
38
|
*/
|
|
@@ -57,7 +53,7 @@ export class Hub {
|
|
|
57
53
|
return this._contextManager.context;
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
60
|
-
*
|
|
56
|
+
* HubProjectManager for the current Hub
|
|
61
57
|
* @returns
|
|
62
58
|
*/
|
|
63
59
|
get projects() {
|
package/dist/es2017/Hub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hub.js","sourceRoot":"","sources":["../../src/Hub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAWjE
|
|
1
|
+
{"version":3,"file":"Hub.js","sourceRoot":"","sources":["../../src/Hub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAWjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,GAAG;IAYd;;;;OAIG;IACH,YAAoB,cAAoC;QACtD,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAoB;QACtC,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;SACxC;aAAM;YACL,MAAM,IAAI,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpD,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;SACrB;IACH,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACV,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;SACrE;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/es2017/HubError.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubError.js","sourceRoot":"","sources":["../../src/HubError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"HubError.js","sourceRoot":"","sources":["../../src/HubError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,cAAc;IAClD;;;;;;OAMG;IACH,YAAY,SAAiB,EAAE,OAAgB,EAAE,SAAiB;QAChE,OAAO,GAAG,OAAO,IAAI,eAAe,CAAC;QACrC,sEAAsE;QACtE,SAAS,GAAG,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAC9D;;;UAGE;QACF,0BAA0B;QAC1B,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,mEAAmE;QACnE,wEAAwE;QACxE,kEAAkE;QAClE,+BAA+B;QAC/B,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use this module for functions that do not need to be used by consumers (yet),
|
|
3
|
-
* but may be shared between hub.js modules, and/or need to be tested
|
|
4
|
-
* to get 100% coverage w/o writing cumbersome tests of higher level functions.
|
|
5
|
-
*
|
|
6
|
-
* Consuming will not be able to import these functions.
|
|
7
|
-
*
|
|
8
|
-
* It's probably a good pattern to add functions here first and then
|
|
9
|
-
* move them to index.ts only when they are needed by a consumer.
|
|
10
|
-
*/
|
|
11
1
|
import { bBoxToPolygon, isBBox } from "../extent";
|
|
2
|
+
import { getFamily } from "./get-family";
|
|
3
|
+
import { getProp } from "../objects";
|
|
12
4
|
/**
|
|
13
5
|
* Create a new content with updated boundary properties
|
|
14
6
|
* @param content original content
|
|
@@ -20,25 +12,11 @@ export const setContentBoundary = (content, boundary) => {
|
|
|
20
12
|
const properties = Object.assign(Object.assign({}, (content.item.properties || {})), { boundary });
|
|
21
13
|
const item = Object.assign(Object.assign({}, content.item), { properties });
|
|
22
14
|
const updated = Object.assign(Object.assign({}, content), { item });
|
|
23
|
-
return Object.assign(Object.assign({}, updated), { boundary: getContentBoundary(
|
|
15
|
+
return Object.assign(Object.assign({}, updated), { boundary: getContentBoundary(item) });
|
|
24
16
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @param content original content
|
|
28
|
-
* @param extent new extent
|
|
29
|
-
* @returns a new content with the updated extent and boundary
|
|
30
|
-
*/
|
|
31
|
-
export const setContentExtent = (content, extent) => {
|
|
32
|
-
// update content's item and extent
|
|
33
|
-
const item = Object.assign(Object.assign({}, content.item), { extent });
|
|
34
|
-
const updated = Object.assign(Object.assign({}, content), { item, extent });
|
|
35
|
-
// derive boundary from content properties
|
|
36
|
-
const boundary = getContentBoundary(updated);
|
|
37
|
-
return Object.assign(Object.assign({}, updated), { boundary });
|
|
38
|
-
};
|
|
39
|
-
const getContentBoundary = (content) => {
|
|
17
|
+
// TODO: this needs to be able to handle "automatic"
|
|
18
|
+
export const getContentBoundary = (item) => {
|
|
40
19
|
var _a;
|
|
41
|
-
const item = content.item;
|
|
42
20
|
const extent = item.extent;
|
|
43
21
|
const isValidItemExtent = isBBox(extent);
|
|
44
22
|
// user specified provenance is stored in item.properties
|
|
@@ -61,7 +39,12 @@ const getContentBoundary = (content) => {
|
|
|
61
39
|
geometry,
|
|
62
40
|
};
|
|
63
41
|
};
|
|
64
|
-
|
|
42
|
+
// when no request options are provided, the underlying
|
|
43
|
+
// request functions assume that we are online in production
|
|
44
|
+
// so we only want use enterprise logic if isPortal is explicitly defined
|
|
45
|
+
export const isPortal = (requestOptions) => {
|
|
46
|
+
return requestOptions && requestOptions.isPortal;
|
|
47
|
+
};
|
|
65
48
|
/**
|
|
66
49
|
* Returns whether or not an item is a proxied csv
|
|
67
50
|
*
|
|
@@ -69,8 +52,146 @@ const MAX_SIZE = 5000000;
|
|
|
69
52
|
* @param requestOptions Hub Request Options (including whether we're in portal)
|
|
70
53
|
* @returns
|
|
71
54
|
*/
|
|
72
|
-
export const isProxiedCSV = (item, requestOptions) => !requestOptions
|
|
55
|
+
export const isProxiedCSV = (item, requestOptions) => !isPortal(requestOptions) &&
|
|
73
56
|
item.access === "public" &&
|
|
74
57
|
item.type === "CSV" &&
|
|
75
|
-
item.size <=
|
|
58
|
+
item.size <= 5000000;
|
|
59
|
+
export const getHubRelativeUrl = (type, identifier, typeKeywords) => {
|
|
60
|
+
// solution types have their own logic
|
|
61
|
+
let contentUrl = getSolutionUrl(type, identifier, typeKeywords);
|
|
62
|
+
if (!contentUrl) {
|
|
63
|
+
const family = getFamily(type);
|
|
64
|
+
const familiesWithPluralizedRoute = [
|
|
65
|
+
"app",
|
|
66
|
+
"dataset",
|
|
67
|
+
"document",
|
|
68
|
+
"map",
|
|
69
|
+
"template",
|
|
70
|
+
];
|
|
71
|
+
// default to the catchall content route
|
|
72
|
+
let path = "/content";
|
|
73
|
+
if (family === "feedback") {
|
|
74
|
+
// the exception
|
|
75
|
+
path = "/feedback/surveys";
|
|
76
|
+
}
|
|
77
|
+
else if (isPageType(type)) {
|
|
78
|
+
// pages are in the document family,
|
|
79
|
+
// but instead of showing the page's metadata on /documents/about
|
|
80
|
+
// but we render the page on the pages route
|
|
81
|
+
path = "/pages";
|
|
82
|
+
}
|
|
83
|
+
else if (familiesWithPluralizedRoute.indexOf(family) > -1) {
|
|
84
|
+
// the rule: route name is plural of family name
|
|
85
|
+
path = `/${family}s`;
|
|
86
|
+
}
|
|
87
|
+
contentUrl = `${path}/${identifier}`;
|
|
88
|
+
}
|
|
89
|
+
return contentUrl;
|
|
90
|
+
};
|
|
91
|
+
export const isPageType = (type) => ["Hub Page", "Site Page"].includes(type);
|
|
92
|
+
const getSolutionUrl = (type, identifier, typeKeywords) => {
|
|
93
|
+
let hubUrl;
|
|
94
|
+
if (type === "Solution") {
|
|
95
|
+
// NOTE: as per the above spreadsheet,
|
|
96
|
+
// solution types are now in the Template family
|
|
97
|
+
// but we don't send them to the route for initiative templates
|
|
98
|
+
if ((typeKeywords === null || typeKeywords === void 0 ? void 0 : typeKeywords.indexOf("Deployed")) > 0) {
|
|
99
|
+
// deployed solutions go to the generic content route
|
|
100
|
+
hubUrl = `/content/${identifier}`;
|
|
101
|
+
}
|
|
102
|
+
// others go to the solution about route
|
|
103
|
+
hubUrl = `/templates/${identifier}/about`;
|
|
104
|
+
}
|
|
105
|
+
return hubUrl;
|
|
106
|
+
};
|
|
107
|
+
export function getMetadataPath(identifier) {
|
|
108
|
+
// NOTE: i have verified that this will work regardless of the "Metadata Style" set on the org
|
|
109
|
+
const metadataPaths = {
|
|
110
|
+
updateFrequency: "metadata.dataIdInfo.resMaint.maintFreq.MaintFreqCd.@_value",
|
|
111
|
+
reviseDate: "metadata.dataIdInfo.idCitation.date.reviseDate",
|
|
112
|
+
pubDate: "metadata.dataIdInfo.idCitation.date.pubDate",
|
|
113
|
+
createDate: "metadata.dataIdInfo.idCitation.date.createDate",
|
|
114
|
+
metadataUpdateFrequency: "metadata.mdMaint.maintFreq.MaintFreqCd.@_value",
|
|
115
|
+
metadataUpdatedDate: "metadata.mdDateSt",
|
|
116
|
+
};
|
|
117
|
+
return metadataPaths[identifier];
|
|
118
|
+
}
|
|
119
|
+
export function getValueFromMetadata(metadata, identifier) {
|
|
120
|
+
const path = getMetadataPath(identifier);
|
|
121
|
+
return path && getProp(metadata, path);
|
|
122
|
+
}
|
|
123
|
+
export var DatePrecision;
|
|
124
|
+
(function (DatePrecision) {
|
|
125
|
+
DatePrecision["Year"] = "year";
|
|
126
|
+
DatePrecision["Month"] = "month";
|
|
127
|
+
DatePrecision["Day"] = "day";
|
|
128
|
+
DatePrecision["Time"] = "time";
|
|
129
|
+
})(DatePrecision || (DatePrecision = {}));
|
|
130
|
+
/**
|
|
131
|
+
* Parses an ISO8601 date string into a date and a precision.
|
|
132
|
+
* This is because a) if somone entered 2018, we want to respect that and not treat it as the same as 2018-01-01
|
|
133
|
+
* and b) you cannot naively call new Date with an ISO 8601 string that does not include time information
|
|
134
|
+
* For example, when I, here in mountain time, do new Date('2018').getFullYear() I get "2017".
|
|
135
|
+
* This is because when you do not provide time or timezone info, UTC is assumed, so new Date('2018') is 2018-01-01T00:00:00 in UTC
|
|
136
|
+
* which is actually 7 hours earlier here in mountain time.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} isoString
|
|
139
|
+
* @return { date: Date, precision: DatePrecision }
|
|
140
|
+
*/
|
|
141
|
+
export function parseISODateString(isoString) {
|
|
142
|
+
isoString = `${isoString}`;
|
|
143
|
+
let date;
|
|
144
|
+
let precision;
|
|
145
|
+
if (/^\d{4}$/.test(isoString)) {
|
|
146
|
+
// yyyy
|
|
147
|
+
date = new Date(+isoString, 0, 1);
|
|
148
|
+
precision = DatePrecision.Year;
|
|
149
|
+
}
|
|
150
|
+
else if (/^\d{4}-\d{1,2}$/.test(isoString)) {
|
|
151
|
+
// yyyy-mm
|
|
152
|
+
const parts = isoString.split("-");
|
|
153
|
+
date = new Date(+parts[0], +parts[1] - 1, 1);
|
|
154
|
+
precision = DatePrecision.Month;
|
|
155
|
+
}
|
|
156
|
+
else if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(isoString)) {
|
|
157
|
+
// yyyy-mm-dd
|
|
158
|
+
const parts = isoString.split("-");
|
|
159
|
+
date = new Date(+parts[0], +parts[1] - 1, +parts[2]);
|
|
160
|
+
precision = DatePrecision.Day;
|
|
161
|
+
}
|
|
162
|
+
else if (!Number.isNaN(Date.parse(isoString))) {
|
|
163
|
+
// any other string parsable to a valid date
|
|
164
|
+
date = new Date(isoString);
|
|
165
|
+
precision = isoString.includes("T")
|
|
166
|
+
? DatePrecision.Time
|
|
167
|
+
: DatePrecision.Day;
|
|
168
|
+
}
|
|
169
|
+
return date && precision && { date, precision };
|
|
170
|
+
}
|
|
171
|
+
export const getServerSpatialReference = (server, layer) => {
|
|
172
|
+
var _a;
|
|
173
|
+
const layerSpatialReference = (_a = layer === null || layer === void 0 ? void 0 : layer.extent) === null || _a === void 0 ? void 0 : _a.spatialReference;
|
|
174
|
+
return layerSpatialReference || (server === null || server === void 0 ? void 0 : server.spatialReference);
|
|
175
|
+
};
|
|
176
|
+
// NOTE: IItem has spatialRefernce: ISpatialReference, but
|
|
177
|
+
// the portal REST API returns spatialReference as as string
|
|
178
|
+
// that is always either WKID like "102100" or
|
|
179
|
+
// WKT like "NAD_1983_HARN_StatePlane_Hawaii_3_FIPS_5103_Feet"
|
|
180
|
+
// so we coerce those string into a ISpatialReference object
|
|
181
|
+
export const getItemSpatialReference = (item) => {
|
|
182
|
+
const spatialReference = item.spatialReference;
|
|
183
|
+
if (!spatialReference || typeof spatialReference === "object") {
|
|
184
|
+
// no need to try and transform this into an ISpatialReference
|
|
185
|
+
return spatialReference;
|
|
186
|
+
}
|
|
187
|
+
// otherwise it _should_ be a string (if coming form the REST API)
|
|
188
|
+
// but we force it in case it was set to a number somewhere outside of TS
|
|
189
|
+
const spatialReferenceString = spatialReference + "";
|
|
190
|
+
const wkid = parseInt(spatialReferenceString, 10);
|
|
191
|
+
return isNaN(wkid)
|
|
192
|
+
? // string is not a number, assume it is WKT
|
|
193
|
+
{ wkt: spatialReferenceString }
|
|
194
|
+
: //
|
|
195
|
+
{ wkid };
|
|
196
|
+
};
|
|
76
197
|
//# sourceMappingURL=_internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internal.js","sourceRoot":"","sources":["../../../src/content/_internal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_internal.js","sourceRoot":"","sources":["../../../src/content/_internal.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAAoB,EACpB,QAA6B,EAC7B,EAAE;IACF,qCAAqC;IACrC,MAAM,UAAU,mCAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,KAAE,QAAQ,GAAE,CAAC;IACpE,MAAM,IAAI,mCAAQ,OAAO,CAAC,IAAI,KAAE,UAAU,GAAE,CAAC;IAC7C,MAAM,OAAO,mCAAQ,OAAO,KAAE,IAAI,GAAE,CAAC;IACrC,uCAAY,OAAO,KAAE,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAG;AAC5D,CAAC,CAAC;AAEF,oDAAoD;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAW,EAAiB,EAAE;;IAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,yDAAyD;IACzD,MAAM,UAAU,GACd,OAAA,IAAI,CAAC,UAAU,0CAAE,QAAQ;QACzB,mDAAmD;QACnD,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC;IACb,QAAQ,UAAU,EAAE;QAClB,KAAK,MA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