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

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-ef6982d2.js → p-21871ede.js} +1 -1
  4. package/dist/arcgis-coding-components/{p-0c2f4384.js → p-3b2457f7.js} +7 -7
  5. package/dist/arcgis-coding-components/{p-d07b6214.js → p-45b5bca3.js} +1 -1
  6. package/dist/arcgis-coding-components/{p-723fc69e.js → p-59247049.js} +1 -1
  7. package/dist/arcgis-coding-components/{p-a73841b8.js → p-6e1f1ee0.js} +1 -1
  8. package/dist/arcgis-coding-components/{p-0f636dd2.js → p-8010edc0.js} +1 -1
  9. package/dist/arcgis-coding-components/{p-03b0ec9a.js → p-9301388a.js} +1 -1
  10. package/dist/arcgis-coding-components/{p-8fb41167.entry.js → p-be5ec0c4.entry.js} +1 -1
  11. package/dist/arcgis-coding-components/{p-4f5314f5.js → p-c0bf49ad.js} +1 -1
  12. package/dist/arcgis-coding-components/{p-7416105e.js → p-ec3e9c42.js} +1 -1
  13. package/dist/cjs/{arcade-defaults-51a9667c.js → arcade-defaults-82737060.js} +114 -236
  14. package/dist/cjs/{arcade-mode-7705211c.js → arcade-mode-b21b24cc.js} +1 -1
  15. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +2 -2
  16. package/dist/cjs/{cssMode-1569c17b.js → cssMode-bc43621f.js} +1 -1
  17. package/dist/cjs/{html-198d0fbe.js → html-4a747b36.js} +1 -1
  18. package/dist/cjs/{htmlMode-cb94b682.js → htmlMode-c11513d8.js} +1 -1
  19. package/dist/cjs/index.cjs.js +1 -1
  20. package/dist/cjs/{javascript-c39cbb25.js → javascript-51f1b49d.js} +2 -2
  21. package/dist/cjs/{jsonMode-23c556fc.js → jsonMode-3985bbe9.js} +1 -1
  22. package/dist/cjs/{tsMode-f2bafe49.js → tsMode-b2b3fb82.js} +1 -1
  23. package/dist/cjs/{typescript-ee8ec13b.js → typescript-795a538e.js} +1 -1
  24. package/dist/components/arcade-defaults.js +108 -230
  25. package/dist/esm/{arcade-defaults-501b9076.js → arcade-defaults-375c8393.js} +114 -236
  26. package/dist/esm/{arcade-mode-f97a9a16.js → arcade-mode-2b1c4c38.js} +1 -1
  27. package/dist/esm/arcgis-arcade-api_6.entry.js +2 -2
  28. package/dist/esm/{cssMode-df00f38e.js → cssMode-2d3bbf6d.js} +1 -1
  29. package/dist/esm/{html-c506d52b.js → html-ba801b93.js} +1 -1
  30. package/dist/esm/{htmlMode-01fe416c.js → htmlMode-790fcdc3.js} +1 -1
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/{javascript-2d3d5417.js → javascript-10081345.js} +2 -2
  33. package/dist/esm/{jsonMode-a5223892.js → jsonMode-d6de3d90.js} +1 -1
  34. package/dist/esm/{tsMode-019f7ae9.js → tsMode-2efadb1a.js} +1 -1
  35. package/dist/esm/{typescript-dd5fb7df.js → typescript-534a4558.js} +1 -1
  36. package/dist/types/utils/profile/editor-profile.d.ts +5 -19
  37. package/dist/types/utils/profile/utils.d.ts +11 -15
  38. package/package.json +6 -6
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-ac186201.js');
6
- const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
6
+ const arcadeDefaults = require('./arcade-defaults-82737060.js');
7
7
 
