@arcgis/coding-components 4.29.0-beta.67 → 4.29.0-beta.69

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.
Files changed (38) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
  2. package/dist/arcgis-coding-components/index.esm.js +1 -1
  3. package/dist/arcgis-coding-components/{p-9301388a.js → p-03b0ec9a.js} +1 -1
  4. package/dist/arcgis-coding-components/{p-3b2457f7.js → p-0c2f4384.js} +7 -7
  5. package/dist/arcgis-coding-components/{p-8010edc0.js → p-0f636dd2.js} +1 -1
  6. package/dist/arcgis-coding-components/{p-c0bf49ad.js → p-4f5314f5.js} +1 -1
  7. package/dist/arcgis-coding-components/{p-59247049.js → p-723fc69e.js} +1 -1
  8. package/dist/arcgis-coding-components/{p-ec3e9c42.js → p-7416105e.js} +1 -1
  9. package/dist/arcgis-coding-components/{p-be5ec0c4.entry.js → p-8fb41167.entry.js} +1 -1
  10. package/dist/arcgis-coding-components/{p-6e1f1ee0.js → p-a73841b8.js} +1 -1
  11. package/dist/arcgis-coding-components/{p-45b5bca3.js → p-d07b6214.js} +1 -1
  12. package/dist/arcgis-coding-components/{p-21871ede.js → p-ef6982d2.js} +1 -1
  13. package/dist/cjs/{arcade-defaults-82737060.js → arcade-defaults-51a9667c.js} +236 -114
  14. package/dist/cjs/{arcade-mode-b21b24cc.js → arcade-mode-7705211c.js} +1 -1
  15. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +2 -2
  16. package/dist/cjs/{cssMode-bc43621f.js → cssMode-1569c17b.js} +1 -1
  17. package/dist/cjs/{html-4a747b36.js → html-198d0fbe.js} +1 -1
  18. package/dist/cjs/{htmlMode-c11513d8.js → htmlMode-cb94b682.js} +1 -1
  19. package/dist/cjs/index.cjs.js +1 -1
  20. package/dist/cjs/{javascript-51f1b49d.js → javascript-c39cbb25.js} +2 -2
  21. package/dist/cjs/{jsonMode-3985bbe9.js → jsonMode-23c556fc.js} +1 -1
  22. package/dist/cjs/{tsMode-b2b3fb82.js → tsMode-f2bafe49.js} +1 -1
  23. package/dist/cjs/{typescript-795a538e.js → typescript-ee8ec13b.js} +1 -1
  24. package/dist/components/arcade-defaults.js +230 -108
  25. package/dist/esm/{arcade-defaults-375c8393.js → arcade-defaults-501b9076.js} +236 -114
  26. package/dist/esm/{arcade-mode-2b1c4c38.js → arcade-mode-f97a9a16.js} +1 -1
  27. package/dist/esm/arcgis-arcade-api_6.entry.js +2 -2
  28. package/dist/esm/{cssMode-2d3bbf6d.js → cssMode-df00f38e.js} +1 -1
  29. package/dist/esm/{html-ba801b93.js → html-c506d52b.js} +1 -1
  30. package/dist/esm/{htmlMode-790fcdc3.js → htmlMode-01fe416c.js} +1 -1
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/{javascript-10081345.js → javascript-2d3d5417.js} +2 -2
  33. package/dist/esm/{jsonMode-d6de3d90.js → jsonMode-a5223892.js} +1 -1
  34. package/dist/esm/{tsMode-2efadb1a.js → tsMode-019f7ae9.js} +1 -1
  35. package/dist/esm/{typescript-534a4558.js → typescript-dd5fb7df.js} +1 -1
  36. package/dist/types/utils/profile/editor-profile.d.ts +19 -5
  37. package/dist/types/utils/profile/utils.d.ts +15 -11
  38. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
3
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
4
4
  require('./index-ac186201.js');
5
5
 
