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