@vertigis/arcgis-extensions 33.3.1 → 33.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/AppConfig.schema.json +10 -5
  2. package/config.d.ts +7 -3
  3. package/config.js +1 -1
  4. package/data/Feature.js +1 -1
  5. package/data/_Relationship.d.ts +1 -1
  6. package/data/convert.js +1 -1
  7. package/data/support/DefaultRelationshipFactory.js +1 -1
  8. package/data/support/DefaultTableExtensionFactory.js +1 -1
  9. package/declarations/arcgis-js-api-extensions/index.d.ts +49 -21
  10. package/docs/html/assets/js/search.js +1 -1
  11. package/docs/html/classes/data__tableextension.tableextension.html +53 -53
  12. package/docs/html/classes/data__tableextension.tablefeaturesettings.html +5 -5
  13. package/docs/html/classes/data__tableextension.tableschema.html +4 -4
  14. package/docs/html/classes/data_arcgisservicetableextension.arcgisservicetableextension.html +47 -47
  15. package/docs/html/classes/data_attachment.attachment.html +24 -24
  16. package/docs/html/classes/data_feature.feature.html +27 -27
  17. package/docs/html/classes/data_featurelist.featurelist.html +17 -17
  18. package/docs/html/classes/data_featureset.featureset.html +23 -23
  19. package/docs/html/classes/data_featuresettings.featuresettings.html +5 -5
  20. package/docs/html/classes/data_featuresourcebase.featuresourcebase.html +61 -61
  21. package/docs/html/classes/data_featuresourcebase.relationshipcollection.html +4 -4
  22. package/docs/html/classes/data_featurestream.featurestream.html +30 -30
  23. package/docs/html/classes/data_fieldextension.fieldextension.html +22 -22
  24. package/docs/html/classes/data_relationshipbase.relationshipbase.html +36 -36
  25. package/docs/html/classes/data_schema.schema.html +4 -4
  26. package/docs/html/classes/data_support_defaultrelationshipfactory.defaultrelationshipfactory.html +2 -2
  27. package/docs/html/classes/data_tasksettings.tasksettings.html +5 -5
  28. package/docs/html/classes/entity.entitybase.html +26 -26
  29. package/docs/html/classes/hyperlink.hyperlink-1.html +6 -6
  30. package/docs/html/classes/languageresources.languageresources-1.html +14 -14
  31. package/docs/html/classes/layer_preset_layerpreset.layerpreset.html +24 -24
  32. package/docs/html/classes/layer_preset_layerpresetsettings.layerpresetsetting.html +6 -6
  33. package/docs/html/classes/mapping__layerextension.arraywrappedcollection.html +2 -2
  34. package/docs/html/classes/mapping__layerextension.layerextension.html +45 -45
  35. package/docs/html/classes/mapping__layerextension.layerextensionschema.html +10 -10
  36. package/docs/html/classes/mapping__sublayerextension.sublayerextension.html +44 -44
  37. package/docs/html/classes/mapping__sublayerextension.sublayerschema.html +4 -4
  38. package/docs/html/classes/mapping__sublayerextension.subsublayerextensioncollection.html +13 -13
  39. package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerextension.html +42 -42
  40. package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerfeaturesettings.html +12 -12
  41. package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerrelationshipcollection.html +11 -11
  42. package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerschema.html +17 -17
  43. package/docs/html/classes/mapping_basemapextension.basemapextension.html +19 -19
  44. package/docs/html/classes/mapping_bookmark.bookmark.html +24 -24
  45. package/docs/html/classes/mapping_buildingcomponentsublayerextension.buildingcomponentsublayerextension.html +43 -43
  46. package/docs/html/classes/mapping_buildingcomponentsublayerextension.buildingcomponentsublayerschema.html +4 -4
  47. package/docs/html/classes/mapping_buildinggroupsublayerextension.buildinggroupsublayerextension.html +43 -43
  48. package/docs/html/classes/mapping_buildinggroupsublayerextension.buildinggroupsublayerschema.html +4 -4
  49. package/docs/html/classes/mapping_buildingscenelayerextension.buildingscenelayerextension.html +44 -44
  50. package/docs/html/classes/mapping_buildingscenelayerextension.buildingscenelayerreadonlyschema.html +10 -10
  51. package/docs/html/classes/mapping_buildingsublayerextension.buildingsublayerextension.html +43 -43
  52. package/docs/html/classes/mapping_buildingsublayerextension.buildingsublayerfeaturesettings.html +4 -4
  53. package/docs/html/classes/mapping_buildingsublayerextension.buildingsublayerschema.html +4 -4
  54. package/docs/html/classes/mapping_csvlayerextension.csvlayerextension.html +43 -43
  55. package/docs/html/classes/mapping_elevationlayerextension.elevationlayerextension.html +44 -44
  56. package/docs/html/classes/mapping_featurecollectionlayerextension.featurecollectionlayerextension.html +42 -42
  57. package/docs/html/classes/mapping_featurelayerextension.featurelayerextension.html +37 -37
  58. package/docs/html/classes/mapping_featurelayerextensionbase.featurelayerextensionbase.html +42 -42
  59. package/docs/html/classes/mapping_featurelayerextensionbase.featurelayerschema.html +8 -8
  60. package/docs/html/classes/mapping_georsslayerextension.georsslayerextension.html +44 -44
  61. package/docs/html/classes/mapping_graphicslayerextension.graphicslayerextension.html +44 -44
  62. package/docs/html/classes/mapping_groundextension.groundextension.html +19 -19
  63. package/docs/html/classes/mapping_grouplayerextension.grouplayerextension.html +45 -45
  64. package/docs/html/classes/mapping_grouplayerextension.grouplayerextensioncollection.html +14 -14
  65. package/docs/html/classes/mapping_imagerylayerextension.imagerylayerextension.html +43 -43
  66. package/docs/html/classes/mapping_imagerytilelayerextension.imagerytilelayerextension.html +44 -44
  67. package/docs/html/classes/mapping_integratedmeshlayerextension.integratedmeshlayerextension.html +44 -44
  68. package/docs/html/classes/mapping_kmllayerextension.kmllayerextension.html +44 -44
  69. package/docs/html/classes/mapping_kmlsublayerextension.kmlsublayerextension.html +44 -44
  70. package/docs/html/classes/mapping_mapconstraints.mapconstraints.html +5 -5
  71. package/docs/html/classes/mapping_mapextension.mapextension.html +19 -19
  72. package/docs/html/classes/mapping_mapimagelayerextension.mapimagelayerextension.html +44 -44
  73. package/docs/html/classes/mapping_mapimagesublayerextension.mapimagesublayerextension.html +42 -42
  74. package/docs/html/classes/mapping_openstreetmaplayerextension.openstreetmaplayerextension.html +44 -44
  75. package/docs/html/classes/mapping_pointcloudlayerextension.pointcloudlayerextension.html +43 -43
  76. package/docs/html/classes/mapping_scenelayerextension.scenelayerextension.html +43 -43
  77. package/docs/html/classes/mapping_streamlayerextension.streamlayerextension.html +43 -43
  78. package/docs/html/classes/mapping_streamlayerextension.streamlayerschema.html +8 -8
  79. package/docs/html/classes/mapping_support__layerextensioncollection.layerextensioncollectionbase.html +20 -20
  80. package/docs/html/classes/mapping_support__sublayerextensioncollection.sublayerextensioncollectionbase.html +19 -19
  81. package/docs/html/classes/mapping_support_layerlistsettings.extensionbaselayerlistsettings.html +6 -6
  82. package/docs/html/classes/mapping_support_layerlistsettings.layerlistsettings.html +7 -7
  83. package/docs/html/classes/mapping_tilelayerextension.tilelayerextension.html +44 -44
  84. package/docs/html/classes/mapping_tilesublayerextension.tilesublayerextension.html +42 -42
  85. package/docs/html/classes/mapping_vectortilelayerextension.vectortilelayerextension.html +44 -44
  86. package/docs/html/classes/mapping_webtilelayerextension.webtilelayerextension.html +44 -44
  87. package/docs/html/classes/mapping_wmslayerextension.wmslayerextension.html +46 -46
  88. package/docs/html/classes/mapping_wmssublayerextension.wmssublayerextension.html +44 -44
  89. package/docs/html/classes/mapping_wmtslayerextension.wmtslayerextension.html +44 -44
  90. package/docs/html/classes/mapping_wmtssublayerextension.wmtssublayerextension.html +44 -44
  91. package/docs/html/classes/menus_menu.menu.html +22 -22
  92. package/docs/html/classes/menus_menuitem.menuitem.html +49 -49
  93. package/docs/html/classes/support_formatsettings.formatsettings.html +5 -5
  94. package/docs/html/classes/support_initializablebase.initializablebase.html +21 -21
  95. package/docs/html/classes/support_initializablecollectionproxy.initializablecollectionproxy.html +2 -2
  96. package/docs/html/classes/support_serializable.serializablebase.html +8 -8
  97. package/docs/html/classes/support_settings.settings.html +6 -6
  98. package/docs/html/classes/tasks_geocoding_arcgisgeocoder.arcgisgeocoder.html +94 -59
  99. package/docs/html/classes/tasks_geocoding_geocoder.geocoder.html +45 -45
  100. package/docs/html/classes/tasks_identify_buildingcomponentsublayerclientsideidentifyprovider.buildingcomponentsublayerclientsideidentifyprovider.html +20 -20
  101. package/docs/html/classes/tasks_identify_clientsideidentifyprovider.clientsideidentifyprovider.html +2 -2
  102. package/docs/html/classes/tasks_identify_featurelayerclientsideidentifyprovider.featurelayerclientsideidentifyprovider.html +2 -2
  103. package/docs/html/classes/tasks_identify_scenelayerclientsideidentifyprovider.scenelayerclientsideidentifyprovider.html +2 -2
  104. package/docs/html/classes/tasks_identify_streamlayerclientsidequeryidentifyprovider.streamlayerclientsidequeryidentifyprovider.html +2 -2
  105. package/docs/html/classes/tasks_query_arcgisrelationship.arcgisrelationship.html +1655 -0
  106. package/docs/html/classes/tasks_query_buildingcomponentsublayerclientsidequeryprovider.buildingcomponentsublayerclientsidequeryprovider.html +20 -20
  107. package/docs/html/classes/tasks_query_clientsidequeryprovider.clientsidequeryprovider.html +2 -2
  108. package/docs/html/classes/tasks_query_querybasedrelationship.querybasedrelationship.html +82 -64
  109. package/docs/html/classes/tasks_query_scenelayerclientsidequeryprovider.scenelayerclientsidequeryprovider.html +2 -2
  110. package/docs/html/classes/tasks_query_streamlayerclientsidequeryprovider.streamlayerclientsidequeryprovider.html +2 -2
  111. package/docs/html/classes/tasks_search_arcgisgeocodersearchprovider.arcgisgeocodersearchprovider.html +470 -0
  112. package/docs/html/classes/tasks_search_geocodersearchprovider.geocodersearchprovider.html +5 -0
  113. package/docs/html/classes/tasks_search_querysearchprovider.querysearchprovider.html +6 -6
  114. package/docs/html/classes/tasks_search_searchservice.searchservice.html +12 -12
  115. package/docs/html/classes/utilities_date.dateformatter.html +25 -25
  116. package/docs/html/classes/utilities_geometry.coordinatesystembounds.html +5 -5
  117. package/docs/html/classes/utilities_number.numberformatter.html +23 -23
  118. package/docs/html/classes/utilities_uri.uri.html +17 -17
  119. package/docs/html/enums/support_esri.wellknownbasemap.html +21 -21
  120. package/docs/html/enums/utilities_number.numberformat.html +7 -7
  121. package/docs/html/index.html +12 -0
  122. package/docs/html/interfaces/data__relationship.relationship-1.html +1 -1
  123. package/docs/html/interfaces/data__relationship.relationshipproperties.html +1 -1
  124. package/docs/html/interfaces/forked_libs_shp_write.shpfiles.html +6 -6
  125. package/docs/html/interfaces/portal_classbreaksrenderer.classbreaksrenderer.html +4 -4
  126. package/docs/html/interfaces/portal_drawinginfo.drawinginfo-1.html +7 -7
  127. package/docs/html/interfaces/portal_heatmaprenderer.heatmaprenderer.html +4 -4
  128. package/docs/html/interfaces/portal_imageservicelayer.imageservicelayer-1.html +17 -17
  129. package/docs/html/interfaces/portal_layerdefinition.fieldoverride.html +6 -3
  130. package/docs/html/interfaces/portal_layerdefinition.layerdefinition-1.html +70 -47
  131. package/docs/html/interfaces/portal_layerdefinition.layerdefinitiondefaults.html +11 -8
  132. package/docs/html/interfaces/portal_layerdefinition.layertimeinfo.html +12 -9
  133. package/docs/html/interfaces/portal_layerdefinition.orderbyclause.html +244 -0
  134. package/docs/html/interfaces/portal_layerdefinition.timeinfoexportoptions.html +7 -4
  135. package/docs/html/interfaces/portal_pointcloudclassbreaksrenderer.pointcloudclassbreaksrenderer.html +4 -4
  136. package/docs/html/interfaces/portal_pointcloudrenderer.pointcloudrendererbase.html +5 -5
  137. package/docs/html/interfaces/portal_pointcloudrgbrenderer.pointcloudrgbrenderer.html +4 -4
  138. package/docs/html/interfaces/portal_pointcloudstretchrenderer.pointcloudstretchrenderer.html +4 -4
  139. package/docs/html/interfaces/portal_pointclouduniquevaluerenderer.pointclouduniquevaluerenderer.html +4 -4
  140. package/docs/html/interfaces/portal_predominancerenderer.predominancerenderer.html +4 -4
  141. package/docs/html/interfaces/portal_renderer.authoringinfo.html +7 -7
  142. package/docs/html/interfaces/portal_renderer.colorramp.html +5 -5
  143. package/docs/html/interfaces/portal_renderer.rendererbase.html +8 -5
  144. package/docs/html/interfaces/portal_simplerenderer.simplerenderer.html +4 -4
  145. package/docs/html/interfaces/portal_temporalrenderer.temporalrenderer.html +4 -4
  146. package/docs/html/interfaces/portal_uniquevaluefromstyle.uniquevaluefromstyle.html +4 -4
  147. package/docs/html/interfaces/portal_uniquevaluerenderer.uniquevaluerenderer.html +4 -4
  148. package/docs/html/interfaces/portal_vectorfieldrenderer.vectorfieldrenderer.html +394 -0
  149. package/docs/html/interfaces/portal_webmap.webmap-1.html +16 -16
  150. package/docs/html/interfaces/portal_webscene.webscene-1.html +16 -16
  151. package/docs/html/interfaces/support_arcgisrequesthelper.arcgisrequestoptions.html +1 -1
  152. package/docs/html/interfaces/support_esri.accessorlike.html +4 -4
  153. package/docs/html/interfaces/support_esri.changeevent.html +4 -4
  154. package/docs/html/interfaces/support_esri.layerwithsublayers.html +1 -1
  155. package/docs/html/interfaces/support_esri.pointcloudlayercachedstatistics.html +3 -3
  156. package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticsfrequentvalues.html +2 -2
  157. package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticshistogram.html +3 -3
  158. package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticslabel.html +2 -2
  159. package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticslabels.html +1 -1
  160. package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticsstats.html +9 -9
  161. package/docs/html/interfaces/support_esri.sublayerlike.html +14 -14
  162. package/docs/html/interfaces/support_serializable.propertydef.html +5 -5
  163. package/docs/html/interfaces/tasks_geocoding_arcgisgeocoder.arcgisgeocoderproperties.html +5 -5
  164. package/docs/html/interfaces/tasks_query_arcgisrelationship.arcgisrelationshipproperties.html +403 -0
  165. package/docs/html/interfaces/tasks_query_querybasedrelationship.querybasedrelationshipproperties.html +7 -2
  166. package/docs/html/interfaces/utilities_geometry.geographictransformationjson.html +1 -1
  167. package/docs/html/interfaces/utilities_geometry.geographictransformationstepjson.html +3 -3
  168. package/docs/html/interfaces/utilities_geometry.geojsonlinestring.html +2 -2
  169. package/docs/html/interfaces/utilities_geometry.geojsonmultilinestring.html +2 -2
  170. package/docs/html/interfaces/utilities_geometry.geojsonmultipoint.html +2 -2
  171. package/docs/html/interfaces/utilities_geometry.geojsonmultipolygon.html +2 -2
  172. package/docs/html/interfaces/utilities_geometry.geojsonpoint.html +2 -2
  173. package/docs/html/interfaces/utilities_geometry.geojsonpolygon.html +2 -2
  174. package/docs/html/interfaces/utilities_geometry.gmloptions.html +3 -3
  175. package/docs/html/interfaces/utilities_number.formatoptions.html +4 -4
  176. package/docs/html/interfaces/utilities_number.numberformatterproperties.html +5 -5
  177. package/docs/html/interfaces/utilities_number.numbersettings.html +4 -4
  178. package/docs/html/interfaces/utilities_number.parseoptions.html +2 -2
  179. package/docs/html/modules/config.html +1 -6
  180. package/docs/html/modules/data__relationship.html +1 -1
  181. package/docs/html/modules/data_convert.html +5 -5
  182. package/docs/html/modules/data_feature.html +3 -3
  183. package/docs/html/modules/mapping__layerextension.html +1 -1
  184. package/docs/html/modules/mapping_mapextension.html +1 -1
  185. package/docs/html/modules/portal_drawinginfo.drawinginfo.html +2 -2
  186. package/docs/html/modules/portal_imageservicelayer.imageservicelayer.html +2 -2
  187. package/docs/html/modules/portal_layerdefinition.html +6 -2
  188. package/docs/html/modules/portal_layerdefinition.layerdefinition.html +1 -1
  189. package/docs/html/modules/portal_layerdefinition.layerdefinitioncapabilities.html +6 -6
  190. package/docs/html/modules/portal_renderer.html +10 -10
  191. package/docs/html/modules/portal_renderer.renderer.html +2 -2
  192. package/docs/html/modules/portal_vectorfieldrenderer.html +157 -0
  193. package/docs/html/modules/portal_webmap.webmap.html +1 -1
  194. package/docs/html/modules/portal_webscene.webscene.html +1 -1
  195. package/docs/html/modules/support_esri.html +145 -61
  196. package/docs/html/modules/support_serializable.html +12 -12
  197. package/docs/html/modules/tasks_geocoding_utilities.html +164 -0
  198. package/docs/html/modules/tasks_query_arcgisrelationship.html +139 -0
  199. package/docs/html/modules/tasks_query_querybasedrelationship.html +2 -2
  200. package/docs/html/modules/tasks_search_arcgisgeocodersearchprovider.html +130 -0
  201. package/docs/html/modules/tasks_search_searchservice.html +1 -1
  202. package/docs/html/modules/utilities__layers.html +33 -33
  203. package/docs/html/modules/utilities_date.html +3 -3
  204. package/docs/html/modules/utilities_esri.html +2 -2
  205. package/docs/html/modules/utilities_geometry.html +25 -25
  206. package/docs/html/modules/utilities_number.html +7 -7
  207. package/docs/html/modules/utilities_query.html +2 -2
  208. package/docs/html/modules/utilities_relationships.html +2 -2
  209. package/docs/html/modules/utilities_uri.html +6 -6
  210. package/docs/html/modules/version.html +1 -1
  211. package/docs/html/modules.html +16 -0
  212. package/forked-libs/shp-write/src/write.js +1 -1
  213. package/mapping/MapImageLayerExtension.js +1 -1
  214. package/mapping/MapImageSublayerExtension.js +1 -1
  215. package/mapping/support/DefaultLayerExtensionFactory.js +1 -1
  216. package/mapping/support/WfsCapabilities.js +1 -1
  217. package/package.json +30 -31
  218. package/portal/DrawingInfo.js +1 -1
  219. package/portal/ImageServiceLayer.js +1 -1
  220. package/portal/Layer.js +1 -1
  221. package/portal/LayerBase.js +1 -1
  222. package/portal/LayerDefinition.d.ts +24 -0
  223. package/portal/LayerDefinition.js +1 -1
  224. package/portal/Renderer.d.ts +3 -2
  225. package/portal/Renderer.js +1 -1
  226. package/portal/VectorFieldRenderer.d.ts +41 -0
  227. package/portal/VectorFieldRenderer.js +1 -0
  228. package/support/_ArcGISRelationshipCollection.js +1 -1
  229. package/support/_query.js +1 -1
  230. package/support/esri.d.ts +9 -3
  231. package/tasks/geocoding/ArcGISGeocoder.d.ts +9 -1
  232. package/tasks/geocoding/ArcGISGeocoder.js +1 -1
  233. package/tasks/geocoding/utilities.d.ts +7 -0
  234. package/tasks/geocoding/utilities.js +1 -0
  235. package/tasks/identify/ArcGISSublayerQueryIdentifyProvider.js +1 -1
  236. package/tasks/identify/BuildingComponentSublayerClientSideIdentifyProvider.d.ts +13 -1
  237. package/tasks/identify/BuildingComponentSublayerClientSideIdentifyProvider.js +1 -1
  238. package/tasks/identify/CSVLayerClientSideQueryIdentifyProvider.js +1 -1
  239. package/tasks/identify/ClientSideIdentifyProvider.d.ts +1 -1
  240. package/tasks/identify/ClientSideIdentifyProvider.js +1 -1
  241. package/tasks/identify/FeatureLayerQueryIdentifyProvider.js +1 -1
  242. package/tasks/identify/ImageryLayerIdentifyProvider.js +1 -1
  243. package/tasks/identify/SceneLayerClientSideIdentifyProvider.d.ts +1 -1
  244. package/tasks/identify/SceneLayerClientSideIdentifyProvider.js +1 -1
  245. package/tasks/identify/StreamLayerClientSideQueryIdentifyProvider.d.ts +1 -1
  246. package/tasks/identify/WMSSublayerIdentifyProvider.js +1 -1
  247. package/tasks/query/ArcGISRelationship.d.ts +69 -0
  248. package/tasks/query/ArcGISRelationship.js +1 -0
  249. package/tasks/query/ArcGISServiceTableQueryProvider.js +1 -1
  250. package/tasks/query/ArcGISSublayerQueryProvider.js +1 -1
  251. package/tasks/query/BuildingComponentSublayerClientSideQueryProvider.d.ts +12 -1
  252. package/tasks/query/BuildingComponentSublayerClientSideQueryProvider.js +1 -1
  253. package/tasks/query/CSVLayerClientSideQueryProvider.js +1 -1
  254. package/tasks/query/ClientSideQueryProvider.d.ts +1 -1
  255. package/tasks/query/ClientSideQueryProvider.js +1 -1
  256. package/tasks/query/FeatureLayerQueryProvider.js +1 -1
  257. package/tasks/query/ImageryLayerQueryProvider.js +1 -1
  258. package/tasks/query/QueryBasedRelationship.d.ts +3 -3
  259. package/tasks/query/SceneLayerClientSideQueryProvider.d.ts +1 -1
  260. package/tasks/query/SceneLayerQueryProvider.js +1 -1
  261. package/tasks/query/StreamLayerClientSideQueryProvider.d.ts +1 -1
  262. package/tasks/search/ArcGISGeocoderSearchProvider.d.ts +17 -0
  263. package/tasks/search/ArcGISGeocoderSearchProvider.js +1 -0
  264. package/tasks/search/SearchService.js +1 -1
  265. package/utilities/arcade.js +1 -1
  266. package/utilities/esri.d.ts +1 -1
  267. package/utilities/geometry.js +1 -1
  268. package/utilities/number.js +1 -1
  269. package/version.d.ts +1 -1
  270. package/version.js +1 -1
