@arcgis/core 4.25.0-next.20220913 → 4.25.0-next.20220915

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 (276) hide show
  1. package/arcade/ArcadeModuleLoader.js +1 -1
  2. package/arcade/ArcadeModuleResolver.js +1 -1
  3. package/arcade/arcade.js +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/featureSetUtils.js +1 -1
  8. package/arcade/featureset/actions/Adapted.js +1 -1
  9. package/arcade/featureset/actions/AttributeFilter.js +1 -1
  10. package/arcade/featureset/actions/OrderBy.js +1 -1
  11. package/arcade/featureset/actions/SpatialFilter.js +1 -1
  12. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  13. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  14. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  15. package/arcade/featureset/support/FeatureSet.js +1 -1
  16. package/arcade/featureset/support/IdSet.js +1 -1
  17. package/arcade/featureset/support/StatsField.js +1 -1
  18. package/arcade/featureset/support/sqlUtils.js +1 -1
  19. package/arcade/featureset/support/stats.js +1 -1
  20. package/arcade/functions/convertdirection.js +1 -1
  21. package/arcade/functions/featuresetbase.js +1 -1
  22. package/arcade/functions/geometry.js +1 -1
  23. package/arcade/functions/string.js +1 -1
  24. package/arcade/lib/parser.js +1 -1
  25. package/arcade/lib/tokenizer.js +1 -1
  26. package/arcade/treeAnalysis.js +1 -1
  27. package/arcade/validation/arcadeValidator.js +1 -1
  28. package/assets/esri/core/workers/RemoteClient.js +1 -1
  29. package/assets/esri/core/workers/chunks/{53485c6bc70852bc023d.js → 05d5c5efb865171bfb0a.js} +1 -1
  30. package/assets/esri/core/workers/chunks/05f761a78224990cea70.js +1 -0
  31. package/assets/esri/core/workers/chunks/0657ebbe3b1923d1eefb.js +1 -0
  32. package/assets/esri/core/workers/chunks/0b9571d24336ac0b4907.js +1 -0
  33. package/assets/esri/core/workers/chunks/{4253b4601cc449ad0594.js → 0dc76d604ba49f98471a.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{db5a6720bcf06f4d5af2.js → 0ed6e00494ed166b7bd3.js} +1 -1
  35. package/assets/esri/core/workers/chunks/16e9bd57f774944d0bf8.js +1 -0
  36. package/assets/esri/core/workers/chunks/1b85698e8b9f6bf58a46.js +1 -0
  37. package/assets/esri/core/workers/chunks/1c0e1c0d8db1fa6a6565.js +1 -0
  38. package/assets/esri/core/workers/chunks/25827c46756a4069b221.js +1 -0
  39. package/assets/esri/core/workers/chunks/2af920691b2d710b52b8.js +1 -0
  40. package/assets/esri/core/workers/chunks/{8ed2ee1f1be4f92a6f93.js → 2be65d7a2751acca3860.js} +1 -1
  41. package/assets/esri/core/workers/chunks/2c4938512dd726a177dd.js +1 -0
  42. package/assets/esri/core/workers/chunks/2ed23dd5fbb4e02ae101.js +1 -0
  43. package/assets/esri/core/workers/chunks/{76367318b857ea9254d3.js → 3035bd57a1f76fae26a4.js} +1 -1
  44. package/assets/esri/core/workers/chunks/323a32a96719a7783b63.js +1 -0
  45. package/assets/esri/core/workers/chunks/36dd5654df5c7f00406d.js +1 -0
  46. package/assets/esri/core/workers/chunks/3ed71c7a0aa8f8367387.js +1 -0
  47. package/assets/esri/core/workers/chunks/40ede4078b22791344a6.js +1 -0
  48. package/assets/esri/core/workers/chunks/{f01284acdc4e135e14d1.js → 42bad97e16b6b04f63db.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{f3ad9de4597183355eae.js → 48aa432e1bf60c68de14.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{f6084a716570836b6920.js → 4b5e449567f9f5f400e1.js} +1 -1
  51. package/assets/esri/core/workers/chunks/5035c5d268a786f65882.js +1 -0
  52. package/assets/esri/core/workers/chunks/51de0afe0c5cb2dfd044.js +1 -0
  53. package/assets/esri/core/workers/chunks/{c7fbc2dc6d20f96a781c.js → 5b16b30ac3166f33e81e.js} +1 -1
  54. package/assets/esri/core/workers/chunks/5d0f6daccc381abf7933.js +1 -0
  55. package/assets/esri/core/workers/chunks/5d780d87e46c0b72b514.js +1 -0
  56. package/assets/esri/core/workers/chunks/6654f9180c8a1bf6d34e.js +1 -0
  57. package/assets/esri/core/workers/chunks/{c68957f6be4772abb6a1.js → 6693e43af546e6eb3f16.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{9a179b6be53af1dff70c.js → 8179031362a3b32545a1.js} +1 -1
  59. package/assets/esri/core/workers/chunks/82419bfc3cbcb64f3874.js +1 -0
  60. package/assets/esri/core/workers/chunks/{8904d7bdce5d170feb3f.js → 8295993cb282b0d29ad2.js} +1 -1
  61. package/assets/esri/core/workers/chunks/988a142646a0b05c9814.js +1 -0
  62. package/assets/esri/core/workers/chunks/a234c056b1f872976a95.js +1 -0
  63. package/assets/esri/core/workers/chunks/{8a1ff12dcc52979eca00.js → adc553b1eb92d3cb6610.js} +1 -1
  64. package/assets/esri/core/workers/chunks/b19ee9436a2a9551987d.js +1 -0
  65. package/assets/esri/core/workers/chunks/{9c8e28dcf5cf0dd6350b.js → b3aa600c37450acd8640.js} +1 -1
  66. package/assets/esri/core/workers/chunks/b3d316e81d89612104cb.js +1 -0
  67. package/assets/esri/core/workers/chunks/{f41805ad8d874e05fbfa.js → b7560e2989d151b9dd47.js} +1 -1
  68. package/assets/esri/core/workers/chunks/bb05472eef3596a32667.js +1 -0
  69. package/assets/esri/core/workers/chunks/c06bcc4f91fbcad804f0.js +1 -0
  70. package/assets/esri/core/workers/chunks/{e561113f08d5a30c6f55.js → c270e544f14617de4955.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{fc5d624d13263e56c81f.js → cb2dc84d972469445da6.js} +1 -1
  72. package/assets/esri/core/workers/chunks/ceb74454576920b0d00c.js +1011 -0
  73. package/assets/esri/core/workers/chunks/{81074accfce5f109f909.js → cfd83bad25be40fe14e9.js} +1 -1
  74. package/assets/esri/core/workers/chunks/d105f206e09a2fe5e2ea.js +1 -0
  75. package/assets/esri/core/workers/chunks/d31bbb13af45ce8e45dc.js +1 -0
  76. package/assets/esri/core/workers/chunks/{ba202a0fa5f1c7b99029.js → d75fcf97569beebbdf0c.js} +1 -1
  77. package/assets/esri/core/workers/chunks/db7c3145ec95fbae7c8e.js +1 -0
  78. package/assets/esri/core/workers/chunks/de128d8a643b4297940b.js +1 -0
  79. package/assets/esri/core/workers/chunks/e7748cefefcc95a4bbe4.js +1 -0
  80. package/assets/esri/core/workers/chunks/f436c86f86236ea7ea04.js +1 -0
  81. package/assets/esri/core/workers/chunks/f47177999f69a80e15bf.js +1 -0
  82. package/assets/esri/core/workers/chunks/{528c32f8ef8b770269a4.js → f607bb297787cc5987f5.js} +1 -1
  83. package/assets/esri/core/workers/chunks/{ef174d2fbcca4c3844d7.js → f67357b3c6c591c9da5e.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{1457b1346e7587f5c57f.js → fab848b7523a74f4a1ab.js} +1 -1
  85. package/assets/esri/core/workers/chunks/fb1d0ac4b4f45830e5cf.js +1 -0
  86. package/assets/esri/core/workers/chunks/{88a01bec361948e87331.js → fd4c90ea124cf996a10e.js} +1 -1
  87. package/assets/esri/core/workers/chunks/fddd4ea487788e003fb1.js +1 -0
  88. package/assets/esri/themes/base/widgets/_Editor.scss +5 -0
  89. package/assets/esri/themes/dark/main.css +1 -1
  90. package/assets/esri/themes/light/main.css +1 -1
  91. package/assets/esri/themes/light/view.css +1 -1
  92. package/chunks/arcade.js +1 -1
  93. package/chunks/languageUtils.js +1 -1
  94. package/geohash/GeohashTree.js +1 -1
  95. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  96. package/geometry/support/meshUtils/primitives.js +1 -1
  97. package/geometry/support/triangulationUtils.js +1 -1
  98. package/interfaces.d.ts +126 -18
  99. package/kernel.js +1 -1
  100. package/layers/BuildingSceneLayer.js +1 -1
  101. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  102. package/layers/buildingSublayers/BuildingGroupSublayer.js +1 -1
  103. package/layers/buildingSublayers/BuildingSublayer.js +1 -1
  104. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  105. package/layers/graphics/sources/support/QueryTask.js +1 -1
  106. package/layers/mixins/ArcGISImageService.js +1 -1
  107. package/layers/mixins/ImageryTileMixin.js +1 -1
  108. package/layers/support/MultidimensionalSubset.js +1 -1
  109. package/layers/support/arcadeUtils.js +1 -1
  110. package/layers/support/labelFormatUtils.js +1 -1
  111. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  112. package/layers/support/rasterDatasets/CloudRaster.js +1 -1
  113. package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
  114. package/layers/support/rasterFunctions/AspectFunction.js +1 -1
  115. package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
  116. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  117. package/layers/support/rasterFunctions/ColormapFunction.js +1 -1
  118. package/layers/support/rasterFunctions/CompositeBandFunction.js +1 -1
  119. package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
  120. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  121. package/layers/support/rasterFunctions/LocalFunction.js +1 -1
  122. package/layers/support/rasterFunctions/LocalFunctionArguments.js +1 -1
  123. package/layers/support/rasterFunctions/MaskFunction.js +1 -1
  124. package/layers/support/rasterFunctions/MaskFunctionArguments.js +1 -1
  125. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  126. package/layers/support/rasterFunctions/RemapFunction.js +1 -1
  127. package/layers/support/rasterFunctions/SlopeFunction.js +1 -1
  128. package/layers/support/rasterFunctions/StatisticsHistogramsFunction.js +1 -1
  129. package/layers/support/rasterFunctions/StretchFunction.js +1 -1
  130. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  131. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  132. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  133. package/layers/support/rasterFunctions/surfaceUtils.js +1 -1
  134. package/layers/support/rasterFunctions/vectorFieldUtils.js +1 -1
  135. package/package.json +1 -1
  136. package/portal/schemas/definitions.js +1 -1
  137. package/renderers/support/DictionaryLoader.js +1 -1
  138. package/renderers/support/rendererConversion.js +1 -1
  139. package/rest/query/executeQuery.js +1 -1
  140. package/rest/support/FeatureSet.js +1 -1
  141. package/rest/support/meshFeatureSet.js +1 -1
  142. package/support/arcadeOnDemand.js +1 -1
  143. package/support/revision.js +1 -1
  144. package/symbols/MeshSymbol3D.js +1 -1
  145. package/symbols/cim/cimAnalyzer.js +1 -1
  146. package/symbols/support/symbolConversion.js +1 -1
  147. package/views/2d/arcade/callExpressionWithCursor.js +1 -1
  148. package/views/2d/arcade/callExpressionWithFeature.js +1 -1
  149. package/views/2d/layers/features/Store2D.js +1 -1
  150. package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
  151. package/views/2d/layers/features/schemaUtils.js +1 -1
  152. package/views/2d/layers/features/support/BinStore.js +1 -1
  153. package/views/2d/layers/features/support/ClusterStore.js +1 -1
  154. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  155. package/views/3d/analysis/Dimensioning/DimensioningController.js +1 -1
  156. package/views/3d/analysis/Dimensioning/LengthDimensionComputation.js +1 -1
  157. package/views/3d/analysis/Dimensioning/LengthDimensionSubTool.js +1 -1
  158. package/views/3d/analysis/DimensioningAnalysisView3D.d.ts +4 -0
  159. package/views/3d/analysis/DimensioningAnalysisView3D.js +1 -1
  160. package/views/3d/analysis/LineOfSight/lineOfSightToolUtils.js +1 -1
  161. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  162. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  163. package/views/3d/glTF/internal/indexUtils.js +1 -1
  164. package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
  165. package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
  166. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  167. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  168. package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
  169. package/views/3d/interactive/manipulatorUtils.js +1 -1
  170. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  171. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  172. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  173. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  174. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  175. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  176. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  177. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  178. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  179. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  180. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  181. package/views/3d/layers/BuildingSublayerView3D.js +1 -1
  182. package/views/3d/layers/FeatureLayerView3D.js +1 -1
  183. package/views/3d/layers/MediaLayerView3D.js +1 -1
  184. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  185. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  186. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  187. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  188. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  189. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  190. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  191. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  192. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  193. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  194. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  195. package/views/3d/layers/graphics/LabelDeconflictor.js +1 -1
  196. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  197. package/views/3d/layers/graphics/primitiveObjectSymbolUtils.js +1 -1
  198. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  199. package/views/3d/layers/support/overlayImageUtils.js +1 -1
  200. package/views/3d/state/ViewState.js +1 -1
  201. package/views/3d/state/ViewStateManager.js +1 -1
  202. package/views/3d/support/ResourceController.js +1 -1
  203. package/views/3d/support/animationUtils.js +1 -1
  204. package/views/3d/support/engineGeometry/line.js +1 -1
  205. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  206. package/views/3d/terrain/OverlayRenderer.js +1 -1
  207. package/views/3d/terrain/TerrainSurface.js +1 -1
  208. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  209. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  210. package/views/3d/webgl-engine/lib/Geometry.js +1 -1
  211. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  212. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  213. package/views/3d/webgl-engine/lib/Indices.js +5 -0
  214. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  215. package/views/3d/webgl-engine/lib/edgeRendering/EdgeProcessingWorker.js +1 -1
  216. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  217. package/views/3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle.js +1 -1
  218. package/views/3d/webgl-engine/lib/edgeRendering/edgeProcessing.js +1 -1
  219. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  220. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  221. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  222. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  223. package/views/SceneView.js +1 -1
  224. package/views/analysis/LengthDimensionResult.d.ts +4 -0
  225. package/views/analysis/LengthDimensionResult.js +5 -0
  226. package/views/interactive/snapping/featureSources/SceneLayerSnappingSource.js +1 -1
  227. package/views/layers/BuildingSceneLayerView.js +1 -1
  228. package/views/layers/FeatureLayerView.js +1 -1
  229. package/views/support/DefaultsFromMap.js +1 -1
  230. package/views/support/RenderState.js +1 -1
  231. package/views/support/Scheduler.js +1 -1
  232. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  233. package/widgets/Directions/DirectionsViewModel.js +1 -1
  234. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  235. package/widgets/Editor/CreateWorkflow.js +1 -1
  236. package/widgets/Editor/EditorViewModel.js +1 -1
  237. package/widgets/Editor.js +1 -1
  238. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  239. package/widgets/Search/support/layerSearchUtils.js +1 -1
  240. package/assets/esri/core/workers/chunks/17be5bd0d1c233d73d7a.js +0 -1
  241. package/assets/esri/core/workers/chunks/183ee2e64761401e988a.js +0 -1
  242. package/assets/esri/core/workers/chunks/1b0fd77a2dde60ec9d2f.js +0 -1
  243. package/assets/esri/core/workers/chunks/1c86541e7486c9d7879a.js +0 -1
  244. package/assets/esri/core/workers/chunks/2b1d3f89954f0fa77e46.js +0 -1
  245. package/assets/esri/core/workers/chunks/2d30dbf61bccf2aedbc3.js +0 -1
  246. package/assets/esri/core/workers/chunks/321f244464b403c465b9.js +0 -1
  247. package/assets/esri/core/workers/chunks/3991035dcf3523c6232a.js +0 -1
  248. package/assets/esri/core/workers/chunks/3f30a39565b929863a60.js +0 -1
  249. package/assets/esri/core/workers/chunks/4999ea62751ee79bdd0a.js +0 -1
  250. package/assets/esri/core/workers/chunks/4d7d6cfa3e1ef97a3acd.js +0 -1
  251. package/assets/esri/core/workers/chunks/4ec401e73d1518f1594b.js +0 -1
  252. package/assets/esri/core/workers/chunks/574483b0dec14cb84d21.js +0 -1011
  253. package/assets/esri/core/workers/chunks/616a20dfd38f25453765.js +0 -1
  254. package/assets/esri/core/workers/chunks/62d41820793b3108b0b3.js +0 -1
  255. package/assets/esri/core/workers/chunks/6acf002723098bfa90c1.js +0 -1
  256. package/assets/esri/core/workers/chunks/6dcdb3c0e1c303a9d2e7.js +0 -1
  257. package/assets/esri/core/workers/chunks/78c3e911ed7715f1a7eb.js +0 -1
  258. package/assets/esri/core/workers/chunks/78fac5c9be32161d9c5a.js +0 -1
  259. package/assets/esri/core/workers/chunks/7b20dc11666af63326f3.js +0 -1
  260. package/assets/esri/core/workers/chunks/7ed7728f5d68bc578e46.js +0 -1
  261. package/assets/esri/core/workers/chunks/898004d1eec310e69d70.js +0 -1
  262. package/assets/esri/core/workers/chunks/8c9253fc271b370a3e92.js +0 -1
  263. package/assets/esri/core/workers/chunks/8e1c804c74d461df60f7.js +0 -1
  264. package/assets/esri/core/workers/chunks/943bc82bdaee883f9ea2.js +0 -1
  265. package/assets/esri/core/workers/chunks/9890c214e98cdf1eeb5d.js +0 -1
  266. package/assets/esri/core/workers/chunks/98d1215cbce71f0e9420.js +0 -1
  267. package/assets/esri/core/workers/chunks/a302a6c18b9701edba81.js +0 -1
  268. package/assets/esri/core/workers/chunks/af36f9cf4e8e261d739d.js +0 -1
  269. package/assets/esri/core/workers/chunks/b539468c8baf83741291.js +0 -1
  270. package/assets/esri/core/workers/chunks/bd2fd077a3ef8952940f.js +0 -1
  271. package/assets/esri/core/workers/chunks/c8312bc3d4cfb6e46f5d.js +0 -1
  272. package/assets/esri/core/workers/chunks/d440b5dd8c7cd17809b6.js +0 -1
  273. package/assets/esri/core/workers/chunks/e80cd966d0be8de58b26.js +0 -1
  274. package/assets/esri/core/workers/chunks/fac4fb73478a0734340c.js +0 -1
  275. package/portal/AssetMapFieldRole.js +0 -5
  276. package/views/3d/analysis/LengthDimensionResult.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import{SqlError as r,SqlErrorCodes as s,FeatureSetError as a,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import l from"../support/FeatureSet.js";import n from"../support/IdSet.js";import{cloneField as o,FeatureServiceDatabaseType as h,layerGeometryEsriConstants as u}from"../support/shared.js";import{reformulateWithoutField as c,toWhereClause as d,translateFunctionToDatabaseSpecific as p,makeToday as f,makeDateString as g,convertIntervalToSql as N,combine as _,scanForField as S}from"../support/sqlUtils.js";import{WhereClause as w}from"../../../core/sql/WhereClause.js";import m from"../../../geometry/SpatialReference.js";class v{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class C extends v{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class T extends v{constructor(e,t,r){super(o(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:c(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class F extends v{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,h.Standardised,this.field.name,this.codefield instanceof w?d(this.codefield,h.Standardised):this.codefield,e.parameters);return r.includes(F.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:w.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,a=null,i=null,l){let n,o,h,u;switch(e.type){case"interval":return N(this.evaluateNodeToWhereClause(e.value,t,a,i,l),e.qualifier,e.op);case"case-expression":{let r=" CASE ";"simple"===e.format&&(r+=this.evaluateNodeToWhereClause(e.operand,t,a,F.BADNESS,l));for(let s=0;s<e.clauses.length;s++)r+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,t,a,F.BADNESS,l)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,t,a,F.BADNESS,l);return null!==e.else&&(r+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,a,F.BADNESS,l)),r+=" END ",r}case"parameter":{const r=l[e.value.toLowerCase()];if("string"==typeof r){return"'"+l[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return g(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(g(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expression-list":o=[];for(const r of e.value)o.push(this.evaluateNodeToWhereClause(r,t,a,i,l));return o;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,a,F.BADNESS,l)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" AND "+this.evaluateNodeToWhereClause(e.right,t,a,i,l)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" OR "+this.evaluateNodeToWhereClause(e.right,t,a,i,l)+") ";case"IS":if("null"!==e.right.type)throw new r(s.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new r(s.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IS NOT NULL )";case"IN":if(n=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const r=[];let s=!0;for(const t of e.right.value){if("string"!==t.type){s=!1;break}if(void 0===this.lkp[t.value]){s=!1;break}r.push(this.lkp[t.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+r.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,a,i,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,a,i,l),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+u+")) ";case"NOT IN":if(n=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const r=[];let s=!0;for(const t of e.right.value){if("string"!==t.type){s=!1;break}if(void 0===this.lkp[t.value]){s=!1;break}r.push(this.lkp[t.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+r.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,a,i,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,a,i,l),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+u+")) ";case"BETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"NOTBETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" NOT BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+i+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+i+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,F.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,F.BADNESS,l)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return g(e.value,t);case"number":return e.value.toString();case"current-time":return f("date"===e.mode,t);case"column-reference":return a&&a.toLowerCase()===e.column.toLowerCase()?"("+i+")":e.column;case"function":{const r=this.evaluateNodeToWhereClause(e.args,t,a,F.BADNESS,l);return p(e.name,r,t)}}throw new r(s.UnsupportedSyntax,{node:e.type})}extractValue(e){return this.codefield instanceof w?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}F.BADNESS="_!!!_BAD_LKP_!!!!";class W extends v{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:c(e,this.field.name,d(this._sql,h.Standardised),t.getFieldsIndex())}}extractValue(e){return this._sql.calculateValueCompiled(e)}}class E extends l{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new m({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=u.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=null;return t=this._extraFilter?await this._getFilteredSet("",null,null,null,e):await this._parent._getSet(e),this._checkCancelled(e),this._wset=new n(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}async _getFeatures(r,s,a,i){const l=[];-1!==s&&void 0===this._featureCache[s]&&l.push(s);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return await this._expandPagedSet(r,o,0,0,i),this._getFeatures(r,s,a,i);let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=a&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==s&&l.push(r._known[e]),l.length>=o)));e++);if(0===l.length)return"success";r=new n([],l,r._ordered,null);const u=Math.min(l.length,a);await this._parent._getFeatures(r,-1,u,i),this._checkCancelled(i);const c=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(l[e]);void 0!==t&&c.push({geometry:t.geometry,attributes:t.attributes,id:l[e]})}for(const n of c){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(n);this._featureCache[n.id]=new e({attributes:r,geometry:t(n.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new a(i.NeverReach)}async _getFilteredSet(e,t,r,s,a){let i=!1;const l=this._reformulateWithoutAdaptions(r);i=l.cannot,r=l.where;let o=!1;if(null!==s){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof C)&&!0===s.scanForField(t.field.name)){if(!(t instanceof T)){s=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}s&&e.length>0&&(s=s.replaceFields(e))}null!==r?null!==this._extraFilter&&(r=_(this._extraFilter,r)):r=this._extraFilter,await this._ensureLoaded();const h=await this._parent._getFilteredSet(e,t,r,s,a);let u;return this._checkCancelled(a),u=!0===i?new n(h._candidates.slice(0).concat(h._known.slice(0)),[],!0===o&&h._ordered,this._clonePageDefinition(h.pagesDefinition)):new n(h._candidates.slice(0),h._known.slice(0),!0===o&&h._ordered,this._clonePageDefinition(h.pagesDefinition)),u}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===S(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}async _stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);if(n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=_(this._extraFilter,a)):a=this._extraFilter,!0===n)return null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1};const h=await this._parent._stat(e,t,r,s,a,i,l);return!1===h.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:h}async _canDoAggregates(e,t,r,s,a){if(null===this._parent)return!1;for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof C))return!1;const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return!1;const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return!l.cannot&&(null!==(a=l.where)?null!==this._extraFilter&&(a=_(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}async _getAggregatePagesDataSourceDefinition(e,t,r,s,l,n,o){if(null===this._parent)throw new a(i.NeverReach);const h=[];for(let c=0;c<t.length;c++){const e=t[c];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)throw new a(i.NeverReach);const r=e.clone();r.workingexpr=t.where,h.push(r)}else h.push(e)}const u=this._reformulateWithoutAdaptions(l);if(u.cannot)throw new a(i.NeverReach);return null!==(l=u.where)?null!==this._extraFilter&&(l=_(this._extraFilter,l)):l=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,h,r,s,l,n,o)}}export{E as AdaptedFeatureSet,v as AdaptedField,T as FieldRename,C as OriginalField,W as SqlExpressionAdapted,F as StringToCodeAdapted};
5
+ import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import{SqlError as r,SqlErrorCodes as s,FeatureSetError as a,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import l from"../support/FeatureSet.js";import n from"../support/IdSet.js";import{cloneField as o,FeatureServiceDatabaseType as h,layerGeometryEsriConstants as u}from"../support/shared.js";import{reformulateWithoutField as c,toWhereClause as d,translateFunctionToDatabaseSpecific as p,makeToday as f,makeDateString as g,convertIntervalToSql as N,combine as _,scanForField as S}from"../support/sqlUtils.js";import{unwrapOrThrow as w,assertIsSome as m}from"../../../core/maybe.js";import{WhereClause as v}from"../../../core/sql/WhereClause.js";import C from"../../../geometry/SpatialReference.js";class T{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class F extends T{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class W extends T{constructor(e,t,r){super(o(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:c(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class E extends T{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,h.Standardised,this.field.name,this.codefield instanceof v?d(this.codefield,h.Standardised):this.codefield,e.parameters);return r.includes(E.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:v.create(r,w(t._parent).getFieldsIndex())}}evaluateNodeToWhereClause(e,t,a=null,i=null,l){let n,o,h,u;switch(e.type){case"interval":return N(this.evaluateNodeToWhereClause(e.value,t,a,i,l),e.qualifier,e.op);case"case-expression":{let r=" CASE ";"simple"===e.format&&(r+=this.evaluateNodeToWhereClause(e.operand,t,a,E.BADNESS,l));for(let s=0;s<e.clauses.length;s++)r+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,t,a,E.BADNESS,l)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,t,a,E.BADNESS,l);return null!==e.else&&(r+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,a,E.BADNESS,l)),r+=" END ",r}case"parameter":{const r=l[e.value.toLowerCase()];if("string"==typeof r){return"'"+l[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return g(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(g(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expression-list":o=[];for(const r of e.value)o.push(this.evaluateNodeToWhereClause(r,t,a,i,l));return o;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,a,E.BADNESS,l)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" AND "+this.evaluateNodeToWhereClause(e.right,t,a,i,l)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" OR "+this.evaluateNodeToWhereClause(e.right,t,a,i,l)+") ";case"IS":if("null"!==e.right.type)throw new r(s.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new r(s.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IS NOT NULL )";case"IN":if(n=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const r=[];let s=!0;for(const t of e.right.value){if("string"!==t.type){s=!1;break}if(void 0===this.lkp[t.value]){s=!1;break}r.push(this.lkp[t.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+r.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,a,i,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,a,i,l),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+u+")) ";case"NOT IN":if(n=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const r=[];let s=!0;for(const t of e.right.value){if("string"!==t.type){s=!1;break}if(void 0===this.lkp[t.value]){s=!1;break}r.push(this.lkp[t.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+r.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,a,i,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,a,i,l),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+u+")) ";case"BETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"NOTBETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" NOT BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+i+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+i+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,E.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,E.BADNESS,l)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return g(e.value,t);case"number":return e.value.toString();case"current-time":return f("date"===e.mode,t);case"column-reference":return a&&a.toLowerCase()===e.column.toLowerCase()?"("+i+")":e.column;case"function":{const r=this.evaluateNodeToWhereClause(e.args,t,a,E.BADNESS,l);return p(e.name,r,t)}}throw new r(s.UnsupportedSyntax,{node:e.type})}extractValue(e){return this.codefield instanceof v?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}E.BADNESS="_!!!_BAD_LKP_!!!!";class x extends T{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:c(e,this.field.name,d(this._sql,h.Standardised),t.getFieldsIndex())}}extractValue(e){return this._sql.calculateValueCompiled(e)}}class A extends l{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=[],this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new C({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=u.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=null;return t=this._extraFilter?await this._getFilteredSet("",null,null,null,e):await(this._parent?._getSet(e)),this._checkCancelled(e),m(t),this._wset=new n(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){return w(this._parent)._isInFeatureSet(e)}async _getFeatures(r,s,a,i){const l=[];-1!==s&&void 0===this._featureCache[s]&&l.push(s);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return await this._expandPagedSet(r,o,0,0,i),this._getFeatures(r,s,a,i);let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=a&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==s&&l.push(r._known[e]),l.length>=o)));e++);if(0===l.length)return"success";r=new n([],l,r._ordered,null);const u=Math.min(l.length,a);await(this._parent?._getFeatures(r,-1,u,i)),this._checkCancelled(i);const c=[];for(let e=0;e<u;e++){const t=this._parent?._featureFromCache(l[e]);void 0!==t&&c.push({geometry:t.geometry,attributes:t.attributes,id:l[e]})}for(const n of c){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(n);this._featureCache[n.id]=new e({attributes:r,geometry:t(n.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new a(i.NeverReach)}async _getFilteredSet(e,t,r,s,a){let i=!1;const l=this._reformulateWithoutAdaptions(r);i=l.cannot,r=l.where;let o=!1;if(null!==s){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof F)&&!0===s.scanForField(t.field.name)){if(!(t instanceof W)){s=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}s&&e.length>0&&(s=s.replaceFields(e))}null!==r?null!==this._extraFilter&&(r=_(this._extraFilter,r)):r=this._extraFilter,await this._ensureLoaded();const h=await w(this._parent)._getFilteredSet(e,t,r,s,a);let u;return this._checkCancelled(a),u=!0===i?new n(h._candidates.slice(0).concat(h._known.slice(0)),[],!0===o&&h._ordered,this._clonePageDefinition(h.pagesDefinition)):new n(h._candidates.slice(0),h._known.slice(0),!0===o&&h._ordered,this._clonePageDefinition(h.pagesDefinition)),u}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===S(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}async _stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);if(n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=_(this._extraFilter,a)):a=this._extraFilter,!0===n)return null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1};const h=await w(this._parent)._stat(e,t,r,s,a,i,l);return!1===h.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:h}async _canDoAggregates(e,t,r,s,a){if(null===this._parent)return!1;for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof F))return!1;const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return!1;const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return!l.cannot&&(null!==(a=l.where)?null!==this._extraFilter&&(a=_(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}async _getAggregatePagesDataSourceDefinition(e,t,r,s,l,n,o){if(null===this._parent)throw new a(i.NeverReach);const h=[];for(let c=0;c<t.length;c++){const e=t[c];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)throw new a(i.NeverReach);const r=e.clone();r.workingexpr=t.where,h.push(r)}else h.push(e)}const u=this._reformulateWithoutAdaptions(l);if(u.cannot)throw new a(i.NeverReach);return null!==(l=u.where)?null!==this._extraFilter&&(l=_(this._extraFilter,l)):l=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,h,r,s,l,n,o)}}export{A as AdaptedFeatureSet,T as AdaptedField,W as FieldRename,F as OriginalField,x as SqlExpressionAdapted,E as StringToCodeAdapted};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{FeatureSetError as e,FeatureSetErrorCodes as t}from"../support/errorsupport.js";import s from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{layerGeometryEsriConstants as r,IdState as n}from"../support/shared.js";import{combine as a}from"../support/sqlUtils.js";import{isPromiseLike as l}from"../../../core/promiseUtils.js";import{WhereClause as h}from"../../../core/sql/WhereClause.js";import u from"../../../geometry/SpatialReference.js";class c extends s{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof h?(this._whereclause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereclause=null)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new u({wkid:4326}),this.geometryType=r.point)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._parent._getFilteredSet("",null,this._whereclause,null,e);return this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new i(t._candidates.slice(0).concat(t._known.slice(0)),[],t._ordered,this._clonePageDefinition(t.pagesDefinition)):this._wset=new i(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===n.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?n.Unknown:t)}_getFeature(e,t,s){return this._parent._getFeature(e,t,s)}_getFeatures(e,t,s,i){return this._parent._getFeatures(e,t,s,i)}_featureFromCache(e){return this._parent._featureFromCache(e)}executeWhereClause(e){return this._whereclause.testFeature(e)}async executeWhereClauseDeferred(e){if(null!==this._whereClauseFunction){const t=this._whereClauseFunction(e);return l(t),t}return this.executeWhereClause(e)}async _fetchAndRefineFeatures(e,t,s){const r=new i([],e,!1,null),a=Math.min(t,e.length);if(await this._parent._getFeatures(r,-1,a,s),this._checkCancelled(s),null==this._whereClauseFunction){for(let t=0;t<a;t++){const s=this._parent._featureFromCache(e[t]);!0===this.executeWhereClause(s)?this._idstates[e[t]]=n.InFeatureSet:this._idstates[e[t]]=n.NotInFeatureSet}return"success"}const l=[];for(let i=0;i<a;i++){const t=this._parent._featureFromCache(e[i]);l.push(await this.executeWhereClauseDeferred(t))}for(let i=0;i<t;i++)!0===l[i]?this._idstates[e[i]]=n.InFeatureSet:this._idstates[e[i]]=n.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,s,r,n){null!==this._whereClauseFunction||(null!==s?null!==this._whereclause&&(s=a(this._whereclause,s)):s=this._whereclause),await this._ensureLoaded();const l=await this._parent._getFilteredSet(e,t,s,r,n);let h;return this._checkCancelled(n),h=null!==this._whereClauseFunction?new i(l._candidates.slice(0).concat(l._known.slice(0)),[],l._ordered,this._clonePageDefinition(l.pagesDefinition)):new i(l._candidates.slice(0),l._known.slice(0),l._ordered,this._clonePageDefinition(l.pagesDefinition)),h}async _stat(e,t,s,i,r,n,l){if(null!==this._whereClauseFunction)return null===r&&""===s&&null===i?this._manualStat(e,t,n,l):{calculated:!1};let h=this._whereclause;null!==r&&null!==this._whereclause&&(h=a(this._whereclause,r));const u=await this._parent._stat(e,t,s,i,h,n,l);return!1===u.calculated?null===r&&""===s&&null===i?this._manualStat(e,t,n,l):{calculated:!1}:u}async _canDoAggregates(e,t,s,i,r){return null===this._whereClauseFunction&&(null!==r?null!==this._whereclause&&(r=a(this._whereclause,r)):r=this._whereclause,null!==this._parent&&this._parent._canDoAggregates(e,t,s,i,r))}async _getAggregatePagesDataSourceDefinition(s,i,r,n,l,h,u){if(null===this._parent)throw new e(t.NeverReach);return null!==l?null!==this._whereclause&&(l=a(this._whereclause,l)):l=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(s,i,r,n,l,h,u)}static registerAction(){s._featuresetFunctions.filter=function(e){if("function"==typeof e)return new c({parentfeatureset:this,whereclause:e});let t=null;return e instanceof h&&(t=e),new c({parentfeatureset:this,whereclause:t})}}}export{c as default};
5
+ import{FeatureSetError as e,FeatureSetErrorCodes as t}from"../support/errorsupport.js";import s from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{layerGeometryEsriConstants as r,IdState as n}from"../support/shared.js";import{combine as a}from"../support/sqlUtils.js";import{isPromiseLike as l}from"../../../core/promiseUtils.js";import{WhereClause as h}from"../../../core/sql/WhereClause.js";import u from"../../../geometry/SpatialReference.js";class c extends s{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof h?(this._whereclause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereclause=null)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new u({wkid:4326}),this.geometryType=r.point)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._parent._getFilteredSet("",null,this._whereclause,null,e);return this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new i(t._candidates.slice(0).concat(t._known.slice(0)),[],t._ordered,this._clonePageDefinition(t.pagesDefinition)):this._wset=new i(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent?._isInFeatureSet(e);return t===n.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?n.Unknown:t)}_getFeature(e,t,s){return this._parent._getFeature(e,t,s)}_getFeatures(e,t,s,i){return this._parent._getFeatures(e,t,s,i)}_featureFromCache(e){return this._parent._featureFromCache(e)}executeWhereClause(e){return this._whereclause?.testFeature(e)??!1}async executeWhereClauseDeferred(e){if(null!==this._whereClauseFunction){const t=this._whereClauseFunction(e);return l(t),t}return this.executeWhereClause(e)}async _fetchAndRefineFeatures(e,t,s){const r=new i([],e,!1,null),a=Math.min(t,e.length);if(await(this._parent?._getFeatures(r,-1,a,s)),this._checkCancelled(s),null==this._whereClauseFunction){for(let t=0;t<a;t++){const s=this._parent?._featureFromCache(e[t]);!0===this.executeWhereClause(s)?this._idstates[e[t]]=n.InFeatureSet:this._idstates[e[t]]=n.NotInFeatureSet}return"success"}const l=[];for(let i=0;i<a;i++){const t=this._parent?._featureFromCache(e[i]);l.push(await this.executeWhereClauseDeferred(t))}for(let i=0;i<t;i++)!0===l[i]?this._idstates[e[i]]=n.InFeatureSet:this._idstates[e[i]]=n.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,s,r,n){null!==this._whereClauseFunction||(null!==s?null!==this._whereclause&&(s=a(this._whereclause,s)):s=this._whereclause),await this._ensureLoaded();const l=await this._parent._getFilteredSet(e,t,s,r,n);let h;return this._checkCancelled(n),h=null!==this._whereClauseFunction?new i(l._candidates.slice(0).concat(l._known.slice(0)),[],l._ordered,this._clonePageDefinition(l.pagesDefinition)):new i(l._candidates.slice(0),l._known.slice(0),l._ordered,this._clonePageDefinition(l.pagesDefinition)),h}async _stat(e,t,s,i,r,n,l){if(null!==this._whereClauseFunction)return null===r&&""===s&&null===i?this._manualStat(e,t,n,l):{calculated:!1};let h=this._whereclause;null!==r&&null!==this._whereclause&&(h=a(this._whereclause,r));const u=await this._parent._stat(e,t,s,i,h,n,l);return!1===u.calculated?null===r&&""===s&&null===i?this._manualStat(e,t,n,l):{calculated:!1}:u}async _canDoAggregates(e,t,s,i,r){return null===this._whereClauseFunction&&(null!==r?null!==this._whereclause&&(r=a(this._whereclause,r)):r=this._whereclause,null!==this._parent&&this._parent._canDoAggregates(e,t,s,i,r))}async _getAggregatePagesDataSourceDefinition(s,i,r,n,l,h,u){if(null===this._parent)throw new e(t.NeverReach);return null!==l?null!==this._whereclause&&(l=a(this._whereclause,l)):l=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(s,i,r,n,l,h,u)}static registerAction(){s._featuresetFunctions.filter=function(e){if("function"==typeof e)return new c({parentfeatureset:this,whereclause:e});let t=null;return e instanceof h&&(t=e),new c({parentfeatureset:this,whereclause:t})}}}export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{W as e}from"../../../chunks/languageUtils.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import s from"../support/IdSet.js";import i from"../support/OrderbyClause.js";class a extends n{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,this._orderbyclause,e);return this._checkCancelled(e),this._wset=t,this._wset}return this._wset}async manualOrderSet(e,t){const r=await this.getIdColumnDictionary(e,[],-1,t);this._orderbyclause.order(r);const n=new s([],[],!0,null);for(let s=0;s<r.length;s++)n._known.push(r[s].id);return n}async getIdColumnDictionary(t,r,n,s){if(n<t._known.length-1){const i=this._maxQueryRate();if("GETPAGES"===t._known[n+1])return await e(this._parent._expandPagedSet(t,i,0,0,s)),this.getIdColumnDictionary(t,r,n,s);let a=n+1;const o=[];for(;a<t._known.length&&"GETPAGES"!==t._known[a];)o.push(t._known[a]),a++;n+=o.length;const u=await e(this._parent._getFeatureBatch(o,s));this._checkCancelled(s);for(const e of u)r.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(t,r,n,s)}return t._candidates.length>0?(await e(this._refineSetBlock(t,this._maxProcessingRate(),s)),this._checkCancelled(s),this.getIdColumnDictionary(t,r,n,s)):r}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,n){return this._parent._getFeatures(e,t,r,n)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}async _fetchAndRefineFeatures(){throw new t(r.NeverReach)}async _getFilteredSet(e,t,r,n,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===n?this._orderbyclause:n,i);this._checkCancelled(i);const o=new s(a._candidates.slice(0),a._known.slice(0),a._ordered,this._clonePageDefinition(a.pagesDefinition));let u=!0;if(a._candidates.length>0&&(u=!1),!1===o._ordered){let e=await this.manualOrderSet(o,i);return!1===u&&(null===t&&null===r||(e=new s(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){n._featuresetFunctions.orderBy=function(e){return""===e?this:new a({parentfeatureset:this,orderbyclause:new i(e)})}}}export{a as default};
5
+ import{W as e}from"../../../chunks/languageUtils.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import s from"../support/IdSet.js";import i from"../support/OrderbyClause.js";class a extends n{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,this._orderbyclause,e);return this._checkCancelled(e),this._wset=t,this._wset}return this._wset}async manualOrderSet(e,t){const r=await this.getIdColumnDictionary(e,[],-1,t);this._orderbyclause?.order(r);const n=new s([],[],!0,null);for(let s=0;s<r.length;s++)n._known.push(r[s].id);return n}async getIdColumnDictionary(t,r,n,s){if(n<t._known.length-1){const i=this._maxQueryRate();if("GETPAGES"===t._known[n+1])return await e(this._parent._expandPagedSet(t,i,0,0,s)),this.getIdColumnDictionary(t,r,n,s);let a=n+1;const o=[];for(;a<t._known.length&&"GETPAGES"!==t._known[a];)o.push(t._known[a]),a++;n+=o.length;const u=await e(this._parent._getFeatureBatch(o,s));this._checkCancelled(s);for(const e of u)r.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(t,r,n,s)}return t._candidates.length>0?(await e(this._refineSetBlock(t,this._maxProcessingRate(),s)),this._checkCancelled(s),this.getIdColumnDictionary(t,r,n,s)):r}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,n){return this._parent._getFeatures(e,t,r,n)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}async _fetchAndRefineFeatures(){throw new t(r.NeverReach)}async _getFilteredSet(e,t,r,n,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===n?this._orderbyclause:n,i);this._checkCancelled(i);const o=new s(a._candidates.slice(0),a._known.slice(0),a._ordered,this._clonePageDefinition(a.pagesDefinition));let u=!0;if(a._candidates.length>0&&(u=!1),!1===o._ordered){let e=await this.manualOrderSet(o,i);return!1===u&&(null===t&&null===r||(e=new s(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){n._featuresetFunctions.orderBy=function(e){return""===e?this:new a({parentfeatureset:this,orderbyclause:new i(e)})}}}export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../sources/Empty.js";import{FeatureSetError as t,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import n from"../support/IdSet.js";import{IdState as a,shapeExtent as s}from"../support/shared.js";import{relate as o,crosses as l,touches as u,within as h,overlaps as _,contains as c,intersects as p}from"../../../geometry/geometryEngineAsync.js";class f extends r{constructor(e){super(e),this._relation="",this._relationGeom=null,this._relationString="",this.declaredClass="esri.arcade.featureset.actions.SpatialFilter",this._relationString=e.relationString,this._parent=e.parentfeatureset,this._maxProcessing=40,this._relation=e.relation,this._relationGeom=e.relationGeom}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,null,null,e);return this._checkCancelled(e),this._wset=new n(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===a.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?a.Unknown:t)}_getFeature(e,t,i){return this._parent._getFeature(e,t,i)}_getFeatures(e,t,i,r){return this._parent._getFeatures(e,t,i,r)}_featureFromCache(e){return this._parent._featureFromCache(e)}async executeSpatialRelationTest(e){if(null===e.geometry)return!1;switch(this._relation){case"esriSpatialRelEnvelopeIntersects":{const t=s(this._relationGeom),i=s(e.geometry);return p(t,i)}case"esriSpatialRelIntersects":return p(this._relationGeom,e.geometry);case"esriSpatialRelContains":return c(this._relationGeom,e.geometry);case"esriSpatialRelOverlaps":return _(this._relationGeom,e.geometry);case"esriSpatialRelWithin":return h(this._relationGeom,e.geometry);case"esriSpatialRelTouches":return u(this._relationGeom,e.geometry);case"esriSpatialRelCrosses":return l(this._relationGeom,e.geometry);case"esriSpatialRelRelation":return o(this._relationGeom,e.geometry,this._relationString)}}async _fetchAndRefineFeatures(e,t,i){const r=new n([],e,!1,null),s=Math.min(t,e.length);await this._parent._getFeatures(r,-1,s,i),this._checkCancelled(i);const o=[];for(let n=0;n<s;n++){const t=this._parent._featureFromCache(e[n]);o.push(await this.executeSpatialRelationTest(t))}for(let n=0;n<t;n++)!0===o[n]?this._idstates[e[n]]=a.InFeatureSet:this._idstates[e[n]]=a.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,i,r,a){await this._ensureLoaded();const s=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,i,r,a);let o;return this._checkCancelled(a),o=null!==t?new n(s._candidates.slice(0).concat(s._known.slice(0)),[],s._ordered,this._clonePageDefinition(s.pagesDefinition)):new n(s._candidates.slice(0),s._known.slice(0),s._ordered,this._clonePageDefinition(s.pagesDefinition)),o}async _stat(e,t,i,r,n,a,s){if(""!==i)return{calculated:!1};const o=await this._parent._stat(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n,a,s);return!1===o.calculated?null===n&&""===i&&null===r?this._manualStat(e,t,a,s):{calculated:!1}:o}async _canDoAggregates(e,t,i,r,n){return""===i&&null===r&&(null!==this._parent&&this._parent._canDoAggregates(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n))}async _getAggregatePagesDataSourceDefinition(e,r,n,a,s,o,l){if(null===this._parent)throw new t(i.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,r,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,s,o,l)}static registerAction(){r._featuresetFunctions.intersects=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelIntersects",relationGeom:t})},r._featuresetFunctions.envelopeIntersects=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelEnvelopeIntersects",relationGeom:t})},r._featuresetFunctions.contains=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelContains",relationGeom:t})},r._featuresetFunctions.overlaps=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelOverlaps",relationGeom:t})},r._featuresetFunctions.within=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelWithin",relationGeom:t})},r._featuresetFunctions.touches=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelTouches",relationGeom:t})},r._featuresetFunctions.crosses=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelCrosses",relationGeom:t})},r._featuresetFunctions.relate=function(t,i){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelRelation",relationGeom:t,relationString:i})}}}export{f as default};
5
+ import e from"../sources/Empty.js";import{FeatureSetError as t,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import n from"../support/IdSet.js";import{IdState as a,shapeExtent as s}from"../support/shared.js";import{relate as o,crosses as l,touches as u,within as h,overlaps as _,contains as c,intersects as p}from"../../../geometry/geometryEngineAsync.js";class f extends r{constructor(e){super(e),this._relation="",this._relationGeom=null,this._relationString="",this.declaredClass="esri.arcade.featureset.actions.SpatialFilter",this._relationString=e.relationString,this._parent=e.parentfeatureset,this._maxProcessing=40,this._relation=e.relation,this._relationGeom=e.relationGeom}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,null,null,e);return this._checkCancelled(e),this._wset=new n(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===a.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?a.Unknown:t)}_getFeature(e,t,i){return this._parent._getFeature(e,t,i)}_getFeatures(e,t,i,r){return this._parent._getFeatures(e,t,i,r)}_featureFromCache(e){return this._parent._featureFromCache(e)}async executeSpatialRelationTest(e){if(null===e.geometry)return!1;switch(this._relation){case"esriSpatialRelEnvelopeIntersects":{const t=s(this._relationGeom),i=s(e.geometry);return p(t,i)}case"esriSpatialRelIntersects":return p(this._relationGeom,e.geometry);case"esriSpatialRelContains":return c(this._relationGeom,e.geometry);case"esriSpatialRelOverlaps":return _(this._relationGeom,e.geometry);case"esriSpatialRelWithin":return h(this._relationGeom,e.geometry);case"esriSpatialRelTouches":return u(this._relationGeom,e.geometry);case"esriSpatialRelCrosses":return l(this._relationGeom,e.geometry);case"esriSpatialRelRelation":return o(this._relationGeom,e.geometry,this._relationString??"")}}async _fetchAndRefineFeatures(e,t,i){const r=new n([],e,!1,null),s=Math.min(t,e.length);await(this._parent?._getFeatures(r,-1,s,i)),this._checkCancelled(i);const o=[];for(let n=0;n<s;n++){const t=this._parent._featureFromCache(e[n]);o.push(await this.executeSpatialRelationTest(t))}for(let n=0;n<t;n++)!0===o[n]?this._idstates[e[n]]=a.InFeatureSet:this._idstates[e[n]]=a.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,i,r,a){await this._ensureLoaded();const s=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,i,r,a);let o;return this._checkCancelled(a),o=null!==t?new n(s._candidates.slice(0).concat(s._known.slice(0)),[],s._ordered,this._clonePageDefinition(s.pagesDefinition)):new n(s._candidates.slice(0),s._known.slice(0),s._ordered,this._clonePageDefinition(s.pagesDefinition)),o}async _stat(e,t,i,r,n,a,s){if(""!==i)return{calculated:!1};const o=await this._parent._stat(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n,a,s);return!1===o.calculated?null===n&&""===i&&null===r?this._manualStat(e,t,a,s):{calculated:!1}:o}async _canDoAggregates(e,t,i,r,n){return""===i&&null===r&&(null!==this._parent&&this._parent._canDoAggregates(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n))}async _getAggregatePagesDataSourceDefinition(e,r,n,a,s,o,l){if(null===this._parent)throw new t(i.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,r,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,s,o,l)}static registerAction(){r._featuresetFunctions.intersects=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelIntersects",relationGeom:t})},r._featuresetFunctions.envelopeIntersects=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelEnvelopeIntersects",relationGeom:t})},r._featuresetFunctions.contains=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelContains",relationGeom:t})},r._featuresetFunctions.overlaps=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelOverlaps",relationGeom:t})},r._featuresetFunctions.within=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelWithin",relationGeom:t})},r._featuresetFunctions.touches=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelTouches",relationGeom:t})},r._featuresetFunctions.crosses=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelCrosses",relationGeom:t})},r._featuresetFunctions.relate=function(t,i){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelRelation",relationGeom:t,relationString:i})}}}export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import t from"../../../request.js";import i from"../../Attachment.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{fromJSON as _}from"../../../geometry/support/jsonUtils.js";import m from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as g}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as S}from"../../../rest/query/executeQueryJSON.js";import"../../../core/arrayUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import{executeQueryPBF as F}from"../../../rest/query/operations/query.js";import b from"../../../rest/support/FeatureSet.js";import R from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as w}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeForIds as D}from"../../../rest/query/executeForIds.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as I}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import x from"../../../rest/support/StatisticDefinition.js";import q from"../../Dictionary.js";import{FeatureSetError as P,FeatureSetErrorCodes as j}from"../support/errorsupport.js";class C extends r{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const i of this._layer.outFields)if(i.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new R;t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}async queryPBF(e){e.quantizationParameters={mode:"edit"};const t=await F(this._layer.parsedUrl,e,new I({}));return b.fromJSON(g(t.data)).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const i="execute"===t?S:"executeForCount"===t?w:D,r="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==r?i(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==r?i(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}async _getFilteredSet(e,t,i,r,a){const n=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,a);let l="",o=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=r.constructClause(),o=!0);const u=new R;u.where=null===i?null===t?"1=1":"":d(i,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let h=await this.executeQuery(u,"executeForIds");null===h&&(h=[]),this._checkCancelled(a);return new s([],h,o,null)}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}async _getFilteredSetUsingPaging(e,t,i,r,a){let n="",l=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=r.constructClause(),l=!0);const o=await this.databaseType();let u=null===i?null===t?"1=1":"":d(i,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let h=this._maxQueryRate();const p=this._layer.capabilities.query.maxRecordCount;void 0!==p&&p<h&&(h=p);let c=null;if(!0===this._pageJustIds)c=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:h,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const r=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);c=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:h,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(c,h,0,1,a),c}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,a=e.pagesDefinition.internal.lastPage,n=new R;this._requestStandardised&&(n.sqlFormat="standard"),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";for(let o=0;o<l.features.length;o++)e.pagesDefinition.internal.set[s+o]=l.features[o].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let o=0;o<l.features.length;o++)this._featureCache[l.features[o].attributes[this._layer.objectIdField]]=l.features[o];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){const s=[];if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let a=0;for(let o=e._lastFetchedIndex;o<e._known.length;o++){if(e._lastFetchedIndex+=1,a++,void 0===this._featureCache[e._known[o]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[o]]){const r=t._featureMap[e._known[o]];null!==r&&(i=!0,this._featureCache[e._known[o]]=r)}}if(!1===i&&(e._known[o]!==t&&s.push(e._known[o]),s.length>=this._maxProcessingRate()-1))break}if(a>=i&&0===s.length)break}if(0===s.length)return"success";const n=new R;this._requestStandardised&&(n.sqlFormat="standard"),n.objectIds=s,n.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),n.returnGeometry=!0,!0===this._removeGeometry&&(n.returnGeometry=!1),n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(r),void 0!==l.error)throw new P(j.RequestFailed,{reason:l.error});for(let o=0;o<l.features.length;o++)this._featureCache[l.features[o].attributes[this._layer.objectIdField]]=l.features[o];return"success"}async _getDistinctPages(e,t,i,r,s,a,n,l,o){await this._ensureLoaded();const u=await this.databaseType();let h=i.parseTree.column;for(let d=0;d<this._layer.fields.length;d++)if(this._layer.fields[d].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[d].name;break}const p=new R;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(r),p.relationParameter=this._makeRelationshipParam(r),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h];const y=await this.executeQuery(p,"execute");if(this._checkCancelled(o),!y.hasOwnProperty("features"))throw new P(j.InvalidStatResponse);let f=!1;for(let d=0;d<this._layer.fields.length;d++)if(this._layer.fields[d].name===h){"date"===this._layer.fields[d].type&&(f=!0);break}for(let d=0;d<y.features.length;d++){if(f){const e=y.features[d].attributes[h];null!==e?l.push(new Date(e)):l.push(e)}else l.push(y.features[d].attributes[h]);if(l.length>=n)break}if(0===y.features.length)return l;if(y.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n){return{calculated:!0,result:await this._getDistinctPages(e+y.features.length,t,i,r,s,a,n,l,o)}}return l}async _distinctStat(e,t,i,r,s,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,s,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new R;if(this._requestStandardised&&(a.sqlFormat="standard"),this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===r?null===i?"1=1":"":d(r,s);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,r,s,a,n){await this._ensureLoaded();const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return u?this._countstat(e,i,r,s):{calculated:!1};if(!1===o||!1===h(t)&&!1===l||!1===t.isStandardized)return""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n);if("distinct"===e)return!1===u?""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,i,r,s,a,n);const c=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};const y=new R;this._requestStandardised&&(y.sqlFormat="standard");let f=null===s?null===r?"1=1":"":d(s,c);this._layer.definitionExpression&&this._useDefinitionExpression&&(f=""!==f?"(("+this._layer.definitionExpression+") AND ("+f+"))":this._layer.definitionExpression),y.where=f,y.spatialRelationship=this._makeRelationshipEnum(i),y.relationParameter=this._makeRelationshipParam(i),y.geometry=null===r?null:r;const _=new x;_.statisticType=p(e),_.onStatisticField=d(t,c),_.outStatisticFieldName="ARCADE_STAT_RESULT",y.returnGeometry=!1;let m="ARCADE_STAT_RESULT";y.outStatistics=[_];const g=await this.executeQuery(y,"execute");if(!g.hasOwnProperty("features")||0===g.features.length)throw new P(j.InvalidStatResponse);let S=!1;for(let d=0;d<g.fields.length;d++)if("ARCADE_STAT_RESULT"===g.fields[d].name.toUpperCase()){m=g.fields[d].name,"date"===g.fields[d].type&&(S=!0);break}if(S){let e=g.features[0].attributes[m];return null!==e&&(e=new Date(g.features[0].attributes[m])),{calculated:!0,result:e}}return{calculated:!0,result:g.features[0].attributes[m]}}_stat(e,t,i,r,s,a,n){return this._stats(e,t,i,r,s,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(i=!0),i)for(let s=0;s<t.length-1;s++)null!==t[s].workingexpr&&(!1===t[s].workingexpr.isStandardized||!1===h(t[s].workingexpr)&&!1===r)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,a,n,l){await this._ensureLoaded();const o=await this.databaseType();let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let s=0;s<t.length;s++){const e=new x;e.onStatisticField=null!==t[s].workingexpr?d(t[s].workingexpr,o):"",e.outStatisticFieldName=t[s].field,e.statisticType=t[s].toStatisticsName(),c.push(e)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===r?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===r?null:r,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,r){let s=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const a=t.pagesDefinition.internal.lastRetrieved,n=a,l=t.pagesDefinition.internal.lastPage,o=new R;if(this._requestStandardised&&(o.sqlFormat="standard"),o.where=s,o.spatialRelationship=t.pagesDefinition.spatialRel,o.relationParameter=t.pagesDefinition.relationParam,o.outFields=t.pagesDefinition.outFields,o.outStatistics=t.pagesDefinition.outStatistics,o.geometry=t.pagesDefinition.geometry,o.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,o.num=t.pagesDefinition.resultRecordCount,o.start=t.pagesDefinition.internal.lastPage,o.returnGeometry=t.pagesDefinition.returnGeometry,o.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&o.geometry&&o.spatialRelationship)return[];const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),!u.hasOwnProperty("features"))throw new P(j.InvalidStatResponse);const d=[];if(t.pagesDefinition.internal.lastPage!==l)return[];for(let e=0;e<u.features.length;e++)t.pagesDefinition.internal.set[n+e]=u.features[e].attributes[t.pagesDefinition.generatedOid];for(let h=0;h<u.features.length;h++)d.push(new e({attributes:u.features[h].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===u.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=u.features[u.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===u.exceededTransferLimit&&u.features.length!==t.pagesDefinition.resultRecordCount||!1===u.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=a+u.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,d}static create(e,t,i,r,s){const a=new m({url:e,outFields:null===t?["*"]:t});return new C({layer:a,spatialReference:i,lrucache:r,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"});const l=await this._layer.queryAttachments(n),o=[];return l&&l[e]&&l[e].forEach((t=>{const r=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let s=null;a&&t.exifInfo&&(s=q.convertJsonToArcade(t.exifInfo,!0)),o.push(new i(t.id,t.name,t.contentType,t.size,r,s))})),o}return[]}async queryRelatedFeatures(i){const r={f:"json",relationshipId:i.relationshipId.toString(),definitionExpression:i.where,outFields:i.outFields.join(","),returnGeometry:i.returnGeometry.toString()};void 0!==i.resultOffset&&null!==i.resultOffset&&(r.resultOffset=i.resultOffset.toString()),void 0!==i.resultRecordCount&&null!==i.resultRecordCount&&(r.resultRecordCount=i.resultRecordCount.toString()),i.orderByFields&&(r.orderByFields=i.orderByFields.join(",")),i.objectIds.length>0&&(r.objectIds=i.objectIds.join(",")),i.outSpatialReference&&(r.outSR=JSON.stringify(i.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:r});if(s.data){const t={},i=s.data;if(i&&i.relatedRecordGroups){const r=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const t of s.relatedRecords){t.geometry&&(t.geometry.spatialReference=r);const i=new e({geometry:t.geometry?_(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new P(j.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new R;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const r=await S(this._layer.parsedUrl.path,i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();const e=f?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=f?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let i=this._layer.url;const r=i.toLowerCase().indexOf("/rest/services");if(i=r>-1?i.substring(0,r):i,i){i+="/rest/info";try{const e=await t(i,{query:{f:"json"}});let r="";return e.data&&e.data.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch(s){return""}}return""}getDataSourceFeatureSet(){const e=new C({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{C as default};
5
+ import e from"../../../Graphic.js";import t from"../../../request.js";import i from"../../Attachment.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as c}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as h,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{fromJSON as _}from"../../../geometry/support/jsonUtils.js";import m from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as g}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as S}from"../../../rest/query/executeQueryJSON.js";import"../../../core/arrayUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import{executeQueryPBF as F}from"../../../rest/query/operations/query.js";import R from"../../../rest/support/FeatureSet.js";import b from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as w}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeForIds as D}from"../../../rest/query/executeForIds.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as I}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import x from"../../../rest/support/StatisticDefinition.js";import P from"../../Dictionary.js";import{FeatureSetError as q,FeatureSetErrorCodes as j}from"../support/errorsupport.js";class v extends r{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return h(t,y.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const i of this._layer.outFields)if(i.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new b;t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){e.quantizationParameters={mode:"edit"};const t=await F(this._layer.parsedUrl,e,new I({}));return R.fromJSON(g(t.data)).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const i="execute"===t?S:"executeForCount"===t?w:D,r="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==r?i(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries?.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==r?i(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}async _getFilteredSet(e,t,i,r,a){const n=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,a);let l="",o=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=r.constructClause(),o=!0);const u=new b;u.where=null===i?null===t?"1=1":"":d(i,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let c=await this.executeQuery(u,"executeForIds");null===c&&(c=[]),this._checkCancelled(a);return new s([],c,o,null)}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}async _getFilteredSetUsingPaging(e,t,i,r,a){let n="",l=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=r.constructClause(),l=!0);const o=await this.databaseType();let u=null===i?null===t?"1=1":"":d(i,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let c=this._maxQueryRate();const p=this._layer.capabilities?.query.maxRecordCount;void 0!==p&&p<c&&(c=p);let h=null;if(!0===this._pageJustIds)h=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:c,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const r=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);h=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:c,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(h,c,0,1,a),h}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,a=e.pagesDefinition.internal.lastPage,n=new b;this._requestStandardised&&(n.sqlFormat="standard"),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[s+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){const s=[];if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let a=0;for(let u=e._lastFetchedIndex;u<e._known.length;u++){if(e._lastFetchedIndex+=1,a++,void 0===this._featureCache[e._known[u]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[u]]){const r=t._featureMap[e._known[u]];null!==r&&(i=!0,this._featureCache[e._known[u]]=r)}}if(!1===i&&(e._known[u]!==t&&s.push(e._known[u]),s.length>=this._maxProcessingRate()-1))break}if(a>=i&&0===s.length)break}if(0===s.length)return"success";const n=new b;this._requestStandardised&&(n.sqlFormat="standard"),n.objectIds=s,n.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),n.returnGeometry=!0,!0===this._removeGeometry&&(n.returnGeometry=!1),n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(r),void 0!==l.error)throw new q(j.RequestFailed,{reason:l.error});const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return"success"}async _getDistinctPages(e,t,i,r,s,a,n,l,o){await this._ensureLoaded();const u=await this.databaseType();let c=i.parseTree.column;const p=this._layer.fields??[];for(let d=0;d<p.length;d++)if(p[d].name.toLowerCase()===c.toLowerCase()){c=p[d].name;break}const h=new b;this._requestStandardised&&(h.sqlFormat="standard");let y=null===a?null===s?"1=1":"":d(a,u);this._layer.definitionExpression&&this._useDefinitionExpression&&(y=""!==y?"(("+this._layer.definitionExpression+") AND ("+y+"))":this._layer.definitionExpression),h.where=y,h.spatialRelationship=this._makeRelationshipEnum(r),h.relationParameter=this._makeRelationshipParam(r),h.geometry=null===s?null:s,h.returnDistinctValues=!0,h.returnGeometry=!1,h.outFields=[c];const f=await this.executeQuery(h,"execute");if(this._checkCancelled(o),!f.hasOwnProperty("features"))throw new q(j.InvalidStatResponse);let _=!1;for(let d=0;d<p.length;d++)if(p[d].name===c){"date"===p[d].type&&(_=!0);break}for(let d=0;d<f.features.length;d++){if(_){const e=f.features[d].attributes[c];null!==e?l.push(new Date(e)):l.push(e)}else l.push(f.features[d].attributes[c]);if(l.length>=n)break}if(0===f.features.length)return l;if(f.features.length===this._layer.capabilities?.query.maxRecordCount&&l.length<n){return{calculated:!0,result:await this._getDistinctPages(e+f.features.length,t,i,r,s,a,n,l,o)}}return l}async _distinctStat(e,t,i,r,s,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,s,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new b;if(this._requestStandardised&&(a.sqlFormat="standard"),this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===r?null===i?"1=1":"":d(r,s);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,r,s,a,n){await this._ensureLoaded();const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return u?this._countstat(e,i,r,s):{calculated:!1};if(!1===o||!1===c(t)&&!1===l||!1===t.isStandardized)return""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n);if("distinct"===e)return!1===u?""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,i,r,s,a,n);const h=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};const y=new b;this._requestStandardised&&(y.sqlFormat="standard");let f=null===s?null===r?"1=1":"":d(s,h);this._layer.definitionExpression&&this._useDefinitionExpression&&(f=""!==f?"(("+this._layer.definitionExpression+") AND ("+f+"))":this._layer.definitionExpression),y.where=f,y.spatialRelationship=this._makeRelationshipEnum(i),y.relationParameter=this._makeRelationshipParam(i),y.geometry=null===r?null:r;const _=new x;_.statisticType=p(e),_.onStatisticField=d(t,h),_.outStatisticFieldName="ARCADE_STAT_RESULT",y.returnGeometry=!1;let m="ARCADE_STAT_RESULT";y.outStatistics=[_];const g=await this.executeQuery(y,"execute");if(!g.hasOwnProperty("features")||0===g.features.length)throw new q(j.InvalidStatResponse);let S=!1;const F=g.fields??[];for(let d=0;d<F.length;d++)if("ARCADE_STAT_RESULT"===F[d].name.toUpperCase()){m=F[d].name,"date"===F[d].type&&(S=!0);break}if(S){let e=g.features[0].attributes[m];return null!==e&&(e=new Date(g.features[0].attributes[m])),{calculated:!0,result:e}}return{calculated:!0,result:g.features[0].attributes[m]}}_stat(e,t,i,r,s,a,n){return this._stats(e,t,i,r,s,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const r=this._layer.capabilities?.query,s=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===c(t[a].workingexpr)&&!1===s)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,a,n,l){await this._ensureLoaded();const o=await this.databaseType();let u="",c=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,c=!0,u=this._layer.objectIdField);const h=[];for(let s=0;s<t.length;s++){const e=new x;e.onStatisticField=null!==t[s].workingexpr?d(t[s].workingexpr,o):"",e.outStatisticFieldName=t[s].field,e.statisticType=t[s].toStatisticsName(),h.push(e)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===r?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:c,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:h,geometry:null===r?null:r,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,r){let s=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const a=t.pagesDefinition.internal.lastRetrieved,n=a,l=t.pagesDefinition.internal.lastPage,o=new b;if(this._requestStandardised&&(o.sqlFormat="standard"),o.where=s,o.spatialRelationship=t.pagesDefinition.spatialRel,o.relationParameter=t.pagesDefinition.relationParam,o.outFields=t.pagesDefinition.outFields,o.outStatistics=t.pagesDefinition.outStatistics,o.geometry=t.pagesDefinition.geometry,o.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,o.num=t.pagesDefinition.resultRecordCount,o.start=t.pagesDefinition.internal.lastPage,o.returnGeometry=t.pagesDefinition.returnGeometry,o.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&o.geometry&&o.spatialRelationship)return[];const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),!u.hasOwnProperty("features"))throw new q(j.InvalidStatResponse);const d=[];if(t.pagesDefinition.internal.lastPage!==l)return[];for(let e=0;e<u.features.length;e++)t.pagesDefinition.internal.set[n+e]=u.features[e].attributes[t.pagesDefinition.generatedOid];for(let c=0;c<u.features.length;c++)d.push(new e({attributes:u.features[c].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===u.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=u.features[u.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===u.exceededTransferLimit&&u.features.length!==t.pagesDefinition.resultRecordCount||!1===u.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=a+u.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,d}static create(e,t,i,r,s){const a=new m({url:e,outFields:null===t?["*"]:t});return new v({layer:a,spatialReference:i,lrucache:r,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,s,a){const n=this._layer.capabilities;if(n?.data.supportsAttachment&&n?.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"});const l=await this._layer.queryAttachments(n),o=[];return l&&l[e]&&l[e].forEach((t=>{const r=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let s=null;a&&t.exifInfo&&(s=P.convertJsonToArcade(t.exifInfo,!0)),o.push(new i(t.id,t.name,t.contentType,t.size,r,s))})),o}return[]}async queryRelatedFeatures(i){const r={f:"json",relationshipId:i.relationshipId.toString(),definitionExpression:i.where,outFields:i.outFields?.join(","),returnGeometry:i.returnGeometry.toString()};void 0!==i.resultOffset&&null!==i.resultOffset&&(r.resultOffset=i.resultOffset.toString()),void 0!==i.resultRecordCount&&null!==i.resultRecordCount&&(r.resultRecordCount=i.resultRecordCount.toString()),i.orderByFields&&(r.orderByFields=i.orderByFields.join(",")),i.objectIds&&i.objectIds.length>0&&(r.objectIds=i.objectIds.join(",")),i.outSpatialReference&&(r.outSR=JSON.stringify(i.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:r});if(s.data){const t={},i=s.data;if(i&&i.relatedRecordGroups){const r=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const t of s.relatedRecords){t.geometry&&(t.geometry.spatialReference=r);const i=new e({geometry:t.geometry?_(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new q(j.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new b;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const r=await S(this._layer.parsedUrl.path,i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();const e=f?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=f?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let i=this._layer.url;const r=i.toLowerCase().indexOf("/rest/services");if(i=r>-1?i.substring(0,r):i,i){i+="/rest/info";try{const e=await t(i,{query:{f:"json"}});let r="";return e.data&&e.data.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch(s){return""}}return""}getDataSourceFeatureSet(){const e=new v({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}}export{v as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as s}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{defaultMaxRecords as a,FeatureServiceDatabaseType as l,IdState as n}from"../support/shared.js";import{toWhereClause as o}from"../support/sqlUtils.js";import u from"../../../geometry/Geometry.js";import h from"../../../layers/FeatureLayer.js";import c from"../../../layers/support/FeatureType.js";import y from"../../../layers/support/Field.js";import p from"../../../rest/support/Query.js";class d extends r{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const s of this._layer.outFields)if(s.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const s of this.fields)if("oid"===s.type)e.push(s),t.push(s.name);else for(const r of this._overrideFields)if(r.toLowerCase()===s.name.toLowerCase()){e.push(s),t.push(s.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this._databaseType=l.Standardised,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}isTable(){return this._forceIsTable||this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return n.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_changeFeature(t){const s={};for(const e of this.fields)s[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:s})}async _getFilteredSet(e,t,s,r,a){let n="",u=!1;if(null!==r&&(n=r.constructClause(),u=!0),this.isTable()&&t&&null!==e&&""!==e){return new i([],[],!0,null)}const h=new p;h.where=null===s?null===t?"1=1":"":o(s,l.Standardised),h.spatialRelationship=this._makeRelationshipEnum(e),h.outSpatialReference=this.spatialReference,h.orderByFields=""!==n?n.split(","):null,h.geometry=null===t?null:t,h.returnGeometry=!0,h.relationParameter=this._makeRelationshipParam(e);const c=await this._layer.queryFeatures(h);if(null===c)return new i([],[],u,null);this._checkCancelled(a);const y=[];c.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];y.push(t),this._featureCache[t]=this._changeFeature(e)}));return new i([],y,u,null)}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _queryAllFeatures(){if(this._wset)return this._wset;const e=new p;if(e.where="1=1",await this._ensureLoaded(),this._layer.source&&this._layer.source.items){const e=[];return this._layer.source.items.forEach((t=>{const s=t.attributes[this._layer.objectIdField];e.push(s),this._featureCache[s]=this._changeFeature(t)})),this._wset=new i([],e,!1,null),this._wset}const t=await this._layer.queryFeatures(e),s=[];return t.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];s.push(t),this._featureCache[t]=this._changeFeature(e)})),this._wset=new i([],s,!1,null),this._wset}async _getFeatures(e,r,i){const a=[];-1!==r&&void 0===this._featureCache[r]&&a.push(r);for(let t=e._lastFetchedIndex;t<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[t]]&&(e._known[t]!==r&&a.push(e._known[t]),a.length>i)));t++);if(0===a.length)return"success";throw new t(s.MissingFeatures)}async _refineSetBlock(e){return e}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!1}relationshipMetaData(){return[]}static _cloneAttr(e){const t={};for(const s in e)t[s]=e[s];return t}nativeCapabilities(){return{title:this._layer.title,canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let s=e.layerDefinition.objectIdField;const r=e.layerDefinition.typeIdField?e.layerDefinition.typeIdField:"",i=[];if(e.layerDefinition.types)for(const u of e.layerDefinition.types)i.push(c.fromJSON(u));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let l=e.featureSet.features;const n=t.toJSON();if(""===s||void 0===s){let t=!1;for(const r of e.layerDefinition.fields)if("oid"===r.type||"esriFieldTypeOID"===r.type){s=r.name,t=!0;break}if(!1===t){let t="FID",r=!0,i=0;for(;r;){let s=!0;for(const r of e.layerDefinition.fields)if(r.name===t){s=!1;break}!0===s?r=!1:(i++,t="FID"+i.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const a=[];for(let s=0;s<l.length;s++)a.push({geometry:e.featureSet.features[s].geometry,attributes:e.featureSet.features[s].attributes?this._cloneAttr(e.featureSet.features[s].attributes):{}}),a[s].attributes[t]=s;l=a,s=t}}const o=[];for(const u of e.layerDefinition.fields)u instanceof y?o.push(u):o.push(y.fromJSON(u));let p=a;switch(p){case"esriGeometryPoint":p="point";break;case"esriGeometryPolyline":p="polyline";break;case"esriGeometryPolygon":p="polygon";break;case"esriGeometryExtent":p="extent";break;case"esriGeometryMultipoint":p="multipoint"}for(const h of l)h.geometry&&h.geometry instanceof u==!1&&(h.geometry.type=p,void 0===h.geometry.spatialReference&&(h.geometry.spatialReference=n));const f={outFields:["*"],source:l,fields:o,types:i,typeIdField:r,objectIdField:s,spatialReference:t};f.geometryType=p||"point";const _=new h(f);return new d({layer:_,spatialReference:t,isTable:null===p||""===p})}async queryAttachments(){return[]}async getFeatureByObjectId(e){const t=new p;t.where=this.objectIdField+"="+e.toString();const s=await this._layer.queryFeatures(t);return 1===s.features.length?s.features[0]:null}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}}export{d as default};
5
+ import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as s}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{defaultMaxRecords as a,FeatureServiceDatabaseType as l,IdState as n}from"../support/shared.js";import{toWhereClause as o}from"../support/sqlUtils.js";import u from"../../../geometry/Geometry.js";import h from"../../../layers/FeatureLayer.js";import c from"../../../layers/support/FeatureType.js";import y from"../../../layers/support/Field.js";import p from"../../../rest/support/Query.js";class d extends r{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const s of this._layer.outFields)if(s.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const s of this.fields)if("oid"===s.type)e.push(s),t.push(s.name);else for(const r of this._overrideFields)if(r.toLowerCase()===s.name.toLowerCase()){e.push(s),t.push(s.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this._databaseType=l.Standardised,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}isTable(){return this._forceIsTable||this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return n.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_changeFeature(t){const s={};for(const e of this.fields)s[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:s})}async _getFilteredSet(e,t,s,r,a){let n="",u=!1;if(null!==r&&(n=r.constructClause(),u=!0),this.isTable()&&t&&null!==e&&""!==e){return new i([],[],!0,null)}const h=new p;h.where=null===s?null===t?"1=1":"":o(s,l.Standardised),h.spatialRelationship=this._makeRelationshipEnum(e),h.outSpatialReference=this.spatialReference,h.orderByFields=""!==n?n.split(","):null,h.geometry=null===t?null:t,h.returnGeometry=!0,h.relationParameter=this._makeRelationshipParam(e);const c=await this._layer.queryFeatures(h);if(null===c)return new i([],[],u,null);this._checkCancelled(a);const y=[];c.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];y.push(t),this._featureCache[t]=this._changeFeature(e)}));return new i([],y,u,null)}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _queryAllFeatures(){if(this._wset)return this._wset;const e=new p;if(e.where="1=1",await this._ensureLoaded(),this._layer.source&&this._layer.source.items){const e=[];return this._layer.source.items.forEach((t=>{const s=t.attributes[this._layer.objectIdField];e.push(s),this._featureCache[s]=this._changeFeature(t)})),this._wset=new i([],e,!1,null),this._wset}const t=await this._layer.queryFeatures(e),s=[];return t.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];s.push(t),this._featureCache[t]=this._changeFeature(e)})),this._wset=new i([],s,!1,null),this._wset}async _getFeatures(e,r,i){const a=[];-1!==r&&void 0===this._featureCache[r]&&a.push(r);for(let t=e._lastFetchedIndex;t<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[t]]&&(e._known[t]!==r&&a.push(e._known[t]),a.length>i)));t++);if(0===a.length)return"success";throw new t(s.MissingFeatures)}async _refineSetBlock(e){return e}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!1}relationshipMetaData(){return[]}static _cloneAttr(e){const t={};for(const s in e)t[s]=e[s];return t}nativeCapabilities(){return{title:this._layer.title??"",canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let s=e.layerDefinition.objectIdField;const r=e.layerDefinition.typeIdField?e.layerDefinition.typeIdField:"",i=[];if(e.layerDefinition.types)for(const u of e.layerDefinition.types)i.push(c.fromJSON(u));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let l=e.featureSet.features;const n=t.toJSON();if(""===s||void 0===s){let t=!1;for(const r of e.layerDefinition.fields)if("oid"===r.type||"esriFieldTypeOID"===r.type){s=r.name,t=!0;break}if(!1===t){let t="FID",r=!0,i=0;for(;r;){let s=!0;for(const r of e.layerDefinition.fields)if(r.name===t){s=!1;break}!0===s?r=!1:(i++,t="FID"+i.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const a=[];for(let s=0;s<l.length;s++)a.push({geometry:e.featureSet.features[s].geometry,attributes:e.featureSet.features[s].attributes?this._cloneAttr(e.featureSet.features[s].attributes):{}}),a[s].attributes[t]=s;l=a,s=t}}const o=[];for(const u of e.layerDefinition.fields)u instanceof y?o.push(u):o.push(y.fromJSON(u));let p=a;switch(p){case"esriGeometryPoint":p="point";break;case"esriGeometryPolyline":p="polyline";break;case"esriGeometryPolygon":p="polygon";break;case"esriGeometryExtent":p="extent";break;case"esriGeometryMultipoint":p="multipoint"}for(const h of l)h.geometry&&h.geometry instanceof u==!1&&(h.geometry.type=p,void 0===h.geometry.spatialReference&&(h.geometry.spatialReference=n));const f={outFields:["*"],source:l,fields:o,types:i,typeIdField:r,objectIdField:s,spatialReference:t};f.geometryType=p||"point";const _=new h(f);return new d({layer:_,spatialReference:t,isTable:null===p||""===p})}async queryAttachments(){return[]}async getFeatureByObjectId(e){const t=new p;t.where=this.objectIdField+"="+e.toString();const s=await this._layer.queryFeatures(t);return 1===s.features.length?s.features[0]:null}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}}export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,IdState as n}from"../support/shared.js";import l from"../../../rest/support/RelationshipQuery.js";class d extends r{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,this._relatedLayer=null,this.relationship=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(0),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types}async databaseType(){return await this._relatedLayer.databaseType(),this._databaseType=this._relatedLayer._databaseType,this._databaseType}isTable(){return this._relatedLayer.isTable()}_isInFeatureSet(){return n.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_changeFeature(t){const i={};for(const e of this.fields)i[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:i})}async _getFilteredSet(e,t,i,r,a){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated){return new s([],[],!0,null)}if(n.capabilities.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,i,r,a);let d="",o=!1;null!==r&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(d=r.constructClause(),o=!0);const u=new l;u.objectIds=[this._findObjectId];const h=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);u.outFields=h,u.relationshipId=this.relationship.id,u.where="1=1";let c=!0;!0===this._removeGeometry&&(c=!1),u.returnGeometry=c,this._requestStandardised&&(u.sqlFormat="standard"),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==d?d.split(","):null;const y=await n.source.queryRelatedFeatures(u);this._checkCancelled(a);const p=y[this._findObjectId]?y[this._findObjectId].features:[],_=[];for(let s=0;s<p.length;s++)this._featureCache[p[s].attributes[this._relatedLayer.objectIdField]]=p[s],_.push(p[s].attributes[this._relatedLayer.objectIdField]);const f=t&&null!==e&&""!==e,g=null!=i;return new s(f||g?_:[],f||g?[]:_,o,null)}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFilteredSetUsingPaging(e,t,i,r,a){let n="",l=!1;const d=this._layer.nativeCapabilities();null!==r&&d&&d.capabilities.queryRelated&&!0===d.capabilities.queryRelated.supportsOrderBy&&(n=r.constructClause(),l=!0),await this.databaseType();const o="1=1";let u=this._maxQueryRate();const h=d.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);const c=t&&null!==e&&""!==e,y=null!=i;let p=null,_=!0;!0===this._removeGeometry&&(_=!1);const f=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);return p=new s(c||y?["GETPAGES"]:[],c||y?[]:["GETPAGES"],l,{outFields:f.join(","),resultRecordCount:u,resultOffset:0,objectIds:[this._findObjectId],where:o,orderByFields:n,returnGeometry:_,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(p,u,0,0,a),p}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,a=e.pagesDefinition.internal.lastPage,n=this._layer.nativeCapabilities(),d=new l;!0===this._requestStandardised&&(d.sqlFormat="standard"),d.relationshipId=this.relationship.id,d.objectIds=e.pagesDefinition.objectIds,d.resultOffset=e.pagesDefinition.internal.lastPage,d.resultRecordCount=e.pagesDefinition.resultRecordCount,d.outFields=e.pagesDefinition.outFields.split(","),d.where=e.pagesDefinition.where,d.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,d.returnGeometry=e.pagesDefinition.returnGeometry,d.outSpatialReference=this.spatialReference;const o=await n.source.queryRelatedFeatures(d);if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return 0;const u=o[this._findObjectId]?o[this._findObjectId].features:[];for(let l=0;l<u.length;l++)e.pagesDefinition.internal.set[s+l]=u[l].attributes[this._relatedLayer.objectIdField];for(let l=0;l<u.length;l++)this._featureCache[u[l].attributes[this._relatedLayer.objectIdField]]=u[l];const h=!o[this._findObjectId]||!1===o[this._findObjectId].exceededTransferLimit;return u.length!==e.pagesDefinition.resultRecordCount&&h&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,r,s,a){const n=[];-1!==r&&void 0===this._featureCache[r]&&n.push(r);const l=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,l))return await this._expandPagedSet(e,l,0,0,a),this._getFeatures(e,r,s,a);let d=0;for(let t=e._lastFetchedIndex;t<e._known.length&&(d++,d<=s&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[t]&&void 0===this._featureCache[e._known[t]]&&(e._known[t]!==r&&n.push(e._known[t]),n.length>s)))&&!(d>=s&&0===n.length);t++);if(0===n.length)return"success";throw new t(i.MissingFeatures)}async _refineSetBlock(e,t,i){return e}async _stat(e,t,i,r,s,a,n){return{calculated:!1}}get gdbVersion(){return this._relatedLayer.gdbVersion}async _canDoAggregates(e,t,i,r,s){return!1}relationshipMetaData(){return this._relatedLayer.relationshipMetaData()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,i,r,s){return this._relatedLayer.queryAttachments(e,t,i,r,s)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}}export{d as default};
5
+ import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,IdState as n}from"../support/shared.js";import l from"../../../rest/support/RelationshipQuery.js";class d extends r{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer?.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(0),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types}async databaseType(){return await this._relatedLayer.databaseType(),this._databaseType=this._relatedLayer._databaseType,this._databaseType}isTable(){return this._relatedLayer.isTable()}_isInFeatureSet(){return n.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_changeFeature(t){const i={};for(const e of this.fields)i[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:i})}async _getFilteredSet(e,t,i,r,a){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated){return new s([],[],!0,null)}if(n.capabilities?.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,i,r,a);let d="",o=!1;null!==r&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(d=r.constructClause(),o=!0);const u=new l;u.objectIds=[this._findObjectId];const h=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);u.outFields=h,u.relationshipId=this.relationship.id,u.where="1=1";let c=!0;!0===this._removeGeometry&&(c=!1),u.returnGeometry=c,this._requestStandardised&&(u.sqlFormat="standard"),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==d?d.split(","):null;const y=await n.source.queryRelatedFeatures(u);this._checkCancelled(a);const p=y[this._findObjectId]?y[this._findObjectId].features:[],_=[];for(let s=0;s<p.length;s++)this._featureCache[p[s].attributes[this._relatedLayer.objectIdField]]=p[s],_.push(p[s].attributes[this._relatedLayer.objectIdField]);const f=t&&null!==e&&""!==e,g=null!=i;return new s(f||g?_:[],f||g?[]:_,o,null)}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFilteredSetUsingPaging(e,t,i,r,a){let n="",l=!1;const d=this._layer.nativeCapabilities();null!==r&&d&&d.capabilities?.queryRelated&&!0===d.capabilities.queryRelated.supportsOrderBy&&(n=r.constructClause(),l=!0),await this.databaseType();const o="1=1";let u=this._maxQueryRate();const h=d.capabilities?.query.maxRecordCount;void 0!==h&&h<u&&(u=h);const c=t&&null!==e&&""!==e,y=null!=i;let p=null,_=!0;!0===this._removeGeometry&&(_=!1);const f=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);return p=new s(c||y?["GETPAGES"]:[],c||y?[]:["GETPAGES"],l,{outFields:f.join(","),resultRecordCount:u,resultOffset:0,objectIds:[this._findObjectId],where:o,orderByFields:n,returnGeometry:_,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(p,u,0,0,a),p}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,a=e.pagesDefinition.internal.lastPage,n=this._layer.nativeCapabilities(),d=new l;!0===this._requestStandardised&&(d.sqlFormat="standard"),d.relationshipId=this.relationship.id,d.objectIds=e.pagesDefinition.objectIds,d.resultOffset=e.pagesDefinition.internal.lastPage,d.resultRecordCount=e.pagesDefinition.resultRecordCount,d.outFields=e.pagesDefinition.outFields.split(","),d.where=e.pagesDefinition.where,d.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,d.returnGeometry=e.pagesDefinition.returnGeometry,d.outSpatialReference=this.spatialReference;const o=await n.source.queryRelatedFeatures(d);if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return 0;const u=o[this._findObjectId]?o[this._findObjectId].features:[];for(let l=0;l<u.length;l++)e.pagesDefinition.internal.set[s+l]=u[l].attributes[this._relatedLayer.objectIdField];for(let l=0;l<u.length;l++)this._featureCache[u[l].attributes[this._relatedLayer.objectIdField]]=u[l];const h=!o[this._findObjectId]||!1===o[this._findObjectId].exceededTransferLimit;return u.length!==e.pagesDefinition.resultRecordCount&&h&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,r,s,a){const n=[];-1!==r&&void 0===this._featureCache[r]&&n.push(r);const l=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,l))return await this._expandPagedSet(e,l,0,0,a),this._getFeatures(e,r,s,a);let d=0;for(let t=e._lastFetchedIndex;t<e._known.length&&(d++,d<=s&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[t]&&void 0===this._featureCache[e._known[t]]&&(e._known[t]!==r&&n.push(e._known[t]),n.length>s)))&&!(d>=s&&0===n.length);t++);if(0===n.length)return"success";throw new t(i.MissingFeatures)}async _refineSetBlock(e,t,i){return e}async _stat(e,t,i,r,s,a,n){return{calculated:!1}}get gdbVersion(){return this._relatedLayer.gdbVersion}async _canDoAggregates(e,t,i,r,s){return!1}relationshipMetaData(){return this._relatedLayer.relationshipMetaData()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,i,r,s){return this._relatedLayer.queryAttachments(e,t,i,r,s)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}}export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"./cache.js";import{FeatureSetError as t,FeatureSetErrorCodes as s}from"./errorsupport.js";import a from"./FeatureSetIterator.js";import r from"./IdSet.js";import{FeatureServiceDatabaseType as n,layerGeometryEsriConstants as i,IdState as l,convertSquareUnitsToCode as u,convertLinearUnitsToCode as h,esriFieldToJson as c,layerGeometryEsriRestConstants as o}from"./shared.js";import{max as d,min as _,sum as p,variance as f,stdev as g,mean as y,distinct as m,count as b}from"./stats.js";import{isPromiseLike as F}from"../../../core/promiseUtils.js";import{WhereClause as w}from"../../../core/sql/WhereClause.js";import{union as S,geodesicArea as I,planarArea as T,geodesicLength as P,planarLength as D}from"../../../geometry/geometryEngineAsync.js";import k from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/FieldsIndex.js";class C{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=n.NotEvaluated,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=[],this.types=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,e&&e.lrucache&&(this.recentlyUsedQueries=e.lrucache),e&&e.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent.loaded?(this._initialiseFeatureSet(),this):(await this._parent.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new k({wkid:4326}),this.geometryType=i.point)}getField(e,t){let s;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some((t=>(t&&t.name.toLowerCase()===e&&(s=t),!!s)))),s}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=new x(this.fields)),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!==e&&e.aborted)throw new t(s.Cancelled)}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,s,a,r){return null!==this._parent&&this._parent._canDoAggregates(e,t,s,a,r)}async _getAggregatePagesDataSourceDefinition(e,a,r,n,i,l,u){if(null===this._parent)throw new t(s.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,a,r,n,i,l,u)}async _getAgregagtePhysicalPage(e,a,r){if(null===this._parent)throw new t(s.NeverReach);return this._parent._getAgregagtePhysicalPage(e,a,r)}async databaseType(){if(this._databaseType===n.NotEvaluated){if(null!==e.applicationCache){const t=e.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==t)return t}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==e.applicationCache&&e.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(t){throw null!==e.applicationCache&&e.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),t}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:n.SqlServer,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:n.Oracle,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:n.StandardisedNoInterval,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return n.StandardisedNoInterval}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new t(s.NotImplemented)}isTable(){return this._parent.isTable()}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return l.Unknown}_getSet(e){throw new t(s.NotImplemented)}async _getFeature(e,a,r){if(this._checkCancelled(r),void 0!==this._featureFromCache(a))return this._featureFromCache(a);if(await this._getFeatures(e,a,this._maxProcessingRate(),r),this._checkCancelled(r),void 0!==this._featureFromCache(a))return this._featureFromCache(a);throw new t(s.MissingFeatures)}async _getFeatureBatch(e,t){this._checkCancelled(t);const s=new r([],e,!1,null),a=[];await this._getFeatures(s,-1,e.length,t),this._checkCancelled(t);for(const r of e)void 0!==this._featureFromCache(r)&&a.push(this._featureFromCache(r));return a}async _getFeatures(e,t,s,a){return"success"}_getFilteredSet(e,a,r,n,i){throw new t(s.NotImplemented)}async _refineSetBlock(e,t,s){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,s),this._refineSetBlock(e,t,s);this._checkCancelled(s);const a=e._candidates.length;this._refineKnowns(e,t);let r=a-e._candidates.length;if(0===e._candidates.length)return e;if(r>=t)return e;if(await this._refineIfParentKnown(e,t-r,s),this._checkCancelled(s),this._refineKnowns(e,t-r),r=a-e._candidates.length,r<t&&e._candidates.length>0){const a=t-r,n=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(n,n.length>a?a:e._candidates.length,s),this._checkCancelled(s),this._refineKnowns(e,t-r),e}return e}_fetchAndRefineFeatures(e,t,s){return null}_prepareFetchAndRefineSet(e){const t=[];for(let s=0;s<e.length;s++)this._isPhysicalFeature(e[s])&&t.push(e[s]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let s=0,a=null;const r=[];t=this._maxQueryRate();for(let n=0;n<e._candidates.length&&"GETPAGES"!==e._candidates[n];n++){let i=!1;const u=this._candidateIdTransform(e._candidates[n]);u!==e._candidates[n]&&(i=!0);const h=this._isInFeatureSet(u);if(h===l.InFeatureSet)!0===i?e._known.includes(u)||(e._known.push(u),s+=1):(e._known.push(e._candidates[n]),s+=1),null===a?a={start:n,end:n}:a.end===n-1?a.end=n:(r.push(a),a={start:n,end:n});else if(h===l.NotInFeatureSet)null===a?a={start:n,end:n}:a.end===n-1?a.end=n:(r.push(a),a={start:n,end:n}),s+=1;else if(h===l.Unknown&&(s+=1,!0===e._ordered))break;if(s>=t)break}null!==a&&r.push(a);for(let n=r.length-1;n>=0;n--)e._candidates.splice(r[n].start,r[n].end-r[n].start+1)}_refineIfParentKnown(e,t,s){const a=new r([],[],e._ordered,null);return a._candidates=e._candidates.slice(0),this._parent._refineSetBlock(a,t,s)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let a=e._lastFetchedIndex;a<e._known.length;a++){if("GETPAGES"===e._known[a])return!0;if(void 0===this._featureCache[e._known[a]]&&(s+=1,s>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let a=0;a<e._candidates.length;a++){if("GETPAGES"===e._candidates[a])return!0;if(s+=1,s>=t)break}return!1}async _expandPagedSet(e,a,r,n,i){if(null===this._parent)throw new t(s.NotImplemented);return this._parent._expandPagedSet(e,a,r,n,i)}async _expandPagedSetFeatureSet(e,t,s,a,r){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(a=1),0===a&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(a=2),0===a)return"finished";const n=await this._getPage(e,a,r);return s+n<t?this._expandPagedSet(e,t,s+n,0,r):"success"}async _getPage(e,t,s){const a=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){a.length=a.length-1;let t=0;for(let r=0;r<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+r>=e.pagesDefinition.internal.set.length);r++)a[a.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+r],t++;e.pagesDefinition.resultOffset+=t;let s=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(s=!0),!1===s&&a.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,s),this._getPage(e,t,s)}_getPhysicalPage(e,t,s){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,s,a){await this._ensureLoaded();let r=await this._stat(e,t,"",null,null,s,a);return!1===r.calculated&&(r=await this._manualStat(e,t,s,a)),r.result}async _manualStat(e,t,s,a){let r=null;switch(e.toLowerCase()){case"count":return r=await b(this,a),{calculated:!0,result:r};case"distinct":return r=await m(this,t,s,a),{calculated:!0,result:r};case"avg":case"mean":return r=await y(this,t,a),{calculated:!0,result:r};case"stdev":return r=await g(this,t,a),{calculated:!0,result:r};case"variance":return r=await f(this,t,a),{calculated:!0,result:r};case"sum":return r=await p(this,t,a),{calculated:!0,result:r};case"min":return r=await _(this,t,a),{calculated:!0,result:r};case"max":return r=await d(this,t,a),{calculated:!0,result:r};default:return{calculated:!0,result:0}}}async _stat(e,t,s,a,r,n,i){const l=await this._parent._stat(e,t,s,a,r,n,i);return!1===l.calculated?null===r&&""===s&&null===a?this._manualStat(e,t,n,i):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),s=[];return new Promise(((e,a)=>{this._unionShapeInBatches(s,t,e,a)}))}_unionAllGeom(e){return new Promise(((t,s)=>{const a=this.iterator(this._defaultTracker(e)),r=[];this._unionShapeInBatches(r,a,t,s)}))}_unionShapeInBatches(e,t,s,a){t.next().then((r=>{try{null!==r&&null!==r.geometry&&e.push(r.geometry),e.length>30||null===r&&e.length>1?S(e).then((n=>{try{null===r?s(n):(e=[n],this._unionShapeInBatches(e,t,s,a))}catch(i){a(i)}}),a):null===r?1===e.length?s(e[0]):s(null):this._unionShapeInBatches(e,t,s,a)}catch(n){a(n)}}),a)}iterator(e){return new a(this,e)}intersection(e,t=!1){return C._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,s=!0){return C._featuresetFunctions.difference.bind(this)(e,t,s)}symmetricDifference(e,t=!1,s=!0){return C._featuresetFunctions.symmetricDifference.bind(this)(e,t,s)}morphShape(e,t,s="unknown",a=null){return C._featuresetFunctions.morphShape.bind(this)(e,t,s,a)}morphShapeAndAttributes(e,t,s="unknown"){return C._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,s)}union(e,t=!1){return C._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return C._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return C._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return C._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return C._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return C._featuresetFunctions.relate.bind(this)(e,t)}within(e){return C._featuresetFunctions.within.bind(this)(e)}touches(e){return C._featuresetFunctions.touches.bind(this)(e)}top(e){return C._featuresetFunctions.top.bind(this)(e)}crosses(e){return C._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,s,a=!0){return C._featuresetFunctions.buffer.bind(this)(e,t,s,a)}filter(e,t=null){return C._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return C._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return C._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return C._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,s){return new Promise(((a,r)=>{this._reduceImpl(this.iterator(this._defaultTracker(s)),e,t,0,a,r,0)}))}_reduceImpl(e,t,s,a,r,n,i){try{if(++i>1e3)return void setTimeout((()=>{i=0,this._reduceImpl(e,t,s,a,r,n,i)}));e.next().then((l=>{try{if(null===l)r(s);else{const u=t(s,l,a,this);F(u)?u.then((s=>{this._reduceImpl(e,t,s,a+1,r,n,i)}),n):this._reduceImpl(e,t,u,a+1,r,n,i)}}catch(u){n(u)}}),n)}catch(l){n(l)}}removeField(e){return C._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,s=null){return C._featuresetFunctions.addField.bind(this)(e,t,s)}sumArea(e,t=!1,s){const a=u(e);return this.reduce(((e,s)=>null===s.geometry?0:t?I(s.geometry,a).then((t=>e+t)):T(s.geometry,a).then((t=>e+t))),0,s)}sumLength(e,t=!1,s){const a=h(e);return this.reduce(((e,s)=>null===s.geometry?0:t?P(s.geometry,a).then((t=>e+t)):D(s.geometry,a).then((t=>e+t))),0,s)}_substituteVars(e,t){if(null!==t){const s={};for(const e in t)s[e.toLowerCase()]=t[e];e.parameters=s}}async distinct(e,t=1e3,s=null,a){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,s),this.calculateStatistic("distinct",r,t,this._defaultTracker(a))}async min(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("min",a,-1,this._defaultTracker(s))}async max(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("max",a,-1,this._defaultTracker(s))}async avg(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("avg",a,-1,this._defaultTracker(s))}async sum(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("sum",a,-1,this._defaultTracker(s))}async stdev(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("stdev",a,-1,this._defaultTracker(s))}async variance(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("variance",a,-1,this._defaultTracker(s))}async count(e){return await this.load(),this.calculateStatistic("count",w.create("1",this.getFieldsIndex()),-1,this._defaultTracker(e))}_defaultTracker(e){return e||{aborted:!1}}forEach(e,t){return new Promise(((s,a)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,s,a,0)}))}_forEachImpl(e,t,s,a,r,n){try{if(++n>1e3)return void setTimeout((()=>{n=0,this._forEachImpl(e,t,s,a,r,n)}),0);e.next().then((i=>{try{if(null===i)a(s);else{const l=t(i);null==l?this._forEachImpl(e,t,s,a,r,n):F(l)?l.then((()=>{try{this._forEachImpl(e,t,s,a,r,n)}catch(i){r(i)}}),r):this._forEachImpl(e,t,s,a,r,n)}}catch(l){r(l)}}),r)}catch(i){r(i)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let s=0;s<this.fields.length;s++)t.layerDefinition.fields.push(c(this.fields[s]));return this.reduce(((e,s)=>{const a={geometry:s.geometry&&s.geometry.toJSON(),attributes:{}};for(const t in s.attributes)a.attributes[t]=s.attributes[t];return t.featureSet.features.push(a),1}),0,e).then((()=>t))}castToText(){return"object, FeatureSet"}queryAttachments(e,t,s,a,r){return this._parent.queryAttachments(e,t,s,a,r)}serviceUrl(){return this._parent.serviceUrl()}subtypes(){return this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map((e=>({name:e.name,code:e.id}))):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(c(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===o[this.geometryType]?"":o[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce(((t,s)=>{const a={geometry:s.geometry?s.geometry.toJSON():null,attributes:s.attributes};return null!==a.geometry&&a.geometry.spatialReference&&delete a.geometry.spatialReference,e.push(a),1}),0,t);const s=this.schema();return s.features=e,s.spatialReference=this.spatialReference.toJSON(),JSON.stringify(s)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const s=[];await this.reduce(((e,a)=>{const r={geometry:a.geometry?!0===t?.keepGeometryType?a.geometry:a.geometry.toJSON():null,attributes:a.attributes};return null!==r.geometry&&r.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete r.geometry.spatialReference,s.push(r),1}),0,e);const a=this.schema();return a.features=s,a.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference.toJSON(),a}}C._featuresetFunctions={};export{C as default};
5
+ import e from"./cache.js";import{FeatureSetError as t,FeatureSetErrorCodes as s}from"./errorsupport.js";import a from"./FeatureSetIterator.js";import r from"./IdSet.js";import{FeatureServiceDatabaseType as n,layerGeometryEsriConstants as i,IdState as l,convertSquareUnitsToCode as u,convertLinearUnitsToCode as h,esriFieldToJson as c,layerGeometryEsriRestConstants as o}from"./shared.js";import{max as d,min as _,sum as p,variance as f,stdev as g,mean as y,distinct as m,count as b}from"./stats.js";import{isPromiseLike as F}from"../../../core/promiseUtils.js";import{WhereClause as w}from"../../../core/sql/WhereClause.js";import{union as S,geodesicArea as I,planarArea as T,geodesicLength as P,planarLength as D}from"../../../geometry/geometryEngineAsync.js";import k from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/FieldsIndex.js";class C{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=n.NotEvaluated,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=[],this.typeIdField=null,this.types=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,e&&e.lrucache&&(this.recentlyUsedQueries=e.lrucache),e&&e.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new k({wkid:4326}),this.geometryType=i.point)}getField(e,t){let s;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some((t=>(t&&t.name.toLowerCase()===e&&(s=t),!!s)))),s}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=new x(this.fields)),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new t(s.Cancelled)}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,s,a,r){return null!==this._parent&&this._parent._canDoAggregates(e,t,s,a,r)}async _getAggregatePagesDataSourceDefinition(e,a,r,n,i,l,u){if(null===this._parent)throw new t(s.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,a,r,n,i,l,u)}async _getAgregagtePhysicalPage(e,a,r){if(null===this._parent)throw new t(s.NeverReach);return this._parent._getAgregagtePhysicalPage(e,a,r)}async databaseType(){if(this._databaseType===n.NotEvaluated){if(null!==e.applicationCache){const t=e.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==t)return t}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==e.applicationCache&&e.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(t){throw null!==e.applicationCache&&e.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),t}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:n.SqlServer,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:n.Oracle,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:n.StandardisedNoInterval,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return n.StandardisedNoInterval}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new t(s.NotImplemented)}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return l.Unknown}_getSet(e){throw new t(s.NotImplemented)}async _getFeature(e,a,r){if(this._checkCancelled(r),void 0!==this._featureFromCache(a))return this._featureFromCache(a);if(await this._getFeatures(e,a,this._maxProcessingRate(),r),this._checkCancelled(r),void 0!==this._featureFromCache(a))return this._featureFromCache(a);throw new t(s.MissingFeatures)}async _getFeatureBatch(e,t){this._checkCancelled(t);const s=new r([],e,!1,null),a=[];await this._getFeatures(s,-1,e.length,t),this._checkCancelled(t);for(const r of e)void 0!==this._featureFromCache(r)&&a.push(this._featureFromCache(r));return a}async _getFeatures(e,t,s,a){return"success"}_getFilteredSet(e,a,r,n,i){throw new t(s.NotImplemented)}async _refineSetBlock(e,t,s){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,s),this._refineSetBlock(e,t,s);this._checkCancelled(s);const a=e._candidates.length;this._refineKnowns(e,t);let r=a-e._candidates.length;if(0===e._candidates.length)return e;if(r>=t)return e;if(await this._refineIfParentKnown(e,t-r,s),this._checkCancelled(s),this._refineKnowns(e,t-r),r=a-e._candidates.length,r<t&&e._candidates.length>0){const a=t-r,n=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(n,n.length>a?a:e._candidates.length,s),this._checkCancelled(s),this._refineKnowns(e,t-r),e}return e}_fetchAndRefineFeatures(e,t,s){return null}_prepareFetchAndRefineSet(e){const t=[];for(let s=0;s<e.length;s++)this._isPhysicalFeature(e[s])&&t.push(e[s]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let s=0,a=null;const r=[];t=this._maxQueryRate();for(let n=0;n<e._candidates.length&&"GETPAGES"!==e._candidates[n];n++){let i=!1;const u=this._candidateIdTransform(e._candidates[n]);u!==e._candidates[n]&&(i=!0);const h=this._isInFeatureSet(u);if(h===l.InFeatureSet)!0===i?e._known.includes(u)||(e._known.push(u),s+=1):(e._known.push(e._candidates[n]),s+=1),null===a?a={start:n,end:n}:a.end===n-1?a.end=n:(r.push(a),a={start:n,end:n});else if(h===l.NotInFeatureSet)null===a?a={start:n,end:n}:a.end===n-1?a.end=n:(r.push(a),a={start:n,end:n}),s+=1;else if(h===l.Unknown&&(s+=1,!0===e._ordered))break;if(s>=t)break}null!==a&&r.push(a);for(let n=r.length-1;n>=0;n--)e._candidates.splice(r[n].start,r[n].end-r[n].start+1)}_refineIfParentKnown(e,t,s){const a=new r([],[],e._ordered,null);return a._candidates=e._candidates.slice(0),this._parent._refineSetBlock(a,t,s)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let a=e._lastFetchedIndex;a<e._known.length;a++){if("GETPAGES"===e._known[a])return!0;if(void 0===this._featureCache[e._known[a]]&&(s+=1,s>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let a=0;a<e._candidates.length;a++){if("GETPAGES"===e._candidates[a])return!0;if(s+=1,s>=t)break}return!1}async _expandPagedSet(e,a,r,n,i){if(null===this._parent)throw new t(s.NotImplemented);return this._parent._expandPagedSet(e,a,r,n,i)}async _expandPagedSetFeatureSet(e,t,s,a,r){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(a=1),0===a&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(a=2),0===a)return"finished";const n=await this._getPage(e,a,r);return s+n<t?this._expandPagedSet(e,t,s+n,0,r):"success"}async _getPage(e,t,s){const a=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){a.length=a.length-1;let t=0;for(let r=0;r<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+r>=e.pagesDefinition.internal.set.length);r++)a[a.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+r],t++;e.pagesDefinition.resultOffset+=t;let s=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(s=!0),!1===s&&a.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,s),this._getPage(e,t,s)}_getPhysicalPage(e,t,s){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,s,a){await this._ensureLoaded();let r=await this._stat(e,t,"",null,null,s,a);return!1===r.calculated&&(r=await this._manualStat(e,t,s,a)),r.result}async _manualStat(e,t,s,a){let r=null;switch(e.toLowerCase()){case"count":return r=await b(this,a),{calculated:!0,result:r};case"distinct":return r=await m(this,t,s,a),{calculated:!0,result:r};case"avg":case"mean":return r=await y(this,t,a),{calculated:!0,result:r};case"stdev":return r=await g(this,t,a),{calculated:!0,result:r};case"variance":return r=await f(this,t,a),{calculated:!0,result:r};case"sum":return r=await p(this,t,a),{calculated:!0,result:r};case"min":return r=await _(this,t,a),{calculated:!0,result:r};case"max":return r=await d(this,t,a),{calculated:!0,result:r};default:return{calculated:!0,result:0}}}async _stat(e,t,s,a,r,n,i){const l=await this._parent._stat(e,t,s,a,r,n,i);return!1===l.calculated?null===r&&""===s&&null===a?this._manualStat(e,t,n,i):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),s=[];return new Promise(((e,a)=>{this._unionShapeInBatches(s,t,e,a)}))}_unionAllGeom(e){return new Promise(((t,s)=>{const a=this.iterator(this._defaultTracker(e)),r=[];this._unionShapeInBatches(r,a,t,s)}))}_unionShapeInBatches(e,t,s,a){t.next().then((r=>{try{null!==r&&null!==r.geometry&&e.push(r.geometry),e.length>30||null===r&&e.length>1?S(e).then((n=>{try{null===r?s(n):(e=[n],this._unionShapeInBatches(e,t,s,a))}catch(i){a(i)}}),a):null===r?1===e.length?s(e[0]):s(null):this._unionShapeInBatches(e,t,s,a)}catch(n){a(n)}}),a)}iterator(e){return new a(this,e)}intersection(e,t=!1){return C._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,s=!0){return C._featuresetFunctions.difference.bind(this)(e,t,s)}symmetricDifference(e,t=!1,s=!0){return C._featuresetFunctions.symmetricDifference.bind(this)(e,t,s)}morphShape(e,t,s="unknown",a=null){return C._featuresetFunctions.morphShape.bind(this)(e,t,s,a)}morphShapeAndAttributes(e,t,s="unknown"){return C._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,s)}union(e,t=!1){return C._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return C._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return C._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return C._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return C._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return C._featuresetFunctions.relate.bind(this)(e,t)}within(e){return C._featuresetFunctions.within.bind(this)(e)}touches(e){return C._featuresetFunctions.touches.bind(this)(e)}top(e){return C._featuresetFunctions.top.bind(this)(e)}crosses(e){return C._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,s,a=!0){return C._featuresetFunctions.buffer.bind(this)(e,t,s,a)}filter(e,t=null){return C._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return C._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return C._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return C._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,s){return new Promise(((a,r)=>{this._reduceImpl(this.iterator(this._defaultTracker(s)),e,t,0,a,r,0)}))}_reduceImpl(e,t,s,a,r,n,i){try{if(++i>1e3)return void setTimeout((()=>{i=0,this._reduceImpl(e,t,s,a,r,n,i)}));e.next().then((l=>{try{if(null===l)r(s);else{const u=t(s,l,a,this);F(u)?u.then((s=>{this._reduceImpl(e,t,s,a+1,r,n,i)}),n):this._reduceImpl(e,t,u,a+1,r,n,i)}}catch(u){n(u)}}),n)}catch(l){n(l)}}removeField(e){return C._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,s=null){return C._featuresetFunctions.addField.bind(this)(e,t,s)}sumArea(e,t=!1,s){const a=u(e);return this.reduce(((e,s)=>null===s.geometry?0:t?I(s.geometry,a).then((t=>e+t)):T(s.geometry,a).then((t=>e+t))),0,s)}sumLength(e,t=!1,s){const a=h(e);return this.reduce(((e,s)=>null===s.geometry?0:t?P(s.geometry,a).then((t=>e+t)):D(s.geometry,a).then((t=>e+t))),0,s)}_substituteVars(e,t){if(null!==t){const s={};for(const e in t)s[e.toLowerCase()]=t[e];e.parameters=s}}async distinct(e,t=1e3,s=null,a){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,s),this.calculateStatistic("distinct",r,t,this._defaultTracker(a))}async min(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("min",a,-1,this._defaultTracker(s))}async max(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("max",a,-1,this._defaultTracker(s))}async avg(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("avg",a,-1,this._defaultTracker(s))}async sum(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("sum",a,-1,this._defaultTracker(s))}async stdev(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("stdev",a,-1,this._defaultTracker(s))}async variance(e,t=null,s){await this.load();const a=w.create(e,this.getFieldsIndex());return this._substituteVars(a,t),this.calculateStatistic("variance",a,-1,this._defaultTracker(s))}async count(e){return await this.load(),this.calculateStatistic("count",w.create("1",this.getFieldsIndex()),-1,this._defaultTracker(e))}_defaultTracker(e){return e||{aborted:!1}}forEach(e,t){return new Promise(((s,a)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,s,a,0)}))}_forEachImpl(e,t,s,a,r,n){try{if(++n>1e3)return void setTimeout((()=>{n=0,this._forEachImpl(e,t,s,a,r,n)}),0);e.next().then((i=>{try{if(null===i)a(s);else{const l=t(i);null==l?this._forEachImpl(e,t,s,a,r,n):F(l)?l.then((()=>{try{this._forEachImpl(e,t,s,a,r,n)}catch(i){r(i)}}),r):this._forEachImpl(e,t,s,a,r,n)}}catch(l){r(l)}}),r)}catch(i){r(i)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let s=0;s<this.fields.length;s++)t.layerDefinition.fields.push(c(this.fields[s]));return this.reduce(((e,s)=>{const a={geometry:s.geometry&&s.geometry.toJSON(),attributes:{}};for(const t in s.attributes)a.attributes[t]=s.attributes[t];return t.featureSet.features.push(a),1}),0,e).then((()=>t))}castToText(){return"object, FeatureSet"}queryAttachments(e,t,s,a,r){return this._parent.queryAttachments(e,t,s,a,r)}serviceUrl(){return this._parent.serviceUrl()}subtypes(){return this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map((e=>({name:e.name,code:e.id}))):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(c(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===o[this.geometryType]?"":o[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce(((t,s)=>{const a={geometry:s.geometry?s.geometry.toJSON():null,attributes:s.attributes};return null!==a.geometry&&a.geometry.spatialReference&&delete a.geometry.spatialReference,e.push(a),1}),0,t);const s=this.schema();return s.features=e,s.spatialReference=this.spatialReference.toJSON(),JSON.stringify(s)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const s=[];await this.reduce(((e,a)=>{const r={geometry:a.geometry?!0===t?.keepGeometryType?a.geometry:a.geometry.toJSON():null,attributes:a.attributes};return null!==r.geometry&&r.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete r.geometry.spatialReference,s.push(r),1}),0,e);const a=this.schema();return a.features=s,a.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),a}}C._featuresetFunctions={};export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t,s,i,e){this._candidates=null,this._known=null,this._lastFetchedIndex=0,this._ordered=!1,this.pagesDefinition=null,this._candidates=t,this._known=s,this._ordered=i,this.pagesDefinition=e}}export{t as default};
5
+ class t{constructor(t,s,e,i){this._lastFetchedIndex=0,this._ordered=!1,this.pagesDefinition=null,this._candidates=t,this._known=s,this._ordered=e,this.pagesDefinition=i}}export{t as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{SqlError as e,SqlErrorCodes as t}from"./errorsupport.js";import{FeatureServiceDatabaseType as r}from"./shared.js";import{toWhereClauseFromTree as n}from"./sqlUtils.js";import{WhereClause as a}from"../../../core/sql/WhereClause.js";function i(i){if("function"===i.parseTree.type){if(0===i.parseTree.args.value.length)return{name:i.parseTree.name,expr:null};if(i.parseTree.args.value.length>1)throw new e(t.MissingStatisticParameters);const s=a.create(n(i.parseTree.args.value[0],r.Standardised,i.parameters),i.fieldsIndex);return{name:i.parseTree.name,expr:s}}return null}class s{clone(){const e=new s;return e.field=this.field,e.tofieldname=this.tofieldname,e.typeofstat=this.typeofstat,e.workingexpr=this.workingexpr,e}static parseStatField(r,n,o){const l=new s;l.field=r;const p=a.create(n,o),u=i(p);if(null===u)throw new e(t.UnsupportedSqlFunction,{function:""});const f=u.name.toUpperCase().trim();if("MIN"===f){if(l.typeofstat="MIN",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"min"})}else if("MAX"===f){if(l.typeofstat="MAX",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"max"})}else if("COUNT"===f)l.typeofstat="COUNT",l.workingexpr=u.expr;else if("STDEV"===f){if(l.typeofstat="STDDEV",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"stdev"})}else if("SUM"===f){if(l.typeofstat="SUM",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"sum"})}else if("MEAN"===f){if(l.typeofstat="AVG",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:f})}else if("AVG"===f){if(l.typeofstat="AVG",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"avg"})}else{if("VAR"!==f)throw new e(t.UnsupportedSqlFunction,{function:f});if(l.typeofstat="VAR",l.workingexpr=u.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"var"})}return l}toStatisticsName(){switch(this.typeofstat.toUpperCase()){case"MIN":return"min";case"MAX":return"max";case"SUM":return"sum";case"COUNT":default:return"count";case"VAR":return"var";case"STDDEV":return"stddev";case"AVG":return"avg"}}}export{s as default};
5
+ import{SqlError as e,SqlErrorCodes as t}from"./errorsupport.js";import{FeatureServiceDatabaseType as r}from"./shared.js";import{toWhereClauseFromTree as n}from"./sqlUtils.js";import{WhereClause as i}from"../../../core/sql/WhereClause.js";function s(s){if("function"===s.parseTree.type){if(0===s.parseTree.args.value.length)return{name:s.parseTree.name,expr:null};if(s.parseTree.args.value.length>1)throw new e(t.MissingStatisticParameters);const a=i.create(n(s.parseTree.args.value[0],r.Standardised,s.parameters),s.fieldsIndex);return{name:s.parseTree.name,expr:a}}return null}class a{constructor(){this.field="",this.tofieldname="",this.typeofstat="MIN",this.workingexpr=null}clone(){const e=new a;return e.field=this.field,e.tofieldname=this.tofieldname,e.typeofstat=this.typeofstat,e.workingexpr=this.workingexpr,e}static parseStatField(r,n,o){const l=new a;l.field=r;const p=i.create(n,o),f=s(p);if(null===f)throw new e(t.UnsupportedSqlFunction,{function:""});const u=f.name.toUpperCase().trim();if("MIN"===u){if(l.typeofstat="MIN",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"min"})}else if("MAX"===u){if(l.typeofstat="MAX",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"max"})}else if("COUNT"===u)l.typeofstat="COUNT",l.workingexpr=f.expr;else if("STDEV"===u){if(l.typeofstat="STDDEV",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"stdev"})}else if("SUM"===u){if(l.typeofstat="SUM",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"sum"})}else if("MEAN"===u){if(l.typeofstat="AVG",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:u})}else if("AVG"===u){if(l.typeofstat="AVG",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"avg"})}else{if("VAR"!==u)throw new e(t.UnsupportedSqlFunction,{function:u});if(l.typeofstat="VAR",l.workingexpr=f.expr,null===p)throw new e(t.InvalidFunctionParameters,{function:"var"})}return l}toStatisticsName(){switch(this.typeofstat.toUpperCase()){case"MIN":return"min";case"MAX":return"max";case"SUM":return"sum";case"COUNT":default:return"count";case"VAR":return"var";case"STDDEV":return"stddev";case"AVG":return"avg"}}}export{a as default};