@arcgis/coding-components 4.31.0-next.76 → 4.31.0-next.78

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 (147) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
  2. package/dist/arcgis-coding-components/assets/code-editor/sql-expr.worker.js +76 -76
  3. package/dist/arcgis-coding-components/index.esm.js +2 -2
  4. package/dist/arcgis-coding-components/{p-4a93290a.js → p-39f82bdf.js} +10 -10
  5. package/dist/arcgis-coding-components/{p-d935b67b.js → p-3e9138d1.js} +2 -2
  6. package/dist/arcgis-coding-components/{p-a2fbd2d7.js → p-56b9a46b.js} +2 -2
  7. package/dist/arcgis-coding-components/{p-159d7e28.js → p-65fac2a2.js} +1 -1
  8. package/dist/arcgis-coding-components/p-6c02d087.js +6 -0
  9. package/dist/arcgis-coding-components/p-75194595.entry.js +6 -0
  10. package/dist/arcgis-coding-components/{p-a1648fd9.js → p-768bbd21.js} +1 -1
  11. package/dist/arcgis-coding-components/{p-53ef9d57.js → p-783b5f57.js} +1 -1
  12. package/dist/arcgis-coding-components/p-7a683b74.entry.js +6 -0
  13. package/dist/arcgis-coding-components/{p-aea8a9ae.js → p-856489e5.js} +2 -2
  14. package/dist/arcgis-coding-components/{p-1c00cf80.js → p-8afa5752.js} +2 -2
  15. package/dist/arcgis-coding-components/{p-8c475464.js → p-8d86a470.js} +2 -2
  16. package/dist/arcgis-coding-components/{p-c9b15662.js → p-a0d7e57e.js} +2 -2
  17. package/dist/arcgis-coding-components/{p-0bd6b819.entry.js → p-c2881d0b.entry.js} +2 -2
  18. package/dist/arcgis-coding-components/{p-1b9499a9.js → p-cae88f7a.js} +2 -2
  19. package/dist/arcgis-coding-components/{p-0f01b138.js → p-d4a2c779.js} +2 -2
  20. package/dist/arcgis-coding-components/{p-521f0e06.js → p-df53ceb3.js} +2 -2
  21. package/dist/arcgis-coding-components/{p-d7e32d38.js → p-f191d5c4.js} +2 -2
  22. package/dist/cjs/{app-globals-fe7e6b36.js → app-globals-36508d17.js} +1 -1
  23. package/dist/cjs/{arcade-defaults-085b41a2.js → arcade-defaults-3ba38e64.js} +3 -3
  24. package/dist/cjs/{arcade-mode-0c677bc5.js → arcade-mode-153379ec.js} +3 -3
  25. package/dist/cjs/arcgis-arcade-editor_6.cjs.entry.js +207 -157
  26. package/dist/cjs/arcgis-coding-components.cjs.js +4 -4
  27. package/dist/cjs/arcgis-sql-expression-editor.cjs.entry.js +26 -7
  28. package/dist/cjs/arcgis-sql-expression-fields.cjs.entry.js +4 -4
  29. package/dist/cjs/{css-8bbe3cfe.js → css-6e35ab05.js} +1 -1
  30. package/dist/cjs/{cssMode-20751da2.js → cssMode-3dc2bccb.js} +3 -3
  31. package/dist/cjs/{html-a4af845f.js → html-20965b18.js} +3 -3
  32. package/dist/cjs/{htmlMode-30e86156.js → htmlMode-9324d914.js} +3 -3
  33. package/dist/cjs/{index-ee1b5dad.js → index-b6860332.js} +1 -1
  34. package/dist/cjs/index.cjs.js +4 -4
  35. package/dist/cjs/{javascript-7d24a9c3.js → javascript-c62e64af.js} +4 -4
  36. package/dist/cjs/{jsonMode-aae37f0e.js → jsonMode-5d208206.js} +3 -3
  37. package/dist/cjs/loader.cjs.js +4 -4
  38. package/dist/cjs/{sql-expr-defaults-19b16751.js → sql-expr-defaults-e8d6f68b.js} +13 -12
  39. package/dist/cjs/{sql-expr-mode-5dfbe435.js → sql-expr-mode-08b2ba7b.js} +7 -5
  40. package/dist/cjs/{tsMode-36dcdc24.js → tsMode-4edda21c.js} +3 -3
  41. package/dist/cjs/{typescript-bcedd639.js → typescript-fef47aa2.js} +3 -3
  42. package/dist/cjs/{useT9n-5a58b74b.js → useT9n-5e3f59e6.js} +3 -3
  43. package/dist/components/arcade-defaults.js +2 -2
  44. package/dist/components/arcade-mode.js +1 -1
  45. package/dist/components/arcade-results.js +1 -1
  46. package/dist/components/arcade-suggestions.js +1 -1
  47. package/dist/components/arcgis-arcade-editor.js +8 -8
  48. package/dist/components/arcgis-arcade-results.js +1 -1
  49. package/dist/components/arcgis-arcade-suggestions.js +1 -1
  50. package/dist/components/arcgis-assets.d.ts +1 -1
  51. package/dist/components/arcgis-assets.js +1 -1
  52. package/dist/components/arcgis-code-editor.js +1 -1
  53. package/dist/components/{arcgis-arcade-variables.d.ts → arcgis-editor-variables.d.ts} +4 -4
  54. package/dist/components/arcgis-editor-variables.js +11 -0
  55. package/dist/components/arcgis-language-api-panel.js +1 -1
  56. package/dist/components/arcgis-sql-expression-editor.js +29 -10
  57. package/dist/components/arcgis-sql-expression-fields.js +103 -2
  58. package/dist/components/chunk-A4MUWALE.js +1 -1
  59. package/dist/components/code-editor.js +2 -2
  60. package/dist/components/{arcade-variables.js → editor-variables.js} +65 -16
  61. package/dist/components/fields.js +1 -1
  62. package/dist/components/index.js +1 -1
  63. package/dist/components/index2.js +1 -1
  64. package/dist/components/language-api-panel.js +1 -1
  65. package/dist/components/markdown.js +1 -1
  66. package/dist/components/sql-expr-defaults.js +1347 -5
  67. package/dist/components/sql-expr-mode.js +6 -4
  68. package/dist/components/useT9n.js +1 -1
  69. package/dist/components/utilities.js +1 -1
  70. package/dist/esm/{app-globals-60c1d02f.js → app-globals-114942c8.js} +1 -1
  71. package/dist/esm/{arcade-defaults-ff80717f.js → arcade-defaults-72d79638.js} +3 -3
  72. package/dist/esm/{arcade-mode-a4ff17cc.js → arcade-mode-33501bbf.js} +3 -3
  73. package/dist/esm/arcgis-arcade-editor_6.entry.js +207 -157
  74. package/dist/esm/arcgis-coding-components.js +5 -5
  75. package/dist/esm/arcgis-sql-expression-editor.entry.js +26 -7
  76. package/dist/esm/arcgis-sql-expression-fields.entry.js +4 -4
  77. package/dist/esm/{css-607cace1.js → css-e669c8cc.js} +1 -1
  78. package/dist/esm/{cssMode-2a8d291e.js → cssMode-a8b477e3.js} +3 -3
  79. package/dist/esm/{html-35122a30.js → html-fa654ea8.js} +3 -3
  80. package/dist/esm/{htmlMode-a22e6838.js → htmlMode-252b58ec.js} +3 -3
  81. package/dist/esm/{index-e129cff7.js → index-515ec576.js} +1 -1
  82. package/dist/esm/index.js +4 -4
  83. package/dist/esm/{javascript-61366963.js → javascript-e43d9aad.js} +4 -4
  84. package/dist/esm/{jsonMode-57111234.js → jsonMode-788ef636.js} +3 -3
  85. package/dist/esm/loader.js +5 -5
  86. package/dist/esm/{sql-expr-defaults-8686a08f.js → sql-expr-defaults-eff5fcd0.js} +14 -13
  87. package/dist/esm/{sql-expr-mode-c7cacc6e.js → sql-expr-mode-f4116ccc.js} +7 -5
  88. package/dist/esm/{tsMode-75e4ee85.js → tsMode-b6afbaf3.js} +3 -3
  89. package/dist/esm/{typescript-b43c3180.js → typescript-e6399cf1.js} +3 -3
  90. package/dist/esm/{useT9n-2b871a88.js → useT9n-1988d923.js} +3 -3
  91. package/dist/loader/cdn.js +1 -1
  92. package/dist/loader/index.cjs.js +1 -1
  93. package/dist/loader/index.es2017.js +1 -1
  94. package/dist/loader/index.js +1 -1
  95. package/dist/types/components/{arcade-variables/arcade-variables.d.ts → editor-variables/editor-variables.d.ts} +25 -2
  96. package/dist/types/components/sql-expression-editor/sql-expression-editor.d.ts +6 -0
  97. package/dist/types/components.d.ts +63 -53
  98. package/dist/types/utils/profile/editor-profile.d.ts +2 -1
  99. package/dist/types/utils/sql-expr-monaco/sql-expr-completion.d.ts +1 -0
  100. package/dist/types/utils/sql-expr-monaco/sql-expr-constants.d.ts +1 -1
  101. package/package.json +11 -11
  102. package/dist/arcgis-coding-components/p-448e8cc3.entry.js +0 -6
  103. package/dist/arcgis-coding-components/p-86849297.entry.js +0 -6
  104. package/dist/arcgis-coding-components/p-d4a498a5.js +0 -6
  105. package/dist/components/arcgis-arcade-variables.js +0 -11
  106. package/dist/components/language-defaults-base.js +0 -1352
  107. package/dist/components/sql-expression-fields.js +0 -109
  108. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.ar.json → editor-variables/t9n/editor-variables.t9n.ar.json} +0 -0
  109. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.bg.json → editor-variables/t9n/editor-variables.t9n.bg.json} +0 -0
  110. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.bs.json → editor-variables/t9n/editor-variables.t9n.bs.json} +0 -0
  111. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.ca.json → editor-variables/t9n/editor-variables.t9n.ca.json} +0 -0
  112. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.cs.json → editor-variables/t9n/editor-variables.t9n.cs.json} +0 -0
  113. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.da.json → editor-variables/t9n/editor-variables.t9n.da.json} +0 -0
  114. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.de.json → editor-variables/t9n/editor-variables.t9n.de.json} +0 -0
  115. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.el.json → editor-variables/t9n/editor-variables.t9n.el.json} +0 -0
  116. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.en.json → editor-variables/t9n/editor-variables.t9n.en.json} +0 -0
  117. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.es.json → editor-variables/t9n/editor-variables.t9n.es.json} +0 -0
  118. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.et.json → editor-variables/t9n/editor-variables.t9n.et.json} +0 -0
  119. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.fi.json → editor-variables/t9n/editor-variables.t9n.fi.json} +0 -0
  120. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.fr.json → editor-variables/t9n/editor-variables.t9n.fr.json} +0 -0
  121. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.he.json → editor-variables/t9n/editor-variables.t9n.he.json} +0 -0
  122. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.hr.json → editor-variables/t9n/editor-variables.t9n.hr.json} +0 -0
  123. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.hu.json → editor-variables/t9n/editor-variables.t9n.hu.json} +0 -0
  124. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.id.json → editor-variables/t9n/editor-variables.t9n.id.json} +0 -0
  125. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.it.json → editor-variables/t9n/editor-variables.t9n.it.json} +0 -0
  126. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.ja.json → editor-variables/t9n/editor-variables.t9n.ja.json} +0 -0
  127. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.ko.json → editor-variables/t9n/editor-variables.t9n.ko.json} +0 -0
  128. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.lt.json → editor-variables/t9n/editor-variables.t9n.lt.json} +0 -0
  129. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.lv.json → editor-variables/t9n/editor-variables.t9n.lv.json} +0 -0
  130. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.nb.json → editor-variables/t9n/editor-variables.t9n.nb.json} +0 -0
  131. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.nl.json → editor-variables/t9n/editor-variables.t9n.nl.json} +0 -0
  132. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.pl.json → editor-variables/t9n/editor-variables.t9n.pl.json} +0 -0
  133. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.pt-BR.json → editor-variables/t9n/editor-variables.t9n.pt-BR.json} +0 -0
  134. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.pt-PT.json → editor-variables/t9n/editor-variables.t9n.pt-PT.json} +0 -0
  135. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.ro.json → editor-variables/t9n/editor-variables.t9n.ro.json} +0 -0
  136. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.ru.json → editor-variables/t9n/editor-variables.t9n.ru.json} +0 -0
  137. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.sk.json → editor-variables/t9n/editor-variables.t9n.sk.json} +0 -0
  138. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.sl.json → editor-variables/t9n/editor-variables.t9n.sl.json} +0 -0
  139. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.sr.json → editor-variables/t9n/editor-variables.t9n.sr.json} +0 -0
  140. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.sv.json → editor-variables/t9n/editor-variables.t9n.sv.json} +0 -0
  141. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.th.json → editor-variables/t9n/editor-variables.t9n.th.json} +0 -0
  142. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.tr.json → editor-variables/t9n/editor-variables.t9n.tr.json} +0 -0
  143. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.uk.json → editor-variables/t9n/editor-variables.t9n.uk.json} +0 -0
  144. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.vi.json → editor-variables/t9n/editor-variables.t9n.vi.json} +0 -0
  145. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.zh-CN.json → editor-variables/t9n/editor-variables.t9n.zh-CN.json} +0 -0
  146. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.zh-HK.json → editor-variables/t9n/editor-variables.t9n.zh-HK.json} +0 -0
  147. /package/dist/arcgis-coding-components/assets/{arcade-variables/t9n/arcade-variables.t9n.zh-TW.json → editor-variables/t9n/editor-variables.t9n.zh-TW.json} +0 -0
