@arcgis/core 4.30.0-next.20240320 → 4.30.0-next.20240322

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 (149) hide show
  1. package/arcade/Dictionary.js +1 -1
  2. package/arcade/Feature.js +1 -1
  3. package/arcade/featureset/actions/Adapted.js +1 -1
  4. package/arcade/featureset/support/shared.js +1 -1
  5. package/arcade/featureset/support/sqlUtils.js +1 -1
  6. package/arcade/parser.js +1 -1
  7. package/arcade/validation/arcadeValidator.js +1 -1
  8. package/arcade/validation/languageKeywords.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/{4e4ad7ac43a72a2f88a1.js → 0005267c754235ae6784.js} +1 -1
  11. package/assets/esri/core/workers/chunks/07fd6804c7eaa8d2ac3f.js +1 -0
  12. package/assets/esri/core/workers/chunks/{ef19c4fabc3682fc7aa7.js → 0b1ccc2cfb7a6361eae6.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{ff4151d794ec73064fac.js → 10b4fbdc0f8be85737f0.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{8fc69ac4cce6d4dd5513.js → 18a9b472007d4f2b7bbb.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{f484d2a3deb3c60d7038.js → 1ad1cdde4db5ab793623.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{2d0a01d0957b3e4512f6.js → 2cc832f9f5b10817f300.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{95d7b168991ddb3a96ca.js → 2fe91a15fcdae540babe.js} +1 -1
  18. package/assets/esri/core/workers/chunks/36dfc55dc536b1831918.js +1 -0
  19. package/assets/esri/core/workers/chunks/505f35a02ac6a67a255b.js +1 -0
  20. package/assets/esri/core/workers/chunks/{51fc02ce8cab70b363b1.js → 5162ba2975b4b025590e.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{4e76bc3274df21ec22e0.js → 51700be6f50efba0bc82.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{cee492b97e841a6d4678.js → 5b41ec1bd24314f6f153.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{d518a0adc3d88700235c.js → 65680926c761bf53fd14.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{9c78ccff1c7f8ae90b06.js → 671892e733d8976e48bb.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{4be6d5660ec1c8ac7606.js → 70188e0aa47da1aa1a7f.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{bf65e5c155ad15f58907.js → 7530fef3ee217643898e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{a0fa32df6a262ffb3179.js → 75bd66a0a1b42e057c1a.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{a53b90ced443603a78c5.js → 7819a446d3c9749ff74f.js} +1 -1
  29. package/assets/esri/core/workers/chunks/7c212395100080cf122e.js +1 -0
  30. package/assets/esri/core/workers/chunks/{424b5d20d7f64e28c0a7.js → 7ca976273f1f64f75aa7.js} +1 -1
  31. package/assets/esri/core/workers/chunks/8c07e1000522c3251ac0.js +1 -0
  32. package/assets/esri/core/workers/chunks/{36d697a3788b86f24588.js → 9403e2ee9c97488ce4f0.js} +1 -1
  33. package/assets/esri/core/workers/chunks/9d240e70a24520b2a810.js +1 -0
  34. package/assets/esri/core/workers/chunks/{e6a5ccd93f2dab2bb1e0.js → a0de5ad1d08f511cf3d8.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{ac8606f2e4719c96a732.js → a7ac2c5e701f44a67aa3.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{3c19806b03f14d288fae.js → b3cd5f8691ba0b5b5729.js} +1 -1
  37. package/assets/esri/core/workers/chunks/b3d905c6b100831ad3c4.js +1 -0
  38. package/assets/esri/core/workers/chunks/{5a747af5273646ab848c.js → c38c6cae22627fbf6f3b.js} +1 -1
  39. package/assets/esri/core/workers/chunks/c4d2ff515fc70b07cb5f.js +1 -0
  40. package/assets/esri/core/workers/chunks/{96fd6fd8cbb3a2ee088e.js → caa03837b9c173ea493f.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{dd5a078b7919f749ba3e.js → d90ee005599c44bfb6ad.js} +1 -1
  42. package/assets/esri/core/workers/chunks/dc3a6ab23a13ec5deed7.js +1 -0
  43. package/assets/esri/core/workers/chunks/{eb3e82ed1653ecf348da.js → e1a2f7282d889e251809.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{1cc0714457e299b54496.js → e22a13ff683d207e0434.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{7f8725f146c29290e240.js → e93cc8cdeaaf81210dc2.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{52274afa07468bc555aa.js → ec52127b5ada8410acf3.js} +13 -13
  47. package/assets/esri/core/workers/chunks/eecb0064c5343e88bfde.js +1 -0
  48. package/assets/esri/core/workers/chunks/f8693321bbd8a93666c7.js +1 -0
  49. package/assets/esri/core/workers/chunks/{fe7dfb8546d0fc40843c.js → fec0d24e8841ba1994f0.js} +1 -1
  50. package/chunks/LineSeries.js +1 -1
  51. package/chunks/Theme.js +1 -1
  52. package/chunks/index.js +5 -0
  53. package/chunks/languageUtils.js +1 -1
  54. package/core/number.js +1 -1
  55. package/core/workers/loaderConfig.js +1 -1
  56. package/interfaces.d.ts +33 -106
  57. package/layers/mixins/ArcGISImageService.js +1 -1
  58. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  59. package/package.json +1 -1
  60. package/rest/geoprocessor/utils.js +1 -1
  61. package/rest/knowledgeGraphService.js +1 -1
  62. package/rest/utils.js +1 -1
  63. package/support/revision.js +1 -1
  64. package/symbols/cim/cimAnalyzer.js +1 -1
  65. package/undoredo/support/DataEditingContext.js +5 -0
  66. package/views/2d/FrameTask.js +1 -1
  67. package/views/2d/constraints/ZoomConstraint.js +1 -1
  68. package/views/2d/engine/webgl/shaderGraph/techniques/TechniqueDebugLayerView.js +1 -1
  69. package/views/2d/engine/webgl/shaderGraph/techniques/markers/ComputedMarkerParams.js +1 -1
  70. package/views/2d/input/MapViewInputManager.js +1 -1
  71. package/views/2d/input/handlers/KeyPan.js +1 -1
  72. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  73. package/views/2d/layers/BaseLayerView2D.js +1 -1
  74. package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
  75. package/views/2d/layers/CatalogDynamicGroupLayerView2D.js +1 -1
  76. package/views/2d/layers/CatalogLayerView2D.js +1 -1
  77. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  78. package/views/2d/layers/GeoRSSLayerView2D.js +1 -1
  79. package/views/2d/layers/GraphicsLayerView2D.js +1 -1
  80. package/views/2d/layers/GroupLayerView2D.js +1 -1
  81. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  82. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  83. package/views/2d/layers/KMLLayerView2D.js +1 -1
  84. package/views/2d/layers/KnowledgeGraphLayerView2D.js +1 -1
  85. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  86. package/views/2d/layers/MapNotesLayerView2D.js +1 -1
  87. package/views/2d/layers/MediaLayerView2D.js +1 -1
  88. package/views/2d/layers/RouteLayerView2D.js +1 -1
  89. package/views/2d/layers/TileLayerView2D.js +1 -1
  90. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  91. package/views/2d/layers/VideoLayerView2D.js +1 -1
  92. package/views/2d/layers/WMSLayerView2D.js +1 -1
  93. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  94. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  95. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  96. package/views/2d/layers/features/schema/processor/symbols/utils.js +5 -0
  97. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  98. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
  99. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  100. package/views/2d/navigation/ZoomBox.js +1 -1
  101. package/views/2d/viewpointUtils.js +1 -1
  102. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  103. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  104. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  105. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  106. package/views/3d/terrain/TerrainRenderer.js +1 -1
  107. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  108. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  110. package/views/3d/webgl-engine/lib/IntersectorInterfaces.js +1 -1
  111. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  112. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  113. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  114. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  115. package/views/draw/DrawOperation.js +1 -1
  116. package/views/input/InputManager.js +1 -1
  117. package/views/input/keys.js +1 -1
  118. package/views/interactive/snapping/SnappingManager.js +1 -1
  119. package/widgets/BasemapLayerList.js +1 -1
  120. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  121. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  122. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  123. package/widgets/FeatureTable.js +1 -1
  124. package/widgets/LayerList.js +1 -1
  125. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  126. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  127. package/widgets/OrientedImageryViewer.js +1 -1
  128. package/widgets/Popup.js +1 -1
  129. package/widgets/TableList.js +1 -1
  130. package/arcade/lib/arcade-parser.js +0 -5
  131. package/arcade/lib/assert.js +0 -5
  132. package/arcade/lib/character.js +0 -5
  133. package/arcade/lib/comment-handler.js +0 -5
  134. package/arcade/lib/error-handler.js +0 -5
  135. package/arcade/lib/parser.js +0 -5
  136. package/arcade/lib/scanner.js +0 -5
  137. package/arcade/lib/tokenizer.js +0 -5
  138. package/arcade/lib/types.js +0 -5
  139. package/assets/esri/core/workers/chunks/12b95408753cea053a40.js +0 -1
  140. package/assets/esri/core/workers/chunks/16397420fb6067b47b25.js +0 -1
  141. package/assets/esri/core/workers/chunks/1fdbeb110fae52b96bb3.js +0 -1
  142. package/assets/esri/core/workers/chunks/2427699e34e1895ed024.js +0 -1
  143. package/assets/esri/core/workers/chunks/65ed5dfd19d99588d66e.js +0 -1
  144. package/assets/esri/core/workers/chunks/785454b084d8ec4e7dc0.js +0 -1
  145. package/assets/esri/core/workers/chunks/7b07f3bc68a54974cd03.js +0 -1
  146. package/assets/esri/core/workers/chunks/7bba67d345da6eced804.js +0 -1
  147. package/assets/esri/core/workers/chunks/ad95daa3f4ad7030bf24.js +0 -1
  148. package/assets/esri/core/workers/chunks/c2573c1cb7c714435acc.js +0 -1
  149. package/assets/esri/core/workers/chunks/d344e99dd999aaaabbe3.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as s}from"./deepClone.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as e}from"./executionError.js";import r from"./ImmutableArray.js";import{i as n,a as o,b as a,c as u,t as l,d as c,e as f,f as h,g as m,h as b,j as y,k as d,l as g,m as w,n as p,o as J,p as T}from"../chunks/languageUtils.js";import A from"../geometry/Geometry.js";function v(t,s,i=!1,e=!1){if(null==t)return null;if(a(t))return m(t);if(o(t))return b(t);if(u(t))return y(t);if(d(t))return g(t,s);if(w(t))return t;if(p(t))return t;if(J(t)){const r=[];for(const n of t)r.push(v(n,s,i,e));return r}if(e&&T(t))return t;const r=new N;r.immutable=!1;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&r.setField(n,v(o,s,i,e))}return r.immutable=i,r}class N{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.attributes=null,this.plain=!1,this.immutable=!0,this.attributes=t instanceof N?t.attributes:t??{}}field(t){const s=t.toLowerCase(),r=this.attributes[t];if(void 0!==r)return r;for(const i in this.attributes)if(i.toLowerCase()===s)return this.attributes[i];throw new i(null,e.FieldNotFound,null,{key:t})}setField(s,r){if(this.immutable)throw new i(null,e.Immutable,null);if(n(r))throw new i(null,e.NoFunctionInDictionary,null);const o=s.toLowerCase();r instanceof Date&&(r=t.dateJSToArcadeDate(r));if(void 0===this.attributes[s]){for(const t in this.attributes)if(t.toLowerCase()===o)return void(this.attributes[t]=r);this.attributes[s]=r}else this.attributes[s]=r}hasField(t){const s=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const i in this.attributes)if(i.toLowerCase()===s)return!0;return!1}keys(){let t=[];for(const s in this.attributes)t.push(s);return t=t.sort(),t}castToText(s=!1){let i="";for(const e in this.attributes){""!==i&&(i+=",");const n=this.attributes[e];null==n?i+=JSON.stringify(e)+":null":o(n)||a(n)||u(n)?i+=JSON.stringify(e)+":"+JSON.stringify(n):n instanceof A?i+=JSON.stringify(e)+":"+l(n):n instanceof r||n instanceof Array?i+=JSON.stringify(e)+":"+l(n,null,s):n instanceof t?i+=s?JSON.stringify(e)+":"+JSON.stringify(n.getTime()):JSON.stringify(e)+":"+n.stringify():null!==n&&"object"==typeof n&&void 0!==n.castToText&&(i+=JSON.stringify(e)+":"+n.castToText(s))}return"{"+i+"}"}static convertObjectToArcadeDictionary(t,s,i=!0,e=!1){const r=new N;r.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&r.setField(n.toString(),v(o,s,i,e))}return r.immutable=i,r}static convertJsonToArcade(t,s,i=!1,e=!1){return v(t,s,i,e)}castAsJson(t=null){const s={};for(let i in this.attributes){const e=this.attributes[i];void 0!==e&&(t?.keyTranslate&&(i=t.keyTranslate(i)),s[i]=c(e,t))}return s}async castDictionaryValueAsJsonAsync(t,s,i,e=null,r){const n=await f(i,e,r);return t[s]=n,n}async castAsJsonAsync(s=null,i=null){const e={},r=[];for(let n in this.attributes){const o=this.attributes[n];i?.keyTranslate&&(n=i.keyTranslate(n)),void 0!==o&&(h(o)||o instanceof A||o instanceof t?e[n]=c(o,i):r.push(this.castDictionaryValueAsJsonAsync(e,n,o,s,i)))}return r.length>0&&await Promise.all(r),e}deepClone(){const t=new N;t.immutable=!1;for(const i of this.keys())t.setField(i,s(this.field(i)));return t}}export{N as default};
5
+ import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as s}from"./deepClone.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as e}from"./executionError.js";import r from"./ImmutableArray.js";import{i as n,a as o,b as a,c as u,t as l,d as c,e as f,f as h,g as m,h as y,j as b,k as d,l as g,m as w,n as p,o as J,p as A}from"../chunks/languageUtils.js";import T from"../geometry/Geometry.js";function v(t,s,i=!1,e=!1){if(null==t)return null;if(a(t))return m(t);if(o(t))return y(t);if(u(t))return b(t);if(d(t))return g(t,s);if(w(t))return t;if(p(t))return t;if(J(t)){const r=[];for(const n of t)r.push(v(n,s,i,e));return r}if(e&&A(t))return t;const r=new N;r.immutable=!1;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&r.setField(n,v(o,s,i,e))}return r.immutable=i,r}class N{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.attributes=null,this.plain=!1,this.immutable=!0,this.attributes=t instanceof N?t.attributes:t??{}}field(t){const s=t.toLowerCase(),r=this.attributes[t];if(void 0!==r)return r;for(const i in this.attributes)if(i.toLowerCase()===s)return this.attributes[i];throw new i(null,e.FieldNotFound,null,{key:t})}setField(s,r){if(this.immutable)throw new i(null,e.Immutable,null);if(n(r))throw new i(null,e.NoFunctionInDictionary,null);const o=s.toLowerCase();r instanceof Date&&(r=t.dateJSToArcadeDate(r));if(void 0===this.attributes[s]){for(const t in this.attributes)if(t.toLowerCase()===o)return void(this.attributes[t]=r);this.attributes[s]=r}else this.attributes[s]=r}hasField(t){const s=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const i in this.attributes)if(i.toLowerCase()===s)return!0;return!1}keys(){let t=[];for(const s in this.attributes)t.push(s);return t=t.sort(),t}castToText(s=!1){let i="";for(const e in this.attributes){""!==i&&(i+=",");const n=this.attributes[e];null==n?i+=JSON.stringify(e)+":null":o(n)||a(n)||u(n)?i+=JSON.stringify(e)+":"+JSON.stringify(n):n instanceof T?i+=JSON.stringify(e)+":"+l(n):n instanceof r||Array.isArray(n)?i+=JSON.stringify(e)+":"+l(n,null,s):n instanceof t?i+=s?JSON.stringify(e)+":"+JSON.stringify(n.getTime()):JSON.stringify(e)+":"+n.stringify():null!==n&&"object"==typeof n&&void 0!==n.castToText&&(i+=JSON.stringify(e)+":"+n.castToText(s))}return"{"+i+"}"}static convertObjectToArcadeDictionary(t,s,i=!0,e=!1){const r=new N;r.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&r.setField(n.toString(),v(o,s,i,e))}return r.immutable=i,r}static convertJsonToArcade(t,s,i=!1,e=!1){return v(t,s,i,e)}castAsJson(t=null){const s={};for(let i in this.attributes){const e=this.attributes[i];void 0!==e&&(t?.keyTranslate&&(i=t.keyTranslate(i)),s[i]=c(e,t))}return s}async castDictionaryValueAsJsonAsync(t,s,i,e=null,r){const n=await f(i,e,r);return t[s]=n,n}async castAsJsonAsync(s=null,i=null){const e={},r=[];for(let n in this.attributes){const o=this.attributes[n];i?.keyTranslate&&(n=i.keyTranslate(n)),void 0!==o&&(h(o)||o instanceof T||o instanceof t?e[n]=c(o,i):r.push(this.castDictionaryValueAsJsonAsync(e,n,o,s,i)))}return r.length>0&&await Promise.all(r),e}deepClone(){const t=new N;t.immutable=!1;for(const i of this.keys())t.setField(i,s(this.field(i)));return t}}export{N as default};
package/arcade/Feature.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"./executionError.js";import n from"./ImmutableArray.js";import{u as o,a,b as l,c as f,t as u,n as d,m as y,k as h,f as c,d as m}from"../chunks/languageUtils.js";import{DateOnly as p}from"../core/sql/DateOnly.js";import{TimeOnly as _}from"../core/sql/TimeOnly.js";import b from"../geometry/Geometry.js";import g from"../geometry/Point.js";import{fromJSON as T}from"../geometry/support/jsonUtils.js";import{convertToGeometry as x}from"../layers/graphics/featureConversionUtils.js";import F from"../layers/support/FieldsIndex.js";class D{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new D;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof D){const t=new D;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return D.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new D;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new D;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=D.parseGeometryFromDictionary(s._geometry,t):s._geometry instanceof b||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new D;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:o(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:F.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":a(r)||l(r)||f(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof b?i+=JSON.stringify(s)+":"+u(r):r instanceof _||r instanceof p?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof n||r instanceof Array?i+=JSON.stringify(s)+":"+u(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":u(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let o=this.attributes[r];if(void 0===o){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(o=this.attributes[t],null!==o){if("time-only"===n){d(o)||(this.attributes[t]=_.fromReader(o.toString()));break}if("date-only"===n){y(o)||(this.attributes[t]=p.fromReader(o.toString()));break}if("timestamp-offset"===n){h(o)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(o.toString()));break}const s=this.isUnknownDateTimeField(t);o instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):h(o)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i))}break}}else if(null!==o){if("time-only"===n){d(o)?this.attributes[r]=o:this.attributes[r]=_.fromReader(o.toString());continue}if("date-only"===n){y(o)?this.attributes[r]=o:this.attributes[r]=p.fromReader(o.toString());continue}if("timestamp-offset"===n){h(o)?this.attributes[r]=o:this.attributes[r]=e.fromReaderAsTimeStampOffset(o.toString());continue}const t=this.isUnknownDateTimeField(r);h(o)?this.attributes[r]=o:o instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i)}}}geometry(){return null===this._geometry||this._geometry instanceof b||(this._optimizedGeomDefinition?(this._geometry=T(x(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=T(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,r.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,r.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===c(i))throw new s(null,r.TypeNotAllowedInFeature,null);const n=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===n)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e,t){const i=D._convertDictionaryToJson(e,!0);return void 0!==i.hasm&&(i.hasM=i.hasm,delete i.hasm),void 0!==i.hasz&&(i.hasZ=i.hasz,delete i.hasz),void 0!==i.spatialreference&&(i.spatialReference=i.spatialreference,delete i.spatialreference),i.spatialReference||(i.spatialReference=t),void 0!==i.rings&&(i.rings=this._fixPathArrays(i.rings,!0===i.hasZ,!0===i.hasZ)),void 0!==i.paths&&(i.paths=this._fixPathArrays(i.paths,!0===i.hasZ,!0===i.hasM)),void 0!==i.points&&(i.points=this._fixPointArrays(i.points,!0===i.hasZ,!0===i.hasM)),T(i)}static _fixPathArrays(e,t,i){const s=[];if(e instanceof Array)for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof n)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(e instanceof Array)for(let r=0;r<e.length;r++){const o=e[r];o instanceof g?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}else if(e instanceof n)for(let r=0;r<e.length();r++){const o=e.get(r);o instanceof g?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}return s}static _convertDictionaryToJson(e,t=!1){const s={};for(const r in e.attributes){let n=e.attributes[r];n instanceof i&&(n=D._convertDictionaryToJson(n)),t?s[r.toLowerCase()]=n:s[r]=n}return s}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const n=e.attributes[i];if(!c(n))throw new s(null,r.InvalidParameter,null);t[i]=n}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=T(e.geometry));const n={};if(null!==e.attributes&&void 0!==e.attributes)for(const o in e.attributes){const t=e.attributes[o];if(null===t)n[o]=t;else{if(!(f(t)||l(t)||a(t)||h(t)||d(t)||y(t)))throw new s(null,r.InvalidParameter,null);n[o]=t}}return D.createFromGraphicLikeObject(i,n,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=m(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(D);export{D as default};
5
+ import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"./executionError.js";import n from"./ImmutableArray.js";import{u as o,a,b as l,c as u,t as f,n as d,m as y,k as h,f as c,d as m}from"../chunks/languageUtils.js";import{DateOnly as p}from"../core/sql/DateOnly.js";import{TimeOnly as _}from"../core/sql/TimeOnly.js";import b from"../geometry/Geometry.js";import g from"../geometry/Point.js";import{fromJSON as T}from"../geometry/support/jsonUtils.js";import{convertToGeometry as x}from"../layers/graphics/featureConversionUtils.js";import F from"../layers/support/FieldsIndex.js";class D{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new D;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof D){const t=new D;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return D.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new D;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new D;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=D.parseGeometryFromDictionary(s._geometry,t):s._geometry instanceof b||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new D;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:o(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:F.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":a(r)||l(r)||u(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof b?i+=JSON.stringify(s)+":"+f(r):r instanceof _||r instanceof p?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof n||Array.isArray(r)?i+=JSON.stringify(s)+":"+f(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":f(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let o=this.attributes[r];if(void 0===o){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(o=this.attributes[t],null!==o){if("time-only"===n){d(o)||(this.attributes[t]=_.fromReader(o.toString()));break}if("date-only"===n){y(o)||(this.attributes[t]=p.fromReader(o.toString()));break}if("timestamp-offset"===n){h(o)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(o.toString()));break}const s=this.isUnknownDateTimeField(t);o instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):h(o)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i))}break}}else if(null!==o){if("time-only"===n){d(o)?this.attributes[r]=o:this.attributes[r]=_.fromReader(o.toString());continue}if("date-only"===n){y(o)?this.attributes[r]=o:this.attributes[r]=p.fromReader(o.toString());continue}if("timestamp-offset"===n){h(o)?this.attributes[r]=o:this.attributes[r]=e.fromReaderAsTimeStampOffset(o.toString());continue}const t=this.isUnknownDateTimeField(r);h(o)?this.attributes[r]=o:o instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i)}}}geometry(){return null===this._geometry||this._geometry instanceof b||(this._optimizedGeomDefinition?(this._geometry=T(x(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=T(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,r.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,r.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===c(i))throw new s(null,r.TypeNotAllowedInFeature,null);const n=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===n)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e,t){const i=D._convertDictionaryToJson(e,!0);return void 0!==i.hasm&&(i.hasM=i.hasm,delete i.hasm),void 0!==i.hasz&&(i.hasZ=i.hasz,delete i.hasz),void 0!==i.spatialreference&&(i.spatialReference=i.spatialreference,delete i.spatialreference),i.spatialReference||(i.spatialReference=t),void 0!==i.rings&&(i.rings=this._fixPathArrays(i.rings,!0===i.hasZ,!0===i.hasZ)),void 0!==i.paths&&(i.paths=this._fixPathArrays(i.paths,!0===i.hasZ,!0===i.hasM)),void 0!==i.points&&(i.points=this._fixPointArrays(i.points,!0===i.hasZ,!0===i.hasM)),T(i)}static _fixPathArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof n)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++){const o=e[r];o instanceof g?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}else if(e instanceof n)for(let r=0;r<e.length();r++){const o=e.get(r);o instanceof g?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}return s}static _convertDictionaryToJson(e,t=!1){const s={};for(const r in e.attributes){let n=e.attributes[r];n instanceof i&&(n=D._convertDictionaryToJson(n)),t?s[r.toLowerCase()]=n:s[r]=n}return s}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const n=e.attributes[i];if(!c(n))throw new s(null,r.InvalidParameter,null);t[i]=n}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=T(e.geometry));const n={};if(null!==e.attributes&&void 0!==e.attributes)for(const o in e.attributes){const t=e.attributes[o];if(null===t)n[o]=t;else{if(!(u(t)||l(t)||a(t)||h(t)||d(t)||y(t)))throw new s(null,r.InvalidParameter,null);n[o]=t}}return D.createFromGraphicLikeObject(i,n,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=m(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(D);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.30/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,isDate as u,isLuxonDate as c,isArcadeTime as d,isArcadeDate as p,isArcadeDateOnly as f,layerGeometryEsriConstants as g}from"../support/shared.js";import{reformulateWithoutField as N,toWhereClause as _,translateFunctionToDatabaseSpecific as S,makeToday as m,makeSqlFromDateTimeParameter as w,makeTimeString as v,arcadeDateToSqlString as C,arcadeDateOnlyToSqlString as T,convertIntervalToSql as F,combine as W,scanForField as E}from"../support/sqlUtils.js";import{assertIsSome as y}from"../../../core/maybe.js";import{WhereClause as A}from"../../../core/sql/WhereClause.js";import x from"../../../geometry/SpatialReference.js";class D{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class I extends D{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class k extends D{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:N(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class b extends D{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 A?_(this.codefield,h.Standardised):this.codefield,e.parameters);return r.includes(b.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:A.create(r,t._parent.getFieldsIndex(),t.dateFieldsTimeZoneDefaultUTC)}}evaluateNodeToWhereClause(e,t,a=null,i=null,l){let n,o,h,g;switch(e.type){case"interval":return F(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,b.BADNESS,l));for(let s=0;s<e.clauses.length;s++)r+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,t,a,b.BADNESS,l)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,t,a,b.BADNESS,l);return null!==e.else&&(r+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,a,b.BADNESS,l)),r+=" END ",r}case"parameter":{const r=l[e.value.toLowerCase()];if("string"==typeof r)return"'"+r.toString().replaceAll("'","''")+"'";if(u(r))return w(r,t);if(c(r))return w(r,t);if(d(r))return v(r,t);if(p(r))return C(r,t);if(f(r))return T(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().replaceAll("'","''")+"'"):u(r[s])||c(r[s])?e.push(w(r[s],t)):d(r[s])?e.push(v(r[s],t)):p(r[s])?e.push(C(r[s],t)):f(r[s])?e.push(T(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,b.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 g=this.evaluateNodeToWhereClause(e.right,t,a,i,l),g instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+g.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+g+")) ";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 g=this.evaluateNodeToWhereClause(e.right,t,a,i,l),g instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+g.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+g+")) ";case"BETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"NOTBETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" NOT BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.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,b.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return m("date"===e.mode,t);case"column-reference":return a&&a.toLowerCase()===e.column.toLowerCase()?"("+i+")":e.column;case"data-type":return e.value;case"function":{const r=this.evaluateNodeToWhereClause(e.args,t,a,b.BADNESS,l);return S(e.name,r,t)}}throw new r(s.UnsupportedSyntax,{node:e.type})}extractValue(e){return this.codefield instanceof A?this.reverseLkp[A.convertValueToStorageFormat(this.codefield.calculateValueCompiled(e))]:this.reverseLkp[e.attributes[this.codefield]]}}b.BADNESS="_!!!_BAD_LKP_!!!!";class B extends D{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:N(e,this.field.name,_(this._sql,h.Standardised),t.getFieldsIndex())}}extractValue(e){return A.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class L extends l{static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}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}_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 x({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=g.point,this.typeIdField="",this.types=null,this.subtypeField=null,this.subtypes=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),y(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 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 I)&&!0===s.scanForField(t.field.name)){if(!(t instanceof k)){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=W(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===E(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=W(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 I))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=W(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=W(this._extraFilter,l)):l=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,h,r,s,l,n,o)}}export{L as AdaptedFeatureSet,D as AdaptedField,k as FieldRename,I as OriginalField,B as SqlExpressionAdapted,b 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,isDate as u,isLuxonDate as c,isArcadeTime as d,isArcadeDate as p,isArcadeDateOnly as f,layerGeometryEsriConstants as g}from"../support/shared.js";import{reformulateWithoutField as N,toWhereClause as _,translateFunctionToDatabaseSpecific as S,makeToday as m,makeSqlFromDateTimeParameter as w,makeTimeString as v,arcadeDateToSqlString as C,arcadeDateOnlyToSqlString as T,convertIntervalToSql as F,combine as W,scanForField as y}from"../support/sqlUtils.js";import{assertIsSome as A}from"../../../core/maybe.js";import{WhereClause as E}from"../../../core/sql/WhereClause.js";import x from"../../../geometry/SpatialReference.js";class D{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class I extends D{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class k extends D{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:N(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class b extends D{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 E?_(this.codefield,h.Standardised):this.codefield,e.parameters);return r.includes(b.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:E.create(r,t._parent.getFieldsIndex(),t.dateFieldsTimeZoneDefaultUTC)}}evaluateNodeToWhereClause(e,t,a=null,i=null,l){let n,o,h,g;switch(e.type){case"interval":return F(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,b.BADNESS,l));for(let s=0;s<e.clauses.length;s++)r+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,t,a,b.BADNESS,l)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,t,a,b.BADNESS,l);return null!==e.else&&(r+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,a,b.BADNESS,l)),r+=" END ",r}case"parameter":{const r=l[e.value.toLowerCase()];if("string"==typeof r)return"'"+r.toString().replaceAll("'","''")+"'";if(u(r))return w(r,t);if(c(r))return w(r,t);if(d(r))return v(r,t);if(p(r))return C(r,t);if(f(r))return T(r,t);if(Array.isArray(r)){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replaceAll("'","''")+"'"):u(r[s])||c(r[s])?e.push(w(r[s],t)):d(r[s])?e.push(v(r[s],t)):p(r[s])?e.push(C(r[s],t)):f(r[s])?e.push(T(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,b.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 g=this.evaluateNodeToWhereClause(e.right,t,a,i,l),Array.isArray(g)?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+g.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" IN ("+g+")) ";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 g=this.evaluateNodeToWhereClause(e.right,t,a,i,l),Array.isArray(g)?" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+g.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,i,l)+" NOT IN ("+g+")) ";case"BETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"NOTBETWEEN":return h=this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)," ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" NOT BETWEEN "+h[0]+" AND "+h[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,a,b.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,b.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,t,a,b.BADNESS,l)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,a,b.BADNESS,l)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return m("date"===e.mode,t);case"column-reference":return a&&a.toLowerCase()===e.column.toLowerCase()?"("+i+")":e.column;case"data-type":return e.value;case"function":{const r=this.evaluateNodeToWhereClause(e.args,t,a,b.BADNESS,l);return S(e.name,r,t)}}throw new r(s.UnsupportedSyntax,{node:e.type})}extractValue(e){return this.codefield instanceof E?this.reverseLkp[E.convertValueToStorageFormat(this.codefield.calculateValueCompiled(e))]:this.reverseLkp[e.attributes[this.codefield]]}}b.BADNESS="_!!!_BAD_LKP_!!!!";class B extends D{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:N(e,this.field.name,_(this._sql,h.Standardised),t.getFieldsIndex())}}extractValue(e){return E.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class L extends l{static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}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}_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 x({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=g.point,this.typeIdField="",this.types=null,this.subtypeField=null,this.subtypes=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),A(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 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 I)&&!0===s.scanForField(t.field.name)){if(!(t instanceof k)){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=W(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===y(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=W(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 I))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=W(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=W(this._extraFilter,l)):l=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,h,r,s,l,n,o)}}export{L as AdaptedFeatureSet,D as AdaptedField,k as FieldRename,I as OriginalField,B as SqlExpressionAdapted,b 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as r}from"../../../core/sql/DateOnly.js";import{TimeOnly as t}from"../../../core/sql/TimeOnly.js";import i from"../../../geometry/Extent.js";import n from"../../../layers/support/Field.js";import{DateTime as o}from"luxon";var l,s;function y(e){return n.fromJSON(e.toJSON())}function p(e){return e.toJSON?e.toJSON():e}function u(e){return"string"==typeof e||e instanceof String}function m(e){return"boolean"==typeof e}function a(e){return"number"==typeof e}function c(e){return e instanceof Array}function f(e){return e instanceof Date}function d(e){return e instanceof o}function T(r){return r instanceof e}function F(e){return e instanceof r}function g(e){return e instanceof t}function G(e,r){return e===r||!(!f(e)&&!T(e)||!f(r)&&!T(r))&&e.getTime()===r.getTime()}function S(e){const r={};for(const t in e)r[t]=e[t];return r}function O(e){if(null==e)return null;if("number"==typeof e)return e;switch(e.toLowerCase()){case"meters":case"meter":return 109404;case"miles":case"mile":return 109439;case"kilometers":case"kilometer":case"km":return 109414}return null}function v(e){if(null==e)return null;switch(e.type){case"polygon":case"multipoint":case"polyline":return e.extent;case"point":return new i({xmin:e.x,ymin:e.y,xmax:e.x,ymax:e.y,spatialReference:e.spatialReference});case"extent":return e}return null}function I(e){if(null==e)return null;if("number"==typeof e)return e;if("number"==typeof e)return e;switch(e.toLowerCase()){case"meters":case"meter":return 9001;case"miles":case"mile":return 9093;case"kilometers":case"kilometer":case"km":return 9036}return null}function D(e,r){return e===r||("point"===e&&"esriGeometryPoint"===r||("polyline"===e&&"esriGeometryPolyline"===r||("polygon"===e&&"esriGeometryPolygon"===r||("extent"===e&&"esriGeometryEnvelope"===r||("multipoint"===e&&"esriGeometryMultipoint"===r||("point"===r&&"esriGeometryPoint"===e||("polyline"===r&&"esriGeometryPolyline"===e||("polygon"===r&&"esriGeometryPolygon"===e||("extent"===r&&"esriGeometryEnvelope"===e||"multipoint"===r&&"esriGeometryMultipoint"===e)))))))))}!function(e){e[e.Standardised=0]="Standardised",e[e.StandardisedNoInterval=1]="StandardisedNoInterval",e[e.SqlServer=2]="SqlServer",e[e.Oracle=3]="Oracle",e[e.Postgres=4]="Postgres",e[e.PGDB=5]="PGDB",e[e.FILEGDB=6]="FILEGDB",e[e.NotEvaluated=7]="NotEvaluated"}(l||(l={})),function(e){e[e.InFeatureSet=0]="InFeatureSet",e[e.NotInFeatureSet=1]="NotInFeatureSet",e[e.Unknown=2]="Unknown"}(s||(s={}));const P=1e3;function b(e){return function(r){e.reject(r)}}function x(e,r){return function(){try{e.apply(null,arguments)}catch(t){r.reject(t)}}}const N={point:"point",polygon:"polygon",polyline:"polyline",multipoint:"multipoint",extent:"extent",esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint",esriGeometryEnvelope:"extent",envelope:"extent"},E={point:"esriGeometryPoint",polygon:"esriGeometryPolygon",polyline:"esriGeometryPolyline",multipoint:"esriGeometryMultipoint",extent:"esriGeometryEnvelope",esriGeometryPoint:"esriGeometryPoint",esriGeometryPolygon:"esriGeometryPolygon",esriGeometryPolyline:"esriGeometryPolyline",esriGeometryMultipoint:"esriGeometryMultipoint",esriGeometryEnvelope:"esriGeometryEnvelope",envelope:"esriGeometryEnvelope"},k={"small-integer":"esriFieldTypeSmallInteger",integer:"esriFieldTypeInteger",long:"esriFieldTypeLong",single:"esriFieldTypeSingle",double:"esriFieldTypeDouble",string:"esriFieldTypeString",date:"esriFieldTypeDate","date-only":"esriFieldTypeDateOnly","time-only":"esriFieldTypeTimeOnly","timestamp-offset":"esriFieldTypeTimestampOffset",oid:"esriFieldTypeOID",geometry:"esriFieldTypeGeometry",blob:"esriFieldTypeBlob",raster:"esriFieldTypeRaster",guid:"esriFieldTypeGUID","global-id":"esriFieldTypeGlobalID",xml:"esriFieldTypeXML","big-integer":"esriFieldTypeBigInteger",esriFieldTypeSmallInteger:"esriFieldTypeSmallInteger",esriFieldTypeInteger:"esriFieldTypeInteger",esriFieldTypeLong:"esriFieldTypeLong",esriFieldTypeSingle:"esriFieldTypeSingle",esriFieldTypeDouble:"esriFieldTypeDouble",esriFieldTypeString:"esriFieldTypeString",esriFieldTypeDate:"esriFieldTypeDate",esriFieldTypeDateOnly:"esriFieldTypeDateOnly",esriFieldTypeTimeOnly:"esriFieldTypeTimeOnly",esriFieldTypeTimestampOffset:"esriFieldTypeTimestampOffset",esriFieldTypeOID:"esriFieldTypeOID",esriFieldTypeGeometry:"esriFieldTypeGeometry",esriFieldTypeBlob:"esriFieldTypeBlob",esriFieldTypeRaster:"esriFieldTypeRaster",esriFieldTypeGUID:"esriFieldTypeGUID",esriFieldTypeGlobalID:"esriFieldTypeGlobalID",esriFieldTypeXML:"esriFieldTypeXML",esriFieldTypeBigInteger:"esriFieldTypeBigInteger"};function w(e){switch(e){case"point":default:return"esriGeometryPoint";case"polygon":return"esriGeometryPolygon";case"multipoint":return"esriGeometryMultipoint";case"polyline":return"esriGeometryPolyline"}}function J(e){return void 0===e?"":e=(e=(e=e.replace(/\/featureserver\/[0-9]*/i,"/FeatureServer")).replace(/\/mapserver\/[0-9]*/i,"/MapServer")).split("?")[0]}function M(e,r){r||(r={}),"function"==typeof r&&(r={cmp:r});const t="boolean"==typeof r.cycles&&r.cycles,i=r.cmp&&(n=r.cmp,function(e){return function(r,t){const i={key:r,value:e[r]},o={key:t,value:e[t]};return n(i,o)}});var n;const o=[];return function e(r){if(r?.toJSON&&"function"==typeof r.toJSON&&(r=r.toJSON()),void 0===r)return;if("number"==typeof r)return isFinite(r)?""+r:"null";if("object"!=typeof r)return JSON.stringify(r);let n,l;if(Array.isArray(r)){for(l="[",n=0;n<r.length;n++)n&&(l+=","),l+=e(r[n])||"null";return l+"]"}if(null===r)return"null";if(o.includes(r)){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const s=o.push(r)-1,y=Object.keys(r).sort(i?.(r));for(l="",n=0;n<y.length;n++){const t=y[n],i=e(r[t]);i&&(l&&(l+=","),l+=JSON.stringify(t)+":"+i)}return o.splice(s,1),"{"+l+"}"}(e)}export{l as FeatureServiceDatabaseType,s as IdState,x as callback,S as cloneAttributes,y as cloneField,I as convertLinearUnitsToCode,O as convertSquareUnitsToCode,P as defaultMaxRecords,G as equalityTest,b as errback,p as esriFieldToJson,J as extractServiceUrl,T as isArcadeDate,F as isArcadeDateOnly,g as isArcadeTime,c as isArray,m as isBoolean,f as isDate,d as isLuxonDate,a as isNumber,u as isString,k as layerFieldEsriConstants,N as layerGeometryEsriConstants,E as layerGeometryEsriRestConstants,D as sameGeomType,v as shapeExtent,M as stableStringify,w as toEsriGeometryType};
5
+ import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as r}from"../../../core/sql/DateOnly.js";import{TimeOnly as i}from"../../../core/sql/TimeOnly.js";import t from"../../../geometry/Extent.js";import n from"../../../layers/support/Field.js";import{DateTime as o}from"luxon";var l,s;function y(e){return n.fromJSON(e.toJSON())}function p(e){return e.toJSON?e.toJSON():e}function u(e){return"string"==typeof e||e instanceof String}function m(e){return"boolean"==typeof e}function a(e){return"number"==typeof e}function c(e){return Array.isArray(e)}function f(e){return e instanceof Date}function d(e){return e instanceof o}function T(r){return r instanceof e}function F(e){return e instanceof r}function g(e){return e instanceof i}function G(e,r){return e===r||!(!f(e)&&!T(e)||!f(r)&&!T(r))&&e.getTime()===r.getTime()}function S(e){const r={};for(const i in e)r[i]=e[i];return r}function O(e){if(null==e)return null;if("number"==typeof e)return e;switch(e.toLowerCase()){case"meters":case"meter":return 109404;case"miles":case"mile":return 109439;case"kilometers":case"kilometer":case"km":return 109414}return null}function v(e){if(null==e)return null;switch(e.type){case"polygon":case"multipoint":case"polyline":return e.extent;case"point":return new t({xmin:e.x,ymin:e.y,xmax:e.x,ymax:e.y,spatialReference:e.spatialReference});case"extent":return e}return null}function I(e){if(null==e)return null;if("number"==typeof e)return e;if("number"==typeof e)return e;switch(e.toLowerCase()){case"meters":case"meter":return 9001;case"miles":case"mile":return 9093;case"kilometers":case"kilometer":case"km":return 9036}return null}function D(e,r){return e===r||("point"===e&&"esriGeometryPoint"===r||("polyline"===e&&"esriGeometryPolyline"===r||("polygon"===e&&"esriGeometryPolygon"===r||("extent"===e&&"esriGeometryEnvelope"===r||("multipoint"===e&&"esriGeometryMultipoint"===r||("point"===r&&"esriGeometryPoint"===e||("polyline"===r&&"esriGeometryPolyline"===e||("polygon"===r&&"esriGeometryPolygon"===e||("extent"===r&&"esriGeometryEnvelope"===e||"multipoint"===r&&"esriGeometryMultipoint"===e)))))))))}!function(e){e[e.Standardised=0]="Standardised",e[e.StandardisedNoInterval=1]="StandardisedNoInterval",e[e.SqlServer=2]="SqlServer",e[e.Oracle=3]="Oracle",e[e.Postgres=4]="Postgres",e[e.PGDB=5]="PGDB",e[e.FILEGDB=6]="FILEGDB",e[e.NotEvaluated=7]="NotEvaluated"}(l||(l={})),function(e){e[e.InFeatureSet=0]="InFeatureSet",e[e.NotInFeatureSet=1]="NotInFeatureSet",e[e.Unknown=2]="Unknown"}(s||(s={}));const P=1e3;function b(e){return function(r){e.reject(r)}}function x(e,r){return function(){try{e.apply(null,arguments)}catch(i){r.reject(i)}}}const N={point:"point",polygon:"polygon",polyline:"polyline",multipoint:"multipoint",extent:"extent",esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint",esriGeometryEnvelope:"extent",envelope:"extent"},E={point:"esriGeometryPoint",polygon:"esriGeometryPolygon",polyline:"esriGeometryPolyline",multipoint:"esriGeometryMultipoint",extent:"esriGeometryEnvelope",esriGeometryPoint:"esriGeometryPoint",esriGeometryPolygon:"esriGeometryPolygon",esriGeometryPolyline:"esriGeometryPolyline",esriGeometryMultipoint:"esriGeometryMultipoint",esriGeometryEnvelope:"esriGeometryEnvelope",envelope:"esriGeometryEnvelope"},k={"small-integer":"esriFieldTypeSmallInteger",integer:"esriFieldTypeInteger",long:"esriFieldTypeLong",single:"esriFieldTypeSingle",double:"esriFieldTypeDouble",string:"esriFieldTypeString",date:"esriFieldTypeDate","date-only":"esriFieldTypeDateOnly","time-only":"esriFieldTypeTimeOnly","timestamp-offset":"esriFieldTypeTimestampOffset",oid:"esriFieldTypeOID",geometry:"esriFieldTypeGeometry",blob:"esriFieldTypeBlob",raster:"esriFieldTypeRaster",guid:"esriFieldTypeGUID","global-id":"esriFieldTypeGlobalID",xml:"esriFieldTypeXML","big-integer":"esriFieldTypeBigInteger",esriFieldTypeSmallInteger:"esriFieldTypeSmallInteger",esriFieldTypeInteger:"esriFieldTypeInteger",esriFieldTypeLong:"esriFieldTypeLong",esriFieldTypeSingle:"esriFieldTypeSingle",esriFieldTypeDouble:"esriFieldTypeDouble",esriFieldTypeString:"esriFieldTypeString",esriFieldTypeDate:"esriFieldTypeDate",esriFieldTypeDateOnly:"esriFieldTypeDateOnly",esriFieldTypeTimeOnly:"esriFieldTypeTimeOnly",esriFieldTypeTimestampOffset:"esriFieldTypeTimestampOffset",esriFieldTypeOID:"esriFieldTypeOID",esriFieldTypeGeometry:"esriFieldTypeGeometry",esriFieldTypeBlob:"esriFieldTypeBlob",esriFieldTypeRaster:"esriFieldTypeRaster",esriFieldTypeGUID:"esriFieldTypeGUID",esriFieldTypeGlobalID:"esriFieldTypeGlobalID",esriFieldTypeXML:"esriFieldTypeXML",esriFieldTypeBigInteger:"esriFieldTypeBigInteger"};function w(e){switch(e){case"point":default:return"esriGeometryPoint";case"polygon":return"esriGeometryPolygon";case"multipoint":return"esriGeometryMultipoint";case"polyline":return"esriGeometryPolyline"}}function J(e){return void 0===e?"":e=(e=(e=e.replace(/\/featureserver\/[0-9]*/i,"/FeatureServer")).replace(/\/mapserver\/[0-9]*/i,"/MapServer")).split("?")[0]}function M(e,r){r||(r={}),"function"==typeof r&&(r={cmp:r});const i="boolean"==typeof r.cycles&&r.cycles,t=r.cmp&&(n=r.cmp,function(e){return function(r,i){const t={key:r,value:e[r]},o={key:i,value:e[i]};return n(t,o)}});var n;const o=[];return function e(r){if(r?.toJSON&&"function"==typeof r.toJSON&&(r=r.toJSON()),void 0===r)return;if("number"==typeof r)return isFinite(r)?""+r:"null";if("object"!=typeof r)return JSON.stringify(r);let n,l;if(Array.isArray(r)){for(l="[",n=0;n<r.length;n++)n&&(l+=","),l+=e(r[n])||"null";return l+"]"}if(null===r)return"null";if(o.includes(r)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const s=o.push(r)-1,y=Object.keys(r).sort(t?.(r));for(l="",n=0;n<y.length;n++){const i=y[n],t=e(r[i]);t&&(l&&(l+=","),l+=JSON.stringify(i)+":"+t)}return o.splice(s,1),"{"+l+"}"}(e)}export{l as FeatureServiceDatabaseType,s as IdState,x as callback,S as cloneAttributes,y as cloneField,I as convertLinearUnitsToCode,O as convertSquareUnitsToCode,P as defaultMaxRecords,G as equalityTest,b as errback,p as esriFieldToJson,J as extractServiceUrl,T as isArcadeDate,F as isArcadeDateOnly,g as isArcadeTime,c as isArray,m as isBoolean,f as isDate,d as isLuxonDate,a as isNumber,u as isString,k as layerFieldEsriConstants,N as layerGeometryEsriConstants,E as layerGeometryEsriRestConstants,D as sameGeomType,v as shapeExtent,M as stableStringify,w as toEsriGeometryType};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../../ArcadeDate.js";import{SqlError as r,SqlErrorCodes as t}from"./errorsupport.js";import{FeatureServiceDatabaseType as a,isDate as s,isLuxonDate as n,isArcadeTime as c,isArcadeDate as o,isArcadeDateOnly as i}from"./shared.js";import{TimeOnly as l}from"../../../core/sql/TimeOnly.js";import{WhereClause as u}from"../../../core/sql/WhereClause.js";import{DateTime as d}from"luxon";function f(e,r){return h(e?.parseTree,r,e?.parameters)}function p(e,r,t){return h(e,r,t)}function m(e,r,t,s){return u.create(h(e.parseTree,a.Standardised,e.parameters,r,t),s,e.timeZone)}function g(e,r,t="AND"){return u.create("(("+f(e,a.Standardised)+")"+t+"("+f(r,a.Standardised)+"))",e.fieldsIndex,e.timeZone)}function h(e,l,u,d=null,f=null){let p,m,g,I;switch(e.type){case"interval":return F(h(e.value,l,u,d,f),e.qualifier,e.op);case"case-expression":{let r=" CASE ";"simple"===e.format&&(r+=h(e.operand,l,u,d,f));for(let t=0;t<e.clauses.length;t++)r+=" WHEN "+h(e.clauses[t].operand,l,u,d,f)+" THEN "+h(e.clauses[t].value,l,u,d,f);return null!==e.else&&(r+=" ELSE "+h(e.else,l,u,d,f)),r+=" END ",r}case"parameter":{const r=u[e.value.toLowerCase()];if("string"==typeof r){return"'"+u[e.value.toLowerCase()].toString().replaceAll("'","''")+"'"}if(s(r))return w(r,l);if(n(r))return w(r,l);if(c(r))return E(r,l);if(o(r))return T(r,l);if(i(r))return S(r,l);if(r instanceof Array){const e=[];for(let t=0;t<r.length;t++)"string"==typeof r[t]?e.push("'"+r[t].toString().replaceAll("'","''")+"'"):s(r[t])||n(r[t])?e.push(w(r[t],l)):c(r[t])?e.push(E(r[t],l)):o(r[t])?e.push(T(r[t],l)):i(r[t])?e.push(S(r[t],l)):e.push(r[t].toString());return e}return r.toString()}case"expression-list":m=[];for(const r of e.value)m.push(h(r,l,u,d,f));return m;case"unary-expression":return" ( NOT "+h(e.expr,l,u,d,f)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+h(e.left,l,u,d,f)+" AND "+h(e.right,l,u,d,f)+") ";case"OR":return" ("+h(e.left,l,u,d,f)+" OR "+h(e.right,l,u,d,f)+") ";case"IS":if("null"!==e.right.type)throw new r(t.UnsupportedIsRhs);return" ("+h(e.left,l,u,d,f)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new r(t.UnsupportedIsRhs);return" ("+h(e.left,l,u,d,f)+" IS NOT NULL )";case"IN":return p=[],"expression-list"===e.right.type?(p=h(e.right,l,u,d,f)," ("+h(e.left,l,u,d,f)+" IN ("+p.join(",")+")) "):(I=h(e.right,l,u,d,f),I instanceof Array?" ("+h(e.left,l,u,d,f)+" IN ("+I.join(",")+")) ":" ("+h(e.left,l,u,d,f)+" IN ("+I+")) ");case"NOT IN":return p=[],"expression-list"===e.right.type?(p=h(e.right,l,u,d,f)," ("+h(e.left,l,u,d,f)+" NOT IN ("+p.join(",")+")) "):(I=h(e.right,l,u,d,f),I instanceof Array?" ("+h(e.left,l,u,d,f)+" NOT IN ("+I.join(",")+")) ":" ("+h(e.left,l,u,d,f)+" NOT IN ("+I+")) ");case"BETWEEN":return g=h(e.right,l,u,d,f)," ("+h(e.left,l,u,d,f)+" BETWEEN "+g[0]+" AND "+g[1]+" ) ";case"NOTBETWEEN":return g=h(e.right,l,u,d,f)," ("+h(e.left,l,u,d,f)+" NOT BETWEEN "+g[0]+" AND "+g[1]+" ) ";case"LIKE":return""!==e.escape?" ("+h(e.left,l,u,d,f)+" LIKE "+h(e.right,l,u,d,f)+" ESCAPE '"+e.escape+"') ":" ("+h(e.left,l,u,d,f)+" LIKE "+h(e.right,l,u,d,f)+") ";case"NOT LIKE":return""!==e.escape?" ("+h(e.left,l,u,d,f)+" NOT LIKE "+h(e.right,l,u,d,f)+" ESCAPE '"+e.escape+"') ":" ("+h(e.left,l,u,d,f)+" NOT LIKE "+h(e.right,l,u,d,f)+") ";case"<>":case"<":case">":case">=":case"<=":case"=":case"*":case"-":case"+":case"/":return" ("+h(e.left,l,u,d,f)+" "+e.operator+" "+h(e.right,l,u,d,f)+") ";case"||":return" ("+h(e.left,l,u,d,f)+" "+(l===a.SqlServer?"+":e.operator)+" "+h(e.right,l,u,d,f)+") "}throw new r(t.UnsupportedOperator,{operator:e.operator});case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return L("date"===e.mode,l);case"column-reference":return d?d.toLowerCase()===e.column.toLowerCase()?"("+f+")":!0===e.delimited?`"${e.column.split('"').join('""')}"`:e.column:e.column;case"data-type":return e.value;case"function":{const r=h(e.args,l,u,d,f);return y(e.name,r,l)}}throw new r(t.UnsupportedSyntax,{node:e.type})}function y(e,s,n){switch(e.toLowerCase().trim()){case"cos":case"sin":case"tan":case"cosh":case"tanh":case"sinh":case"acos":case"asin":case"atan":case"floor":case"log10":case"log":case"abs":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${s[0]})`;case"ceiling":case"ceil":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"ceiling"});switch(n){case a.Standardised:case a.StandardisedNoInterval:}return"CEILING("+s[0]+")";case"mod":case"power":case"nullif":if(2!==s.length)throw new r(t.InvalidFunctionParameters,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${s[0]},${s[1]})`;case"round":if(2===s.length)return"ROUND("+s[0]+","+s[1]+")";if(1===s.length)return"ROUND("+s[0]+")";throw new r(t.InvalidFunctionParameters,{function:"round"});case"truncate":if(s.length<1||s.length>2)throw new r(t.InvalidFunctionParameters,{function:"truncate"});return n===a.SqlServer?"ROUND("+s[0]+(1===s.length?"0":","+s[1])+",1)":"TRUNCATE("+s[0]+(1===s.length?")":","+s[1]+")");case"char_length":case"len":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"char_length"});switch(n){case a.SqlServer:return"LEN("+s[0]+")";case a.Oracle:return"LENGTH("+s[0]+")";default:return"CHAR_LENGTH("+s[0]+")"}case"coalesce":case"concat":{if(s.length<1)throw new r(t.InvalidFunctionParameters,{function:e.toLowerCase()});let a=e.toUpperCase().trim()+"(";for(let e=0;e<s.length;e++)0!==e&&(a+=","),a+=s[e];return a+=")",a}case"lower":case"lcase":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"lower"});return"LOWER("+s[0]+")";case"upper":case"ucase":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"upper"});return"UPPER("+s[0]+")";case"substring":{let e="";switch(n){case a.Oracle:return e="SUBSTR("+s[0]+","+s[1],3===s.length&&(e+=","+s[2]),e+=")",e;case a.SqlServer:return e=3===s.length?"SUBSTRING("+s[0]+","+s[1]+","+s[2]+")":"SUBSTRING("+s[0]+", "+s[1]+", LEN("+s[0]+") - "+s[1]+")",e;default:return e="SUBSTRING("+s[0]+" FROM "+s[1],3===s.length&&(e+=" FOR "+s[2]),e+=")",e}}case"extract":return"EXTRACT("+s[0].replaceAll("'","")+" FROM "+s[1]+")";case"cast":{let e="";switch(n){case a.Oracle:switch(s[1].type){case"date":e="DATE";break;case"float":e="DOUBLE";break;case"integer":e="INTEGER";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="TIMESTAMP";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`;case a.Postgres:switch(s[1].type){case"date":e="DATE";break;case"float":e="DOUBLE PRECISION";break;case"integer":e="INT";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="TIMESTAMP";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`;case a.SqlServer:switch(s[1].type){case"date":e="DATE";break;case"float":e="FLOAT";break;case"integer":e="INT";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="DATETIME";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`;default:switch(s[1].type){case"date":e="DATE";break;case"float":e="FLOAT";break;case"integer":e="INTEGER";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="TIMESTAMP";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`}}}throw new r(t.InvalidFunctionParameters,{function:e})}function T(e,r){const t=e.toDateTime(),s=0===t.hour&&0===t.minute&&0===t.second&&0===t.millisecond;switch(r){case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:return s?`date '${t.toFormat("yyyy-LL-dd")}'`:`timestamp '${t.toFormat("yyyy-LL-dd HH:mm:ss")}'`;case a.Oracle:return s?`TO_DATE('${t.toFormat("yyyy-LL-dd")}','YYYY-MM-DD')`:`TO_DATE('${t.toFormat("yyyy-LL-dd HH:mm:ss")}','YYYY-MM-DD HH24:MI:SS')`;case a.SqlServer:return`'${t.toFormat(s?"yyyy-LL-dd":"yyyy-LL-dd HH:mm:ss")}'`;case a.PGDB:return`#${t.toFormat(s?"LL-dd-yyyy":"LL-dd-yyyy HH:mm:ss")}#`;case a.Postgres:return`TIMESTAMP '${t.toFormat(s?"yyyy-LL-dd":"yyyy-LL-dd HH:mm:ss")}'`;default:return`timestamp '${t.toFormat("yyyy-LL-dd HH:mm:ss")}'`}}function S(e,r){switch(r){case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:return e.toSQLWithKeyword();case a.Oracle:return`TO_DATE('${e.toFormat("Y-MM-DD")}'`;case a.SqlServer:return`'${e.toFormat("Y-MM-DD")}'`;case a.PGDB:return`#${e.toFormat("Y-MM-DD")}#`;case a.Postgres:return`TIMESTAMP '${e.toFormat("Y-MM-DD")}'`;default:return e.toSQLWithKeyword()}}function E(e,r){switch(e instanceof l&&(e=e.toStorageString()),r){case a.Oracle:return`TO_DATE('${e}', 'HH24:MI:SS')`;case a.SqlServer:return`'${e}'`;case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:case a.Postgres:default:return`time '${e}'`}}function w(r,t){return T(e.dateTimeToArcadeDate(n(r)?r:d.fromJSDate(r)),t)}function L(e,r){switch(r){case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:case a.Oracle:return e?"CURRENT_DATE":"CURRENT_TIMESTAMP";case a.SqlServer:return e?"CAST(GETDATE() AS DATE)":"GETDATE()";case a.PGDB:case a.Postgres:default:return e?"CURRENT_DATE":"CURRENT_TIMESTAMP"}}function I(e,r,t={}){const a={},s={},n={esriFieldTypeSmallInteger:"integer",esriFieldTypeInteger:"integer",esriFieldTypeBigInteger:"integer",esriFieldTypeSingle:"double",esriFieldTypeDouble:"double",esriFieldTypeString:"string",esriFieldTypeTimeOnly:"time-only",esriFieldTypeDateOnly:"date-only",esriFieldTypeTimestampOffset:"timestamp-offset",esriFieldTypeDate:"date",esriFieldTypeOID:"integer",esriFieldTypeGUID:"guid",esriFieldTypeGlobalID:"guid",oid:"integer",long:"integer","small-integer":"integer",integer:"integer","big-integer":"integer",single:"double","time-only":"time-only","date-only":"date-only","timestamp-offset":"timestemp-offset",double:"double",date:"date",guid:"guid","global-id":"guid",string:"string"};for(const c of r){const e=c.type?n[c.type]:void 0;a[c.name.toLowerCase()]=void 0===e?"":e}for(const c in t){const e=n[t[c]];s[c.toLowerCase()]=void 0===e?"":e}switch(A(a,e.parseTree,e.parameters,s)){case"double":return"double";case"integer":return"integer";case"date":return"date";case"date-only":return"date-only";case"time-only":return"time-only";case"timestamp-offset":return"timestamp-offset";case"string":return"string";case"global-id":case"guid":return"guid"}return""}function A(e,a,n,l){let u;switch(a.type){case"interval":return"integer";case"case-expression":{const r=[];if("simple"===a.format){for(let t=0;t<a.clauses.length;t++)r.push(A(e,a.clauses[t].value,n,l));null!==a.else&&r.push(A(e,a.else,n,l))}else{for(let t=0;t<a.clauses.length;t++)r.push(A(e,a.else,n,l));null!==a.else&&r.push(A(e,a.else,n,l))}return b(r)}case"parameter":{const e=l[a.value.toLowerCase()];if(void 0===e&&n){const e=n[a.value.toLowerCase()];if(void 0===e)return"";if(null===e)return"";if("string"==typeof e||e instanceof String)return"string";if("boolean"==typeof e)return"boolean";if(s(e))return"date";if(o(e))return"date";if(i(e))return"date-only";if(c(e))return"time-only";if("number"==typeof e)return e%1==0?"integer":"double"}return void 0===e?"":e}case"expression-list":{const r=[];for(const t of a.value)r.push(A(e,t,n,l));return r}case"unary-expression":return"boolean";case"binary-expression":switch(a.operator){case"AND":case"OR":case"IN":case"NOT IN":case"BETWEEN":case"NOTBETWEEN":case"LIKE":case"NOT LIKE":case"<>":case"<":case">":case">=":case"<=":case"=":return"boolean";case"IS":case"ISNOT":if("null"!==a.right.type)throw new r(t.UnsupportedIsRhs);return"boolean";case"*":case"-":case"+":case"/":return b([A(e,a.left,n,l),A(e,a.right,n,l)]);case"||":return"string";default:throw new r(t.UnsupportedOperator,{operator:a.operator})}case"null":return"";case"boolean":return"boolean";case"string":return"string";case"number":return null===a.value?"":a.value%1==0?"integer":"double";case"date":return"date";case"timestamp":return a.withtimezone?"timestamp-offset":"date";case"time":return"time-only";case"current-time":return"date";case"column-reference":{const r=e[a.column.toLowerCase()];return void 0===r?"":r}case"function":switch(a.name.toLowerCase()){case"cast":switch(a.args?.value[1]?.value.type??""){case"integer":case"smallint":return"integer";case"real":case"float":return"double";case"date":case"timestamp":return!0===a.args?.value[1]?.value?.withtimezone?"timestamp-offset":"date";case"time":return"time-only";case"varchar":return"string";default:return""}case"position":case"extract":case"char_length":case"mod":return"integer";case"round":if(u=A(e,a.args,n,l),u instanceof Array){if(u.length<=0)return"double";u=u[0]}return u;case"sign":return"integer";case"ceiling":case"floor":case"abs":return u=A(e,a.args,n,l),u instanceof Array&&(u=b(u)),"integer"===u||"double"===u?u:"double";case"area":case"length":case"log":case"log10":case"sin":case"cos":case"tan":case"asin":case"acos":case"atan":case"cosh":case"sinh":case"tanh":case"power":return"double";case"substring":case"trim":case"concat":case"lower":case"upper":return"string";case"truncate":return"double";case"nullif":case"coalesce":return u=A(e,a.args,n,l),u instanceof Array?u.length>0?u[0]:"":u}return""}throw new r(t.UnsupportedSyntax,{node:a.type})}const N={boolean:1,string:2,integer:3,double:4,date:5};function b(e){if(e){let r="";for(const t of e)""!==t&&(r=""===r||N[r]<N[t]?t:r);return r}return""}function v(e,r){return O(e.parseTree,r)}function D(e){return"column-reference"===e?.parseTree.type}function O(e,r){if(null==e)return!1;switch(e.type){case"when-clause":return O(e.operand,r)||O(e.value,r);case"case-expression":for(const t of e.clauses)if(O(t,r))return!0;return!("simple"!==e.format||!O(e.operand,r))||!(null===e.else||!O(e.else,r));case"parameter":case"null":case"boolean":case"date":case"timestamp":case"time":case"string":case"number":return!1;case"expression-list":for(const t of e.value)if(O(t,r))return!0;return!1;case"unary-expression":return O(e.expr,r);case"binary-expression":return O(e.left,r)||O(e.right,r);case"column-reference":return r.toLowerCase()===e.column.toLowerCase();case"function":return O(e.args,r)}return!1}function R(e){let r="";return r+=e.period.toUpperCase(),r}function F(e,r,t){let a="";return a="interval-period"===r.type?R(r):R(r.start)+" TO "+R(r.end),"INTERVAL "+t+" "+e+" "+a}export{S as arcadeDateOnlyToSqlString,T as arcadeDateToSqlString,g as combine,F as convertIntervalToSql,D as isSingleField,w as makeSqlFromDateTimeParameter,E as makeTimeString,L as makeToday,I as predictType,m as reformulateWithoutField,v as scanForField,f as toWhereClause,p as toWhereClauseFromTree,y as translateFunctionToDatabaseSpecific};
5
+ import{ArcadeDate as e}from"../../ArcadeDate.js";import{SqlError as r,SqlErrorCodes as t}from"./errorsupport.js";import{FeatureServiceDatabaseType as a,isDate as s,isLuxonDate as n,isArcadeTime as c,isArcadeDate as i,isArcadeDateOnly as o}from"./shared.js";import{TimeOnly as l}from"../../../core/sql/TimeOnly.js";import{WhereClause as u}from"../../../core/sql/WhereClause.js";import{DateTime as d}from"luxon";function p(e,r){return h(e?.parseTree,r,e?.parameters)}function f(e,r,t){return h(e,r,t)}function m(e,r,t,s){return u.create(h(e.parseTree,a.Standardised,e.parameters,r,t),s,e.timeZone)}function g(e,r,t="AND"){return u.create("(("+p(e,a.Standardised)+")"+t+"("+p(r,a.Standardised)+"))",e.fieldsIndex,e.timeZone)}function h(e,l,u,d=null,p=null){let f,m,g,L;switch(e.type){case"interval":return F(h(e.value,l,u,d,p),e.qualifier,e.op);case"case-expression":{let r=" CASE ";"simple"===e.format&&(r+=h(e.operand,l,u,d,p));for(let t=0;t<e.clauses.length;t++)r+=" WHEN "+h(e.clauses[t].operand,l,u,d,p)+" THEN "+h(e.clauses[t].value,l,u,d,p);return null!==e.else&&(r+=" ELSE "+h(e.else,l,u,d,p)),r+=" END ",r}case"parameter":{const r=u[e.value.toLowerCase()];if("string"==typeof r){return"'"+u[e.value.toLowerCase()].toString().replaceAll("'","''")+"'"}if(s(r))return w(r,l);if(n(r))return w(r,l);if(c(r))return E(r,l);if(i(r))return T(r,l);if(o(r))return S(r,l);if(Array.isArray(r)){const e=[];for(let t=0;t<r.length;t++)"string"==typeof r[t]?e.push("'"+r[t].toString().replaceAll("'","''")+"'"):s(r[t])||n(r[t])?e.push(w(r[t],l)):c(r[t])?e.push(E(r[t],l)):i(r[t])?e.push(T(r[t],l)):o(r[t])?e.push(S(r[t],l)):e.push(r[t].toString());return e}return r.toString()}case"expression-list":m=[];for(const r of e.value)m.push(h(r,l,u,d,p));return m;case"unary-expression":return" ( NOT "+h(e.expr,l,u,d,p)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+h(e.left,l,u,d,p)+" AND "+h(e.right,l,u,d,p)+") ";case"OR":return" ("+h(e.left,l,u,d,p)+" OR "+h(e.right,l,u,d,p)+") ";case"IS":if("null"!==e.right.type)throw new r(t.UnsupportedIsRhs);return" ("+h(e.left,l,u,d,p)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new r(t.UnsupportedIsRhs);return" ("+h(e.left,l,u,d,p)+" IS NOT NULL )";case"IN":return f=[],"expression-list"===e.right.type?(f=h(e.right,l,u,d,p)," ("+h(e.left,l,u,d,p)+" IN ("+f.join(",")+")) "):(L=h(e.right,l,u,d,p),Array.isArray(L)?" ("+h(e.left,l,u,d,p)+" IN ("+L.join(",")+")) ":" ("+h(e.left,l,u,d,p)+" IN ("+L+")) ");case"NOT IN":return f=[],"expression-list"===e.right.type?(f=h(e.right,l,u,d,p)," ("+h(e.left,l,u,d,p)+" NOT IN ("+f.join(",")+")) "):(L=h(e.right,l,u,d,p),Array.isArray(L)?" ("+h(e.left,l,u,d,p)+" NOT IN ("+L.join(",")+")) ":" ("+h(e.left,l,u,d,p)+" NOT IN ("+L+")) ");case"BETWEEN":return g=h(e.right,l,u,d,p)," ("+h(e.left,l,u,d,p)+" BETWEEN "+g[0]+" AND "+g[1]+" ) ";case"NOTBETWEEN":return g=h(e.right,l,u,d,p)," ("+h(e.left,l,u,d,p)+" NOT BETWEEN "+g[0]+" AND "+g[1]+" ) ";case"LIKE":return""!==e.escape?" ("+h(e.left,l,u,d,p)+" LIKE "+h(e.right,l,u,d,p)+" ESCAPE '"+e.escape+"') ":" ("+h(e.left,l,u,d,p)+" LIKE "+h(e.right,l,u,d,p)+") ";case"NOT LIKE":return""!==e.escape?" ("+h(e.left,l,u,d,p)+" NOT LIKE "+h(e.right,l,u,d,p)+" ESCAPE '"+e.escape+"') ":" ("+h(e.left,l,u,d,p)+" NOT LIKE "+h(e.right,l,u,d,p)+") ";case"<>":case"<":case">":case">=":case"<=":case"=":case"*":case"-":case"+":case"/":return" ("+h(e.left,l,u,d,p)+" "+e.operator+" "+h(e.right,l,u,d,p)+") ";case"||":return" ("+h(e.left,l,u,d,p)+" "+(l===a.SqlServer?"+":e.operator)+" "+h(e.right,l,u,d,p)+") "}throw new r(t.UnsupportedOperator,{operator:e.operator});case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return A("date"===e.mode,l);case"column-reference":return d?d.toLowerCase()===e.column.toLowerCase()?"("+p+")":!0===e.delimited?`"${e.column.split('"').join('""')}"`:e.column:e.column;case"data-type":return e.value;case"function":{const r=h(e.args,l,u,d,p);return y(e.name,r,l)}}throw new r(t.UnsupportedSyntax,{node:e.type})}function y(e,s,n){switch(e.toLowerCase().trim()){case"cos":case"sin":case"tan":case"cosh":case"tanh":case"sinh":case"acos":case"asin":case"atan":case"floor":case"log10":case"log":case"abs":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${s[0]})`;case"ceiling":case"ceil":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"ceiling"});switch(n){case a.Standardised:case a.StandardisedNoInterval:}return"CEILING("+s[0]+")";case"mod":case"power":case"nullif":if(2!==s.length)throw new r(t.InvalidFunctionParameters,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${s[0]},${s[1]})`;case"round":if(2===s.length)return"ROUND("+s[0]+","+s[1]+")";if(1===s.length)return"ROUND("+s[0]+")";throw new r(t.InvalidFunctionParameters,{function:"round"});case"truncate":if(s.length<1||s.length>2)throw new r(t.InvalidFunctionParameters,{function:"truncate"});return n===a.SqlServer?"ROUND("+s[0]+(1===s.length?"0":","+s[1])+",1)":"TRUNCATE("+s[0]+(1===s.length?")":","+s[1]+")");case"char_length":case"len":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"char_length"});switch(n){case a.SqlServer:return"LEN("+s[0]+")";case a.Oracle:return"LENGTH("+s[0]+")";default:return"CHAR_LENGTH("+s[0]+")"}case"coalesce":case"concat":{if(s.length<1)throw new r(t.InvalidFunctionParameters,{function:e.toLowerCase()});let a=e.toUpperCase().trim()+"(";for(let e=0;e<s.length;e++)0!==e&&(a+=","),a+=s[e];return a+=")",a}case"lower":case"lcase":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"lower"});return"LOWER("+s[0]+")";case"upper":case"ucase":if(1!==s.length)throw new r(t.InvalidFunctionParameters,{function:"upper"});return"UPPER("+s[0]+")";case"substring":{let e="";switch(n){case a.Oracle:return e="SUBSTR("+s[0]+","+s[1],3===s.length&&(e+=","+s[2]),e+=")",e;case a.SqlServer:return e=3===s.length?"SUBSTRING("+s[0]+","+s[1]+","+s[2]+")":"SUBSTRING("+s[0]+", "+s[1]+", LEN("+s[0]+") - "+s[1]+")",e;default:return e="SUBSTRING("+s[0]+" FROM "+s[1],3===s.length&&(e+=" FOR "+s[2]),e+=")",e}}case"extract":return"EXTRACT("+s[0].replaceAll("'","")+" FROM "+s[1]+")";case"cast":{let e="";switch(n){case a.Oracle:switch(s[1].type){case"date":e="DATE";break;case"float":e="DOUBLE";break;case"integer":e="INTEGER";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="TIMESTAMP";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`;case a.Postgres:switch(s[1].type){case"date":e="DATE";break;case"float":e="DOUBLE PRECISION";break;case"integer":e="INT";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="TIMESTAMP";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`;case a.SqlServer:switch(s[1].type){case"date":e="DATE";break;case"float":e="FLOAT";break;case"integer":e="INT";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="DATETIME";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`;default:switch(s[1].type){case"date":e="DATE";break;case"float":e="FLOAT";break;case"integer":e="INTEGER";break;case"real":e="REAL";break;case"smallint":e="SMALLINT";break;case"timestamp":e="TIMESTAMP";break;case"varchar":e="VARCHAR("+s[1].size.toString()+")"}return`CAST(${s[0]} AS ${e})`}}}throw new r(t.InvalidFunctionParameters,{function:e})}function T(e,r){const t=e.toDateTime(),s=0===t.hour&&0===t.minute&&0===t.second&&0===t.millisecond;switch(r){case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:return s?`date '${t.toFormat("yyyy-LL-dd")}'`:`timestamp '${t.toFormat("yyyy-LL-dd HH:mm:ss")}'`;case a.Oracle:return s?`TO_DATE('${t.toFormat("yyyy-LL-dd")}','YYYY-MM-DD')`:`TO_DATE('${t.toFormat("yyyy-LL-dd HH:mm:ss")}','YYYY-MM-DD HH24:MI:SS')`;case a.SqlServer:return`'${t.toFormat(s?"yyyy-LL-dd":"yyyy-LL-dd HH:mm:ss")}'`;case a.PGDB:return`#${t.toFormat(s?"LL-dd-yyyy":"LL-dd-yyyy HH:mm:ss")}#`;case a.Postgres:return`TIMESTAMP '${t.toFormat(s?"yyyy-LL-dd":"yyyy-LL-dd HH:mm:ss")}'`;default:return`timestamp '${t.toFormat("yyyy-LL-dd HH:mm:ss")}'`}}function S(e,r){switch(r){case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:return e.toSQLWithKeyword();case a.Oracle:return`TO_DATE('${e.toFormat("Y-MM-DD")}'`;case a.SqlServer:return`'${e.toFormat("Y-MM-DD")}'`;case a.PGDB:return`#${e.toFormat("Y-MM-DD")}#`;case a.Postgres:return`TIMESTAMP '${e.toFormat("Y-MM-DD")}'`;default:return e.toSQLWithKeyword()}}function E(e,r){switch(e instanceof l&&(e=e.toStorageString()),r){case a.Oracle:return`TO_DATE('${e}', 'HH24:MI:SS')`;case a.SqlServer:return`'${e}'`;case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:case a.Postgres:default:return`time '${e}'`}}function w(r,t){return T(e.dateTimeToArcadeDate(n(r)?r:d.fromJSDate(r)),t)}function A(e,r){switch(r){case a.FILEGDB:case a.Standardised:case a.StandardisedNoInterval:case a.Oracle:return e?"CURRENT_DATE":"CURRENT_TIMESTAMP";case a.SqlServer:return e?"CAST(GETDATE() AS DATE)":"GETDATE()";case a.PGDB:case a.Postgres:default:return e?"CURRENT_DATE":"CURRENT_TIMESTAMP"}}function L(e,r,t={}){const a={},s={},n={esriFieldTypeSmallInteger:"integer",esriFieldTypeInteger:"integer",esriFieldTypeBigInteger:"integer",esriFieldTypeSingle:"double",esriFieldTypeDouble:"double",esriFieldTypeString:"string",esriFieldTypeTimeOnly:"time-only",esriFieldTypeDateOnly:"date-only",esriFieldTypeTimestampOffset:"timestamp-offset",esriFieldTypeDate:"date",esriFieldTypeOID:"integer",esriFieldTypeGUID:"guid",esriFieldTypeGlobalID:"guid",oid:"integer",long:"integer","small-integer":"integer",integer:"integer","big-integer":"integer",single:"double","time-only":"time-only","date-only":"date-only","timestamp-offset":"timestemp-offset",double:"double",date:"date",guid:"guid","global-id":"guid",string:"string"};for(const c of r){const e=c.type?n[c.type]:void 0;a[c.name.toLowerCase()]=void 0===e?"":e}for(const c in t){const e=n[t[c]];s[c.toLowerCase()]=void 0===e?"":e}switch(I(a,e.parseTree,e.parameters,s)){case"double":return"double";case"integer":return"integer";case"date":return"date";case"date-only":return"date-only";case"time-only":return"time-only";case"timestamp-offset":return"timestamp-offset";case"string":return"string";case"global-id":case"guid":return"guid"}return""}function I(e,a,n,l){let u;switch(a.type){case"interval":return"integer";case"case-expression":{const r=[];if("simple"===a.format){for(let t=0;t<a.clauses.length;t++)r.push(I(e,a.clauses[t].value,n,l));null!==a.else&&r.push(I(e,a.else,n,l))}else{for(let t=0;t<a.clauses.length;t++)r.push(I(e,a.else,n,l));null!==a.else&&r.push(I(e,a.else,n,l))}return b(r)}case"parameter":{const e=l[a.value.toLowerCase()];if(void 0===e&&n){const e=n[a.value.toLowerCase()];if(void 0===e)return"";if(null===e)return"";if("string"==typeof e||e instanceof String)return"string";if("boolean"==typeof e)return"boolean";if(s(e))return"date";if(i(e))return"date";if(o(e))return"date-only";if(c(e))return"time-only";if("number"==typeof e)return e%1==0?"integer":"double"}return void 0===e?"":e}case"expression-list":{const r=[];for(const t of a.value)r.push(I(e,t,n,l));return r}case"unary-expression":return"boolean";case"binary-expression":switch(a.operator){case"AND":case"OR":case"IN":case"NOT IN":case"BETWEEN":case"NOTBETWEEN":case"LIKE":case"NOT LIKE":case"<>":case"<":case">":case">=":case"<=":case"=":return"boolean";case"IS":case"ISNOT":if("null"!==a.right.type)throw new r(t.UnsupportedIsRhs);return"boolean";case"*":case"-":case"+":case"/":return b([I(e,a.left,n,l),I(e,a.right,n,l)]);case"||":return"string";default:throw new r(t.UnsupportedOperator,{operator:a.operator})}case"null":return"";case"boolean":return"boolean";case"string":return"string";case"number":return null===a.value?"":a.value%1==0?"integer":"double";case"date":return"date";case"timestamp":return a.withtimezone?"timestamp-offset":"date";case"time":return"time-only";case"current-time":return"date";case"column-reference":{const r=e[a.column.toLowerCase()];return void 0===r?"":r}case"function":switch(a.name.toLowerCase()){case"cast":switch(a.args?.value[1]?.value.type??""){case"integer":case"smallint":return"integer";case"real":case"float":return"double";case"date":case"timestamp":return!0===a.args?.value[1]?.value?.withtimezone?"timestamp-offset":"date";case"time":return"time-only";case"varchar":return"string";default:return""}case"position":case"extract":case"char_length":case"mod":return"integer";case"round":if(u=I(e,a.args,n,l),Array.isArray(u)){if(u.length<=0)return"double";u=u[0]}return u;case"sign":return"integer";case"ceiling":case"floor":case"abs":return u=I(e,a.args,n,l),Array.isArray(u)&&(u=b(u)),"integer"===u||"double"===u?u:"double";case"area":case"length":case"log":case"log10":case"sin":case"cos":case"tan":case"asin":case"acos":case"atan":case"cosh":case"sinh":case"tanh":case"power":return"double";case"substring":case"trim":case"concat":case"lower":case"upper":return"string";case"truncate":return"double";case"nullif":case"coalesce":return u=I(e,a.args,n,l),Array.isArray(u)?u.length>0?u[0]:"":u}return""}throw new r(t.UnsupportedSyntax,{node:a.type})}const N={boolean:1,string:2,integer:3,double:4,date:5};function b(e){if(e){let r="";for(const t of e)""!==t&&(r=""===r||N[r]<N[t]?t:r);return r}return""}function v(e,r){return O(e.parseTree,r)}function D(e){return"column-reference"===e?.parseTree.type}function O(e,r){if(null==e)return!1;switch(e.type){case"when-clause":return O(e.operand,r)||O(e.value,r);case"case-expression":for(const t of e.clauses)if(O(t,r))return!0;return!("simple"!==e.format||!O(e.operand,r))||!(null===e.else||!O(e.else,r));case"parameter":case"null":case"boolean":case"date":case"timestamp":case"time":case"string":case"number":return!1;case"expression-list":for(const t of e.value)if(O(t,r))return!0;return!1;case"unary-expression":return O(e.expr,r);case"binary-expression":return O(e.left,r)||O(e.right,r);case"column-reference":return r.toLowerCase()===e.column.toLowerCase();case"function":return O(e.args,r)}return!1}function R(e){let r="";return r+=e.period.toUpperCase(),r}function F(e,r,t){let a="";return a="interval-period"===r.type?R(r):R(r.start)+" TO "+R(r.end),"INTERVAL "+t+" "+e+" "+a}export{S as arcadeDateOnlyToSqlString,T as arcadeDateToSqlString,g as combine,F as convertIntervalToSql,D as isSingleField,w as makeSqlFromDateTimeParameter,E as makeTimeString,A as makeToday,L as predictType,m as reformulateWithoutField,v as scanForField,p as toWhereClause,f as toWhereClauseFromTree,y as translateFunctionToDatabaseSpecific};
package/arcade/parser.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{findScriptDependencies as o}from"./treeAnalysis.js";import{parse as r}from"./lib/arcade-parser.js";import{ParsingError as e,ParsingErrorCodes as i}from"./lib/types.js";function n(n,d=[]){const l=r(n);if(null===l.body||void 0===l.body)throw new e({index:0,line:0,column:0,data:null,description:"",code:i.InvalidExpression});return l.loadedModules={},o(l,d),l}export{n as parseScript};
5
+ import{r as o,T as n,o as e}from"../chunks/index.js";import{findScriptDependencies as i}from"./treeAnalysis.js";function d(d,r=[]){const s=o(d);if(null===s.body||void 0===s.body)throw new n({index:0,line:0,column:0,data:null,description:"",code:e.InvalidExpression});return s.loadedModules={},i(s,r),s}export{d as parseScript};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{parse as e}from"../lib/arcade-parser.js";import{DiagnosticCodes as i,diagnosticMessages as t}from"./diagnosticMessages.js";import{arcadeReservedKeywords as n}from"./languageKeywords.js";import{DiagnosticSeverity as s}from"./types.js";import{parsingErrorMessages as a,Syntax as o,isVariableDeclaration as r,isIdentifier as d,isEmptyStatement as c,isBlockStatement as l}from"../lib/types.js";function h(e,i){return i?e.replaceAll(/\${(.*?)}/g,((e,t)=>i[t]?.toString()??"")):e}function f(e){return!!e&&"dictionary"!==e.type}class p{constructor(e,i=[]){this._apiDefinitions=e,this._profileVariables=i,this._isInBlock=!1,this._identifierBeingAssigned=void 0,this._assignmentValidationMode="disabled",this._scriptScopeIdentifiers=new Map,this._diagnostics=new Array,this._undeclaredIdentifiersInFunctions=new Map}validateScript(t){if(!t)return{diagnostics:[],program:null};this._isInBlock=!1,this._identifierBeingAssigned=void 0,this._assignmentValidationMode="disabled",this._diagnostics=[],this._scriptScopeIdentifiers.clear(),this._undeclaredIdentifiersInFunctions.clear(),this._functionScopeIdentifiers=void 0;let n=null;try{n=e(t,{tolerant:!0}),this.handleErrors(n.errors),n.body.forEach((e=>this.validateStatement(e))),this.diagnoseIdentifiers(),this._undeclaredIdentifiersInFunctions.size>0&&this._undeclaredIdentifiersInFunctions.forEach((e=>{for(const t of e)this.logDiagnostic(t.node.loc,{code:i.NotDefined,data:{identifier:t.node.name}})}))}catch(s){this.handleException(s)}return{diagnostics:this._diagnostics,program:n}}disableRecordIdentifierAssignment(e,i){const t=this._assignmentValidationMode;this._assignmentValidationMode="disabled",e.call(this,i),this._assignmentValidationMode=t}inBlock(e,i){const t=this._isInBlock;this._isInBlock=!0,e.call(this,i),this._isInBlock=t}get _isInFunctionScope(){return!!this._functionScopeIdentifiers}inFunctionScope(e){this._functionScopeIdentifiers=new Map,e.call(this),this.diagnoseIdentifiers(),this._functionScopeIdentifiers=void 0}logDiagnostic(e,i){const n={severity:s.Error,...i,message:h(t[i.code]??a[i.code],i.data),range:{start:{line:e.start.line-1,character:e.start.column},end:{line:e.end.line-1,character:e.end.column}}};this._diagnostics.push(n)}handleErrors(e){(e??[]).forEach(this.handleException,this)}handleException(e){if(g(e)){const{range:i,code:t,data:n}=e;this.logDiagnostic(i,{code:t,data:n})}else this.logDiagnostic({start:{line:1,column:0},end:{line:1,column:0}},{code:i.ExecutionError,data:{stack:e.stack}})}getIdentifierInfo(e){return this._functionScopeIdentifiers?.get(e)??this._scriptScopeIdentifiers.get(e)}setIdentiferInfo(e,i){this._functionScopeIdentifiers?this._functionScopeIdentifiers.set(e,i):((this._functionScopeIdentifiers??this._scriptScopeIdentifiers).set(e,i),this._functionScopeIdentifiers||this._undeclaredIdentifiersInFunctions.has(e)&&(this._undeclaredIdentifiersInFunctions.delete(e),i.used=!0))}isProfileVariable(e){return(this._profileVariables??[]).some((i=>i.name.toLowerCase()===e))}isApiItem(e){const i=!!this._apiDefinitions?.constantDefinitions?.get(e),t=!!this._apiDefinitions?.functionDefinitions?.get(e);return i||t}validateStatement(e){if(e)switch(e.type){case o.BlockStatement:return void e.body.forEach((e=>this.validateStatement(e)));case o.VariableDeclaration:return void e.declarations.forEach((e=>this.validateVariableDeclarator(e)));case o.FunctionDeclaration:return void this.validateFunctionDeclaration(e);case o.ExportNamedDeclaration:return void this.validateExportDeclaration(e);case o.ImportDeclaration:return void this.validateImportDeclaration(e);case o.WhileStatement:return void this.validateWhileStatement(e);case o.ForStatement:return void this.validateForStatement(e);case o.ForInStatement:return void this.validateForInStatement(e);case o.IfStatement:return void this.validateIfStatement(e);case o.ReturnStatement:return void this.validateExpression(e.argument);case o.ExpressionStatement:return void this.validateExpression(e.expression);case o.BreakStatement:case o.ContinueStatement:case o.EmptyStatement:return}}validateVariableDeclarator(e){this.validateExpression(e.init),this.recordVariableIdentifier(e.id,{initialized:!!e.init})}validateFunctionDeclaration(e){this.recordFunctionIdentifier(e),this.inFunctionScope((()=>{e.params.forEach((e=>this.recordParamAsIdentifier(e))),m(e.body)&&this.logDiagnostic(e.body.loc,{code:i.UnexpectedEmptyFunction,data:{identifier:e.id.name},severity:s.Warning}),this.validateStatement(e.body)}))}validateExportDeclaration(e){this.validateStatement(e.declaration)}validateImportDeclaration(e){this.recordImportIdentifier(e)}validateForStatement(e){r(e.init)?this.inBlock(this.validateStatement,e.init):this.validateExpression(e.init),this.validateExpression(e.update),this.validateExpression(e.test),m(e.body)&&this.logDiagnostic(e.body.loc,{code:i.EmptyBlockStatement,severity:s.Warning}),this.inBlock(this.validateStatement,e.body)}validateWhileStatement(e){this.validateExpression(e.test),m(e.body)&&this.logDiagnostic(e.body.loc,{code:i.EmptyBlockStatement,severity:s.Warning}),this.inBlock(this.validateStatement,e.body)}validateForInStatement(e){d(e.left)?this.validateExpression(e.left):this.recordVariableIdentifier(e.left.declarations[0].id,{initialized:!0,inBlock:!0}),this.validateExpression(e.right),m(e.body)&&this.logDiagnostic(e.body.loc,{code:i.EmptyBlockStatement,severity:s.Warning}),this.validateStatement(e.body)}validateIfStatement(e){this.validateExpression(e.test),m(e.consequent)&&this.logDiagnostic(e.consequent.loc,{code:i.EmptyBlockStatement,severity:s.Warning}),e.alternate&&m(e.alternate)&&this.logDiagnostic(e.alternate.loc,{code:i.EmptyBlockStatement,severity:s.Warning}),this.inBlock(this.validateStatement,e.consequent),this.inBlock(this.validateStatement,e.alternate)}validateExpression(e){if(e)switch(e.type){case o.AssignmentExpression:return void this.validateAssignmentExpression(e);case o.CallExpression:return void this.validateCallExpression(e);case o.Identifier:return void this.validateIdentifier(e);case o.Literal:return void this.validateLiteral(e);case o.ArrayExpression:return void e.elements.forEach((e=>this.validateExpression(e)));case o.ObjectExpression:return void this.validateObjectExpression(e);case o.UnaryExpression:return void this.validateUnaryExpression(e);case o.UpdateExpression:return void this.validateUpdateExpression(e);case o.BinaryExpression:case o.LogicalExpression:return void this.validateBinaryAndLogicalExpression(e);case o.MemberExpression:return void this.validateMemberExpression(e);case o.TemplateLiteral:return void e.expressions.forEach((e=>this.validateExpression(e)));default:return}}validateAssignmentExpression(e){const i=this._identifierBeingAssigned,t=this._assignmentValidationMode;d(e.left)&&(this._identifierBeingAssigned=e.left.name.toLowerCase(),this._assignmentValidationMode="left"),this.validateExpression(e.left),d(e.left)&&(this._assignmentValidationMode="right"),this.validateExpression(e.right),this._identifierBeingAssigned=i,this._assignmentValidationMode=t}validateCallExpression(e){if(this.validateExpression(e.callee),d(e.callee)){const i=e.callee.name.toLowerCase(),t=this.getIdentifierInfo(i),n=this._apiDefinitions?.functionDefinitions?.get(i);if(!t&&n){const i=u(n,e.arguments.length);i&&this.logDiagnostic(e.loc,i)}}e.arguments.forEach((e=>this.validateExpression(e)))}validateIdentifier(e){const t=e.name.toLowerCase(),n=this.getIdentifierInfo(t);if(n){if("left"===this._assignmentValidationMode&&this._identifierBeingAssigned===t)return void(n.initialized=!0);if("right"===this._assignmentValidationMode&&this._identifierBeingAssigned===t)return;n.used=!0}else if(!this.isProfileVariable(t)&&!this.isApiItem(t)){if(this._isInFunctionScope){let i=this._undeclaredIdentifiersInFunctions.get(t);return i||(i=[],this._undeclaredIdentifiersInFunctions.set(t,i)),void i.push({node:e,identifier:t})}this.logDiagnostic(e.loc,{code:i.NotDefined,data:{identifier:e.name}})}}validateLiteral(e){I(e.raw).forEach((e=>{const i=this.getIdentifierInfo(e.toLowerCase());i&&(i.used=!0)}))}logProfileOrApiConflict(e){const t=e.name.toLowerCase(),n=this.isProfileVariable(t),a=this.isApiItem(t);(n||a)&&this.logDiagnostic(e.loc,{code:n?i.ProfileVariablesConflict:i.ApiConflict,severity:s.Warning,data:{identifier:e.name}})}logReservedKeywordsConflict(e){const t=e.name.toLowerCase();n.includes(t)&&this.logDiagnostic(e.loc,{code:i.ReservedKeyword,severity:s.Warning,data:{identifier:e.name}})}validateObjectExpression(e){e.properties.forEach((e=>{this.validateExpression(e.value)}))}validateUnaryExpression(e){this.validateExpression(e.argument)}validateUpdateExpression(e){this.validateExpression(e.argument)}validateBinaryAndLogicalExpression(e){this.validateExpression(e.left),this.validateExpression(e.right)}validateMemberExpression(e){const i=this.flattenMemberExpressionAndValidate(e),t=i[0].object;this.disableRecordIdentifierAssignment(this.validateExpression,t),d(t)&&(this.getIdentifierInfo(t.name.toLowerCase())||this.validateMemberExpressionWithProfile(i)||this.validateConstantMemberExpression(i))}flattenMemberExpressionAndValidate(e){return e.type===o.MemberExpression?(d(e.property)&&!e.computed||this.validateExpression(e.property),[...this.flattenMemberExpressionAndValidate(e.object),e]):[]}extractAndValidatePropertyName(e){switch(e.type){case"Identifier":return e.name.toLowerCase();case"Literal":return"string"!=typeof e.value?(this.logDiagnostic(e.loc,{code:i.UnexpectedPropertyIdentifier}),null):e.value.toLowerCase();default:return this.logDiagnostic(e.loc,{code:i.UnexpectedPropertyIdentifier}),null}}validateConstantMemberExpression(e){const t=e[0];if(!d(t.object))return!1;const n=t.object.name.toLowerCase(),s=this._apiDefinitions?.constantDefinitions?.get(n);if(!s)return!1;if("namespace"!==s.type)return this.logDiagnostic(t.property.loc,{code:i.NotADictionary,data:{identifier:n}}),!0;const a=this.extractAndValidatePropertyName(t.property);if(!a)return!0;if(!s.members.some((e=>e.key===a))){const e=s.members.reduce(((e,i)=>`${e}${e?" | ":""}${i.completion.label.split(".").pop()}`),"");this.logDiagnostic(t.property.loc,{code:i.InvalidConstantIdentifier,data:{list:e}})}return e.length>1&&this.logDiagnostic(e[1].property.loc,{code:i.UnexpectedPropertyIdentifier}),!0}validateMemberExpressionWithProfile(e){const t=e[0];if(t.object.type!==o.Identifier)return!1;const n=t.object.name.toLowerCase(),a=this._profileVariables?.find((e=>e.key===n));if(!a)return!1;if(f(a))return this.logDiagnostic(t.object.loc,{code:i.NotADictionary,data:{identifier:a.name}}),!0;if(this._identifierBeingAssigned===n)return this.logDiagnostic(t.loc,{code:i.ProfileVariablesAreImmutable}),!0;let r=a;for(let o=0;o<e.length;o++){if(e[o].computed)return!0;if(f(r))return this.logDiagnostic(e[o-1]?.property.loc??e[o].object.loc,{code:i.NotADictionary,data:{identifier:r.name}}),!0;const t=this.extractAndValidatePropertyName(e[o].property);if(!t)return!0;if(0===r.properties.length)return this.logDiagnostic(e[o].property.loc,{code:i.UnknownPropertyIdentifier,data:{identifier:t},severity:s.Warning}),!0;const n=r.properties.find((e=>e.name.toLowerCase()===t));if(!n){const t=r.properties.reduce(((e,i)=>`${e}${e?" | ":""}${i.name.split(".").pop()}`),"");return this.logDiagnostic(e[o].property.loc,{code:i.InvalidPropertyIdentifier,data:{list:t}}),!0}r=n}return!0}recordVariableIdentifier(e,t){this.logReservedKeywordsConflict(e),this.logProfileOrApiConflict(e);const n=e.name.toLowerCase();let a=this.getIdentifierInfo(n);const o=a&&this._isInFunctionScope&&"function"===a.scope,r=a&&!this._isInFunctionScope&&"script"===a.scope;(o||r)&&this.logDiagnostic(e.loc,{code:i.AlreadyDefined,data:{identifier:e.name},severity:s.Warning});const d=t.inBlock??this._isInBlock,{initialized:c}=t;if(!a||this._isInFunctionScope&&"function"!==a.scope){a={node:e,used:!1,initialized:c,scope:this._isInFunctionScope?"function":d?"block":"script"}}else a.node=e,a.used=!1,a.initialized=c;return"block"!==a.scope||d||(a.scope="script",this.logDiagnostic(e.loc,{code:i.AlreadyDefined,data:{identifier:e.name},severity:s.Warning})),this.setIdentiferInfo(n,a),!1}recordImportIdentifier(e){const t=e.specifiers[0].local;this.logProfileOrApiConflict(t);const n=t.name.toLowerCase();let a=this.getIdentifierInfo(n);a?.scope&&this.logDiagnostic(e.specifiers[0].local.loc,{code:i.AlreadyDefined,data:{identifier:e.specifiers[0].local.name},severity:s.Warning}),a={node:e.specifiers[0].local,used:!1,...a,scope:"script",initialized:!0},this.setIdentiferInfo(n,a)}recordFunctionIdentifier(e){this.logProfileOrApiConflict(e.id);const t=e.id.name.toLowerCase();let n=this.getIdentifierInfo(t);n?.scope&&this.logDiagnostic(e.id.loc,{code:i.AlreadyDefined,data:{identifier:e.id.name},severity:s.Warning}),n={node:e.id,used:!1,...n,scope:"script",initialized:!0},this.setIdentiferInfo(t,n)}recordParamAsIdentifier(e){return this.recordVariableIdentifier(e,{initialized:!0})}diagnoseIdentifiers(){(this._functionScopeIdentifiers??this._scriptScopeIdentifiers).forEach((e=>{e.node&&(e.used?e.initialized||this.logDiagnostic(e.node.loc,{code:i.DefinedNeverAssigned,data:{identifier:e.node.name},severity:s.Warning}):this.logDiagnostic(e.node.loc,{code:e.initialized?i.AssignedNeverUsed:i.DefinedNeverUsed,data:{identifier:e.node.name},severity:s.Warning}))}))}}function g(e){return"ParsingError"===e?.name}function m(e){return c(e)||l(e)&&!e?.body.length}function u(e,t){if(!e||null==t||t<0)return null;const{min:n,max:s}=e.overloads.reduce(((e,i)=>{const{min:t,max:n}=i.parametersInfo;return e.min>=0&&(e.min=Math.min(t,e.min)),e.max>=0&&(e.max=n<0?n:Math.max(n,e.max)),e}),{min:1/0,max:0});return t<n?n>0?{code:i.NotEnoughArguments,data:{min:n}}:{code:i.NoArgumentExpected}:s>=0&&t>s?{code:i.TooManyArguments,data:{max:s}}:null}const v=new RegExp(/\B@\w+/g);function I(e){return Array.from((e??"").matchAll(v),(e=>e[0].slice(1)))}function y(e,i=[],t){if(!e)return{diagnostics:[]};return new p(t,i).validateScript(e)}export{p as ArcadeValidationService,h as format,f as isValueVariable,y as validateScript};
5
+ import{r as e,q as i,i as t,E as n,k as s,Q as a,j as o}from"../../chunks/index.js";import{DiagnosticCodes as r,diagnosticMessages as d}from"./diagnosticMessages.js";import{arcadeReservedKeywords as c}from"./languageKeywords.js";import{DiagnosticSeverity as l}from"./types.js";function h(e,i){return i?e.replaceAll(/\${(.*?)}/g,((e,t)=>i[t]?.toString()??"")):e}function f(e){return!!e&&"dictionary"!==e.type}class p{constructor(e,i=[]){this._apiDefinitions=e,this._profileVariables=i,this._isInBlock=!1,this._identifierBeingAssigned=void 0,this._assignmentValidationMode="disabled",this._scriptScopeIdentifiers=new Map,this._diagnostics=new Array,this._undeclaredIdentifiersInFunctions=new Map}validateScript(i){if(!i)return{diagnostics:[],program:null};this._isInBlock=!1,this._identifierBeingAssigned=void 0,this._assignmentValidationMode="disabled",this._diagnostics=[],this._scriptScopeIdentifiers.clear(),this._undeclaredIdentifiersInFunctions.clear(),this._functionScopeIdentifiers=void 0;let t=null;try{t=e(i,{tolerant:!0}),this.handleErrors(t.errors),t.body.forEach((e=>this.validateStatement(e))),this.diagnoseIdentifiers(),this._undeclaredIdentifiersInFunctions.size>0&&this._undeclaredIdentifiersInFunctions.forEach((e=>{for(const i of e)this.logDiagnostic(i.node.loc,{code:r.NotDefined,data:{identifier:i.node.name}})}))}catch(n){this.handleException(n)}return{diagnostics:this._diagnostics,program:t}}disableRecordIdentifierAssignment(e,i){const t=this._assignmentValidationMode;this._assignmentValidationMode="disabled",e.call(this,i),this._assignmentValidationMode=t}inBlock(e,i){const t=this._isInBlock;this._isInBlock=!0,e.call(this,i),this._isInBlock=t}get _isInFunctionScope(){return!!this._functionScopeIdentifiers}inFunctionScope(e){this._functionScopeIdentifiers=new Map,e.call(this),this.diagnoseIdentifiers(),this._functionScopeIdentifiers=void 0}logDiagnostic(e,t){const n={severity:l.Error,...t,message:h(d[t.code]??i[t.code],t.data),range:{start:{line:e.start.line-1,character:e.start.column},end:{line:e.end.line-1,character:e.end.column}}};this._diagnostics.push(n)}handleErrors(e){(e??[]).forEach(this.handleException,this)}handleException(e){if(g(e)){const{range:i,code:t,data:n}=e;this.logDiagnostic(i,{code:t,data:n})}else this.logDiagnostic({start:{line:1,column:0},end:{line:1,column:0}},{code:r.ExecutionError,data:{stack:e.stack}})}getIdentifierInfo(e){return this._functionScopeIdentifiers?.get(e)??this._scriptScopeIdentifiers.get(e)}setIdentiferInfo(e,i){this._functionScopeIdentifiers?this._functionScopeIdentifiers.set(e,i):((this._functionScopeIdentifiers??this._scriptScopeIdentifiers).set(e,i),this._functionScopeIdentifiers||this._undeclaredIdentifiersInFunctions.has(e)&&(this._undeclaredIdentifiersInFunctions.delete(e),i.used=!0))}isProfileVariable(e){return(this._profileVariables??[]).some((i=>i.name.toLowerCase()===e))}isApiItem(e){const i=!!this._apiDefinitions?.constantDefinitions?.get(e),t=!!this._apiDefinitions?.functionDefinitions?.get(e);return i||t}validateStatement(e){if(e)switch(e.type){case t.BlockStatement:return void e.body.forEach((e=>this.validateStatement(e)));case t.VariableDeclaration:return void e.declarations.forEach((e=>this.validateVariableDeclarator(e)));case t.FunctionDeclaration:return void this.validateFunctionDeclaration(e);case t.ExportNamedDeclaration:return void this.validateExportDeclaration(e);case t.ImportDeclaration:return void this.validateImportDeclaration(e);case t.WhileStatement:return void this.validateWhileStatement(e);case t.ForStatement:return void this.validateForStatement(e);case t.ForInStatement:return void this.validateForInStatement(e);case t.IfStatement:return void this.validateIfStatement(e);case t.ReturnStatement:return void this.validateExpression(e.argument);case t.ExpressionStatement:return void this.validateExpression(e.expression);case t.BreakStatement:case t.ContinueStatement:case t.EmptyStatement:return}}validateVariableDeclarator(e){this.validateExpression(e.init),this.recordVariableIdentifier(e.id,{initialized:!!e.init})}validateFunctionDeclaration(e){this.recordFunctionIdentifier(e),this.inFunctionScope((()=>{e.params.forEach((e=>this.recordParamAsIdentifier(e))),m(e.body)&&this.logDiagnostic(e.body.loc,{code:r.UnexpectedEmptyFunction,data:{identifier:e.id.name},severity:l.Warning}),this.validateStatement(e.body)}))}validateExportDeclaration(e){this.validateStatement(e.declaration)}validateImportDeclaration(e){this.recordImportIdentifier(e)}validateForStatement(e){n(e.init)?this.inBlock(this.validateStatement,e.init):this.validateExpression(e.init),this.validateExpression(e.update),this.validateExpression(e.test),m(e.body)&&this.logDiagnostic(e.body.loc,{code:r.EmptyBlockStatement,severity:l.Warning}),this.inBlock(this.validateStatement,e.body)}validateWhileStatement(e){this.validateExpression(e.test),m(e.body)&&this.logDiagnostic(e.body.loc,{code:r.EmptyBlockStatement,severity:l.Warning}),this.inBlock(this.validateStatement,e.body)}validateForInStatement(e){s(e.left)?this.validateExpression(e.left):this.recordVariableIdentifier(e.left.declarations[0].id,{initialized:!0,inBlock:!0}),this.validateExpression(e.right),m(e.body)&&this.logDiagnostic(e.body.loc,{code:r.EmptyBlockStatement,severity:l.Warning}),this.validateStatement(e.body)}validateIfStatement(e){this.validateExpression(e.test),m(e.consequent)&&this.logDiagnostic(e.consequent.loc,{code:r.EmptyBlockStatement,severity:l.Warning}),e.alternate&&m(e.alternate)&&this.logDiagnostic(e.alternate.loc,{code:r.EmptyBlockStatement,severity:l.Warning}),this.inBlock(this.validateStatement,e.consequent),this.inBlock(this.validateStatement,e.alternate)}validateExpression(e){if(e)switch(e.type){case t.AssignmentExpression:return void this.validateAssignmentExpression(e);case t.CallExpression:return void this.validateCallExpression(e);case t.Identifier:return void this.validateIdentifier(e);case t.Literal:return void this.validateLiteral(e);case t.ArrayExpression:return void e.elements.forEach((e=>this.validateExpression(e)));case t.ObjectExpression:return void this.validateObjectExpression(e);case t.UnaryExpression:return void this.validateUnaryExpression(e);case t.UpdateExpression:return void this.validateUpdateExpression(e);case t.BinaryExpression:case t.LogicalExpression:return void this.validateBinaryAndLogicalExpression(e);case t.MemberExpression:return void this.validateMemberExpression(e);case t.TemplateLiteral:return void e.expressions.forEach((e=>this.validateExpression(e)));default:return}}validateAssignmentExpression(e){const i=this._identifierBeingAssigned,t=this._assignmentValidationMode;s(e.left)&&(this._identifierBeingAssigned=e.left.name.toLowerCase(),this._assignmentValidationMode="left"),this.validateExpression(e.left),s(e.left)&&(this._assignmentValidationMode="right"),this.validateExpression(e.right),this._identifierBeingAssigned=i,this._assignmentValidationMode=t}validateCallExpression(e){if(this.validateExpression(e.callee),s(e.callee)){const i=e.callee.name.toLowerCase(),t=this.getIdentifierInfo(i),n=this._apiDefinitions?.functionDefinitions?.get(i);if(!t&&n){const i=u(n,e.arguments.length);i&&this.logDiagnostic(e.loc,i)}}e.arguments.forEach((e=>this.validateExpression(e)))}validateIdentifier(e){const i=e.name.toLowerCase(),t=this.getIdentifierInfo(i);if(t){if("left"===this._assignmentValidationMode&&this._identifierBeingAssigned===i)return void(t.initialized=!0);if("right"===this._assignmentValidationMode&&this._identifierBeingAssigned===i)return;t.used=!0}else if(!this.isProfileVariable(i)&&!this.isApiItem(i)){if(this._isInFunctionScope){let t=this._undeclaredIdentifiersInFunctions.get(i);return t||(t=[],this._undeclaredIdentifiersInFunctions.set(i,t)),void t.push({node:e,identifier:i})}this.logDiagnostic(e.loc,{code:r.NotDefined,data:{identifier:e.name}})}}validateLiteral(e){I(e.raw).forEach((e=>{const i=this.getIdentifierInfo(e.toLowerCase());i&&(i.used=!0)}))}logProfileOrApiConflict(e){const i=e.name.toLowerCase(),t=this.isProfileVariable(i),n=this.isApiItem(i);(t||n)&&this.logDiagnostic(e.loc,{code:t?r.ProfileVariablesConflict:r.ApiConflict,severity:l.Warning,data:{identifier:e.name}})}logReservedKeywordsConflict(e){const i=e.name.toLowerCase();c.includes(i)&&this.logDiagnostic(e.loc,{code:r.ReservedKeyword,severity:l.Warning,data:{identifier:e.name}})}validateObjectExpression(e){e.properties.forEach((e=>{this.validateExpression(e.value)}))}validateUnaryExpression(e){this.validateExpression(e.argument)}validateUpdateExpression(e){this.validateExpression(e.argument)}validateBinaryAndLogicalExpression(e){this.validateExpression(e.left),this.validateExpression(e.right)}validateMemberExpression(e){const i=this.flattenMemberExpressionAndValidate(e),t=i[0].object;this.disableRecordIdentifierAssignment(this.validateExpression,t),s(t)&&(this.getIdentifierInfo(t.name.toLowerCase())||this.validateMemberExpressionWithProfile(i)||this.validateConstantMemberExpression(i))}flattenMemberExpressionAndValidate(e){return e.type===t.MemberExpression?(s(e.property)&&!e.computed||this.validateExpression(e.property),[...this.flattenMemberExpressionAndValidate(e.object),e]):[]}extractAndValidatePropertyName(e){switch(e.type){case"Identifier":return e.name.toLowerCase();case"Literal":return"string"!=typeof e.value?(this.logDiagnostic(e.loc,{code:r.UnexpectedPropertyIdentifier}),null):e.value.toLowerCase();default:return this.logDiagnostic(e.loc,{code:r.UnexpectedPropertyIdentifier}),null}}validateConstantMemberExpression(e){const i=e[0];if(!s(i.object))return!1;const t=i.object.name.toLowerCase(),n=this._apiDefinitions?.constantDefinitions?.get(t);if(!n)return!1;if("namespace"!==n.type)return this.logDiagnostic(i.property.loc,{code:r.NotADictionary,data:{identifier:t}}),!0;const a=this.extractAndValidatePropertyName(i.property);if(!a)return!0;if(!n.members.some((e=>e.key===a))){const e=n.members.reduce(((e,i)=>`${e}${e?" | ":""}${i.completion.label.split(".").pop()}`),"");this.logDiagnostic(i.property.loc,{code:r.InvalidConstantIdentifier,data:{list:e}})}return e.length>1&&this.logDiagnostic(e[1].property.loc,{code:r.UnexpectedPropertyIdentifier}),!0}validateMemberExpressionWithProfile(e){const i=e[0];if(i.object.type!==t.Identifier)return!1;const n=i.object.name.toLowerCase(),s=this._profileVariables?.find((e=>e.key===n));if(!s)return!1;if(f(s))return this.logDiagnostic(i.object.loc,{code:r.NotADictionary,data:{identifier:s.name}}),!0;if(this._identifierBeingAssigned===n)return this.logDiagnostic(i.loc,{code:r.ProfileVariablesAreImmutable}),!0;let a=s;for(let t=0;t<e.length;t++){if(e[t].computed)return!0;if(f(a))return this.logDiagnostic(e[t-1]?.property.loc??e[t].object.loc,{code:r.NotADictionary,data:{identifier:a.name}}),!0;const i=this.extractAndValidatePropertyName(e[t].property);if(!i)return!0;if(0===a.properties.length)return this.logDiagnostic(e[t].property.loc,{code:r.UnknownPropertyIdentifier,data:{identifier:i},severity:l.Warning}),!0;const n=a.properties.find((e=>e.name.toLowerCase()===i));if(!n){const i=a.properties.reduce(((e,i)=>`${e}${e?" | ":""}${i.name.split(".").pop()}`),"");return this.logDiagnostic(e[t].property.loc,{code:r.InvalidPropertyIdentifier,data:{list:i}}),!0}a=n}return!0}recordVariableIdentifier(e,i){this.logReservedKeywordsConflict(e),this.logProfileOrApiConflict(e);const t=e.name.toLowerCase();let n=this.getIdentifierInfo(t);const s=n&&this._isInFunctionScope&&"function"===n.scope,a=n&&!this._isInFunctionScope&&"script"===n.scope;(s||a)&&this.logDiagnostic(e.loc,{code:r.AlreadyDefined,data:{identifier:e.name},severity:l.Warning});const o=i.inBlock??this._isInBlock,{initialized:d}=i;if(!n||this._isInFunctionScope&&"function"!==n.scope){n={node:e,used:!1,initialized:d,scope:this._isInFunctionScope?"function":o?"block":"script"}}else n.node=e,n.used=!1,n.initialized=d;return"block"!==n.scope||o||(n.scope="script",this.logDiagnostic(e.loc,{code:r.AlreadyDefined,data:{identifier:e.name},severity:l.Warning})),this.setIdentiferInfo(t,n),!1}recordImportIdentifier(e){const i=e.specifiers[0].local;this.logProfileOrApiConflict(i);const t=i.name.toLowerCase();let n=this.getIdentifierInfo(t);n?.scope&&this.logDiagnostic(e.specifiers[0].local.loc,{code:r.AlreadyDefined,data:{identifier:e.specifiers[0].local.name},severity:l.Warning}),n={node:e.specifiers[0].local,used:!1,...n,scope:"script",initialized:!0},this.setIdentiferInfo(t,n)}recordFunctionIdentifier(e){this.logProfileOrApiConflict(e.id);const i=e.id.name.toLowerCase();let t=this.getIdentifierInfo(i);t?.scope&&this.logDiagnostic(e.id.loc,{code:r.AlreadyDefined,data:{identifier:e.id.name},severity:l.Warning}),t={node:e.id,used:!1,...t,scope:"script",initialized:!0},this.setIdentiferInfo(i,t)}recordParamAsIdentifier(e){return this.recordVariableIdentifier(e,{initialized:!0})}diagnoseIdentifiers(){(this._functionScopeIdentifiers??this._scriptScopeIdentifiers).forEach((e=>{e.node&&(e.used?e.initialized||this.logDiagnostic(e.node.loc,{code:r.DefinedNeverAssigned,data:{identifier:e.node.name},severity:l.Warning}):this.logDiagnostic(e.node.loc,{code:e.initialized?r.AssignedNeverUsed:r.DefinedNeverUsed,data:{identifier:e.node.name},severity:l.Warning}))}))}}function g(e){return"ParsingError"===e?.name}function m(e){return a(e)||o(e)&&!e?.body.length}function u(e,i){if(!e||null==i||i<0)return null;const{min:t,max:n}=e.overloads.reduce(((e,i)=>{const{min:t,max:n}=i.parametersInfo;return e.min>=0&&(e.min=Math.min(t,e.min)),e.max>=0&&(e.max=n<0?n:Math.max(n,e.max)),e}),{min:1/0,max:0});return i<t?t>0?{code:r.NotEnoughArguments,data:{min:t}}:{code:r.NoArgumentExpected}:n>=0&&i>n?{code:r.TooManyArguments,data:{max:n}}:null}const v=new RegExp(/\B@\w+/g);function I(e){return Array.from((e??"").matchAll(v),(e=>e[0].slice(1)))}function E(e,i=[],t){if(!e)return{diagnostics:[]};return new p(t,i).validateScript(e)}export{p as ArcadeValidationService,h as format,f as isValueVariable,E as validateScript};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{Keywords as t}from"../lib/types.js";const e=Object.values(t),c=["case","catch","debugger","switch","try"];export{e as arcadeKeywords,c as arcadeReservedKeywords};
5
+ import{l as c}from"../../chunks/index.js";const e=Object.values(c),t=["case","catch","debugger","switch","try"];export{e as arcadeKeywords,t as arcadeReservedKeywords};