@arcgis/ai-components 5.2.0-next.2 → 5.2.0-next.21
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/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +23 -22
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +36 -7
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/cdn/27NEUQN3.js +2 -0
- package/dist/cdn/2NMR43NW.js +2 -0
- package/dist/cdn/3YMSOD5D.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4I4MCV7V.js +71 -0
- package/dist/cdn/4RZPOYZ7.js +9 -0
- package/dist/cdn/5SBLS4NW.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
- package/dist/cdn/6LZ6GOHF.js +56 -0
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/ASSH4WSC.js +36 -0
- package/dist/cdn/BFPMQT3A.js +2 -0
- package/dist/cdn/C7E7MJSR.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/CIW3QMKV.js +2 -0
- package/dist/cdn/CJIV4KJZ.js +179 -0
- package/dist/cdn/CVHJMR5X.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
- package/dist/cdn/E7TMP4YV.js +3 -0
- package/dist/cdn/EBRNMPPO.js +48 -0
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/GJUD7EA3.js +3 -0
- package/dist/cdn/HCR23HJB.js +2 -0
- package/dist/cdn/HOCTVCHH.js +2 -0
- package/dist/cdn/I64KIZG3.js +2 -0
- package/dist/cdn/IB4WTK74.js +2 -0
- package/dist/cdn/IC5P5NYY.js +2 -0
- package/dist/cdn/ICA7JOSU.js +161 -0
- package/dist/cdn/IKEF7ZHH.js +181 -0
- package/dist/cdn/IXAKT6L3.js +2 -0
- package/dist/cdn/JEIMRNYM.js +2 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
- package/dist/cdn/{4HU7735A.js → KTOL6IN7.js} +6 -4
- package/dist/cdn/L77BTGXY.js +2 -0
- package/dist/cdn/LODKJRS4.js +2 -0
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/NOJYPREL.js +3 -0
- package/dist/cdn/NXKKG5TK.js +2 -0
- package/dist/cdn/O3F47IO5.js +2 -0
- package/dist/cdn/O7TGCM5P.js +6 -0
- package/dist/cdn/PBTINZTK.js +65 -0
- package/dist/cdn/PDEBKVBO.js +22 -0
- package/dist/cdn/PDT6I6TZ.js +2 -0
- package/dist/cdn/PSWI3MFB.js +2 -0
- package/dist/cdn/Q7TL5Q5N.js +2 -0
- package/dist/cdn/QSA4T3BU.js +2 -0
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/ROLXMEVE.js +18 -0
- package/dist/cdn/RX45PCYB.js +9 -0
- package/dist/cdn/SMADRJ67.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/U53OEX6L.js +2 -0
- package/dist/cdn/VDXSALQI.js +2 -0
- package/dist/cdn/VKU4WAQV.js +2 -0
- package/dist/cdn/W2JAKE2M.js +2 -0
- package/dist/cdn/WAVKMZA6.js +2 -0
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/WNS5ZUF5.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
- package/dist/cdn/XGS5EIA5.js +14 -0
- package/dist/cdn/XVQJBUMY.js +2 -0
- package/dist/cdn/YJ3QQXF6.js +2 -0
- package/dist/cdn/YYY7HKYX.js +2 -0
- package/dist/cdn/ZEYIBYSF.js +66 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +1410 -1342
- package/dist/chunks/arcgisKnowledgeGraph.js +110 -72
- package/dist/chunks/converterUtils.js +39 -32
- package/dist/chunks/dataExplorationGraph.js +139 -113
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +231 -191
- package/dist/chunks/helpGraph.js +17 -13
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +24 -20
- package/dist/chunks/navigationGraph.js +33 -28
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +267 -226
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +12 -9
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +385 -152
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
- package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/loader.js +7 -6
- package/dist/types/lumina.d.ts +11 -5
- package/dist/types/preact.d.ts +12 -5
- package/dist/types/react.d.ts +13 -5
- package/dist/types/stencil.d.ts +11 -5
- package/dist/utils/index.d.ts +85 -42
- package/dist/utils/index.js +54 -49
- package/package.json +8 -7
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FHVXO2WG.js +0 -166
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GSEPHN3A.js +0 -106
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JY6LLOUJ.js +0 -22
- package/dist/cdn/MDVYQQUG.js +0 -14
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/ON2V5XI2.js +0 -3
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/S6W6HV4T.js +0 -36
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V2P4AIGG.js +0 -2
- package/dist/cdn/V5YEZSRY.js +0 -16
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YY2SBO3V.js +0 -2
package/dist/chunks/adapter.js
CHANGED
|
@@ -1,56 +1,58 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import
|
|
2
|
+
import me from "@arcgis/core/identity/IdentityManager.js";
|
|
3
3
|
import k from "@arcgis/core/portal/Portal.js";
|
|
4
|
-
import { Annotation as b, messagesStateReducer as
|
|
5
|
-
import
|
|
4
|
+
import { Annotation as b, messagesStateReducer as Te } from "@langchain/langgraph/web";
|
|
5
|
+
import "@arcgis/toolkit/string";
|
|
6
|
+
import { k as qe, j as B, i as De } from "./generateLayerDescriptions.js";
|
|
6
7
|
import "@langchain/core/messages";
|
|
7
8
|
import "@langchain/core/callbacks/dispatch/web";
|
|
8
9
|
import "@langchain/openai";
|
|
9
|
-
import
|
|
10
|
+
import X from "@arcgis/core/config.js";
|
|
11
|
+
import * as Ae from "@arcgis/core/core/reactiveUtils.js";
|
|
10
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
11
|
-
import
|
|
13
|
+
import he from "@arcgis/core/request.js";
|
|
12
14
|
import "@langchain/core/prompts";
|
|
13
15
|
import { tool as f } from "@langchain/core/tools";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { createAgeRenderer as
|
|
25
|
-
import { getSchemesByTag as
|
|
26
|
-
import { createContinuousRenderer as
|
|
27
|
-
import { createRenderer as
|
|
28
|
-
import { getSchemesByTag as
|
|
29
|
-
import { createRenderer as
|
|
30
|
-
import { getSchemesByTag as
|
|
31
|
-
import { createRenderer as
|
|
32
|
-
import { getSchemesByTag as
|
|
33
|
-
import { createRenderer as
|
|
34
|
-
import { getSchemesByTag as
|
|
35
|
-
import { createAgeRenderer as
|
|
36
|
-
import { createRenderer as
|
|
37
|
-
import { getSchemesByTag as
|
|
38
|
-
import { ToolNode as
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import * as
|
|
42
|
-
import { formatDateOnly as
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
16
|
+
import Pe from "@arcgis/core/Graphic.js";
|
|
17
|
+
import { addressToLocations as Le } from "@arcgis/core/rest/locator.js";
|
|
18
|
+
import je from "@arcgis/core/symbols/PictureMarkerSymbol.js";
|
|
19
|
+
import i, { z as E } from "zod";
|
|
20
|
+
import Ge from "@arcgis/core/geometry/Extent.js";
|
|
21
|
+
import ve from "@arcgis/core/geometry/Point.js";
|
|
22
|
+
import { createRenderer as Oe } from "@arcgis/core/smartMapping/renderers/pieChart.js";
|
|
23
|
+
import { getSchemesByTag as Me, getSchemes as Qe } from "@arcgis/core/smartMapping/symbology/pieChart.js";
|
|
24
|
+
import { getBackgroundColorTheme as ye } from "@arcgis/core/views/support/colorUtils.js";
|
|
25
|
+
import { a as x, s as S } from "./index.js";
|
|
26
|
+
import { createAgeRenderer as _e, createContinuousRenderer as We } from "@arcgis/core/smartMapping/renderers/color.js";
|
|
27
|
+
import { getSchemesByTag as le } from "@arcgis/core/smartMapping/symbology/color.js";
|
|
28
|
+
import { createContinuousRenderer as Ve } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
|
|
29
|
+
import { createRenderer as Ue } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
|
|
30
|
+
import { getSchemesByTag as Ke } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
|
|
31
|
+
import { createRenderer as Be } from "@arcgis/core/smartMapping/renderers/heatmap.js";
|
|
32
|
+
import { getSchemesByTag as He } from "@arcgis/core/smartMapping/symbology/heatmap.js";
|
|
33
|
+
import { createRenderer as Je } from "@arcgis/core/smartMapping/renderers/predominance.js";
|
|
34
|
+
import { getSchemesByTag as Ze } from "@arcgis/core/smartMapping/symbology/predominance.js";
|
|
35
|
+
import { createRenderer as Ye } from "@arcgis/core/smartMapping/renderers/relationship.js";
|
|
36
|
+
import { getSchemesByTag as Xe } from "@arcgis/core/smartMapping/symbology/relationship.js";
|
|
37
|
+
import { createAgeRenderer as et, createContinuousRenderer as tt } from "@arcgis/core/smartMapping/renderers/size.js";
|
|
38
|
+
import { createRenderer as rt } from "@arcgis/core/smartMapping/renderers/type.js";
|
|
39
|
+
import { getSchemesByTag as at } from "@arcgis/core/smartMapping/symbology/type.js";
|
|
40
|
+
import { ToolNode as ot } from "@langchain/langgraph/prebuilt";
|
|
41
|
+
import nt from "@arcgis/core/layers/support/FeatureEffect.js";
|
|
42
|
+
import Se from "@arcgis/core/layers/support/FeatureFilter.js";
|
|
43
|
+
import * as it from "@arcgis/core/geometry/operators/unionOperator.js";
|
|
44
|
+
import { formatDateOnly as st, convertDateFormatToIntlOptions as Q, formatTimeOnly as lt, formatDate as fe } from "@arcgis/core/intl.js";
|
|
45
|
+
import ct from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
46
|
+
import ut from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
47
|
+
import dt from "@arcgis/core/rest/support/TopFeaturesQuery.js";
|
|
48
|
+
import pt from "@arcgis/core/rest/support/TopFilter.js";
|
|
49
|
+
import mt from "@arcgis/core/WebLinkChart.js";
|
|
50
|
+
import xe from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
|
|
49
51
|
import "@arcgis/core/views/LinkChartView.js";
|
|
50
|
-
import { fetchKnowledgeGraph as
|
|
51
|
-
import
|
|
52
|
-
const L = (e, t) => t ?? e,
|
|
53
|
-
...
|
|
52
|
+
import { fetchKnowledgeGraph as ge, executeQueryStreaming as ht, executeSearchStreaming as yt } from "@arcgis/core/rest/knowledgeGraphService.js";
|
|
53
|
+
import ft from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
|
|
54
|
+
const L = (e, t) => t ?? e, Rn = b.Root({
|
|
55
|
+
...qe(),
|
|
54
56
|
// internal to the navigation agent
|
|
55
57
|
intent: b({
|
|
56
58
|
reducer: L
|
|
@@ -69,122 +71,122 @@ const L = (e, t) => t ?? e, Tn = b.Root({
|
|
|
69
71
|
})
|
|
70
72
|
})
|
|
71
73
|
});
|
|
72
|
-
async function
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
74
|
+
async function gt(e, t) {
|
|
75
|
+
const a = k.getDefault().helperServices, o = a.geocode.find((m) => m.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
|
|
76
|
+
if (!o)
|
|
75
77
|
throw new Error("No geocoding service found in helperServices.");
|
|
76
|
-
const n =
|
|
78
|
+
const n = o.url, l = `${X.assetsPath?.endsWith("/") ? X.assetsPath : `${X.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await Le(n, {
|
|
77
79
|
address: { SingleLine: e },
|
|
78
80
|
outFields: ["Match_addr"]
|
|
79
81
|
}))?.[0];
|
|
80
|
-
if (!
|
|
82
|
+
if (!c?.extent || !c.location)
|
|
81
83
|
throw new Error(`Could not find location for: ${e}`);
|
|
82
|
-
const
|
|
83
|
-
url:
|
|
84
|
+
const u = new je({
|
|
85
|
+
url: l,
|
|
84
86
|
width: 24,
|
|
85
87
|
height: 24
|
|
86
|
-
}), d = new
|
|
87
|
-
geometry:
|
|
88
|
-
symbol:
|
|
88
|
+
}), d = new Pe({
|
|
89
|
+
geometry: c.location,
|
|
90
|
+
symbol: u
|
|
89
91
|
});
|
|
90
|
-
t.graphics.removeAll(), t.graphics.add(d), await t.goTo(
|
|
92
|
+
t.graphics.removeAll(), t.graphics.add(d), await t.goTo(c.extent);
|
|
91
93
|
const p = {
|
|
92
|
-
address:
|
|
93
|
-
location:
|
|
94
|
-
extent:
|
|
94
|
+
address: c.address ?? "",
|
|
95
|
+
location: c.location ? c.location.toJSON() : null,
|
|
96
|
+
extent: c.extent ? c.extent.toJSON() : null
|
|
95
97
|
};
|
|
96
98
|
return {
|
|
97
99
|
text: `Successfully zoomed to ${e}.`,
|
|
98
100
|
sharedStatePatch: { lastResolvedLocation: { value: p } }
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
|
-
const
|
|
103
|
+
const wt = ["mapView"];
|
|
102
104
|
function $(e) {
|
|
103
105
|
const r = e?.configurable?.context;
|
|
104
106
|
if (!r || typeof r != "object")
|
|
105
107
|
throw new Error("NavigationAgent context missing");
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
throw new Error(`NavigationAgent context missing: ${
|
|
108
|
+
const a = wt.filter((o) => !(o in r));
|
|
109
|
+
if (a.length)
|
|
110
|
+
throw new Error(`NavigationAgent context missing: ${a.join(", ")}`);
|
|
109
111
|
return r;
|
|
110
112
|
}
|
|
111
|
-
async function
|
|
113
|
+
async function bt({ address: e }, t) {
|
|
112
114
|
const { mapView: r } = $(t);
|
|
113
|
-
return await
|
|
115
|
+
return await gt(e, r);
|
|
114
116
|
}
|
|
115
|
-
const
|
|
117
|
+
const Tt = i.object({
|
|
116
118
|
address: i.string().describe("The full address or place name to locate.")
|
|
117
|
-
}),
|
|
119
|
+
}), $n = f(bt, {
|
|
118
120
|
name: "goToAddress",
|
|
119
121
|
description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
|
|
120
|
-
schema:
|
|
122
|
+
schema: Tt
|
|
121
123
|
});
|
|
122
|
-
async function
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
124
|
+
async function vt(e, t) {
|
|
125
|
+
const a = t.map.bookmarks;
|
|
126
|
+
if (!a || a.length === 0)
|
|
125
127
|
throw new Error("No bookmarks found in the map.");
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
+
const o = a.find((l) => l.name === e);
|
|
129
|
+
if (!o)
|
|
128
130
|
throw new Error(`Bookmark with name "${e}" not found.`);
|
|
129
|
-
const n =
|
|
131
|
+
const n = o.viewpoint;
|
|
130
132
|
if (!n)
|
|
131
133
|
throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);
|
|
132
134
|
return await t.goTo(n), { text: `Navigated to bookmark: ${e}` };
|
|
133
135
|
}
|
|
134
|
-
async function
|
|
136
|
+
async function St({ bookmarkName: e }, t) {
|
|
135
137
|
const { mapView: r } = $(t);
|
|
136
|
-
return await Promise.resolve(
|
|
138
|
+
return await Promise.resolve(vt(e, r));
|
|
137
139
|
}
|
|
138
|
-
const
|
|
139
|
-
bookmarkName:
|
|
140
|
-
}),
|
|
140
|
+
const xt = E.object({
|
|
141
|
+
bookmarkName: E.string().describe("The name of the bookmark to navigate to.")
|
|
142
|
+
}), Cn = f(St, {
|
|
141
143
|
name: "goToBookmark",
|
|
142
144
|
description: "Go to the extent of the bookmark with the given name.",
|
|
143
|
-
schema:
|
|
145
|
+
schema: xt
|
|
144
146
|
});
|
|
145
|
-
async function
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
147
|
+
async function Rt(e, t, r) {
|
|
148
|
+
const a = r.map?.allLayers.find((l) => l.id === e);
|
|
149
|
+
if (!a)
|
|
148
150
|
return { text: `Error: Layer with id ${e} not found` };
|
|
149
|
-
const
|
|
150
|
-
n.where =
|
|
151
|
+
const o = t?.trim() ? t : "1=1", n = a.createQuery();
|
|
152
|
+
n.where = o;
|
|
151
153
|
try {
|
|
152
|
-
const { extent:
|
|
153
|
-
if (
|
|
154
|
-
return { text: `No features found in ${
|
|
155
|
-
if (
|
|
156
|
-
await r.goTo(
|
|
154
|
+
const { extent: l, count: s } = await a.queryExtent(n);
|
|
155
|
+
if (s === 0)
|
|
156
|
+
return { text: `No features found in ${a.title} matching: ${o}`, where: o };
|
|
157
|
+
if (l)
|
|
158
|
+
await r.goTo(l);
|
|
157
159
|
else
|
|
158
|
-
return { text: `Error: Unable to determine extent for ${
|
|
159
|
-
const
|
|
160
|
+
return { text: `Error: Unable to determine extent for ${a.title}`, where: o };
|
|
161
|
+
const c = {
|
|
160
162
|
layerId: e,
|
|
161
|
-
layerTitle:
|
|
162
|
-
where:
|
|
163
|
-
count:
|
|
163
|
+
layerTitle: a.title ?? e,
|
|
164
|
+
where: o,
|
|
165
|
+
count: s
|
|
164
166
|
};
|
|
165
167
|
return {
|
|
166
|
-
text: `Successfully zoomed to ${
|
|
167
|
-
where:
|
|
168
|
-
sharedStatePatch: { lastNavigatedFeatures: { value:
|
|
168
|
+
text: `Successfully zoomed to ${s} feature(s) in ${a.title} matching: ${o}`,
|
|
169
|
+
where: o,
|
|
170
|
+
sharedStatePatch: { lastNavigatedFeatures: { value: c } }
|
|
169
171
|
};
|
|
170
|
-
} catch (
|
|
171
|
-
return console.error("Error in goToFeatures:",
|
|
172
|
+
} catch (l) {
|
|
173
|
+
return console.error("Error in goToFeatures:", l), { text: `Error: ${l instanceof Error ? l.message : "Unknown error"}`, where: o };
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
|
-
async function
|
|
175
|
-
const { mapView:
|
|
176
|
-
return await
|
|
176
|
+
async function $t({ layerId: e, where: t }, r) {
|
|
177
|
+
const { mapView: a } = $(r);
|
|
178
|
+
return await Rt(e, t, a);
|
|
177
179
|
}
|
|
178
|
-
const
|
|
179
|
-
layerId:
|
|
180
|
-
where:
|
|
181
|
-
}),
|
|
180
|
+
const Ct = E.object({
|
|
181
|
+
layerId: E.string().describe("The layerId of the layer to zoom to."),
|
|
182
|
+
where: E.string().describe("The sql-92 where clause used to query features to zoom to")
|
|
183
|
+
}), En = f($t, {
|
|
182
184
|
name: "goToFeatures",
|
|
183
185
|
description: "Go to the features that match the given filter related to the given layerId.",
|
|
184
|
-
schema:
|
|
186
|
+
schema: Ct
|
|
185
187
|
});
|
|
186
|
-
async function
|
|
187
|
-
const r = new
|
|
188
|
+
async function Et(e) {
|
|
189
|
+
const r = new Ge({
|
|
188
190
|
xmin: -180,
|
|
189
191
|
ymin: -90,
|
|
190
192
|
xmax: 180,
|
|
@@ -193,16 +195,16 @@ async function $t(e) {
|
|
|
193
195
|
}).expand(0.7);
|
|
194
196
|
return await e.goTo(r), { text: "Successfully zoomed to world extent" };
|
|
195
197
|
}
|
|
196
|
-
async function
|
|
198
|
+
async function Nt(e, t) {
|
|
197
199
|
const { mapView: r } = $(t);
|
|
198
|
-
return await
|
|
200
|
+
return await Et(r);
|
|
199
201
|
}
|
|
200
|
-
const
|
|
202
|
+
const It = E.object({}), Nn = f(Nt, {
|
|
201
203
|
name: "goToFullExtent",
|
|
202
204
|
description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
|
|
203
|
-
schema:
|
|
205
|
+
schema: It
|
|
204
206
|
});
|
|
205
|
-
async function
|
|
207
|
+
async function kt(e) {
|
|
206
208
|
const r = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
207
209
|
if (r)
|
|
208
210
|
await e.goTo(r);
|
|
@@ -212,94 +214,94 @@ async function It(e) {
|
|
|
212
214
|
}
|
|
213
215
|
async function Ft(e, t) {
|
|
214
216
|
const { mapView: r } = $(t);
|
|
215
|
-
return await
|
|
217
|
+
return await kt(r);
|
|
216
218
|
}
|
|
217
|
-
const
|
|
219
|
+
const zt = i.object({}), In = f(Ft, {
|
|
218
220
|
name: "goToHomeExtent",
|
|
219
221
|
description: "Go to the initial web map view extent",
|
|
220
|
-
schema:
|
|
222
|
+
schema: zt
|
|
221
223
|
});
|
|
222
|
-
async function
|
|
224
|
+
async function qt(e, t) {
|
|
223
225
|
await t.when();
|
|
224
|
-
const r = t.map?.allLayers.find((
|
|
226
|
+
const r = t.map?.allLayers.find((o) => o.id === e);
|
|
225
227
|
if (!r)
|
|
226
228
|
return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`), { text: `Could not find layer for: ${e}` };
|
|
227
|
-
let
|
|
228
|
-
return (r.type === "link-chart" || r.type === "knowledge-graph-sublayer") && t.map?.activeLinkChartLayer ?
|
|
229
|
+
let a;
|
|
230
|
+
return (r.type === "link-chart" || r.type === "knowledge-graph-sublayer") && t.map?.activeLinkChartLayer ? a = t.map.diagramNodesExtent : a = r.fullExtent, a ? (await t.goTo(a), r.visible = !0, { text: `Successfully zoomed to: ${r.title ?? ""}` }) : { text: "Layer has no defined extent. Cannot zoom to layer." };
|
|
229
231
|
}
|
|
230
|
-
async function
|
|
232
|
+
async function Dt({ layerId: e }, t) {
|
|
231
233
|
const { mapView: r } = $(t);
|
|
232
|
-
return await
|
|
234
|
+
return await qt(e, r);
|
|
233
235
|
}
|
|
234
|
-
const
|
|
235
|
-
layerId:
|
|
236
|
-
}),
|
|
236
|
+
const At = E.object({
|
|
237
|
+
layerId: E.string().describe("The id of the layer to navigate to")
|
|
238
|
+
}), kn = f(Dt, {
|
|
237
239
|
name: "goToLayer",
|
|
238
240
|
description: "Zooms the map view to the full extent of the top matching layer.",
|
|
239
|
-
schema:
|
|
241
|
+
schema: At
|
|
240
242
|
});
|
|
241
|
-
async function
|
|
243
|
+
async function Pt(e, t) {
|
|
242
244
|
return await t.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
|
|
243
245
|
}
|
|
244
|
-
async function
|
|
246
|
+
async function Lt({ scale: e }, t) {
|
|
245
247
|
const { mapView: r } = $(t);
|
|
246
|
-
return await
|
|
248
|
+
return await Pt(e, r);
|
|
247
249
|
}
|
|
248
|
-
const
|
|
250
|
+
const jt = i.object({
|
|
249
251
|
scale: i.number().describe("The map scale of the view to go to.")
|
|
250
|
-
}),
|
|
252
|
+
}), Fn = f(Lt, {
|
|
251
253
|
name: "goToScale",
|
|
252
254
|
description: "Go to the specified view scale.",
|
|
253
|
-
schema:
|
|
255
|
+
schema: jt
|
|
254
256
|
});
|
|
255
|
-
async function
|
|
256
|
-
const
|
|
257
|
-
target: new
|
|
257
|
+
async function Gt(e, t, r) {
|
|
258
|
+
const o = {
|
|
259
|
+
target: new ve({
|
|
258
260
|
longitude: e.longitude,
|
|
259
261
|
latitude: e.latitude,
|
|
260
262
|
spatialReference: { wkid: 4326 }
|
|
261
263
|
})
|
|
262
264
|
};
|
|
263
|
-
return r?.zoom !== void 0 && (
|
|
265
|
+
return r?.zoom !== void 0 && (o.zoom = r.zoom), r?.scale !== void 0 && (o.scale = r.scale), await t.goTo(o), { text: `Successfully navigated to: ${[
|
|
264
266
|
`(${e.latitude}°, ${e.longitude}°)`,
|
|
265
267
|
r?.zoom !== void 0 ? `zoom ${r.zoom}` : "",
|
|
266
268
|
r?.scale !== void 0 ? `scale 1:${r.scale}` : ""
|
|
267
269
|
].filter(Boolean).join(", ")}` };
|
|
268
270
|
}
|
|
269
|
-
async function
|
|
271
|
+
async function Ot({
|
|
270
272
|
center: e,
|
|
271
273
|
zoom: t,
|
|
272
274
|
scale: r
|
|
273
|
-
},
|
|
274
|
-
const { mapView:
|
|
275
|
-
return await
|
|
275
|
+
}, a) {
|
|
276
|
+
const { mapView: o } = $(a);
|
|
277
|
+
return await Gt(e, o, { zoom: t, scale: r });
|
|
276
278
|
}
|
|
277
|
-
const
|
|
279
|
+
const Mt = i.object({
|
|
278
280
|
center: i.object({
|
|
279
281
|
longitude: i.number().describe("The longitude (x-coordinate) of the point to navigate to."),
|
|
280
282
|
latitude: i.number().describe("The latitude (y-coordinate) of the point to navigate to.")
|
|
281
283
|
}),
|
|
282
284
|
zoom: i.number().optional().describe("The zoom level. Higher values = more zoomed in."),
|
|
283
285
|
scale: i.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
|
|
284
|
-
}),
|
|
286
|
+
}), zn = f(Ot, {
|
|
285
287
|
name: "goToViewpoint",
|
|
286
288
|
description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
|
|
287
|
-
schema:
|
|
289
|
+
schema: Mt
|
|
288
290
|
});
|
|
289
|
-
async function
|
|
291
|
+
async function Qt(e, t) {
|
|
290
292
|
return await t.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
|
|
291
293
|
}
|
|
292
|
-
async function
|
|
294
|
+
async function _t({ zoom: e }, t) {
|
|
293
295
|
const { mapView: r } = $(t);
|
|
294
|
-
return await
|
|
296
|
+
return await Qt(e, r);
|
|
295
297
|
}
|
|
296
|
-
const
|
|
298
|
+
const Wt = i.object({
|
|
297
299
|
zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
|
|
298
|
-
}),
|
|
300
|
+
}), qn = f(_t, {
|
|
299
301
|
name: "goToZoom",
|
|
300
302
|
description: 'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',
|
|
301
|
-
schema:
|
|
302
|
-
}),
|
|
303
|
+
schema: Wt
|
|
304
|
+
}), we = /* @__PURE__ */ Object.assign({
|
|
303
305
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md": () => import("./arcgis_knowledge_current_lc_context.js").then((e) => e.default),
|
|
304
306
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md": () => import("./arcgis_knowledge_current_map_context.js").then((e) => e.default),
|
|
305
307
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md": () => import("./arcgis_knowledge_lucene_generation_prompt.js").then((e) => e.default),
|
|
@@ -313,115 +315,115 @@ const Qt = i.object({
|
|
|
313
315
|
"../agents/navigation/prompts/navigation_intent_prompt.md": () => import("./navigation_intent_prompt.js").then((e) => e.default),
|
|
314
316
|
"../agents/navigation/prompts/navigation_tool_prompt.md": () => import("./navigation_tool_prompt.js").then((e) => e.default)
|
|
315
317
|
});
|
|
316
|
-
async function
|
|
317
|
-
const t = Object.entries(
|
|
318
|
+
async function te(e) {
|
|
319
|
+
const t = Object.entries(we).find(([r]) => r.endsWith(`/${e}.md`));
|
|
318
320
|
if (!t)
|
|
319
321
|
throw new Error(`Prompt not found: ${e}
|
|
320
322
|
Available prompts:
|
|
321
|
-
${Object.keys(
|
|
323
|
+
${Object.keys(we).join(`
|
|
322
324
|
`)}`);
|
|
323
325
|
return await t[1]();
|
|
324
326
|
}
|
|
325
|
-
const
|
|
327
|
+
const Vt = (e, t = 300) => {
|
|
326
328
|
const r = e.replace(/\s+/gu, " ").replace(/[*_`#>\-]/gu, "").trim();
|
|
327
329
|
return r.length > t ? `${r.slice(0, t)}...` : r;
|
|
328
|
-
},
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
330
|
+
}, Re = (e, t) => {
|
|
331
|
+
const a = e?.configurable?.services?.[t];
|
|
332
|
+
if (a == null)
|
|
331
333
|
throw new Error(`${t} missing in config.configurable.services`);
|
|
332
|
-
return
|
|
333
|
-
},
|
|
334
|
-
const
|
|
334
|
+
return a;
|
|
335
|
+
}, Dn = (e, t) => (r, a) => {
|
|
336
|
+
const o = a?.configurable?.services;
|
|
335
337
|
for (const n of e)
|
|
336
|
-
if (!
|
|
338
|
+
if (!o?.[n])
|
|
337
339
|
throw new Error(`${t} requires services.${n} to be available.`);
|
|
338
340
|
return r;
|
|
339
341
|
};
|
|
340
|
-
async function
|
|
341
|
-
const { fields: t, layer: r, view:
|
|
342
|
-
let
|
|
343
|
-
return n ?
|
|
344
|
-
basemapTheme: await
|
|
342
|
+
async function Ut(e) {
|
|
343
|
+
const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: n } = e;
|
|
344
|
+
let l;
|
|
345
|
+
return n ? l = Me({
|
|
346
|
+
basemapTheme: await ye(a),
|
|
345
347
|
geometryType: r.geometryType,
|
|
346
348
|
includedTags: n,
|
|
347
349
|
numColors: Math.min(t.length, 8)
|
|
348
|
-
})[0] :
|
|
349
|
-
basemapTheme: await
|
|
350
|
+
})[0] : l = Qe({
|
|
351
|
+
basemapTheme: await ye(a),
|
|
350
352
|
geometryType: r.geometryType,
|
|
351
353
|
numColors: Math.min(t.length, 8)
|
|
352
354
|
}).primaryScheme, {
|
|
353
355
|
layer: r,
|
|
354
|
-
view:
|
|
355
|
-
attributes: t.map((
|
|
356
|
-
field:
|
|
357
|
-
label: r.fields.find((
|
|
356
|
+
view: a,
|
|
357
|
+
attributes: t.map((s) => ({
|
|
358
|
+
field: s,
|
|
359
|
+
label: r.fields.find((c) => c.name === s)?.alias ?? ""
|
|
358
360
|
})).slice(0, 8),
|
|
359
361
|
outlineOptimizationEnabled: !0,
|
|
360
362
|
sizeOptimizationEnabled: !0,
|
|
361
|
-
includeSizeVariable:
|
|
362
|
-
pieChartScheme:
|
|
363
|
+
includeSizeVariable: o.includes("Size"),
|
|
364
|
+
pieChartScheme: l
|
|
363
365
|
};
|
|
364
366
|
}
|
|
365
|
-
async function
|
|
366
|
-
return await
|
|
367
|
+
async function Kt(e) {
|
|
368
|
+
return await Oe(e);
|
|
367
369
|
}
|
|
368
|
-
async function
|
|
370
|
+
async function Bt({
|
|
369
371
|
arcgisMap: e,
|
|
370
372
|
arcgisMapView: t,
|
|
371
373
|
layerId: r,
|
|
372
|
-
fields:
|
|
373
|
-
colorSchemes:
|
|
374
|
+
fields: a,
|
|
375
|
+
colorSchemes: o,
|
|
374
376
|
includeSize: n
|
|
375
377
|
}) {
|
|
376
|
-
const
|
|
377
|
-
if (!
|
|
378
|
+
const l = t, s = e?.allLayers.find((d) => d.id === r);
|
|
379
|
+
if (!s)
|
|
378
380
|
return `Could not find layer for id: ${r}`;
|
|
379
|
-
const
|
|
381
|
+
const u = {
|
|
380
382
|
styleName: n ? "chart-size" : "chart",
|
|
381
|
-
fields:
|
|
382
|
-
layer:
|
|
383
|
-
view:
|
|
384
|
-
colorSchemeTags:
|
|
383
|
+
fields: a,
|
|
384
|
+
layer: s,
|
|
385
|
+
view: l,
|
|
386
|
+
colorSchemeTags: o
|
|
385
387
|
};
|
|
386
388
|
try {
|
|
387
|
-
const d = await
|
|
388
|
-
return
|
|
389
|
+
const d = await Ut(u), p = await Kt(d);
|
|
390
|
+
return s.renderer = p.renderer, s.visible = !0, `Chart renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
389
391
|
} catch (d) {
|
|
390
392
|
return `Error applying chart renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
|
-
const
|
|
395
|
+
const Ht = ["mapView"];
|
|
394
396
|
function R(e) {
|
|
395
397
|
const r = e?.configurable?.context;
|
|
396
398
|
if (!r || typeof r != "object")
|
|
397
399
|
throw new Error("LayerStylingAgent context missing");
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
400
|
-
throw new Error(`LayerStylingAgent context missing: ${
|
|
400
|
+
const a = Ht.filter((o) => !(o in r));
|
|
401
|
+
if (a.length)
|
|
402
|
+
throw new Error(`LayerStylingAgent context missing: ${a.join(", ")}`);
|
|
401
403
|
return r;
|
|
402
404
|
}
|
|
403
|
-
async function
|
|
405
|
+
async function Jt({
|
|
404
406
|
layerId: e,
|
|
405
407
|
fields: t,
|
|
406
408
|
colorSchemes: r,
|
|
407
|
-
includeSize:
|
|
408
|
-
},
|
|
409
|
-
const { mapView: n } = R(
|
|
410
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
409
|
+
includeSize: a
|
|
410
|
+
}, o) {
|
|
411
|
+
const { mapView: n } = R(o);
|
|
412
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Bt({
|
|
411
413
|
arcgisMap: n.map,
|
|
412
414
|
arcgisMapView: n,
|
|
413
415
|
layerId: e,
|
|
414
416
|
fields: t,
|
|
415
417
|
colorSchemes: r,
|
|
416
|
-
includeSize:
|
|
418
|
+
includeSize: a
|
|
417
419
|
});
|
|
418
420
|
}
|
|
419
|
-
const
|
|
421
|
+
const Zt = i.object({
|
|
420
422
|
layerId: i.string().describe("The id of the layer to apply the chart renderer to"),
|
|
421
423
|
fields: i.array(i.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
|
|
422
424
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
423
425
|
includeSize: i.boolean().optional().describe("Whether to vary the chart size (chart-size)")
|
|
424
|
-
}),
|
|
426
|
+
}), An = f(Jt, {
|
|
425
427
|
name: "chart",
|
|
426
428
|
description: `Label: Charts
|
|
427
429
|
Description: Show the values of two or more categories as a proportion of the total using a pie chart.
|
|
@@ -434,308 +436,308 @@ const Ht = i.object({
|
|
|
434
436
|
Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
|
|
435
437
|
Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
|
|
436
438
|
Fields: This style requires 2-8 number fields.`,
|
|
437
|
-
schema:
|
|
439
|
+
schema: Zt
|
|
438
440
|
});
|
|
439
|
-
function
|
|
440
|
-
const { fields: t, layer: r, view:
|
|
441
|
-
let
|
|
442
|
-
return n && (
|
|
441
|
+
function Yt(e) {
|
|
442
|
+
const { fields: t, layer: r, view: a, theme: o, colorSchemeTags: n } = e, l = t[0];
|
|
443
|
+
let s;
|
|
444
|
+
return n && (s = le({
|
|
443
445
|
geometryType: r.geometryType,
|
|
444
446
|
includedTags: n,
|
|
445
|
-
theme:
|
|
447
|
+
theme: o || "high-to-low"
|
|
446
448
|
})[0]), {
|
|
447
449
|
layer: r,
|
|
448
|
-
view:
|
|
449
|
-
startTime:
|
|
450
|
+
view: a,
|
|
451
|
+
startTime: l,
|
|
450
452
|
endTime: /* @__PURE__ */ new Date(),
|
|
451
|
-
theme:
|
|
453
|
+
theme: o,
|
|
452
454
|
sizeOptimizationEnabled: !0,
|
|
453
455
|
outlineOptimizationEnabled: !0,
|
|
454
|
-
colorScheme:
|
|
456
|
+
colorScheme: s
|
|
455
457
|
};
|
|
456
458
|
}
|
|
457
|
-
async function
|
|
458
|
-
return await
|
|
459
|
+
async function Xt(e) {
|
|
460
|
+
return await _e(e);
|
|
459
461
|
}
|
|
460
|
-
async function
|
|
462
|
+
async function er({
|
|
461
463
|
arcgisMap: e,
|
|
462
464
|
arcgisMapView: t,
|
|
463
465
|
layerId: r,
|
|
464
|
-
fields:
|
|
465
|
-
colorSchemes:
|
|
466
|
+
fields: a,
|
|
467
|
+
colorSchemes: o,
|
|
466
468
|
theme: n
|
|
467
469
|
}) {
|
|
468
|
-
const
|
|
469
|
-
if (!
|
|
470
|
+
const l = t, s = e?.allLayers.find((u) => u.id === r);
|
|
471
|
+
if (!s)
|
|
470
472
|
return `Could not find layer for id: ${r}`;
|
|
471
|
-
const
|
|
473
|
+
const c = {
|
|
472
474
|
styleName: "color-age",
|
|
473
|
-
fields:
|
|
474
|
-
layer:
|
|
475
|
-
view:
|
|
476
|
-
colorSchemeTags:
|
|
475
|
+
fields: a,
|
|
476
|
+
layer: s,
|
|
477
|
+
view: l,
|
|
478
|
+
colorSchemeTags: o,
|
|
477
479
|
theme: n
|
|
478
480
|
};
|
|
479
481
|
try {
|
|
480
|
-
const
|
|
481
|
-
return
|
|
482
|
-
} catch (
|
|
483
|
-
return `Error applying color-age renderer: ${
|
|
482
|
+
const u = Yt(c), d = await Xt(u);
|
|
483
|
+
return s.renderer = d.renderer, s.visible = !0, `Color-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
484
|
+
} catch (u) {
|
|
485
|
+
return `Error applying color-age renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
484
486
|
}
|
|
485
487
|
}
|
|
486
|
-
async function
|
|
488
|
+
async function tr({
|
|
487
489
|
layerId: e,
|
|
488
490
|
fields: t,
|
|
489
491
|
colorSchemes: r,
|
|
490
|
-
theme:
|
|
491
|
-
},
|
|
492
|
-
const { mapView: n } = R(
|
|
493
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
492
|
+
theme: a
|
|
493
|
+
}, o) {
|
|
494
|
+
const { mapView: n } = R(o);
|
|
495
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await er({
|
|
494
496
|
arcgisMap: n.map,
|
|
495
497
|
arcgisMapView: n,
|
|
496
498
|
layerId: e,
|
|
497
499
|
fields: t,
|
|
498
500
|
colorSchemes: r,
|
|
499
|
-
theme:
|
|
501
|
+
theme: a
|
|
500
502
|
});
|
|
501
503
|
}
|
|
502
|
-
const
|
|
504
|
+
const rr = i.object({
|
|
503
505
|
layerId: i.string().describe("The id of the layer to apply the color-age renderer to"),
|
|
504
506
|
fields: i.array(i.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
|
|
505
507
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
506
508
|
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
|
|
507
|
-
}),
|
|
509
|
+
}), Pn = f(tr, {
|
|
508
510
|
name: "color-age",
|
|
509
511
|
description: `Label: Age (color)
|
|
510
512
|
Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
|
|
511
513
|
Keywords: since, age, how old, how long
|
|
512
514
|
Example: Show the age of each feature based on its reported date.
|
|
513
515
|
Fields: This style requires at least one field with a date type.`,
|
|
514
|
-
schema:
|
|
516
|
+
schema: rr
|
|
515
517
|
});
|
|
516
|
-
function
|
|
517
|
-
const { fields: t, layer: r, view:
|
|
518
|
-
let { theme: n } = e,
|
|
519
|
-
const
|
|
520
|
-
let
|
|
521
|
-
return
|
|
518
|
+
function ar(e) {
|
|
519
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
520
|
+
let { theme: n } = e, l = t[1];
|
|
521
|
+
const s = t[0];
|
|
522
|
+
let c;
|
|
523
|
+
return o && (c = le({
|
|
522
524
|
geometryType: r.geometryType,
|
|
523
|
-
includedTags:
|
|
525
|
+
includedTags: o,
|
|
524
526
|
theme: n || "high-to-low"
|
|
525
527
|
})[0]), {
|
|
526
528
|
layer: r,
|
|
527
|
-
view:
|
|
528
|
-
field:
|
|
529
|
-
normalizationField:
|
|
529
|
+
view: a,
|
|
530
|
+
field: s,
|
|
531
|
+
normalizationField: l,
|
|
530
532
|
theme: n,
|
|
531
533
|
sizeOptimizationEnabled: !0,
|
|
532
534
|
outlineOptimizationEnabled: !0,
|
|
533
|
-
colorScheme:
|
|
535
|
+
colorScheme: c
|
|
534
536
|
};
|
|
535
537
|
}
|
|
536
|
-
async function
|
|
537
|
-
return await
|
|
538
|
+
async function or(e) {
|
|
539
|
+
return await We(e);
|
|
538
540
|
}
|
|
539
|
-
async function
|
|
541
|
+
async function nr({
|
|
540
542
|
arcgisMap: e,
|
|
541
543
|
arcgisMapView: t,
|
|
542
544
|
layerId: r,
|
|
543
|
-
fields:
|
|
544
|
-
colorSchemes:
|
|
545
|
+
fields: a,
|
|
546
|
+
colorSchemes: o,
|
|
545
547
|
theme: n
|
|
546
548
|
}) {
|
|
547
|
-
const
|
|
548
|
-
if (!
|
|
549
|
+
const l = t, s = e?.allLayers.find((u) => u.id === r);
|
|
550
|
+
if (!s)
|
|
549
551
|
return `Could not find layer for id: ${r}`;
|
|
550
|
-
const
|
|
552
|
+
const c = {
|
|
551
553
|
styleName: "color",
|
|
552
|
-
fields:
|
|
553
|
-
layer:
|
|
554
|
-
view:
|
|
555
|
-
colorSchemeTags:
|
|
554
|
+
fields: a,
|
|
555
|
+
layer: s,
|
|
556
|
+
view: l,
|
|
557
|
+
colorSchemeTags: o,
|
|
556
558
|
theme: n
|
|
557
559
|
};
|
|
558
560
|
try {
|
|
559
|
-
const
|
|
560
|
-
return
|
|
561
|
-
} catch (
|
|
562
|
-
return `Error applying color renderer: ${
|
|
561
|
+
const u = ar(c), d = await or(u);
|
|
562
|
+
return s.renderer = d.renderer, s.visible = !0, `Color renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
563
|
+
} catch (u) {
|
|
564
|
+
return `Error applying color renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
563
565
|
}
|
|
564
566
|
}
|
|
565
|
-
async function
|
|
567
|
+
async function ir({
|
|
566
568
|
layerId: e,
|
|
567
569
|
fields: t,
|
|
568
570
|
colorSchemes: r,
|
|
569
|
-
theme:
|
|
570
|
-
},
|
|
571
|
-
const { mapView: n } = R(
|
|
572
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
571
|
+
theme: a
|
|
572
|
+
}, o) {
|
|
573
|
+
const { mapView: n } = R(o);
|
|
574
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await nr({
|
|
573
575
|
arcgisMap: n.map,
|
|
574
576
|
arcgisMapView: n,
|
|
575
577
|
layerId: e,
|
|
576
578
|
fields: t,
|
|
577
579
|
colorSchemes: r,
|
|
578
|
-
theme:
|
|
580
|
+
theme: a
|
|
579
581
|
});
|
|
580
582
|
}
|
|
581
|
-
const
|
|
583
|
+
const sr = i.object({
|
|
582
584
|
layerId: i.string().describe("The id of the layer to apply the color renderer to"),
|
|
583
585
|
fields: i.array(i.string()).describe("The field(s) to use for the color renderer"),
|
|
584
586
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
585
587
|
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
|
|
586
|
-
}),
|
|
588
|
+
}), Ln = f(ir, {
|
|
587
589
|
name: "color",
|
|
588
590
|
description: `Label: Counts and Amounts (color)
|
|
589
591
|
Description: Vary color along a continuous color ramp to represent numeric or ranked data.
|
|
590
592
|
Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
|
|
591
593
|
Example: Color each feature based on the population density.
|
|
592
594
|
Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,
|
|
593
|
-
schema:
|
|
595
|
+
schema: sr
|
|
594
596
|
});
|
|
595
|
-
function
|
|
596
|
-
const { fields: t, layer: r, view:
|
|
597
|
-
let
|
|
598
|
-
const
|
|
599
|
-
return
|
|
597
|
+
function lr(e) {
|
|
598
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o, theme: n } = e;
|
|
599
|
+
let l, s;
|
|
600
|
+
const c = t[0];
|
|
601
|
+
return o && (s = le({
|
|
600
602
|
geometryType: r.geometryType,
|
|
601
|
-
includedTags:
|
|
603
|
+
includedTags: o,
|
|
602
604
|
theme: n || "high-to-low"
|
|
603
605
|
})[0]), {
|
|
604
606
|
layer: r,
|
|
605
|
-
view:
|
|
606
|
-
field:
|
|
607
|
-
normalizationField:
|
|
607
|
+
view: a,
|
|
608
|
+
field: c,
|
|
609
|
+
normalizationField: l,
|
|
608
610
|
theme: n,
|
|
609
611
|
colorOptions: {
|
|
610
|
-
colorScheme:
|
|
612
|
+
colorScheme: s
|
|
611
613
|
}
|
|
612
614
|
};
|
|
613
615
|
}
|
|
614
|
-
async function
|
|
615
|
-
return await
|
|
616
|
+
async function cr(e) {
|
|
617
|
+
return await Ve(e);
|
|
616
618
|
}
|
|
617
|
-
async function
|
|
619
|
+
async function ur({
|
|
618
620
|
arcgisMap: e,
|
|
619
621
|
arcgisMapView: t,
|
|
620
622
|
layerId: r,
|
|
621
|
-
fields:
|
|
622
|
-
colorSchemes:
|
|
623
|
+
fields: a,
|
|
624
|
+
colorSchemes: o,
|
|
623
625
|
theme: n
|
|
624
626
|
}) {
|
|
625
|
-
const
|
|
626
|
-
if (!
|
|
627
|
+
const l = t, s = e?.allLayers.find((u) => u.id === r);
|
|
628
|
+
if (!s)
|
|
627
629
|
return `Could not find layer for id: ${r}`;
|
|
628
|
-
const
|
|
630
|
+
const c = {
|
|
629
631
|
styleName: "color-size-univariate",
|
|
630
|
-
fields:
|
|
631
|
-
layer:
|
|
632
|
-
view:
|
|
633
|
-
colorSchemeTags:
|
|
632
|
+
fields: a,
|
|
633
|
+
layer: s,
|
|
634
|
+
view: l,
|
|
635
|
+
colorSchemeTags: o,
|
|
634
636
|
theme: n
|
|
635
637
|
};
|
|
636
638
|
try {
|
|
637
|
-
const
|
|
638
|
-
return
|
|
639
|
-
} catch (
|
|
640
|
-
return `Error applying color-size-univariate renderer: ${
|
|
639
|
+
const u = lr(c), d = await cr(u);
|
|
640
|
+
return s.renderer = d.renderer, s.visible = !0, `Color-size-univariate renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
641
|
+
} catch (u) {
|
|
642
|
+
return `Error applying color-size-univariate renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
641
643
|
}
|
|
642
644
|
}
|
|
643
|
-
async function
|
|
645
|
+
async function dr({
|
|
644
646
|
layerId: e,
|
|
645
647
|
fields: t,
|
|
646
648
|
colorSchemes: r,
|
|
647
|
-
theme:
|
|
648
|
-
},
|
|
649
|
-
const { mapView: n } = R(
|
|
650
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
649
|
+
theme: a
|
|
650
|
+
}, o) {
|
|
651
|
+
const { mapView: n } = R(o);
|
|
652
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await ur({
|
|
651
653
|
arcgisMap: n.map,
|
|
652
654
|
arcgisMapView: n,
|
|
653
655
|
layerId: e,
|
|
654
656
|
fields: t,
|
|
655
657
|
colorSchemes: r,
|
|
656
|
-
theme:
|
|
658
|
+
theme: a
|
|
657
659
|
});
|
|
658
660
|
}
|
|
659
|
-
const
|
|
661
|
+
const pr = i.object({
|
|
660
662
|
layerId: i.string().describe("The id of the layer to apply the color-size univariate renderer to"),
|
|
661
663
|
fields: i.array(i.string()).describe("The fields to use for the color-size univariate renderer"),
|
|
662
664
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
663
665
|
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
|
|
664
|
-
}),
|
|
666
|
+
}), jn = f(dr, {
|
|
665
667
|
name: "color-size-univariate",
|
|
666
668
|
description: `Label: Color and Size (univariate)
|
|
667
669
|
Description: Vary symbol size and color based on the values of two numeric attributes.
|
|
668
670
|
Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
|
|
669
671
|
Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
|
|
670
672
|
Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,
|
|
671
|
-
schema:
|
|
673
|
+
schema: pr
|
|
672
674
|
});
|
|
673
|
-
function
|
|
674
|
-
const { fields: t, layer: r, view:
|
|
675
|
+
function mr(e) {
|
|
676
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
675
677
|
let n;
|
|
676
|
-
return
|
|
677
|
-
includedTags:
|
|
678
|
+
return o && (n = Ke({
|
|
679
|
+
includedTags: o,
|
|
678
680
|
numColors: Math.min(t.length, 8)
|
|
679
681
|
})[0]), {
|
|
680
682
|
layer: r,
|
|
681
|
-
view:
|
|
683
|
+
view: a,
|
|
682
684
|
legendOptions: {
|
|
683
685
|
unit: "units"
|
|
684
686
|
},
|
|
685
|
-
attributes: t.map((
|
|
686
|
-
field:
|
|
687
|
-
label: r.fields.find((
|
|
687
|
+
attributes: t.map((l) => ({
|
|
688
|
+
field: l,
|
|
689
|
+
label: r.fields.find((s) => s.name === l)?.alias ?? ""
|
|
688
690
|
})).slice(0, 8),
|
|
689
691
|
outlineOptimizationEnabled: !0,
|
|
690
692
|
dotDensityScheme: n
|
|
691
693
|
};
|
|
692
694
|
}
|
|
693
|
-
async function
|
|
694
|
-
return await
|
|
695
|
+
async function hr(e) {
|
|
696
|
+
return await Ue(e);
|
|
695
697
|
}
|
|
696
|
-
async function
|
|
698
|
+
async function yr({
|
|
697
699
|
arcgisMap: e,
|
|
698
700
|
arcgisMapView: t,
|
|
699
701
|
layerId: r,
|
|
700
|
-
fields:
|
|
701
|
-
colorSchemes:
|
|
702
|
+
fields: a,
|
|
703
|
+
colorSchemes: o
|
|
702
704
|
}) {
|
|
703
|
-
const n = t,
|
|
704
|
-
if (!
|
|
705
|
+
const n = t, l = e?.allLayers.find((c) => c.id === r);
|
|
706
|
+
if (!l)
|
|
705
707
|
return `Could not find layer for id: ${r}`;
|
|
706
|
-
const
|
|
708
|
+
const s = {
|
|
707
709
|
styleName: "dot-density",
|
|
708
|
-
fields:
|
|
709
|
-
layer:
|
|
710
|
+
fields: a,
|
|
711
|
+
layer: l,
|
|
710
712
|
view: n,
|
|
711
|
-
colorSchemeTags:
|
|
713
|
+
colorSchemeTags: o
|
|
712
714
|
};
|
|
713
715
|
try {
|
|
714
|
-
const
|
|
715
|
-
return
|
|
716
|
-
} catch (
|
|
717
|
-
return `Error applying dot density renderer: ${
|
|
716
|
+
const c = mr(s), u = await hr(c);
|
|
717
|
+
return l.renderer = u.renderer, l.visible = !0, `Dot Density renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
|
|
718
|
+
} catch (c) {
|
|
719
|
+
return `Error applying dot density renderer: ${c instanceof Error ? c.message : String(c)}`;
|
|
718
720
|
}
|
|
719
721
|
}
|
|
720
|
-
async function
|
|
722
|
+
async function fr({
|
|
721
723
|
layerId: e,
|
|
722
724
|
fields: t,
|
|
723
725
|
colorSchemes: r
|
|
724
|
-
},
|
|
725
|
-
const { mapView:
|
|
726
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
727
|
-
arcgisMap:
|
|
728
|
-
arcgisMapView:
|
|
726
|
+
}, a) {
|
|
727
|
+
const { mapView: o } = R(a);
|
|
728
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await yr({
|
|
729
|
+
arcgisMap: o.map,
|
|
730
|
+
arcgisMapView: o,
|
|
729
731
|
layerId: e,
|
|
730
732
|
fields: t,
|
|
731
733
|
colorSchemes: r
|
|
732
734
|
});
|
|
733
735
|
}
|
|
734
|
-
const
|
|
736
|
+
const gr = i.object({
|
|
735
737
|
layerId: i.string().describe("The id of the layer to apply the dot density renderer to"),
|
|
736
738
|
fields: i.array(i.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
|
|
737
739
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
738
|
-
}),
|
|
740
|
+
}), Gn = f(fr, {
|
|
739
741
|
name: "dot-density",
|
|
740
742
|
description: `Dot Density
|
|
741
743
|
Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
|
|
@@ -749,143 +751,143 @@ const yr = i.object({
|
|
|
749
751
|
- Display demographic patterns within census tracts
|
|
750
752
|
**Fields:** Requires 2-8 number fields.
|
|
751
753
|
**Keywords:** density, how much, how many, total, number, amount`,
|
|
752
|
-
schema:
|
|
754
|
+
schema: gr
|
|
753
755
|
});
|
|
754
|
-
function
|
|
755
|
-
const { fields: t, layer: r, view:
|
|
756
|
+
function wr(e) {
|
|
757
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
756
758
|
let n;
|
|
757
|
-
const
|
|
758
|
-
return
|
|
759
|
-
includedTags:
|
|
760
|
-
basemap:
|
|
759
|
+
const l = t[0];
|
|
760
|
+
return o && (n = He({
|
|
761
|
+
includedTags: o,
|
|
762
|
+
basemap: a.map?.basemap || "topo"
|
|
761
763
|
})[0]), {
|
|
762
764
|
layer: r,
|
|
763
|
-
view:
|
|
764
|
-
field:
|
|
765
|
+
view: a,
|
|
766
|
+
field: l,
|
|
765
767
|
heatmapScheme: n
|
|
766
768
|
};
|
|
767
769
|
}
|
|
768
|
-
async function
|
|
769
|
-
return await
|
|
770
|
+
async function br(e) {
|
|
771
|
+
return await Be(e);
|
|
770
772
|
}
|
|
771
|
-
async function
|
|
773
|
+
async function Tr({
|
|
772
774
|
arcgisMap: e,
|
|
773
775
|
arcgisMapView: t,
|
|
774
776
|
layerId: r,
|
|
775
|
-
fields:
|
|
776
|
-
colorSchemes:
|
|
777
|
+
fields: a,
|
|
778
|
+
colorSchemes: o
|
|
777
779
|
}) {
|
|
778
|
-
const n = t,
|
|
779
|
-
if (!
|
|
780
|
+
const n = t, l = e?.allLayers.find((c) => c.id === r);
|
|
781
|
+
if (!l)
|
|
780
782
|
return `Could not find layer for id: ${r}`;
|
|
781
|
-
const
|
|
783
|
+
const s = {
|
|
782
784
|
styleName: "heatmap",
|
|
783
|
-
fields:
|
|
784
|
-
layer:
|
|
785
|
+
fields: a,
|
|
786
|
+
layer: l,
|
|
785
787
|
view: n,
|
|
786
|
-
colorSchemeTags:
|
|
788
|
+
colorSchemeTags: o
|
|
787
789
|
};
|
|
788
790
|
try {
|
|
789
|
-
const
|
|
790
|
-
return
|
|
791
|
-
} catch (
|
|
792
|
-
return `Error applying heatmap renderer: ${
|
|
791
|
+
const c = wr(s), u = await br(c);
|
|
792
|
+
return l.renderer = u.renderer, l.visible = !0, `Heatmap renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
|
|
793
|
+
} catch (c) {
|
|
794
|
+
return `Error applying heatmap renderer: ${c instanceof Error ? c.message : String(c)}`;
|
|
793
795
|
}
|
|
794
796
|
}
|
|
795
|
-
async function
|
|
797
|
+
async function vr({
|
|
796
798
|
layerId: e,
|
|
797
799
|
fields: t,
|
|
798
800
|
colorSchemes: r
|
|
799
|
-
},
|
|
800
|
-
const { mapView:
|
|
801
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
802
|
-
arcgisMap:
|
|
803
|
-
arcgisMapView:
|
|
801
|
+
}, a) {
|
|
802
|
+
const { mapView: o } = R(a);
|
|
803
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Tr({
|
|
804
|
+
arcgisMap: o.map,
|
|
805
|
+
arcgisMapView: o,
|
|
804
806
|
layerId: e,
|
|
805
807
|
fields: t,
|
|
806
808
|
colorSchemes: r
|
|
807
809
|
});
|
|
808
810
|
}
|
|
809
|
-
const
|
|
811
|
+
const Sr = i.object({
|
|
810
812
|
layerId: i.string().describe("The id of the layer to apply the heatmap renderer to"),
|
|
811
813
|
fields: i.array(i.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
|
|
812
814
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
813
|
-
}),
|
|
815
|
+
}), On = f(vr, {
|
|
814
816
|
name: "heatmap",
|
|
815
817
|
description: `Label: Heat Map
|
|
816
818
|
Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
|
|
817
819
|
Keywords: density, heatmap, hot spots, pattern, cluster
|
|
818
820
|
Example: Create a heatmap
|
|
819
821
|
Fields: This typically requires zero or one field of type number.`,
|
|
820
|
-
schema:
|
|
822
|
+
schema: Sr
|
|
821
823
|
});
|
|
822
|
-
function
|
|
823
|
-
const { fields: t, layer: r, view:
|
|
824
|
-
let
|
|
825
|
-
return n && (
|
|
824
|
+
function xr(e) {
|
|
825
|
+
const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: n } = e;
|
|
826
|
+
let l;
|
|
827
|
+
return n && (l = Ze({
|
|
826
828
|
geometryType: r.geometryType,
|
|
827
829
|
includedTags: n,
|
|
828
830
|
numColors: Math.min(t.length, 10)
|
|
829
831
|
})[0]), {
|
|
830
832
|
layer: r,
|
|
831
|
-
view:
|
|
832
|
-
fields: t.map((
|
|
833
|
+
view: a,
|
|
834
|
+
fields: t.map((s) => ({ name: s })).slice(0, 9),
|
|
833
835
|
outlineOptimizationEnabled: !0,
|
|
834
836
|
sizeOptimizationEnabled: !0,
|
|
835
|
-
includeSizeVariable:
|
|
836
|
-
predominanceScheme:
|
|
837
|
+
includeSizeVariable: o.includes("Size"),
|
|
838
|
+
predominanceScheme: l
|
|
837
839
|
};
|
|
838
840
|
}
|
|
839
|
-
async function
|
|
840
|
-
return await
|
|
841
|
+
async function Rr(e) {
|
|
842
|
+
return await Je(e);
|
|
841
843
|
}
|
|
842
|
-
async function
|
|
844
|
+
async function $r({
|
|
843
845
|
arcgisMap: e,
|
|
844
846
|
arcgisMapView: t,
|
|
845
847
|
layerId: r,
|
|
846
|
-
fields:
|
|
847
|
-
colorSchemes:
|
|
848
|
+
fields: a,
|
|
849
|
+
colorSchemes: o,
|
|
848
850
|
includeSize: n
|
|
849
851
|
}) {
|
|
850
|
-
const
|
|
851
|
-
if (!
|
|
852
|
+
const l = t, s = e?.allLayers.find((d) => d.id === r);
|
|
853
|
+
if (!s)
|
|
852
854
|
return `Could not find layer for id: ${r}`;
|
|
853
|
-
const
|
|
855
|
+
const u = {
|
|
854
856
|
styleName: n ? "predominance-size" : "predominance",
|
|
855
|
-
fields:
|
|
856
|
-
layer:
|
|
857
|
-
view:
|
|
858
|
-
colorSchemeTags:
|
|
857
|
+
fields: a,
|
|
858
|
+
layer: s,
|
|
859
|
+
view: l,
|
|
860
|
+
colorSchemeTags: o
|
|
859
861
|
};
|
|
860
862
|
try {
|
|
861
|
-
const d =
|
|
862
|
-
return
|
|
863
|
+
const d = xr(u), p = await Rr(d);
|
|
864
|
+
return s.renderer = p.renderer, s.visible = !0, `Predominance renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
863
865
|
} catch (d) {
|
|
864
866
|
return `Error applying predominance renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
865
867
|
}
|
|
866
868
|
}
|
|
867
|
-
async function
|
|
869
|
+
async function Cr({
|
|
868
870
|
layerId: e,
|
|
869
871
|
fields: t,
|
|
870
872
|
colorSchemes: r,
|
|
871
|
-
includeSize:
|
|
872
|
-
},
|
|
873
|
-
const { mapView: n } = R(
|
|
874
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
873
|
+
includeSize: a
|
|
874
|
+
}, o) {
|
|
875
|
+
const { mapView: n } = R(o);
|
|
876
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await $r({
|
|
875
877
|
arcgisMap: n.map,
|
|
876
878
|
arcgisMapView: n,
|
|
877
879
|
layerId: e,
|
|
878
880
|
fields: t,
|
|
879
881
|
colorSchemes: r,
|
|
880
|
-
includeSize:
|
|
882
|
+
includeSize: a
|
|
881
883
|
});
|
|
882
884
|
}
|
|
883
|
-
const
|
|
885
|
+
const Er = i.object({
|
|
884
886
|
layerId: i.string().describe("The id of the layer to apply the predominance renderer to"),
|
|
885
887
|
fields: i.array(i.string()).describe("The fields to use for the predominance renderer (competing categories)"),
|
|
886
888
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
887
889
|
includeSize: i.boolean().optional().describe("Whether to include size visualization (predominance-size)")
|
|
888
|
-
}),
|
|
890
|
+
}), Mn = f(Cr, {
|
|
889
891
|
name: "predominance",
|
|
890
892
|
description: `Label: Predominant category
|
|
891
893
|
Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
|
|
@@ -898,219 +900,219 @@ const $r = i.object({
|
|
|
898
900
|
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
|
|
899
901
|
Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
|
|
900
902
|
Fields: This style relies on 2-10 number fields.`,
|
|
901
|
-
schema:
|
|
903
|
+
schema: Er
|
|
902
904
|
});
|
|
903
|
-
function
|
|
904
|
-
const { fields: t, layer: r, view:
|
|
905
|
+
function Nr(e) {
|
|
906
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
905
907
|
let n;
|
|
906
|
-
const
|
|
908
|
+
const l = {
|
|
907
909
|
field: t[0]
|
|
908
|
-
},
|
|
910
|
+
}, s = {
|
|
909
911
|
field: t[1]
|
|
910
912
|
};
|
|
911
|
-
return
|
|
913
|
+
return o && (n = Xe({
|
|
912
914
|
geometryType: r.geometryType,
|
|
913
|
-
includedTags:
|
|
915
|
+
includedTags: o
|
|
914
916
|
})[0]), {
|
|
915
917
|
layer: r,
|
|
916
|
-
view:
|
|
917
|
-
field1:
|
|
918
|
-
field2:
|
|
918
|
+
view: a,
|
|
919
|
+
field1: l,
|
|
920
|
+
field2: s,
|
|
919
921
|
outlineOptimizationEnabled: !0,
|
|
920
922
|
sizeOptimizationEnabled: !0,
|
|
921
923
|
relationshipScheme: n
|
|
922
924
|
};
|
|
923
925
|
}
|
|
924
|
-
async function
|
|
925
|
-
return await
|
|
926
|
+
async function Ir(e) {
|
|
927
|
+
return await Ye(e);
|
|
926
928
|
}
|
|
927
|
-
async function
|
|
929
|
+
async function kr({
|
|
928
930
|
arcgisMap: e,
|
|
929
931
|
arcgisMapView: t,
|
|
930
932
|
layerId: r,
|
|
931
|
-
fields:
|
|
932
|
-
colorSchemes:
|
|
933
|
+
fields: a,
|
|
934
|
+
colorSchemes: o
|
|
933
935
|
}) {
|
|
934
|
-
const n = t,
|
|
935
|
-
if (!
|
|
936
|
+
const n = t, l = e?.allLayers.find((c) => c.id === r);
|
|
937
|
+
if (!l)
|
|
936
938
|
return `Could not find layer for id: ${r}`;
|
|
937
|
-
const
|
|
939
|
+
const s = {
|
|
938
940
|
styleName: "relationship",
|
|
939
|
-
fields:
|
|
940
|
-
layer:
|
|
941
|
+
fields: a,
|
|
942
|
+
layer: l,
|
|
941
943
|
view: n,
|
|
942
|
-
colorSchemeTags:
|
|
944
|
+
colorSchemeTags: o
|
|
943
945
|
};
|
|
944
946
|
try {
|
|
945
|
-
const
|
|
946
|
-
return
|
|
947
|
-
} catch (
|
|
948
|
-
return `Error applying relationship renderer: ${
|
|
947
|
+
const c = Nr(s), u = await Ir(c);
|
|
948
|
+
return l.renderer = u.renderer, l.visible = !0, `Relationship renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
|
|
949
|
+
} catch (c) {
|
|
950
|
+
return `Error applying relationship renderer: ${c instanceof Error ? c.message : String(c)}`;
|
|
949
951
|
}
|
|
950
952
|
}
|
|
951
953
|
async function Fr({
|
|
952
954
|
layerId: e,
|
|
953
955
|
fields: t,
|
|
954
956
|
colorSchemes: r
|
|
955
|
-
},
|
|
956
|
-
const { mapView:
|
|
957
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
958
|
-
arcgisMap:
|
|
959
|
-
arcgisMapView:
|
|
957
|
+
}, a) {
|
|
958
|
+
const { mapView: o } = R(a);
|
|
959
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await kr({
|
|
960
|
+
arcgisMap: o.map,
|
|
961
|
+
arcgisMapView: o,
|
|
960
962
|
layerId: e,
|
|
961
963
|
fields: t,
|
|
962
964
|
colorSchemes: r
|
|
963
965
|
});
|
|
964
966
|
}
|
|
965
|
-
const
|
|
967
|
+
const zr = i.object({
|
|
966
968
|
layerId: i.string().describe("The id of the layer to apply the relationship renderer to"),
|
|
967
969
|
fields: i.array(i.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
|
|
968
970
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
969
|
-
}),
|
|
971
|
+
}), Qn = f(Fr, {
|
|
970
972
|
name: "relationship",
|
|
971
973
|
description: `Label: Relationship
|
|
972
974
|
Description: Overlays two color ramps to represent the relationship between two numeric attributes.
|
|
973
975
|
Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
|
|
974
976
|
Example: Show the relationship between tree height and carbon storage
|
|
975
977
|
Fields: This style requires two number fields.`,
|
|
976
|
-
schema:
|
|
978
|
+
schema: zr
|
|
977
979
|
});
|
|
978
|
-
function
|
|
979
|
-
const { fields: t, layer: r, view:
|
|
980
|
+
function qr(e) {
|
|
981
|
+
const { fields: t, layer: r, view: a, theme: o } = e, n = t[0];
|
|
980
982
|
return {
|
|
981
983
|
layer: r,
|
|
982
|
-
view:
|
|
984
|
+
view: a,
|
|
983
985
|
startTime: n,
|
|
984
986
|
endTime: /* @__PURE__ */ new Date(),
|
|
985
|
-
theme:
|
|
987
|
+
theme: o,
|
|
986
988
|
sizeOptimizationEnabled: !0,
|
|
987
989
|
outlineOptimizationEnabled: !0
|
|
988
990
|
};
|
|
989
991
|
}
|
|
990
|
-
async function
|
|
991
|
-
return await
|
|
992
|
+
async function Dr(e) {
|
|
993
|
+
return await et(e);
|
|
992
994
|
}
|
|
993
|
-
async function
|
|
995
|
+
async function Ar({
|
|
994
996
|
arcgisMap: e,
|
|
995
997
|
arcgisMapView: t,
|
|
996
998
|
layerId: r,
|
|
997
|
-
fields:
|
|
998
|
-
colorSchemes:
|
|
999
|
+
fields: a,
|
|
1000
|
+
colorSchemes: o,
|
|
999
1001
|
theme: n
|
|
1000
1002
|
}) {
|
|
1001
|
-
const
|
|
1002
|
-
if (!
|
|
1003
|
+
const l = t, s = e?.allLayers.find((u) => u.id === r);
|
|
1004
|
+
if (!s)
|
|
1003
1005
|
return `Could not find layer for id: ${r}`;
|
|
1004
|
-
const
|
|
1006
|
+
const c = {
|
|
1005
1007
|
styleName: "size-age",
|
|
1006
|
-
fields:
|
|
1007
|
-
layer:
|
|
1008
|
-
view:
|
|
1009
|
-
colorSchemeTags:
|
|
1008
|
+
fields: a,
|
|
1009
|
+
layer: s,
|
|
1010
|
+
view: l,
|
|
1011
|
+
colorSchemeTags: o,
|
|
1010
1012
|
theme: n
|
|
1011
1013
|
};
|
|
1012
1014
|
try {
|
|
1013
|
-
const
|
|
1014
|
-
return
|
|
1015
|
-
} catch (
|
|
1016
|
-
return `Error applying size-age renderer: ${
|
|
1015
|
+
const u = qr(c), d = await Dr(u);
|
|
1016
|
+
return s.renderer = d.renderer, s.visible = !0, `Size-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1017
|
+
} catch (u) {
|
|
1018
|
+
return `Error applying size-age renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1017
1019
|
}
|
|
1018
1020
|
}
|
|
1019
|
-
async function
|
|
1021
|
+
async function Pr({
|
|
1020
1022
|
layerId: e,
|
|
1021
1023
|
fields: t,
|
|
1022
1024
|
colorSchemes: r,
|
|
1023
|
-
theme:
|
|
1024
|
-
},
|
|
1025
|
-
const { mapView: n } = R(
|
|
1026
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
1025
|
+
theme: a
|
|
1026
|
+
}, o) {
|
|
1027
|
+
const { mapView: n } = R(o);
|
|
1028
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ar({
|
|
1027
1029
|
arcgisMap: n.map,
|
|
1028
1030
|
arcgisMapView: n,
|
|
1029
1031
|
layerId: e,
|
|
1030
1032
|
fields: t,
|
|
1031
1033
|
colorSchemes: r,
|
|
1032
|
-
theme:
|
|
1034
|
+
theme: a
|
|
1033
1035
|
});
|
|
1034
1036
|
}
|
|
1035
|
-
const
|
|
1037
|
+
const Lr = i.object({
|
|
1036
1038
|
layerId: i.string().describe("The id of the layer to apply the size-age renderer to"),
|
|
1037
1039
|
fields: i.array(i.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
|
|
1038
1040
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1039
1041
|
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
|
|
1040
|
-
}),
|
|
1042
|
+
}), _n = f(Pr, {
|
|
1041
1043
|
name: "size-age",
|
|
1042
1044
|
description: `Label: Age (size)
|
|
1043
1045
|
Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
|
|
1044
1046
|
Keywords: since, age, how old, how long
|
|
1045
1047
|
Example: Change the size of features so older features are larger than new features.
|
|
1046
1048
|
Fields: This style requires at least one field with a date type.`,
|
|
1047
|
-
schema:
|
|
1049
|
+
schema: Lr
|
|
1048
1050
|
});
|
|
1049
|
-
function
|
|
1050
|
-
const { fields: t, layer: r, view:
|
|
1051
|
-
let { theme:
|
|
1052
|
-
const
|
|
1051
|
+
function jr(e) {
|
|
1052
|
+
const { fields: t, layer: r, view: a } = e;
|
|
1053
|
+
let { theme: o } = e, n = t[1];
|
|
1054
|
+
const l = t[0];
|
|
1053
1055
|
return {
|
|
1054
1056
|
layer: r,
|
|
1055
|
-
view:
|
|
1056
|
-
field:
|
|
1057
|
+
view: a,
|
|
1058
|
+
field: l,
|
|
1057
1059
|
normalizationField: n,
|
|
1058
|
-
theme:
|
|
1060
|
+
theme: o,
|
|
1059
1061
|
sizeOptimizationEnabled: !0,
|
|
1060
1062
|
outlineOptimizationEnabled: !0
|
|
1061
1063
|
};
|
|
1062
1064
|
}
|
|
1063
|
-
async function
|
|
1064
|
-
return await
|
|
1065
|
+
async function Gr(e) {
|
|
1066
|
+
return await tt(e);
|
|
1065
1067
|
}
|
|
1066
|
-
async function
|
|
1068
|
+
async function Or({
|
|
1067
1069
|
arcgisMap: e,
|
|
1068
1070
|
arcgisMapView: t,
|
|
1069
1071
|
layerId: r,
|
|
1070
|
-
fields:
|
|
1071
|
-
colorSchemes:
|
|
1072
|
+
fields: a,
|
|
1073
|
+
colorSchemes: o,
|
|
1072
1074
|
theme: n
|
|
1073
1075
|
}) {
|
|
1074
|
-
const
|
|
1075
|
-
if (!
|
|
1076
|
+
const l = t, s = e?.allLayers.find((u) => u.id === r);
|
|
1077
|
+
if (!s)
|
|
1076
1078
|
return `Could not find layer for id: ${r}`;
|
|
1077
|
-
const
|
|
1079
|
+
const c = {
|
|
1078
1080
|
styleName: "size",
|
|
1079
|
-
fields:
|
|
1080
|
-
layer:
|
|
1081
|
-
view:
|
|
1082
|
-
colorSchemeTags:
|
|
1081
|
+
fields: a,
|
|
1082
|
+
layer: s,
|
|
1083
|
+
view: l,
|
|
1084
|
+
colorSchemeTags: o,
|
|
1083
1085
|
theme: n
|
|
1084
1086
|
};
|
|
1085
1087
|
try {
|
|
1086
|
-
const
|
|
1087
|
-
return
|
|
1088
|
-
} catch (
|
|
1089
|
-
return `Error applying size renderer: ${
|
|
1088
|
+
const u = jr(c), d = await Gr(u);
|
|
1089
|
+
return s.renderer = d.renderer, s.visible = !0, `Size renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1090
|
+
} catch (u) {
|
|
1091
|
+
return `Error applying size renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1090
1092
|
}
|
|
1091
1093
|
}
|
|
1092
|
-
async function
|
|
1094
|
+
async function Mr({
|
|
1093
1095
|
layerId: e,
|
|
1094
1096
|
fields: t,
|
|
1095
1097
|
colorSchemes: r,
|
|
1096
|
-
theme:
|
|
1097
|
-
},
|
|
1098
|
-
const { mapView: n } = R(
|
|
1099
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
1098
|
+
theme: a
|
|
1099
|
+
}, o) {
|
|
1100
|
+
const { mapView: n } = R(o);
|
|
1101
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Or({
|
|
1100
1102
|
arcgisMap: n.map,
|
|
1101
1103
|
arcgisMapView: n,
|
|
1102
1104
|
layerId: e,
|
|
1103
1105
|
fields: t,
|
|
1104
1106
|
colorSchemes: r,
|
|
1105
|
-
theme:
|
|
1107
|
+
theme: a
|
|
1106
1108
|
});
|
|
1107
1109
|
}
|
|
1108
|
-
const
|
|
1110
|
+
const Qr = i.object({
|
|
1109
1111
|
layerId: i.string().describe("The id of the layer to apply the size renderer to"),
|
|
1110
1112
|
fields: i.array(i.string()).describe("The field(s) to use for the size renderer (numeric data)"),
|
|
1111
1113
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1112
1114
|
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
|
|
1113
|
-
}),
|
|
1115
|
+
}), Wn = f(Mr, {
|
|
1114
1116
|
name: "size",
|
|
1115
1117
|
description: `Label: Counts and Amounts (size)
|
|
1116
1118
|
Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
|
|
@@ -1123,255 +1125,252 @@ const Or = i.object({
|
|
|
1123
1125
|
Keywords: graduated size, proportional size, classed size, how much, total, number, when
|
|
1124
1126
|
Example: Vary the size of each feature based on the date a ticket was completed.
|
|
1125
1127
|
Fields: This style requires a single field with a date type.`,
|
|
1126
|
-
schema:
|
|
1128
|
+
schema: Qr
|
|
1127
1129
|
});
|
|
1128
|
-
function
|
|
1129
|
-
const { fields: t, layer: r, view:
|
|
1130
|
-
let
|
|
1131
|
-
return
|
|
1130
|
+
function _r(e) {
|
|
1131
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e, n = t[0], l = t[1], s = t[2];
|
|
1132
|
+
let c;
|
|
1133
|
+
return o && (c = at({
|
|
1132
1134
|
geometryType: r.geometryType,
|
|
1133
|
-
includedTags:
|
|
1135
|
+
includedTags: o
|
|
1134
1136
|
})[0]), {
|
|
1135
1137
|
layer: r,
|
|
1136
|
-
view:
|
|
1138
|
+
view: a,
|
|
1137
1139
|
field: n,
|
|
1138
|
-
field2:
|
|
1139
|
-
field3:
|
|
1140
|
+
field2: l,
|
|
1141
|
+
field3: s,
|
|
1140
1142
|
outlineOptimizationEnabled: !0,
|
|
1141
1143
|
sizeOptimizationEnabled: !0,
|
|
1142
|
-
typeScheme:
|
|
1144
|
+
typeScheme: c
|
|
1143
1145
|
};
|
|
1144
1146
|
}
|
|
1145
|
-
async function
|
|
1146
|
-
return await
|
|
1147
|
+
async function Wr(e) {
|
|
1148
|
+
return await rt(e);
|
|
1147
1149
|
}
|
|
1148
|
-
async function
|
|
1150
|
+
async function Vr({
|
|
1149
1151
|
arcgisMap: e,
|
|
1150
1152
|
arcgisMapView: t,
|
|
1151
1153
|
layerId: r,
|
|
1152
|
-
fields:
|
|
1153
|
-
colorSchemes:
|
|
1154
|
+
fields: a,
|
|
1155
|
+
colorSchemes: o,
|
|
1154
1156
|
theme: n
|
|
1155
1157
|
}) {
|
|
1156
|
-
const
|
|
1157
|
-
if (!
|
|
1158
|
+
const l = t, s = e?.allLayers.find((u) => u.id === r);
|
|
1159
|
+
if (!s)
|
|
1158
1160
|
return `Could not find layer for id: ${r}`;
|
|
1159
|
-
const
|
|
1161
|
+
const c = {
|
|
1160
1162
|
styleName: "type",
|
|
1161
|
-
fields:
|
|
1162
|
-
layer:
|
|
1163
|
-
view:
|
|
1164
|
-
colorSchemeTags:
|
|
1163
|
+
fields: a,
|
|
1164
|
+
layer: s,
|
|
1165
|
+
view: l,
|
|
1166
|
+
colorSchemeTags: o,
|
|
1165
1167
|
theme: n
|
|
1166
1168
|
};
|
|
1167
1169
|
try {
|
|
1168
|
-
const
|
|
1169
|
-
return
|
|
1170
|
-
} catch (
|
|
1171
|
-
return `Error applying type renderer: ${
|
|
1170
|
+
const u = _r(c), d = await Wr(u);
|
|
1171
|
+
return s.renderer = d.renderer, s.visible = !0, `Type renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1172
|
+
} catch (u) {
|
|
1173
|
+
return `Error applying type renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1172
1174
|
}
|
|
1173
1175
|
}
|
|
1174
|
-
async function
|
|
1176
|
+
async function Ur({
|
|
1175
1177
|
layerId: e,
|
|
1176
1178
|
fields: t,
|
|
1177
1179
|
colorSchemes: r,
|
|
1178
|
-
theme:
|
|
1179
|
-
},
|
|
1180
|
-
const { mapView: n } = R(
|
|
1181
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } },
|
|
1180
|
+
theme: a
|
|
1181
|
+
}, o) {
|
|
1182
|
+
const { mapView: n } = R(o);
|
|
1183
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Vr({
|
|
1182
1184
|
arcgisMap: n.map,
|
|
1183
1185
|
arcgisMapView: n,
|
|
1184
1186
|
layerId: e,
|
|
1185
1187
|
fields: t,
|
|
1186
1188
|
colorSchemes: r,
|
|
1187
|
-
theme:
|
|
1189
|
+
theme: a
|
|
1188
1190
|
});
|
|
1189
1191
|
}
|
|
1190
|
-
const
|
|
1192
|
+
const Kr = i.object({
|
|
1191
1193
|
layerId: i.string().describe("The id of the layer to apply the type renderer to"),
|
|
1192
1194
|
fields: i.array(i.string()).describe("The field(s) to use for the type renderer (categorical data)"),
|
|
1193
1195
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1194
1196
|
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
|
|
1195
|
-
}),
|
|
1197
|
+
}), Vn = f(Ur, {
|
|
1196
1198
|
name: "type",
|
|
1197
1199
|
description: `Label: Types (unique symbols)
|
|
1198
1200
|
Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
|
|
1199
1201
|
Keywords: categorical, category, type, unique, discrete, point of interest, region, group
|
|
1200
1202
|
Example: Color each feature based on the region it belongs to
|
|
1201
1203
|
Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
|
|
1202
|
-
schema:
|
|
1203
|
-
}),
|
|
1204
|
-
...
|
|
1204
|
+
schema: Kr
|
|
1205
|
+
}), Un = b.Root({
|
|
1206
|
+
...B(),
|
|
1205
1207
|
vectorSearchLayerIds: b(),
|
|
1206
1208
|
vectorSearchFieldResults: b(),
|
|
1207
1209
|
layerFieldInfo: b(),
|
|
1208
1210
|
selectedLayerId: b()
|
|
1209
|
-
}),
|
|
1210
|
-
...
|
|
1211
|
+
}), Kn = b.Root({
|
|
1212
|
+
...B(),
|
|
1211
1213
|
vectorSearchLayerIds: b(),
|
|
1212
1214
|
vectorSearchFieldResults: b(),
|
|
1213
1215
|
layerFieldInfo: b(),
|
|
1214
1216
|
queryResponse: b(),
|
|
1215
1217
|
dataExplorationMessages: b({
|
|
1216
|
-
reducer:
|
|
1218
|
+
reducer: Te,
|
|
1217
1219
|
default: () => []
|
|
1218
1220
|
})
|
|
1219
|
-
}),
|
|
1220
|
-
function
|
|
1221
|
+
}), Br = ["mapView"];
|
|
1222
|
+
function F(e) {
|
|
1221
1223
|
const r = e?.configurable?.context;
|
|
1222
1224
|
if (!r || typeof r != "object")
|
|
1223
1225
|
throw new Error("DataExplorationAgent context missing");
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
throw new Error(`DataExplorationAgent context missing: ${
|
|
1226
|
+
const a = Br.filter((o) => !(o in r));
|
|
1227
|
+
if (a.length)
|
|
1228
|
+
throw new Error(`DataExplorationAgent context missing: ${a.join(", ")}`);
|
|
1227
1229
|
return r;
|
|
1228
1230
|
}
|
|
1229
|
-
const
|
|
1230
|
-
const t = e.map?.allLayers.filter((
|
|
1231
|
+
const Hr = (e) => {
|
|
1232
|
+
const t = e.map?.allLayers.filter((a) => a.type === "feature");
|
|
1231
1233
|
let r = 0;
|
|
1232
|
-
return t?.forEach((
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1234
|
+
return t?.forEach((a) => {
|
|
1235
|
+
const o = a;
|
|
1236
|
+
o.featureEffect && (o.featureEffect = null, r++);
|
|
1235
1237
|
}), r > 0 ? `Cleared filters from ${r} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
|
|
1236
|
-
},
|
|
1237
|
-
const { mapView: r } =
|
|
1238
|
-
return
|
|
1239
|
-
},
|
|
1238
|
+
}, Jr = async (e, t) => {
|
|
1239
|
+
const { mapView: r } = F(t);
|
|
1240
|
+
return Hr(r);
|
|
1241
|
+
}, Zr = f(Jr, {
|
|
1240
1242
|
name: "clearFilters",
|
|
1241
1243
|
description: "Clears all feature effects/filters from the map but does NOT change the current view. Use when user says 'clear filters', 'reset filters', 'remove filters', 'show all features', or wants to remove emphasis without navigating anywhere.",
|
|
1242
1244
|
schema: i.object({})
|
|
1243
|
-
}),
|
|
1244
|
-
e.map?.allLayers.filter((
|
|
1245
|
-
const n =
|
|
1245
|
+
}), Yr = async (e) => {
|
|
1246
|
+
e.map?.allLayers.filter((o) => o.type === "feature")?.forEach((o) => {
|
|
1247
|
+
const n = o;
|
|
1246
1248
|
n.featureEffect && (n.featureEffect = null);
|
|
1247
1249
|
});
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1250
|
-
},
|
|
1251
|
-
const { mapView: r } =
|
|
1252
|
-
return await
|
|
1253
|
-
},
|
|
1250
|
+
const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
1251
|
+
return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
|
|
1252
|
+
}, Xr = async (e, t) => {
|
|
1253
|
+
const { mapView: r } = F(t);
|
|
1254
|
+
return await Yr(r);
|
|
1255
|
+
}, ea = f(Xr, {
|
|
1254
1256
|
name: "resetMap",
|
|
1255
1257
|
description: "Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",
|
|
1256
1258
|
schema: i.object({})
|
|
1257
|
-
});
|
|
1258
|
-
function
|
|
1259
|
+
}), be = 750;
|
|
1260
|
+
function U(e) {
|
|
1259
1261
|
return "point" in e && e.point !== void 0;
|
|
1260
1262
|
}
|
|
1261
|
-
function
|
|
1263
|
+
function j(e) {
|
|
1262
1264
|
return "layerId" in e && e.layerId !== void 0;
|
|
1263
1265
|
}
|
|
1264
|
-
const
|
|
1265
|
-
if (
|
|
1266
|
+
const H = async (e, t) => {
|
|
1267
|
+
if (U(e)) {
|
|
1266
1268
|
const { point: r } = e;
|
|
1267
|
-
return { geometry: new
|
|
1269
|
+
return { geometry: new ve({
|
|
1268
1270
|
x: r.x,
|
|
1269
1271
|
y: r.y,
|
|
1270
1272
|
spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
|
|
1271
1273
|
}) };
|
|
1272
1274
|
}
|
|
1273
|
-
if (
|
|
1275
|
+
if (j(e)) {
|
|
1274
1276
|
const r = t.map?.allLayers.find(
|
|
1275
|
-
(
|
|
1277
|
+
(n) => n.id === e.layerId
|
|
1276
1278
|
);
|
|
1277
1279
|
if (!r)
|
|
1278
1280
|
return { error: `Could not find geometry layer with ID: ${e.layerId}` };
|
|
1279
|
-
const
|
|
1281
|
+
const a = r.title ?? r.id, o = e.where?.trim() || "1=1";
|
|
1280
1282
|
try {
|
|
1281
|
-
const
|
|
1282
|
-
where:
|
|
1283
|
+
const n = await r.queryFeatures({
|
|
1284
|
+
where: o,
|
|
1283
1285
|
returnGeometry: !0,
|
|
1284
|
-
outSpatialReference: t.spatialReference
|
|
1286
|
+
outSpatialReference: t.spatialReference,
|
|
1287
|
+
num: be + 1
|
|
1285
1288
|
});
|
|
1286
|
-
if (!
|
|
1289
|
+
if (!n.features.length)
|
|
1287
1290
|
return {
|
|
1288
|
-
error: `No features found in geometry layer "${
|
|
1291
|
+
error: `No features found in geometry layer "${a}" with the specified where clause: ${o}`
|
|
1289
1292
|
};
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
}
|
|
1302
|
-
return n.spatialReference || (n.spatialReference = t.spatialReference), { geometry: n };
|
|
1303
|
-
} catch (a) {
|
|
1304
|
-
return { error: `Failed to query geometry: ${String(a)}` };
|
|
1293
|
+
if (n.features.length > be)
|
|
1294
|
+
return {
|
|
1295
|
+
error: `Geometry filter for layer "${a}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`
|
|
1296
|
+
};
|
|
1297
|
+
const l = n.features.map((c) => c.geometry).filter((c) => !!c);
|
|
1298
|
+
if (!l.length)
|
|
1299
|
+
return { error: "No valid geometries found for the matched geometry layer features." };
|
|
1300
|
+
const s = l.length === 1 ? l[0] : it.executeMany(l);
|
|
1301
|
+
return s ? (s.spatialReference || (s.spatialReference = t.spatialReference), { geometry: s }) : { error: "Failed to combine geometries from geometry layer." };
|
|
1302
|
+
} catch (n) {
|
|
1303
|
+
return { error: `Failed to query geometry: ${String(n)}` };
|
|
1305
1304
|
}
|
|
1306
1305
|
}
|
|
1307
1306
|
return { error: "Invalid geometry configuration provided" };
|
|
1308
|
-
},
|
|
1309
|
-
const
|
|
1310
|
-
if (!
|
|
1307
|
+
}, ta = async (e, t, r, a, o, n) => {
|
|
1308
|
+
const l = e.map?.allLayers.find((c) => c.id === t);
|
|
1309
|
+
if (!l)
|
|
1311
1310
|
return { success: !1, error: `Layer '${t}' not found.` };
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1311
|
+
const s = l.createQuery();
|
|
1312
|
+
s.where = r ?? "1=1", a && (s.geometry = a, s.spatialRelationship = "intersects", o && (s.distance = o), n && (s.units = n));
|
|
1314
1313
|
try {
|
|
1315
|
-
const { extent:
|
|
1316
|
-
return !
|
|
1314
|
+
const { extent: c, count: u } = await l.queryExtent(s);
|
|
1315
|
+
return !c || u === 0 ? {
|
|
1317
1316
|
success: !1,
|
|
1318
|
-
error: `No features found for filter (where: ${
|
|
1319
|
-
} : (await e.goTo(
|
|
1320
|
-
} catch (
|
|
1317
|
+
error: `No features found for filter (where: ${s.where}${a ? ", spatial filter used" : ""})`
|
|
1318
|
+
} : (await e.goTo(c), { success: !0 });
|
|
1319
|
+
} catch (c) {
|
|
1321
1320
|
return {
|
|
1322
1321
|
success: !1,
|
|
1323
|
-
error:
|
|
1322
|
+
error: c instanceof Error ? c.message : String(c)
|
|
1324
1323
|
};
|
|
1325
1324
|
}
|
|
1326
|
-
},
|
|
1327
|
-
const
|
|
1325
|
+
}, ra = async (e, t, r, a, o, n) => {
|
|
1326
|
+
const l = t.map?.allLayers.find(
|
|
1328
1327
|
(p) => p.id === e.layerId
|
|
1329
1328
|
);
|
|
1330
|
-
if (!
|
|
1329
|
+
if (!l)
|
|
1331
1330
|
return `Could not find target layer with ID: ${e.layerId}`;
|
|
1332
|
-
let
|
|
1333
|
-
if (
|
|
1334
|
-
const p = await
|
|
1331
|
+
let s;
|
|
1332
|
+
if (o) {
|
|
1333
|
+
const p = await H(o, t);
|
|
1335
1334
|
if ("error" in p)
|
|
1336
1335
|
return p.error;
|
|
1337
|
-
|
|
1336
|
+
s = p.geometry;
|
|
1338
1337
|
}
|
|
1339
|
-
if (
|
|
1340
|
-
filter: new
|
|
1338
|
+
if (l.featureEffect = null, l.featureEffect = new nt({
|
|
1339
|
+
filter: new Se({
|
|
1341
1340
|
...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
|
|
1342
|
-
geometry:
|
|
1341
|
+
geometry: s,
|
|
1343
1342
|
spatialRelationship: "intersects",
|
|
1344
|
-
distance:
|
|
1345
|
-
units:
|
|
1343
|
+
distance: o?.distance,
|
|
1344
|
+
units: o?.units
|
|
1346
1345
|
}),
|
|
1347
1346
|
includedEffect: r,
|
|
1348
|
-
excludedEffect:
|
|
1349
|
-
}),
|
|
1350
|
-
return `Applied feature effects to "${
|
|
1351
|
-
const
|
|
1347
|
+
excludedEffect: a
|
|
1348
|
+
}), l.visible = !0, n)
|
|
1349
|
+
return `Applied feature effects to "${l.title ?? e.layerId}" within current map extent.`;
|
|
1350
|
+
const c = e.objectIds?.length ? `${l.objectIdField} IN (${e.objectIds.join(",")})` : e.where, u = await ta(
|
|
1352
1351
|
t,
|
|
1353
1352
|
e.layerId,
|
|
1354
|
-
u,
|
|
1355
1353
|
c,
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1354
|
+
s,
|
|
1355
|
+
o?.distance,
|
|
1356
|
+
o?.units
|
|
1357
|
+
), d = l.title ?? e.layerId;
|
|
1358
|
+
return u.success ? `Applied feature effects to target layer "${l.title ?? e.layerId}"${o && "layerId" in o ? ` using geometry from layer "${o.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${u.error}`;
|
|
1359
|
+
}, aa = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], I = i.enum(aa), oa = async ({
|
|
1361
1360
|
targetLayer: e,
|
|
1362
1361
|
geometryFilter: t,
|
|
1363
1362
|
useCurrentExtent: r,
|
|
1364
|
-
includedEffect:
|
|
1365
|
-
excludedEffect:
|
|
1363
|
+
includedEffect: a = "drop-shadow(2px, 2px, 2px, gray)",
|
|
1364
|
+
excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
|
|
1366
1365
|
}, n) => {
|
|
1367
|
-
const { mapView:
|
|
1368
|
-
return await
|
|
1369
|
-
},
|
|
1366
|
+
const { mapView: l } = F(n);
|
|
1367
|
+
return await ra(e, l, a, o, t, r);
|
|
1368
|
+
}, na = i.object({
|
|
1370
1369
|
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1371
1370
|
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1372
1371
|
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
1373
1372
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1374
|
-
}),
|
|
1373
|
+
}), ia = i.object({
|
|
1375
1374
|
point: i.object({
|
|
1376
1375
|
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
1377
1376
|
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
@@ -1381,7 +1380,7 @@ const K = async (e, t) => {
|
|
|
1381
1380
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1382
1381
|
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
1383
1382
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1384
|
-
}),
|
|
1383
|
+
}), sa = i.object({
|
|
1385
1384
|
targetLayer: i.object({
|
|
1386
1385
|
layerId: i.string().describe("The layerId of the layer on which to set a feature effect."),
|
|
1387
1386
|
where: i.string().describe("The SQL-92 where clause representing the features to emphasize."),
|
|
@@ -1389,7 +1388,7 @@ const K = async (e, t) => {
|
|
|
1389
1388
|
"Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause."
|
|
1390
1389
|
)
|
|
1391
1390
|
}),
|
|
1392
|
-
geometryFilter: i.union([
|
|
1391
|
+
geometryFilter: i.union([na, ia]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
|
|
1393
1392
|
useCurrentExtent: i.boolean().optional().describe(
|
|
1394
1393
|
"Set to true when the previous query used the current map extent as a spatial filter. This ensures the feature effect applies only to features visible in the current view. Default is false."
|
|
1395
1394
|
),
|
|
@@ -1399,11 +1398,11 @@ const K = async (e, t) => {
|
|
|
1399
1398
|
excludedEffect: i.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
|
|
1400
1399
|
"The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."
|
|
1401
1400
|
)
|
|
1402
|
-
}),
|
|
1401
|
+
}), la = f(oa, {
|
|
1403
1402
|
name: "setFeatureEffect",
|
|
1404
1403
|
description: "Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",
|
|
1405
|
-
schema:
|
|
1406
|
-
}),
|
|
1404
|
+
schema: sa
|
|
1405
|
+
}), re = (e) => {
|
|
1407
1406
|
if (e instanceof Date)
|
|
1408
1407
|
return Number.isNaN(e.getTime()) ? null : e;
|
|
1409
1408
|
if (typeof e == "number" && Number.isFinite(e)) {
|
|
@@ -1411,44 +1410,44 @@ const K = async (e, t) => {
|
|
|
1411
1410
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
1412
1411
|
}
|
|
1413
1412
|
return null;
|
|
1414
|
-
},
|
|
1413
|
+
}, ca = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ua = (e) => {
|
|
1415
1414
|
if (typeof e == "string" && e)
|
|
1416
1415
|
return e;
|
|
1417
|
-
const t =
|
|
1416
|
+
const t = re(e);
|
|
1418
1417
|
return t ? t.toISOString().slice(0, 10) : null;
|
|
1419
|
-
},
|
|
1420
|
-
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"),
|
|
1421
|
-
return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset:
|
|
1422
|
-
},
|
|
1423
|
-
const
|
|
1424
|
-
if (
|
|
1425
|
-
const n =
|
|
1426
|
-
return n ?
|
|
1418
|
+
}, Bn = () => {
|
|
1419
|
+
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
|
|
1420
|
+
return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
|
|
1421
|
+
}, da = (e, t, r) => {
|
|
1422
|
+
const a = t?.toLowerCase();
|
|
1423
|
+
if (a === "date-only") {
|
|
1424
|
+
const n = ua(e);
|
|
1425
|
+
return n ? st(n, Q("short-date")) : e;
|
|
1427
1426
|
}
|
|
1428
|
-
if (
|
|
1427
|
+
if (a === "time-only") {
|
|
1429
1428
|
if (typeof e == "string" && e)
|
|
1430
|
-
return
|
|
1431
|
-
const n =
|
|
1432
|
-
return n ?
|
|
1433
|
-
...
|
|
1429
|
+
return lt(e, Q("long-time"));
|
|
1430
|
+
const n = re(e);
|
|
1431
|
+
return n ? fe(n, {
|
|
1432
|
+
...Q("long-time"),
|
|
1434
1433
|
timeZone: "UTC"
|
|
1435
1434
|
}) : e;
|
|
1436
1435
|
}
|
|
1437
|
-
const
|
|
1438
|
-
return
|
|
1439
|
-
...
|
|
1440
|
-
timeZone:
|
|
1436
|
+
const o = re(e);
|
|
1437
|
+
return o ? fe(o, {
|
|
1438
|
+
...Q("short-date-short-time"),
|
|
1439
|
+
timeZone: ca(r)
|
|
1441
1440
|
}) : e;
|
|
1442
|
-
},
|
|
1441
|
+
}, $e = (e, t, r) => {
|
|
1443
1442
|
if (e && typeof e != "function") {
|
|
1444
|
-
const
|
|
1445
|
-
if (
|
|
1446
|
-
const
|
|
1447
|
-
return
|
|
1443
|
+
const a = "getField" in r && r.getField?.(e), o = a && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(a.name) : null;
|
|
1444
|
+
if (o?.type === "coded-value") {
|
|
1445
|
+
const l = o.codedValues.find((s) => s.code === t);
|
|
1446
|
+
return l ? l.name : null;
|
|
1448
1447
|
}
|
|
1449
1448
|
}
|
|
1450
1449
|
return null;
|
|
1451
|
-
},
|
|
1450
|
+
}, pa = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ma = (e) => {
|
|
1452
1451
|
if (e instanceof Date)
|
|
1453
1452
|
return Number.isNaN(e.getTime()) ? null : e;
|
|
1454
1453
|
if (typeof e == "number" && Number.isFinite(e)) {
|
|
@@ -1460,7 +1459,7 @@ const K = async (e, t) => {
|
|
|
1460
1459
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
1461
1460
|
}
|
|
1462
1461
|
return null;
|
|
1463
|
-
},
|
|
1462
|
+
}, ha = (e, t) => {
|
|
1464
1463
|
if (typeof e != "number")
|
|
1465
1464
|
return e;
|
|
1466
1465
|
const r = {};
|
|
@@ -1470,184 +1469,184 @@ const K = async (e, t) => {
|
|
|
1470
1469
|
} catch {
|
|
1471
1470
|
return e;
|
|
1472
1471
|
}
|
|
1473
|
-
},
|
|
1474
|
-
const
|
|
1475
|
-
if (!
|
|
1472
|
+
}, ya = (e, t, r) => {
|
|
1473
|
+
const a = ma(e);
|
|
1474
|
+
if (!a)
|
|
1476
1475
|
return e;
|
|
1477
|
-
const
|
|
1478
|
-
t.dateStyle ?
|
|
1476
|
+
const o = {};
|
|
1477
|
+
t.dateStyle ? o.dateStyle = t.dateStyle : (t.year && (o.year = t.year), t.month && (o.month = t.month)), t.timeStyle && (o.timeStyle = t.timeStyle), t.timeStyle && t.hour12 === "always" ? o.hour12 = !0 : t.timeStyle && t.hour12 === "never" && (o.hour12 = !1), o.timeZone = pa(r);
|
|
1479
1478
|
try {
|
|
1480
|
-
return new Intl.DateTimeFormat(void 0,
|
|
1479
|
+
return new Intl.DateTimeFormat(void 0, o).format(a);
|
|
1481
1480
|
} catch {
|
|
1482
1481
|
return e;
|
|
1483
1482
|
}
|
|
1484
|
-
},
|
|
1483
|
+
}, Ce = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, Ee = (e, t, r, a, o) => {
|
|
1485
1484
|
if (r == null)
|
|
1486
1485
|
return r;
|
|
1487
|
-
const
|
|
1488
|
-
return
|
|
1489
|
-
},
|
|
1490
|
-
const
|
|
1491
|
-
return
|
|
1492
|
-
},
|
|
1493
|
-
const
|
|
1494
|
-
(
|
|
1495
|
-
), n = t.features.map((
|
|
1496
|
-
const
|
|
1497
|
-
return e.fields.forEach((
|
|
1498
|
-
if (!Object.hasOwn(
|
|
1486
|
+
const l = e.getFieldConfiguration?.(t)?.fieldFormat;
|
|
1487
|
+
return l?.type === "number" ? ha(r, l) : l?.type === "date-time" ? ya(r, l, o) : da(r, a, o);
|
|
1488
|
+
}, fa = (e, t, r, a) => {
|
|
1489
|
+
const o = e.fieldsIndex?.get(t), n = $e(t, r, e) ?? r;
|
|
1490
|
+
return Ee(e, t, n, o?.type, a);
|
|
1491
|
+
}, ga = (e, t) => Ce(e, t), Ne = (e, t, r) => {
|
|
1492
|
+
const a = e.objectIdField, o = t.features.map(
|
|
1493
|
+
(l) => l.attributes[a]
|
|
1494
|
+
), n = t.features.map((l) => {
|
|
1495
|
+
const s = l.attributes, c = {};
|
|
1496
|
+
return e.fields.forEach((u) => {
|
|
1497
|
+
if (!Object.hasOwn(s, u.name))
|
|
1499
1498
|
return;
|
|
1500
|
-
const d =
|
|
1501
|
-
if (
|
|
1502
|
-
u
|
|
1499
|
+
const d = s[u.name];
|
|
1500
|
+
if (u.name === a) {
|
|
1501
|
+
c[u.name] = d;
|
|
1503
1502
|
return;
|
|
1504
1503
|
}
|
|
1505
|
-
const p =
|
|
1506
|
-
|
|
1507
|
-
}),
|
|
1504
|
+
const p = $e(u.name, d, e) ?? d, m = Ce(e, u.name);
|
|
1505
|
+
c[m] = Ee(e, u.name, p, u.type, r);
|
|
1506
|
+
}), c;
|
|
1508
1507
|
});
|
|
1509
|
-
return { objectIds:
|
|
1510
|
-
},
|
|
1511
|
-
const
|
|
1512
|
-
return
|
|
1513
|
-
},
|
|
1514
|
-
const
|
|
1508
|
+
return { objectIds: o, attributes: n };
|
|
1509
|
+
}, wa = (e, t, r) => {
|
|
1510
|
+
const a = e.createQuery();
|
|
1511
|
+
return a.outFields = [t], a.where = r || "1=1", a.num = 1, a;
|
|
1512
|
+
}, ba = async (e, t, r, a) => {
|
|
1513
|
+
const o = a.map?.allLayers.find((m) => m.id === e), n = wa(o, t, r.where), s = (await o.queryFeatures(n)).features[0], c = s ? s.attributes[t] : null, u = fa(o, t, c, a.timeZone), d = ga(o, t);
|
|
1515
1514
|
return {
|
|
1516
1515
|
tool: "getAttribute",
|
|
1517
|
-
layerName:
|
|
1518
|
-
summary: `${d} = ${
|
|
1516
|
+
layerName: o.title ?? e,
|
|
1517
|
+
summary: `${d} = ${u}`,
|
|
1519
1518
|
details: {
|
|
1520
1519
|
fieldName: t,
|
|
1521
1520
|
fieldAlias: d !== t ? d : void 0,
|
|
1522
|
-
value:
|
|
1521
|
+
value: u,
|
|
1523
1522
|
where: r.where
|
|
1524
1523
|
}
|
|
1525
1524
|
};
|
|
1526
1525
|
};
|
|
1527
|
-
async function
|
|
1528
|
-
const { mapView:
|
|
1526
|
+
async function Ta({ layerId: e, fieldName: t, query: r }, a) {
|
|
1527
|
+
const { mapView: o } = F(a), n = await ba(e, t, r, o);
|
|
1529
1528
|
return JSON.stringify(n, null, 2);
|
|
1530
1529
|
}
|
|
1531
|
-
const
|
|
1530
|
+
const va = i.object({
|
|
1532
1531
|
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1533
1532
|
fieldName: i.string().describe("The name of the field/attribute from which to get a field value."),
|
|
1534
1533
|
query: i.object({
|
|
1535
1534
|
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1536
1535
|
})
|
|
1537
|
-
}),
|
|
1536
|
+
}), Sa = f(Ta, {
|
|
1538
1537
|
name: "getAttribute",
|
|
1539
1538
|
description: "Returns an attribute value for a given feature.",
|
|
1540
|
-
schema:
|
|
1541
|
-
}),
|
|
1542
|
-
function
|
|
1539
|
+
schema: va
|
|
1540
|
+
}), ce = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
|
|
1541
|
+
function K(e, t) {
|
|
1543
1542
|
let r = e ?? "";
|
|
1544
1543
|
return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
|
|
1545
1544
|
}
|
|
1546
|
-
const
|
|
1547
|
-
const { targetLayer: t, fieldName: r, statisticType:
|
|
1548
|
-
if (!
|
|
1545
|
+
const xa = async (e) => {
|
|
1546
|
+
const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: n, geometryFilter: l } = e, s = o.map?.allLayers.find((v) => v.id === t.layerId);
|
|
1547
|
+
if (!s)
|
|
1549
1548
|
throw new Error(`Layer '${t.layerId}' not found.`);
|
|
1550
|
-
const
|
|
1549
|
+
const c = await o.whenLayerView(s), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
|
|
1551
1550
|
if (!d)
|
|
1552
1551
|
throw new Error(`Field '${r}' not found.`);
|
|
1553
|
-
let
|
|
1554
|
-
if (
|
|
1555
|
-
const v = await
|
|
1552
|
+
let m, y;
|
|
1553
|
+
if (l) {
|
|
1554
|
+
const v = await H(l, o);
|
|
1556
1555
|
if ("error" in v)
|
|
1557
1556
|
throw new Error(v.error);
|
|
1558
1557
|
if (!v.geometry)
|
|
1559
|
-
throw
|
|
1560
|
-
if (
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
geometryLayerName:
|
|
1564
|
-
geometryLayerId:
|
|
1565
|
-
geometryWhere:
|
|
1566
|
-
distance:
|
|
1567
|
-
units:
|
|
1558
|
+
throw j(l) ? new Error(`No features found matching: ${l.where}`) : new Error("Failed to create geometry");
|
|
1559
|
+
if (j(l)) {
|
|
1560
|
+
const M = o.map?.allLayers.find((P) => P.id === l.layerId);
|
|
1561
|
+
m = {
|
|
1562
|
+
geometryLayerName: M?.title ?? M?.id,
|
|
1563
|
+
geometryLayerId: l.layerId,
|
|
1564
|
+
geometryWhere: l.where,
|
|
1565
|
+
distance: l.distance,
|
|
1566
|
+
units: l.units,
|
|
1568
1567
|
applied: !0
|
|
1569
1568
|
};
|
|
1570
|
-
} else
|
|
1571
|
-
point:
|
|
1572
|
-
distance:
|
|
1573
|
-
units:
|
|
1569
|
+
} else U(l) && (m = {
|
|
1570
|
+
point: l.point,
|
|
1571
|
+
distance: l.distance,
|
|
1572
|
+
units: l.units,
|
|
1574
1573
|
applied: !0
|
|
1575
1574
|
});
|
|
1576
|
-
|
|
1575
|
+
y = new Se({
|
|
1577
1576
|
geometry: v.geometry,
|
|
1578
|
-
distance:
|
|
1579
|
-
units:
|
|
1577
|
+
distance: l.distance,
|
|
1578
|
+
units: l.units,
|
|
1580
1579
|
spatialRelationship: "intersects"
|
|
1581
1580
|
});
|
|
1582
1581
|
}
|
|
1583
|
-
const
|
|
1584
|
-
let
|
|
1582
|
+
const g = ce(c, [r], !1);
|
|
1583
|
+
let h = null, w = null;
|
|
1585
1584
|
const T = 10;
|
|
1586
1585
|
if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
|
|
1587
1586
|
try {
|
|
1588
1587
|
const v = {
|
|
1589
|
-
layer:
|
|
1590
|
-
useFeaturesInView:
|
|
1591
|
-
view:
|
|
1588
|
+
layer: s,
|
|
1589
|
+
useFeaturesInView: g,
|
|
1590
|
+
view: g ? o : void 0,
|
|
1592
1591
|
field: r,
|
|
1593
|
-
sqlWhere:
|
|
1594
|
-
...
|
|
1595
|
-
outStatisticTypes: { include: [
|
|
1592
|
+
sqlWhere: K(s.definitionExpression, t.where),
|
|
1593
|
+
...y && { filter: y },
|
|
1594
|
+
outStatisticTypes: { include: [a] }
|
|
1596
1595
|
};
|
|
1597
|
-
|
|
1598
|
-
const
|
|
1599
|
-
(
|
|
1600
|
-
layer:
|
|
1601
|
-
useFeaturesInView:
|
|
1602
|
-
view:
|
|
1596
|
+
h = await ct(v);
|
|
1597
|
+
const M = ["string", "small-integer", "integer"], P = d.domain?.type === "coded-value" ? d.domain : null;
|
|
1598
|
+
(M.includes(d.type) || P) && (w = (await ut({
|
|
1599
|
+
layer: s,
|
|
1600
|
+
useFeaturesInView: g,
|
|
1601
|
+
view: g ? o : void 0,
|
|
1603
1602
|
field: r,
|
|
1604
|
-
sqlWhere:
|
|
1605
|
-
...
|
|
1606
|
-
})).uniqueValueInfos.sort((
|
|
1607
|
-
...
|
|
1608
|
-
value:
|
|
1603
|
+
sqlWhere: K(s.definitionExpression, t.where),
|
|
1604
|
+
...y && { filter: y }
|
|
1605
|
+
})).uniqueValueInfos.sort((z, ze) => ze.count - z.count).slice(0, T)), w && d.domain?.type === "coded-value" && (w = w.map((z) => ({
|
|
1606
|
+
...z,
|
|
1607
|
+
value: P ? P.getName(z.value) ?? z.value : z.value
|
|
1609
1608
|
})));
|
|
1610
1609
|
} catch (v) {
|
|
1611
1610
|
console.error("Statistics error:", v);
|
|
1612
1611
|
}
|
|
1613
1612
|
return {
|
|
1614
1613
|
tool: "getStatistics",
|
|
1615
|
-
layerName:
|
|
1616
|
-
summary: `${
|
|
1614
|
+
layerName: s.title ?? t.layerId,
|
|
1615
|
+
summary: `${a} = ${typeof h?.[a] == "number" ? h[a] : "N/A"}`,
|
|
1617
1616
|
details: {
|
|
1618
1617
|
fieldName: r,
|
|
1619
1618
|
fieldAlias: p,
|
|
1620
|
-
statisticType:
|
|
1621
|
-
statistic:
|
|
1622
|
-
summaryStatistics:
|
|
1623
|
-
uniqueValues:
|
|
1619
|
+
statisticType: a,
|
|
1620
|
+
statistic: h?.[a] ?? null,
|
|
1621
|
+
summaryStatistics: h,
|
|
1622
|
+
uniqueValues: w,
|
|
1624
1623
|
where: t.where,
|
|
1625
|
-
spatialFilterInfo:
|
|
1624
|
+
spatialFilterInfo: m
|
|
1626
1625
|
}
|
|
1627
1626
|
};
|
|
1628
1627
|
};
|
|
1629
|
-
async function
|
|
1628
|
+
async function Ra({
|
|
1630
1629
|
targetLayer: e,
|
|
1631
1630
|
fieldName: t,
|
|
1632
1631
|
statisticType: r,
|
|
1633
|
-
geometryFilter:
|
|
1634
|
-
},
|
|
1635
|
-
const n =
|
|
1632
|
+
geometryFilter: a
|
|
1633
|
+
}, o) {
|
|
1634
|
+
const n = Re(o, "layersAndFieldsRegistry"), { mapView: l } = F(o), s = await xa({
|
|
1636
1635
|
targetLayer: e,
|
|
1637
1636
|
fieldName: t,
|
|
1638
1637
|
statisticType: r,
|
|
1639
|
-
mapView:
|
|
1638
|
+
mapView: l,
|
|
1640
1639
|
layersAndFieldsRegistry: n,
|
|
1641
|
-
geometryFilter:
|
|
1640
|
+
geometryFilter: a
|
|
1642
1641
|
});
|
|
1643
|
-
return JSON.stringify(
|
|
1642
|
+
return JSON.stringify(s, null, 2);
|
|
1644
1643
|
}
|
|
1645
|
-
const
|
|
1644
|
+
const $a = i.object({
|
|
1646
1645
|
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1647
1646
|
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1648
1647
|
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
1649
1648
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1650
|
-
}),
|
|
1649
|
+
}), Ca = i.object({
|
|
1651
1650
|
point: i.object({
|
|
1652
1651
|
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
1653
1652
|
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
@@ -1657,17 +1656,17 @@ const Ro = i.object({
|
|
|
1657
1656
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1658
1657
|
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
1659
1658
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1660
|
-
}),
|
|
1659
|
+
}), Ea = i.object({
|
|
1661
1660
|
targetLayer: i.object({
|
|
1662
1661
|
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1663
1662
|
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1664
1663
|
}),
|
|
1665
|
-
geometryFilter: i.union([
|
|
1664
|
+
geometryFilter: i.union([$a, Ca]).optional().describe(
|
|
1666
1665
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
1667
1666
|
),
|
|
1668
1667
|
fieldName: i.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
|
|
1669
1668
|
statisticType: i.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
|
|
1670
|
-
}),
|
|
1669
|
+
}), Na = f(Ra, {
|
|
1671
1670
|
name: "getStatistics",
|
|
1672
1671
|
description: `Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
|
|
1673
1672
|
|
|
@@ -1682,96 +1681,96 @@ DO NOT USE FOR:
|
|
|
1682
1681
|
- Simple counts of features matching a condition — use queryFeatures instead
|
|
1683
1682
|
|
|
1684
1683
|
Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,
|
|
1685
|
-
schema:
|
|
1686
|
-
}),
|
|
1687
|
-
const n = r.map?.allLayers.find((
|
|
1688
|
-
let
|
|
1689
|
-
if (
|
|
1690
|
-
const
|
|
1691
|
-
if ("error" in
|
|
1684
|
+
schema: Ea
|
|
1685
|
+
}), Ia = async (e, t, r, a, o) => {
|
|
1686
|
+
const n = r.map?.allLayers.find((m) => m.id === e.layerId), l = await r.whenLayerView(n), s = n.title ?? e.layerId;
|
|
1687
|
+
let c;
|
|
1688
|
+
if (a) {
|
|
1689
|
+
const m = await H(a, r);
|
|
1690
|
+
if ("error" in m)
|
|
1692
1691
|
return {
|
|
1693
1692
|
tool: "getTopFeatures",
|
|
1694
|
-
layerName:
|
|
1693
|
+
layerName: s,
|
|
1695
1694
|
summary: "Geometry lookup failed",
|
|
1696
|
-
details: { error:
|
|
1695
|
+
details: { error: m.error }
|
|
1697
1696
|
};
|
|
1698
|
-
if (!
|
|
1697
|
+
if (!m.geometry)
|
|
1699
1698
|
return {
|
|
1700
1699
|
tool: "getTopFeatures",
|
|
1701
|
-
layerName:
|
|
1700
|
+
layerName: s,
|
|
1702
1701
|
summary: "No features found for geometry filter",
|
|
1703
1702
|
details: {
|
|
1704
|
-
error: `No features found matching: ${"where" in
|
|
1703
|
+
error: `No features found matching: ${"where" in a ? a.where : "unknown criteria"}`
|
|
1705
1704
|
}
|
|
1706
1705
|
};
|
|
1707
|
-
|
|
1708
|
-
} else
|
|
1709
|
-
const
|
|
1706
|
+
c = m.geometry;
|
|
1707
|
+
} else o && (c = r.extent.clone());
|
|
1708
|
+
const u = t.groupByFields && t.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
|
|
1710
1709
|
try {
|
|
1711
|
-
let
|
|
1712
|
-
if (
|
|
1713
|
-
const
|
|
1710
|
+
let m;
|
|
1711
|
+
if (u) {
|
|
1712
|
+
const h = new dt({
|
|
1714
1713
|
where: e.where || "1=1",
|
|
1715
1714
|
outFields: p,
|
|
1716
1715
|
orderByFields: e.orderByFields,
|
|
1717
|
-
geometry:
|
|
1718
|
-
spatialRelationship:
|
|
1719
|
-
distance:
|
|
1720
|
-
units:
|
|
1721
|
-
topFilter: new
|
|
1716
|
+
geometry: c,
|
|
1717
|
+
spatialRelationship: c ? "intersects" : void 0,
|
|
1718
|
+
distance: a?.distance,
|
|
1719
|
+
units: a?.units,
|
|
1720
|
+
topFilter: new pt({
|
|
1722
1721
|
topCount: t.topCount,
|
|
1723
1722
|
groupByFields: t.groupByFields,
|
|
1724
1723
|
orderByFields: t.orderByFields
|
|
1725
1724
|
})
|
|
1726
1725
|
});
|
|
1727
|
-
|
|
1726
|
+
m = await n.queryTopFeatures(h);
|
|
1728
1727
|
} else {
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
const
|
|
1728
|
+
const h = n.createQuery();
|
|
1729
|
+
h.where = K(n.definitionExpression, e.where || "1=1"), h.outFields = p.length ? p : ["*"], h.orderByFields = t.orderByFields, h.num = t.topCount, c && (h.geometry = c, h.spatialRelationship = "intersects"), a?.distance && (h.distance = a.distance), a?.units && (h.units = a.units), h.outSpatialReference = r.spatialReference;
|
|
1730
|
+
const w = ce(l, e.outFields, o ?? !1);
|
|
1732
1731
|
try {
|
|
1733
|
-
|
|
1732
|
+
m = w ? await l.queryFeatures(h) : await n.queryFeatures(h);
|
|
1734
1733
|
} catch (T) {
|
|
1735
|
-
console.warn("Client-side query failed, falling back to server:", T),
|
|
1734
|
+
console.warn("Client-side query failed, falling back to server:", T), m = await n.queryFeatures(h);
|
|
1736
1735
|
}
|
|
1737
1736
|
}
|
|
1738
|
-
const
|
|
1737
|
+
const y = m.features.map((h) => h.attributes[d]), { attributes: g } = Ne(n, m, r.timeZone);
|
|
1739
1738
|
return {
|
|
1740
1739
|
tool: "getTopFeatures",
|
|
1741
|
-
layerName:
|
|
1740
|
+
layerName: s,
|
|
1742
1741
|
summary: `Top ${t.topCount} features extracted`,
|
|
1743
1742
|
details: {
|
|
1744
1743
|
topCount: t.topCount,
|
|
1745
|
-
attributes:
|
|
1746
|
-
objectIds:
|
|
1744
|
+
attributes: g,
|
|
1745
|
+
objectIds: y,
|
|
1747
1746
|
objectIdField: d,
|
|
1748
1747
|
where: e.where,
|
|
1749
1748
|
orderByFields: t.orderByFields,
|
|
1750
|
-
...
|
|
1749
|
+
...u && { groupByFields: t.groupByFields }
|
|
1751
1750
|
}
|
|
1752
1751
|
};
|
|
1753
|
-
} catch (
|
|
1752
|
+
} catch (m) {
|
|
1754
1753
|
return {
|
|
1755
1754
|
tool: "getTopFeatures",
|
|
1756
|
-
layerName:
|
|
1755
|
+
layerName: s,
|
|
1757
1756
|
summary: "Query failed",
|
|
1758
|
-
details: { error:
|
|
1757
|
+
details: { error: m instanceof Error ? m.message : String(m) }
|
|
1759
1758
|
};
|
|
1760
1759
|
}
|
|
1761
|
-
},
|
|
1760
|
+
}, ka = async ({
|
|
1762
1761
|
targetLayer: e,
|
|
1763
1762
|
topFilter: t,
|
|
1764
1763
|
geometryFilter: r,
|
|
1765
|
-
useCurrentExtent:
|
|
1766
|
-
},
|
|
1767
|
-
const { mapView: n } =
|
|
1768
|
-
return JSON.stringify(
|
|
1769
|
-
},
|
|
1764
|
+
useCurrentExtent: a
|
|
1765
|
+
}, o) => {
|
|
1766
|
+
const { mapView: n } = F(o), l = await Ia(e, t, n, r, a);
|
|
1767
|
+
return JSON.stringify(l, null, 2);
|
|
1768
|
+
}, Fa = i.object({
|
|
1770
1769
|
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1771
1770
|
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1772
1771
|
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
1773
1772
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1774
|
-
}),
|
|
1773
|
+
}), za = i.object({
|
|
1775
1774
|
point: i.object({
|
|
1776
1775
|
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
1777
1776
|
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
@@ -1781,7 +1780,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1781
1780
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1782
1781
|
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
1783
1782
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1784
|
-
}),
|
|
1783
|
+
}), qa = i.object({
|
|
1785
1784
|
targetLayer: i.object({
|
|
1786
1785
|
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1787
1786
|
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
|
|
@@ -1792,7 +1791,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1792
1791
|
).default("*")
|
|
1793
1792
|
)
|
|
1794
1793
|
}),
|
|
1795
|
-
geometryFilter: i.union([
|
|
1794
|
+
geometryFilter: i.union([Fa, za]).optional().describe(
|
|
1796
1795
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
1797
1796
|
),
|
|
1798
1797
|
topFilter: i.object({
|
|
@@ -1805,83 +1804,83 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1805
1804
|
useCurrentExtent: i.boolean().optional().describe(
|
|
1806
1805
|
"Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer)."
|
|
1807
1806
|
)
|
|
1808
|
-
}),
|
|
1807
|
+
}), Da = f(ka, {
|
|
1809
1808
|
name: "getTopFeatures",
|
|
1810
1809
|
description: 'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',
|
|
1811
|
-
schema:
|
|
1812
|
-
}),
|
|
1813
|
-
const
|
|
1814
|
-
let
|
|
1810
|
+
schema: qa
|
|
1811
|
+
}), ee = 25, Aa = async (e, t, r, a) => {
|
|
1812
|
+
const o = t.map?.allLayers.find((h) => h.id === e.layerId), n = await t.whenLayerView(o), l = o.title ?? e.layerId;
|
|
1813
|
+
let s;
|
|
1815
1814
|
if (r) {
|
|
1816
|
-
const
|
|
1817
|
-
if ("error" in
|
|
1818
|
-
const
|
|
1819
|
-
if (
|
|
1820
|
-
const T = t.map?.allLayers.find((
|
|
1821
|
-
|
|
1822
|
-
} else
|
|
1815
|
+
const h = await H(r, t);
|
|
1816
|
+
if ("error" in h) {
|
|
1817
|
+
const w = { error: h.error };
|
|
1818
|
+
if (j(r)) {
|
|
1819
|
+
const T = t.map?.allLayers.find((C) => C.id === r.layerId);
|
|
1820
|
+
w.geometryLayerName = T?.title ?? T?.id, w.geometryLayerId = r.layerId, w.geometryWhere = r.where;
|
|
1821
|
+
} else U(r) && (w.point = r.point);
|
|
1823
1822
|
return {
|
|
1824
1823
|
tool: "queryFeatures",
|
|
1825
|
-
layerName:
|
|
1824
|
+
layerName: l,
|
|
1826
1825
|
summary: "Geometry lookup failed",
|
|
1827
|
-
details:
|
|
1826
|
+
details: w
|
|
1828
1827
|
};
|
|
1829
1828
|
}
|
|
1830
|
-
if (!
|
|
1831
|
-
const
|
|
1832
|
-
if (
|
|
1833
|
-
const T = t.map?.allLayers.find((
|
|
1834
|
-
|
|
1835
|
-
} else
|
|
1829
|
+
if (!h.geometry) {
|
|
1830
|
+
const w = {};
|
|
1831
|
+
if (j(r)) {
|
|
1832
|
+
const T = t.map?.allLayers.find((C) => C.id === r.layerId);
|
|
1833
|
+
w.error = `No features found matching: ${r.where}`, w.geometryLayerName = T?.title ?? T?.id, w.geometryLayerId = r.layerId, w.geometryWhere = r.where;
|
|
1834
|
+
} else U(r) && (w.error = "Failed to create point geometry", w.point = r.point);
|
|
1836
1835
|
return {
|
|
1837
1836
|
tool: "queryFeatures",
|
|
1838
|
-
layerName:
|
|
1837
|
+
layerName: l,
|
|
1839
1838
|
summary: "No features found for geometry filter",
|
|
1840
|
-
details:
|
|
1839
|
+
details: w
|
|
1841
1840
|
};
|
|
1842
1841
|
}
|
|
1843
|
-
|
|
1844
|
-
} else
|
|
1845
|
-
const
|
|
1846
|
-
d.where =
|
|
1847
|
-
let p,
|
|
1842
|
+
s = h.geometry;
|
|
1843
|
+
} else a && (s = t.extent.clone());
|
|
1844
|
+
const c = ce(n, e.outFields, a ?? !1), u = o.objectIdField, d = o.createQuery();
|
|
1845
|
+
d.where = K(o.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, u])], d.orderByFields = e.orderByFields, s && (d.geometry = s, d.spatialRelationship = "intersects"), r?.distance && (d.distance = r.distance), r?.units && (d.units = r.units), d.outSpatialReference = t.spatialReference;
|
|
1846
|
+
let p, m;
|
|
1848
1847
|
try {
|
|
1849
|
-
p =
|
|
1850
|
-
} catch (
|
|
1851
|
-
console.warn("Client-side query failed, falling back to server:",
|
|
1848
|
+
p = c ? await n.queryFeatureCount(d) : await o.queryFeatureCount(d), p > 0 && p <= ee && (m = c ? await n.queryFeatures(d) : await o.queryFeatures(d));
|
|
1849
|
+
} catch (h) {
|
|
1850
|
+
console.warn("Client-side query failed, falling back to server:", h), p = await o.queryFeatureCount(d), p > 0 && p <= ee && (m = await o.queryFeatures(d));
|
|
1852
1851
|
}
|
|
1853
|
-
const { objectIds:
|
|
1852
|
+
const { objectIds: y, attributes: g } = m ? Ne(o, m, t.timeZone) : { objectIds: void 0, attributes: void 0 };
|
|
1854
1853
|
return {
|
|
1855
1854
|
tool: "queryFeatures",
|
|
1856
|
-
layerName:
|
|
1855
|
+
layerName: l,
|
|
1857
1856
|
summary: `${p} features found`,
|
|
1858
1857
|
details: {
|
|
1859
1858
|
totalCount: p,
|
|
1860
1859
|
where: e.where,
|
|
1861
1860
|
orderByFields: e.orderByFields,
|
|
1862
1861
|
outFields: e.outFields,
|
|
1863
|
-
...
|
|
1864
|
-
...
|
|
1865
|
-
...p >
|
|
1862
|
+
...y && { objectIds: y, objectIdField: u },
|
|
1863
|
+
...g && { attributes: g },
|
|
1864
|
+
...p > ee && {
|
|
1866
1865
|
note: `${p} features found.`
|
|
1867
1866
|
}
|
|
1868
1867
|
}
|
|
1869
1868
|
};
|
|
1870
1869
|
};
|
|
1871
|
-
async function
|
|
1870
|
+
async function Pa({
|
|
1872
1871
|
targetLayer: e,
|
|
1873
1872
|
geometryFilter: t,
|
|
1874
1873
|
useCurrentExtent: r
|
|
1875
|
-
},
|
|
1876
|
-
const { mapView:
|
|
1874
|
+
}, a) {
|
|
1875
|
+
const { mapView: o } = F(a), n = await Aa(e, o, t, r);
|
|
1877
1876
|
return JSON.stringify(n, null, 2);
|
|
1878
1877
|
}
|
|
1879
|
-
const
|
|
1878
|
+
const La = i.object({
|
|
1880
1879
|
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1881
1880
|
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1882
1881
|
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
1883
1882
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1884
|
-
}),
|
|
1883
|
+
}), ja = i.object({
|
|
1885
1884
|
point: i.object({
|
|
1886
1885
|
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
1887
1886
|
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
@@ -1891,7 +1890,7 @@ const Lo = i.object({
|
|
|
1891
1890
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1892
1891
|
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
1893
1892
|
units: I.optional().describe("The units for the distance buffer.")
|
|
1894
|
-
}),
|
|
1893
|
+
}), Ga = i.object({
|
|
1895
1894
|
targetLayer: i.object({
|
|
1896
1895
|
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1897
1896
|
where: i.string().describe(
|
|
@@ -1904,13 +1903,13 @@ const Lo = i.object({
|
|
|
1904
1903
|
).default("*")
|
|
1905
1904
|
)
|
|
1906
1905
|
}),
|
|
1907
|
-
geometryFilter: i.union([
|
|
1906
|
+
geometryFilter: i.union([La, ja]).optional().describe(
|
|
1908
1907
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
1909
1908
|
),
|
|
1910
1909
|
useCurrentExtent: i.boolean().optional().describe(
|
|
1911
1910
|
"Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer)."
|
|
1912
1911
|
)
|
|
1913
|
-
}),
|
|
1912
|
+
}), Oa = f(Pa, {
|
|
1914
1913
|
name: "queryFeatures",
|
|
1915
1914
|
description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
|
|
1916
1915
|
|
|
@@ -1922,49 +1921,47 @@ USE THIS TOOL FOR:
|
|
|
1922
1921
|
- Any question where the user wants to SEE or COUNT matching features
|
|
1923
1922
|
|
|
1924
1923
|
This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
1925
|
-
schema:
|
|
1926
|
-
}),
|
|
1927
|
-
async function
|
|
1928
|
-
const { messages: r } = await
|
|
1924
|
+
schema: Ga
|
|
1925
|
+
}), Ma = [Sa, Na, Da, Oa], Hn = [la, ea, Zr], Qa = new ot(Ma, { handleToolErrors: !1 });
|
|
1926
|
+
async function Jn(e, t) {
|
|
1927
|
+
const { messages: r } = await Qa.invoke({ messages: e.dataExplorationMessages }, t), a = [], o = [];
|
|
1929
1928
|
for (const n of r) {
|
|
1930
|
-
const
|
|
1931
|
-
let
|
|
1932
|
-
typeof
|
|
1929
|
+
const l = n.content;
|
|
1930
|
+
let s;
|
|
1931
|
+
typeof l != "string" && (s = {
|
|
1933
1932
|
tool: n.name ?? "unknown",
|
|
1934
1933
|
layerName: "unknown",
|
|
1935
1934
|
summary: "Query failed",
|
|
1936
|
-
details: { error: "Skipping non-string tool output:", raw:
|
|
1935
|
+
details: { error: "Skipping non-string tool output:", raw: l }
|
|
1937
1936
|
});
|
|
1938
1937
|
try {
|
|
1939
|
-
typeof
|
|
1938
|
+
typeof l == "string" ? s = JSON.parse(l) : s = {
|
|
1940
1939
|
tool: n.name ?? "unknown",
|
|
1941
1940
|
layerName: "unknown",
|
|
1942
1941
|
summary: "Query failed",
|
|
1943
|
-
details: { error: "Invalid tool output type", raw:
|
|
1942
|
+
details: { error: "Invalid tool output type", raw: l }
|
|
1944
1943
|
};
|
|
1945
1944
|
} catch {
|
|
1946
|
-
|
|
1945
|
+
s = {
|
|
1947
1946
|
tool: n.name ?? "unknown",
|
|
1948
1947
|
layerName: "unknown",
|
|
1949
1948
|
summary: "Query failed",
|
|
1950
|
-
details: { error:
|
|
1949
|
+
details: { error: l }
|
|
1951
1950
|
};
|
|
1952
1951
|
}
|
|
1953
|
-
|
|
1952
|
+
a.push(s), s.details && typeof s.details == "object" && "error" in s.details ? o.push(`- ${s.tool}: Error - ${String(s.details.error)}`) : o.push(`- ${s.layerName}: ${s.summary}`);
|
|
1954
1953
|
}
|
|
1955
|
-
return await S({ text: `Finished executing layer query tool: ${
|
|
1954
|
+
return await S({ text: `Finished executing layer query tool: ${o.join(", ")}` }, t), {
|
|
1956
1955
|
...e,
|
|
1957
1956
|
dataExplorationMessages: [...e.dataExplorationMessages, ...r],
|
|
1958
|
-
queryResponse:
|
|
1957
|
+
queryResponse: a,
|
|
1959
1958
|
status: "success",
|
|
1960
|
-
|
|
1961
|
-
`),
|
|
1962
|
-
summary: a.length > 0 ? _t(a.join(`
|
|
1959
|
+
summary: o.length > 0 ? Vt(o.join(`
|
|
1963
1960
|
`)) : "Query executed."
|
|
1964
1961
|
};
|
|
1965
1962
|
}
|
|
1966
|
-
const
|
|
1967
|
-
...
|
|
1963
|
+
const Zn = b.Root({
|
|
1964
|
+
...B(),
|
|
1968
1965
|
// internal to the help agent
|
|
1969
1966
|
helpInternalState: b({
|
|
1970
1967
|
reducer: L,
|
|
@@ -1972,100 +1969,100 @@ const Kn = b.Root({
|
|
|
1972
1969
|
toolCallMessage: void 0
|
|
1973
1970
|
})
|
|
1974
1971
|
})
|
|
1975
|
-
}),
|
|
1972
|
+
}), _a = (e, t) => {
|
|
1976
1973
|
const r = Array.from(e.values()).find(
|
|
1977
1974
|
({ layerItem: n }) => n.title?.toLowerCase().includes(t.toLowerCase())
|
|
1978
1975
|
);
|
|
1979
1976
|
if (!r) {
|
|
1980
|
-
const n = Array.from(e.values()).map((
|
|
1977
|
+
const n = Array.from(e.values()).map((l) => l.layerItem.title).join(", ");
|
|
1981
1978
|
return `Could not find a layer matching "${t}". Available layers: ${n}`;
|
|
1982
1979
|
}
|
|
1983
|
-
const
|
|
1980
|
+
const a = Array.from(r.fieldRegistry.values()), o = a.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
|
|
1984
1981
|
`);
|
|
1985
|
-
return `**${r.layerItem.title}** has ${
|
|
1982
|
+
return `**${r.layerItem.title}** has ${a.length} field(s):
|
|
1986
1983
|
|
|
1987
|
-
${
|
|
1988
|
-
},
|
|
1989
|
-
const r =
|
|
1990
|
-
return
|
|
1991
|
-
},
|
|
1984
|
+
${o}`;
|
|
1985
|
+
}, Wa = async ({ layerTitle: e }, t) => {
|
|
1986
|
+
const r = Re(t, "layersAndFieldsRegistry");
|
|
1987
|
+
return _a(r, e);
|
|
1988
|
+
}, Yn = f(Wa, {
|
|
1992
1989
|
name: "listLayerFields",
|
|
1993
1990
|
description: "Lists all fields for a given layer by title. Use ONLY when the user explicitly asks to see fields, columns, or attributes of a specific named layer. Do NOT call this tool for general help questions, capability overviews, or layer listing.",
|
|
1994
1991
|
schema: i.object({
|
|
1995
1992
|
layerTitle: i.string().describe("The title or partial title of the layer to list fields for.")
|
|
1996
1993
|
})
|
|
1997
|
-
}),
|
|
1998
|
-
...
|
|
1994
|
+
}), Xn = b.Root({
|
|
1995
|
+
...B(),
|
|
1999
1996
|
intent: b({
|
|
2000
1997
|
reducer: (e, t) => t
|
|
2001
1998
|
}),
|
|
2002
1999
|
arcgisKnowledgeMessages: b({
|
|
2003
|
-
reducer:
|
|
2000
|
+
reducer: Te,
|
|
2004
2001
|
default: () => []
|
|
2005
2002
|
}),
|
|
2006
2003
|
arcgisKnowledgeToolResult: b({
|
|
2007
2004
|
reducer: (e, t) => t,
|
|
2008
2005
|
default: () => null
|
|
2009
2006
|
})
|
|
2010
|
-
}),
|
|
2007
|
+
}), _ = {
|
|
2011
2008
|
conversationId: ""
|
|
2012
2009
|
};
|
|
2013
|
-
function
|
|
2010
|
+
function ue(e) {
|
|
2014
2011
|
const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
|
|
2015
2012
|
if (!t || t?.length !== 1)
|
|
2016
2013
|
throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
|
|
2017
2014
|
}
|
|
2018
|
-
function
|
|
2015
|
+
function N(e) {
|
|
2019
2016
|
return !!e?.map && !("activeLinkChartLayer" in e.map);
|
|
2020
2017
|
}
|
|
2021
|
-
async function
|
|
2022
|
-
!e ||
|
|
2018
|
+
async function J(e) {
|
|
2019
|
+
!e || N(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
|
|
2023
2020
|
}
|
|
2024
|
-
function
|
|
2021
|
+
function Z(e) {
|
|
2025
2022
|
const r = e?.configurable?.context;
|
|
2026
2023
|
if (!r || typeof r != "object")
|
|
2027
2024
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2028
2025
|
if (!("view" in r))
|
|
2029
2026
|
throw new Error("View context missing");
|
|
2030
|
-
const
|
|
2031
|
-
return
|
|
2032
|
-
view:
|
|
2027
|
+
const a = r.view;
|
|
2028
|
+
return a.map && !("activeLinkChartLayer" in a.map) && ue(a), {
|
|
2029
|
+
view: a
|
|
2033
2030
|
};
|
|
2034
2031
|
}
|
|
2035
|
-
function
|
|
2032
|
+
function ei(e) {
|
|
2036
2033
|
const r = e?.configurable?.context;
|
|
2037
|
-
if (
|
|
2034
|
+
if (Ie(e) === "knowledgeGraph")
|
|
2038
2035
|
return "knowledgeGraph";
|
|
2039
|
-
const
|
|
2040
|
-
return
|
|
2036
|
+
const o = r.view;
|
|
2037
|
+
return N(o) ? (ue(o), "map") : "linkChart";
|
|
2041
2038
|
}
|
|
2042
|
-
async function
|
|
2039
|
+
async function O(e) {
|
|
2043
2040
|
const r = e?.configurable?.context;
|
|
2044
|
-
if (
|
|
2041
|
+
if (Ie(e) === "knowledgeGraph")
|
|
2045
2042
|
return r;
|
|
2046
2043
|
{
|
|
2047
|
-
const
|
|
2048
|
-
if (
|
|
2049
|
-
const n =
|
|
2044
|
+
const o = r.view.map;
|
|
2045
|
+
if (o && "activeLinkChartLayer" in o) {
|
|
2046
|
+
const n = o.knowledgeGraph?.url;
|
|
2050
2047
|
if (!n)
|
|
2051
2048
|
throw new Error("Knowledge graph url missing from link chart.");
|
|
2052
2049
|
return {
|
|
2053
|
-
knowledgeGraph: await
|
|
2050
|
+
knowledgeGraph: await ge(n)
|
|
2054
2051
|
};
|
|
2055
2052
|
} else {
|
|
2056
|
-
|
|
2057
|
-
const
|
|
2058
|
-
(
|
|
2053
|
+
ue(r.view);
|
|
2054
|
+
const l = (r.view.map?.allLayers.find(
|
|
2055
|
+
(c) => c.type === "knowledge-graph"
|
|
2059
2056
|
)).url;
|
|
2060
|
-
if (!
|
|
2057
|
+
if (!l)
|
|
2061
2058
|
throw new Error("Knowledge graph url missing from map.");
|
|
2062
2059
|
return {
|
|
2063
|
-
knowledgeGraph: await
|
|
2060
|
+
knowledgeGraph: await ge(l)
|
|
2064
2061
|
};
|
|
2065
2062
|
}
|
|
2066
2063
|
}
|
|
2067
2064
|
}
|
|
2068
|
-
function
|
|
2065
|
+
function Ie(e) {
|
|
2069
2066
|
const r = e?.configurable?.context;
|
|
2070
2067
|
if (!r || typeof r != "object")
|
|
2071
2068
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
@@ -2077,12 +2074,12 @@ function xe(e) {
|
|
|
2077
2074
|
return "view";
|
|
2078
2075
|
throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
|
|
2079
2076
|
}
|
|
2080
|
-
class
|
|
2077
|
+
class Va {
|
|
2081
2078
|
constructor(t) {
|
|
2082
|
-
this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation =
|
|
2079
|
+
this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = de.fromDataModel(t);
|
|
2083
2080
|
}
|
|
2084
2081
|
}
|
|
2085
|
-
class
|
|
2082
|
+
class de {
|
|
2086
2083
|
constructor() {
|
|
2087
2084
|
this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
|
|
2088
2085
|
mappingInfo: {
|
|
@@ -2092,14 +2089,14 @@ class ne {
|
|
|
2092
2089
|
};
|
|
2093
2090
|
}
|
|
2094
2091
|
static fromDataModel(t) {
|
|
2095
|
-
const r = new
|
|
2096
|
-
for (const
|
|
2097
|
-
r.entityTypes.push(
|
|
2098
|
-
for (const
|
|
2099
|
-
r.relationshipTypes.push(
|
|
2092
|
+
const r = new de();
|
|
2093
|
+
for (const a of t.entityTypes)
|
|
2094
|
+
r.entityTypes.push(G.fromEntityType(a));
|
|
2095
|
+
for (const a of t.relationshipTypes)
|
|
2096
|
+
r.relationshipTypes.push(Ua.fromRelationshipType(a));
|
|
2100
2097
|
return r.identifierInfo = {
|
|
2101
2098
|
mappingInfo: {
|
|
2102
|
-
identifierMapsTo:
|
|
2099
|
+
identifierMapsTo: Ka(
|
|
2103
2100
|
t.identifierInfo.identifierMappingInfo.identifierInfoType
|
|
2104
2101
|
),
|
|
2105
2102
|
identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
|
|
@@ -2108,51 +2105,51 @@ class ne {
|
|
|
2108
2105
|
}
|
|
2109
2106
|
// Generates a short summary of the types in the data model for LLM consumption.
|
|
2110
2107
|
static getDataModelTypesSummary(t) {
|
|
2111
|
-
const r = t.entityTypes.map((
|
|
2108
|
+
const r = t.entityTypes.map((o) => o.name).join(", "), a = t.relationshipTypes.map((o) => o.name).join(", ");
|
|
2112
2109
|
return `Entity Types: ${r}.
|
|
2113
|
-
Relationship Types: ${
|
|
2110
|
+
Relationship Types: ${a}.`;
|
|
2114
2111
|
}
|
|
2115
2112
|
}
|
|
2116
|
-
class
|
|
2113
|
+
class G {
|
|
2117
2114
|
constructor() {
|
|
2118
2115
|
this.name = "", this.properties = [];
|
|
2119
2116
|
}
|
|
2120
2117
|
static fromEntityType(t) {
|
|
2121
|
-
const r = new
|
|
2122
|
-
r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role =
|
|
2123
|
-
for (const
|
|
2124
|
-
const
|
|
2125
|
-
name:
|
|
2126
|
-
alias:
|
|
2127
|
-
fieldType:
|
|
2128
|
-
role:
|
|
2129
|
-
geometryDef:
|
|
2130
|
-
geometryType:
|
|
2131
|
-
hasM:
|
|
2132
|
-
hasZ:
|
|
2118
|
+
const r = new G();
|
|
2119
|
+
r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Ba(t.role);
|
|
2120
|
+
for (const a of t.properties) {
|
|
2121
|
+
const o = {
|
|
2122
|
+
name: a.name,
|
|
2123
|
+
alias: a.alias ? a.alias : void 0,
|
|
2124
|
+
fieldType: a.fieldType,
|
|
2125
|
+
role: Ha(a.role),
|
|
2126
|
+
geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
|
|
2127
|
+
geometryType: a.geometryType ?? "esriGeometryAny",
|
|
2128
|
+
hasM: a.hasM ? a.hasM : void 0,
|
|
2129
|
+
hasZ: a.hasZ ? a.hasZ : void 0
|
|
2133
2130
|
} : void 0
|
|
2134
2131
|
};
|
|
2135
|
-
r.properties.push(
|
|
2132
|
+
r.properties.push(o);
|
|
2136
2133
|
}
|
|
2137
2134
|
return r;
|
|
2138
2135
|
}
|
|
2139
2136
|
}
|
|
2140
|
-
class
|
|
2137
|
+
class Ua extends G {
|
|
2141
2138
|
constructor() {
|
|
2142
2139
|
super(...arguments), this.observedEndPoints = [];
|
|
2143
2140
|
}
|
|
2144
2141
|
static fromRelationshipType(t) {
|
|
2145
|
-
const r =
|
|
2142
|
+
const r = G.fromEntityType(t);
|
|
2146
2143
|
r.observedEndPoints = [];
|
|
2147
|
-
for (const
|
|
2144
|
+
for (const a of t.endPoints)
|
|
2148
2145
|
r.observedEndPoints.push({
|
|
2149
|
-
originEntityType:
|
|
2150
|
-
destinationEntityType:
|
|
2146
|
+
originEntityType: a.originEntityType,
|
|
2147
|
+
destinationEntityType: a.destinationEntityType
|
|
2151
2148
|
});
|
|
2152
2149
|
return r;
|
|
2153
2150
|
}
|
|
2154
2151
|
}
|
|
2155
|
-
const
|
|
2152
|
+
const Ka = (e) => {
|
|
2156
2153
|
switch (e) {
|
|
2157
2154
|
case "esriIdentifierInfoTypeUNSPECIFIED":
|
|
2158
2155
|
return "UNSPECIFIED";
|
|
@@ -2163,7 +2160,7 @@ const Uo = (e) => {
|
|
|
2163
2160
|
default:
|
|
2164
2161
|
return e;
|
|
2165
2162
|
}
|
|
2166
|
-
},
|
|
2163
|
+
}, Ba = (e) => {
|
|
2167
2164
|
switch (e) {
|
|
2168
2165
|
case "Regular":
|
|
2169
2166
|
return "esriGraphNamedObjectRegular";
|
|
@@ -2175,7 +2172,7 @@ const Uo = (e) => {
|
|
|
2175
2172
|
return e;
|
|
2176
2173
|
}
|
|
2177
2174
|
};
|
|
2178
|
-
function
|
|
2175
|
+
function Ha(e) {
|
|
2179
2176
|
switch (e) {
|
|
2180
2177
|
case "esriGraphPropertyRegular":
|
|
2181
2178
|
return "Regular";
|
|
@@ -2213,7 +2210,10 @@ function Bo(e) {
|
|
|
2213
2210
|
return "Regular";
|
|
2214
2211
|
}
|
|
2215
2212
|
}
|
|
2216
|
-
function
|
|
2213
|
+
function Y(e) {
|
|
2214
|
+
return e?.signal;
|
|
2215
|
+
}
|
|
2216
|
+
function Ja(e, t) {
|
|
2217
2217
|
return t ? `${e}
|
|
2218
2218
|
|
|
2219
2219
|
Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
|
|
@@ -2223,249 +2223,257 @@ Execution Error: ${t.executionError}
|
|
|
2223
2223
|
Failed Query:
|
|
2224
2224
|
${t.failedGraphQuery}` : e;
|
|
2225
2225
|
}
|
|
2226
|
-
async function
|
|
2227
|
-
const { graphQuery:
|
|
2228
|
-
return
|
|
2229
|
-
${a}
|
|
2230
|
-
|
|
2231
|
-
Explanation: ${n}`;
|
|
2226
|
+
async function Za(e, t, r, a) {
|
|
2227
|
+
const { graphQuery: o, explanation: n } = await pe(e, t, r, a);
|
|
2228
|
+
return { graphQuery: o, explanation: n };
|
|
2232
2229
|
}
|
|
2233
|
-
async function
|
|
2230
|
+
async function pe(e, t, r, a, o) {
|
|
2234
2231
|
const n = {
|
|
2235
|
-
message:
|
|
2236
|
-
context: new
|
|
2232
|
+
message: Ja(e, o),
|
|
2233
|
+
context: new Va(t)
|
|
2237
2234
|
};
|
|
2238
|
-
|
|
2239
|
-
const
|
|
2235
|
+
_.conversationId && (n.conversationId = _.conversationId);
|
|
2236
|
+
const l = Y(a);
|
|
2237
|
+
await S({ text: "Attempting to generate a cypher query from your prompt..." }, a);
|
|
2238
|
+
const s = await he(`${r}/chat`, {
|
|
2240
2239
|
method: "post",
|
|
2241
2240
|
body: JSON.stringify(n),
|
|
2242
2241
|
headers: {
|
|
2243
2242
|
"Content-Type": "application/json",
|
|
2244
|
-
token:
|
|
2245
|
-
}
|
|
2243
|
+
token: me.findCredential(k.getDefault().url)?.token ?? ""
|
|
2244
|
+
},
|
|
2245
|
+
signal: l
|
|
2246
2246
|
});
|
|
2247
2247
|
if (s.httpStatus !== 200)
|
|
2248
2248
|
throw new Error(`Graph query service returned an error: ${s.httpStatus}`, {
|
|
2249
2249
|
cause: s.data
|
|
2250
2250
|
});
|
|
2251
|
-
|
|
2251
|
+
_.conversationId || (_.conversationId = s.data.conversationId);
|
|
2252
2252
|
let c = !1;
|
|
2253
2253
|
const u = Date.now();
|
|
2254
|
-
let
|
|
2254
|
+
let d = s.data.sequenceNumber, p = "", m = "", y = 1;
|
|
2255
2255
|
for (; !c; ) {
|
|
2256
|
-
await new Promise((
|
|
2257
|
-
{ text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,
|
|
2258
|
-
|
|
2259
|
-
),
|
|
2260
|
-
const
|
|
2256
|
+
await new Promise((h) => setTimeout(h, 1e3)), await S(
|
|
2257
|
+
{ text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, y)}` },
|
|
2258
|
+
a
|
|
2259
|
+
), y = y % 3 + 1;
|
|
2260
|
+
const g = await he(`${r}/chat`, {
|
|
2261
2261
|
method: "post",
|
|
2262
2262
|
body: JSON.stringify({
|
|
2263
2263
|
conversationId: s.data.conversationId,
|
|
2264
2264
|
inquiryId: s.data.inquiryId,
|
|
2265
|
-
ackSequenceNumber:
|
|
2265
|
+
ackSequenceNumber: d
|
|
2266
2266
|
}),
|
|
2267
2267
|
headers: {
|
|
2268
2268
|
"Content-Type": "application/json",
|
|
2269
|
-
token:
|
|
2270
|
-
}
|
|
2269
|
+
token: me.findCredential(k.getDefault().url)?.token ?? ""
|
|
2270
|
+
},
|
|
2271
|
+
signal: l
|
|
2271
2272
|
});
|
|
2272
|
-
if (
|
|
2273
|
-
throw new Error(`Graph query service polling returned an error: ${
|
|
2274
|
-
cause:
|
|
2273
|
+
if (g.httpStatus !== 200)
|
|
2274
|
+
throw new Error(`Graph query service polling returned an error: ${g.httpStatus}`, {
|
|
2275
|
+
cause: g.data
|
|
2275
2276
|
});
|
|
2276
|
-
if (
|
|
2277
|
-
|
|
2278
|
-
|
|
2277
|
+
if (g.data.context?.kind) {
|
|
2278
|
+
if (g.data.context.kind !== "GraphQueryGenerationResponse")
|
|
2279
|
+
throw new Error(`Unexpected response from graph query service polling. Message: ${g.data.message}`, {
|
|
2280
|
+
cause: g.data
|
|
2281
|
+
});
|
|
2282
|
+
p = g.data.context.graphQuery, m = g.data.message || "", c = !0;
|
|
2283
|
+
} else if (!g.data.hasMore)
|
|
2279
2284
|
c = !0;
|
|
2280
2285
|
else if (Date.now() - u > 6e4)
|
|
2281
2286
|
throw new Error("Graph query service polling timed out after 1 minute.");
|
|
2282
|
-
|
|
2287
|
+
d = g.data.sequenceNumber;
|
|
2283
2288
|
}
|
|
2284
|
-
return { graphQuery:
|
|
2289
|
+
return { graphQuery: p, explanation: m };
|
|
2285
2290
|
}
|
|
2286
|
-
const
|
|
2287
|
-
function
|
|
2291
|
+
const q = 3;
|
|
2292
|
+
function ke(e, t = 100) {
|
|
2288
2293
|
const r = {};
|
|
2289
|
-
for (const
|
|
2290
|
-
const [
|
|
2291
|
-
typeof n == "string" && n.length > t ? r[
|
|
2294
|
+
for (const a of Object.entries(e.properties ?? {})) {
|
|
2295
|
+
const [o, n] = a;
|
|
2296
|
+
typeof n == "string" && n.length > t ? r[o] = `${n.slice(0, t)}... (truncated, original length: ${n.length})` : r[o] = n;
|
|
2292
2297
|
}
|
|
2293
2298
|
return e.properties = r, e;
|
|
2294
2299
|
}
|
|
2295
|
-
function
|
|
2300
|
+
function A(e) {
|
|
2296
2301
|
return typeof e != "object" || e === null ? String(e) : "details" in e && typeof e.details == "object" && e.details !== null && "errorMessage" in e.details && typeof e.details.errorMessage == "string" ? e.details.errorMessage : "message" in e && typeof e.message == "string" ? e.message : String(e);
|
|
2297
2302
|
}
|
|
2298
|
-
const
|
|
2303
|
+
const Ya = async ({
|
|
2299
2304
|
kg: e,
|
|
2300
2305
|
queryParams: t,
|
|
2301
2306
|
targetStructure: r,
|
|
2302
|
-
targetStructureReducer:
|
|
2303
|
-
requestOptions:
|
|
2307
|
+
targetStructureReducer: a,
|
|
2308
|
+
requestOptions: o,
|
|
2304
2309
|
queryRowLimit: n,
|
|
2305
|
-
queryTimeoutMs:
|
|
2310
|
+
queryTimeoutMs: l
|
|
2306
2311
|
}) => {
|
|
2307
|
-
let
|
|
2308
|
-
const
|
|
2309
|
-
|
|
2312
|
+
let s = null, c = r;
|
|
2313
|
+
const u = new AbortController(), d = o?.signal, p = () => {
|
|
2314
|
+
u.abort(d?.reason);
|
|
2310
2315
|
};
|
|
2311
|
-
d && (d.aborted ?
|
|
2316
|
+
d && (d.aborted ? u.abort(d.reason) : d.addEventListener("abort", p, { once: !0 }));
|
|
2312
2317
|
try {
|
|
2313
|
-
const
|
|
2314
|
-
|
|
2315
|
-
const
|
|
2316
|
-
let
|
|
2317
|
-
const
|
|
2318
|
+
const m = await ht(e, t, o);
|
|
2319
|
+
s = m.resultHeader;
|
|
2320
|
+
const y = m.resultRowsStream.getReader();
|
|
2321
|
+
let g = 0;
|
|
2322
|
+
const h = Date.now(), w = !1;
|
|
2318
2323
|
for (; ; ) {
|
|
2319
|
-
const { done: T, value:
|
|
2324
|
+
const { done: T, value: C } = await y.read();
|
|
2320
2325
|
if (T)
|
|
2321
2326
|
break;
|
|
2322
|
-
if (!
|
|
2323
|
-
return
|
|
2324
|
-
for (const v of
|
|
2325
|
-
if (
|
|
2326
|
-
return
|
|
2327
|
-
|
|
2327
|
+
if (!w && l && Date.now() - h > l)
|
|
2328
|
+
return u.abort(), { type: "timeout" };
|
|
2329
|
+
for (const v of C) {
|
|
2330
|
+
if (g++, n && g > n)
|
|
2331
|
+
return u.abort(), { type: "success", rowLimitReached: !0, resultHeader: s, processedResult: c };
|
|
2332
|
+
c = a(c, v);
|
|
2328
2333
|
}
|
|
2329
2334
|
}
|
|
2330
|
-
} catch (
|
|
2331
|
-
return
|
|
2335
|
+
} catch (m) {
|
|
2336
|
+
return u.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: A(m), error: m };
|
|
2332
2337
|
} finally {
|
|
2333
2338
|
d?.removeEventListener("abort", p);
|
|
2334
2339
|
}
|
|
2335
|
-
return { type: "success", rowLimitReached: !1, resultHeader:
|
|
2340
|
+
return { type: "success", rowLimitReached: !1, resultHeader: s, processedResult: c };
|
|
2336
2341
|
};
|
|
2337
|
-
async function
|
|
2342
|
+
async function Fe({
|
|
2338
2343
|
prompt: e,
|
|
2339
2344
|
kg: t,
|
|
2340
2345
|
graphQueryServiceUrl: r,
|
|
2341
|
-
targetStructure:
|
|
2342
|
-
targetStructureReducer:
|
|
2346
|
+
targetStructure: a,
|
|
2347
|
+
targetStructureReducer: o,
|
|
2343
2348
|
requestOptions: n,
|
|
2344
|
-
queryRowLimit:
|
|
2345
|
-
queryTimeoutMs:
|
|
2346
|
-
config:
|
|
2349
|
+
queryRowLimit: l,
|
|
2350
|
+
queryTimeoutMs: s,
|
|
2351
|
+
config: c
|
|
2347
2352
|
}) {
|
|
2348
|
-
let
|
|
2349
|
-
for (let d = 1; d <=
|
|
2353
|
+
let u;
|
|
2354
|
+
for (let d = 1; d <= q; d++) {
|
|
2350
2355
|
let p;
|
|
2351
2356
|
try {
|
|
2352
|
-
p = await
|
|
2353
|
-
} catch (
|
|
2357
|
+
p = await pe(e, t.dataModel, r, c, u);
|
|
2358
|
+
} catch (g) {
|
|
2354
2359
|
return {
|
|
2355
2360
|
type: "generation-error",
|
|
2356
|
-
errorMessage:
|
|
2357
|
-
error:
|
|
2361
|
+
errorMessage: A(g),
|
|
2362
|
+
error: g
|
|
2358
2363
|
};
|
|
2359
2364
|
}
|
|
2360
2365
|
await S(
|
|
2361
2366
|
{
|
|
2362
2367
|
text: `Attempting to execute query: ${p.graphQuery.substring(0, 500)}${p.graphQuery.length > 500 ? "..." : ""}`
|
|
2363
2368
|
},
|
|
2364
|
-
|
|
2369
|
+
c
|
|
2365
2370
|
);
|
|
2366
|
-
const
|
|
2371
|
+
const m = await Ya({
|
|
2367
2372
|
kg: t,
|
|
2368
|
-
queryParams: new
|
|
2373
|
+
queryParams: new xe({
|
|
2369
2374
|
openCypherQuery: p.graphQuery
|
|
2370
2375
|
}),
|
|
2371
|
-
targetStructure:
|
|
2372
|
-
targetStructureReducer:
|
|
2376
|
+
targetStructure: a,
|
|
2377
|
+
targetStructureReducer: o,
|
|
2373
2378
|
requestOptions: n,
|
|
2374
|
-
queryRowLimit:
|
|
2375
|
-
queryTimeoutMs:
|
|
2376
|
-
}),
|
|
2377
|
-
if (
|
|
2379
|
+
queryRowLimit: l,
|
|
2380
|
+
queryTimeoutMs: s
|
|
2381
|
+
}), y = m.type === "aborted" ? "Query execution was aborted." : m.type === "timeout" ? "Query execution timed out." : m.type === "error" ? `Query failed with error: ${m.errorMessage}` : "";
|
|
2382
|
+
if (m.type === "success")
|
|
2378
2383
|
return {
|
|
2379
2384
|
type: "success",
|
|
2380
2385
|
graphQuery: p.graphQuery,
|
|
2381
2386
|
explanation: p.explanation,
|
|
2382
|
-
rowLimitReached:
|
|
2383
|
-
resultHeader:
|
|
2384
|
-
processedResult:
|
|
2387
|
+
rowLimitReached: m.rowLimitReached,
|
|
2388
|
+
resultHeader: m.resultHeader,
|
|
2389
|
+
processedResult: m.processedResult
|
|
2385
2390
|
};
|
|
2386
|
-
if (
|
|
2391
|
+
if (m.type === "aborted")
|
|
2387
2392
|
return {
|
|
2388
2393
|
type: "aborted",
|
|
2389
|
-
errorMessage:
|
|
2394
|
+
errorMessage: y,
|
|
2390
2395
|
graphQuery: p.graphQuery,
|
|
2391
2396
|
explanation: p.explanation
|
|
2392
2397
|
};
|
|
2393
|
-
if (d >=
|
|
2394
|
-
return
|
|
2398
|
+
if (d >= q)
|
|
2399
|
+
return m.type === "timeout" ? {
|
|
2395
2400
|
type: "timeout",
|
|
2396
|
-
errorMessage:
|
|
2401
|
+
errorMessage: y,
|
|
2397
2402
|
graphQuery: p.graphQuery,
|
|
2398
2403
|
explanation: p.explanation
|
|
2399
2404
|
} : {
|
|
2400
2405
|
type: "execution-error",
|
|
2401
|
-
errorMessage:
|
|
2402
|
-
error:
|
|
2406
|
+
errorMessage: y,
|
|
2407
|
+
error: m.error,
|
|
2403
2408
|
graphQuery: p.graphQuery,
|
|
2404
2409
|
explanation: p.explanation
|
|
2405
2410
|
};
|
|
2406
|
-
|
|
2411
|
+
u = {
|
|
2407
2412
|
failedGraphQuery: p.graphQuery,
|
|
2408
|
-
executionError:
|
|
2413
|
+
executionError: y,
|
|
2409
2414
|
attemptCount: d
|
|
2410
2415
|
}, await S(
|
|
2411
|
-
{ text: `Attempt ${d} failed with error: ${
|
|
2412
|
-
|
|
2416
|
+
{ text: `Attempt ${d} failed with error: ${y}. Retrying...` },
|
|
2417
|
+
c
|
|
2413
2418
|
);
|
|
2414
2419
|
}
|
|
2415
2420
|
throw new Error(
|
|
2416
|
-
`Failed to execute generated cypher due to an unexpected error after ${
|
|
2421
|
+
`Failed to execute generated cypher due to an unexpected error after ${q} attempts.`
|
|
2417
2422
|
);
|
|
2418
2423
|
}
|
|
2419
|
-
const
|
|
2424
|
+
const Xa = async ({
|
|
2420
2425
|
kg: e,
|
|
2421
2426
|
searchQuery: t,
|
|
2422
2427
|
typeCategoryFilter: r,
|
|
2423
|
-
namedTypesFilter:
|
|
2424
|
-
searchResultLimit:
|
|
2428
|
+
namedTypesFilter: a,
|
|
2429
|
+
searchResultLimit: o,
|
|
2425
2430
|
requestOptions: n
|
|
2426
2431
|
}) => {
|
|
2427
|
-
const
|
|
2428
|
-
let
|
|
2429
|
-
r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (
|
|
2430
|
-
const
|
|
2432
|
+
const l = [];
|
|
2433
|
+
let s = [r];
|
|
2434
|
+
r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (s = ["entity", "relationship"]);
|
|
2435
|
+
const c = o ?? 1 / 0;
|
|
2431
2436
|
try {
|
|
2432
|
-
for (const
|
|
2433
|
-
const d =
|
|
2437
|
+
for (const u of s) {
|
|
2438
|
+
const d = c - l.length;
|
|
2434
2439
|
if (d <= 0)
|
|
2435
2440
|
break;
|
|
2436
|
-
const
|
|
2441
|
+
const y = (await yt(
|
|
2437
2442
|
e,
|
|
2438
|
-
new
|
|
2443
|
+
new ft({
|
|
2439
2444
|
searchQuery: t,
|
|
2440
|
-
typeCategoryFilter:
|
|
2441
|
-
namedTypesFilter:
|
|
2445
|
+
typeCategoryFilter: u,
|
|
2446
|
+
namedTypesFilter: a ?? void 0,
|
|
2442
2447
|
num: d
|
|
2443
2448
|
}),
|
|
2444
2449
|
n
|
|
2445
2450
|
)).resultRowsStream.getReader();
|
|
2446
|
-
let
|
|
2447
|
-
for (; !
|
|
2448
|
-
const { done:
|
|
2449
|
-
if (
|
|
2450
|
-
|
|
2451
|
+
let g = !1;
|
|
2452
|
+
for (; !g; ) {
|
|
2453
|
+
const { done: h, value: w } = await y.read();
|
|
2454
|
+
if (h) {
|
|
2455
|
+
g = !0;
|
|
2451
2456
|
break;
|
|
2452
2457
|
}
|
|
2453
|
-
for (const T of
|
|
2454
|
-
for (const
|
|
2455
|
-
|
|
2458
|
+
for (const T of w)
|
|
2459
|
+
for (const C of T)
|
|
2460
|
+
l.push(C);
|
|
2456
2461
|
}
|
|
2457
2462
|
}
|
|
2458
|
-
} catch (
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2463
|
+
} catch (u) {
|
|
2464
|
+
const d = A(u);
|
|
2465
|
+
return n?.signal?.aborted ? {
|
|
2466
|
+
type: "aborted",
|
|
2467
|
+
errorMessage: d,
|
|
2468
|
+
error: u
|
|
2469
|
+
} : { type: "error", errorMessage: d, error: u };
|
|
2462
2470
|
}
|
|
2463
2471
|
return {
|
|
2464
2472
|
type: "success",
|
|
2465
|
-
results:
|
|
2473
|
+
results: l
|
|
2466
2474
|
};
|
|
2467
2475
|
};
|
|
2468
|
-
function
|
|
2476
|
+
function eo(e, t) {
|
|
2469
2477
|
D(e, (r) => {
|
|
2470
2478
|
t.set(`${r.typeName}__${r.id}`, {
|
|
2471
2479
|
id: r.id,
|
|
@@ -2475,126 +2483,144 @@ function Xo(e, t) {
|
|
|
2475
2483
|
}
|
|
2476
2484
|
function D(e, t) {
|
|
2477
2485
|
if (!(!e || typeof e != "object")) {
|
|
2478
|
-
if (
|
|
2486
|
+
if (ro(e))
|
|
2479
2487
|
for (const r of e.path)
|
|
2480
2488
|
D(r, t);
|
|
2481
|
-
else if (
|
|
2489
|
+
else if (to(e))
|
|
2482
2490
|
t(e);
|
|
2483
2491
|
else if (Array.isArray(e))
|
|
2484
2492
|
for (const r of e)
|
|
2485
2493
|
D(r, t);
|
|
2486
|
-
else if (
|
|
2494
|
+
else if (ao(e))
|
|
2487
2495
|
for (const r of Object.values(e.properties ?? {}))
|
|
2488
2496
|
D(r, t);
|
|
2489
2497
|
}
|
|
2490
2498
|
}
|
|
2491
|
-
function
|
|
2499
|
+
function to(e) {
|
|
2492
2500
|
return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
|
|
2493
2501
|
}
|
|
2494
|
-
function
|
|
2502
|
+
function ro(e) {
|
|
2495
2503
|
return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
|
|
2496
2504
|
}
|
|
2497
|
-
function
|
|
2505
|
+
function ao(e) {
|
|
2498
2506
|
return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
|
|
2499
2507
|
}
|
|
2500
|
-
function
|
|
2508
|
+
function oo(e, t) {
|
|
2501
2509
|
const r = [];
|
|
2502
|
-
for (const
|
|
2503
|
-
const
|
|
2504
|
-
for (const n of
|
|
2505
|
-
r.push({ id: n, typeName:
|
|
2510
|
+
for (const a of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
|
|
2511
|
+
const o = e.getMemberIdsByType(a.name);
|
|
2512
|
+
for (const n of o)
|
|
2513
|
+
r.push({ id: n, typeName: a.name });
|
|
2506
2514
|
}
|
|
2507
2515
|
return r;
|
|
2508
2516
|
}
|
|
2509
|
-
function
|
|
2510
|
-
const t = [], r = [],
|
|
2511
|
-
if (
|
|
2517
|
+
function no(e) {
|
|
2518
|
+
const t = [], r = [], o = e?.allLayers.find((n) => n.type === "knowledge-graph")?.inclusionModeDefinition;
|
|
2519
|
+
if (o?.generateAllSublayers)
|
|
2512
2520
|
return { allNamedTypesFullyDynamic: !0, idTypePairs: t, dynamicTypes: r };
|
|
2513
|
-
for (const [n,
|
|
2514
|
-
if (
|
|
2521
|
+
for (const [n, l] of o?.namedTypeDefinitions ?? [])
|
|
2522
|
+
if (l.useAllData)
|
|
2515
2523
|
r.push(n);
|
|
2516
2524
|
else
|
|
2517
|
-
for (const [
|
|
2518
|
-
t.push({ id:
|
|
2525
|
+
for (const [s] of l.members)
|
|
2526
|
+
t.push({ id: s, typeName: n });
|
|
2519
2527
|
return { allNamedTypesFullyDynamic: !1, idTypePairs: t, dynamicTypes: r };
|
|
2520
2528
|
}
|
|
2521
|
-
async function
|
|
2522
|
-
const { view: n } =
|
|
2529
|
+
async function io(e, t, r, a, o) {
|
|
2530
|
+
const { view: n } = a, l = await Fe({
|
|
2523
2531
|
prompt: e,
|
|
2524
2532
|
kg: t,
|
|
2525
2533
|
graphQueryServiceUrl: r,
|
|
2526
2534
|
targetStructure: /* @__PURE__ */ new Map(),
|
|
2527
|
-
targetStructureReducer: (p,
|
|
2528
|
-
for (const
|
|
2529
|
-
|
|
2535
|
+
targetStructureReducer: (p, m) => {
|
|
2536
|
+
for (const y of m)
|
|
2537
|
+
eo(y, p);
|
|
2530
2538
|
return p;
|
|
2531
2539
|
},
|
|
2532
2540
|
requestOptions: {
|
|
2533
|
-
signal:
|
|
2534
|
-
timeout:
|
|
2541
|
+
signal: Y(o),
|
|
2542
|
+
timeout: o?.timeout
|
|
2535
2543
|
},
|
|
2536
|
-
config:
|
|
2544
|
+
config: o
|
|
2537
2545
|
});
|
|
2538
|
-
if (
|
|
2539
|
-
const p =
|
|
2546
|
+
if (l.type !== "success") {
|
|
2547
|
+
const p = l.type === "generation-error" ? l.errorMessage : `${l.errorMessage} Cypher query: ${l.graphQuery}`;
|
|
2540
2548
|
throw new Error(`Failed to add records to the link chart. ${p}`);
|
|
2541
2549
|
}
|
|
2542
|
-
const { graphQuery:
|
|
2550
|
+
const { graphQuery: s, explanation: c, processedResult: u } = l, d = Array.from(u.values());
|
|
2543
2551
|
return await S(
|
|
2544
2552
|
{
|
|
2545
2553
|
text: `Query Results parsed into ${d.length} unique relationships and entities. Atempting to add to link chart...`
|
|
2546
2554
|
},
|
|
2547
|
-
|
|
2548
|
-
), !
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
Explanation: ${u}`) : (await n?.map?.allLayers.find(
|
|
2552
|
-
(h) => h.type === "knowledge-graph"
|
|
2553
|
-
)?.addRecords(d), `Map updated successfully. Cypher Query used:
|
|
2554
|
-
${c}
|
|
2555
|
-
|
|
2556
|
-
Explanation: ${u}`);
|
|
2555
|
+
o
|
|
2556
|
+
), !N(n) && n?.map ? (await n.map.addRecords(d), await J(n), { generatedQuery: s, explanation: c, addedIdTypePairs: d }) : (await n?.map?.allLayers.find(
|
|
2557
|
+
(m) => m.type === "knowledge-graph"
|
|
2558
|
+
)?.addRecords(d), { generatedQuery: s, explanation: c, addedIdTypePairs: d });
|
|
2557
2559
|
}
|
|
2558
|
-
const
|
|
2560
|
+
const W = "addRecords", so = i.object({
|
|
2559
2561
|
prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
|
|
2560
|
-
}),
|
|
2561
|
-
const { knowledgeGraph: r } = await
|
|
2562
|
-
let
|
|
2563
|
-
if (
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2562
|
+
}), lo = async ({ prompt: e }, t) => {
|
|
2563
|
+
const { knowledgeGraph: r } = await O(t), a = Z(t), { view: o } = a, l = k.getDefault().helperServices;
|
|
2564
|
+
let s = e;
|
|
2565
|
+
if (!N(o) && o.map) {
|
|
2566
|
+
const c = o.map, u = await te("arcgis_knowledge_current_lc_context"), d = oo(c, r);
|
|
2567
|
+
s = `${e}
|
|
2566
2568
|
|
|
2567
|
-
${
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
} else {
|
|
2572
|
-
const l = a.map, d = await Y("arcgis_knowledge_current_lc_context"), p = oa(l, r);
|
|
2573
|
-
c = `${e}
|
|
2569
|
+
${u}${JSON.stringify(d)}`;
|
|
2570
|
+
} else if (N(o) && o.map) {
|
|
2571
|
+
const c = o.map, { allNamedTypesFullyDynamic: u, idTypePairs: d, dynamicTypes: p } = no(c), m = await te("arcgis_knowledge_current_map_context");
|
|
2572
|
+
if (s = `${e}
|
|
2574
2573
|
|
|
2575
|
-
${d}${JSON.stringify(p)}
|
|
2574
|
+
${m}${JSON.stringify(d)} and all entities or relationships with the the following typeNames in the array: ${JSON.stringify(p)}`, u)
|
|
2575
|
+
return {
|
|
2576
|
+
toolName: W,
|
|
2577
|
+
status: "success",
|
|
2578
|
+
summary: "No records have been added to the map because all data in the knowledge graph is contained in the map.",
|
|
2579
|
+
details: {
|
|
2580
|
+
generatedQuery: "N/A",
|
|
2581
|
+
explanation: "All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",
|
|
2582
|
+
addedIdTypePairs: []
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2576
2585
|
}
|
|
2577
|
-
|
|
2578
|
-
c,
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2586
|
+
try {
|
|
2587
|
+
const { generatedQuery: c, explanation: u, addedIdTypePairs: d } = await io(
|
|
2588
|
+
s,
|
|
2589
|
+
r,
|
|
2590
|
+
`${l.aiAssistantServices.url}${l.aiAssistantServices.graphQueryAssistant}`,
|
|
2591
|
+
a,
|
|
2592
|
+
t
|
|
2593
|
+
);
|
|
2594
|
+
return {
|
|
2595
|
+
toolName: W,
|
|
2596
|
+
status: "success",
|
|
2597
|
+
summary: `Records added successfully. Cypher Query used: ${c}
|
|
2598
|
+
|
|
2599
|
+
Number of records added: ${d.length}`,
|
|
2600
|
+
details: {
|
|
2601
|
+
generatedQuery: c,
|
|
2602
|
+
explanation: u,
|
|
2603
|
+
addedIdTypePairs: d
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
} catch (c) {
|
|
2607
|
+
const u = A(c);
|
|
2608
|
+
return console.error(`Failed to add records to the link chart. ${u}`, c), {
|
|
2609
|
+
toolName: W,
|
|
2610
|
+
status: "error",
|
|
2611
|
+
errorMessage: `Failed to add records to the link chart. ${u}`,
|
|
2612
|
+
error: c
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2615
|
+
}, ti = f(lo, {
|
|
2616
|
+
name: W,
|
|
2591
2617
|
description: "Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",
|
|
2592
|
-
schema:
|
|
2618
|
+
schema: so
|
|
2593
2619
|
});
|
|
2594
|
-
async function
|
|
2595
|
-
return await t.map?.applyLayout(e), await
|
|
2620
|
+
async function co(e, t) {
|
|
2621
|
+
return await t.map?.applyLayout(e), await J(t), { appliedLayout: e };
|
|
2596
2622
|
}
|
|
2597
|
-
const
|
|
2623
|
+
const ae = "applyLayout", uo = i.object({
|
|
2598
2624
|
layout: i.enum([
|
|
2599
2625
|
"organic-standard",
|
|
2600
2626
|
"organic-community",
|
|
@@ -2608,143 +2634,160 @@ const ee = "applyLayout", la = i.object({
|
|
|
2608
2634
|
]).describe(
|
|
2609
2635
|
"The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline"
|
|
2610
2636
|
)
|
|
2611
|
-
}),
|
|
2612
|
-
const { view: r } =
|
|
2613
|
-
if (
|
|
2637
|
+
}), po = async ({ layout: e }, t) => {
|
|
2638
|
+
const { view: r } = Z(t);
|
|
2639
|
+
if (N(r))
|
|
2614
2640
|
return {
|
|
2615
|
-
toolName:
|
|
2641
|
+
toolName: ae,
|
|
2616
2642
|
status: "error",
|
|
2617
2643
|
errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
|
|
2618
2644
|
error: new Error()
|
|
2619
2645
|
};
|
|
2620
2646
|
{
|
|
2621
|
-
const
|
|
2647
|
+
const { appliedLayout: a } = await co(e, r);
|
|
2622
2648
|
return {
|
|
2623
|
-
toolName:
|
|
2649
|
+
toolName: ae,
|
|
2624
2650
|
status: "success",
|
|
2625
|
-
summary:
|
|
2651
|
+
summary: `Successfully applied layout: ${a}.`,
|
|
2652
|
+
details: {
|
|
2653
|
+
appliedLayout: a
|
|
2654
|
+
}
|
|
2626
2655
|
};
|
|
2627
2656
|
}
|
|
2628
|
-
},
|
|
2629
|
-
name:
|
|
2657
|
+
}, ri = f(po, {
|
|
2658
|
+
name: ae,
|
|
2630
2659
|
description: "Apply a diagram layout to the link chart",
|
|
2631
|
-
schema:
|
|
2660
|
+
schema: uo
|
|
2632
2661
|
});
|
|
2633
|
-
async function
|
|
2634
|
-
return t.map?.changeNonspatialDataDisplay(e), await
|
|
2662
|
+
async function mo(e, t) {
|
|
2663
|
+
return t.map?.changeNonspatialDataDisplay(e), await J(t), { appliedNonspatialDataDisplayMode: e };
|
|
2635
2664
|
}
|
|
2636
|
-
const
|
|
2665
|
+
const oe = "changeNonspatialVisibility", ho = i.object({
|
|
2637
2666
|
setting: i.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
|
|
2638
|
-
}),
|
|
2639
|
-
const { view: r } =
|
|
2640
|
-
if (
|
|
2667
|
+
}), yo = async ({ setting: e }, t) => {
|
|
2668
|
+
const { view: r } = Z(t);
|
|
2669
|
+
if (N(r))
|
|
2641
2670
|
return {
|
|
2642
|
-
toolName:
|
|
2671
|
+
toolName: oe,
|
|
2643
2672
|
status: "error",
|
|
2644
2673
|
errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
|
|
2645
2674
|
error: new Error()
|
|
2646
2675
|
};
|
|
2647
2676
|
{
|
|
2648
|
-
const
|
|
2677
|
+
const { appliedNonspatialDataDisplayMode: a } = await mo(e, r);
|
|
2649
2678
|
return {
|
|
2650
|
-
toolName:
|
|
2679
|
+
toolName: oe,
|
|
2651
2680
|
status: "success",
|
|
2652
|
-
summary:
|
|
2681
|
+
summary: `Successfully applied nonspatial visibility setting: ${a}.`,
|
|
2682
|
+
details: {
|
|
2683
|
+
appliedNonspatialDataDisplayMode: a
|
|
2684
|
+
}
|
|
2653
2685
|
};
|
|
2654
2686
|
}
|
|
2655
|
-
},
|
|
2656
|
-
name:
|
|
2687
|
+
}, ai = f(yo, {
|
|
2688
|
+
name: oe,
|
|
2657
2689
|
description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
|
|
2658
|
-
schema:
|
|
2690
|
+
schema: ho
|
|
2659
2691
|
});
|
|
2660
|
-
async function
|
|
2661
|
-
let n;
|
|
2662
|
-
for (let s = 1; s <=
|
|
2663
|
-
const { graphQuery: c, explanation: u } = await
|
|
2692
|
+
async function fo(e, t, r, a, o) {
|
|
2693
|
+
let n, l = "";
|
|
2694
|
+
for (let s = 1; s <= q; s++) {
|
|
2695
|
+
const { graphQuery: c, explanation: u } = await pe(
|
|
2664
2696
|
e,
|
|
2665
2697
|
t.dataModel,
|
|
2666
2698
|
r,
|
|
2667
|
-
|
|
2699
|
+
o,
|
|
2668
2700
|
n
|
|
2669
2701
|
);
|
|
2670
2702
|
try {
|
|
2671
|
-
await S({ text: `Attempting to create link chart from derived query: ${c}` },
|
|
2672
|
-
const
|
|
2703
|
+
await S({ text: `Attempting to create link chart from derived query: ${c}` }, o);
|
|
2704
|
+
const d = await mt.fromCypherQuery(
|
|
2673
2705
|
t,
|
|
2674
|
-
new
|
|
2706
|
+
new xe({
|
|
2675
2707
|
openCypherQuery: c
|
|
2676
2708
|
})
|
|
2677
2709
|
);
|
|
2678
|
-
await S({ text: "Link chart created successfully, loading..." },
|
|
2679
|
-
const
|
|
2680
|
-
return
|
|
2710
|
+
await S({ text: "Link chart created successfully, loading..." }, o), await d.load();
|
|
2711
|
+
const p = a.map;
|
|
2712
|
+
return a.map = d, await a.when(), await Ae.whenOnce(() => !a.updating), d.entityCount === 0 && d.relationshipCount === 0 ? (a.map === d && (a.map = p), d.destroy(), {
|
|
2681
2713
|
type: "error",
|
|
2682
|
-
|
|
2714
|
+
errorMessage: `Query returned no results. Cypher Query used to create the link chart:
|
|
2683
2715
|
${c}
|
|
2684
2716
|
|
|
2685
2717
|
Explanation: ${u}`
|
|
2686
|
-
}) : (await
|
|
2718
|
+
}) : (await J(a), {
|
|
2687
2719
|
type: "success",
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
Explanation: ${u}`
|
|
2720
|
+
graphQuery: c,
|
|
2721
|
+
explanation: u
|
|
2692
2722
|
});
|
|
2693
|
-
} catch (
|
|
2694
|
-
const
|
|
2695
|
-
if (s >=
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2723
|
+
} catch (d) {
|
|
2724
|
+
const p = A(d);
|
|
2725
|
+
if (s >= q) {
|
|
2726
|
+
l = p;
|
|
2727
|
+
break;
|
|
2728
|
+
}
|
|
2699
2729
|
n = {
|
|
2700
2730
|
failedGraphQuery: c,
|
|
2701
|
-
executionError:
|
|
2731
|
+
executionError: p,
|
|
2702
2732
|
attemptCount: s
|
|
2703
2733
|
}, await S(
|
|
2704
|
-
{ text: `Attempt ${s} to create link chart failed with error: ${
|
|
2705
|
-
|
|
2734
|
+
{ text: `Attempt ${s} to create link chart failed with error: ${p}. Retrying ...` },
|
|
2735
|
+
o
|
|
2706
2736
|
);
|
|
2707
2737
|
}
|
|
2708
2738
|
}
|
|
2709
|
-
|
|
2739
|
+
return {
|
|
2740
|
+
type: "error",
|
|
2741
|
+
errorMessage: `Failed to create link chart after ${q} attempts. Last error: ${l}`
|
|
2742
|
+
};
|
|
2710
2743
|
}
|
|
2711
|
-
const
|
|
2744
|
+
const V = "createLinkChart", go = i.object({
|
|
2712
2745
|
prompt: i.string().describe(
|
|
2713
2746
|
"The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
|
|
2714
2747
|
)
|
|
2715
|
-
}),
|
|
2716
|
-
const { knowledgeGraph: r } = await
|
|
2717
|
-
if (
|
|
2748
|
+
}), wo = async ({ prompt: e }, t) => {
|
|
2749
|
+
const { knowledgeGraph: r } = await O(t), { view: a } = Z(t);
|
|
2750
|
+
if (N(a))
|
|
2718
2751
|
return {
|
|
2719
|
-
toolName:
|
|
2752
|
+
toolName: V,
|
|
2720
2753
|
status: "error",
|
|
2721
2754
|
errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
|
|
2722
2755
|
error: new Error()
|
|
2723
2756
|
};
|
|
2724
2757
|
{
|
|
2725
|
-
const n = k.getDefault().helperServices,
|
|
2758
|
+
const n = k.getDefault().helperServices, l = await fo(
|
|
2726
2759
|
e,
|
|
2727
2760
|
r,
|
|
2728
2761
|
`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
|
|
2729
|
-
|
|
2762
|
+
a,
|
|
2730
2763
|
t
|
|
2731
2764
|
);
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2765
|
+
if (l.type === "error")
|
|
2766
|
+
return {
|
|
2767
|
+
toolName: V,
|
|
2768
|
+
status: "error",
|
|
2769
|
+
errorMessage: l.errorMessage,
|
|
2770
|
+
error: new Error()
|
|
2771
|
+
};
|
|
2772
|
+
const { graphQuery: s, explanation: c } = l;
|
|
2773
|
+
return {
|
|
2774
|
+
toolName: V,
|
|
2739
2775
|
status: "success",
|
|
2740
|
-
summary:
|
|
2776
|
+
summary: `Link chart created successfully. Cypher Query used to create the link chart:
|
|
2777
|
+
${s}
|
|
2778
|
+
|
|
2779
|
+
Explanation: ${c}`,
|
|
2780
|
+
details: {
|
|
2781
|
+
generatedQuery: s,
|
|
2782
|
+
explanation: c
|
|
2783
|
+
}
|
|
2741
2784
|
};
|
|
2742
2785
|
}
|
|
2743
|
-
},
|
|
2744
|
-
name:
|
|
2786
|
+
}, oi = f(wo, {
|
|
2787
|
+
name: V,
|
|
2745
2788
|
description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",
|
|
2746
|
-
schema:
|
|
2747
|
-
}),
|
|
2789
|
+
schema: go
|
|
2790
|
+
}), ne = "queryGraphData", bo = i.object({
|
|
2748
2791
|
prompt: i.string().describe(
|
|
2749
2792
|
`The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. IMPORTANT:
|
|
2750
2793
|
|
|
@@ -2752,223 +2795,248 @@ REQUEST LIMIT: If the user does not specifically request for no limits or an exp
|
|
|
2752
2795
|
|
|
2753
2796
|
DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for specific column names in the result, ensure that the generated query has descriptive column names (using AS statements) to make the results easier to understand when displayed in a table format.`
|
|
2754
2797
|
)
|
|
2755
|
-
}),
|
|
2756
|
-
const { knowledgeGraph: r } = await
|
|
2798
|
+
}), To = async ({ prompt: e }, t) => {
|
|
2799
|
+
const { knowledgeGraph: r } = await O(t), o = k.getDefault().helperServices, n = await Fe({
|
|
2757
2800
|
prompt: e,
|
|
2758
2801
|
kg: r,
|
|
2759
|
-
graphQueryServiceUrl: `${
|
|
2802
|
+
graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
2760
2803
|
targetStructure: new Array(),
|
|
2761
|
-
targetStructureReducer: (
|
|
2804
|
+
targetStructureReducer: (y, g) => (y.push(g), y),
|
|
2762
2805
|
requestOptions: {
|
|
2763
|
-
signal: t
|
|
2806
|
+
signal: Y(t),
|
|
2764
2807
|
timeout: t?.timeout
|
|
2765
2808
|
},
|
|
2766
2809
|
config: t
|
|
2767
2810
|
});
|
|
2768
2811
|
if (n.type !== "success") {
|
|
2769
|
-
const
|
|
2770
|
-
|
|
2812
|
+
const y = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
|
|
2813
|
+
return {
|
|
2814
|
+
toolName: ne,
|
|
2815
|
+
status: "error",
|
|
2816
|
+
errorMessage: `Failed to query the knowledge graph. ${y}`,
|
|
2817
|
+
error: "error" in n ? n.error : null
|
|
2818
|
+
};
|
|
2771
2819
|
}
|
|
2772
|
-
const { graphQuery: s, processedResult: c, resultHeader: u } = n,
|
|
2773
|
-
for (const
|
|
2774
|
-
for (const
|
|
2820
|
+
const { graphQuery: l, explanation: s, processedResult: c, resultHeader: u } = n, d = u.headerKeys;
|
|
2821
|
+
for (const y of c)
|
|
2822
|
+
for (const g of y)
|
|
2775
2823
|
D(
|
|
2776
|
-
|
|
2777
|
-
(
|
|
2824
|
+
g,
|
|
2825
|
+
(h) => ke(h)
|
|
2778
2826
|
);
|
|
2779
|
-
const
|
|
2827
|
+
const p = 50, m = c.slice(0, p).map((y) => JSON.stringify(y));
|
|
2780
2828
|
return {
|
|
2781
|
-
toolName:
|
|
2829
|
+
toolName: ne,
|
|
2782
2830
|
status: "success",
|
|
2783
2831
|
summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
|
|
2784
2832
|
|
|
2785
2833
|
\`\`\`cypher
|
|
2786
|
-
${
|
|
2834
|
+
${l}
|
|
2787
2835
|
\`\`\`
|
|
2788
2836
|
|
|
2789
2837
|
Query Results:
|
|
2790
|
-
${
|
|
2838
|
+
${m.length} result(s) found.
|
|
2791
2839
|
|
|
2792
|
-
Column Headers: ${
|
|
2840
|
+
Column Headers: ${d.join(", ")}
|
|
2793
2841
|
|
|
2794
|
-
${
|
|
2842
|
+
${m.length > p ? `Showing top ${p} results:
|
|
2795
2843
|
|
|
2796
2844
|
` : `Results:
|
|
2797
2845
|
|
|
2798
|
-
`}${
|
|
2846
|
+
`}${m.join(`
|
|
2799
2847
|
`)}
|
|
2800
2848
|
`,
|
|
2801
2849
|
details: {
|
|
2802
|
-
generatedQuery:
|
|
2850
|
+
generatedQuery: l,
|
|
2851
|
+
explanation: s,
|
|
2803
2852
|
resultHeader: u,
|
|
2804
2853
|
queryResults: c
|
|
2805
2854
|
}
|
|
2806
2855
|
};
|
|
2807
|
-
},
|
|
2808
|
-
name:
|
|
2856
|
+
}, ni = f(To, {
|
|
2857
|
+
name: ne,
|
|
2809
2858
|
description: "Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",
|
|
2810
|
-
schema:
|
|
2811
|
-
}),
|
|
2859
|
+
schema: bo
|
|
2860
|
+
}), ie = "generateCypher", vo = i.object({
|
|
2812
2861
|
prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
|
|
2813
|
-
}),
|
|
2814
|
-
const { knowledgeGraph: r } = await
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2862
|
+
}), So = async ({ prompt: e }, t) => {
|
|
2863
|
+
const { knowledgeGraph: r } = await O(t), o = k.getDefault().helperServices;
|
|
2864
|
+
try {
|
|
2865
|
+
const { graphQuery: n, explanation: l } = await Za(
|
|
2866
|
+
e,
|
|
2867
|
+
r.dataModel,
|
|
2868
|
+
`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
2869
|
+
t
|
|
2870
|
+
);
|
|
2871
|
+
return {
|
|
2872
|
+
toolName: ie,
|
|
2873
|
+
status: "success",
|
|
2874
|
+
summary: `Generated Graph Query:
|
|
2875
|
+
${n}
|
|
2876
|
+
|
|
2877
|
+
Explanation: ${l}`,
|
|
2878
|
+
details: {
|
|
2879
|
+
generatedQuery: n,
|
|
2880
|
+
explanation: l
|
|
2881
|
+
}
|
|
2882
|
+
};
|
|
2883
|
+
} catch (n) {
|
|
2884
|
+
const l = A(n);
|
|
2885
|
+
return {
|
|
2886
|
+
toolName: ie,
|
|
2887
|
+
status: "error",
|
|
2888
|
+
errorMessage: `Failed to generate Cypher query. ${l}`,
|
|
2889
|
+
error: n
|
|
2890
|
+
};
|
|
2891
|
+
}
|
|
2892
|
+
}, ii = f(So, {
|
|
2893
|
+
name: ie,
|
|
2827
2894
|
description: "Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",
|
|
2828
|
-
schema:
|
|
2829
|
-
}),
|
|
2895
|
+
schema: vo
|
|
2896
|
+
}), xo = (e) => {
|
|
2830
2897
|
const t = e.dataModel, r = /* @__PURE__ */ new Map();
|
|
2831
|
-
for (const
|
|
2832
|
-
if (
|
|
2833
|
-
for (const [
|
|
2834
|
-
const d = r.get(
|
|
2835
|
-
|
|
2898
|
+
for (const s of t.searchIndexes)
|
|
2899
|
+
if (s.supportedCategory !== "esriTypeMetaEntityProvenance")
|
|
2900
|
+
for (const [c, u] of s.searchProperties.entries()) {
|
|
2901
|
+
const d = r.get(c) ?? /* @__PURE__ */ new Set();
|
|
2902
|
+
u.propertyNames.forEach((p) => d.add(p)), r.set(c, d);
|
|
2836
2903
|
}
|
|
2837
|
-
const
|
|
2838
|
-
${
|
|
2839
|
-
`)}`,
|
|
2840
|
-
${
|
|
2904
|
+
const a = t.entityTypes.filter((s) => r.has(s.name)), o = t.relationshipTypes.filter((s) => r.has(s.name)), n = `Entity Types:
|
|
2905
|
+
${a.map(({ name: s }) => `${s}: [${Array.from(r.get(s) ?? []).join(", ")}]`).join(`
|
|
2906
|
+
`)}`, l = `Relationship Types:
|
|
2907
|
+
${o.map(({ name: s }) => `${s}: [${Array.from(r.get(s) ?? []).join(", ")}]`).join(`
|
|
2841
2908
|
`)}`;
|
|
2842
2909
|
return `${n}
|
|
2843
2910
|
|
|
2844
|
-
${
|
|
2911
|
+
${l}`;
|
|
2845
2912
|
};
|
|
2846
|
-
async function
|
|
2847
|
-
const r = await
|
|
2913
|
+
async function Ro(e, t) {
|
|
2914
|
+
const r = await te("arcgis_knowledge_lucene_generation_prompt"), a = {
|
|
2848
2915
|
inquiry: e,
|
|
2849
|
-
dataModelForSearch:
|
|
2850
|
-
},
|
|
2916
|
+
dataModelForSearch: xo(t)
|
|
2917
|
+
}, o = i.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), n = i.number().int().positive().nullable().describe(
|
|
2851
2918
|
"The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."
|
|
2852
|
-
),
|
|
2919
|
+
), l = i.array(
|
|
2853
2920
|
i.enum(
|
|
2854
|
-
t.dataModel.entityTypes.map((
|
|
2921
|
+
t.dataModel.entityTypes.map((u) => u.name).concat(t.dataModel.relationshipTypes.map((u) => u.name))
|
|
2855
2922
|
)
|
|
2856
|
-
).min(1),
|
|
2923
|
+
).min(1), s = i.object({
|
|
2857
2924
|
query: i.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
|
|
2858
|
-
typeFilters:
|
|
2925
|
+
typeFilters: l.nullable().describe(
|
|
2859
2926
|
"Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"
|
|
2860
2927
|
),
|
|
2861
|
-
typeCategoryFilter:
|
|
2928
|
+
typeCategoryFilter: o,
|
|
2862
2929
|
resultLimit: n
|
|
2863
2930
|
});
|
|
2864
|
-
return await
|
|
2931
|
+
return await De({
|
|
2865
2932
|
promptText: r,
|
|
2866
|
-
inputVariables:
|
|
2867
|
-
schema:
|
|
2933
|
+
inputVariables: a,
|
|
2934
|
+
schema: s
|
|
2868
2935
|
});
|
|
2869
2936
|
}
|
|
2870
|
-
const
|
|
2937
|
+
const se = "searchGraphData", $o = i.object({
|
|
2871
2938
|
prompt: i.string().describe(
|
|
2872
2939
|
"The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results."
|
|
2873
2940
|
)
|
|
2874
|
-
}),
|
|
2875
|
-
const { knowledgeGraph: r } = await
|
|
2941
|
+
}), Co = async ({ prompt: e }, t) => {
|
|
2942
|
+
const { knowledgeGraph: r } = await O(t);
|
|
2876
2943
|
await S({ text: "Generating search query for the user inquiry" }, t);
|
|
2877
|
-
const
|
|
2944
|
+
const a = await Ro(e, r);
|
|
2878
2945
|
await S({ text: "Executing graph search with generated search query" }, t);
|
|
2879
|
-
const
|
|
2946
|
+
const o = await Xa({
|
|
2880
2947
|
kg: r,
|
|
2881
|
-
searchQuery:
|
|
2882
|
-
typeCategoryFilter:
|
|
2883
|
-
namedTypesFilter:
|
|
2884
|
-
searchResultLimit:
|
|
2948
|
+
searchQuery: a.query,
|
|
2949
|
+
typeCategoryFilter: a.typeCategoryFilter,
|
|
2950
|
+
namedTypesFilter: a.typeFilters,
|
|
2951
|
+
searchResultLimit: a.resultLimit,
|
|
2885
2952
|
requestOptions: {
|
|
2886
|
-
signal: t
|
|
2953
|
+
signal: Y(t),
|
|
2887
2954
|
timeout: t?.timeout
|
|
2888
2955
|
}
|
|
2889
2956
|
});
|
|
2890
|
-
if (
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2957
|
+
if (o.type !== "success")
|
|
2958
|
+
return {
|
|
2959
|
+
toolName: se,
|
|
2960
|
+
status: "error",
|
|
2961
|
+
errorMessage: o.errorMessage,
|
|
2962
|
+
error: "error" in o ? o.error : null
|
|
2963
|
+
};
|
|
2964
|
+
for (const s of o.results)
|
|
2895
2965
|
D(
|
|
2896
|
-
|
|
2897
|
-
(
|
|
2966
|
+
s,
|
|
2967
|
+
(c) => ke(c)
|
|
2898
2968
|
);
|
|
2899
|
-
const n = 10,
|
|
2969
|
+
const n = 10, l = o.results.slice(0, n);
|
|
2900
2970
|
return {
|
|
2901
|
-
toolName:
|
|
2971
|
+
toolName: se,
|
|
2902
2972
|
status: "success",
|
|
2903
2973
|
summary: `To answer the query, the following lucene query was generated and executed:
|
|
2904
|
-
Query: ${
|
|
2905
|
-
Type Category Filter: ${
|
|
2906
|
-
Named Type Filters: ${
|
|
2907
|
-
Result Limit: ${
|
|
2974
|
+
Query: ${a.query}
|
|
2975
|
+
Type Category Filter: ${a.typeCategoryFilter}
|
|
2976
|
+
Named Type Filters: ${a.typeFilters ? a.typeFilters.join(", ") : "None"}
|
|
2977
|
+
Result Limit: ${a.resultLimit ?? "No limit"}
|
|
2908
2978
|
|
|
2909
|
-
Search Results: ${
|
|
2979
|
+
Search Results: ${o.results.length} result(s) found.
|
|
2910
2980
|
|
|
2911
|
-
${
|
|
2981
|
+
${o.results.length > n ? `Showing top ${n} results:
|
|
2912
2982
|
|
|
2913
|
-
` : ""}${
|
|
2983
|
+
` : ""}${l.map((s) => JSON.stringify(s)).join(`
|
|
2914
2984
|
`)}`,
|
|
2915
2985
|
details: {
|
|
2916
|
-
|
|
2917
|
-
searchResults:
|
|
2918
|
-
...a
|
|
2919
|
-
}
|
|
2986
|
+
generatedSearchQuery: a,
|
|
2987
|
+
searchResults: o.results
|
|
2920
2988
|
}
|
|
2921
2989
|
};
|
|
2922
|
-
},
|
|
2923
|
-
name:
|
|
2990
|
+
}, si = f(Co, {
|
|
2991
|
+
name: se,
|
|
2924
2992
|
description: "Allows users to search the knowledge graph for text matching their inquiry, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.",
|
|
2925
|
-
schema:
|
|
2993
|
+
schema: $o
|
|
2926
2994
|
});
|
|
2927
2995
|
export {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2996
|
+
Pn as A,
|
|
2997
|
+
Ln as B,
|
|
2998
|
+
jn as C,
|
|
2999
|
+
Gn as D,
|
|
3000
|
+
On as E,
|
|
3001
|
+
Mn as F,
|
|
3002
|
+
de as G,
|
|
3003
|
+
Zn as H,
|
|
3004
|
+
Qn as I,
|
|
3005
|
+
_n as J,
|
|
3006
|
+
Wn as K,
|
|
3007
|
+
Vn as L,
|
|
3008
|
+
Un as M,
|
|
3009
|
+
Rn as N,
|
|
3010
|
+
Bn as O,
|
|
3011
|
+
Hn as P,
|
|
3012
|
+
Ma as Q,
|
|
3013
|
+
F as R,
|
|
3014
|
+
Kn as S,
|
|
3015
|
+
Jn as T,
|
|
3016
|
+
ri as a,
|
|
3017
|
+
ii as b,
|
|
3018
|
+
ai as c,
|
|
3019
|
+
oi as d,
|
|
3020
|
+
ti as e,
|
|
3021
|
+
Re as f,
|
|
3022
|
+
te as g,
|
|
3023
|
+
ei as h,
|
|
3024
|
+
O as i,
|
|
3025
|
+
Xn as j,
|
|
3026
|
+
$n as k,
|
|
3027
|
+
Yn as l,
|
|
3028
|
+
Cn as m,
|
|
3029
|
+
En as n,
|
|
3030
|
+
Nn as o,
|
|
3031
|
+
In as p,
|
|
3032
|
+
ni as q,
|
|
3033
|
+
Dn as r,
|
|
3034
|
+
si as s,
|
|
3035
|
+
Vt as t,
|
|
3036
|
+
kn as u,
|
|
3037
|
+
Fn as v,
|
|
3038
|
+
zn as w,
|
|
3039
|
+
qn as x,
|
|
2972
3040
|
$ as y,
|
|
2973
|
-
|
|
3041
|
+
An as z
|
|
2974
3042
|
};
|