8
8
  async function colorizeCode(code) {
9
9
  return await arcadeDefaults.editor.colorize(code, "arcade", { tabSize: 2 });
@@ -3019,7 +3019,7 @@ async function getArcadeWorker(uri) {
3019
3019
  * @returns mode for arcade
3020
3020
  */
3021
3021
  async function getMode() {
3022
- return await Promise.resolve().then(function () { return require('./arcade-mode-7705211c.js'); });
3022
+ return await Promise.resolve().then(function () { return require('./arcade-mode-b21b24cc.js'); });
3023
3023
  }
3024
3024
  // Register the language in Monaco
3025
3025
  arcadeDefaults.languages.register({
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const arcadeDefaults = require('./arcade-defaults-51a9667c.js');
3
+ const arcadeDefaults = require('./arcade-defaults-82737060.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-51a9667c.js');
3
+ const arcadeDefaults = require('./arcade-defaults-82737060.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-51a9667c.js');
3
+ const arcadeDefaults = require('./arcade-defaults-82737060.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-51a9667c.js');
5
+ const arcadeDefaults = require('./arcade-defaults-82737060.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-ee8ec13b.js');
4
- require('./arcade-defaults-51a9667c.js');
3
+ const typescript = require('./typescript-795a538e.js');
4
+ require('./arcade-defaults-82737060.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-51a9667c.js');
3
+ const arcadeDefaults = require('./arcade-defaults-82737060.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-51a9667c.js');
3
+ const arcadeDefaults = require('./arcade-defaults-82737060.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-51a9667c.js');
3
+ const arcadeDefaults = require('./arcade-defaults-82737060.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 { InsertTextMode, InsertTextFormat, CompletionItemKind } from 'vscode-languageserver-types';
2
+ import { CompletionItemKind, InsertTextMode, InsertTextFormat } 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,122 +21,87 @@ async function newWebMap(definition) {
21
21
  function isSupportedLayerInstance(item) {
22
22
  return (!!item &&
23
23
  typeof item === "object" &&
24
- "declaredClass" in item &&
25
24
  typeof item.declaredClass === "string" &&
26
25
  item.declaredClass.startsWith("esri.layers."));
27
26
  }
28
27
  function isFeatureSetInstance(item) {
29
28
  return (!!item &&
30
29
  typeof item === "object" &&
31
- "declaredClass" in item &&
32
30
  typeof item.declaredClass === "string" &&
33
31
  item.declaredClass === "esri.rest.support.FeatureSet");
34
32
  }
35
33
  function isQueryableLayerInstance(item) {
36
34
  return (!!item &&
37
35
  typeof item === "object" &&
38
- "declaredClass" in item &&
39
36
  typeof item.declaredClass === "string" &&
40
37
  item.declaredClass.startsWith("esri.layers.") &&
41
38
  "fields" in item &&
42
- "queryFeatures" in item &&
43
39
  typeof item.queryFeatures === "function");
44
40
  }
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
- }
52
41
  function isGroupLayerInstance(item) {
53
42
  return (!!item &&
54
43
  typeof item === "object" &&
55
- "declaredClass" in item &&
56
44
  typeof item.declaredClass === "string" &&
57
45
  item.declaredClass === "esri.layers.GroupLayer");
58
46
  }
59
47
  function isWebMapInstance(item) {
60
- return (!!item &&
61
- typeof item === "object" &&
62
- "declaredClass" in item &&
63
- typeof item.declaredClass === "string" &&
64
- item.declaredClass === "esri.WebMap");
48
+ return (!!item && typeof item === "object" && typeof item.declaredClass === "string" && item.declaredClass === "esri.WebMap");
65
49
  }
66
50
  function isPortalItemDefinition(item) {
67
- return !!item && typeof item === "object" && "portalItem" in item && item.portalItem != null;
51
+ return !!item && typeof item === "object" && item.portalItem != null;
68
52
  }
69
53
  function isFeatureLayerItemDefinition(item) {
70
- return !!item && typeof item === "object" && "portalItem" in item && item.portalItem != null;
54
+ return !!item && typeof item === "object" && item.portalItem != null;
71
55
  }
72
56
  function isFieldsDefinition(item) {
73
- return (!!item && typeof item === "object" && "fields" in item && Array.isArray(item.fields) && !("declaredClass" in item));
57
+ return !!item && typeof item === "object" && Array.isArray(item.fields) && !("declaredClass" in item);
74
58
  }
75
59
  function isUrlDefinition(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");
60
+ return !!item && typeof item === "object" && typeof item.url === "string" && !("declaredClass" in item);
95
61
  }
96
62
  function isPredefinedProfile(item) {
97
63
  return (!!item &&
98
64
  typeof item === "object" &&
99
- "id" in item &&
100
- "definitions" in item &&
101
65
  typeof item.id === "string" &&
102
66
  typeof item.definitions === "object" &&
103
67
  !Array.isArray(item.definitions));
104
68
  }
105
69
 
106
- function isTitleCapableSource(item) {
107
- return !!item && typeof item === "object" && "title" in item && typeof item.title === "string";
108
- }
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;
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;
117
83
  }
118
- function isSubtypesCapableLayer(item) {
119
- return !!item && typeof item === "object" && "subtypeField" in item && "subtypes" in item;
84
+ function isTypesCapabaleLayer(item) {
85
+ return !!item?.typeIdField;
120
86
  }
121
87
  function isDomainsCapableLayer(item) {
122
- return !!item && typeof item === "object" && "getFieldDomain" in item && typeof item.getFieldDomain === "function";
88
+ return typeof item?.getFieldDomain === "function";
123
89
  }
124
90
  function isRelationshipsCapableLayer(item) {
125
- return (isLayerIdCapableSource(item) &&
126
- "relationships" in item &&
127
- "url" in item &&
128
- Array.isArray(item.relationships) &&
129
- typeof item.url === "string");
91
+ return Array.isArray(item?.relationships) && typeof item?.url === "string";
130
92
  }
131
93
  function isTableCapableLayer(item) {
132
- return !!item && typeof item === "object" && "isTable" in item && typeof item.isTable === "boolean";
94
+ return typeof item?.isTable === "boolean";
133
95
  }
134
96
  function isLoadableSource(item) {
135
- return !!item && typeof item === "object" && "load" in item && typeof item.load === "function";
97
+ return typeof item?.load === "function";
136
98
  }
137
99
  //#endregion
138
100
  //#region Support Functions
139
101
  async function getRelatedFeatureLayer(layer, relationship) {
102
+ if (!relationship) {
103
+ return null;
104
+ }
140
105
  const relatedFeatureLayer = await newFeatureLayer({ url: `${layer.url}/${relationship.relatedTableId}` });
141
106
  await relatedFeatureLayer.load();
142
107
  return relatedFeatureLayer;
@@ -149,23 +114,7 @@ function sortFields(layer) {
149
114
  if (secondField.type === "oid") {
150
115
  return 1;
151
116
  }
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)) {
117
+ if (isTypesCapabaleLayer(layer)) {
169
118
  if (firstField.name === layer.typeIdField) {
170
119
  return -1;
171
120
  }
@@ -176,19 +125,20 @@ function sortFields(layer) {
176
125
  return firstField.name.localeCompare(secondField.name, "en", { sensitivity: "base" });
177
126
  };
178
127
  }
179
- function getTypeOrSubtypeDomainGroup(profile, types, field) {
128
+ function getSubtypesProperties(profile, types, field) {
180
129
  // Try the coded domain first
181
- if (isCodedValueDomainInstance(field.domain)) {
182
- return getCodedValueDomainGroup(profile, field.domain, { code: "subtypes" });
130
+ const group = getDomainValuesProperties(profile, field.domain, { code: "subtypes" });
131
+ if (group) {
132
+ return group;
183
133
  }
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
- });
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}"` }));
189
136
  return new GroupOfVariables(profile, { code: "subtypes" }, values);
190
137
  }
191
- function getCodedValueDomainGroup(profile, domain, label) {
138
+ function getDomainValuesProperties(profile, domain, label) {
139
+ if (!domain || domain.type !== "coded-value") {
140
+ return null;
141
+ }
192
142
  const values = domain.codedValues.map((v) => new ValueVariable({
193
143
  profile,
194
144
  label: `${v.code}`,
@@ -198,33 +148,29 @@ function getCodedValueDomainGroup(profile, domain, label) {
198
148
  }));
199
149
  return new GroupOfVariables(profile, label, values);
200
150
  }
201
- function getDomainValuesGroup(profile, types, field) {
151
+ function getDomainValuesBySubtypeGroup(profile, types, field) {
202
152
  const variables = [];
203
- if (types.length === 0) {
204
- return null;
205
- }
206
- types.forEach((type) => {
207
- let domain = type.domains[field.name];
153
+ types.forEach((t) => {
154
+ let domain = t.domains[field.name];
208
155
  if (!domain) {
209
156
  return;
210
157
  }
211
- if (isInheritedDomainInstance(domain)) {
158
+ if (domain.type === "inherited") {
212
159
  domain = field.domain;
213
160
  return;
214
161
  }
215
- if (!isCodedValueDomainInstance(domain)) {
216
- return;
217
- }
218
- const domainValuesGroup = getCodedValueDomainGroup(profile, domain, {
162
+ const domainValuesGroup = getDomainValuesProperties(profile, domain, {
219
163
  code: "domainvaluesfortypeformat",
220
164
  formatValues: {
221
165
  fieldName: field.alias ?? field.name,
222
- typeName: type.name
166
+ typeName: t.name
223
167
  }
224
168
  });
225
- const id = isSubtypeInstance(type) ? type.code : type.id;
226
- const label = `${id}`;
227
- const snippet = `"${id}""`;
169
+ if (!domainValuesGroup) {
170
+ return;
171
+ }
172
+ const label = `${t.id}`;
173
+ const snippet = `"${t.id}""`;
228
174
  const subtypeDictionary = new DictionaryVariable({ profile, label, snippet });
229
175
  subtypeDictionary.variables = [domainValuesGroup];
230
176
  variables.push(subtypeDictionary);
@@ -234,9 +180,6 @@ function getDomainValuesGroup(profile, types, field) {
234
180
  }
235
181
  return new GroupOfVariables(profile, { code: "domainvaluesbysubtypes" }, variables);
236
182
  }
237
- function areAllDomainsInherited(types, field) {
238
- return types.every((type) => type.domains[field.name].type === "inherited");
239
- }
240
183
  // const validIdentifierExpr = new RegExp(/^[a-z_$][\w$]*$/gi);
241
184
  const validIdentifierExpr = /^[a-z_$][a-z0-9_$]*$/giu;
242
185
  function getMemberExpressionProperty(prop, includeDot = true) {
@@ -264,6 +207,10 @@ async function supportedSourceFromDefinition(definition) {
264
207
  else {
265
208
  source = await newFeatureLayer(definition);
266
209
  }
210
+ if (!source) {
211
+ console.error("Invalid FeatureSetDefinition", definition);
212
+ return null;
213
+ }
267
214
  if (isLoadableSource(source)) {
268
215
  await source.load();
269
216
  }
@@ -299,7 +246,10 @@ function filterFeatureLayerInfos(layers, queryCapability) {
299
246
  //#endregion
300
247
  //#region Functions to Editor Variables to a language service variables
301
248
  async function variablesToLSVariable(editorVariables, kind = CompletionItemKind.Variable) {
302
- return await Promise.all(editorVariables.map(async (editorVariable) => {
249
+ if (!editorVariables) {
250
+ return [];
251
+ }
252
+ const properties = await Promise.all(editorVariables.map(async (editorVariable) => {
303
253
  switch (editorVariable.type) {
304
254
  case "dictionary":
305
255
  return await dictionaryToLSDictionary(editorVariable, kind);
@@ -309,6 +259,7 @@ async function variablesToLSVariable(editorVariables, kind = CompletionItemKind.
309
259
  return variableToLSVariable(editorVariable, kind);
310
260
  }
311
261
  }));
262
+ return properties.filter((p) => p);
312
263
  }
313
264
  function variableToLSVariable(editorVariable, kind) {
314
265
  const { name, type } = editorVariable;
@@ -426,7 +377,7 @@ async function dictionaryToLSDictionary(editorDictionary, kind) {
426
377
  previous += ` \n${description}`;
427
378
  }
428
379
  return previous;
429
- }, description);
380
+ }, description ?? "");
430
381
  return {
431
382
  name,
432
383
  description,
@@ -481,7 +432,7 @@ class ProfileItemBase {
481
432
  if (typeof this.description === "string") {
482
433
  return this.description;
483
434
  }
484
- return D(this._profile?.intlStrings[this.description.code], this.description.formatValues);
435
+ return D(this._profile?.intlStrings[this.description.code ?? ""], this.description.formatValues);
485
436
  }
486
437
  /**
487
438
  * Returns true if the item pass the filter test
@@ -504,7 +455,7 @@ class VariableBase extends ProfileItemBase {
504
455
  super(props.profile, props.label, props.description ?? props.declaration?.description);
505
456
  this.declaration = props.declaration ?? {};
506
457
  this.name = props.declaration?.name ?? "";
507
- this.snippet = props.snippet ?? "";
458
+ this.snippet = props.snippet || "";
508
459
  this.nonInteractive = props.nonInteractive ?? false;
509
460
  this.filterDescription = props.filterDescription ?? false;
510
461
  this.icon = props.icon;
@@ -522,7 +473,7 @@ class ValueVariable extends VariableBase {
522
473
  }
523
474
  getDescription() {
524
475
  if (this.description == null) {
525
- return this._profile?.intlStrings[this.type.toLowerCase()] ?? "";
476
+ return resolveIntlPath(this._profile?.intlStrings, this.type.toLowerCase()) ?? "";
526
477
  }
527
478
  return super.getDescription();
528
479
  }
@@ -543,7 +494,7 @@ class ArrayVariable extends VariableBase {
543
494
  }
544
495
  getDescription() {
545
496
  if (this.description == null) {
546
- return this._profile?.intlStrings[this.type.toLowerCase()] ?? "";
497
+ return resolveIntlPath(this._profile?.intlStrings, this.type.toLowerCase()) ?? "";
547
498
  }
548
499
  return super.getDescription();
549
500
  }
@@ -558,8 +509,8 @@ class ArrayVariable extends VariableBase {
558
509
  * collection is ready or not.
559
510
  */
560
511
  class CollectionBasedVariable extends VariableBase {
561
- constructor() {
562
- super(...arguments);
512
+ constructor(props) {
513
+ super(props);
563
514
  this.isCollection = true;
564
515
  this._loaded = true;
565
516
  /**
@@ -695,19 +646,21 @@ class SourceBasedVariable extends CollectionBasedVariable {
695
646
  this._definition = props.declaration?.definition;
696
647
  }
697
648
  get title() {
698
- return isTitleCapableSource(this._source) ? this._source.title : "";
649
+ return this._source?.title ?? "";
699
650
  }
700
651
  get url() {
701
- return isUrlCapableSource(this._source) ? this._source.url : "";
652
+ return this._definition?.url ?? "";
702
653
  }
703
654
  get informationUrl() {
704
655
  if (!this.loaded) {
705
656
  return null;
706
657
  }
707
- if (!this.url) {
658
+ const url = this._source?.url;
659
+ if (!url) {
708
660
  return null;
709
661
  }
710
- return isLayerIdCapableSource(this._source) ? `${this.url}/${this._source.layerId}` : this.url;
662
+ const layerId = this._source?.layerId ?? "";
663
+ return `${url}/${layerId}`;
711
664
  }
712
665
  get informationType() {
713
666
  return this._profile?.intlStrings.layer ?? "layer";
@@ -719,19 +672,16 @@ class SourceBasedVariable extends CollectionBasedVariable {
719
672
  this._loadPromise = this._loadSource();
720
673
  return await this._loadPromise;
721
674
  }
722
- _getValueSnippet(field) {
723
- return this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
724
- }
725
675
  _getFieldProperty(field) {
726
676
  // Check if the field is the type id field or of the field has a coded domain.
727
677
  // If it has then the property will be an exanpdable property (dictionary).
728
678
  // Otherwise just return a simple value property.
729
- const subtypesOrDomainValuesDictionary = this._getDomainDictionary(field);
679
+ const subtypesOrDomainValuesDictionary = this._getSubtypesOrDomainValuesDictionary(field);
730
680
  if (subtypesOrDomainValuesDictionary) {
731
681
  return subtypesOrDomainValuesDictionary;
732
682
  }
733
683
  // Create the value property
734
- const valueSnippet = this._getValueSnippet(field);
684
+ const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
735
685
  return new ValueVariable({
736
686
  profile: this._profile,
737
687
  label: valueSnippet,
@@ -741,113 +691,12 @@ class SourceBasedVariable extends CollectionBasedVariable {
741
691
  filterDescription: true
742
692
  });
743
693
  }
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
694
+ _getSubtypesOrDomainValuesDictionary(field) {
832
695
  if (!isDomainsCapableLayer(this._source)) {
833
696
  return null;
834
697
  }
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);
698
+ // Create the domain dictionary, we may not use it
699
+ const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
851
700
  const domainDictionary = new DictionaryVariable({
852
701
  profile: this._profile,
853
702
  label: valueSnippet,
@@ -865,7 +714,13 @@ class SourceBasedVariable extends CollectionBasedVariable {
865
714
  })
866
715
  ]);
867
716
  domainDictionary.variables = [headerGroup];
868
- // Add the DomainName snippet if the type is feature
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
869
724
  if (this.type === "feature") {
870
725
  const domainNameSnippet = `DomainName(${this.snippet}, "${field.name}")`;
871
726
  headerGroup.variables.push(new ValueVariable({
@@ -875,6 +730,29 @@ class SourceBasedVariable extends CollectionBasedVariable {
875
730
  snippet: domainNameSnippet
876
731
  }));
877
732
  }
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);
878
756
  return domainDictionary;
879
757
  }
880
758
  async _getRelationshipsProperty() {
@@ -1084,7 +962,7 @@ class FeatureSetCollectionVariable extends CollectionBasedVariable {
1084
962
  : {
1085
963
  code: "webmapformat",
1086
964
  formatValues: {
1087
- webMapTitle: this._featureSetCollections.source.portalItem.title || "Untitled map"
965
+ webMapTitle: this._featureSetCollections.source.portalItem.title ?? "Untitled map"
1088
966
  }
1089
967
  };
1090
968
  const headerGroup = new GroupOfVariables(this._profile, groupLabel, [