@arcgis/coding-components 4.28.0-beta.5 → 4.28.0-beta.6
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/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
- package/dist/arcgis-coding-components/p-93738c78.entry.js +1 -0
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +35 -40
- package/dist/components/arcade-results.js +32 -37
- package/dist/components/arcgis-arcade-editor.js +3 -3
- package/dist/esm/arcgis-arcade-api_6.entry.js +35 -40
- package/dist/types/utils/arcade-executor.d.ts +9 -8
- package/package.json +12 -12
- package/dist/arcgis-coding-components/p-84c74c0e.entry.js +0 -1
|
@@ -3215,57 +3215,57 @@ function isArcadeImmutableArray(value) {
|
|
|
3215
3215
|
}
|
|
3216
3216
|
function valueToArcadeResult(value) {
|
|
3217
3217
|
if (value == null || value === undefined) {
|
|
3218
|
-
return { type: "null"
|
|
3218
|
+
return { type: "null" };
|
|
3219
3219
|
}
|
|
3220
3220
|
if (Array.isArray(value)) {
|
|
3221
|
-
return { type: "array",
|
|
3221
|
+
return { type: "array", value };
|
|
3222
3222
|
}
|
|
3223
3223
|
if (isArcadeImmutableArray(value)) {
|
|
3224
|
-
return { type: "array",
|
|
3224
|
+
return { type: "array", value: value.toArray() };
|
|
3225
3225
|
}
|
|
3226
3226
|
if (value instanceof Date) {
|
|
3227
|
-
return { type: "date",
|
|
3227
|
+
return { type: "date", value };
|
|
3228
3228
|
}
|
|
3229
3229
|
if (typeof value === "string") {
|
|
3230
|
-
return { type: "text",
|
|
3230
|
+
return { type: "text", value };
|
|
3231
3231
|
}
|
|
3232
3232
|
if (typeof value === "number") {
|
|
3233
|
-
return { type: "number",
|
|
3233
|
+
return { type: "number", value };
|
|
3234
3234
|
}
|
|
3235
3235
|
if (typeof value === "boolean") {
|
|
3236
|
-
return { type: "boolean",
|
|
3236
|
+
return { type: "boolean", value };
|
|
3237
3237
|
}
|
|
3238
3238
|
if (typeof value !== "object") {
|
|
3239
|
-
return { type: "unknown"
|
|
3239
|
+
return { type: "unknown" };
|
|
3240
3240
|
}
|
|
3241
3241
|
if (isArcadeDate(value)) {
|
|
3242
|
-
return { type: "date",
|
|
3242
|
+
return { type: "date", value };
|
|
3243
3243
|
}
|
|
3244
3244
|
if (isArcadeDateOnly(value)) {
|
|
3245
|
-
return { type: "dateOnly",
|
|
3245
|
+
return { type: "dateOnly", value };
|
|
3246
3246
|
}
|
|
3247
3247
|
if (isArcadeTimeOnly(value)) {
|
|
3248
|
-
return { type: "time",
|
|
3248
|
+
return { type: "time", value };
|
|
3249
3249
|
}
|
|
3250
3250
|
if (isArcadeAttachment(value)) {
|
|
3251
|
-
return { type: "attachment",
|
|
3251
|
+
return { type: "attachment", value };
|
|
3252
3252
|
}
|
|
3253
3253
|
if (isArcadePortal(value)) {
|
|
3254
|
-
return { type: "portal",
|
|
3254
|
+
return { type: "portal", value };
|
|
3255
3255
|
}
|
|
3256
3256
|
if (isArcadeFeatureSet(value)) {
|
|
3257
|
-
return { type: "featureSet",
|
|
3257
|
+
return { type: "featureSet", value, features: [], iterator: null };
|
|
3258
3258
|
}
|
|
3259
3259
|
if (isArcadeFeature(value)) {
|
|
3260
|
-
return { type: "feature",
|
|
3260
|
+
return { type: "feature", value };
|
|
3261
3261
|
}
|
|
3262
3262
|
if (isArcadeDictionary(value)) {
|
|
3263
|
-
return { type: "dictionary",
|
|
3263
|
+
return { type: "dictionary", value };
|
|
3264
3264
|
}
|
|
3265
3265
|
if (isGeometry(value)) {
|
|
3266
|
-
return { type: "geometry",
|
|
3266
|
+
return { type: "geometry", value };
|
|
3267
3267
|
}
|
|
3268
|
-
return { type: "unknown"
|
|
3268
|
+
return { type: "unknown" };
|
|
3269
3269
|
}
|
|
3270
3270
|
function formatArcadeResultDate(dateObject, lang = "en") {
|
|
3271
3271
|
// Default to english
|
|
@@ -3283,13 +3283,7 @@ function formatArcadeResultDateOnly(dateObject) {
|
|
|
3283
3283
|
function formatArcadeResultTimeOnly(dateObject) {
|
|
3284
3284
|
return dateObject.value.toString();
|
|
3285
3285
|
}
|
|
3286
|
-
function
|
|
3287
|
-
if (field.type === "date" && typeof value === "number") {
|
|
3288
|
-
value = new Date(value);
|
|
3289
|
-
}
|
|
3290
|
-
return valueToArcadeResult(value);
|
|
3291
|
-
}
|
|
3292
|
-
async function loadArcadeResult(result) {
|
|
3286
|
+
async function loadArcadeResult(result, timeReference = { timeZone: "system" }) {
|
|
3293
3287
|
if (result.type !== "featureSet") {
|
|
3294
3288
|
return result;
|
|
3295
3289
|
}
|
|
@@ -3297,15 +3291,12 @@ async function loadArcadeResult(result) {
|
|
|
3297
3291
|
await result.value.load();
|
|
3298
3292
|
// Create the first iterator
|
|
3299
3293
|
result.iterator = result.value.iterator({ aborted: false });
|
|
3300
|
-
// Load the first batch of items
|
|
3301
|
-
result.features = await loadFeatureSetItems(result);
|
|
3302
|
-
return result;
|
|
3303
|
-
}
|
|
3304
|
-
async function loadFeatureSetItems(result) {
|
|
3305
3294
|
if (result.iterator == null) {
|
|
3306
|
-
return
|
|
3295
|
+
return result;
|
|
3307
3296
|
}
|
|
3308
|
-
|
|
3297
|
+
// Load the first batch of items
|
|
3298
|
+
result.features = (await result.iterator.nextBatchAsArcadeFeatures(BatchSize, timeReference)) ?? [];
|
|
3299
|
+
return result;
|
|
3309
3300
|
}
|
|
3310
3301
|
async function executeScript(editorProfile, script, testContext, console) {
|
|
3311
3302
|
//
|
|
@@ -3333,7 +3324,7 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3333
3324
|
// Execute the script
|
|
3334
3325
|
const scriptOutput = await executor.executeAsync(profileVariableInstances ?? {}, executeContext);
|
|
3335
3326
|
// Convert script output to arcade result object and load data if necessary
|
|
3336
|
-
const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput));
|
|
3327
|
+
const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput), timeReference);
|
|
3337
3328
|
// Timestamp and measure cost
|
|
3338
3329
|
scriptResult.timeStamp = timeStamp;
|
|
3339
3330
|
scriptResult.compilationTime = t1 - t0;
|
|
@@ -3348,7 +3339,6 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3348
3339
|
}
|
|
3349
3340
|
return {
|
|
3350
3341
|
type: "error",
|
|
3351
|
-
simpleType: false,
|
|
3352
3342
|
value: message,
|
|
3353
3343
|
error,
|
|
3354
3344
|
timeStamp: timeStamp,
|
|
@@ -3436,7 +3426,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3436
3426
|
}
|
|
3437
3427
|
const editorProfile = await this._editorProfilePromise;
|
|
3438
3428
|
if (!editorProfile) {
|
|
3439
|
-
this._executionResult = { type: "error", value: "Missing editor profile", error: null
|
|
3429
|
+
this._executionResult = { type: "error", value: "Missing editor profile", error: null };
|
|
3440
3430
|
return;
|
|
3441
3431
|
}
|
|
3442
3432
|
this._showExecutionPanel = true;
|
|
@@ -3543,11 +3533,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3543
3533
|
*/
|
|
3544
3534
|
async getTestResult() {
|
|
3545
3535
|
if (!this.testData) {
|
|
3546
|
-
return { type: "error", value: "Missing test data", error: null
|
|
3536
|
+
return { type: "error", value: "Missing test data", error: null };
|
|
3547
3537
|
}
|
|
3548
3538
|
const editorProfile = await this._editorProfilePromise;
|
|
3549
3539
|
if (!editorProfile) {
|
|
3550
|
-
return { type: "error", value: "Missing editor profile", error: null
|
|
3540
|
+
return { type: "error", value: "Missing editor profile", error: null };
|
|
3551
3541
|
}
|
|
3552
3542
|
await this._componentReadyDefer.promise;
|
|
3553
3543
|
const script = await this._codeEditorElt?.getValue();
|
|
@@ -3963,7 +3953,7 @@ const ArcgisArcadeResults = class {
|
|
|
3963
3953
|
return (index.h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, value.keys().map((key) => {
|
|
3964
3954
|
const arcadeValue = valueToArcadeResult(value.field(key));
|
|
3965
3955
|
return this.renderTreeItem(arcadeValue, key);
|
|
3966
|
-
}), geometry ? this.renderTreeItem({ type: "geometry",
|
|
3956
|
+
}), geometry ? this.renderTreeItem({ type: "geometry", value: geometry }, "geometry") : null));
|
|
3967
3957
|
}
|
|
3968
3958
|
renderTreeItem(arcadeResult, key, expanded = false) {
|
|
3969
3959
|
switch (arcadeResult.type) {
|
|
@@ -4002,8 +3992,13 @@ const ArcgisArcadeResults = class {
|
|
|
4002
3992
|
const fields = arcadeDefaults.supportedFields(arcadeResult.value.fields);
|
|
4003
3993
|
return (index.h("table", null, index.h("thead", null, index.h("tr", null, fields.map((field) => (index.h("th", null, field.name))))), index.h("tbody", null, arcadeResult.features.map((feature) => {
|
|
4004
3994
|
return (index.h("tr", null, fields.map((field) => {
|
|
4005
|
-
|
|
4006
|
-
|
|
3995
|
+
try {
|
|
3996
|
+
const arcadeResult = valueToArcadeResult(feature.field(field.name));
|
|
3997
|
+
return index.h("td", null, this.renderSimpleValue(arcadeResult));
|
|
3998
|
+
}
|
|
3999
|
+
catch (e) {
|
|
4000
|
+
return index.h("td", null);
|
|
4001
|
+
}
|
|
4007
4002
|
})));
|
|
4008
4003
|
}))));
|
|
4009
4004
|
}
|
|
@@ -56,57 +56,57 @@ function isArcadeImmutableArray(value) {
|
|
|
56
56
|
}
|
|
57
57
|
function valueToArcadeResult(value) {
|
|
58
58
|
if (value == null || value === undefined) {
|
|
59
|
-
return { type: "null"
|
|
59
|
+
return { type: "null" };
|
|
60
60
|
}
|
|
61
61
|
if (Array.isArray(value)) {
|
|
62
|
-
return { type: "array",
|
|
62
|
+
return { type: "array", value };
|
|
63
63
|
}
|
|
64
64
|
if (isArcadeImmutableArray(value)) {
|
|
65
|
-
return { type: "array",
|
|
65
|
+
return { type: "array", value: value.toArray() };
|
|
66
66
|
}
|
|
67
67
|
if (value instanceof Date) {
|
|
68
|
-
return { type: "date",
|
|
68
|
+
return { type: "date", value };
|
|
69
69
|
}
|
|
70
70
|
if (typeof value === "string") {
|
|
71
|
-
return { type: "text",
|
|
71
|
+
return { type: "text", value };
|
|
72
72
|
}
|
|
73
73
|
if (typeof value === "number") {
|
|
74
|
-
return { type: "number",
|
|
74
|
+
return { type: "number", value };
|
|
75
75
|
}
|
|
76
76
|
if (typeof value === "boolean") {
|
|
77
|
-
return { type: "boolean",
|
|
77
|
+
return { type: "boolean", value };
|
|
78
78
|
}
|
|
79
79
|
if (typeof value !== "object") {
|
|
80
|
-
return { type: "unknown"
|
|
80
|
+
return { type: "unknown" };
|
|
81
81
|
}
|
|
82
82
|
if (isArcadeDate(value)) {
|
|
83
|
-
return { type: "date",
|
|
83
|
+
return { type: "date", value };
|
|
84
84
|
}
|
|
85
85
|
if (isArcadeDateOnly(value)) {
|
|
86
|
-
return { type: "dateOnly",
|
|
86
|
+
return { type: "dateOnly", value };
|
|
87
87
|
}
|
|
88
88
|
if (isArcadeTimeOnly(value)) {
|
|
89
|
-
return { type: "time",
|
|
89
|
+
return { type: "time", value };
|
|
90
90
|
}
|
|
91
91
|
if (isArcadeAttachment(value)) {
|
|
92
|
-
return { type: "attachment",
|
|
92
|
+
return { type: "attachment", value };
|
|
93
93
|
}
|
|
94
94
|
if (isArcadePortal(value)) {
|
|
95
|
-
return { type: "portal",
|
|
95
|
+
return { type: "portal", value };
|
|
96
96
|
}
|
|
97
97
|
if (isArcadeFeatureSet(value)) {
|
|
98
|
-
return { type: "featureSet",
|
|
98
|
+
return { type: "featureSet", value, features: [], iterator: null };
|
|
99
99
|
}
|
|
100
100
|
if (isArcadeFeature(value)) {
|
|
101
|
-
return { type: "feature",
|
|
101
|
+
return { type: "feature", value };
|
|
102
102
|
}
|
|
103
103
|
if (isArcadeDictionary(value)) {
|
|
104
|
-
return { type: "dictionary",
|
|
104
|
+
return { type: "dictionary", value };
|
|
105
105
|
}
|
|
106
106
|
if (isGeometry(value)) {
|
|
107
|
-
return { type: "geometry",
|
|
107
|
+
return { type: "geometry", value };
|
|
108
108
|
}
|
|
109
|
-
return { type: "unknown"
|
|
109
|
+
return { type: "unknown" };
|
|
110
110
|
}
|
|
111
111
|
function formatArcadeResultDate(dateObject, lang = "en") {
|
|
112
112
|
// Default to english
|
|
@@ -124,13 +124,7 @@ function formatArcadeResultDateOnly(dateObject) {
|
|
|
124
124
|
function formatArcadeResultTimeOnly(dateObject) {
|
|
125
125
|
return dateObject.value.toString();
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
if (field.type === "date" && typeof value === "number") {
|
|
129
|
-
value = new Date(value);
|
|
130
|
-
}
|
|
131
|
-
return valueToArcadeResult(value);
|
|
132
|
-
}
|
|
133
|
-
async function loadArcadeResult(result) {
|
|
127
|
+
async function loadArcadeResult(result, timeReference = { timeZone: "system" }) {
|
|
134
128
|
if (result.type !== "featureSet") {
|
|
135
129
|
return result;
|
|
136
130
|
}
|
|
@@ -138,15 +132,12 @@ async function loadArcadeResult(result) {
|
|
|
138
132
|
await result.value.load();
|
|
139
133
|
// Create the first iterator
|
|
140
134
|
result.iterator = result.value.iterator({ aborted: false });
|
|
141
|
-
// Load the first batch of items
|
|
142
|
-
result.features = await loadFeatureSetItems(result);
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
async function loadFeatureSetItems(result) {
|
|
146
135
|
if (result.iterator == null) {
|
|
147
|
-
return
|
|
136
|
+
return result;
|
|
148
137
|
}
|
|
149
|
-
|
|
138
|
+
// Load the first batch of items
|
|
139
|
+
result.features = (await result.iterator.nextBatchAsArcadeFeatures(BatchSize, timeReference)) ?? [];
|
|
140
|
+
return result;
|
|
150
141
|
}
|
|
151
142
|
async function executeScript(editorProfile, script, testContext, console) {
|
|
152
143
|
//
|
|
@@ -174,7 +165,7 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
174
165
|
// Execute the script
|
|
175
166
|
const scriptOutput = await executor.executeAsync(profileVariableInstances ?? {}, executeContext);
|
|
176
167
|
// Convert script output to arcade result object and load data if necessary
|
|
177
|
-
const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput));
|
|
168
|
+
const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput), timeReference);
|
|
178
169
|
// Timestamp and measure cost
|
|
179
170
|
scriptResult.timeStamp = timeStamp;
|
|
180
171
|
scriptResult.compilationTime = t1 - t0;
|
|
@@ -189,7 +180,6 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
189
180
|
}
|
|
190
181
|
return {
|
|
191
182
|
type: "error",
|
|
192
|
-
simpleType: false,
|
|
193
183
|
value: message,
|
|
194
184
|
error,
|
|
195
185
|
timeStamp: timeStamp,
|
|
@@ -434,7 +424,7 @@ const ArcgisArcadeResults = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
434
424
|
return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, value.keys().map((key) => {
|
|
435
425
|
const arcadeValue = valueToArcadeResult(value.field(key));
|
|
436
426
|
return this.renderTreeItem(arcadeValue, key);
|
|
437
|
-
}), geometry ? this.renderTreeItem({ type: "geometry",
|
|
427
|
+
}), geometry ? this.renderTreeItem({ type: "geometry", value: geometry }, "geometry") : null));
|
|
438
428
|
}
|
|
439
429
|
renderTreeItem(arcadeResult, key, expanded = false) {
|
|
440
430
|
switch (arcadeResult.type) {
|
|
@@ -473,8 +463,13 @@ const ArcgisArcadeResults = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
473
463
|
const fields = supportedFields(arcadeResult.value.fields);
|
|
474
464
|
return (h("table", null, h("thead", null, h("tr", null, fields.map((field) => (h("th", null, field.name))))), h("tbody", null, arcadeResult.features.map((feature) => {
|
|
475
465
|
return (h("tr", null, fields.map((field) => {
|
|
476
|
-
|
|
477
|
-
|
|
466
|
+
try {
|
|
467
|
+
const arcadeResult = valueToArcadeResult(feature.field(field.name));
|
|
468
|
+
return h("td", null, this.renderSimpleValue(arcadeResult));
|
|
469
|
+
}
|
|
470
|
+
catch (e) {
|
|
471
|
+
return h("td", null);
|
|
472
|
+
}
|
|
478
473
|
})));
|
|
479
474
|
}))));
|
|
480
475
|
}
|
|
@@ -91,7 +91,7 @@ const ArcgisArcadeEditor$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
|
91
91
|
}
|
|
92
92
|
const editorProfile = await this._editorProfilePromise;
|
|
93
93
|
if (!editorProfile) {
|
|
94
|
-
this._executionResult = { type: "error", value: "Missing editor profile", error: null
|
|
94
|
+
this._executionResult = { type: "error", value: "Missing editor profile", error: null };
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
this._showExecutionPanel = true;
|
|
@@ -198,11 +198,11 @@ const ArcgisArcadeEditor$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
|
198
198
|
*/
|
|
199
199
|
async getTestResult() {
|
|
200
200
|
if (!this.testData) {
|
|
201
|
-
return { type: "error", value: "Missing test data", error: null
|
|
201
|
+
return { type: "error", value: "Missing test data", error: null };
|
|
202
202
|
}
|
|
203
203
|
const editorProfile = await this._editorProfilePromise;
|
|
204
204
|
if (!editorProfile) {
|
|
205
|
-
return { type: "error", value: "Missing editor profile", error: null
|
|
205
|
+
return { type: "error", value: "Missing editor profile", error: null };
|
|
206
206
|
}
|
|
207
207
|
await this._componentReadyDefer.promise;
|
|
208
208
|
const script = await this._codeEditorElt?.getValue();
|
|
@@ -3211,57 +3211,57 @@ function isArcadeImmutableArray(value) {
|
|
|
3211
3211
|
}
|
|
3212
3212
|
function valueToArcadeResult(value) {
|
|
3213
3213
|
if (value == null || value === undefined) {
|
|
3214
|
-
return { type: "null"
|
|
3214
|
+
return { type: "null" };
|
|
3215
3215
|
}
|
|
3216
3216
|
if (Array.isArray(value)) {
|
|
3217
|
-
return { type: "array",
|
|
3217
|
+
return { type: "array", value };
|
|
3218
3218
|
}
|
|
3219
3219
|
if (isArcadeImmutableArray(value)) {
|
|
3220
|
-
return { type: "array",
|
|
3220
|
+
return { type: "array", value: value.toArray() };
|
|
3221
3221
|
}
|
|
3222
3222
|
if (value instanceof Date) {
|
|
3223
|
-
return { type: "date",
|
|
3223
|
+
return { type: "date", value };
|
|
3224
3224
|
}
|
|
3225
3225
|
if (typeof value === "string") {
|
|
3226
|
-
return { type: "text",
|
|
3226
|
+
return { type: "text", value };
|
|
3227
3227
|
}
|
|
3228
3228
|
if (typeof value === "number") {
|
|
3229
|
-
return { type: "number",
|
|
3229
|
+
return { type: "number", value };
|
|
3230
3230
|
}
|
|
3231
3231
|
if (typeof value === "boolean") {
|
|
3232
|
-
return { type: "boolean",
|
|
3232
|
+
return { type: "boolean", value };
|
|
3233
3233
|
}
|
|
3234
3234
|
if (typeof value !== "object") {
|
|
3235
|
-
return { type: "unknown"
|
|
3235
|
+
return { type: "unknown" };
|
|
3236
3236
|
}
|
|
3237
3237
|
if (isArcadeDate(value)) {
|
|
3238
|
-
return { type: "date",
|
|
3238
|
+
return { type: "date", value };
|
|
3239
3239
|
}
|
|
3240
3240
|
if (isArcadeDateOnly(value)) {
|
|
3241
|
-
return { type: "dateOnly",
|
|
3241
|
+
return { type: "dateOnly", value };
|
|
3242
3242
|
}
|
|
3243
3243
|
if (isArcadeTimeOnly(value)) {
|
|
3244
|
-
return { type: "time",
|
|
3244
|
+
return { type: "time", value };
|
|
3245
3245
|
}
|
|
3246
3246
|
if (isArcadeAttachment(value)) {
|
|
3247
|
-
return { type: "attachment",
|
|
3247
|
+
return { type: "attachment", value };
|
|
3248
3248
|
}
|
|
3249
3249
|
if (isArcadePortal(value)) {
|
|
3250
|
-
return { type: "portal",
|
|
3250
|
+
return { type: "portal", value };
|
|
3251
3251
|
}
|
|
3252
3252
|
if (isArcadeFeatureSet(value)) {
|
|
3253
|
-
return { type: "featureSet",
|
|
3253
|
+
return { type: "featureSet", value, features: [], iterator: null };
|
|
3254
3254
|
}
|
|
3255
3255
|
if (isArcadeFeature(value)) {
|
|
3256
|
-
return { type: "feature",
|
|
3256
|
+
return { type: "feature", value };
|
|
3257
3257
|
}
|
|
3258
3258
|
if (isArcadeDictionary(value)) {
|
|
3259
|
-
return { type: "dictionary",
|
|
3259
|
+
return { type: "dictionary", value };
|
|
3260
3260
|
}
|
|
3261
3261
|
if (isGeometry(value)) {
|
|
3262
|
-
return { type: "geometry",
|
|
3262
|
+
return { type: "geometry", value };
|
|
3263
3263
|
}
|
|
3264
|
-
return { type: "unknown"
|
|
3264
|
+
return { type: "unknown" };
|
|
3265
3265
|
}
|
|
3266
3266
|
function formatArcadeResultDate(dateObject, lang = "en") {
|
|
3267
3267
|
// Default to english
|
|
@@ -3279,13 +3279,7 @@ function formatArcadeResultDateOnly(dateObject) {
|
|
|
3279
3279
|
function formatArcadeResultTimeOnly(dateObject) {
|
|
3280
3280
|
return dateObject.value.toString();
|
|
3281
3281
|
}
|
|
3282
|
-
function
|
|
3283
|
-
if (field.type === "date" && typeof value === "number") {
|
|
3284
|
-
value = new Date(value);
|
|
3285
|
-
}
|
|
3286
|
-
return valueToArcadeResult(value);
|
|
3287
|
-
}
|
|
3288
|
-
async function loadArcadeResult(result) {
|
|
3282
|
+
async function loadArcadeResult(result, timeReference = { timeZone: "system" }) {
|
|
3289
3283
|
if (result.type !== "featureSet") {
|
|
3290
3284
|
return result;
|
|
3291
3285
|
}
|
|
@@ -3293,15 +3287,12 @@ async function loadArcadeResult(result) {
|
|
|
3293
3287
|
await result.value.load();
|
|
3294
3288
|
// Create the first iterator
|
|
3295
3289
|
result.iterator = result.value.iterator({ aborted: false });
|
|
3296
|
-
// Load the first batch of items
|
|
3297
|
-
result.features = await loadFeatureSetItems(result);
|
|
3298
|
-
return result;
|
|
3299
|
-
}
|
|
3300
|
-
async function loadFeatureSetItems(result) {
|
|
3301
3290
|
if (result.iterator == null) {
|
|
3302
|
-
return
|
|
3291
|
+
return result;
|
|
3303
3292
|
}
|
|
3304
|
-
|
|
3293
|
+
// Load the first batch of items
|
|
3294
|
+
result.features = (await result.iterator.nextBatchAsArcadeFeatures(BatchSize, timeReference)) ?? [];
|
|
3295
|
+
return result;
|
|
3305
3296
|
}
|
|
3306
3297
|
async function executeScript(editorProfile, script, testContext, console) {
|
|
3307
3298
|
//
|
|
@@ -3329,7 +3320,7 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3329
3320
|
// Execute the script
|
|
3330
3321
|
const scriptOutput = await executor.executeAsync(profileVariableInstances ?? {}, executeContext);
|
|
3331
3322
|
// Convert script output to arcade result object and load data if necessary
|
|
3332
|
-
const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput));
|
|
3323
|
+
const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput), timeReference);
|
|
3333
3324
|
// Timestamp and measure cost
|
|
3334
3325
|
scriptResult.timeStamp = timeStamp;
|
|
3335
3326
|
scriptResult.compilationTime = t1 - t0;
|
|
@@ -3344,7 +3335,6 @@ async function executeScript(editorProfile, script, testContext, console) {
|
|
|
3344
3335
|
}
|
|
3345
3336
|
return {
|
|
3346
3337
|
type: "error",
|
|
3347
|
-
simpleType: false,
|
|
3348
3338
|
value: message,
|
|
3349
3339
|
error,
|
|
3350
3340
|
timeStamp: timeStamp,
|
|
@@ -3432,7 +3422,7 @@ const ArcgisArcadeEditor = class {
|
|
|
3432
3422
|
}
|
|
3433
3423
|
const editorProfile = await this._editorProfilePromise;
|
|
3434
3424
|
if (!editorProfile) {
|
|
3435
|
-
this._executionResult = { type: "error", value: "Missing editor profile", error: null
|
|
3425
|
+
this._executionResult = { type: "error", value: "Missing editor profile", error: null };
|
|
3436
3426
|
return;
|
|
3437
3427
|
}
|
|
3438
3428
|
this._showExecutionPanel = true;
|
|
@@ -3539,11 +3529,11 @@ const ArcgisArcadeEditor = class {
|
|
|
3539
3529
|
*/
|
|
3540
3530
|
async getTestResult() {
|
|
3541
3531
|
if (!this.testData) {
|
|
3542
|
-
return { type: "error", value: "Missing test data", error: null
|
|
3532
|
+
return { type: "error", value: "Missing test data", error: null };
|
|
3543
3533
|
}
|
|
3544
3534
|
const editorProfile = await this._editorProfilePromise;
|
|
3545
3535
|
if (!editorProfile) {
|
|
3546
|
-
return { type: "error", value: "Missing editor profile", error: null
|
|
3536
|
+
return { type: "error", value: "Missing editor profile", error: null };
|
|
3547
3537
|
}
|
|
3548
3538
|
await this._componentReadyDefer.promise;
|
|
3549
3539
|
const script = await this._codeEditorElt?.getValue();
|
|
@@ -3959,7 +3949,7 @@ const ArcgisArcadeResults = class {
|
|
|
3959
3949
|
return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, value.keys().map((key) => {
|
|
3960
3950
|
const arcadeValue = valueToArcadeResult(value.field(key));
|
|
3961
3951
|
return this.renderTreeItem(arcadeValue, key);
|
|
3962
|
-
}), geometry ? this.renderTreeItem({ type: "geometry",
|
|
3952
|
+
}), geometry ? this.renderTreeItem({ type: "geometry", value: geometry }, "geometry") : null));
|
|
3963
3953
|
}
|
|
3964
3954
|
renderTreeItem(arcadeResult, key, expanded = false) {
|
|
3965
3955
|
switch (arcadeResult.type) {
|
|
@@ -3998,8 +3988,13 @@ const ArcgisArcadeResults = class {
|
|
|
3998
3988
|
const fields = supportedFields(arcadeResult.value.fields);
|
|
3999
3989
|
return (h("table", null, h("thead", null, h("tr", null, fields.map((field) => (h("th", null, field.name))))), h("tbody", null, arcadeResult.features.map((feature) => {
|
|
4000
3990
|
return (h("tr", null, fields.map((field) => {
|
|
4001
|
-
|
|
4002
|
-
|
|
3991
|
+
try {
|
|
3992
|
+
const arcadeResult = valueToArcadeResult(feature.field(field.name));
|
|
3993
|
+
return h("td", null, this.renderSimpleValue(arcadeResult));
|
|
3994
|
+
}
|
|
3995
|
+
catch (e) {
|
|
3996
|
+
return h("td", null);
|
|
3997
|
+
}
|
|
4003
3998
|
})));
|
|
4004
3999
|
}))));
|
|
4005
4000
|
}
|
|
@@ -4,6 +4,12 @@ import type { IEditorProfileDefinition } from "./profile/types";
|
|
|
4
4
|
* The key's value must be of type ArcGIS core ProfileVariableInstanceType.
|
|
5
5
|
*/
|
|
6
6
|
export type ProfileVariableInstances = Record<string, __esri.ProfileVariableInstanceType>;
|
|
7
|
+
/**
|
|
8
|
+
* An object that represents a time reference.
|
|
9
|
+
*/
|
|
10
|
+
export interface IEditorTimeReference {
|
|
11
|
+
timeZone: string;
|
|
12
|
+
}
|
|
7
13
|
/**
|
|
8
14
|
* If a profile doesn't contain a map, the spatial reference of geometries will be defaulted to
|
|
9
15
|
* wkid: 3857.
|
|
@@ -26,9 +32,7 @@ export interface IEditorTestContext {
|
|
|
26
32
|
* Defines the default time reference in which to create and display Arcade date types.
|
|
27
33
|
* By default, the time zone is set to "system".
|
|
28
34
|
*/
|
|
29
|
-
timeReference?:
|
|
30
|
-
timeZone: string;
|
|
31
|
-
};
|
|
35
|
+
timeReference?: IEditorTimeReference;
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* @deprecated Use IEditorTestContext instead.
|
|
@@ -52,7 +56,7 @@ export interface IArcadeRuntimeFeatureSet {
|
|
|
52
56
|
iterator(abortSignal: IAbortSignal): IArcadeRuntimeFeatureSetIterator;
|
|
53
57
|
}
|
|
54
58
|
export interface IArcadeRuntimeFeatureSetIterator {
|
|
55
|
-
|
|
59
|
+
nextBatchAsArcadeFeatures(bsize: number, timeReference: IEditorTimeReference): Promise<IArcadeRuntimeDictionary[] | null>;
|
|
56
60
|
}
|
|
57
61
|
export interface IArcadeRuntimeDate {
|
|
58
62
|
declaredRootClass: string;
|
|
@@ -76,7 +80,6 @@ export interface IArcadeRuntimeTimeOnly {
|
|
|
76
80
|
export type ResultType = "unknown" | "error" | "null" | "array" | "date" | "dateOnly" | "time" | "text" | "number" | "boolean" | "dictionary" | "geometry" | "attachment" | "feature" | "featureSet" | "portal";
|
|
77
81
|
interface IArcadeResultBase {
|
|
78
82
|
type: ResultType;
|
|
79
|
-
simpleType: boolean;
|
|
80
83
|
timeStamp?: Date;
|
|
81
84
|
compilationTime?: number;
|
|
82
85
|
executionTime?: number;
|
|
@@ -91,7 +94,6 @@ export interface IArcadeResultError extends IArcadeResultBase {
|
|
|
91
94
|
type: "error";
|
|
92
95
|
value: string;
|
|
93
96
|
error: any;
|
|
94
|
-
simpleType: false;
|
|
95
97
|
}
|
|
96
98
|
export interface IArcadeResultArray extends IArcadeResultBase {
|
|
97
99
|
type: "array";
|
|
@@ -137,7 +139,7 @@ export interface IArcadeResultFeatureSet extends IArcadeResultBase {
|
|
|
137
139
|
type: "featureSet";
|
|
138
140
|
value: IArcadeRuntimeFeatureSet;
|
|
139
141
|
iterator: IArcadeRuntimeFeatureSetIterator | null;
|
|
140
|
-
features:
|
|
142
|
+
features: IArcadeRuntimeDictionary[];
|
|
141
143
|
}
|
|
142
144
|
export interface IArcadeResultPortal extends IArcadeResultBase {
|
|
143
145
|
type: "portal";
|
|
@@ -152,6 +154,5 @@ export declare function valueToArcadeResult(value: unknown): ArcadeResult;
|
|
|
152
154
|
export declare function formatArcadeResultDate(dateObject: IArcadeResultDate, lang?: string): string;
|
|
153
155
|
export declare function formatArcadeResultDateOnly(dateObject: IArcadeResultDateOnly): string;
|
|
154
156
|
export declare function formatArcadeResultTimeOnly(dateObject: IArcadeResultTimeOnly): string;
|
|
155
|
-
export declare function fieldValueToArcadeResult(field: __esri.Field, value: unknown): ArcadeResult;
|
|
156
157
|
export declare function executeScript(editorProfile: IEditorProfileDefinition | undefined, script: string | undefined, testContext: IEditorTestContext, console?: (log: string) => void): Promise<ArcadeResult>;
|
|
157
158
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/coding-components",
|
|
3
3
|
"description": "Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.",
|
|
4
|
-
"version": "4.28.0-beta.
|
|
4
|
+
"version": "4.28.0-beta.6",
|
|
5
5
|
"module": "dist/components/index.js",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -50,25 +50,25 @@
|
|
|
50
50
|
"prettier": "prettier . --write"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@arcgis/arcade-languageservice": "4.28.0-beta.
|
|
53
|
+
"@arcgis/arcade-languageservice": "4.28.0-beta.6",
|
|
54
54
|
"@esri/calcite-components": "^1.8.0",
|
|
55
55
|
"@stencil/core": "2.22.3",
|
|
56
56
|
"monaco-editor": "^0.39.0",
|
|
57
57
|
"vscode-languageserver-types": "^3.17.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@arcgis/components-plugins": "4.28.0-beta.
|
|
61
|
-
"@arcgis/components-utils": "4.28.0-beta.
|
|
60
|
+
"@arcgis/components-plugins": "4.28.0-beta.6",
|
|
61
|
+
"@arcgis/components-utils": "4.28.0-beta.6",
|
|
62
62
|
"@arcgis/core": ">=4.28.0-next <4.29",
|
|
63
|
-
"@arcgis/core-adapter": "4.28.0-beta.
|
|
63
|
+
"@arcgis/core-adapter": "4.28.0-beta.6",
|
|
64
64
|
"@arcgis/eslint-config": "1.0.0",
|
|
65
65
|
"@arcgis/typescript-config": "1.0.0",
|
|
66
66
|
"@stencil/sass": "^2.0.4",
|
|
67
|
-
"@storybook/addon-a11y": "^7.4.
|
|
68
|
-
"@storybook/addon-essentials": "^7.4.
|
|
69
|
-
"@storybook/addon-links": "^7.4.
|
|
70
|
-
"@storybook/web-components": "^7.4.
|
|
71
|
-
"@storybook/web-components-vite": "^7.4.
|
|
67
|
+
"@storybook/addon-a11y": "^7.4.5",
|
|
68
|
+
"@storybook/addon-essentials": "^7.4.5",
|
|
69
|
+
"@storybook/addon-links": "^7.4.5",
|
|
70
|
+
"@storybook/web-components": "^7.4.5",
|
|
71
|
+
"@storybook/web-components-vite": "^7.4.5",
|
|
72
72
|
"@types/estraverse": "^5.1.2",
|
|
73
73
|
"@types/estree": "^1.0.0",
|
|
74
74
|
"@types/fs-extra": "^11.0.1",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"rollup": "^3.25.0",
|
|
103
103
|
"rollup-plugin-import-css": "^3.1.0",
|
|
104
104
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
105
|
-
"storybook": "^7.4.
|
|
105
|
+
"storybook": "^7.4.5",
|
|
106
106
|
"ts-node": "^10.9.1",
|
|
107
107
|
"typescript": "4.9.5",
|
|
108
108
|
"vite": "^4.4.9",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"peerDependencies": {
|
|
113
113
|
"@arcgis/core": ">=4.28.0-next <4.29"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "5d458acf1958bd1a7ab664804153cd4c64a6af36"
|
|
116
116
|
}
|