6
6
  /*!-----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
3
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
4
4
  require('./index-ac186201.js');
5
5
 
6
6
  /*!-----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
3
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
4
4
  require('./index-ac186201.js');
5
5
 
6
6
  /*!-----------------------------------------------------------------------------
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
5
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
6
6
  require('./index-ac186201.js');
7
7
 
8
8
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const typescript = require('./typescript-795a538e.js');
4
- require('./arcade-defaults-82737060.js');
3
+ const typescript = require('./typescript-ee8ec13b.js');
4
+ require('./arcade-defaults-51a9667c.js');
5
5
  require('./index-ac186201.js');
6
6
 
7
7
  /*!-----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
3
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
4
4
  require('./index-ac186201.js');
5
5
 
6
6
  /*!-----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
3
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
4
4
  require('./index-ac186201.js');
5
5
 
6
6
  /*!-----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-82737060.js');
3
+ const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
4
4
  require('./index-ac186201.js');
5
5
 
6
6
  /*!-----------------------------------------------------------------------------
@@ -1,5 +1,5 @@
1
1
  import { Emitter, Uri } from 'monaco-editor';
2
- import { CompletionItemKind, InsertTextMode, InsertTextFormat } from 'vscode-languageserver-types';
2
+ import { InsertTextMode, InsertTextFormat, CompletionItemKind } from 'vscode-languageserver-types';
3
3
  import { i as importPortalPortalItem, a as importLayersFeatureLayer, b as importWebMap, s as supportedFields, c as importRequest, f as fieldTypeToIconName, d as fieldTypeToArcadeType } from './fields.js';
4
4
  import { p as portalItemPageUrl } from './utilities.js';
5
5
  import { V, X, G, D, E, N } from './index2.js';
@@ -21,87 +21,122 @@ async function newWebMap(definition) {
21
21
  function isSupportedLayerInstance(item) {
22
22
  return (!!item &&
23
23
  typeof item === "object" &&
24
+ "declaredClass" in item &&
24
25
  typeof item.declaredClass === "string" &&
25
26
  item.declaredClass.startsWith("esri.layers."));
26
27
  }
27
28
  function isFeatureSetInstance(item) {
28
29
  return (!!item &&
29
30
  typeof item === "object" &&
31
+ "declaredClass" in item &&
30
32
  typeof item.declaredClass === "string" &&
31
33
  item.declaredClass === "esri.rest.support.FeatureSet");
32
34
  }
33
35
  function isQueryableLayerInstance(item) {
34
36
  return (!!item &&
35
37
  typeof item === "object" &&
38
+ "declaredClass" in item &&
36
39
  typeof item.declaredClass === "string" &&
37
40
  item.declaredClass.startsWith("esri.layers.") &&
38
41
  "fields" in item &&
42
+ "queryFeatures" in item &&
39
43
  typeof item.queryFeatures === "function");
40
44
  }
45
+ function isSubtypeSublayerInstance(item) {
46
+ return (!!item &&
47
+ typeof item === "object" &&
48
+ "declaredClass" in item &&
49
+ typeof item.declaredClass === "string" &&
50
+ item.declaredClass === "esri.layers.support.SubtypeSublayer");
51
+ }
41
52
  function isGroupLayerInstance(item) {
42
53
  return (!!item &&
43
54
  typeof item === "object" &&
55
+ "declaredClass" in item &&
44
56
  typeof item.declaredClass === "string" &&
45
57
  item.declaredClass === "esri.layers.GroupLayer");
46
58
  }
47
59
  function isWebMapInstance(item) {
48
- return (!!item && typeof item === "object" && typeof item.declaredClass === "string" && item.declaredClass === "esri.WebMap");
60
+ return (!!item &&
61
+ typeof item === "object" &&
62
+ "declaredClass" in item &&
63
+ typeof item.declaredClass === "string" &&
64
+ item.declaredClass === "esri.WebMap");
49
65
  }
50
66
  function isPortalItemDefinition(item) {
51
- return !!item && typeof item === "object" && item.portalItem != null;
67
+ return !!item && typeof item === "object" && "portalItem" in item && item.portalItem != null;
52
68
  }
53
69
  function isFeatureLayerItemDefinition(item) {
54
- return !!item && typeof item === "object" && item.portalItem != null;
70
+ return !!item && typeof item === "object" && "portalItem" in item && item.portalItem != null;
55
71
  }
56
72
  function isFieldsDefinition(item) {
57
- return !!item && typeof item === "object" && Array.isArray(item.fields) && !("declaredClass" in item);
73
+ return (!!item && typeof item === "object" && "fields" in item && Array.isArray(item.fields) && !("declaredClass" in item));
58
74
  }
59
75
  function isUrlDefinition(item) {
60
- return !!item && typeof item === "object" && typeof item.url === "string" && !("declaredClass" in item);
76
+ return (!!item && typeof item === "object" && "url" in item && typeof item.url === "string" && !("declaredClass" in item));
77
+ }
78
+ function isSubtypeInstance(item) {
79
+ return (!!item &&
80
+ typeof item === "object" &&
81
+ "declaredClass" in item &&
82
+ item.declaredClass === "esri.layers.support.Subtype");
83
+ }
84
+ function isCodedValueDomainInstance(item) {
85
+ return (!!item &&
86
+ typeof item === "object" &&
87
+ "declaredClass" in item &&
88
+ item.declaredClass === "esri.layers.support.CodedValueDomain");
89
+ }
90
+ function isInheritedDomainInstance(item) {
91
+ return (!!item &&
92
+ typeof item === "object" &&
93
+ "declaredClass" in item &&
94
+ item.declaredClass === "esri.layers.support.InheritedDomain");
61
95
  }
62
96
  function isPredefinedProfile(item) {
63
97
  return (!!item &&
64
98
  typeof item === "object" &&
99
+ "id" in item &&
100
+ "definitions" in item &&
65
101
  typeof item.id === "string" &&
66
102
  typeof item.definitions === "object" &&
67
103
  !Array.isArray(item.definitions));
68
104
  }
69
105
 
70
- function resolveIntlPath(dictionary, path) {
71
- if (!dictionary) {
72
- return "";
73
- }
74
- const pathSegments = path.split(".");
75
- let pathSegment = pathSegments.shift();
76
- let entry = dictionary;
77
- while (entry && pathSegment) {
78
- // @ts-expect-error
79
- entry = entry[pathSegment];
80
- pathSegment = pathSegments.shift();
81
- }
82
- return typeof entry === "string" ? entry : path;
106
+ function isTitleCapableSource(item) {
107
+ return !!item && typeof item === "object" && "title" in item && typeof item.title === "string";
83
108
  }
84
- function isTypesCapabaleLayer(item) {
85
- return !!item?.typeIdField;
109
+ function isUrlCapableSource(item) {
110
+ return !!item && typeof item === "object" && "url" in item && typeof item.url === "string";
111
+ }
112
+ function isLayerIdCapableSource(item) {
113
+ return !!item && typeof item === "object" && "layerId" in item && typeof item.layerId === "number";
114
+ }
115
+ function isFeatureTypesCapableLayer(item) {
116
+ return !!item && typeof item === "object" && "typeIdField" in item && "types" in item;
117
+ }
118
+ function isSubtypesCapableLayer(item) {
119
+ return !!item && typeof item === "object" && "subtypeField" in item && "subtypes" in item;
86
120
  }
87
121
  function isDomainsCapableLayer(item) {
88
- return typeof item?.getFieldDomain === "function";
122
+ return !!item && typeof item === "object" && "getFieldDomain" in item && typeof item.getFieldDomain === "function";
89
123
  }
90
124
  function isRelationshipsCapableLayer(item) {
91
- return Array.isArray(item?.relationships) && typeof item?.url === "string";
125
+ return (isLayerIdCapableSource(item) &&
126
+ "relationships" in item &&
127
+ "url" in item &&
128
+ Array.isArray(item.relationships) &&
129
+ typeof item.url === "string");
92
130
  }
93
131
  function isTableCapableLayer(item) {
94
- return typeof item?.isTable === "boolean";
132
+ return !!item && typeof item === "object" && "isTable" in item && typeof item.isTable === "boolean";
95
133
  }
96
134
  function isLoadableSource(item) {
97
- return typeof item?.load === "function";
135
+ return !!item && typeof item === "object" && "load" in item && typeof item.load === "function";
98
136
  }
99
137
  //#endregion
100
138
  //#region Support Functions
101
139
  async function getRelatedFeatureLayer(layer, relationship) {
102
- if (!relationship) {
103
- return null;
104
- }
105
140
  const relatedFeatureLayer = await newFeatureLayer({ url: `${layer.url}/${relationship.relatedTableId}` });
106
141
  await relatedFeatureLayer.load();
107
142
  return relatedFeatureLayer;
@@ -114,7 +149,23 @@ function sortFields(layer) {
114
149
  if (secondField.type === "oid") {
115
150
  return 1;
116
151
  }
117
- if (isTypesCapabaleLayer(layer)) {
152
+ if (isSubtypeSublayerInstance(layer)) {
153
+ if (firstField.name === layer.parent.subtypeField) {
154
+ return -1;
155
+ }
156
+ if (secondField.name === layer.parent.subtypeField) {
157
+ return 1;
158
+ }
159
+ }
160
+ if (isSubtypesCapableLayer(layer)) {
161
+ if (firstField.name === layer.subtypeField) {
162
+ return -1;
163
+ }
164
+ if (secondField.name === layer.subtypeField) {
165
+ return 1;
166
+ }
167
+ }
168
+ if (isFeatureTypesCapableLayer(layer)) {
118
169
  if (firstField.name === layer.typeIdField) {
119
170
  return -1;
120
171
  }
@@ -125,20 +176,19 @@ function sortFields(layer) {
125
176
  return firstField.name.localeCompare(secondField.name, "en", { sensitivity: "base" });
126
177
  };
127
178
  }
128
- function getSubtypesProperties(profile, types, field) {
179
+ function getTypeOrSubtypeDomainGroup(profile, types, field) {
129
180
  // Try the coded domain first
130
- const group = getDomainValuesProperties(profile, field.domain, { code: "subtypes" });
131
- if (group) {
132
- return group;
181
+ if (isCodedValueDomainInstance(field.domain)) {
182
+ return getCodedValueDomainGroup(profile, field.domain, { code: "subtypes" });
133
183
  }
134
- // No coded domain for the subtypes, we will manufacture it
135
- const values = types.map((t) => new ValueVariable({ profile, label: `${t.id}`, description: t.name, snippet: `"${t.id}"` }));
184
+ // No coded domain, we will manufacture it
185
+ const values = types.map((t) => {
186
+ const label = isSubtypeInstance(t) ? t.code : t.id;
187
+ return new ValueVariable({ profile, label: `${label}`, description: t.name, snippet: `"${label}"` });
188
+ });
136
189
  return new GroupOfVariables(profile, { code: "subtypes" }, values);
137
190
  }
138
- function getDomainValuesProperties(profile, domain, label) {
139
- if (!domain || domain.type !== "coded-value") {
140
- return null;
141
- }
191
+ function getCodedValueDomainGroup(profile, domain, label) {
142
192
  const values = domain.codedValues.map((v) => new ValueVariable({
143
193
  profile,
144
194
  label: `${v.code}`,
@@ -148,29 +198,33 @@ function getDomainValuesProperties(profile, domain, label) {
148
198
  }));
149
199
  return new GroupOfVariables(profile, label, values);
150
200
  }
151
- function getDomainValuesBySubtypeGroup(profile, types, field) {
201
+ function getDomainValuesGroup(profile, types, field) {
152
202
  const variables = [];
153
- types.forEach((t) => {
154
- let domain = t.domains[field.name];
203
+ if (types.length === 0) {
204
+ return null;
205
+ }
206
+ types.forEach((type) => {
207
+ let domain = type.domains[field.name];
155
208
  if (!domain) {
156
209
  return;
157
210
  }
158
- if (domain.type === "inherited") {
211
+ if (isInheritedDomainInstance(domain)) {
159
212
  domain = field.domain;
160
213
  return;
161
214
  }
162
- const domainValuesGroup = getDomainValuesProperties(profile, domain, {
215
+ if (!isCodedValueDomainInstance(domain)) {
216
+ return;
217
+ }
218
+ const domainValuesGroup = getCodedValueDomainGroup(profile, domain, {
163
219
  code: "domainvaluesfortypeformat",
164
220
  formatValues: {
165
221
  fieldName: field.alias ?? field.name,
166
- typeName: t.name
222
+ typeName: type.name
167
223
  }
168
224
  });
169
- if (!domainValuesGroup) {
170
- return;
171
- }
172
- const label = `${t.id}`;
173
- const snippet = `"${t.id}""`;
225
+ const id = isSubtypeInstance(type) ? type.code : type.id;
226
+ const label = `${id}`;
227
+ const snippet = `"${id}""`;
174
228
  const subtypeDictionary = new DictionaryVariable({ profile, label, snippet });
175
229
  subtypeDictionary.variables = [domainValuesGroup];
176
230
  variables.push(subtypeDictionary);
@@ -180,6 +234,9 @@ function getDomainValuesBySubtypeGroup(profile, types, field) {
180
234
  }
181
235
  return new GroupOfVariables(profile, { code: "domainvaluesbysubtypes" }, variables);
182
236
  }
237
+ function areAllDomainsInherited(types, field) {
238
+ return types.every((type) => type.domains[field.name].type === "inherited");
239
+ }
183
240
  // const validIdentifierExpr = new RegExp(/^[a-z_$][\w$]*$/gi);
184
241
  const validIdentifierExpr = /^[a-z_$][a-z0-9_$]*$/giu;
185
242
  function getMemberExpressionProperty(prop, includeDot = true) {
@@ -207,10 +264,6 @@ async function supportedSourceFromDefinition(definition) {
207
264
  else {
208
265
  source = await newFeatureLayer(definition);
209
266
  }
210
- if (!source) {
211
- console.error("Invalid FeatureSetDefinition", definition);
212
- return null;
213
- }
214
267
  if (isLoadableSource(source)) {
215
268
  await source.load();
216
269
  }
@@ -246,10 +299,7 @@ function filterFeatureLayerInfos(layers, queryCapability) {
246
299
  //#endregion
247
300
  //#region Functions to Editor Variables to a language service variables
248
301
  async function variablesToLSVariable(editorVariables, kind = CompletionItemKind.Variable) {
249
- if (!editorVariables) {
250
- return [];
251
- }
252
- const properties = await Promise.all(editorVariables.map(async (editorVariable) => {
302
+ return await Promise.all(editorVariables.map(async (editorVariable) => {
253
303
  switch (editorVariable.type) {
254
304
  case "dictionary":
255
305
  return await dictionaryToLSDictionary(editorVariable, kind);
@@ -259,7 +309,6 @@ async function variablesToLSVariable(editorVariables, kind = CompletionItemKind.
259
309
  return variableToLSVariable(editorVariable, kind);
260
310
  }
261
311
  }));
262
- return properties.filter((p) => p);
263
312
  }
264
313
  function variableToLSVariable(editorVariable, kind) {
265
314
  const { name, type } = editorVariable;
@@ -377,7 +426,7 @@ async function dictionaryToLSDictionary(editorDictionary, kind) {
377
426
  previous += ` \n${description}`;
378
427
  }
379
428
  return previous;
380
- }, description ?? "");
429
+ }, description);
381
430
  return {
382
431
  name,
383
432
  description,
@@ -432,7 +481,7 @@ class ProfileItemBase {
432
481
  if (typeof this.description === "string") {
433
482
  return this.description;
434
483
  }
435
- return D(this._profile?.intlStrings[this.description.code ?? ""], this.description.formatValues);
484
+ return D(this._profile?.intlStrings[this.description.code], this.description.formatValues);
436
485
  }
437
486
  /**
438
487
  * Returns true if the item pass the filter test
@@ -455,7 +504,7 @@ class VariableBase extends ProfileItemBase {
455
504
  super(props.profile, props.label, props.description ?? props.declaration?.description);
456
505
  this.declaration = props.declaration ?? {};
457
506
  this.name = props.declaration?.name ?? "";
458
- this.snippet = props.snippet || "";
507
+ this.snippet = props.snippet ?? "";
459
508
  this.nonInteractive = props.nonInteractive ?? false;
460
509
  this.filterDescription = props.filterDescription ?? false;
461
510
  this.icon = props.icon;
@@ -473,7 +522,7 @@ class ValueVariable extends VariableBase {
473
522
  }
474
523
  getDescription() {
475
524
  if (this.description == null) {
476
- return resolveIntlPath(this._profile?.intlStrings, this.type.toLowerCase()) ?? "";
525
+ return this._profile?.intlStrings[this.type.toLowerCase()] ?? "";
477
526
  }
478
527
  return super.getDescription();
479
528
  }
@@ -494,7 +543,7 @@ class ArrayVariable extends VariableBase {
494
543
  }
495
544
  getDescription() {
496
545
  if (this.description == null) {
497
- return resolveIntlPath(this._profile?.intlStrings, this.type.toLowerCase()) ?? "";
546
+ return this._profile?.intlStrings[this.type.toLowerCase()] ?? "";
498
547
  }
499
548
  return super.getDescription();
500
549
  }
@@ -509,8 +558,8 @@ class ArrayVariable extends VariableBase {
509
558
  * collection is ready or not.
510
559
  */