@@ -2286,11 +2286,8 @@
2286
2286
  "description": "Properties that can be used to initialize a {@link Relationship}.",
2287
2287
  "properties": {
2288
2288
  "$relationshipType": {
2289
- "description": "The Relationship's type.",
2290
- "enum": [
2291
- "QueryBasedRelationship"
2292
- ],
2293
- "type": "string"
2289
+ "$ref": "#/definitions/RelationshipType",
2290
+ "description": "The Relationship's type."
2294
2291
  },
2295
2292
  "failureMode": {
2296
2293
  "$ref": "#/definitions/FailureMode",
@@ -2328,6 +2325,9 @@
2328
2325
  }
2329
2326
  ]
2330
2327
  },
2328
+ "RelationshipType": {
2329
+ "description": "The type of the Relationship."
2330
+ },
2331
2331
  "Schema": {
2332
2332
  "description": "Metadata about features, such as fields, domains, geometry type, etc."
2333
2333
  },
@@ -2899,6 +2899,10 @@
2899
2899
  "description": "Information on the source of the item and its copyright status.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#accessInformation)",
2900
2900
  "type": "string"
2901
2901
  },
2902
+ "apiKey": {
2903
+ "description": "An authorization string used to access the portal item.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#apiKey)",
2904
+ "type": "string"
2905
+ },
2902
2906
  "applicationProxies": {
2903
2907
  "description": "Contains an array of objects containing proxy information for premium platform services.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#applicationProxies)",
2904
2908
  "items": {
@@ -3084,6 +3088,7 @@
3084
3088
  "required": [
3085
3089
  "access",
3086
3090
  "accessInformation",
3091
+ "apiKey",
3087
3092
  "applicationProxies",
3088
3093
  "avgRating",
3089
3094
  "categories",
package/config.d.ts CHANGED
@@ -4,8 +4,15 @@ import type { Transformation } from "./utilities/transformation.js";
4
4
  interface Config {
5
5
  /**
6
6
  * The geometry service to use for geometry operations.
7
+ *
8
+ * @deprecated Use geometryServiceUrl instead.
7
9
  */
8
10
  geometryService?: GeometryService;
11
+ /**
12
+ * The URL of the geometry service to use for geometry operations that
13
+ * require a geometry service.
14
+ */
15
+ geometryServiceUrl?: string;
9
16
  /**
10
17
  * Automatic datum transformations that will be applied whenever there is a
11
18
  * match between the input and output spatial references during geometry
@@ -23,8 +30,5 @@ interface Config {
23
30
  */
24
31
  heatmapsEnabled: boolean;
25
32
  }
26
- /**
27
- * Default API configuration.
28
- */
29
33
  export declare const config: Config;
30
34
  export {};
package/config.js CHANGED
@@ -1 +1 @@
1
- export const config={autoTransformations:[],portals:new Map,heatmapsEnabled:!0};
1
+ export class ConfigImpl{constructor(){this.autoTransformations=[],this.portals=new Map,this.heatmapsEnabled=!0}get geometryService(){return this._geometryService}set geometryService(e){console.warn("The 'config.geometryService' property has been deprecated as of August 2021 and will be removed in a future release. Use geometryServiceUrl instead."),this._geometryService=e}}export const config=new ConfigImpl;
package/data/Feature.js CHANGED
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import Graphic from"@arcgis/core/Graphic";import*as Arcade from"@arcgis/core/arcade/arcade";import{EntityBase}from"../Entity.js";import{Hyperlink}from"../Hyperlink.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{toEsriApiGeometry,toPortalGeometry}from"../portal/Geometry.js";import{serializable}from"../support/Serializable.js";import{MapTransformCollection}from"../utilities/MapTransformCollection.js";import{ObservableMap}from"../utilities/ObservableMap.js";import{ReadOnlyMap}from"../utilities/ReadOnlyMap.js";import{arcadeScriptUsesGeometry,isArcadeScriptAsync,runArcadeExpression,runAsyncArcadeExpression}from"../utilities/arcade.js";import{flatten,groupBy}from"../utilities/array.js";import{checkArg}from"../utilities/checkArg.js";import{Collection}from"../utilities/collection.js";import{parse as parseDate,esriFormatToGeocortexFormat}from"../utilities/date.js";import{isCodedValueDomain}from"../utilities/esri.js";import{some,map as mapIterable,concat,forEach,find}from"../utilities/iterable.js";import{getLogger}from"../utilities/log.js";import{parse as parseNumber,NumberFormat}from"../utilities/number.js";import{map as promiseMap}from"../utilities/promise.js";import{format as formatString}from"../utilities/string.js";import{FeatureSettings}from"./FeatureSettings.js";import{_fieldWithArcadeXRegex,_fieldWithRelationshipRegex,Schema}from"./Schema.js";const log=getLogger("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let Feature=class extends EntityBase{constructor(e){super(e),this._itemType=ItemType.FEATURE,this._expressionFieldValues=new ObservableMap,this._expressionValuesUpdatePending=!1,this.settings=new FeatureSettings,this.settings._setFeature(this),this.schema=new Schema,this.schema._featureSettings=this.settings,this.attachments=new Collection,this.attributes=new ObservableMap,this._relatedFeatures=new ObservableMap,this.expressionFieldValues=new ExpressionFieldsValuesImpl(this._expressionFieldValues,this)}get geometry(){return this._geometry}set geometry(e){var t;this._notifyChange("geometryType"),this._geometry=toEsriApiGeometry(e),this.schema.spatialReference=null===(t=this._geometry)||void 0===t?void 0:t.spatialReference}get geometryType(){return this.geometry?this.geometry.type:void 0}get source(){return this._source}set source(e){this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.settings.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0)}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get presentableAttributes(){return this._presentableAttributes=this._presentableAttributes||new PresentableAttributesImpl(this),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new HyperlinksCollection(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get _hydrationStatus(){var e,t;return this._featureHydrationStatus?this._featureHydrationStatus:(null===(t=null===(e=this.source)||void 0===e?void 0:e.capabilities)||void 0===t?void 0:t.supportsQuery)&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){var e;if(null===(e=this.settings.popupTemplate)||void 0===e?void 0:e.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}format(e,...t){let r="string"==typeof e?{format:e}:e;checkArg("options",r).isNotMissing();const{format:i}=r;checkArg("format",i).isNotMissing();let s=r.format.replace(escapedBraceRegex,escapedBracePlaceholder);return s=s.replace(fieldTokenRegex,((e,t,i,s,a)=>formatAttribute(this,t||i,s,{...r,format:a?`{0:${a}}`:"{0}"}))),s=s.replace(escapedBracePlaceholderRegex,"{{"),r={...r},r.format=s,formatString(r,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}async fetchExpressionInfos(e=!1){var t;const{expressionInfos:r}=null!==(t=this.settings.popupTemplate)&&void 0!==t?t:{};if(r)return await Promise.all(r.map((async e=>{var t,r,i,s,a;try{const o=null!==(r=null===(t=this.source)||void 0===t?void 0:t.layer)&&void 0!==r?r:null===(i=this.source)||void 0===i?void 0:i.sublayer;let n=null===(s=this.source)||void 0===s?void 0:s.mapExtension;if(!n){const e=null===(a=this.source)||void 0===a?void 0:a.layerExtension;n=null==e?void 0:e.mapExtension}this._expressionFieldValues.set(e.name,await runAsyncArcadeExpression(e.expression,{layer:o,map:null==n?void 0:n.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,invalidRelationshipOrExpression)}}))),e?this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))})):void 0}async fetchRelatedFeatures(e){if(!this.source)return;let t;if(e){const r="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!r||!this.source.relationships.includes(r))throw new InvalidOperationError("Relationship not found in feature source.");t=[r]}else t=this.source.relationships.toArray();const r=await promiseMap(t,(async e=>[e,await e.getRelatedFeatures(this)]));for(const e of r)this._relatedFeatures.set(e[0],e[1])}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);for(const t of e){const e=this.attachments.findIndex((e=>e.id===t.id));e>=0?this.attachments.splice(e,1,t):this.attachments.add(t)}}}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{var t;const r={};if("project"===e&&this.primaryKey&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery)r[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,t]of this.attributes.entries())r[e]=t;return r},deserialize:e=>{if(this.attributes.clear(),e instanceof Map)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,r]of Object.entries(e))this.attributes.set(t,r)}},geometry:{serializeModes:["project"],serialize:e=>{var t;return"project"===e&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery?this.getDefault("geometry"):toPortalGeometry(this.geometry)},deserialize:e=>this.geometry=toEsriApiGeometry(e)},settings:{serializeModes:["project"],serialize:e=>{var t;return"project"===e&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)}},schema:{serializeModes:["project"],serialize:e=>{var t;return"project"===e&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)}},source:["project"]}}_watchProperty(e,t,r,i){if("title"===e||"description"===e){const s=super._watchProperty(e,t,r,i),a="title"===e?"settings.popupTemplate.title":"settings.popupTemplate.content",o=this.watch(a,(()=>{this._notifyChange(e)})),n=this.presentableAttributes.on("change",(()=>{this._notifyChange(e)}));return{remove(){s.remove(),o.remove(),n.remove()}}}return super._watchProperty(e,t,r,i)}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],r=[];for(const i of e)t.includes(i)?r.push(this.fetchRelatedFeatures(i)):log.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(r)}_findRelationshipIds(...e){const t=[];for(const r of e){let e;const i=r.replace(escapedBraceRegex,escapedBracePlaceholder);for(;e=relationshipIdRegex.exec(i),null!==e;){const r=e[0];t.includes(r)||t.push(e[1])}}return t}};Feature=__decorate([serializable],Feature);export{Feature};export function toFeature(e,t){const r=new Feature(t);for(const t of Object.keys(e.attributes))r.attributes.set(t,e.attributes[t]);return r.geometry=e.geometry,e.popupTemplate&&(r.settings.popupTemplate=e.popupTemplate),r}export function toGraphic(e){var t,r;const i=new Graphic;i.attributes={};for(const t of e.attributes.keys())i.attributes[t]=e.attributes.get(t);return(null===(t=e.source)||void 0===t?void 0:t.layer)&&(i.layer=null===(r=e.source)||void 0===r?void 0:r.layer),i.geometry=e.geometry,e.settings.popupTemplate&&(i.popupTemplate=e.settings.popupTemplate),i}const ERR_PRESENTABLE_ATTRIBUTES_READONLY="Presentable attributes are read-only.",ERR_HYPERLINK_READONLY="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class ExpressionFieldsValuesImpl extends ReadOnlyMap{constructor(e,t){super(e),this._feature=t}get(e){var t,r;if(!super.has(e)){const{spatialReference:i}=this._feature.schema,s=null===(r=null===(t=this._feature.settings.popupTemplate)||void 0===t?void 0:t.expressionInfos)||void 0===r?void 0:r.find((t=>t.name===e));if(!s)return;(async()=>{var t,r,a,o,n;try{if(isArcadeScriptAsync(s.expression,i)){const l=null!==(r=null===(t=this._feature.source)||void 0===t?void 0:t.layer)&&void 0!==r?r:null===(a=this._feature.source)||void 0===a?void 0:a.sublayer;let p=null===(o=this._feature.source)||void 0===o?void 0:o.mapExtension;if(!p){const e=null===(n=this._feature.source)||void 0===n?void 0:n.layerExtension;p=null==e?void 0:e.mapExtension}this._originalMap.set(e,await runAsyncArcadeExpression(s.expression,{feature:this._feature,layer:l,map:null==p?void 0:p.map,spatialReference:i}))}else await Arcade.load(),arcadeScriptUsesGeometry(s.expression,i)&&await Arcade.enableGeometrySupport(),this._originalMap.set(e,runArcadeExpression(s.expression,{feature:this._feature,spatialReference:i}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,invalidRelationshipOrExpression)}})()}return super.get(e)}}class PresentableAttributesImpl extends ReadOnlyMap{constructor(e){super(new ObservableMap),this._feature=e}get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}clear(){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}delete(e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}forEach(e,t){checkArg("callback",e).isNotMissing();for(const r of this.keys())e.call(t,this.get(r),r,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){return some(this.keys(),(t=>t===e))}set(...e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}*entries(){yield*mapIterable(this.keys(),(e=>[e,this.get(e)]))}*keys(){var e;const t=this._feature.schema.fields.expressionFields.map((e=>e.name)),r=[];(null===(e=this._feature.source)||void 0===e?void 0:e.relationships)&&this._feature.source.relationships.filter((e=>"one-to-one"===e.cardinality||"many-to-one"===e.cardinality)).forEach((e=>r.push(...e.relatedSource.schema.fields.map((t=>`relationships/${e.id}/${t.name}`)).toArray()))),yield*concat(this._feature.attributes.keys(),t.toArray(),r)}*values(){yield*mapIterable(this.keys(),(e=>this.get(e)))}[Symbol.iterator](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(checkArg("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,r=()=>{t.forEach((e=>e.remove())),t.clear()},i=()=>{const t={added:Array.from(this.entries()).filter((t=>t[1]!==e.get(t[0]))),removed:Array.from(e.entries()).filter((e=>!this.has(e[0])||e[1]!==this.get(e[0]))),target:this};(t.added.length||t.removed.length)&&(this.emit("change",t),s())},s=()=>{e.clear(),r(),forEach(this.keys(),(r=>{const s=this._getFieldExtension(r);let a="{0}";if(s){const e=s.watch("format",(()=>{i()}));t.add(e),s.format&&(a=s.format)}e.set(r,this._formatAttribute(r,a))}))};s();const a=this._feature.attributes.on("change",(()=>{i()})),o=this._feature.schema.fieldExtensions.on("change",(()=>{i()})),n=this._feature.settings.formatSettings.watch(["numberFormat","dateFormat","locale"],(()=>{i()})),l=this._feature.expressionFieldValues.on("change",(()=>{i()})),p=this._feature.schema.fields.on("change",(e=>{var t,r;((null===(t=e.added)||void 0===t?void 0:t.some((e=>null!==e.name.match(_fieldWithArcadeXRegex))))||(null===(r=e.removed)||void 0===r?void 0:r.some((e=>null!==e.name.match(_fieldWithArcadeXRegex)))))&&i()})),u=this._feature.settings.watch("popupTemplate",(()=>{i()}));this._onAllObserversRemoved=()=>{l.remove(),a.remove(),o.remove(),p.remove(),n.remove(),u.remove(),e.clear(),r()}}const r=super.on("change",t);return this._numObservers++,{remove:()=>{r.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}watch(e,t){if("size"===e){const e=this._feature.attributes.watch("size",((e,r)=>{t(e+this._feature.schema.fields._expressionFieldsLength,r+this._feature.schema.fields._expressionFieldsLength,"size",this)})),r=this._feature.schema.fields.watch("_expressionFieldsLength",((e,r)=>{t(e+this._feature.attributes.size,r+this._feature.attributes.size,"size",this)}));return{remove:()=>{e.remove(),r.remove()}}}return super.watch(e,t)}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const r=e.match(_fieldWithArcadeXRegex),i=e.match(_fieldWithRelationshipRegex);if(r)return formatAttribute(this._feature,"expression",r[1],{format:t});if(i){const[,e,r]=i;return formatAttribute(this._feature,e,r,{format:t})}return formatAttribute(this._feature,void 0,e,{format:t})}}const fieldTokenRegex=/\{(?:relationships[\\/](\w\w*)[\\/])?(?:(expression)[\\/])?([a-zA-Z][.\w]*)(?::([^}]*))?\}/g,relationshipIdRegex=/\{relationships\/(\w\w*)[\\/]([^}]*)\}/g,escapedBraceRegex=/{{/g,escapedBracePlaceholder="\0MAGIC\0",escapedBracePlaceholderRegex=new RegExp(escapedBracePlaceholder,"g"),invalidRelationshipOrExpression="#INVALID";class HyperlinksCollection extends MapTransformCollection{constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}_getHyperlink(e){return this._hyperlinks=this._hyperlinks||new WeakMap,this._hyperlinks.has(e)||this._hyperlinks.set(e,new FeatureHyperlink(this._feature,e)),this._hyperlinks.get(e)}}let FeatureHyperlink=class extends Hyperlink{constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t}get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}_watchProperty(e,t,r,i){const s=super._watchProperty(e,t,r,i),a=this._template.watch(e,(()=>{this._notifyChange(e)})),o=this._feature.presentableAttributes.on("change",(()=>{this._notifyChange(e)}));return{remove:()=>{s.remove(),a.remove(),o.remove()}}}_getSerializableProperties(){return{}}};function formatAttribute(e,t,r,i={format:"{0}"}){var s,a,o,n;if("expression"!==t){if(t){const s=find(e.relatedFeatures.keys(),(e=>e.id===t));if(!s)return log.debug("Could not resolve related field '{0}/{1}",t,r),invalidRelationshipOrExpression;const a=Array.from(e.relatedFeatures.get(s));return"many-to-one"===s.cardinality||"one-to-one"===s.cardinality?a.length<1?(log.debug("Could not resolve related field '{0}/{1}",t,r),invalidRelationshipOrExpression):formatAttributeValue(a[0],r,i):a.map((e=>formatAttributeValue(e,r,i))).filter((e=>""!==e)).join(",")}return formatAttributeValue(e,r,i)}if(!(null===(a=null===(s=e.settings.popupTemplate)||void 0===s?void 0:s.expressionInfos)||void 0===a?void 0:a.find((e=>e.name===r))))return log.debug("Could not find expression '{0}'.",r),invalidRelationshipOrExpression;try{const t=null!==(n=null!==(o=e.expressionFieldValues.get(r))&&void 0!==o?o:i.defaultExpressionValue)&&void 0!==n?n:"",s=e.schema.findFieldByName(`expression/${r}`);let a=i;if(s){const t=e.schema.fieldExtensions.forField(s);a=formatOptionsForField(e,r,formatOptionsFromSettings(t.formatSettings),a)}return formatValue(e,t,a)}catch(e){if(e instanceof Error)return log.error({message:"Error evaluating expression '{0}': {1}.",error:e},r,e.message),invalidRelationshipOrExpression;throw e}}function formatAttributeValue(e,t,r){var i,s;let a=e.attributes.get(t);if(null==a)return"";const o=e.schema.findFieldByName(t);let n={format:"{0}"};const l=null===(s=null===(i=e.type)||void 0===i?void 0:i.domains)||void 0===s?void 0:s[t];if(t===e.schema.typeIdField)a=e.type?e.type.name:a;else if(isCodedValueDomain(l)){const e=l.codedValues.find((e=>`${e.code}`==`${a.toString()}`));a=e?e.name:a}else if(o)if(isCodedValueDomain(o.domain)){const e=o.domain.codedValues.find((e=>`${e.code}`==`${a.toString()}`));e&&(a=e.name)}else{switch(o.type){case"integer":case"small-integer":case"single":case"double":a=parseNumber(a);break;case"date":a=parseDate({timeZone:e.schema.timeZone},a);break;default:a=`${a.toString()}`}n=formatOptionsFromSettings(e.schema.fieldExtensions.forField(o).formatSettings)}return formatValue(e,a,formatOptionsForField(e,t,n,r))}function formatValue(e,t,r){let i=r;if("number"==typeof t||t instanceof Date){i={...formatOptionsFromSettings(e.settings.formatSettings),...r}}return"{0}"===i.format&&"string"==typeof t?t:formatString(i,t)}function formatOptionsFromSettings(e){return{format:"{0}",dateFormat:e.dateFormat,numberFormat:e.numberFormat,currency:e.currency,fractionalDigits:e.fractionalDigits,locale:e.locale,timeZone:e.timeZone}}function formatOptionsForField(e,t,r,i){const{popupTemplate:s}=e.settings,a=(null==s?void 0:s.fieldInfos)?s.fieldInfos.find((e=>e.fieldName===t)):void 0,o=a?a.format:void 0;let n;return o&&(n={format:"{0}",numberFormat:o.digitSeparator?NumberFormat.NUMBER:NumberFormat.FIXED_POINT,dateFormat:esriFormatToGeocortexFormat(o.dateFormat),fractionalDigits:o.places}),{...n,...r,...i}}FeatureHyperlink=__decorate([serializable],FeatureHyperlink);export async function resolveRelatedFeatures(e){const t=groupBy(e,(e=>e.source));await Promise.all(flatten([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,r])=>{t.relatedFeatures.set(e,r)}))})(e))))}
1
+ import{__decorate}from"tslib";import Graphic from"@arcgis/core/Graphic";import*as Arcade from"@arcgis/core/arcade/arcade";import{EntityBase}from"../Entity.js";import{Hyperlink}from"../Hyperlink.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{toEsriApiGeometry,toPortalGeometry}from"../portal/Geometry.js";import{serializable}from"../support/Serializable.js";import{MapTransformCollection}from"../utilities/MapTransformCollection.js";import{ObservableMap}from"../utilities/ObservableMap.js";import{ReadOnlyMap}from"../utilities/ReadOnlyMap.js";import{arcadeScriptUsesGeometry,isArcadeScriptAsync,runArcadeExpression,runAsyncArcadeExpression}from"../utilities/arcade.js";import{flatten,groupBy}from"../utilities/array.js";import{checkArg}from"../utilities/checkArg.js";import{Collection}from"../utilities/collection.js";import{parse as parseDate,esriFormatToGeocortexFormat}from"../utilities/date.js";import{isCodedValueDomain}from"../utilities/esri.js";import{some,map as mapIterable,concat,forEach,find}from"../utilities/iterable.js";import{getLogger}from"../utilities/log.js";import{parse as parseNumber,NumberFormat}from"../utilities/number.js";import{map as promiseMap}from"../utilities/promise.js";import{format as formatString}from"../utilities/string.js";import{FeatureSettings}from"./FeatureSettings.js";import{_fieldWithArcadeXRegex,_fieldWithRelationshipRegex,Schema}from"./Schema.js";const log=getLogger("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let Feature=class extends EntityBase{constructor(e){super(e),this._itemType=ItemType.FEATURE,this._expressionFieldValues=new ObservableMap,this._expressionValuesUpdatePending=!1,this.settings=new FeatureSettings,this.settings._setFeature(this),this.schema=new Schema,this.schema._featureSettings=this.settings,this.attachments=new Collection,this.attributes=new ObservableMap,this._relatedFeatures=new ObservableMap,this.expressionFieldValues=new ExpressionFieldsValuesImpl(this._expressionFieldValues,this)}get geometry(){return this._geometry}set geometry(e){var t;this._notifyChange("geometryType"),this._geometry=toEsriApiGeometry(e),this.schema.spatialReference=null===(t=this._geometry)||void 0===t?void 0:t.spatialReference}get geometryType(){return this.geometry?this.geometry.type:void 0}get source(){return this._source}set source(e){this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.settings.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0)}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get presentableAttributes(){return this._presentableAttributes=this._presentableAttributes||new PresentableAttributesImpl(this),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new HyperlinksCollection(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get _hydrationStatus(){var e,t;return this._featureHydrationStatus?this._featureHydrationStatus:(null===(t=null===(e=this.source)||void 0===e?void 0:e.capabilities)||void 0===t?void 0:t.supportsQuery)&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){var e;if(null===(e=this.settings.popupTemplate)||void 0===e?void 0:e.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}format(e,...t){let r="string"==typeof e?{format:e}:e;checkArg("options",r).isNotMissing();const{format:i}=r;checkArg("format",i).isNotMissing();let s=r.format.replace(escapedBraceRegex,escapedBracePlaceholder);return s=s.replace(fieldTokenRegex,((e,t,i,s,a)=>formatAttribute(this,t||i,s,{...r,format:a?`{0:${a}}`:"{0}"}))),s=s.replace(escapedBracePlaceholderRegex,"{{"),r={...r},r.format=s,formatString(r,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}async fetchExpressionInfos(e=!1){var t;const{expressionInfos:r}=null!==(t=this.settings.popupTemplate)&&void 0!==t?t:{};if(r)return await Promise.all(r.map((async e=>{var t,r,i,s,a;try{const o=null!==(r=null===(t=this.source)||void 0===t?void 0:t.layer)&&void 0!==r?r:null===(i=this.source)||void 0===i?void 0:i.sublayer;let n=null===(s=this.source)||void 0===s?void 0:s.mapExtension;if(!n){const e=null===(a=this.source)||void 0===a?void 0:a.layerExtension;n=null==e?void 0:e.mapExtension}this._expressionFieldValues.set(e.name,await runAsyncArcadeExpression(e.expression,{layer:o,map:null==n?void 0:n.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,invalidRelationshipOrExpression)}}))),e?this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))})):void 0}async fetchRelatedFeatures(e){if(!this.source)return;let t;if(e){const r="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!r||!this.source.relationships.includes(r))throw new InvalidOperationError("Relationship not found in feature source.");t=[r]}else t=this.source.relationships.toArray();const r=await promiseMap(t,(async e=>[e,await e.getRelatedFeatures(this)]));for(const e of r)this._relatedFeatures.set(e[0],e[1])}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);for(const t of e){const e=this.attachments.findIndex((e=>e.id===t.id));e>=0?this.attachments.splice(e,1,t):this.attachments.add(t)}}}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{var t;const r={};if("project"===e&&this.primaryKey&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery)r[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,t]of this.attributes.entries())r[e]=t;return r},deserialize:e=>{if(this.attributes.clear(),e instanceof Map)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,r]of Object.entries(e))this.attributes.set(t,r)}},geometry:{serializeModes:["project"],serialize:e=>{var t;return"project"===e&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery?this.getDefault("geometry"):toPortalGeometry(this.geometry)},deserialize:e=>this.geometry=toEsriApiGeometry(e)},settings:{serializeModes:["project"],serialize:e=>{var t;return"project"===e&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)}},schema:{serializeModes:["project"],serialize:e=>{var t;return"project"===e&&(null===(t=this.source)||void 0===t?void 0:t.capabilities).supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)}},source:["project"]}}_watchProperty(e,t,r,i){if("title"===e||"description"===e){const s=super._watchProperty(e,t,r,i),a="title"===e?"settings.popupTemplate.title":"settings.popupTemplate.content",o=this.watch(a,(()=>{this._notifyChange(e)})),n=this.presentableAttributes.on("change",(()=>{this._notifyChange(e)}));return{remove(){s.remove(),o.remove(),n.remove()}}}return super._watchProperty(e,t,r,i)}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],r=[];for(const i of e)t.includes(i)?r.push(this.fetchRelatedFeatures(i)):log.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(r)}_findRelationshipIds(...e){const t=[];for(const r of e){let e;const i=r.replace(escapedBraceRegex,escapedBracePlaceholder);for(;e=relationshipIdRegex.exec(i),null!==e;){const r=e[0];t.includes(r)||t.push(e[1])}}return t}};Feature=__decorate([serializable],Feature);export{Feature};export function toFeature(e,t){const r=new Feature(t);for(const t of Object.keys(e.attributes))r.attributes.set(t,e.attributes[t]);return r.geometry=e.geometry,e.popupTemplate&&(r.settings.popupTemplate=e.popupTemplate),r}export function toGraphic(e){var t,r;const i=new Graphic;i.attributes={};for(const t of e.attributes.keys())i.attributes[t]=e.attributes.get(t);return(null===(t=e.source)||void 0===t?void 0:t.layer)&&(i.layer=null===(r=e.source)||void 0===r?void 0:r.layer),i.geometry=e.geometry,e.settings.popupTemplate&&(i.popupTemplate=e.settings.popupTemplate),i}const ERR_PRESENTABLE_ATTRIBUTES_READONLY="Presentable attributes are read-only.",ERR_HYPERLINK_READONLY="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class ExpressionFieldsValuesImpl extends ReadOnlyMap{constructor(e,t){super(e),this._feature=t}get(e){var t,r;if(!super.has(e)){const{spatialReference:i}=this._feature.schema,s=null===(r=null===(t=this._feature.settings.popupTemplate)||void 0===t?void 0:t.expressionInfos)||void 0===r?void 0:r.find((t=>t.name===e));if(!s)return;(async()=>{var t,r,a,o,n;try{if(isArcadeScriptAsync(s.expression,i)){const l=null!==(r=null===(t=this._feature.source)||void 0===t?void 0:t.layer)&&void 0!==r?r:null===(a=this._feature.source)||void 0===a?void 0:a.sublayer;let p=null===(o=this._feature.source)||void 0===o?void 0:o.mapExtension;if(!p){const e=null===(n=this._feature.source)||void 0===n?void 0:n.layerExtension;p=null==e?void 0:e.mapExtension}this._originalMap.set(e,await runAsyncArcadeExpression(s.expression,{feature:this._feature,layer:l,map:null==p?void 0:p.map,spatialReference:i}))}else arcadeScriptUsesGeometry(s.expression,i)&&await Arcade.enableGeometrySupport(),this._originalMap.set(e,runArcadeExpression(s.expression,{feature:this._feature,spatialReference:i}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,invalidRelationshipOrExpression)}})()}return super.get(e)}}class PresentableAttributesImpl extends ReadOnlyMap{constructor(e){super(new ObservableMap),this._feature=e}get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}clear(){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}delete(e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}forEach(e,t){checkArg("callback",e).isNotMissing();for(const r of this.keys())e.call(t,this.get(r),r,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){return some(this.keys(),(t=>t===e))}set(...e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}*entries(){yield*mapIterable(this.keys(),(e=>[e,this.get(e)]))}*keys(){var e;const t=this._feature.schema.fields.expressionFields.map((e=>e.name)),r=[];(null===(e=this._feature.source)||void 0===e?void 0:e.relationships)&&this._feature.source.relationships.filter((e=>"one-to-one"===e.cardinality||"many-to-one"===e.cardinality)).forEach((e=>r.push(...e.relatedSource.schema.fields.map((t=>`relationships/${e.id}/${t.name}`)).toArray()))),yield*concat(this._feature.attributes.keys(),t.toArray(),r)}*values(){yield*mapIterable(this.keys(),(e=>this.get(e)))}[Symbol.iterator](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(checkArg("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,r=()=>{t.forEach((e=>e.remove())),t.clear()},i=()=>{const t={added:Array.from(this.entries()).filter((t=>t[1]!==e.get(t[0]))),removed:Array.from(e.entries()).filter((e=>!this.has(e[0])||e[1]!==this.get(e[0]))),target:this};(t.added.length||t.removed.length)&&(this.emit("change",t),s())},s=()=>{e.clear(),r(),forEach(this.keys(),(r=>{const s=this._getFieldExtension(r);let a="{0}";if(s){const e=s.watch("format",(()=>{i()}));t.add(e),s.format&&(a=s.format)}e.set(r,this._formatAttribute(r,a))}))};s();const a=this._feature.attributes.on("change",(()=>{i()})),o=this._feature.schema.fieldExtensions.on("change",(()=>{i()})),n=this._feature.settings.formatSettings.watch(["numberFormat","dateFormat","locale"],(()=>{i()})),l=this._feature.expressionFieldValues.on("change",(()=>{i()})),p=this._feature.schema.fields.on("change",(e=>{var t,r;((null===(t=e.added)||void 0===t?void 0:t.some((e=>null!==e.name.match(_fieldWithArcadeXRegex))))||(null===(r=e.removed)||void 0===r?void 0:r.some((e=>null!==e.name.match(_fieldWithArcadeXRegex)))))&&i()})),u=this._feature.settings.watch("popupTemplate",(()=>{i()}));this._onAllObserversRemoved=()=>{l.remove(),a.remove(),o.remove(),p.remove(),n.remove(),u.remove(),e.clear(),r()}}const r=super.on("change",t);return this._numObservers++,{remove:()=>{r.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}watch(e,t){if("size"===e){const e=this._feature.attributes.watch("size",((e,r)=>{t(e+this._feature.schema.fields._expressionFieldsLength,r+this._feature.schema.fields._expressionFieldsLength,"size",this)})),r=this._feature.schema.fields.watch("_expressionFieldsLength",((e,r)=>{t(e+this._feature.attributes.size,r+this._feature.attributes.size,"size",this)}));return{remove:()=>{e.remove(),r.remove()}}}return super.watch(e,t)}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const r=e.match(_fieldWithArcadeXRegex),i=e.match(_fieldWithRelationshipRegex);if(r)return formatAttribute(this._feature,"expression",r[1],{format:t});if(i){const[,e,r]=i;return formatAttribute(this._feature,e,r,{format:t})}return formatAttribute(this._feature,void 0,e,{format:t})}}const fieldTokenRegex=/\{(?:relationships[\\/](\w\w*)[\\/])?(?:(expression)[\\/])?([a-zA-Z][.\w]*)(?::([^}]*))?\}/g,relationshipIdRegex=/\{relationships\/(\w\w*)[\\/]([^}]*)\}/g,escapedBraceRegex=/{{/g,escapedBracePlaceholder="\0MAGIC\0",escapedBracePlaceholderRegex=new RegExp(escapedBracePlaceholder,"g"),invalidRelationshipOrExpression="#INVALID";class HyperlinksCollection extends MapTransformCollection{constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}_getHyperlink(e){return this._hyperlinks=this._hyperlinks||new WeakMap,this._hyperlinks.has(e)||this._hyperlinks.set(e,new FeatureHyperlink(this._feature,e)),this._hyperlinks.get(e)}}let FeatureHyperlink=class extends Hyperlink{constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t}get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}_watchProperty(e,t,r,i){const s=super._watchProperty(e,t,r,i),a=this._template.watch(e,(()=>{this._notifyChange(e)})),o=this._feature.presentableAttributes.on("change",(()=>{this._notifyChange(e)}));return{remove:()=>{s.remove(),a.remove(),o.remove()}}}_getSerializableProperties(){return{}}};function formatAttribute(e,t,r,i={format:"{0}"}){var s,a,o,n;if("expression"!==t){if(t){const s=find(e.relatedFeatures.keys(),(e=>e.id===t));if(!s)return log.debug("Could not resolve related field '{0}/{1}",t,r),invalidRelationshipOrExpression;const a=Array.from(e.relatedFeatures.get(s));return"many-to-one"===s.cardinality||"one-to-one"===s.cardinality?a.length<1?(log.debug("Could not resolve related field '{0}/{1}",t,r),invalidRelationshipOrExpression):formatAttributeValue(a[0],r,i):a.map((e=>formatAttributeValue(e,r,i))).filter((e=>""!==e)).join(",")}return formatAttributeValue(e,r,i)}if(!(null===(a=null===(s=e.settings.popupTemplate)||void 0===s?void 0:s.expressionInfos)||void 0===a?void 0:a.find((e=>e.name===r))))return log.debug("Could not find expression '{0}'.",r),invalidRelationshipOrExpression;try{const t=null!==(n=null!==(o=e.expressionFieldValues.get(r))&&void 0!==o?o:i.defaultExpressionValue)&&void 0!==n?n:"",s=e.schema.findFieldByName(`expression/${r}`);let a=i;if(s){const t=e.schema.fieldExtensions.forField(s);a=formatOptionsForField(e,r,formatOptionsFromSettings(t.formatSettings),a)}return formatValue(e,t,a)}catch(e){if(e instanceof Error)return log.error({message:"Error evaluating expression '{0}': {1}.",error:e},r,e.message),invalidRelationshipOrExpression;throw e}}function formatAttributeValue(e,t,r){var i,s;let a=e.attributes.get(t);if(null==a)return"";const o=e.schema.findFieldByName(t);let n={format:"{0}"};const l=null===(s=null===(i=e.type)||void 0===i?void 0:i.domains)||void 0===s?void 0:s[t];if(t===e.schema.typeIdField)a=e.type?e.type.name:a;else if(isCodedValueDomain(l)){const e=l.codedValues.find((e=>`${e.code}`==`${a.toString()}`));a=e?e.name:a}else if(o)if(isCodedValueDomain(o.domain)){const e=o.domain.codedValues.find((e=>`${e.code}`==`${a.toString()}`));e&&(a=e.name)}else{switch(o.type){case"integer":case"small-integer":case"single":case"double":a=parseNumber(a);break;case"date":a=parseDate({timeZone:e.schema.timeZone},a);break;default:a=`${a.toString()}`}n=formatOptionsFromSettings(e.schema.fieldExtensions.forField(o).formatSettings)}return formatValue(e,a,formatOptionsForField(e,t,n,r))}function formatValue(e,t,r){let i=r;if("number"==typeof t||t instanceof Date){i={...formatOptionsFromSettings(e.settings.formatSettings),...r}}return"{0}"===i.format&&"string"==typeof t?t:formatString(i,t)}function formatOptionsFromSettings(e){return{format:"{0}",dateFormat:e.dateFormat,numberFormat:e.numberFormat,currency:e.currency,fractionalDigits:e.fractionalDigits,locale:e.locale,timeZone:e.timeZone}}function formatOptionsForField(e,t,r,i){const{popupTemplate:s}=e.settings,a=(null==s?void 0:s.fieldInfos)?s.fieldInfos.find((e=>e.fieldName===t)):void 0,o=a?a.format:void 0;let n;return o&&(n={format:"{0}",numberFormat:o.digitSeparator?NumberFormat.NUMBER:NumberFormat.FIXED_POINT,dateFormat:esriFormatToGeocortexFormat(o.dateFormat),fractionalDigits:o.places}),{...n,...r,...i}}FeatureHyperlink=__decorate([serializable],FeatureHyperlink);export async function resolveRelatedFeatures(e){const t=groupBy(e,(e=>e.source));await Promise.all(flatten([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,r])=>{t.relatedFeatures.set(e,r)}))})(e))))}
@@ -91,4 +91,4 @@ export declare type GeodatabaseCardinality = "esriRelCardinalityOneToOne" | "esr
91
91
  /**
92
92
  * The type of the Relationship.
93
93
  */
94
- export declare type RelationshipType = "QueryBasedRelationship";
94
+ export declare type RelationshipType = "QueryBasedRelationship" | "ArcGISRelationship";
package/data/convert.js CHANGED
@@ -1 +1 @@
1
- import Point from"@arcgis/core/geometry/Point";import SpatialReference from"@arcgis/core/geometry/SpatialReference";import{translate}from"../locale/language.js";import{toEsriApiGeometry,toPortalGeometry}from"../portal/Geometry.js";import{checkArg,assertNever}from"../utilities/checkArg.js";import{parse as parseDate,format as formatDate,DEFAULT_PARSING_FORMATS,DateFormat,INVALID_DATE}from"../utilities/date.js";import{esriToWKT,esriToGeoJSON,geoJSONToEsri,wktToEsri,esriWkidToWkt,esriWktToWkid,project,isPoint,isMultipoint,isPolyline,isPolygon,isExtent}from"../utilities/geometry.js";import{getLogger}from"../utilities/log.js";import{parse as parseNumber,format as formatNumber,NumberFormat,isNumeric}from"../utilities/number.js";import{Feature}from"./Feature.js";import{FeatureSet}from"./FeatureSet.js";const FORMULA_TRIGGER_CHARS=["=","-","+","@"],QUOTE='"',FIELD_NAME_REGEX=/[^a-zA-Z\d_]/g,DEFAULT_WINDOWS_ROW_DELIMITER="\r\n",DEFAULT_UNIX_ROW_DELIMITER="\n",DEFAULT_SHEET_NAME="sheet1",DEFAULT_EXCEL_DATE_FORMATS=[...DEFAULT_PARSING_FORMATS.map(_convertToExcelDateFormatString),"M/d/yy"],shapefileNameRegex=/(\w+)_(point|multipoint|polyline|polygon)z?/;var DBaseTypes;function _getConvertLogger(){return getLogger("geocortex.api.data.convert")}!function(e){e.DATE="D",e.NUMBER="N",e.STRING="C",e.BOOLEAN="L"}(DBaseTypes||(DBaseTypes={}));export var GeometryFormat;!function(e){e.NONE="NONE",e.WKT="WKT",e.XY="XY",e.XYZ="XYZ",e.LAT_LON="LAT_LONG",e.GEO_JSON="GEO_JSON",e.ARCGIS_JSON="ARCGIS_JSON"}(GeometryFormat||(GeometryFormat={}));export async function toCsv(e,t){checkArg("featureSet",e).isNotMissing();const r=Array.from(e),o={...{useFormattedValues:!1,alwaysQuote:!1,escapeFormulaChars:!0,delimiter:",",dateFormat:DateFormat.ROUND_TRIP,geometryFormat:r.some((e=>void 0!==e.geometry&&null!==e.geometry))?GeometryFormat.WKT:GeometryFormat.NONE,includeByteOrderMark:!0,outSpatialReference:SpatialReference.WGS84,includeHeaderRow:!0,outFields:_getDefaultOutFields(e.source),rowDelimiter:navigator.platform.startsWith("Win")?"\r\n":"\n"},...t},{includeByteOrderMark:a,includeHeaderRow:n,delimiter:i,outFields:s,rowDelimiter:m}=o,l=[];a&&l.push("\ufeff");const u=_getGeometryColumns(r,o),c=_getAttributeColumns(r,s,e.schema,!0),f=_getAttributeColumns(r,s,e.schema,!1);if(n){const e=[];for(const t of u)e.push(_quotify(t,o));for(const t of c)e.push(_quotify(t,o));for(const t of f)e.push(_quotify(t,o));const t=e.join(i)+m;l.push(t)}await Promise.all(r.map((async e=>{const t=[],r=(t,r)=>_quotify(_stringify(_getAttributeValue(e,t,r),r),r);t.push(...await _getCSVGeometry(e.geometry,o)),t.push(...c.map((e=>r(e,o)))),t.push(...f.map((e=>r(e,o))));const a=`${t.join(i)}${m}`;l.push(a)})));return new Blob(l,{type:"text/plain",endings:"\n"===m||"\r\n"===m?"transparent":"native"})}export async function csvToFeatureSet(e,t){let r;if(checkArg("csvData",e).isNotMissing(),e instanceof Blob){const t=new Promise(((t,r)=>{const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{r(o.error)},o.readAsText(e)}));r=await t}else r=e;const o={...{delimiter:",",escapeFormulaChars:!0,includeHeaderRow:!0,outFields:["*"],inSpatialReference:SpatialReference.WGS84,generatePrimaryKey:!0,primaryKeyField:"OBJECTID"},...t,detectOid:!(null==t?void 0:t.primaryKeyField)},a=_parseCSV(r,o.rowDelimiter||_parseRowDelimiter(r),o.delimiter),n=_parseGeometries(a,o),i=_parseSchema(a,n,o),s=await _parseFeatures(a,n,i,o);return new FeatureSet({features:s,schema:i})}export async function toXLSX(e,t){var r;checkArg("featureSet",e).isNotMissing();const o=Array.from(e),a={...{useFormattedValues:!1,includeHeaderRow:!0,escapeFormulaChars:!0,geometryFormat:o.some((e=>void 0!==e.geometry&&null!==e.geometry))?GeometryFormat.WKT:GeometryFormat.NONE,outFields:_getDefaultOutFields(e.source),outSpatialReference:SpatialReference.WGS84,dateFormat:DateFormat.DEFAULT,numberFormat:NumberFormat.DEFAULT,sheetName:"sheet1"},...t},{outFields:n,includeHeaderRow:i,numberFormat:s}=a,m=[],l=_getGeometryColumns(o,a),u=_getAttributeColumns(o,n,e.schema,!0),c=_getAttributeColumns(o,n,e.schema,!1);if(i){const t=l.concat(u).concat(_getXlsxColumnName(c,e.source));m.push(t)}await Promise.all(o.map((async e=>{const t=[];t.push(...await _getGeometry(e.geometry,a));for(const r of u){const o=_toXLSXValue(e.attributes.get(r),a);t.push(o)}for(const r of c){const o=_toXLSXValue(_getAttributeValue(e,r,a),a);t.push(o)}m.push(t)})));const f=await import("xlsx"),p={SheetNames:[],Sheets:{}},d=f.utils.aoa_to_sheet(m,{cellDates:!0});for(const e of Object.keys(d).filter((e=>!e.startsWith("!")))){const t=d[e];"d"===t.t?t.z=_convertToExcelDateFormatString(null!==(r=a.dateFormat)&&void 0!==r?r:DateFormat.ROUND_TRIP):"n"===t.t&&(t.z=_convertToExcelNumberFormatString(s))}p.SheetNames.push(a.sheetName),p.Sheets[a.sheetName]=d;const y=f.write(p,{type:"binary",bookType:"xlsx",compression:!0,bookSST:!0,cellDates:!0}),g=new Uint8Array(y.length);for(let e=0;e<y.length;e++)g[e]=y.charCodeAt(e);return new Blob([g.buffer],{type:"text/plain"})}export async function xlsxToFeatureSet(e,t){checkArg("xlsxData",e).isNotMissing();const r={...{includeHeaderRow:!0,escapeFormulaChars:!0,outFields:["*"],inSpatialReference:SpatialReference.WGS84,generatePrimaryKey:!0,primaryKeyField:"OBJECTID"},...t,detectOid:!(null==t?void 0:t.primaryKeyField)},o=await _parseXLSX(e,r),a=_parseGeometries(o,r),n=_parseSchema(o,a,r),i=await _parseFeatures(o,a,n,r);return new FeatureSet({features:i,schema:n})}export async function toShapefile(e,t){checkArg("featureSet",e).isNotMissing();const[{default:r},o]=await Promise.all([import("jszip"),import("../forked-libs/shp-write/index.js")]),a=Array.from(e),n={...{useFormattedValues:!1,outFields:_getDefaultOutFields(e.source),fileName:e.title||"export"},...t},{outFields:i,outSpatialReference:s,fileName:m}=n,l=new Map,u=a.filter((e=>isPoint(e.geometry)));l.set(u.some((e=>e.geometry.hasZ||e.geometry.hasM))?"POINTZ":"POINT",u);const c=a.filter((e=>isMultipoint(e.geometry)));l.set(c.some((e=>e.geometry.hasZ||e.geometry.hasM))?"MULTIPOINTZ":"MULTIPOINT",c);const f=a.filter((e=>isPolyline(e.geometry)));l.set(f.some((e=>e.geometry.hasZ||e.geometry.hasM))?"POLYLINEZ":"POLYLINE",f);const p=a.filter((e=>isPolygon(e.geometry)||isExtent(e.geometry)));l.set(p.some((e=>e.geometry.hasZ||e.geometry.hasM))?"POLYGONZ":"POLYGON",p);const d=_getAttributeColumns(a,i,e.schema,!0);let y=_getAttributeColumns(a,i,e.schema,!1);y=d.concat(y);const g=new r,h=Array.from(l.keys()).filter((e=>l.get(e).length>0));await Promise.all(h.map((async t=>{const r=l.get(t),a=await Promise.all(r.map((e=>_projectGeometry(e.geometry,s)))),i=await _getDBaseSpatialReferenceWKT(a),u=n.useFormattedValues?Object.assign({},...y.map((e=>({[e]:DBaseTypes.STRING})))):_getDBaseColumnTypes(r,y,e.schema,"timestamp"===n.dateFormat),c=_getDBaseGeometries(a),f=_getDbaseValues(r,y,u,n);o.write(f,t,c,((e,r)=>{const o=h.length>1?`${m}_${t.toLowerCase()}`:m;g.file(`${o}.shp`,r.shp.buffer,{binary:!0}),g.file(`${o}.shx`,r.shx.buffer,{binary:!0}),g.file(`${o}.dbf`,r.dbf.buffer,{binary:!0}),g.file(`${o}.prj`,i)}))})));const F=g.generate({type:"uint8array"});return new Blob([F.buffer],{type:"text/plain"})}export async function shapefileToFeatureSet(e,t){checkArg("shapefileData",e).isNotMissing();const r={outFields:["*"],includeHeaderRow:!0,generatePrimaryKey:!0,primaryKeyField:"OBJECTID",...t,detectOid:!(null==t?void 0:t.primaryKeyField)},o=new Promise(((t,r)=>{const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{r(o.error)},o.readAsArrayBuffer(e)})),[{default:a},n]=await Promise.all([import("jszip"),import("shpjs")]),i=await o,s=new a(new Uint8Array(i)),m=s.filter((()=>!0)).map((e=>e.name));let l,u=m.filter((e=>e.endsWith(".shp"))).map((e=>e.substring(0,e.length-4)));if(u=_parseShapefileNames(u),m.some((e=>e.endsWith(".prj")))&&!u.every((e=>m.includes(`${e}.prj`))))throw new Error("Shapefile zip must contain the same prj file for each separate shapefile");for(const e of m.filter((e=>e.endsWith(".prj")))){const t=s.file(e).asText();if(l){if(t!==l)throw new Error("Shapefile zip must contain the same prj file for each separate shapefile")}else l=t}const c={geometries:[],columnCount:0,columnIndex:0};let f=[];for(const e of u){if(!m.includes(`${e}.shx`)||!m.includes(`${e}.dbf`))throw new Error("Shapefile must contain shp, shx, and dbf files.");const t=s.file(`${e}.shp`).asUint8Array(),r=n.parseShp(t),o=s.file(`${e}.dbf`).asUint8Array(),a=n.parseDbf(o);if(a.length!==r.length)throw new Error("Shapefile must contain shp, shx, and dbf files.");const i=await Promise.all(r.map((e=>_parseShpGeometry(e,l))));c.geometries=c.geometries.concat(i),f=f.concat(a)}const p=_parseDBaseData(f),d=_parseSchema(p,c,r),y=await _parseFeatures(p,c,d,r);return new FeatureSet({features:y,schema:d})}function _getGeometryColumns(e,t){return t.geometryFormat===GeometryFormat.XYZ?["x","y","z"]:t.geometryFormat===GeometryFormat.XY?["x","y"]:t.geometryFormat===GeometryFormat.LAT_LON?["latitude","longitude"]:t.geometryFormat===GeometryFormat.NONE?[]:["geometry"]}function _getAttributeColumns(e,t,r,o){const a=r.fields.filter((e=>"oid"===e.type)).map((e=>e.name)).toArray();if(o)return a;if(t&&!t.includes("*"))return t.filter((e=>!a.includes(e)));{const t=r.fields.filter((e=>"oid"!==e.type)).map((e=>e.name)).toArray();let o=[];for(const r of e)for(const e of r.attributes.keys())t.includes(e)||a.includes(e)||o.includes(e)||o.push(e);return o=o.sort(),t.concat(o)}}function _getXlsxColumnName(e,t){var r;const o=null===(r=null==t?void 0:t.schema)||void 0===r?void 0:r.fieldExtensions.initializedItems.map((e=>e.field));return e.map((e=>{var t,r;return null!==(r=null===(t=null==o?void 0:o.find((t=>t.name===e)))||void 0===t?void 0:t.alias)&&void 0!==r?r:e}))}function _getDefaultOutFields(e){var t,r,o,a,n,i,s,m;if(!e)return["*"];const l=null===(t=e.featureSettings.popupTemplate)||void 0===t?void 0:t.content,u=Array.isArray(l)?null===(a=null===(o=null===(r=l.find((e=>"fields"===e.type)))||void 0===r?void 0:r.fieldInfos)||void 0===o?void 0:o.filter((e=>e.visible)))||void 0===a?void 0:a.map((e=>e.fieldName)):void 0;return null!==(m=null!=u?u:null===(s=null===(i=null===(n=e.featureSettings.popupTemplate)||void 0===n?void 0:n.fieldInfos)||void 0===i?void 0:i.filter((e=>e.visible)))||void 0===s?void 0:s.map((e=>e.fieldName)))&&void 0!==m?m:["*"]}async function _getCSVGeometry(e,t){let r=await _getGeometry(e,t);return t.geometryFormat!==GeometryFormat.XYZ&&t.geometryFormat!==GeometryFormat.XY&&t.geometryFormat!==GeometryFormat.LAT_LON||(r=r.map((e=>void 0===e?"":_stringify(e,t)))),r.map((e=>""===e?"":_quotify(e,t)))}async function _getGeometry(e,t){const r=await _projectGeometry(e,t.outSpatialReference);if(t.geometryFormat===GeometryFormat.XYZ){if(!r)return["","",""];if(!isPoint(r))throw new Error("Cannot use geometry format XYZ with non-point geometry");return[r.x,r.y,r.z]}if(t.geometryFormat===GeometryFormat.XY){if(!r)return["",""];if(!isPoint(r))throw new Error("Cannot use geometry format XY with non-point geometry");return[r.x,r.y]}if(t.geometryFormat===GeometryFormat.LAT_LON){if(!r)return["",""];if(!isPoint(r))throw new Error("Cannot use geometry format LAT_LONG with non-point geometry");return[r.y,r.x]}return t.geometryFormat===GeometryFormat.ARCGIS_JSON?r?[JSON.stringify(toPortalGeometry(r))]:[""]:t.geometryFormat===GeometryFormat.WKT?r?[esriToWKT(r)]:[""]:t.geometryFormat===GeometryFormat.GEO_JSON?r?[JSON.stringify(esriToGeoJSON(r))]:[""]:[]}async function _projectGeometry(e,t){return(null==e?void 0:e.spatialReference)&&!e.spatialReference.equals(t)&&t?(await project([e],t))[0]:e}function _quotify(e,t){const r=[t.delimiter,'"',"\r","\n",t.rowDelimiter];if(t.alwaysQuote||r.some((t=>e.includes(t)))){return`"${e.replace(new RegExp('"',"g"),'""')}"`}return e}function _stringify(e,t){if(null==e)return"";if(!t.useFormattedValues){if("number"==typeof e){const r=t.numberFormat||NumberFormat.ROUND_TRIP;return formatNumber(r,e)}if(e instanceof Date)return"timestamp"===t.dateFormat?e.getTime().toString():formatDate({format:t.dateFormat,timeZone:"UTC"},e)}let r=e.toString();return t.escapeFormulaChars&&(r=escapeFormulaChars(r)),r}function _getAttributeValue(e,t,r){var o,a,n;if(r.useFormattedValues||_hasCodedDomain(e,t))return null!==(o=e.presentableAttributes.get(t))&&void 0!==o?o:e.attributes.get(t);if("date"===(null===(a=e.schema.findFieldByName(t))||void 0===a?void 0:a.type)){const r=parseDate(e.attributes.get(t));if(!isNaN(r.getTime()))return r}return null!==(n=e.attributes.get(t))&&void 0!==n?n:e.presentableAttributes.get(t)}function _hasCodedDomain(e,t){var r,o,a,n,i;return t===e.schema.typeIdField||("coded-value"===(null===(a=null===(o=null===(r=e.type)||void 0===r?void 0:r.domains)||void 0===o?void 0:o[t])||void 0===a?void 0:a.type)||"coded-value"===(null===(i=null===(n=e.schema.findFieldByName(t))||void 0===n?void 0:n.domain)||void 0===i?void 0:i.type))}function escapeFormulaChars(e){for(const t of FORMULA_TRIGGER_CHARS)if(e.startsWith(t))return`\t${e}`;return e}function _parseRowDelimiter(e){let t="\n";return _forDelimiter(e,"\r\n",((r,o)=>(0===r&&o===e.length||(t="\r\n"),!1))),t}function _parseCSV(e,t,r){const o=[];if(_forDelimiter(e,t,((t,a)=>{const n=e.substring(t,a);return n.length>0&&o.push(((e,t)=>{const o=[];return _forDelimiter(e,r,((r,a)=>{const n=e.substring(r,a);return o.push({raw:_parseQuotes(n,t,o.length)}),!0})),o})(n,o.length)),!0})),o.length){const e=o[0].length;o.forEach(((t,r)=>{if(t.length!==e)throw new Error(`Detected invalid CSV: Row ${r} does not have expected number of columns: ${e}`)}))}return o}function _parseQuotes(e,t,r){const o=e.startsWith('"'),a=e.endsWith('"');if(o&&!a||!o&&a)throw new Error(`Detected invalid CSV: Missing opening or closing quote for value at row:${t} column:${r}`);const n=o?e.substring('"'.length,e.length-'"'.length):e;let i=-1;return _forDelimiter(n,'"',((e,o)=>{if(o===n.length)return!0;if(i<0){if(o!==n.length)return i=o,!0}else if(o===i+'"'.length)return i=-1,!0;throw new Error(`Detected invalid CSV: Non-escaped quote for value at row:${t} column:${r}`)})),n.replace(new RegExp('""',"g"),'"')}function _forDelimiter(e,t,r){let o,a=!1,n=0,i=0;for(;o=e.indexOf(t,n),!(o<0);){for(let t=n;t<o;)e.substring(t).startsWith('"')?(a=!a,t+='"'.length):t++;const s=o+t.length;if(!a){const e=r(i,o);if(i=s,!e)break}n=s}r(i,e.length)}const geometryTypeHeaders={[GeometryFormat.XYZ]:[["x","y","z"]],[GeometryFormat.XY]:[["x","y"]],[GeometryFormat.LAT_LON]:[["lat","lon"],["lat","long"],["latitude","longitude"]],[GeometryFormat.ARCGIS_JSON]:[["geometry"]],[GeometryFormat.GEO_JSON]:[["geometry"]],[GeometryFormat.WKT]:[["geometry"]]};function _parseArcGisJson(e,t){const r=JSON.parse(e),o=toEsriApiGeometry(r);return r.spatialReference||(o.spatialReference=t),o}function _parseGeoJson(e,t){const r=geoJSONToEsri(JSON.parse(e));return r.spatialReference=t,r}function _parseWkt(e,t){const r=wktToEsri(e);return r.spatialReference=t,r}function _findGeometryFormatIndex(e,t){const r=geometryTypeHeaders[t];for(const t of r){const r=e.findIndex(((r,o)=>!(o+t.length>e.length)&&t.every(((t,r)=>e[o+r].raw.toString().toLowerCase()===t))));if(-1!==r)return r}}function _detectGeometry(e,t){return e.map(((e,r)=>{const o=null==e?void 0:e.raw;if("string"==typeof o&&""!==o)try{return t(o,void 0),r}catch{return}})).find((e=>void 0!==e))}function _parseGeometries(e,t){const r=t.includeHeaderRow?e.slice(1):e;if(t.geometryFormat===GeometryFormat.NONE)return{columnCount:0,columnIndex:0};const o=(e,o)=>{const a=o===GeometryFormat.XYZ,n=o===GeometryFormat.LAT_LON,i=a?3:2;return{columnCount:i,columnIndex:e,geometries:r.map((r=>{if(r.length>=e+i&&isNumeric(r[e+0].raw)&&isNumeric(r[e+1].raw)&&(!a||isNumeric(r[e+2].raw)))return new Point({x:parseNumber(n?r[e+1].raw:r[e+0].raw),y:parseNumber(n?r[e+0].raw:r[e+1].raw),z:a?parseNumber(r[e+2].raw):0,spatialReference:t.inSpatialReference})}))}},a=(e,o)=>({columnCount:1,columnIndex:e,geometries:r.map((t=>t[e])).map((e=>{if(""!==e.raw)return o(e.raw.toString(),t.inSpatialReference)}))});if(t.geometryFormat){const r=_findGeometryFormatIndex(e[0],t.geometryFormat);if(t.includeHeaderRow&&void 0===r)throw new Error(`Error parsing CSV: Expected geometry columns ${geometryTypeHeaders[t.geometryFormat][0].join(",")} are missing for GeometryType.${t.geometryFormat}`);return((e,t)=>{switch(t){case GeometryFormat.NONE:return{columnCount:0,columnIndex:0};case GeometryFormat.LAT_LON:case GeometryFormat.XYZ:case GeometryFormat.XY:return o(e,t);case GeometryFormat.ARCGIS_JSON:return a(e,_parseArcGisJson);case GeometryFormat.GEO_JSON:return a(e,_parseGeoJson);case GeometryFormat.WKT:return a(e,_parseWkt);default:return assertNever(t,new Error(`Unknown geometry format "${t}".`))}})(null!=r?r:0,t.geometryFormat)}if(t.includeHeaderRow){const t=_findGeometryFormatIndex(e[0],GeometryFormat.ARCGIS_JSON);if(void 0!==t)for(const e of[_parseArcGisJson,_parseGeoJson,_parseWkt])try{return a(t,e)}catch(e){}const r=[GeometryFormat.XYZ,GeometryFormat.XY,GeometryFormat.LAT_LON];for(const t of r){const r=_findGeometryFormatIndex(e[0],t);if(void 0!==r)return o(r,t)}}for(const e of[_parseArcGisJson,_parseGeoJson,_parseWkt])try{const t=_detectGeometry(r[0],e);return a(t,e)}catch(e){}return{columnCount:0,columnIndex:0}}function _parseSchema(e,t,r){var o;const a={fields:[]};let n=0;for(let o=t.columnCount;o<e[0].length;o++){if(i=o,0!==t.columnCount&&i>=t.columnIndex&&i<t.columnIndex+t.columnCount)continue;const s=_parseFieldType(e,o,r);let m=e[0][o].raw.toString(),l=m.replace(FIELD_NAME_REGEX,"_");if(r.includeHeaderRow||(l="field"+ ++n,m=translate("gcx.api.data.convert.import-field-alias",n)),!l)throw new Error("Error parsing CSV or XLSX: Header cannot contain blank values");a.fields.push({alias:m,name:l,type:s})}var i;if(a.spatialReference=r.outSpatialReference,null===(o=t.geometries)||void 0===o?void 0:o.length){const e=t.geometries.filter((e=>void 0!==e)).map((e=>e.type)),r=e[0];a.geometryType=e.every((e=>e===r))?r:void 0}if(r.generatePrimaryKey&&!a.fields.find((e=>"esriFieldTypeOID"===e.type))){const e=a.fields.length+1,t=!!a.fields.find((e=>"id"===e.name.toLowerCase()));a.fields.push({name:t?`field${e}`:"id",alias:t?translate("gcx.api.data.convert.import-field-alias",e):"id",type:"esriFieldTypeOID"})}return a}function _parseFieldType(e,t,r){var o;let a=!1,n=!0,i=!0,s=!0;const m=new Set,l=r.includeHeaderRow?e[0]:[],u=r.includeHeaderRow?e.slice(1):e;for(const e of u){const o=e[t];""!==o.raw&&(m.add(o.raw),a=!0,n&&(n=isNumeric(o.raw)||Number.isNaN(o.raw)),i&&(i=o.raw instanceof Date||parseDate(r.dateFormat||DEFAULT_PARSING_FORMATS,o.raw)!==INVALID_DATE),s&&(s=parseDate(r.dateFormat||DEFAULT_EXCEL_DATE_FORMATS,o.formatted)!==INVALID_DATE))}const c=m.size===u.length;return r.primaryKeyField&&(null===(o=l[t])||void 0===o?void 0:o.raw)===r.primaryKeyField||r.detectOid&&a&&c&&n?(r.detectOid=!1,"esriFieldTypeOID"):a&&s?"esriFieldTypeDate":a&&n?"esriFieldTypeDouble":a&&i?"esriFieldTypeDate":"esriFieldTypeString"}async function _parseFeatures(e,t,r,o){const a=[],n=o.includeHeaderRow?e.slice(1):e,i=(e,r)=>0===t.columnCount||(r<t.columnIndex||r>=t.columnIndex+t.columnCount);return await Promise.all(n.map((async(e,n)=>{var s;const m=new Feature;for(let t=0;t<r.fields.length;t++){const a=r.fields[t],l=e.filter(i);if(o.outFields.includes("*")||o.outFields.includes(a.name)){let e=await _parseValue(null===(s=l[t])||void 0===s?void 0:s.raw,a,o);"esriFieldTypeOID"===a.type&&null===e&&(e=n),m.attributes.set(a.name,e)}}t.geometries&&(m.geometry=await _projectGeometry(t.geometries[n],o.outSpatialReference)),a.push(m)}))),a}async function _parseValue(e,t,r){if("esriFieldTypeDouble"===t.type||"esriFieldTypeOID"===t.type)return"number"==typeof e?e:e?parseNumber(e):null;if("esriFieldTypeDate"===t.type){if(e instanceof Date)return e.getTime();if("number"==typeof e){const t=(await import("xlsx")).SSF.parse_date_code(e);return t?new Date(t.y,t.m-1,t.d,t.H,t.M,t.S).getTime():void 0}return""===e?null:parseDate(e).getTime()}const o=e.toString();if(r.escapeFormulaChars&&o.startsWith("\t"))for(const e of FORMULA_TRIGGER_CHARS)if(o.length>1&&o.charAt(1)===e)return o.substring(1);return o}function _convertToExcelDateFormatString(e){switch(e){case DateFormat.DATE_SHORT:return"dd/MM/yyyy";case DateFormat.DATE_LONG:return"MMMM d, yyyy";case DateFormat.TIME_SHORT:return"h:mm AM/PM";case DateFormat.TIME_LONG:return"h:mm:ss AM/PM";case DateFormat.DATE_TIME_SHORT:case DateFormat.DEFAULT:return"MMM d yyyy h:mm AM/PM";case DateFormat.DATE_TIME_LONG:return"MMMM d yyyy h:mm AM/PM";case DateFormat.FULL:return"dddd, MMMM d yyyy h:mm AM/PM";case DateFormat.ISO_8601:case DateFormat.ROUND_TRIP:return'yyyy-MM-dd"T"HH:mm:ss';default:{const t=e.replace(/tt/g,"AM/PM");return t.includes("z")&&_getConvertLogger().warn("Warning: Excel will not recognize timezone format 'z', 'zz', or 'zzz'"),t.includes("h")&&!t.includes("AM/PM")&&_getConvertLogger().warn("Warning: Excel will interpret 'h' as 'H' if the format does not have an AM/PM designator"),t}}}function _convertToExcelNumberFormatString(e){switch(e){case NumberFormat.ACCOUNTING:return'_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)';case NumberFormat.CURRENCY:return'"$"#,##0.00';case NumberFormat.FIXED_POINT:case NumberFormat.DEFAULT:return"0.0000";case NumberFormat.NUMBER:return"#,##0.0000";case NumberFormat.PERCENT:return"0%";case NumberFormat.ROUND_TRIP:return"0.00000";default:return e}}function _toXLSXValue(e,t){if(null==e)return"";if(!t.useFormattedValues){if("number"==typeof e)return e;if(e instanceof Date){const r=(new Date).getTimezoneOffset()-e.getTimezoneOffset(),o=new Date(e.getTime()+60*r*1e3);return"timestamp"===t.dateFormat?o.getTime():o}}let r=e.toString();return t.escapeFormulaChars&&(r=escapeFormulaChars(r)),r}async function _parseXLSX(e,t){const r=await import("xlsx"),o=new Promise(((o,a)=>{const n=new FileReader;n.onload=()=>{const e=new Uint8Array(n.result);let a="";for(const t of e)a+=String.fromCharCode(t);const i=r.read(a,{type:"binary",cellDates:!0}),s=t.sheetName||i.SheetNames[0],m=i.Sheets[s];o(m)},n.onerror=()=>{a(n.error)},n.readAsArrayBuffer(e)})),a=await o,n=r.utils.decode_range(a["!ref"]),i=[];for(let e=n.s.r;e<=n.e.r;e++){const t=[];for(let o=n.s.c;o<=n.e.c;o++){const n=a[`${r.utils.encode_cell({r:e,c:o})}`];t.push(n?{raw:n.v,formatted:"s"===n.t?void 0:n.w}:{raw:""})}i.push(t)}return i}async function _getDBaseSpatialReferenceWKT(e){let t;for(const r of e)if(t){if(r.spatialReference.wkid!==t)throw new Error("Cannot create shapefile that contains geometries with different spatial references.")}else t=r.spatialReference.wkid;return t||(t=SpatialReference.WGS84.wkid),esriWkidToWkt(t)}function _getDBaseColumnTypes(e,t,r,o){const a={};for(const n of t){if(e.some((e=>_hasCodedDomain(e,n)))){a[n]=DBaseTypes.STRING;continue}const t=r?r.fields.find((e=>e.name===n)):void 0;if(t){switch(t.type){case"oid":case"double":case"integer":case"single":case"small-integer":a[n]=DBaseTypes.NUMBER;break;case"date":a[n]=o?DBaseTypes.NUMBER:DBaseTypes.DATE;break;default:a[n]=DBaseTypes.STRING}continue}const i=(e,t)=>{var r;return null!==(r=e.attributes.get(t))&&void 0!==r?r:e.presentableAttributes.get(t)};e.every((e=>i(e,n)instanceof Date||void 0===i(e,n)))&&e.some((e=>i(e,n)instanceof Date))?a[n]=o?DBaseTypes.NUMBER:DBaseTypes.DATE:e.every((e=>"number"==typeof i(e,n)||void 0===i(e,n)))&&e.some((e=>"number"==typeof i(e,n)))?a[n]=DBaseTypes.NUMBER:e.every((e=>"boolean"==typeof i(e,n)||void 0===i(e,n)))&&e.some((e=>"boolean"==typeof i(e,n)))?a[n]=DBaseTypes.BOOLEAN:a[n]=DBaseTypes.STRING}return a}function _getDBaseGeometries(e){return e.map((e=>{if(isPoint(e)){const{x:t,y:r,z:o,m:a}=e,n=[t,r];return e.hasZ&&n.push(o),e.hasM&&n.push(a),_padZValues(n,e)}if(isMultipoint(e))return _padZValuesArray(e.points,e);if(isPolyline(e))return _padZValues2DArray(e.paths,e);if(isPolygon(e))return _padZValues2DArray(e.rings,e);if(isExtent(e)){const t=[e.xmin,e.ymax];return[[t,[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin],t]]}throw new Error("Unsupported geometry type.")}))}function _padZValues(e,t){return 3===e.length&&!t.hasZ&&t.hasM?[e[0],e[1],void 0,e[2]]:e}function _padZValuesArray(e,t){return e.map((e=>_padZValues(e,t)))}function _padZValues2DArray(e,t){return e.map((e=>_padZValuesArray(e,t)))}function _getDbaseValues(e,t,r,o){const a=[];for(const n of e){const e={};for(const a of t){let t=_getAttributeValue(n,a,o);if(null==t&&(t=""),o.useFormattedValues)t=t.toString();else{t=getDbaseValue(t,r[a],o)}e[a]=t}a.push(e)}return a}function getDbaseValue(e,t,r){var o,a;switch(t){case DBaseTypes.NUMBER:return e instanceof Date?e.getTime():parseNumber(e);case DBaseTypes.STRING:return e instanceof Date?formatDate({format:null!==(o=r.dateFormat)&&void 0!==o?o:DateFormat.ROUND_TRIP,timeZone:"UTC"},e):"number"==typeof e?formatNumber(null!==(a=r.numberFormat)&&void 0!==a?a:NumberFormat.DEFAULT,e):e.toString();case DBaseTypes.BOOLEAN:return!!e;case DBaseTypes.DATE:return parseDate(e);default:return e.toString()}}function _parseShapefileNames(e){if(!e.length)return[];let t=e[0];const r=t.match(shapefileNameRegex);return r?(t=r[1],e.filter((e=>{const r=e.match(shapefileNameRegex);return r&&r[1]===t}))):[t]}function _parseDBaseData(e){const t=e.map((e=>Object.keys(e))).reduce(((e,t)=>e.concat(t.filter((t=>!e.includes(t))))),[]);return[t.map((e=>({raw:e}))),...e.map((e=>t.map((t=>({raw:e[t]})))))]}function _parseShpPointGeometry(e){checkArg("geometry.coordinates",e.type).matches("Point"),checkArg("geometry.coordinates",e.coordinates).satisfies((e=>"number"==typeof e||Array.isArray(e)));const[t,r,o]=e.coordinates,a=new Point({x:t,y:r,spatialReference:SpatialReference.WGS84});if(Array.isArray(o)){const[e,t]=o;!e&&!t||e?a.z=e:a.m=t}return a}async function _parseShpGeometry(e,t){const r=isPoint(e)?_parseShpPointGeometry(e):geoJSONToEsri(e);if(t){let e;const o=await esriWktToWkid(t);if(o&&(e=new SpatialReference({wkid:parseNumber(o)})),!e)throw new Error(`Could go find wkid that matches wkt: ${t}`);r.spatialReference=e}return r}
1
+ import Point from"@arcgis/core/geometry/Point";import SpatialReference from"@arcgis/core/geometry/SpatialReference";import{translate}from"../locale/language.js";import{toEsriApiGeometry,toPortalGeometry}from"../portal/Geometry.js";import{checkArg,assertNever}from"../utilities/checkArg.js";import{parse as parseDate,format as formatDate,DEFAULT_PARSING_FORMATS,DateFormat,INVALID_DATE}from"../utilities/date.js";import{esriToWKT,esriToGeoJSON,geoJSONToEsri,wktToEsri,esriWkidToWkt,esriWktToWkid,project,isPoint,isMultipoint,isPolyline,isPolygon,isExtent}from"../utilities/geometry.js";import{getLogger}from"../utilities/log.js";import{parse as parseNumber,format as formatNumber,NumberFormat,isNumeric}from"../utilities/number.js";import{Feature}from"./Feature.js";import{FeatureSet}from"./FeatureSet.js";const FORMULA_TRIGGER_CHARS=["=","-","+","@"],QUOTE='"',FIELD_NAME_REGEX=/[^a-zA-Z\d_]/g,DEFAULT_WINDOWS_ROW_DELIMITER="\r\n",DEFAULT_UNIX_ROW_DELIMITER="\n",DEFAULT_SHEET_NAME="sheet1",DEFAULT_EXCEL_DATE_FORMATS=[...DEFAULT_PARSING_FORMATS.map(_convertToExcelDateFormatString),"M/d/yy"],shapefileNameRegex=/(\w+)_(point|multipoint|polyline|polygon)z?/;var DBaseTypes;function _getConvertLogger(){return getLogger("geocortex.api.data.convert")}!function(e){e.DATE="D",e.NUMBER="N",e.STRING="C",e.BOOLEAN="L"}(DBaseTypes||(DBaseTypes={}));export var GeometryFormat;!function(e){e.NONE="NONE",e.WKT="WKT",e.XY="XY",e.XYZ="XYZ",e.LAT_LON="LAT_LONG",e.GEO_JSON="GEO_JSON",e.ARCGIS_JSON="ARCGIS_JSON"}(GeometryFormat||(GeometryFormat={}));export async function toCsv(e,t){checkArg("featureSet",e).isNotMissing();const r=Array.from(e),o={...{useFormattedValues:!1,alwaysQuote:!1,escapeFormulaChars:!0,delimiter:",",dateFormat:DateFormat.ROUND_TRIP,geometryFormat:r.some((e=>void 0!==e.geometry&&null!==e.geometry))?GeometryFormat.WKT:GeometryFormat.NONE,includeByteOrderMark:!0,outSpatialReference:SpatialReference.WGS84,includeHeaderRow:!0,outFields:_getDefaultOutFields(e.source),rowDelimiter:navigator.platform.startsWith("Win")?"\r\n":"\n"},...t},{includeByteOrderMark:a,includeHeaderRow:n,delimiter:i,outFields:s,rowDelimiter:m}=o,l=[];a&&l.push("\ufeff");const u=_getGeometryColumns(r,o),c=_getAttributeColumns(r,s,e.schema,!0),f=_getAttributeColumns(r,s,e.schema,!1);if(n){const e=[];for(const t of u)e.push(_quotify(t,o));for(const t of c)e.push(_quotify(t,o));for(const t of f)e.push(_quotify(t,o));const t=e.join(i)+m;l.push(t)}await Promise.all(r.map((async e=>{const t=[],r=(t,r)=>_quotify(_stringify(_getAttributeValue(e,t,r),r),r);t.push(...await _getCSVGeometry(e.geometry,o)),t.push(...c.map((e=>r(e,o)))),t.push(...f.map((e=>r(e,o))));const a=`${t.join(i)}${m}`;l.push(a)})));return new Blob(l,{type:"text/plain",endings:"\n"===m||"\r\n"===m?"transparent":"native"})}export async function csvToFeatureSet(e,t){let r;if(checkArg("csvData",e).isNotMissing(),e instanceof Blob){const t=new Promise(((t,r)=>{const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{r(o.error)},o.readAsText(e)}));r=await t}else r=e;const o={...{delimiter:",",escapeFormulaChars:!0,includeHeaderRow:!0,outFields:["*"],inSpatialReference:SpatialReference.WGS84,generatePrimaryKey:!0,primaryKeyField:"OBJECTID"},...t,detectOid:!(null==t?void 0:t.primaryKeyField)},a=_parseCSV(r,o.rowDelimiter||_parseRowDelimiter(r),o.delimiter),n=_parseGeometries(a,o),i=_parseSchema(a,n,o),s=await _parseFeatures(a,n,i,o);return new FeatureSet({features:s,schema:i})}export async function toXLSX(e,t){var r;checkArg("featureSet",e).isNotMissing();const o=Array.from(e),a={...{useFormattedValues:!1,includeHeaderRow:!0,escapeFormulaChars:!0,geometryFormat:o.some((e=>void 0!==e.geometry&&null!==e.geometry))?GeometryFormat.WKT:GeometryFormat.NONE,outFields:_getDefaultOutFields(e.source),outSpatialReference:SpatialReference.WGS84,dateFormat:DateFormat.DEFAULT,numberFormat:NumberFormat.DEFAULT,sheetName:"sheet1"},...t},{outFields:n,includeHeaderRow:i,numberFormat:s}=a,m=[],l=_getGeometryColumns(o,a),u=_getAttributeColumns(o,n,e.schema,!0),c=_getAttributeColumns(o,n,e.schema,!1);if(i){const t=l.concat(u).concat(_getXlsxColumnName(c,e.source));m.push(t)}await Promise.all(o.map((async e=>{const t=[];t.push(...await _getGeometry(e.geometry,a));for(const r of u){const o=_toXLSXValue(e.attributes.get(r),a);t.push(o)}for(const r of c){const o=_toXLSXValue(_getAttributeValue(e,r,a),a);t.push(o)}m.push(t)})));const f=await import("xlsx"),p={SheetNames:[],Sheets:{}},d=f.utils.aoa_to_sheet(m,{cellDates:!0});for(const e of Object.keys(d).filter((e=>!e.startsWith("!")))){const t=d[e];"d"===t.t?t.z=_convertToExcelDateFormatString(null!==(r=a.dateFormat)&&void 0!==r?r:DateFormat.ROUND_TRIP):"n"===t.t&&(t.z=_convertToExcelNumberFormatString(s))}p.SheetNames.push(a.sheetName),p.Sheets[a.sheetName]=d;const y=f.write(p,{type:"binary",bookType:"xlsx",compression:!0,bookSST:!0,cellDates:!0}),g=new Uint8Array(y.length);for(let e=0;e<y.length;e++)g[e]=y.charCodeAt(e);return new Blob([g.buffer],{type:"text/plain"})}export async function xlsxToFeatureSet(e,t){checkArg("xlsxData",e).isNotMissing();const r={...{includeHeaderRow:!0,escapeFormulaChars:!0,outFields:["*"],inSpatialReference:SpatialReference.WGS84,generatePrimaryKey:!0,primaryKeyField:"OBJECTID"},...t,detectOid:!(null==t?void 0:t.primaryKeyField)},o=await _parseXLSX(e,r),a=_parseGeometries(o,r),n=_parseSchema(o,a,r),i=await _parseFeatures(o,a,n,r);return new FeatureSet({features:i,schema:n})}export async function toShapefile(e,t){checkArg("featureSet",e).isNotMissing();const[{default:r},o]=await Promise.all([import("jszip"),import("../forked-libs/shp-write/index.js")]),a=Array.from(e),n={...{useFormattedValues:!1,outFields:_getDefaultOutFields(e.source),fileName:e.title||"export"},...t},{outFields:i,outSpatialReference:s,fileName:m}=n,l=new Map,u=a.filter((e=>isPoint(e.geometry)));l.set(u.some((e=>e.geometry.hasZ||e.geometry.hasM))?"POINTZ":"POINT",u);const c=a.filter((e=>isMultipoint(e.geometry)));l.set(c.some((e=>e.geometry.hasZ||e.geometry.hasM))?"MULTIPOINTZ":"MULTIPOINT",c);const f=a.filter((e=>isPolyline(e.geometry)));l.set(f.some((e=>e.geometry.hasZ||e.geometry.hasM))?"POLYLINEZ":"POLYLINE",f);const p=a.filter((e=>isPolygon(e.geometry)||isExtent(e.geometry)));l.set(p.some((e=>e.geometry.hasZ||e.geometry.hasM))?"POLYGONZ":"POLYGON",p);const d=_getAttributeColumns(a,i,e.schema,!0);let y=_getAttributeColumns(a,i,e.schema,!1);y=d.concat(y);const g=new r,h=Array.from(l.keys()).filter((e=>l.get(e).length>0));await Promise.all(h.map((async t=>{const r=l.get(t),a=await Promise.all(r.map((e=>_projectGeometry(e.geometry,s)))),i=await _getDBaseSpatialReferenceWKT(a),u=n.useFormattedValues?Object.assign({},...y.map((e=>({[e]:DBaseTypes.STRING})))):_getDBaseColumnTypes(r,y,e.schema,"timestamp"===n.dateFormat),c=_getDBaseGeometries(a),f=_getDbaseValues(r,y,u,n);o.write(f,t,c,((e,r)=>{const o=h.length>1?`${m}_${t.toLowerCase()}`:m;g.file(`${o}.shp`,r.shp.buffer,{binary:!0}),g.file(`${o}.shx`,r.shx.buffer,{binary:!0}),g.file(`${o}.dbf`,r.dbf.buffer,{binary:!0}),g.file(`${o}.prj`,i)}))})));const F=await g.generateAsync({type:"uint8array"});return new Blob([F.buffer],{type:"text/plain"})}export async function shapefileToFeatureSet(e,t){checkArg("shapefileData",e).isNotMissing();const r={outFields:["*"],includeHeaderRow:!0,generatePrimaryKey:!0,primaryKeyField:"OBJECTID",...t,detectOid:!(null==t?void 0:t.primaryKeyField)},o=new Promise(((t,r)=>{const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{r(o.error)},o.readAsArrayBuffer(e)})),[{default:a},n]=await Promise.all([import("jszip"),import("shpjs")]),i=await o,s=await a.loadAsync(new Uint8Array(i)),m=s.filter((()=>!0)).map((e=>e.name));let l,u=m.filter((e=>e.endsWith(".shp"))).map((e=>e.substring(0,e.length-4)));if(u=_parseShapefileNames(u),m.some((e=>e.endsWith(".prj")))&&!u.every((e=>m.includes(`${e}.prj`))))throw new Error("Shapefile zip must contain the same prj file for each separate shapefile");await Promise.all(m.filter((e=>e.endsWith(".prj"))).map((async e=>{const t=await s.file(e).async("string");if(l){if(t!==l)throw new Error("Shapefile zip must contain the same prj file for each separate shapefile")}else l=t})));const c={geometries:[],columnCount:0,columnIndex:0};let f=[];for(const e of u){if(!m.includes(`${e}.shx`)||!m.includes(`${e}.dbf`))throw new Error("Shapefile must contain shp, shx, and dbf files.");const t=await s.file(`${e}.shp`).async("uint8array"),r=n.parseShp(t),o=await s.file(`${e}.dbf`).async("uint8array"),a=n.parseDbf(o);if(a.length!==r.length)throw new Error("Shapefile must contain shp, shx, and dbf files.");const i=await Promise.all(r.map((e=>_parseShpGeometry(e,l))));c.geometries=c.geometries.concat(i),f=f.concat(a)}const p=_parseDBaseData(f),d=_parseSchema(p,c,r),y=await _parseFeatures(p,c,d,r);return new FeatureSet({features:y,schema:d})}function _getGeometryColumns(e,t){return t.geometryFormat===GeometryFormat.XYZ?["x","y","z"]:t.geometryFormat===GeometryFormat.XY?["x","y"]:t.geometryFormat===GeometryFormat.LAT_LON?["latitude","longitude"]:t.geometryFormat===GeometryFormat.NONE?[]:["geometry"]}function _getAttributeColumns(e,t,r,o){const a=r.fields.filter((e=>"oid"===e.type)).map((e=>e.name)).toArray();if(o)return a;if(t&&!t.includes("*"))return t.filter((e=>!a.includes(e)));{const t=r.fields.filter((e=>"oid"!==e.type)).map((e=>e.name)).toArray();let o=[];for(const r of e)for(const e of r.attributes.keys())t.includes(e)||a.includes(e)||o.includes(e)||o.push(e);return o=o.sort(),t.concat(o)}}function _getXlsxColumnName(e,t){var r;const o=null===(r=null==t?void 0:t.schema)||void 0===r?void 0:r.fieldExtensions.initializedItems.map((e=>e.field));return e.map((e=>{var t,r;return null!==(r=null===(t=null==o?void 0:o.find((t=>t.name===e)))||void 0===t?void 0:t.alias)&&void 0!==r?r:e}))}function _getDefaultOutFields(e){var t,r,o,a,n,i,s,m;if(!e)return["*"];const l=null===(t=e.featureSettings.popupTemplate)||void 0===t?void 0:t.content,u=Array.isArray(l)?null===(a=null===(o=null===(r=l.find((e=>"fields"===e.type)))||void 0===r?void 0:r.fieldInfos)||void 0===o?void 0:o.filter((e=>e.visible)))||void 0===a?void 0:a.map((e=>e.fieldName)):void 0;return null!==(m=null!=u?u:null===(s=null===(i=null===(n=e.featureSettings.popupTemplate)||void 0===n?void 0:n.fieldInfos)||void 0===i?void 0:i.filter((e=>e.visible)))||void 0===s?void 0:s.map((e=>e.fieldName)))&&void 0!==m?m:["*"]}async function _getCSVGeometry(e,t){let r=await _getGeometry(e,t);return t.geometryFormat!==GeometryFormat.XYZ&&t.geometryFormat!==GeometryFormat.XY&&t.geometryFormat!==GeometryFormat.LAT_LON||(r=r.map((e=>void 0===e?"":_stringify(e,t)))),r.map((e=>""===e?"":_quotify(e,t)))}async function _getGeometry(e,t){const r=await _projectGeometry(e,t.outSpatialReference);if(t.geometryFormat===GeometryFormat.XYZ){if(!r)return["","",""];if(!isPoint(r))throw new Error("Cannot use geometry format XYZ with non-point geometry");return[r.x,r.y,r.z]}if(t.geometryFormat===GeometryFormat.XY){if(!r)return["",""];if(!isPoint(r))throw new Error("Cannot use geometry format XY with non-point geometry");return[r.x,r.y]}if(t.geometryFormat===GeometryFormat.LAT_LON){if(!r)return["",""];if(!isPoint(r))throw new Error("Cannot use geometry format LAT_LONG with non-point geometry");return[r.y,r.x]}return t.geometryFormat===GeometryFormat.ARCGIS_JSON?r?[JSON.stringify(toPortalGeometry(r))]:[""]:t.geometryFormat===GeometryFormat.WKT?r?[esriToWKT(r)]:[""]:t.geometryFormat===GeometryFormat.GEO_JSON?r?[JSON.stringify(esriToGeoJSON(r))]:[""]:[]}async function _projectGeometry(e,t){return(null==e?void 0:e.spatialReference)&&!e.spatialReference.equals(t)&&t?(await project([e],t))[0]:e}function _quotify(e,t){const r=[t.delimiter,'"',"\r","\n",t.rowDelimiter];if(t.alwaysQuote||r.some((t=>e.includes(t)))){return`"${e.replace(new RegExp('"',"g"),'""')}"`}return e}function _stringify(e,t){if(null==e)return"";if(!t.useFormattedValues){if("number"==typeof e){const r=t.numberFormat||NumberFormat.ROUND_TRIP;return formatNumber(r,e)}if(e instanceof Date)return"timestamp"===t.dateFormat?e.getTime().toString():formatDate({format:t.dateFormat,timeZone:"UTC"},e)}let r=e.toString();return t.escapeFormulaChars&&(r=escapeFormulaChars(r)),r}function _getAttributeValue(e,t,r){var o,a,n;if(r.useFormattedValues||_hasCodedDomain(e,t))return null!==(o=e.presentableAttributes.get(t))&&void 0!==o?o:e.attributes.get(t);if("date"===(null===(a=e.schema.findFieldByName(t))||void 0===a?void 0:a.type)){const r=parseDate(e.attributes.get(t));if(!isNaN(r.getTime()))return r}return null!==(n=e.attributes.get(t))&&void 0!==n?n:e.presentableAttributes.get(t)}function _hasCodedDomain(e,t){var r,o,a,n,i;return t===e.schema.typeIdField||("coded-value"===(null===(a=null===(o=null===(r=e.type)||void 0===r?void 0:r.domains)||void 0===o?void 0:o[t])||void 0===a?void 0:a.type)||"coded-value"===(null===(i=null===(n=e.schema.findFieldByName(t))||void 0===n?void 0:n.domain)||void 0===i?void 0:i.type))}function escapeFormulaChars(e){for(const t of FORMULA_TRIGGER_CHARS)if(e.startsWith(t))return`\t${e}`;return e}function _parseRowDelimiter(e){let t="\n";return _forDelimiter(e,"\r\n",((r,o)=>(0===r&&o===e.length||(t="\r\n"),!1))),t}function _parseCSV(e,t,r){const o=[];if(_forDelimiter(e,t,((t,a)=>{const n=e.substring(t,a);return n.length>0&&o.push(((e,t)=>{const o=[];return _forDelimiter(e,r,((r,a)=>{const n=e.substring(r,a);return o.push({raw:_parseQuotes(n,t,o.length)}),!0})),o})(n,o.length)),!0})),o.length){const e=o[0].length;o.forEach(((t,r)=>{if(t.length!==e)throw new Error(`Detected invalid CSV: Row ${r} does not have expected number of columns: ${e}`)}))}return o}function _parseQuotes(e,t,r){const o=e.startsWith('"'),a=e.endsWith('"');if(o&&!a||!o&&a)throw new Error(`Detected invalid CSV: Missing opening or closing quote for value at row:${t} column:${r}`);const n=o?e.substring('"'.length,e.length-'"'.length):e;let i=-1;return _forDelimiter(n,'"',((e,o)=>{if(o===n.length)return!0;if(i<0){if(o!==n.length)return i=o,!0}else if(o===i+'"'.length)return i=-1,!0;throw new Error(`Detected invalid CSV: Non-escaped quote for value at row:${t} column:${r}`)})),n.replace(new RegExp('""',"g"),'"')}function _forDelimiter(e,t,r){let o,a=!1,n=0,i=0;for(;o=e.indexOf(t,n),!(o<0);){for(let t=n;t<o;)e.substring(t).startsWith('"')?(a=!a,t+='"'.length):t++;const s=o+t.length;if(!a){const e=r(i,o);if(i=s,!e)break}n=s}r(i,e.length)}const geometryTypeHeaders={[GeometryFormat.XYZ]:[["x","y","z"]],[GeometryFormat.XY]:[["x","y"]],[GeometryFormat.LAT_LON]:[["lat","lon"],["lat","long"],["latitude","longitude"]],[GeometryFormat.ARCGIS_JSON]:[["geometry"]],[GeometryFormat.GEO_JSON]:[["geometry"]],[GeometryFormat.WKT]:[["geometry"]]};function _parseArcGisJson(e,t){const r=JSON.parse(e),o=toEsriApiGeometry(r);return r.spatialReference||(o.spatialReference=t),o}function _parseGeoJson(e,t){const r=geoJSONToEsri(JSON.parse(e));return r.spatialReference=t,r}function _parseWkt(e,t){const r=wktToEsri(e);return r.spatialReference=t,r}function _findGeometryFormatIndex(e,t){const r=geometryTypeHeaders[t];for(const t of r){const r=e.findIndex(((r,o)=>!(o+t.length>e.length)&&t.every(((t,r)=>e[o+r].raw.toString().toLowerCase()===t))));if(-1!==r)return r}}function _detectGeometry(e,t){return e.map(((e,r)=>{const o=null==e?void 0:e.raw;if("string"==typeof o&&""!==o)try{return t(o,void 0),r}catch{return}})).find((e=>void 0!==e))}function _parseGeometries(e,t){const r=t.includeHeaderRow?e.slice(1):e;if(t.geometryFormat===GeometryFormat.NONE)return{columnCount:0,columnIndex:0};const o=(e,o)=>{const a=o===GeometryFormat.XYZ,n=o===GeometryFormat.LAT_LON,i=a?3:2;return{columnCount:i,columnIndex:e,geometries:r.map((r=>{if(r.length>=e+i&&isNumeric(r[e+0].raw)&&isNumeric(r[e+1].raw)&&(!a||isNumeric(r[e+2].raw)))return new Point({x:parseNumber(n?r[e+1].raw:r[e+0].raw),y:parseNumber(n?r[e+0].raw:r[e+1].raw),z:a?parseNumber(r[e+2].raw):0,spatialReference:t.inSpatialReference})}))}},a=(e,o)=>({columnCount:1,columnIndex:e,geometries:r.map((t=>t[e])).map((e=>{if(""!==e.raw)return o(e.raw.toString(),t.inSpatialReference)}))});if(t.geometryFormat){const r=_findGeometryFormatIndex(e[0],t.geometryFormat);if(t.includeHeaderRow&&void 0===r)throw new Error(`Error parsing CSV: Expected geometry columns ${geometryTypeHeaders[t.geometryFormat][0].join(",")} are missing for GeometryType.${t.geometryFormat}`);return((e,t)=>{switch(t){case GeometryFormat.NONE:return{columnCount:0,columnIndex:0};case GeometryFormat.LAT_LON:case GeometryFormat.XYZ:case GeometryFormat.XY:return o(e,t);case GeometryFormat.ARCGIS_JSON:return a(e,_parseArcGisJson);case GeometryFormat.GEO_JSON:return a(e,_parseGeoJson);case GeometryFormat.WKT:return a(e,_parseWkt);default:return assertNever(t,new Error(`Unknown geometry format "${t}".`))}})(null!=r?r:0,t.geometryFormat)}if(t.includeHeaderRow){const t=_findGeometryFormatIndex(e[0],GeometryFormat.ARCGIS_JSON);if(void 0!==t)for(const e of[_parseArcGisJson,_parseGeoJson,_parseWkt])try{return a(t,e)}catch(e){}const r=[GeometryFormat.XYZ,GeometryFormat.XY,GeometryFormat.LAT_LON];for(const t of r){const r=_findGeometryFormatIndex(e[0],t);if(void 0!==r)return o(r,t)}}for(const e of[_parseArcGisJson,_parseGeoJson,_parseWkt])try{const t=_detectGeometry(r[0],e);return a(t,e)}catch(e){}return{columnCount:0,columnIndex:0}}function _parseSchema(e,t,r){var o;const a={fields:[]};let n=0;for(let o=t.columnCount;o<e[0].length;o++){if(i=o,0!==t.columnCount&&i>=t.columnIndex&&i<t.columnIndex+t.columnCount)continue;const s=_parseFieldType(e,o,r);let m=e[0][o].raw.toString(),l=m.replace(FIELD_NAME_REGEX,"_");if(r.includeHeaderRow||(l="field"+ ++n,m=translate("gcx.api.data.convert.import-field-alias",n)),!l)throw new Error("Error parsing CSV or XLSX: Header cannot contain blank values");a.fields.push({alias:m,name:l,type:s})}var i;if(a.spatialReference=r.outSpatialReference,null===(o=t.geometries)||void 0===o?void 0:o.length){const e=t.geometries.filter((e=>void 0!==e)).map((e=>e.type)),r=e[0];a.geometryType=e.every((e=>e===r))?r:void 0}if(r.generatePrimaryKey&&!a.fields.find((e=>"esriFieldTypeOID"===e.type))){const e=a.fields.length+1,t=!!a.fields.find((e=>"id"===e.name.toLowerCase()));a.fields.push({name:t?`field${e}`:"id",alias:t?translate("gcx.api.data.convert.import-field-alias",e):"id",type:"esriFieldTypeOID"})}return a}function _parseFieldType(e,t,r){var o;let a=!1,n=!0,i=!0,s=!0;const m=new Set,l=r.includeHeaderRow?e[0]:[],u=r.includeHeaderRow?e.slice(1):e;for(const e of u){const o=e[t];""!==o.raw&&(m.add(o.raw),a=!0,n&&(n=isNumeric(o.raw)||Number.isNaN(o.raw)),i&&(i=o.raw instanceof Date||parseDate(r.dateFormat||DEFAULT_PARSING_FORMATS,o.raw)!==INVALID_DATE),s&&(s=parseDate(r.dateFormat||DEFAULT_EXCEL_DATE_FORMATS,o.formatted)!==INVALID_DATE))}const c=m.size===u.length;return r.primaryKeyField&&(null===(o=l[t])||void 0===o?void 0:o.raw)===r.primaryKeyField||r.detectOid&&a&&c&&n?(r.detectOid=!1,"esriFieldTypeOID"):a&&s?"esriFieldTypeDate":a&&n?"esriFieldTypeDouble":a&&i?"esriFieldTypeDate":"esriFieldTypeString"}async function _parseFeatures(e,t,r,o){const a=[],n=o.includeHeaderRow?e.slice(1):e,i=(e,r)=>0===t.columnCount||(r<t.columnIndex||r>=t.columnIndex+t.columnCount);return await Promise.all(n.map((async(e,n)=>{var s;const m=new Feature;for(let t=0;t<r.fields.length;t++){const a=r.fields[t],l=e.filter(i);if(o.outFields.includes("*")||o.outFields.includes(a.name)){let e=await _parseValue(null===(s=l[t])||void 0===s?void 0:s.raw,a,o);"esriFieldTypeOID"===a.type&&null===e&&(e=n),m.attributes.set(a.name,e)}}t.geometries&&(m.geometry=await _projectGeometry(t.geometries[n],o.outSpatialReference)),a.push(m)}))),a}async function _parseValue(e,t,r){if("esriFieldTypeDouble"===t.type||"esriFieldTypeOID"===t.type)return"number"==typeof e?e:e?parseNumber(e):null;if("esriFieldTypeDate"===t.type){if(e instanceof Date)return e.getTime();if("number"==typeof e){const t=(await import("xlsx")).SSF.parse_date_code(e);return t?new Date(t.y,t.m-1,t.d,t.H,t.M,t.S).getTime():void 0}return""===e?null:parseDate(e).getTime()}const o=e.toString();if(r.escapeFormulaChars&&o.startsWith("\t"))for(const e of FORMULA_TRIGGER_CHARS)if(o.length>1&&o.charAt(1)===e)return o.substring(1);return o}function _convertToExcelDateFormatString(e){switch(e){case DateFormat.DATE_SHORT:return"dd/MM/yyyy";case DateFormat.DATE_LONG:return"MMMM d, yyyy";case DateFormat.TIME_SHORT:return"h:mm AM/PM";case DateFormat.TIME_LONG:return"h:mm:ss AM/PM";case DateFormat.DATE_TIME_SHORT:case DateFormat.DEFAULT:return"MMM d yyyy h:mm AM/PM";case DateFormat.DATE_TIME_LONG:return"MMMM d yyyy h:mm AM/PM";case DateFormat.FULL:return"dddd, MMMM d yyyy h:mm AM/PM";case DateFormat.ISO_8601:case DateFormat.ROUND_TRIP:return'yyyy-MM-dd"T"HH:mm:ss';default:{const t=e.replace(/tt/g,"AM/PM");return t.includes("z")&&_getConvertLogger().warn("Warning: Excel will not recognize timezone format 'z', 'zz', or 'zzz'"),t.includes("h")&&!t.includes("AM/PM")&&_getConvertLogger().warn("Warning: Excel will interpret 'h' as 'H' if the format does not have an AM/PM designator"),t}}}function _convertToExcelNumberFormatString(e){switch(e){case NumberFormat.ACCOUNTING:return'_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)';case NumberFormat.CURRENCY:return'"$"#,##0.00';case NumberFormat.FIXED_POINT:case NumberFormat.DEFAULT:return"0.0000";case NumberFormat.NUMBER:return"#,##0.0000";case NumberFormat.PERCENT:return"0%";case NumberFormat.ROUND_TRIP:return"0.00000";default:return e}}function _toXLSXValue(e,t){if(null==e)return"";if(!t.useFormattedValues){if("number"==typeof e)return e;if(e instanceof Date){const r=(new Date).getTimezoneOffset()-e.getTimezoneOffset(),o=new Date(e.getTime()+60*r*1e3);return"timestamp"===t.dateFormat?o.getTime():o}}let r=e.toString();return t.escapeFormulaChars&&(r=escapeFormulaChars(r)),r}async function _parseXLSX(e,t){const r=await import("xlsx"),o=new Promise(((o,a)=>{const n=new FileReader;n.onload=()=>{const e=new Uint8Array(n.result);let a="";for(const t of e)a+=String.fromCharCode(t);const i=r.read(a,{type:"binary",cellDates:!0}),s=t.sheetName||i.SheetNames[0],m=i.Sheets[s];o(m)},n.onerror=()=>{a(n.error)},n.readAsArrayBuffer(e)})),a=await o,n=r.utils.decode_range(a["!ref"]),i=[];for(let e=n.s.r;e<=n.e.r;e++){const t=[];for(let o=n.s.c;o<=n.e.c;o++){const n=a[`${r.utils.encode_cell({r:e,c:o})}`];t.push(n?{raw:n.v,formatted:"s"===n.t?void 0:n.w}:{raw:""})}i.push(t)}return i}async function _getDBaseSpatialReferenceWKT(e){let t;for(const r of e)if(t){if(r.spatialReference.wkid!==t)throw new Error("Cannot create shapefile that contains geometries with different spatial references.")}else t=r.spatialReference.wkid;return t||(t=SpatialReference.WGS84.wkid),esriWkidToWkt(t)}function _getDBaseColumnTypes(e,t,r,o){const a={};for(const n of t){if(e.some((e=>_hasCodedDomain(e,n)))){a[n]=DBaseTypes.STRING;continue}const t=r?r.fields.find((e=>e.name===n)):void 0;if(t){switch(t.type){case"oid":case"double":case"integer":case"single":case"small-integer":a[n]=DBaseTypes.NUMBER;break;case"date":a[n]=o?DBaseTypes.NUMBER:DBaseTypes.DATE;break;default:a[n]=DBaseTypes.STRING}continue}const i=(e,t)=>{var r;return null!==(r=e.attributes.get(t))&&void 0!==r?r:e.presentableAttributes.get(t)};e.every((e=>i(e,n)instanceof Date||void 0===i(e,n)))&&e.some((e=>i(e,n)instanceof Date))?a[n]=o?DBaseTypes.NUMBER:DBaseTypes.DATE:e.every((e=>"number"==typeof i(e,n)||void 0===i(e,n)))&&e.some((e=>"number"==typeof i(e,n)))?a[n]=DBaseTypes.NUMBER:e.every((e=>"boolean"==typeof i(e,n)||void 0===i(e,n)))&&e.some((e=>"boolean"==typeof i(e,n)))?a[n]=DBaseTypes.BOOLEAN:a[n]=DBaseTypes.STRING}return a}function _getDBaseGeometries(e){return e.map((e=>{if(isPoint(e)){const{x:t,y:r,z:o,m:a}=e,n=[t,r];return e.hasZ&&n.push(o),e.hasM&&n.push(a),_padZValues(n,e)}if(isMultipoint(e))return _padZValuesArray(e.points,e);if(isPolyline(e))return _padZValues2DArray(e.paths,e);if(isPolygon(e))return _padZValues2DArray(e.rings,e);if(isExtent(e)){const t=[e.xmin,e.ymax];return[[t,[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin],t]]}throw new Error("Unsupported geometry type.")}))}function _padZValues(e,t){return 3===e.length&&!t.hasZ&&t.hasM?[e[0],e[1],void 0,e[2]]:e}function _padZValuesArray(e,t){return e.map((e=>_padZValues(e,t)))}function _padZValues2DArray(e,t){return e.map((e=>_padZValuesArray(e,t)))}function _getDbaseValues(e,t,r,o){const a=[];for(const n of e){const e={};for(const a of t){let t=_getAttributeValue(n,a,o);if(null==t&&(t=""),o.useFormattedValues)t=t.toString();else{t=getDbaseValue(t,r[a],o)}e[a]=t}a.push(e)}return a}function getDbaseValue(e,t,r){var o,a;switch(t){case DBaseTypes.NUMBER:return e instanceof Date?e.getTime():parseNumber(e);case DBaseTypes.STRING:return e instanceof Date?formatDate({format:null!==(o=r.dateFormat)&&void 0!==o?o:DateFormat.ROUND_TRIP,timeZone:"UTC"},e):"number"==typeof e?formatNumber(null!==(a=r.numberFormat)&&void 0!==a?a:NumberFormat.DEFAULT,e):e.toString();case DBaseTypes.BOOLEAN:return!!e;case DBaseTypes.DATE:return parseDate(e);default:return e.toString()}}function _parseShapefileNames(e){if(!e.length)return[];let t=e[0];const r=t.match(shapefileNameRegex);return r?(t=r[1],e.filter((e=>{const r=e.match(shapefileNameRegex);return r&&r[1]===t}))):[t]}function _parseDBaseData(e){const t=e.map((e=>Object.keys(e))).reduce(((e,t)=>e.concat(t.filter((t=>!e.includes(t))))),[]);return[t.map((e=>({raw:e}))),...e.map((e=>t.map((t=>({raw:e[t]})))))]}function _parseShpPointGeometry(e){checkArg("geometry.coordinates",e.type).matches("Point"),checkArg("geometry.coordinates",e.coordinates).satisfies((e=>"number"==typeof e||Array.isArray(e)));const[t,r,o]=e.coordinates,a=new Point({x:t,y:r,spatialReference:SpatialReference.WGS84});if(Array.isArray(o)){const[e,t]=o;!e&&!t||e?a.z=e:a.m=t}return a}async function _parseShpGeometry(e,t){const r=isPoint(e)?_parseShpPointGeometry(e):geoJSONToEsri(e);if(t){let e;const o=await esriWktToWkid(t);if(o&&(e=new SpatialReference({wkid:parseNumber(o)})),!e)throw new Error(`Could go find wkid that matches wkt: ${t}`);r.spatialReference=e}return r}
@@ -1 +1 @@
1
- import{ArgumentError}from"../../ArgumentError.js";import{QueryBasedRelationship}from"../../tasks/query/QueryBasedRelationship.js";import{checkArg}from"../../utilities/checkArg.js";export class DefaultRelationshipFactory{create(e){switch(checkArg("properties",e).isNotMissing(),checkArg("properties.$relationshipType",e.$relationshipType).isNotMissing(),e.$relationshipType){case"QueryBasedRelationship":return new QueryBasedRelationship(e)}throw new ArgumentError("properties.$relationshipType","Unsupported relationship type.")}}DefaultRelationshipFactory.instance=new DefaultRelationshipFactory;
1
+ import{ArgumentError}from"../../ArgumentError.js";import{ArcGISRelationship}from"../../tasks/query/ArcGISRelationship.js";import{QueryBasedRelationship}from"../../tasks/query/QueryBasedRelationship.js";import{checkArg}from"../../utilities/checkArg.js";export class DefaultRelationshipFactory{create(e){switch(checkArg("properties",e).isNotMissing(),checkArg("properties.$relationshipType",e.$relationshipType).isNotMissing(),e.$relationshipType){case"QueryBasedRelationship":return new QueryBasedRelationship(e);case"ArcGISRelationship":return new ArcGISRelationship(e)}throw new ArgumentError("properties.$relationshipType","Unsupported relationship type.")}}DefaultRelationshipFactory.instance=new DefaultRelationshipFactory;
@@ -1 +1 @@
1
- import{ArgumentError}from"../../ArgumentError.js";import{checkArg}from"../../utilities/checkArg.js";import{isFeatureLayer}from"../../utilities/layers.js";import{ArcGISServiceTableExtension}from"../ArcGISServiceTableExtension.js";export class DefaultTableExtensionFactory{create(e){if(checkArg("properties",e).isNotMissing(),checkArg("properties.table",e.table).isNotMissing(),isFeatureLayer(e.table))return new ArcGISServiceTableExtension(e);if(e.table.$tableType)switch(e.table.$tableType){case"ArcGISServiceTable":return new ArcGISServiceTableExtension(e)}throw new ArgumentError("properties.table","Unable to determine correct type of table extension to create.")}}DefaultTableExtensionFactory.instance=new DefaultTableExtensionFactory;
1
+ import{ArgumentError}from"../../ArgumentError.js";import{checkArg}from"../../utilities/checkArg.js";import{isFeatureLayer}from"../../utilities/layers.js";import{ArcGISServiceTableExtension}from"../ArcGISServiceTableExtension.js";export class DefaultTableExtensionFactory{create(e){if(checkArg("properties",e).isNotMissing(),checkArg("properties.table",e.table).isNotMissing(),isFeatureLayer(e.table))return new ArcGISServiceTableExtension(e);if(e.table.$tableType&&"ArcGISServiceTable"===e.table.$tableType)return new ArcGISServiceTableExtension(e);throw new ArgumentError("properties.table","Unable to determine correct type of table extension to create.")}}DefaultTableExtensionFactory.instance=new DefaultTableExtensionFactory;
@@ -90,10 +90,10 @@ declare module "@arcgis/core/support/arcadeUtils" {
90
90
  layer: __esri.Layer | __esri.Sublayer,
91
91
  spatialReference: __esri.SpatialReference
92
92
  ): FeatureSetCollection;
93
- export function convertServiceUrlToWorkspace(
94
- serviceUrl: string,
95
- spatialReference: __esri.SpatialReference
96
- ): FeatureSetCollection;
93
+ export function convertServiceUrlToWorkspace(args: {
94
+ url: string;
95
+ spatialReference: __esri.SpatialReference;
96
+ }): FeatureSetCollection;
97
97
  }
98
98
 
99
99
  declare module "@arcgis/core/arcade/featureset/sources/FeatureLayerMemory" {
@@ -210,12 +210,17 @@ declare namespace __esri {
210
210
  loadStyle(style: string | Object): Promise<void>;
211
211
  }
212
212
 
213
- // Check if these properties exist in ESRI420.
213
+ // Check if these properties exist in ESRI421.
214
214
  export interface WMSLayer {
215
215
  mapUrl: string;
216
216
  }
217
217
 
218
- // Check if these properties exist in ESRI420.
218
+ // Check if these properties exist in ESRI421.
219
+ export interface WMSLayerProperties {
220
+ mapUrl?: string;
221
+ }
222
+
223
+ // Check if these properties exist in ESRI421.
219
224
  export interface FeatureLayer {
220
225
  mode: number;
221
226
  }
@@ -224,12 +229,10 @@ declare namespace __esri {
224
229
  clone(): this;
225
230
  }
226
231
 
227
- // Check if these properties exist in ESRI420.
228
- export interface WMSLayerProperties {
229
- mapUrl?: string;
230
- }
232
+ // Check if VectorFieldRenderer extends Renderer in ESRI422.
233
+ export interface VectorFieldRenderer extends Renderer {}
231
234
 
232
- // Check if WMSSublayer extends these in ESRI420.
235
+ // Check if WMSSublayer extends these in ESRI421.
233
236
  export interface WMSSublayer extends JSONSupport {}
234
237
 
235
238
  export interface SpatialReferenceConstructor {
@@ -238,20 +241,45 @@ declare namespace __esri {
238
241
  WGS84: SpatialReference;
239
242
  }
240
243
 
241
- // Check if these properties exist in ESRI420.
242
- export interface LocatorSuggestLocationsParams {
244
+ // Check if these properties exist in ESRI421.
245
+ export interface locatorSuggestLocationsParams {
243
246
  // These properties are not exposed by the type file provided by esri.
244
247
  searchExtent: Extent;
245
248
  maxSuggestions: number;
246
249
  countryCode: string;
247
250
  }
248
251
 
249
- export interface Query {
250
- resultRecordCount?: number;
251
- num: number;
252
+ export interface locator {
253
+ // This signature is broken in the typings and documentation. It's
254
+ // missing the first `url` parameter. Check if this is fixed in ESRI421.
255
+ locationToAddress(
256
+ url: string,
257
+ params: locatorLocationToAddressParams,
258
+ requestOptions?: any
259
+ ): Promise<supportAddressCandidate>;
260
+ }
261
+
262
+ export interface query {
263
+ // This signature is broken in the typings and documentation. It's
264
+ // missing the first `url` parameter. Check if this is fixed in ESRI421.
265
+ executeForCount(
266
+ url: string,
267
+ query: supportQuery | supportQueryProperties,
268
+ requestOptions?: any
269
+ ): Promise<number>;
270
+ }
271
+
272
+ export interface imageService {
273
+ // This signature is broken in the typings and documentation. It's
274
+ // missing the first `url` parameter. Check if this is fixed in ESRI421.
275
+ identify(
276
+ url: string,
277
+ params: supportImageIdentifyParameters,
278
+ requestOptions?: any
279
+ ): Promise<supportImageIdentifyResult>;
252
280
  }
253
281
 
254
- // Check if layer is present in ESRI420.
282
+ // Check if layer is present in ESRI421.
255
283
  export interface BuildingSublayer {
256
284
  layer: __esri.BuildingSceneLayer;
257
285
  }
@@ -315,7 +343,7 @@ declare namespace __esri {
315
343
  }
316
344
 
317
345
  export interface ImageryLayer {
318
- // This disappeared in 4.19 for some reason. Check to see if they added it back in ESRI420.
346
+ // This disappeared in 4.19 for some reason. Check to see if they added it back in ESRI421.
319
347
  rasterAttributeTableFieldPrefix: string;
320
348
  }
321
349
 
@@ -344,9 +372,9 @@ declare namespace __esri {
344
372
  ): Promise<ImageIdentifyResult>;
345
373
  }
346
374
 
347
- // ESRI420: Check if they've added to their documented properties.
375
+ // ESRI421: Check if they've added to their documented properties.
348
376
  export interface StreamLayerView {
349
- createQuery(): __esri.Query;
377
+ createQuery(): __esri.supportQuery;
350
378
  view: __esri.MapView | __esri.SceneView;
351
379
  }
352
380
 
@@ -371,7 +399,7 @@ declare namespace __esri {
371
399
  }
372
400
 
373
401
  export interface Symbol3DLayerProperties {
374
- // ESRI420: Check if they've added this to the interface. The type
402
+ // ESRI421: Check if they've added this to the interface. The type
375
403
  // property is required for autocasting to work.
376
404
  type: Symbol3DLayer["type"];
377
405
  }