@vertigis/arcgis-extensions 54.14.6 → 54.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/Feature.js +1 -1
- package/declarations/arcgis-js-api-extensions/index.d.ts +0 -29
- package/docs/html/assets/hierarchy.js +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/utilities_format_date.DateFormatter.html +1 -1
- package/docs/html/classes/utilities_format_number.NumberFormatter.html +1 -1
- package/docs/html/classes/utilities_format_time.TimeFormatter.html +1 -1
- package/docs/html/classes/utilities_log.ConsoleLogger.html +1 -1
- package/docs/html/classes/utilities_log.LoggerBase.html +1 -1
- package/docs/html/functions/utilities_arcade.constructProfile.html +43 -0
- package/docs/html/functions/utilities_arcade.createExecutorForExpression.html +53 -0
- package/docs/html/functions/utilities_arcade.isArcadeScriptAsync.html +7 -2
- package/docs/html/functions/utilities_arcade.isExpressionAsyncOnly.html +43 -0
- package/docs/html/functions/utilities_arcade.runArcadeExpression.html +9 -3
- package/docs/html/functions/utilities_arcade.runAsyncArcadeExpression.html +7 -2
- package/docs/html/functions/utilities_arcade.runAsyncExpression.html +47 -0
- package/docs/html/functions/utilities_arcade.runSyncExpression.html +52 -0
- package/docs/html/functions/utilities_arcade.toArcadeVariable.html +57 -0
- package/docs/html/hierarchy.html +19 -19
- package/docs/html/interfaces/utilities_arcade.RunArcadeExpressionParams.html +15 -6
- package/docs/html/interfaces/utilities_collection.AfterItemChangeEvent.html +1 -1
- package/docs/html/interfaces/utilities_format_FormatSettings.FormatSettings.html +1 -1
- package/docs/html/interfaces/utilities_format_date.DateFormatterProperties.html +1 -1
- package/docs/html/interfaces/utilities_format_date.DateSettings.html +1 -1
- package/docs/html/interfaces/utilities_format_number.NumberFormatterProperties.html +1 -1
- package/docs/html/interfaces/utilities_format_number.NumberSettings.html +1 -1
- package/docs/html/interfaces/utilities_format_string.FormatOptions.html +1 -1
- package/docs/html/interfaces/utilities_format_time.TimeFormatterProperties.html +1 -1
- package/docs/html/interfaces/utilities_format_time.TimeSettings.html +1 -1
- package/docs/html/interfaces/utilities_log.LogMessageOptions.html +1 -1
- package/docs/html/interfaces/utilities_log.LogMessageResourceOptions.html +1 -1
- package/docs/html/modules/utilities_arcade.html +6 -2
- package/docs/html/types/utilities_arcade.ArcadeVariable.html +39 -0
- package/docs/html/variables/version.version.html +1 -1
- package/package.json +1 -1
- package/utilities/arcade.d.ts +98 -4
- package/utilities/arcade.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/utilities/arcade.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type EsriMap from "@arcgis/core/Map";
|
|
2
|
+
import * as Arcade from "@arcgis/core/arcade.js";
|
|
2
3
|
import type SpatialReference from "@arcgis/core/geometry/SpatialReference";
|
|
3
4
|
import type Layer from "@arcgis/core/layers/Layer";
|
|
4
5
|
import type Sublayer from "@arcgis/core/layers/support/Sublayer";
|
|
5
6
|
import type { Feature } from "../data/Feature.js";
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* A custom Arcade variable value tagged with an explicit Arcade Variable type
|
|
9
|
+
* definition (excluding its `name`, which is inferred from its key in the
|
|
10
|
+
* `vars` object). Use this to attach values to the `vars` parameter of
|
|
11
|
+
* {@link runAsyncExpression} and {@link runSyncExpression} that are not plain
|
|
12
|
+
* JSON-compatible values (e.g. a FeatureSet, a Dictionary, or an Array of
|
|
13
|
+
* Features). Values in `vars` that are not created with this function are
|
|
14
|
+
* assumed to be plain JSON-compatible values and are declared using the "json"
|
|
15
|
+
* Arcade variable type.
|
|
16
|
+
*/
|
|
17
|
+
export type ArcadeVariable = {
|
|
18
|
+
value: unknown;
|
|
19
|
+
} & (Omit<Arcade.SimpleVariable, "name"> | Omit<Arcade.DictionaryVariable, "name"> | Omit<Arcade.ArrayVariable, "name">);
|
|
20
|
+
/**
|
|
21
|
+
* Parameters for the {@link runArcadeExpression}, {@link runSyncExpression},
|
|
22
|
+
* {@link runAsyncExpression}, and {@link runAsyncArcadeExpression} functions.
|
|
9
23
|
*/
|
|
10
24
|
export interface RunArcadeExpressionParams {
|
|
11
25
|
/**
|
|
@@ -28,27 +42,59 @@ export interface RunArcadeExpressionParams {
|
|
|
28
42
|
*/
|
|
29
43
|
layer?: Layer | Sublayer;
|
|
30
44
|
/**
|
|
31
|
-
* Additional Arcade arguments to attach to the script when run.
|
|
45
|
+
* Additional Arcade arguments to attach to the script when run. Values are
|
|
46
|
+
* assumed to be plain JSON-compatible values (declared using the "json"
|
|
47
|
+
* Arcade variable type) unless created with {@link toArcadeVariable} to
|
|
48
|
+
* specify an explicit Arcade variable type.
|
|
32
49
|
*/
|
|
33
50
|
vars?: Record<string, unknown>;
|
|
34
51
|
/**
|
|
35
52
|
* Emit an error when the script is missing referenced variables. Defaults
|
|
36
53
|
* to 'true'.
|
|
54
|
+
*
|
|
55
|
+
* @deprecated When using the {@link runAsyncExpression} or
|
|
56
|
+
* {@link runSyncExpression} function, this parameter is no longer used and
|
|
57
|
+
* the function will throw if any required parameters are missing.
|
|
37
58
|
*/
|
|
38
59
|
emitErrorOnMissingVariables?: boolean;
|
|
39
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates and returns an ArcadeExecutor object for the given expression. This
|
|
63
|
+
* should primarily be used for executing Arcade expressions in a sync context
|
|
64
|
+
* with {@link runSyncExpression}. If you are executing an expression in an async
|
|
65
|
+
* context, you should use the {@link runAsyncExpression} function instead. Sync
|
|
66
|
+
* Arcade expressions cannot be run without first creating an executor
|
|
67
|
+
* asynchronously.
|
|
68
|
+
*
|
|
69
|
+
* @param expression The Arcade expression string.
|
|
70
|
+
* @param profile The profile definition used to execute the given expression.
|
|
71
|
+
* If not provided, a generic profile with all primary variable types will be
|
|
72
|
+
* used.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createExecutorForExpression(expression: string, profile?: Arcade.Profile): Promise<Arcade.ArcadeExecutor>;
|
|
75
|
+
/**
|
|
76
|
+
* Detect if the arcade expression requires an async evaluation.
|
|
77
|
+
*
|
|
78
|
+
* @param expression The Arcade expression string.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isExpressionAsyncOnly(expression: string): Promise<boolean>;
|
|
40
81
|
/**
|
|
41
82
|
* Detect if the arcade expression requires an async evaluation.
|
|
42
83
|
*
|
|
84
|
+
* @deprecated Use {@link isExpressionAsyncOnly} instead. This function will be
|
|
85
|
+
* removed in a future release.
|
|
43
86
|
* @param expression The Arcade expression string.
|
|
44
87
|
* @param spatialReference Optionally the spatial reference for the expressions.
|
|
45
88
|
*/
|
|
46
89
|
export declare function isArcadeScriptAsync(expression: string, spatialReference?: SpatialReference): boolean;
|
|
47
90
|
/**
|
|
48
|
-
* Execute
|
|
91
|
+
* Execute a synchronous arcade expression string, and return the unformatted
|
|
49
92
|
* result. You must call 'enableGeometrySupport' prior to evaluating any
|
|
50
93
|
* expressions that might require the geometry engine.
|
|
51
94
|
*
|
|
95
|
+
* @deprecated Create an executor using {@link createExecutorForExpression} and
|
|
96
|
+
* then call {@link runSyncExpression} instead. This function will be removed
|
|
97
|
+
* in a future release.
|
|
52
98
|
* @param expression The arcade expression string.
|
|
53
99
|
* @param params The parameters.
|
|
54
100
|
*/
|
|
@@ -57,7 +103,55 @@ export declare function runArcadeExpression(expression: string, params: RunArcad
|
|
|
57
103
|
* Execute an asynchronous arcade expression string, and return the unformatted
|
|
58
104
|
* result.
|
|
59
105
|
*
|
|
106
|
+
* @deprecated Use runAsyncExpression instead. This function will be removed in
|
|
107
|
+
* a future release.
|
|
60
108
|
* @param expression The arcade expression string.
|
|
61
109
|
* @param params The parameters.
|
|
62
110
|
*/
|
|
63
111
|
export declare function runAsyncArcadeExpression(expression: string, params: RunArcadeExpressionParams): Promise<unknown>;
|
|
112
|
+
/**
|
|
113
|
+
* Execute a synchronous arcade expression string, and return the unformatted
|
|
114
|
+
* result.
|
|
115
|
+
*
|
|
116
|
+
* @param expression The arcade expression string.
|
|
117
|
+
* @param params The parameters.
|
|
118
|
+
* @param executor The ArcadeExecutor to use for executing the expression. The
|
|
119
|
+
* executor should be created using the {@link createExecutorForExpression}
|
|
120
|
+
* function.
|
|
121
|
+
*/
|
|
122
|
+
export declare function runSyncExpression(expression: string, params: RunArcadeExpressionParams, executor: Arcade.ArcadeExecutor): unknown;
|
|
123
|
+
/**
|
|
124
|
+
* Execute an asynchronous arcade expression string, and return the unformatted
|
|
125
|
+
* result.
|
|
126
|
+
*
|
|
127
|
+
* @param expression The arcade expression string.
|
|
128
|
+
* @param params The parameters.
|
|
129
|
+
*/
|
|
130
|
+
export declare function runAsyncExpression(expression: string, params: RunArcadeExpressionParams): Promise<unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* Constructs an Arcade profile based on the provided parameters.
|
|
133
|
+
*
|
|
134
|
+
* @param params The parameters.
|
|
135
|
+
*/
|
|
136
|
+
export declare function constructProfile(params: RunArcadeExpressionParams): Arcade.Profile;
|
|
137
|
+
/**
|
|
138
|
+
* Tags a value with an explicit Arcade Variable type definition so it can be
|
|
139
|
+
* passed through the `vars` parameter of {@link runAsyncExpression} and
|
|
140
|
+
* {@link runSyncExpression} without being assumed to be a plain JSON-compatible
|
|
141
|
+
* value.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```
|
|
145
|
+
* await runAsyncExpression("Count($features)", {
|
|
146
|
+
* vars: {
|
|
147
|
+
* $features: toArcadeVariable(featureSet, { type: "featureSet" }),
|
|
148
|
+
* },
|
|
149
|
+
* });
|
|
150
|
+
* ```;
|
|
151
|
+
*
|
|
152
|
+
* @param value The value of the variable.
|
|
153
|
+
* @param definition The Arcade variable type definition (excluding `name`) to
|
|
154
|
+
* declare the value as (e.g. `{ type: "featureSet" }` for a FeatureSet
|
|
155
|
+
* object).
|
|
156
|
+
*/
|
|
157
|
+
export declare function toArcadeVariable(value: unknown, definition: Omit<Arcade.SimpleVariable, "name"> | Omit<Arcade.DictionaryVariable, "name"> | Omit<Arcade.ArrayVariable, "name">): ArcadeVariable;
|
package/utilities/arcade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"@arcgis/core/arcade/arcade.js";import*as r from"@arcgis/core/support/arcadeUtils.js";import{checkArg as a}from"./checkArg.js";const
|
|
1
|
+
import*as e from"@arcgis/core/arcade/arcade.js";import*as r from"@arcgis/core/arcade.js";import*as t from"@arcgis/core/support/arcadeUtils.js";import{checkArg as a}from"./checkArg.js";const n=new Map,s=r.createArcadeCache(),o=["__proto__"],i={variables:[{name:"$feature",type:"feature"},{name:"$map",type:"featureSetCollection"},{name:"$layer",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$view",type:"featureSetCollection"}]};export async function createExecutorForExpression(e,t){return await r.createArcadeExecutor(e,t??i)}export async function isExpressionAsyncOnly(e){return(await createExecutorForExpression(e)).isAsync}export function isArcadeScriptAsync(r,a){const n=c(r,a);return["$datastore","$map","$layer"].some(e=>t.hasVariable(n,e))||e.scriptIsAsync({...n,isAsync:void 0,usesFeatureSet:void 0,usesGeometry:void 0},void 0)}export function runArcadeExpression(r,n){const{map:s,layer:o,vars:i,feature:p,spatialReference:u,emitErrorOnMissingVariables:f=!0}=n;a("$map and $layer parameters are not supported in synchronous arcade",n).satisfies(()=>!s&&!o);const l=t.getViewInfo({spatialReference:u}),y=t.createExecContext(p?.toGraphic(),l);if(i)for(const e of Object.keys(i))y.vars[e]=i[e];const m=c(r,u);if(t.hasVariable(m,"$feature"))if(f)a("params.feature",p).isNotMissing();else if(!p)return;return e.executeScript(m,y)}export async function runAsyncArcadeExpression(r,n){const{map:s,layer:o,vars:i,feature:p,spatialReference:u,emitErrorOnMissingVariables:f=!0}=n,l={...c(r,u)},y=["$datastore","$map","$layer"].filter(e=>t.hasVariable(l,e));await t.loadScriptDependencies(l,!0,y);const m=t.getViewInfo({spatialReference:u}),d=t.createExecContext(p?.toGraphic(),m);if(l.isAsync=!0,l.usesFeatureSet=!0,await Promise.all([e.enableAsyncSupport(),(async()=>{await import("@arcgis/core/arcade/functions/featuresetbase.js"),await e.enableFeatureSetSupport()})(),l.usesGeometry&&e.enableGeometrySupport()]),!t.hasVariable(l,"$feature")||(f&&a("params.feature",p).isNotMissing(),p)){if(y.includes("$map")){if(f&&a("params.map",s).isNotMissing(),!s)return;d.vars.$map=t.convertMapToFeatureSetCollection({map:s,spatialReference:u})}if(y.includes("$layer")){if(f&&a("params.layer",o).isNotMissing(),!o)return;d.vars.$layer=t.convertFeatureLayerToFeatureSet({layer:o,spatialReference:u})}if(y.includes("$datastore")){f&&a("params.layer",o).isNotMissing();const e=o?.url;if(!e)return;d.vars.$datastore=t.convertServiceUrlToWorkspace({url:e,spatialReference:u})}if(i)for(const e of Object.keys(i))d.vars[e]=i[e];return t.createFunction(l,d)(d)}}export function runSyncExpression(e,r,t){a("$map and $layer parameters are not supported in synchronous arcade",r).satisfies(()=>!r.map&&!r.layer);const n=p(e);if(n.length)throw new Error(`Invalid Arcade expression tokens: ${n.join()}`);const s=u(r),o=f(r);return t.execute(s,o)}export async function runAsyncExpression(e,r){const t=p(e);if(t.length)throw new Error(`Invalid Arcade expression tokens: ${t.join()}`);const a=constructProfile(r),n=u(r),s=f(r),o=await createExecutorForExpression(e,a);return await o.executeAsync(n,s)}export function constructProfile(e){const{feature:r,map:t,layer:a,vars:n}=e,s=[];if(n)for(const e of Object.keys(n)){const r=n[e];l(r)?s.push(y(e,r)):s.push({name:e,type:"json"})}return r&&s.push({name:"$feature",type:"feature"}),t&&s.push({name:"$map",type:"featureSetCollection"}),a&&(s.push({name:"$layer",type:"featureSet"}),s.push({name:"$datastore",type:"featureSetCollection"})),{variables:s}}export function toArcadeVariable(e,r){return{value:e,...r}}function c(r,t){const a=`${r}-${t?.wkid}`;if(n.has(a))return n.get(a);const s=p(r);if(s.length)throw new Error(`Invalid Arcade expression tokens: ${s.join()}`);const o=e.parseScript(r,t);return n.set(a,o),o}function p(e){return o.filter(r=>e.includes(r))}function u(e){const{feature:r,map:t,layer:a,vars:n}=e,s={};if(n)for(const e of Object.keys(n)){const r=n[e];s[e]=l(r)?r.value:r}return r&&(s.$feature=r.toGraphic()),t&&(s.$map=t),a&&(s.$layer=a,s.$datastore=a?.url),s}function f(e){const{spatialReference:r}=e;return{cache:s,spatialReference:r}}function l(e){return"object"==typeof e&&null!==e&&"value"in e&&"type"in e&&"string"==typeof e.type}function y(e,r){return"dictionary"===r.type?{name:e,type:"dictionary",properties:r.properties}:"array"===r.type?{name:e,type:"array",elementType:r.elementType}:{name:e,type:r.type}}
|
package/version.d.ts
CHANGED
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version="54.
|
|
1
|
+
export const version="54.15.0";
|