511
560
  class CollectionBasedVariable extends VariableBase {
512
- constructor(props) {
513
- super(props);
561
+ constructor() {
562
+ super(...arguments);
514
563
  this.isCollection = true;
515
564
  this._loaded = true;
516
565
  /**
@@ -646,21 +695,19 @@ class SourceBasedVariable extends CollectionBasedVariable {
646
695
  this._definition = props.declaration?.definition;
647
696
  }
648
697
  get title() {
649
- return this._source?.title ?? "";
698
+ return isTitleCapableSource(this._source) ? this._source.title : "";
650
699
  }
651
700
  get url() {
652
- return this._definition?.url ?? "";
701
+ return isUrlCapableSource(this._source) ? this._source.url : "";
653
702
  }
654
703
  get informationUrl() {
655
704
  if (!this.loaded) {
656
705
  return null;
657
706
  }
658
- const url = this._source?.url;
659
- if (!url) {
707
+ if (!this.url) {
660
708
  return null;
661
709
  }
662
- const layerId = this._source?.layerId ?? "";
663
- return `${url}/${layerId}`;
710
+ return isLayerIdCapableSource(this._source) ? `${this.url}/${this._source.layerId}` : this.url;
664
711
  }
665
712
  get informationType() {
666
713
  return this._profile?.intlStrings.layer ?? "layer";
@@ -672,16 +719,19 @@ class SourceBasedVariable extends CollectionBasedVariable {
672
719
  this._loadPromise = this._loadSource();
673
720
  return await this._loadPromise;
674
721
  }
722
+ _getValueSnippet(field) {
723
+ return this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
724
+ }
675
725
  _getFieldProperty(field) {
676
726
  // Check if the field is the type id field or of the field has a coded domain.
677
727
  // If it has then the property will be an exanpdable property (dictionary).
678
728
  // Otherwise just return a simple value property.
679
- const subtypesOrDomainValuesDictionary = this._getSubtypesOrDomainValuesDictionary(field);
729
+ const subtypesOrDomainValuesDictionary = this._getDomainDictionary(field);
680
730
  if (subtypesOrDomainValuesDictionary) {
681
731
  return subtypesOrDomainValuesDictionary;
682
732
  }
683
733
  // Create the value property
684
- const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
734
+ const valueSnippet = this._getValueSnippet(field);
685
735
  return new ValueVariable({
686
736
  profile: this._profile,
687
737
  label: valueSnippet,
@@ -691,12 +741,113 @@ class SourceBasedVariable extends CollectionBasedVariable {
691
741
  filterDescription: true
692
742
  });
693
743
  }
694
- _getSubtypesOrDomainValuesDictionary(field) {
744
+ get _domainSource() {
745
+ if (isSubtypeSublayerInstance(this._source)) {
746
+ return this._source.parent;
747
+ }
748
+ return isDomainsCapableLayer(this._source) ? this._source : null;
749
+ }
750
+ _getDomainDictionary(field) {
751
+ if (!isDomainsCapableLayer(this._domainSource)) {
752
+ return null;
753
+ }
754
+ // Note we have multiple scenarios:
755
+ // - Layers without subtypes or feature types: We will check if the field has a domain
756
+ // - Layers with only subtypes: We will parse the subtypes metadata and create a dictionary
757
+ // - Layers with only feature types: We will parse the feature types metadata
758
+ // - Layers with both subtypes and feature types: we will actually use the subtypes metadata
759
+ // Summary, we will always use the subtypes metadata if available.
760
+ if (isSubtypesCapableLayer(this._domainSource)) {
761
+ return this._getSubtypeDomainDictionary(field);
762
+ }
763
+ if (isFeatureTypesCapableLayer(this._domainSource)) {
764
+ return this._getFeatureTypeDomainDictionary(field);
765
+ }
766
+ return this._getFieldDomainDictionary(field);
767
+ }
768
+ _getSubtypeDomainDictionary(field) {
769
+ // SHould be tested before calling this function
770
+ if (!isSubtypesCapableLayer(this._domainSource)) {
771
+ return null;
772
+ }
773
+ // If the source is the subtype sublayer then the subtype value is already set.
774
+ // It doesn't make sense to show the subtypes for the subtype field.
775
+ // For the other field, the getFieldDomain will return the domain for the subtype.
776
+ if (isSubtypeSublayerInstance(this._source)) {
777
+ if (field.name === this._domainSource.subtypeField) {
778
+ return null;
779
+ }
780
+ return this._getFieldDomainDictionary(field);
781
+ }
782
+ // The code here shoud be executed for layers that have subtypes but are not subtype sublayers.
783
+ // Sepcial case for the subtype field
784
+ if (field.name === this._domainSource.subtypeField) {
785
+ const domainDictionary = this._createDomainDictionary(field);
786
+ domainDictionary.variables.push(getTypeOrSubtypeDomainGroup(this._profile, this._domainSource.subtypes, field));
787
+ return domainDictionary;
788
+ }
789
+ // Check if all the domains for the field in the types are inherited.
790
+ // If it is we can simplify the structure by avoiding splitting in subtypes
791
+ if (areAllDomainsInherited(this._domainSource.subtypes, field)) {
792
+ return this._getFieldDomainDictionary(field);
793
+ }
794
+ // We have domains per subtype
795
+ // We need to go thru each types and create a dictionary.
796
+ const domainValuesBySubtypeGroup = getDomainValuesGroup(this._profile, this._domainSource.subtypes, field);
797
+ if (!domainValuesBySubtypeGroup) {
798
+ return null;
799
+ }
800
+ const domainDictionary = this._createDomainDictionary(field);
801
+ domainDictionary.variables.push(domainValuesBySubtypeGroup);
802
+ return domainDictionary;
803
+ }
804
+ _getFeatureTypeDomainDictionary(field) {
805
+ // SHould be tested before calling this function
806
+ if (!isFeatureTypesCapableLayer(this._domainSource)) {
807
+ return null;
808
+ }
809
+ // Special case for the type id field
810
+ if (field.name === this._domainSource.typeIdField) {
811
+ const domainDictionary = this._createDomainDictionary(field);
812
+ domainDictionary.variables.push(getTypeOrSubtypeDomainGroup(this._profile, this._domainSource.types, field));
813
+ return domainDictionary;
814
+ }
815
+ // Check if all the domains for the field in the types are inherited.
816
+ // If it is we can simplify the structure by avoiding splitting in subtypes
817
+ if (areAllDomainsInherited(this._domainSource.types, field)) {
818
+ return this._getFieldDomainDictionary(field);
819
+ }
820
+ // We have domains per feature type
821
+ // We need to go thru each types and create a dictionary.
822
+ const domainValuesByFeatureTypeGroup = getDomainValuesGroup(this._profile, this._domainSource.types, field);
823
+ if (!domainValuesByFeatureTypeGroup) {
824
+ return null;
825
+ }
826
+ const domainDictionary = this._createDomainDictionary(field);
827
+ domainDictionary.variables.push(domainValuesByFeatureTypeGroup);
828
+ return domainDictionary;
829
+ }
830
+ _getFieldDomainDictionary(field) {
831
+ // SHould be tested before calling this function
695
832
  if (!isDomainsCapableLayer(this._source)) {
696
833
  return null;
697
834
  }
698
- // Create the domain dictionary, we may not use it
699
- const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
835
+ const fieldDomain = this._source.getFieldDomain(field.name);
836
+ if (!isCodedValueDomainInstance(fieldDomain)) {
837
+ return null;
838
+ }
839
+ const domainValuesGroup = getCodedValueDomainGroup(this._profile, fieldDomain, {
840
+ code: "domainvalues"
841
+ });
842
+ const domainDictionary = this._createDomainDictionary(field);
843
+ domainDictionary.variables.push(domainValuesGroup);
844
+ return domainDictionary;
845
+ }
846
+ _createDomainDictionary(field) {
847
+ // Create the domain dictionary.
848
+ // The dictionary will have a header group and a value group.
849
+ // At this point we are only creating the header group in the dictionary.
850
+ const valueSnippet = this._getValueSnippet(field);
700
851
  const domainDictionary = new DictionaryVariable({
701
852
  profile: this._profile,
702
853
  label: valueSnippet,
@@ -714,13 +865,7 @@ class SourceBasedVariable extends CollectionBasedVariable {
714
865
  })
715
866
  ]);
716
867
  domainDictionary.variables = [headerGroup];
717
- // If it is the subtype field then get its coded domain values
718
- if (isTypesCapabaleLayer(this._source) && field.name === this._source.typeIdField) {
719
- const subtypesGroup = getSubtypesProperties(this._profile, this._source.types, field);
720
- domainDictionary.variables.push(subtypesGroup);
721
- return domainDictionary;
722
- }
723
- // Since its' not the subtype field then add the snippet for the domain name
868
+ // Add the DomainName snippet if the type is feature
724
869
  if (this.type === "feature") {
725
870
  const domainNameSnippet = `DomainName(${this.snippet}, "${field.name}")`;
726
871
  headerGroup.variables.push(new ValueVariable({
@@ -730,29 +875,6 @@ class SourceBasedVariable extends CollectionBasedVariable {
730
875
  snippet: domainNameSnippet
731
876
  }));
732
877
  }
733
- if (isTypesCapabaleLayer(this._source)) {
734
- // Check if all the domains for the field in the types are inherited.
735
- // If it is we can simplify the structure by avoiding splitting in subtypes
736
- const allInherited = this._source.types.every((t) => t.domains[field.name].type === "inherited");
737
- if (!allInherited) {
738
- // We have domains per subtype
739
- // We need to go thru each types and create a dictionary.
740
- const domainValuesBySubtypeGroup = getDomainValuesBySubtypeGroup(this._profile, this._source.types, field);
741
- if (!domainValuesBySubtypeGroup) {
742
- return null;
743
- }
744
- domainDictionary.variables.push(domainValuesBySubtypeGroup);
745
- return domainDictionary;
746
- }
747
- }
748
- // Either we have types but all the domains are inherited or we don't have types
749
- const domainValuesGroup = getDomainValuesProperties(this._profile, this._source.getFieldDomain(field.name), {
750
- code: "domainvalues"
751
- });
752
- if (!domainValuesGroup) {
753
- return null;
754
- }
755
- domainDictionary.variables.push(domainValuesGroup);
756
878
  return domainDictionary;
757
879
  }
758
880
  async _getRelationshipsProperty() {
@@ -962,7 +1084,7 @@ class FeatureSetCollectionVariable extends CollectionBasedVariable {
962
1084
  : {
963
1085
  code: "webmapformat",
964
1086
  formatValues: {
965
- webMapTitle: this._featureSetCollections.source.portalItem.title ?? "Untitled map"
1087
+ webMapTitle: this._featureSetCollections.source.portalItem.title || "Untitled map"
966
1088
  }
967
1089
  };
968
1090
  const headerGroup = new GroupOfVariables(this._profile, groupLabel, [