@@ -1,1352 +0,0 @@
1
- /*!
2
- * All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
- * See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
- * v4.31.0-next.76
5
- */
6
- import { n as newLayersFeatureLayer, i as importRequest, s as supportedFields, a as newPortalPortalItem, b as newWebScene, c as newWebMap, f as fieldAlias, d as fieldTypeToIconName, e as fieldTypeToApiValueVarType } from './fields.js';
7
- import { p as portalItemPageUrl } from './utilities.js';
8
- import { i as isNotNull, a as isNotUndefined, b as addLTRMark, c as setValuesInString, n as normalizeLocale } from './index2.js';
9
- import { InsertTextMode, InsertTextFormat, CompletionItemKind, MarkupKind } from 'vscode-languageserver-types';
10
- import { Emitter, editor, Uri } from 'monaco-editor';
11
- import { getArcgisAssetPath as getAssetPath } from "./arcgis-assets.js";
12
-
13
- //#region Type Guards
14
- function isFeatureLayerLikeInstance(item) {
15
- return (!!item &&
16
- typeof item === "object" &&
17
- "declaredClass" in item &&
18
- typeof item.declaredClass === "string" &&
19
- item.declaredClass.startsWith("esri.layers.") &&
20
- isFieldsDefinition(item) &&
21
- "queryFeatures" in item &&
22
- typeof item.queryFeatures === "function");
23
- }
24
- function isGroupLayerCapable(item) {
25
- return (!!item &&
26
- typeof item === "object" &&
27
- "allLayers" in item &&
28
- "allTables" in item &&
29
- typeof item.allLayers === "object" &&
30
- typeof item.allTables === "object");
31
- }
32
- function isMapInstance(item) {
33
- return (!!item &&
34
- typeof item === "object" &&
35
- "declaredClass" in item &&
36
- typeof item.declaredClass === "string" &&
37
- (item.declaredClass === "esri.Map" ||
38
- item.declaredClass === "esri.WebMap" ||
39
- item.declaredClass === "esri.WebScene"));
40
- }
41
- function isLoadAllCapable(item) {
42
- return !!item && typeof item === "object" && "loadAll" in item && typeof item.loadAll === "function";
43
- }
44
- function isPortalItemDefinition(item) {
45
- return !!item && typeof item === "object" && "portalItem" in item && item.portalItem != null;
46
- }
47
- function isFeatureLayerItemDefinition(item) {
48
- return !!item && typeof item === "object" && "portalItem" in item && item.portalItem != null;
49
- }
50
- function isFieldsDefinition(item) {
51
- return !!item && typeof item === "object" && "fields" in item && Array.isArray(item.fields);
52
- }
53
- function isUrlDefinition(item) {
54
- return !!item && typeof item === "object" && "url" in item && typeof item.url === "string";
55
- }
56
- function isSupportedServiceUrlDefinition(item) {
57
- return isUrlDefinition(item) && /\/(?:featureserver|mapserver)(?:\/|$)/iu.test(item.url);
58
- }
59
- function isFeatureDefinition(item) {
60
- return isUrlDefinition(item) || isFieldsDefinition(item) || isFeatureLayerItemDefinition(item);
61
- }
62
- function isFeatureSetDefinition(item) {
63
- return isUrlDefinition(item) || isFieldsDefinition(item) || isFeatureLayerItemDefinition(item);
64
- }
65
- function isFeatureSetCollectionDefinition(item) {
66
- return isPortalItemDefinition(item) || isMapInstance(item) || isSupportedServiceUrlDefinition(item);
67
- }
68
- function isSubtypeInstance(item) {
69
- return (!!item &&
70
- typeof item === "object" &&
71
- "declaredClass" in item &&
72
- item.declaredClass === "esri.layers.support.Subtype");
73
- }
74
- function isCodedValueDomainInstance(item) {
75
- return (!!item &&
76
- typeof item === "object" &&
77
- "declaredClass" in item &&
78
- item.declaredClass === "esri.layers.support.CodedValueDomain");
79
- }
80
- function isInheritedDomainInstance(item) {
81
- return (!!item &&
82
- typeof item === "object" &&
83
- "declaredClass" in item &&
84
- item.declaredClass === "esri.layers.support.InheritedDomain");
85
- }
86
- function isPredefinedProfile(item) {
87
- return (!!item &&
88
- typeof item === "object" &&
89
- "id" in item &&
90
- typeof item.id === "string" &&
91
- "definitions" in item &&
92
- typeof item.definitions === "object" &&
93
- !Array.isArray(item.definitions));
94
- }
95
- function isTitleCapableSource(item) {
96
- return !!item && typeof item === "object" && "title" in item && typeof item.title === "string";
97
- }
98
- function isUrlCapableSource(item) {
99
- return !!item && typeof item === "object" && "url" in item && typeof item.url === "string";
100
- }
101
- function isLayerIdCapableSource(item) {
102
- return !!item && typeof item === "object" && "layerId" in item && typeof item.layerId === "number";
103
- }
104
- function isFeatureTypesCapableLayer(item) {
105
- return !!item && typeof item === "object" && "typeIdField" in item && "types" in item;
106
- }
107
- function isDomainsCapableLayer(item) {
108
- return !!item && typeof item === "object" && "getFieldDomain" in item && typeof item.getFieldDomain === "function";
109
- }
110
- function isSubtypeFieldCapableLayer(item) {
111
- return !!item && typeof item === "object" && "subtypeField" in item;
112
- }
113
- function isSubtypesCapableLayer(item) {
114
- return isSubtypeFieldCapableLayer(item) && "subtypes" in item;
115
- }
116
- function isPortalItemCapable(item) {
117
- return !!item && typeof item === "object" && "portalItem" in item;
118
- }
119
- function isRelationshipsCapableLayer(item) {
120
- return (isLayerIdCapableSource(item) &&
121
- "relationships" in item &&
122
- "url" in item &&
123
- Array.isArray(item.relationships) &&
124
- typeof item.url === "string");
125
- }
126
- function isTableCapableLayer(item) {
127
- return !!item && typeof item === "object" && "isTable" in item && typeof item.isTable === "boolean";
128
- }
129
- function isLoadableSource(item) {
130
- return !!item && typeof item === "object" && "load" in item && typeof item.load === "function";
131
- }
132
- //#endregion
133
- //#region Service Metadata
134
- async function supportedSourceFromDefinition(definition) {
135
- if (!definition) {
136
- return null;
137
- }
138
- let source = null;
139
- if (isFieldsDefinition(definition)) {
140
- source = definition;
141
- }
142
- else {
143
- source = await newLayersFeatureLayer(definition);
144
- }
145
- if (isLoadableSource(source)) {
146
- await source.load();
147
- }
148
- return source;
149
- }
150
- async function serviceMetaData(url) {
151
- url += "/layers";
152
- const request = await importRequest();
153
- const response = await request(url, { responseType: "json", query: { f: "json" } });
154
- const queryCapability = url.endsWith("MapServer/layers") ? "data" : "query";
155
- const layers = getSupportedLayerInfos(response.data?.layers, queryCapability);
156
- const tables = getSupportedLayerInfos(response.data?.tables, queryCapability);
157
- return { layers, tables };
158
- }
159
- function getSupportedLayerInfos(layers, queryCapability) {
160
- if (!layers) {
161
- return [];
162
- }
163
- return layers.filter((layer) => {
164
- switch (layer.type) {
165
- case "Feature Layer":
166
- case "Oriented Imagery Layer":
167
- case "Catalog Layer":
168
- case "Table": {
169
- const capabilities = layer.capabilities
170
- ? layer.capabilities
171
- .toLowerCase()
172
- .split(",")
173
- .map((value) => value.trim())
174
- : [];
175
- return capabilities.includes(queryCapability);
176
- }
177
- default:
178
- return false;
179
- }
180
- });
181
- }
182
- //#endregion
183
-
184
- //#endregion
185
- //#region Support functions
186
- async function getRelatedFeatureLayer(layer, relationship) {
187
- const relatedFeatureLayer = await newLayersFeatureLayer({ url: `${layer.url}/${relationship.relatedTableId}` });
188
- await relatedFeatureLayer.load();
189
- return relatedFeatureLayer;
190
- }
191
- function sortFields(layer) {
192
- return (firstField, secondField) => {
193
- if (firstField.type === "oid") {
194
- return -1;
195
- }
196
- if (secondField.type === "oid") {
197
- return 1;
198
- }
199
- if (isSubtypeFieldCapableLayer(layer)) {
200
- if (firstField.name === layer.subtypeField) {
201
- return -1;
202
- }
203
- if (secondField.name === layer.subtypeField) {
204
- return 1;
205
- }
206
- }
207
- if (isFeatureTypesCapableLayer(layer)) {
208
- if (firstField.name === layer.typeIdField) {
209
- return -1;
210
- }
211
- if (secondField.name === layer.typeIdField) {
212
- return 1;
213
- }
214
- }
215
- return firstField.name.localeCompare(secondField.name, "en", { sensitivity: "base" });
216
- };
217
- }
218
- function areAllDomainsInherited(types, field) {
219
- return types?.every((type) => type.domains?.[field.name]?.type === "inherited") ?? false;
220
- }
221
- // const validIdentifierExpr = new RegExp(/^[a-z_$][\w$]*$/gi);
222
- const validIdentifierExpr = /^[a-z_$][a-z0-9_$]*$/giu;
223
- function getMemberExpressionProperty(prop, includeDot = true) {
224
- if (prop.match(validIdentifierExpr)) {
225
- return `${includeDot ? "." : ""}${prop}`;
226
- }
227
- return `["${prop}"]`;
228
- }
229
- function assembleMemberExpression(obj, prop) {
230
- if (!obj) {
231
- return prop;
232
- }
233
- return `${obj}${getMemberExpressionProperty(prop)}`;
234
- }
235
- function getMapPortalItem(map) {
236
- if (isPortalItemCapable(map)) {
237
- return map.portalItem;
238
- }
239
- return null;
240
- }
241
- /**
242
- * converts fields to profile values and calculates the feature completion description all in one iteration
243
- */
244
- function fieldsToProfileValues(fields, initialFeatureCompletionDescription, includeAliases = false) {
245
- let featureCompletionDescription = initialFeatureCompletionDescription;
246
- const fieldProfileValues = [];
247
- const aliasProfileValues = [];
248
- supportedFields(fields).forEach((field) => {
249
- if (featureCompletionDescription) {
250
- featureCompletionDescription += " \n \n";
251
- }
252
- featureCompletionDescription += `**${field.name}** (${field.alias}) \n${field.type}`;
253
- if (field.description) {
254
- featureCompletionDescription += ` \n'${field.description}`;
255
- }
256
- // The property for the field
257
- const type = fieldTypeToApiValueVarType(field);
258
- const insertText = getMemberExpressionProperty(field.name, false);
259
- const description = fieldAlias(field);
260
- fieldProfileValues.push({
261
- name: field.name,
262
- description,
263
- type,
264
- completion: {
265
- label: field.name,
266
- detail: description,
267
- insertText,
268
- insertTextMode: InsertTextMode.asIs,
269
- insertTextFormat: InsertTextFormat.PlainText,
270
- kind: CompletionItemKind.Field,
271
- },
272
- });
273
- if (includeAliases) {
274
- if (!field.alias || field.alias.toLowerCase() === field.name.toLowerCase()) {
275
- return;
276
- }
277
- // The property for the alias if different than the field name
278
- let aliasCompletionDescription = `**${field.alias}** \n${field.type}`;
279
- if (field.description) {
280
- aliasCompletionDescription += ` \n'${field.description}`;
281
- }
282
- aliasProfileValues.push({
283
- name: field.alias,
284
- description: field.name,
285
- type,
286
- completion: {
287
- label: field.alias,
288
- detail: field.name,
289
- insertText,
290
- insertTextMode: InsertTextMode.asIs,
291
- insertTextFormat: InsertTextFormat.PlainText,
292
- kind: CompletionItemKind.Field,
293
- documentation: { kind: "markdown", value: aliasCompletionDescription },
294
- },
295
- });
296
- }
297
- });
298
- const properties = [...fieldProfileValues, ...aliasProfileValues];
299
- return [properties, featureCompletionDescription];
300
- }
301
- /**
302
- * Represents a item in the EditorProfile. The profile is converted into an optimized way for
303
- * rendering in the editor. In addition to the representation of profile variables, other
304
- * structures are created such as groups.
305
- */
306
- class ProfileItemBase {
307
- constructor(_profile, _label, description) {
308
- this._profile = _profile;
309
- this._label = _label;
310
- this.description = description;
311
- this.filterDescription = false;
312
- }
313
- /**
314
- * Returns the label string.
315
- */
316
- getLabel() {
317
- if (this._label == null) {
318
- return "";
319
- }
320
- if (typeof this._label === "string") {
321
- // Some of our variables can start with a $ sign.
322
- // If the component is under RTL, the string is messed up.
323
- // It is converted from $feature to feature$, This is not acceptable since the label
324
- // represents a variable name. We are adding in front of the $ sign a right to left mark.
325
- return addLTRMark(this._label);
326
- }
327
- return setValuesInString(this._profile?.intlStrings[this._label.code], this._label.formatValues);
328
- }
329
- /**
330
- * Returns the description string.
331
- */
332
- getDescription() {
333
- if (this.description == null) {
334
- return "";
335
- }
336
- if (typeof this.description === "string") {
337
- return this.description;
338
- }
339
- return setValuesInString(this._profile?.intlStrings[this.description.code], this.description.formatValues);
340
- }
341
- /**
342
- * Returns true if the item pass the filter test
343
- */
344
- passFilter(filterExpression) {
345
- if (!filterExpression) {
346
- return true;
347
- }
348
- if (filterExpression.test(this.getLabel())) {
349
- return true;
350
- }
351
- return this.filterDescription && filterExpression.test(this.getDescription());
352
- }
353
- }
354
- /**
355
- * The base class for profile variables representation in the EditorProfile.
356
- */
357
- class VariableBase extends ProfileItemBase {
358
- constructor(props) {
359
- super(props.profile, props.label, props.description ?? props.declaration?.description);
360
- this.declaration = props.declaration ?? {};
361
- this.name = props.declaration?.name ?? "";
362
- this.snippet = props.snippet ?? "";
363
- this.nonInteractive = props.nonInteractive ?? false;
364
- this.filterDescription = props.filterDescription ?? false;
365
- this.icon = props.icon;
366
- }
367
- }
368
- /**
369
- * Represents the IProfileValue.
370
- */
371
- class ValueVariable extends VariableBase {
372
- constructor(props) {
373
- super(props);
374
- this.type = "text";
375
- this.isCollection = false;
376
- this.type = props.declaration?.type ?? "text";
377
- }
378
- getDescription() {
379
- if (this.description == null) {
380
- return this._profile?.intlStrings[this.type.toLowerCase()] ?? "";
381
- }
382
- return super.getDescription();
383
- }
384
- toProfileVariableDefinition() {
385
- return { type: this.type, name: "", ...this.declaration };
386
- }
387
- }
388
- /**
389
- * Represents the IProfileArray. The main difference is that the IProfileValue type
390
- * is used as valueType.
391
- */
392
- class ArrayVariable extends VariableBase {
393
- constructor(props) {
394
- super(props);
395
- this.type = "array";
396
- this.isCollection = false;
397
- this.elementType = props.declaration?.elementType ?? { type: "number", name: "number" };
398
- }
399
- getDescription() {
400
- if (this.description == null) {
401
- return this._profile?.intlStrings[this.type.toLowerCase()] ?? "";
402
- }
403
- return super.getDescription();
404
- }
405
- toProfileVariableDefinition() {
406
- return { type: this.type, elementType: this.elementType, name: "", ...this.declaration };
407
- }
408
- }
409
- /**
410
- * Represents a collection of items. The collection of items can be synchronous or
411
- * asynchronous. If the collection is asynchronous then the collection should be
412
- * loaded by using the function 'load'. The property 'loaded' indicates if the
413
- * collection is ready or not.
414
- */
415
- class CollectionBasedVariable extends VariableBase {
416
- constructor(owner, props) {
417
- super(props);
418
- this.owner = owner;
419
- this.isCollection = true;
420
- this._loaded = true;
421
- /**
422
- * The collection of items used to display the profile.
423
- * If the collection is asynchronous, the 'load' function should
424
- * be called first before using the items.
425
- */
426
- this.variables = [];
427
- }
428
- get breadcrumb() {
429
- // If there's an owner, prepend its breadcrumb and append the current name
430
- if (this.owner) {
431
- const ownerBreadcrumb = this.owner.breadcrumb;
432
- return ownerBreadcrumb ? `${ownerBreadcrumb} / ${this.name}` : this.name;
433
- }
434
- // If there's no owner, this is the root element, so just return its name
435
- return this.name;
436
- }
437
- /**
438
- * Returns true if the collection has been loaded
439
- */
440
- get loaded() {
441
- return this._loaded;
442
- }
443
- /**
444
- * Returns an url to the associated information
445
- */
446
- get informationUrl() {
447
- return null;
448
- }
449
- get informationType() {
450
- return "";
451
- }
452
- }
453
- class GroupOfVariables extends ProfileItemBase {
454
- constructor(profile, label, variables = []) {
455
- super(profile, label);
456
- this.variables = variables;
457
- this.type = "group";
458
- this.isCollection = true;
459
- }
460
- passFilter() {
461
- return true;
462
- }
463
- }
464
- class DictionaryVariable extends CollectionBasedVariable {
465
- constructor(owner, props) {
466
- super(owner, props);
467
- this.type = "dictionary";
468
- /**
469
- * The variables that the dictionary holds. It is different than the variables.
470
- * The variables may contain grouping.
471
- */
472
- this.dictionaryVariables = [];
473
- this.loadPropertyDeclarations(props.declaration?.properties);
474
- // If we have a snippet then wrap the properties in a group and use the snippet as the heading
475
- // This is not applicable for root Dictionary such as Profile
476
- if (this.snippet && this.dictionaryVariables.length) {
477
- this.variables = [new GroupOfVariables(this._profile, this.snippet, this.dictionaryVariables)];
478
- }
479
- }
480
- async loadSource() {
481
- // No-op
482
- }
483
- loadPropertyDeclarations(declarations) {
484
- this.dictionaryVariables = this.createVariableInstances(declarations);
485
- this.variables = this.dictionaryVariables;
486
- }
487
- createVariableInstances(declarations) {
488
- if (!Array.isArray(declarations)) {
489
- return [];
490
- }
491
- const properties = [];
492
- declarations.forEach((declaration) => {
493
- const variable = this.createVariableInstance(declaration);
494
- if (variable) {
495
- properties.push(variable);
496
- }
497
- });
498
- return properties;
499
- }
500
- createVariableInstance(declaration) {
501
- const snippet = assembleMemberExpression(this.snippet, declaration.name);
502
- switch (declaration.type) {
503
- case "number":
504
- case "text":
505
- case "boolean":
506
- case "date":
507
- case "dateOnly":
508
- case "time":
509
- case "geometry":
510
- case "knowledgeGraph":
511
- return new ValueVariable({ profile: this._profile, declaration, label: snippet, snippet });
512
- case "feature":
513
- return new FeatureVariable(this, { profile: this._profile, declaration, label: snippet, snippet });
514
- case "featureSet":
515
- return new FeatureSetVariable(this, { profile: this._profile, declaration, label: snippet, snippet }, [
516
- new ValueVariable({ profile: this._profile, label: snippet, description: "", snippet }),
517
- ]);
518
- case "featureSetCollection":
519
- return new FeatureSetCollectionVariable(this, {
520
- profile: this._profile,
521
- declaration,
522
- label: snippet,
523
- snippet,
524
- });
525
- case "dictionary":
526
- return new DictionaryVariable(this, {
527
- profile: this._profile,
528
- declaration,
529
- label: snippet,
530
- snippet,
531
- });
532
- case "array":
533
- return new ArrayVariable({
534
- profile: this._profile,
535
- declaration,
536
- label: snippet,
537
- snippet,
538
- });
539
- default:
540
- console.error("Editor profile: Invalid profile variable", declaration);
541
- return null;
542
- }
543
- }
544
- toProfileVariableDefinition() {
545
- return {
546
- type: this.type,
547
- name: "",
548
- ...this.declaration,
549
- properties: this.dictionaryVariables.map((variable) => variable.toProfileVariableDefinition()),
550
- };
551
- }
552
- }
553
- class SourceBasedVariable extends CollectionBasedVariable {
554
- constructor(owner, props, relationshipsProperties) {
555
- super(owner, props);
556
- this.relationshipsProperties = relationshipsProperties;
557
- this._source = null;
558
- this._loaded = false;
559
- this._definition = props.declaration?.definition;
560
- }
561
- get title() {
562
- return isTitleCapableSource(this._source) ? this._source.title : "";
563
- }
564
- get url() {
565
- return isUrlCapableSource(this._source) ? this._source.url : "";
566
- }
567
- get informationUrl() {
568
- if (!this.loaded) {
569
- return null;
570
- }
571
- if (!this.url) {
572
- return null;
573
- }
574
- return isLayerIdCapableSource(this._source) ? `${this.url}/${this._source.layerId}` : this.url;
575
- }
576
- get informationType() {
577
- return this._profile?.intlStrings.layer ?? "layer";
578
- }
579
- async loadSource() {
580
- if (isNotNull(this._loadPromise) && isNotUndefined(this._loadPromise)) {
581
- return await this._loadPromise;
582
- }
583
- this._loadPromise = this._loadSource();
584
- return await this._loadPromise;
585
- }
586
- _getValueSnippet(field) {
587
- // If the source is a feature, then we want to assemble the snippet ($feature) with the field name as a member expression
588
- return this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
589
- }
590
- _getSubtypeOrDomainNameSnippet(field) {
591
- if (this.type !== "feature") {
592
- return null;
593
- }
594
- if (isSubtypeFieldCapableLayer(this._source) && field.name === this._source.subtypeField) {
595
- return `SubtypeName(${this.snippet})`;
596
- }
597
- return `DomainName(${this.snippet}, "${field.name}")`;
598
- }
599
- _getFieldProperty(field) {
600
- // Check if the field is the type id field or of the field has a coded domain.
601
- // If it has then the property will be an exanpdable property (dictionary).
602
- // Otherwise just return a simple value property.
603
- const subtypesOrDomainValuesDictionary = this._getDomainDictionary(field);
604
- if (subtypesOrDomainValuesDictionary) {
605
- return subtypesOrDomainValuesDictionary;
606
- }
607
- // Create the value property
608
- const valueSnippet = this._getValueSnippet(field);
609
- return new ValueVariable({
610
- profile: this._profile,
611
- label: valueSnippet,
612
- description: fieldAlias(field),
613
- snippet: valueSnippet,
614
- icon: fieldTypeToIconName(field),
615
- filterDescription: true,
616
- });
617
- }
618
- _getDomainDictionary(field) {
619
- if (!isDomainsCapableLayer(this._source)) {
620
- return null;
621
- }
622
- // Note we have multiple scenarios:
623
- // - Layers without subtypes or feature types: We will check if the field has a domain
624
- // - Layers with only subtypes: We will parse the subtypes metadata and create a dictionary
625
- // - Layers with only feature types: We will parse the feature types metadata
626
- // - Layers with both subtypes and feature types: we will actually use the subtypes metadata
627
- // Summary, we will always use the subtypes metadata if available.
628
- if (isSubtypeFieldCapableLayer(this._source) && !!this._source.subtypeField) {
629
- return this._getSubtypeDomainDictionary(field);
630
- }
631
- if (isFeatureTypesCapableLayer(this._source) && !!this._source.typeIdField) {
632
- return this._getFeatureTypeDomainDictionary(field);
633
- }
634
- return this._getFieldDomainDictionary(field);
635
- }
636
- _getSubtypeDomainDictionary(field) {
637
- // Should be tested before calling this function
638
- if (!isSubtypeFieldCapableLayer(this._source)) {
639
- return null;
640
- }
641
- // If the source has a subtype field but doesn't have subtypes, it is certainly a subtype sublayer
642
- if (!isSubtypesCapableLayer(this._source)) {
643
- // For the subtype field there is no domain
644
- if (field.name === this._source.subtypeField) {
645
- return null;
646
- }
647
- // For the other fields, we will use the getFieldDomain function
648
- return this._getFieldDomainDictionary(field);
649
- }
650
- // The code here shoud be executed for layers that have subtypes
651
- // Sepcial case for the subtype field
652
- if (field.name === this._source.subtypeField) {
653
- const domainDictionary = this._createDomainDictionary(field);
654
- domainDictionary.icon = "subtype";
655
- domainDictionary.variables.push(this._getTypeOrSubtypeDomainGroup(this._source.subtypes, field));
656
- return domainDictionary;
657
- }
658
- // Check if all the domains for the field in the types are inherited.
659
- // If it is we can simplify the structure by avoiding splitting in subtypes
660
- if (areAllDomainsInherited(this._source.subtypes, field)) {
661
- return this._getFieldDomainDictionary(field);
662
- }
663
- // We have domains per subtype
664
- // We need to go thru each types and create a dictionary.
665
- const domainValuesBySubtypeGroup = this._getDomainValuesGroup(this._source.subtypes, field);
666
- if (!domainValuesBySubtypeGroup) {
667
- return null;
668
- }
669
- const domainDictionary = this._createDomainDictionary(field);
670
- domainDictionary.variables.push(domainValuesBySubtypeGroup);
671
- return domainDictionary;
672
- }
673
- _getFeatureTypeDomainDictionary(field) {
674
- // SHould be tested before calling this function
675
- if (!isFeatureTypesCapableLayer(this._source)) {
676
- return null;
677
- }
678
- // Special case for the type id field
679
- if (field.name === this._source.typeIdField) {
680
- const domainDictionary = this._createDomainDictionary(field);
681
- domainDictionary.variables.push(this._getTypeOrSubtypeDomainGroup(this._source.types, field));
682
- return domainDictionary;
683
- }
684
- // Check if all the domains for the field in the types are inherited.
685
- // If it is we can simplify the structure by avoiding splitting in subtypes
686
- if (areAllDomainsInherited(this._source.types, field)) {
687
- return this._getFieldDomainDictionary(field);
688
- }
689
- // We have domains per feature type
690
- // We need to go thru each types and create a dictionary.
691
- const domainValuesByFeatureTypeGroup = this._getDomainValuesGroup(this._source.types, field);
692
- if (!domainValuesByFeatureTypeGroup) {
693
- return null;
694
- }
695
- const domainDictionary = this._createDomainDictionary(field);
696
- domainDictionary.variables.push(domainValuesByFeatureTypeGroup);
697
- return domainDictionary;
698
- }
699
- _getFieldDomainDictionary(field) {
700
- // SHould be tested before calling this function
701
- if (!isDomainsCapableLayer(this._source)) {
702
- return null;
703
- }
704
- const fieldDomain = this._source.getFieldDomain(field.name);
705
- if (!isCodedValueDomainInstance(fieldDomain)) {
706
- return null;
707
- }
708
- const domainValuesGroup = this._getCodedValueDomainGroup(fieldDomain, {
709
- code: "domainvalues",
710
- });
711
- const domainDictionary = this._createDomainDictionary(field);
712
- domainDictionary.variables.push(domainValuesGroup);
713
- return domainDictionary;
714
- }
715
- _getTypeOrSubtypeDomainGroup(types, field) {
716
- // Try the coded domain first
717
- if (isCodedValueDomainInstance(field.domain)) {
718
- return this._getCodedValueDomainGroup(field.domain, { code: "subtypes" });
719
- }
720
- // No coded domain, we will manufacture it
721
- const values = types?.map((t) => {
722
- const label = isSubtypeInstance(t) ? t.code : t.id;
723
- return new ValueVariable({
724
- profile: this._profile,
725
- label: `${label}`,
726
- description: t.name,
727
- snippet: `"${label}"`,
728
- });
729
- }) ?? [];
730
- return new GroupOfVariables(this._profile, { code: "subtypes" }, values);
731
- }
732
- _getCodedValueDomainGroup(domain, label) {
733
- const values = domain.codedValues.map((v) => new ValueVariable({
734
- profile: this._profile,
735
- label: `${v.code}`,
736
- description: v.name,
737
- snippet: `"${v.code}"`,
738
- filterDescription: true,
739
- }));
740
- return new GroupOfVariables(this._profile, label, values);
741
- }
742
- _getDomainValuesGroup(types, field) {
743
- const variables = [];
744
- if (!types || types.length === 0) {
745
- return null;
746
- }
747
- types.forEach((type) => {
748
- let domain = type.domains?.[field.name];
749
- if (!domain) {
750
- return;
751
- }
752
- if (isInheritedDomainInstance(domain)) {
753
- domain = field.domain;
754
- return;
755
- }
756
- if (!isCodedValueDomainInstance(domain)) {
757
- return;
758
- }
759
- const alias = fieldAlias(field);
760
- const domainValuesGroup = this._getCodedValueDomainGroup(domain, {
761
- code: "domainvaluesfortypeformat",
762
- formatValues: {
763
- fieldName: alias,
764
- typeName: type.name,
765
- },
766
- });
767
- const id = isSubtypeInstance(type) ? type.code : type.id;
768
- const label = `${id}`;
769
- const snippet = `"${id}""`;
770
- const subtypeDictionary = new DictionaryVariable(this, {
771
- profile: this._profile,
772
- label,
773
- snippet,
774
- description: type.name,
775
- declaration: { name: alias },
776
- });
777
- subtypeDictionary.variables = [domainValuesGroup];
778
- variables.push(subtypeDictionary);
779
- });
780
- if (!variables.length) {
781
- return null;
782
- }
783
- return new GroupOfVariables(this._profile, { code: "domainvaluesbysubtypes" }, variables);
784
- }
785
- _createDomainDictionary(field) {
786
- // Create the domain dictionary.
787
- // The dictionary will have a header group and a value group.
788
- // At this point we are only creating the header group in the dictionary.
789
- const valueSnippet = this._getValueSnippet(field);
790
- const alias = fieldAlias(field);
791
- const domainDictionary = new DictionaryVariable(this, {
792
- profile: this._profile,
793
- label: valueSnippet,
794
- description: alias,
795
- snippet: valueSnippet,
796
- icon: "form-dropdown",
797
- declaration: { name: field.name },
798
- });
799
- // Add the header group
800
- const headerGroup = new GroupOfVariables(this._profile, alias, [
801
- new ValueVariable({
802
- profile: this._profile,
803
- label: valueSnippet,
804
- description: "",
805
- snippet: valueSnippet,
806
- }),
807
- ]);
808
- domainDictionary.variables = [headerGroup];
809
- // Add the SubtypeName or DomainName snippet if available
810
- const subtypeOrDomainNameSnippet = this._getSubtypeOrDomainNameSnippet(field);
811
- if (subtypeOrDomainNameSnippet) {
812
- headerGroup.variables.push(new ValueVariable({
813
- profile: this._profile,
814
- label: subtypeOrDomainNameSnippet,
815
- description: "",
816
- snippet: subtypeOrDomainNameSnippet,
817
- }));
818
- }
819
- return domainDictionary;
820
- }
821
- async _getRelationshipsProperty() {
822
- // We need the data store to find the relationship feature layers
823
- if (!this.relationshipsProperties?.exposeRelationships || !this._profile?.supportFeatureSetFunctions) {
824
- return null;
825
- }
826
- const source = this._source;
827
- if (!isRelationshipsCapableLayer(source)) {
828
- return null;
829
- }
830
- const relationshipsGroup = new GroupOfVariables(this._profile, { code: "relationships" });
831
- const relationshipItems = await Promise.all(source.relationships.map(async (relationship) => {
832
- const relatedLayer = await getRelatedFeatureLayer(source, relationship);
833
- if (!isFeatureLayerLikeInstance(relatedLayer)) {
834
- return null;
835
- }
836
- if (relationship.relatedTableId === this.relationshipsProperties?.sourceTableId) {
837
- // We don't want to show the reverse relationship
838
- return null;
839
- }
840
- const snippet = `FeatureSetByRelationshipName(${this.snippet}, "${relationship.name}")`;
841
- return new FeatureSetVariable(this, {
842
- profile: this._profile,
843
- declaration: { definition: relatedLayer },
844
- label: relatedLayer.title,
845
- description: "",
846
- nonInteractive: true,
847
- }, [new ValueVariable({ profile: this._profile, label: snippet, description: "", snippet })], { exposeRelationships: true, sourceTableId: source.layerId });
848
- }));
849
- relationshipsGroup.variables = relationshipItems.filter(isNotNull);
850
- if (!relationshipsGroup.variables.length) {
851
- return null;
852
- }
853
- return relationshipsGroup;
854
- }
855
- }
856
- class FeatureVariable extends SourceBasedVariable {
857
- constructor(owner, props) {
858
- super(owner, props, { exposeRelationships: true });
859
- this.type = "feature";
860
- }
861
- get title() {
862
- if (isTitleCapableSource(this._source)) {
863
- return this._source.title ?? "";
864
- }
865
- return { code: "feature" };
866
- }
867
- async _loadSource() {
868
- if (this.loaded) {
869
- return this._source;
870
- }
871
- try {
872
- this._source = await supportedSourceFromDefinition(this._definition);
873
- if (!this._source) {
874
- throw new Error("Invalid definition");
875
- }
876
- // The title group and snippet
877
- const title = isTitleCapableSource(this._source) ? (this._source.title ?? "") : "";
878
- this.variables.push(new GroupOfVariables(this._profile, title, [
879
- new ValueVariable({
880
- profile: this._profile,
881
- label: this.snippet,
882
- description: "",
883
- snippet: this.snippet,
884
- }),
885
- ]));
886
- // The collection of feature attribute values
887
- const valuesGroup = new GroupOfVariables(this._profile, { code: "values" });
888
- this.variables.push(valuesGroup);
889
- // Add the geometry if it's a feature layer and not a table
890
- if (isTableCapableLayer(this._source) && !this._source.isTable) {
891
- const snippet = `Geometry(${this.snippet})`;
892
- const geometryProperty = new ValueVariable({
893
- profile: this._profile,
894
- declaration: { name: snippet },
895
- label: snippet,
896
- description: "Geometry",
897
- snippet,
898
- icon: "shapes",
899
- filterDescription: true,
900
- });
901
- valuesGroup.variables.push(geometryProperty);
902
- }
903
- this._source.fields.sort(sortFields(this._source)).forEach((field) => {
904
- valuesGroup.variables.push(this._getFieldProperty(field));
905
- });
906
- // The relatonships
907
- const relationshipsGroup = await this._getRelationshipsProperty();
908
- if (relationshipsGroup) {
909
- this.variables.push(relationshipsGroup);
910
- }
911
- }
912
- catch (error) {
913
- console.error("Error with definition", error, this._definition);
914
- this._source = null;
915
- }
916
- finally {
917
- this._loaded = true;
918
- }
919
- return this._source;
920
- }
921
- toProfileVariableDefinition() {
922
- return { type: this.type, name: "", ...this.declaration, definition: this._definition };
923
- }
924
- }
925
- class FeatureSetVariable extends SourceBasedVariable {
926
- constructor(owner, props, featureSetSnippets = [],
927
- // Relationships for feature set if only supported if the feature set is actually
928
- // representing a relationsip feature layer for a feature source.
929
- relationshipProps) {
930
- super(owner, props, relationshipProps);
931
- this.featureSetSnippets = featureSetSnippets;
932
- this.type = "featureSet";
933
- }
934
- get title() {
935
- if (isTitleCapableSource(this._source)) {
936
- return this._source.title ?? "";
937
- }
938
- return { code: "featureset" };
939
- }
940
- async _loadSource() {
941
- if (this.loaded) {
942
- return this._source;
943
- }
944
- try {
945
- this._source = await supportedSourceFromDefinition(this._definition);
946
- if (!this._source) {
947
- throw new Error("Invalid definition");
948
- }
949
- // The title group and snippet
950
- this.variables.push(new GroupOfVariables(this._profile, this.title, this.featureSetSnippets));
951
- // Add the fields
952
- const fieldsGroup = new GroupOfVariables(this._profile, { code: "fields" });
953
- this.variables.push(fieldsGroup);
954
- fieldsGroup.variables = this._source.fields
955
- .sort(sortFields(this._source))
956
- .map((field) => this._getFieldProperty(field));
957
- // Add the relationships if enabled
958
- const relationshipsGroup = await this._getRelationshipsProperty();
959
- if (relationshipsGroup) {
960
- this.variables.push(relationshipsGroup);
961
- }
962
- }
963
- catch (error) {
964
- console.error("Error with definition", error, this._definition);
965
- this._source = null;
966
- }
967
- finally {
968
- this._loaded = true;
969
- }
970
- return this._source;
971
- }
972
- toProfileVariableDefinition() {
973
- return { type: this.type, name: "", ...this.declaration, definition: this._definition };
974
- }
975
- }
976
- class FeatureSetCollectionVariable extends CollectionBasedVariable {
977
- constructor(owner, props) {
978
- super(owner, props);
979
- this.type = "featureSetCollection";
980
- this._featureSetCollections = null;
981
- this._loaded = false;
982
- this._definition = props.declaration?.definition;
983
- }
984
- get informationUrl() {
985
- if (!this.loaded || !this._featureSetCollections) {
986
- return null;
987
- }
988
- if (typeof this._featureSetCollections.source !== "string") {
989
- return portalItemPageUrl(getMapPortalItem(this._featureSetCollections.source));
990
- }
991
- // const firstLayer = this._featureSetCollection.layers[0] ?? this._featureSetCollection.tables[0];
992
- // if (!firstLayer) {
993
- return null;
994
- // }
995
- // return `${firstLayer.url}`;
996
- }
997
- get informationType() {
998
- if (!this.loaded || !this._featureSetCollections) {
999
- return "";
1000
- }
1001
- if (typeof this._featureSetCollections.source === "string") {
1002
- return this._profile?.intlStrings.featureservice ?? "featureservice";
1003
- }
1004
- switch (this._featureSetCollections.source.declaredClass) {
1005
- case "esri.WebMap":
1006
- return this._profile?.intlStrings.webmap ?? "webmap";
1007
- case "esri.WebScene":
1008
- return this._profile?.intlStrings.webscene ?? "webscene";
1009
- default:
1010
- return this._profile?.intlStrings.map ?? "map";
1011
- }
1012
- }
1013
- async loadSource() {
1014
- if (isNotNull(this._loadPromise) && isNotUndefined(this._loadPromise)) {
1015
- return await this._loadPromise;
1016
- }
1017
- this._loadPromise = this._loadSource();
1018
- return await this._loadPromise;
1019
- }
1020
- async _loadSource() {
1021
- if (this.loaded) {
1022
- return this._featureSetCollections;
1023
- }
1024
- try {
1025
- this._featureSetCollections = await this._featureSetCollectionsFromDefinition();
1026
- if (!this._featureSetCollections) {
1027
- throw new Error("Invalid definition");
1028
- }
1029
- // Create the group for the header
1030
- const groupLabel = typeof this._featureSetCollections.source === "string"
1031
- ? { code: this._featureSetCollections.source.endsWith("FeatureServer") ? "featureservice" : "mapservice" }
1032
- : {
1033
- code: "webmapformat",
1034
- formatValues: {
1035
- webMapTitle: getMapPortalItem(this._featureSetCollections.source)?.title || "Untitled map",
1036
- },
1037
- };
1038
- const headerGroup = new GroupOfVariables(this._profile, groupLabel, [
1039
- new ValueVariable({
1040
- profile: this._profile,
1041
- label: this.snippet,
1042
- description: "",
1043
- snippet: this.snippet,
1044
- }),
1045
- ]);
1046
- // Creates the groups for the layer and tables
1047
- const layersGroup = new GroupOfVariables(this._profile, { code: "layers" }, this._featureSetCollections.layers);
1048
- const tablesGroup = new GroupOfVariables(this._profile, { code: "tables" }, this._featureSetCollections.tables);
1049
- this.variables.push(headerGroup, layersGroup, tablesGroup);
1050
- }
1051
- catch (error) {
1052
- console.error("Error with definition", error, this._definition);
1053
- this._featureSetCollections = null;
1054
- }
1055
- finally {
1056
- this._loaded = true;
1057
- }
1058
- return this._featureSetCollections;
1059
- }
1060
- async _featureSetCollectionsFromDefinition() {
1061
- if (!this._definition) {
1062
- return null;
1063
- }
1064
- if (isMapInstance(this._definition)) {
1065
- return await this._featureSetCollectionFromMap(this._definition);
1066
- }
1067
- if (isUrlDefinition(this._definition)) {
1068
- return await this._featureSetCollectionFromUrl(this._definition.url);
1069
- }
1070
- if (isPortalItemDefinition(this._definition)) {
1071
- // Preload the portal item so we can discover if are dealing with a Web Map
1072
- // or Feature Service
1073
- return await this._featureSetCollectionFromPortalItem(this._definition.portalItem);
1074
- }
1075
- return null;
1076
- }
1077
- async _featureSetCollectionFromMap(map) {
1078
- if (isLoadAllCapable(map)) {
1079
- // Make sure the map is loaded
1080
- await map.loadAll();
1081
- }
1082
- // Until jsapi fix a bug we have to load the table separately
1083
- await Promise.all(map.tables.map(async (t) => (await t.load())));
1084
- return {
1085
- layers: this._convertWebMapLayersToVariables(map.layers),
1086
- tables: this._convertWebMapLayersToVariables(map.tables, true),
1087
- source: map,
1088
- };
1089
- }
1090
- async _featureSetCollectionFromPortalItem(definition) {
1091
- const portalItem = await newPortalPortalItem(definition);
1092
- await portalItem.load();
1093
- switch (portalItem.type) {
1094
- case "Web Map": {
1095
- const webMap = await newWebMap({ portalItem });
1096
- return await this._featureSetCollectionFromMap(webMap);
1097
- }
1098
- case "Web Scene": {
1099
- const webScene = await newWebScene({ portalItem });
1100
- return await this._featureSetCollectionFromMap(webScene);
1101
- }
1102
- case "Feature Service":
1103
- return await this._featureSetCollectionFromUrl(portalItem.url);
1104
- default:
1105
- console.error("Unsupported portal item", definition);
1106
- return null;
1107
- }
1108
- }
1109
- async _featureSetCollectionFromUrl(url) {
1110
- let processedUrl = url.replace(/\/featureserver\/[0-9]*/iu, "/FeatureServer");
1111
- processedUrl = processedUrl.replace(/\/mapserver\/[0-9]*/iu, "/MapServer");
1112
- processedUrl = processedUrl.split("?")[0];
1113
- if (!processedUrl) {
1114
- return null;
1115
- }
1116
- const metadata = await serviceMetaData(processedUrl);
1117
- const layersPromise = Promise.all(metadata.layers.map(async (layerInfo) => {
1118
- const featureLayer = await newLayersFeatureLayer({ url: `${processedUrl}/${layerInfo.id}` });
1119
- await featureLayer.load();
1120
- return this._createFeatureSetVariable(featureLayer);
1121
- }));
1122
- const tablesPromise = Promise.all(metadata.tables.map(async (layerInfo) => {
1123
- const table = await newLayersFeatureLayer({ url: `${processedUrl}/${layerInfo.id}` });
1124
- await table.load();
1125
- return this._createFeatureSetVariable(table);
1126
- }));
1127
- const [layers, tables] = await Promise.all([layersPromise, tablesPromise]);
1128
- return { layers, tables, source: processedUrl };
1129
- }
1130
- _convertWebMapLayersToVariables(layers, filteringTables = false) {
1131
- const layerVariables = [];
1132
- layers
1133
- .toArray()
1134
- .reverse()
1135
- .forEach((layer) => {
1136
- if (isFeatureLayerLikeInstance(layer)) {
1137
- layerVariables.push(this._createFeatureSetVariable(layer, true));
1138
- return;
1139
- }
1140
- if (isGroupLayerCapable(layer)) {
1141
- const groupLayerVariables = filteringTables
1142
- ? this._convertWebMapLayersToVariables(layer.allTables, true)
1143
- : this._convertWebMapLayersToVariables(layer.allLayers);
1144
- layerVariables.push(...groupLayerVariables);
1145
- }
1146
- });
1147
- return layerVariables;
1148
- }
1149
- _createFeatureSetVariable(featureLayerLike, isFromWebMap = false) {
1150
- return new FeatureSetVariable(this, {
1151
- profile: this._profile,
1152
- declaration: { name: featureLayerLike.title, definition: featureLayerLike },
1153
- label: isFromWebMap
1154
- ? featureLayerLike.title
1155
- : (featureLayerLike.sourceJSON.name ?? featureLayerLike.title),
1156
- description: "",
1157
- nonInteractive: true,
1158
- }, this._makeFeatureSetSnippets(featureLayerLike, isFromWebMap));
1159
- }
1160
- _makeFeatureSetSnippets(featureLayerLike, isFromWebMap = false) {
1161
- if (!this._profile?.supportFeatureSetFunctions) {
1162
- return [];
1163
- }
1164
- if (isFromWebMap) {
1165
- const snippetById = `FeatureSetById(${this.snippet}, "${featureLayerLike.id}")`;
1166
- const snippetByName = `FeatureSetByName(${this.snippet}, "${featureLayerLike.title}")`;
1167
- return [
1168
- new ValueVariable({ profile: this._profile, label: snippetById, description: "", snippet: snippetById }),
1169
- new ValueVariable({ profile: this._profile, label: snippetByName, description: "", snippet: snippetByName }),
1170
- ];
1171
- }
1172
- else {
1173
- const snippetById = `FeatureSetById(${this.snippet}, "${featureLayerLike.layerId}")`;
1174
- return [new ValueVariable({ profile: this._profile, label: snippetById, description: "", snippet: snippetById })];
1175
- }
1176
- }
1177
- toProfileVariableDefinition() {
1178
- return { type: this.type, name: "", ...this.declaration, definition: this._definition };
1179
- }
1180
- }
1181
- /**
1182
- * The EditorProfile is an object that represents an Arcade Profile.
1183
- * It is used to display the profile in the editor.
1184
- * It takes an IEditorProfile as a definition and a locale.
1185
- * A EditorPofile instance
1186
- * Some of the variables in the profile are based on layers, web maps, or feature services.
1187
- * They need to be loaded asynchronously to get the metadata necessary for validation and completion.
1188
- */
1189
- class EditorProfile extends DictionaryVariable {
1190
- constructor(definition, intlStrings, locale = "en") {
1191
- // Delay the load of the variable declarations so we have a `this`
1192
- super(undefined, {
1193
- profile: null,
1194
- declaration: { properties: [] },
1195
- });
1196
- this.definition = definition;
1197
- this.intlStrings = intlStrings;
1198
- this.locale = locale;
1199
- this.variables = [];
1200
- // We are the root
1201
- this._profile = this;
1202
- // Now that `this` is defined, we can load the variables
1203
- this.loadPropertyDeclarations(definition?.variables);
1204
- }
1205
- /**
1206
- * Returns true if the profile supports feature set functions for snippets.
1207
- */
1208
- get supportFeatureSetFunctions() {
1209
- return this.definition?.bundles?.includes("data-access") ?? false;
1210
- }
1211
- /**
1212
- * Returns the EditorProfile as a json. The EditorProfile may have been updated. This function allows to
1213
- * get the new json representing mutations.
1214
- */
1215
- toEditorProfileDefinition() {
1216
- return {
1217
- ...this.definition,
1218
- variables: this.dictionaryVariables.map((variable) => variable.toProfileVariableDefinition()),
1219
- };
1220
- }
1221
- }
1222
- //#endregion
1223
-
1224
- async function d(t,i){try{let n=await t,e=new Map,o=new Map,a=[],r=D(i);return n.forEach(p=>{let c=[];p.items.forEach(s=>h(c,o,e,r,s)),c.length&&a.push({...p,items:c});}),{categories:a,functionDefinitions:e,constantDefinitions:o}}catch(n){return console.error(n),{categories:[],functionDefinitions:new Map,constantDefinitions:new Map}}}function D(t){let{profile:{apiVersion:i,bundles:n,hiddenApiItems:e=[]}={}}=t,o=y(i),a=Array.isArray(n)&&n.length>0?new Set(["core",...n]):void 0;return r=>M(o,r.sinceVersion)&&(!a||a.has(r.bundle))&&!e.includes(r.name)}function h(t,i,n,e,o){if(Array.isArray(o)){o.forEach(a=>A(t,n,e,a));return}o.type==="constant"?k(t,i,e,o):A(t,n,e,o);}function A(t,i,n,e){if(!n(e))return;e.disableDocumentation||t.push(e);let{completion:{label:o}}=e,a=o.toLowerCase(),r=i.get(a);r||(r={type:"functionDefinition",key:a,overloads:[]},i.set(a,r)),r.overloads.push(e);}function k(t,i,n,e){if(!n(e))return;t.push(e);let{completion:{label:o}}=e,a=o.toLowerCase();i.set(a,e);let[r,p]=e.completion.label.split(".");if(!p)return;let c=r.toLowerCase(),s=i.get(c);s||(s={type:"namespace",key:c,members:[],completion:{label:r,detail:r,insertText:r,insertTextMode:InsertTextMode.adjustIndentation,insertTextFormat:InsertTextFormat.PlainText,kind:CompletionItemKind.Enum}},i.set(c,s));let l=structuredClone(e);l.name=p,l.completion.label=p,l.completion.insertText=p,l.completion.kind=CompletionItemKind.Constant,s.members.push(l),s.completion.documentation=s.members.reduce((u,m)=>(u.value=`${u.value}${u.value?`
1225
-
1226
- `:""}**${m.completion.label}**: ${m.description}`,u),{kind:MarkupKind.Markdown,value:""});}function y(t){if(!t||typeof t!="string")return null;let i=t.split(".").map(o=>Number.parseInt(o));if(i.some(Number.isNaN))return console.error("Invalid API version string",t),null;let[n,e]=i.slice(0,2);return {major:n,minor:e}}function M(t,i){if(!t)return !0;let n=y(i);return n?t.major>n.major?!1:t.minor===void 0||n.minor===void 0?!0:n.minor<=t.minor:!0}
1227
-
1228
- // this file contains the building blocks for a language default provider
1229
- const defaultContext = {
1230
- locale: "en",
1231
- };
1232
- class LanguageDefaultsBase {
1233
- // #endregion
1234
- constructor(languageId, _apiConfig) {
1235
- this.languageId = languageId;
1236
- this._apiConfig = _apiConfig;
1237
- // #region Protected properties
1238
- this._onDidChange = new Emitter();
1239
- this._modelToProfileMap = new Map();
1240
- this._modelToApiContextMap = new Map();
1241
- this._localeToApiLibraryPromiseMap = new Map();
1242
- this._onModelContextDidChange = new Emitter();
1243
- this._onDidModelContextChangeTimeout = -1;
1244
- /**
1245
- * The worker host is used by the worker to invoke methods on the main thread.
1246
- */
1247
- this.workerHost = {
1248
- getApiLibrary: async (locale) => await this.getApiLibrary(locale),
1249
- };
1250
- editor.onWillDisposeModel((model) => {
1251
- this.disposeForModel(model.uri);
1252
- });
1253
- }
1254
- // #region Protected methods
1255
- _fireModelContextDidChange(key) {
1256
- if (this._onDidModelContextChangeTimeout !== -1) {
1257
- return;
1258
- }
1259
- this._onDidModelContextChangeTimeout = window.setTimeout(() => {
1260
- this._onDidModelContextChangeTimeout = -1;
1261
- this._onModelContextDidChange.fire(key);
1262
- }, 0);
1263
- }
1264
- _getApiKey(modelId) {
1265
- if (!Uri.isUri(modelId)) {
1266
- modelId = Uri.parse(modelId);
1267
- }
1268
- return modelId.toString();
1269
- }
1270
- // #endregion
1271
- // #region Public methods
1272
- get onDidChange() {
1273
- return this._onDidChange.event;
1274
- }
1275
- /**
1276
- * Dispose any cached resources for the model
1277
- */
1278
- disposeForModel(modelId) {
1279
- const key = this._getApiKey(modelId);
1280
- this._modelToProfileMap.delete(key);
1281
- if (this._modelToApiContextMap.delete(key)) {
1282
- this._fireModelContextDidChange(key);
1283
- }
1284
- }
1285
- /**
1286
- * Returns the editor profile for the given model id.
1287
- * @param modelId The model id for which to get the editor profile.
1288
- * @returns The editor profile for the model.
1289
- */
1290
- getEditorProfileForModel(modelId) {
1291
- return this._modelToProfileMap.get(this._getApiKey(modelId));
1292
- }
1293
- /**
1294
- * Returns the API context for the given model id.
1295
- * Returns the default context if the model has no context.
1296
- * @param modelId The model id for which to get the API context.
1297
- * @returns The API context for the model.
1298
- */
1299
- getApiContextForModel(contextId) {
1300
- return this._modelToApiContextMap.get(this._getApiKey(contextId)) ?? defaultContext;
1301
- }
1302
- /**
1303
- * Set or update api context for the given model id.
1304
- * @param modelId The model id for which to set the context.
1305
- * @param apiContext The api context to set.
1306
- */
1307
- updateApiContextForModel(modelId, apiContext) {
1308
- const key = this._getApiKey(modelId);
1309
- const currentApiContext = this._modelToApiContextMap.get(key) ?? {};
1310
- this._modelToApiContextMap.set(key, { ...currentApiContext, ...apiContext });
1311
- this._fireModelContextDidChange(key);
1312
- }
1313
- get onModelContextDidChange() {
1314
- return this._onModelContextDidChange.event;
1315
- }
1316
- /**
1317
- * Gets the API library for the given model id.
1318
- * @param modelId The model id for which to get the API library.
1319
- * @returns The API library for the model.
1320
- */
1321
- async getApiLibraryForModel(modelId) {
1322
- const apiContext = this.getApiContextForModel(modelId);
1323
- const apiLibraryPromise = this.getApiLibrary(apiContext.locale ?? "en");
1324
- return (await d(apiLibraryPromise, apiContext)).categories;
1325
- }
1326
- // #endregion
1327
- //#region Private methods
1328
- async fetchApiLibrary(locale) {
1329
- try {
1330
- const { apiPath, apiPrefix } = this._apiConfig;
1331
- const url = getAssetPath(`${apiPath}/${apiPrefix}${locale}.json`);
1332
- const response = await fetch(url);
1333
- if (response.ok) {
1334
- return await response.json();
1335
- }
1336
- return [];
1337
- }
1338
- catch {
1339
- return [];
1340
- }
1341
- }
1342
- async getApiLibrary(locale) {
1343
- const normalizedLocale = normalizeLocale(locale);
1344
- if (!this._localeToApiLibraryPromiseMap.has(normalizedLocale)) {
1345
- // Make this atomic to avoid multiple fetches
1346
- this._localeToApiLibraryPromiseMap.set(normalizedLocale, this.fetchApiLibrary(normalizedLocale));
1347
- }
1348
- return (await this._localeToApiLibraryPromiseMap.get(normalizedLocale)) ?? [];
1349
- }
1350
- }
1351
-
1352
- export { EditorProfile as E, LanguageDefaultsBase as L, isFeatureSetCollectionDefinition as a, isFeatureSetDefinition as b, isFeatureDefinition as c, fieldsToProfileValues as f, isPredefinedProfile as i };