@arcgis/core 5.0.0-next.18 → 5.0.0-next.19

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 (105) hide show
  1. package/AttributeBinsGraphic.js +1 -1
  2. package/analysis/ElevationProfile/ElevationProfileLineGround.js +1 -1
  3. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  4. package/analysis/ElevationProfile/ElevationProfileLineQuery.js +1 -1
  5. package/analysis/ElevationProfile/ElevationProfileLineScene.js +1 -1
  6. package/arcade/featureSetUtils.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerOGC.js +5 -0
  10. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  11. package/arcade/featureset/support/FeatureSet.js +1 -1
  12. package/arcade/featureset/support/shared.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/057d59ee6144e5890780.js +1 -0
  15. package/assets/esri/core/workers/chunks/{31b5900119dd7cd9e7d3.js → 0a6ad58ca4ca0cba2fa0.js} +1 -1
  16. package/assets/esri/core/workers/chunks/0d8d3d0de49064971874.js +1 -0
  17. package/assets/esri/core/workers/chunks/{b87bc987983b31c13f64.js → 0f1b9d69961dad0b922f.js} +1 -1
  18. package/assets/esri/core/workers/chunks/110cc01dd6af7ee125d4.js +1 -0
  19. package/assets/esri/core/workers/chunks/11687718c8635eb7bf37.js +1 -0
  20. package/assets/esri/core/workers/chunks/{5f6df4a3376b52ead53f.js → 14f994b1dd682bf2d61a.js} +1 -1
  21. package/assets/esri/core/workers/chunks/3538eb39ebb58acedd67.js +1 -0
  22. package/assets/esri/core/workers/chunks/{02a22dd6d208a925cc5a.js → 52cf643621662712dc85.js} +1 -1
  23. package/assets/esri/core/workers/chunks/5755b11272b777507612.js +1 -0
  24. package/assets/esri/core/workers/chunks/{d69265ceabfa92b40bb7.js → 58969dde8c3d0b2a9829.js} +1 -1
  25. package/assets/esri/core/workers/chunks/6e4829b52ade3e41ccc4.js +1 -0
  26. package/assets/esri/core/workers/chunks/{4a89e120be142ab58a27.js → 7224b321606116fd691c.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{257f17b3836a623a9dbe.js → 795b09ff7a8f4e91f4dc.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{3ac7562ea90f91a9f30c.js → 82b2741e75c2e9b88252.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{5d2e5774768d8f290343.js → b656e8fd374113523404.js} +1 -1
  30. package/assets/esri/core/workers/chunks/bccb9ac572bc093fb177.js +1 -0
  31. package/assets/esri/core/workers/chunks/{79dbfa2b9b332ca0002f.js → c52161b94c0fb071747e.js} +1 -1
  32. package/assets/esri/core/workers/chunks/db76958fd9f54b6bd324.js +1 -0
  33. package/assets/esri/core/workers/chunks/e61d7762b56e36dc7e8a.js +1 -0
  34. package/assets/esri/core/workers/chunks/{b30897952494a3e5b9fe.js → e69c2b613bd0210e25ba.js} +1 -1
  35. package/assets/esri/core/workers/chunks/f43e1e1a1b2eb737e00c.js +1 -0
  36. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  37. package/chunks/GlowComposition.glsl.js +46 -46
  38. package/chunks/ShadedColorMaterial.glsl.js +10 -10
  39. package/config.js +1 -1
  40. package/editing/templateUtils.js +1 -1
  41. package/interfaces.d.ts +120 -23
  42. package/kernel.js +1 -1
  43. package/layers/BingMapsLayer.js +1 -1
  44. package/layers/PointCloudLayer.js +1 -1
  45. package/layers/SceneLayer.js +1 -1
  46. package/layers/VideoLayer.js +1 -1
  47. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  48. package/layers/mixins/SceneService.js +1 -1
  49. package/layers/ogc/ogcFeatureUtils.js +1 -1
  50. package/libs/parquet/parquet.js +1 -1
  51. package/package.json +1 -1
  52. package/renderers/support/RasterSymbolizer.js +1 -1
  53. package/rest/support/QueryMixin.js +1 -1
  54. package/support/revision.js +1 -1
  55. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  56. package/symbols/cim/cimAnalyzer.js +1 -1
  57. package/undoredo/support/ServiceVersionInfo.js +1 -1
  58. package/undoredo/support/Services.js +1 -1
  59. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  60. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
  61. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterHighlightShader.js +5 -0
  62. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  63. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterXYBandHighlightShader.js +5 -0
  64. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/stretch.js +1 -1
  66. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  67. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  68. package/views/3d/environment/SceneViewEnvironment.js +1 -1
  69. package/views/3d/environment/SunLighting.js +1 -1
  70. package/views/3d/environment/VirtualLighting.js +1 -1
  71. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  72. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  73. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  74. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  75. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  76. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  77. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  78. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  79. package/widgets/Editor/VisibleElements.js +1 -1
  80. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  81. package/widgets/Editor/workflowUtils.js +1 -1
  82. package/widgets/Editor.js +1 -1
  83. package/widgets/FeatureTable/FieldColumn.js +1 -1
  84. package/widgets/FeatureTable/Grid/Column.js +1 -1
  85. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  86. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  87. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  88. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  89. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  90. package/widgets/OrientedImageryViewer.js +1 -1
  91. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  92. package/widgets/smartMapping/SizeSlider.js +1 -1
  93. package/widgets/support/SelectionList/VisibleElements.js +1 -1
  94. package/widgets/support/SelectionList.js +1 -1
  95. package/assets/esri/core/workers/chunks/080268f78436a2f0d996.js +0 -1
  96. package/assets/esri/core/workers/chunks/18474c017ddacd1d3d2c.js +0 -1
  97. package/assets/esri/core/workers/chunks/27e6a6c5610007ac6a54.js +0 -1
  98. package/assets/esri/core/workers/chunks/5415fbcc7ed203fc5575.js +0 -1
  99. package/assets/esri/core/workers/chunks/631fb2e62e48f8be4051.js +0 -1
  100. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +0 -1
  101. package/assets/esri/core/workers/chunks/9595aabbaf411eceea1e.js +0 -1
  102. package/assets/esri/core/workers/chunks/a470f662d73aa8d5d90f.js +0 -1
  103. package/assets/esri/core/workers/chunks/a57751f3d78524c876cd.js +0 -1
  104. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +0 -1
  105. package/assets/esri/core/workers/chunks/dec336700cfb83abbbeb.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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import r from"./Graphic.js";import{ClonableMixin as s}from"./core/Clonable.js";import{clone as o}from"./core/lang.js";import{property as e}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/Logger.js";import{subclass as c}from"./core/accessorSupport/decorators/subclass.js";var i;let a=class extends(s(r)){static{i=this}constructor(t){super(t),this.stackedAttributes=null}cloneShallow(){return new i(Object.assign({stackedAttributes:this.stackedAttributes},super.cloneShallow()))}toJSON(){return{...super.toJSON(),stackedAttributes:o(this.stackedAttributes)}}};t([e()],a.prototype,"stackedAttributes",void 0),a=i=t([c("esri.AttributeBinsGraphic")],a);export{a as default};
5
+ import{__decorate as t}from"tslib";import r from"./Graphic.js";import{clone as s}from"./core/lang.js";import{property as e}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/Logger.js";import{subclass as o}from"./core/accessorSupport/decorators/subclass.js";var c;let i=class extends r{static{c=this}constructor(t){super(t),this.stackedAttributes=null}cloneShallow(){return new c(Object.assign({stackedAttributes:this.stackedAttributes},super.cloneShallow()))}toJSON(){return{...super.toJSON(),stackedAttributes:s(this.stackedAttributes)}}};t([e()],i.prototype,"stackedAttributes",void 0),i=c=t([o("esri.AttributeBinsGraphic")],i);export{i 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import r from"../../Color.js";import e from"./ElevationProfileLine.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends e{constructor(o){super(o),this.type="ground",this.color=new r("#ff7f00")}};o([t()],i.prototype,"type",void 0),o([t({type:r,nonNullable:!0})],i.prototype,"color",void 0),i=o([s("esri.analysis.ElevationProfile.ElevationProfileLineGround")],i);const p=i;export{p as default};
5
+ import{__decorate as o}from"tslib";import r from"../../Color.js";import e from"./ElevationProfileLine.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends e{constructor(o){super(o),this.type="ground",this.color=new r("#ff7f00")}};o([s({type:r,nonNullable:!0})],i.prototype,"color",void 0),i=o([t("esri.analysis.ElevationProfile.ElevationProfileLineGround")],i);const p=i;export{p 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import r from"../../Color.js";import t from"./ElevationProfileLine.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends t{constructor(o){super(o),this.type="input",this.color=new r("#00c8c8")}};o([e()],p.prototype,"type",void 0),o([e({type:r,nonNullable:!0})],p.prototype,"color",void 0),p=o([s("esri.analysis.ElevationProfile.ElevationProfileLineInput")],p);const i=p;export{i as default};
5
+ import{__decorate as o}from"tslib";import r from"../../Color.js";import t from"./ElevationProfileLine.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends t{constructor(o){super(o),this.type="input",this.color=new r("#00c8c8")}};o([e({type:r,nonNullable:!0})],i.prototype,"color",void 0),i=o([s("esri.analysis.ElevationProfile.ElevationProfileLineInput")],i);const p=i;export{p 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import r from"../../Color.js";import e from"./ElevationProfileLine.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends e{constructor(o){super(o),this.type="query",this.color=new r("#db334a"),this.source=null}equals(o){return this===o||super.equals(o)&&this.source===o.source}};o([s()],i.prototype,"type",void 0),o([s({type:r,nonNullable:!0})],i.prototype,"color",void 0),o([s({clonable:"reference"})],i.prototype,"source",void 0),i=o([t("esri.analysis.ElevationProfile.ElevationProfileLineQuery")],i);const p=i;export{p as default};
5
+ import{__decorate as o}from"tslib";import r from"../../Color.js";import e from"./ElevationProfileLine.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends e{constructor(o){super(o),this.type="query",this.color=new r("#db334a"),this.source=null}equals(o){return this===o||super.equals(o)&&this.source===o.source}};o([s({type:r,nonNullable:!0})],i.prototype,"color",void 0),o([s({clonable:"reference"})],i.prototype,"source",void 0),i=o([t("esri.analysis.ElevationProfile.ElevationProfileLineQuery")],i);const c=i;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import r from"../../Color.js";import e from"./ElevationProfileLine.js";import{equals as t}from"../../core/arrayUtils.js";import{equalsMaybe as s}from"../../core/maybe.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";let l=class extends e{constructor(o){super(o),this.type="scene",this.color=new r("#cf4ccf"),this.include=null,this.exclude=null}equals(o){return this===o||super.equals(o)&&p(this.include,o.include)&&p(this.exclude,o.exclude)}};function p(o,r){return s(o,r,(o,r)=>t(Array.from(o),Array.from(r)))}o([i()],l.prototype,"type",void 0),o([i({type:r,nonNullable:!0})],l.prototype,"color",void 0),o([i()],l.prototype,"include",void 0),o([i()],l.prototype,"exclude",void 0),l=o([c("esri.analysis.ElevationProfile.ElevationProfileLineScene")],l);const n=l;export{n as default};
5
+ import{__decorate as o}from"tslib";import r from"../../Color.js";import e from"./ElevationProfileLine.js";import{equals as t}from"../../core/arrayUtils.js";import{equalsMaybe as s}from"../../core/maybe.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";let l=class extends e{constructor(o){super(o),this.type="scene",this.color=new r("#cf4ccf"),this.include=null,this.exclude=null}equals(o){return this===o||super.equals(o)&&p(this.include,o.include)&&p(this.exclude,o.exclude)}};function p(o,r){return s(o,r,(o,r)=>t(Array.from(o),Array.from(r)))}o([i({type:r,nonNullable:!0})],l.prototype,"color",void 0),o([i()],l.prototype,"include",void 0),o([i()],l.prototype,"exclude",void 0),l=o([c("esri.analysis.ElevationProfile.ElevationProfileLineScene")],l);const n=l;export{n 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a1 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import s from"./featureset/sources/FeatureLayerMemory.js";import i from"./featureset/sources/FeatureLayerRelated.js";import o from"./featureset/support/cache.js";import{FeatureSetError as u}from"./featureset/support/errorsupport.js";import{isSupportedSourceLayer as c,isSupportedLayer as d,extractServiceUrl as p}from"./featureset/support/shared.js";import{isLoadable as f}from"../core/Loadable.js";import y from"../core/sql/WhereClause.js";import h from"../layers/FeatureLayer.js";import m from"../layers/Layer.js";import w from"../portal/PortalItem.js";function I(){null===o.applicationCache&&(o.applicationCache=new o)}async function L(e,t,a){if(o.applicationCache){const a=o.applicationCache.getLayerInfo(e);if(a){const r=await a;return new h({url:e,outFields:t,sourceJSON:r})}const n=new h({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(o.applicationCache){o.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw o.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new h({url:e,outFields:t,sourceJSON:a})}const l=new h({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new h({url:e,outFields:t})}async function S(e,t,a,r,n,l=null){return _(await L(e,["*"],n),t,a,r,n,l)}function _(e,t=null,a=null,r=!0,i=null,o=null){switch(e.type){case"catalog-footprint":return _(e.parent,t,a,r,i,o);case"subtype-sublayer":{const l=_(e.parent,t,a,r,i,o);return new n({parentfeatureset:l,whereclause:y.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:l.dateFieldsTimeZoneDefaultUTC})})}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new s({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:i,interceptor:o});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const n={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:i,interceptor:o};return!e.url&&e.source?new s(n):new l(n)}default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function C(t){if(null!==o.applicationCache){const e=o.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==o.applicationCache){o.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw o.applicationCache.clearLayerInfo(t),r}}return a}async function k(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==o.applicationCache){const e=o.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements?.[0])return e.layerDataElements[0]}throw new u("DataElementsNotFound")})();if(null!==o.applicationCache){o.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw o.applicationCache.clearLayerInfo(r),l}}return n}async function g(t,a){if(null!==o.applicationCache){const e=o.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==o.applicationCache){o.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw o.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function F(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},l=await g(e,null);if(r.metadata=l,void 0!==l.controllerDatasetLayers?.utilityNetworkLayerId&&null!==l.controllerDatasetLayers.utilityNetworkLayerId){if(l.layers)for(const e of l.layers)r.layerNameLkp[e.id]=e.name;if(l.tables)for(const e of l.tables)r.layerNameLkp[e.id]=e.name;const s=l.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;const i=await k(e,s);if(i){r.queryelem=i,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const l=await C(e+"/"+s);if(void 0!==l.systemLayers?.associationsTableId&&null!==l.systemLayers.associationsTableId){let s=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),s=await S(e+"/"+l.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await s.load(),r.unVersion>=4&&(s=new n({parentfeatureset:s,whereclause:y.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})}),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function N(e,t,a,r=null,n=null,l=!0,s=null,o=null){let u=e.serviceUrl();if(!u)return null;u=u.endsWith("/")?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString();const c=await S(u,r,n,l,s,o);return new i({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:o})}class T extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=_(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,a=null){if(f(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>d(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>d(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(f(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>d(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>d(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=_(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await g(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new O(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await L(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await L(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function A(e,t,a=null,r=null){return new T(e,t,a,r)}function E(e,t,a=null,r=null){return new O(e,t,a,r)}function D(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof m&&c(e)){const a=e;switch(t){case"datasource":return _(a,s,"outFields"in a?a.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return _(a,s,"outFields"in a?a.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return _(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return _(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function M(e,t,a,r,n,l,s,i=null){if(o.applicationCache){const u=o.applicationCache.getLayerInfo(e+":"+l.url);if(u)return b(await u,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await b(await o,t,a,r,n,s,i)}const u=new w({id:e,portal:l}).load();o.applicationCache?o.applicationCache.setLayerInfo(e+":"+l.url,u):null!=s&&s.setCachedPortalItem(l.url,e,u);try{return await b(await u,t,a,r,n,s,i)}catch(c){throw o.applicationCache&&o.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,u),c}}async function b(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await L(p(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=m.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=await m.fromPortalItem(e)}return _(i,a,r,n,l,s)}export{F as constructAssociationMetaDataFeatureSetFromUrl,_ as constructFeatureSet,M as constructFeatureSetFromPortalItem,N as constructFeatureSetFromRelationship,S as constructFeatureSetFromUrl,D as convertToFeatureSet,A as createFeatureSetCollectionFromMap,E as createFeatureSetCollectionFromService,I as initialiseMetaDataCache};
5
+ import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a1 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import s from"./featureset/sources/FeatureLayerMemory.js";import i from"./featureset/sources/FeatureLayerOGC.js";import o from"./featureset/sources/FeatureLayerRelated.js";import u from"./featureset/support/cache.js";import{FeatureSetError as c}from"./featureset/support/errorsupport.js";import{isSupportedSourceLayer as d,isSupportedLayer as p,extractServiceUrl as f}from"./featureset/support/shared.js";import{isLoadable as y}from"../core/Loadable.js";import m from"../core/sql/WhereClause.js";import h from"../layers/FeatureLayer.js";import w from"../layers/Layer.js";import I from"../portal/PortalItem.js";function L(){null===u.applicationCache&&(u.applicationCache=new u)}async function S(e,t,a){if(u.applicationCache){const a=u.applicationCache.getLayerInfo(e);if(a){const r=await a;return new h({url:e,outFields:t,sourceJSON:r})}const n=new h({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(u.applicationCache){u.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw u.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new h({url:e,outFields:t,sourceJSON:a})}const l=new h({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new h({url:e,outFields:t})}async function _(e,t,a,r,n,l=null){return C(await S(e,["*"],n),t,a,r,n,l)}function C(e,t=null,a=null,r=!0,o=null,u=null){switch(e.type){case"catalog-footprint":return C(e.parent,t,a,r,o,u);case"subtype-sublayer":{const l=C(e.parent,t,a,r,o,u);return new n({parentfeatureset:l,whereclause:m.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:l.dateFieldsTimeZoneDefaultUTC})})}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new s({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const n={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u};return!e.url&&e.source?new s(n):new l(n)}case"ogc-feature":return new i({layer:e,spatialReference:t,outFields:a,includeGeometry:r});default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function k(t){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw u.applicationCache.clearLayerInfo(t),r}}return a}async function F(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements?.[0])return e.layerDataElements[0]}throw new c("DataElementsNotFound")})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw u.applicationCache.clearLayerInfo(r),l}}return n}async function g(t,a){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw u.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function N(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},l=await g(e,null);if(r.metadata=l,void 0!==l.controllerDatasetLayers?.utilityNetworkLayerId&&null!==l.controllerDatasetLayers.utilityNetworkLayerId){if(l.layers)for(const e of l.layers)r.layerNameLkp[e.id]=e.name;if(l.tables)for(const e of l.tables)r.layerNameLkp[e.id]=e.name;const s=l.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;const i=await F(e,s);if(i){r.queryelem=i,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const l=await k(e+"/"+s);if(void 0!==l.systemLayers?.associationsTableId&&null!==l.systemLayers.associationsTableId){let s=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),s=await _(e+"/"+l.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await s.load(),r.unVersion>=4&&(s=new n({parentfeatureset:s,whereclause:m.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})}),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function T(e,t,a,r=null,n=null,l=!0,s=null,i=null){let u=e.serviceUrl();if(!u)return null;u=u.endsWith("/")?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString();const c=await _(u,r,n,l,s,i);return new o({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=C(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,a=null){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>p(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>p(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>p(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>p(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class A extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=C(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await g(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new A(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new O(e,t,a,r)}function D(e,t,a=null,r=null){return new A(e,t,a,r)}function M(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof w&&d(e)){const a=e;switch(t){case"datasource":return C(a,s,"outFields"in a?a.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return C(a,s,"outFields"in a?a.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return C(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return C(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function b(e,t,a,r,n,l,s,i=null){if(u.applicationCache){const o=u.applicationCache.getLayerInfo(e+":"+l.url);if(o)return j(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await j(await o,t,a,r,n,s,i)}const o=new I({id:e,portal:l}).load();u.applicationCache?u.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await j(await o,t,a,r,n,s,i)}catch(c){throw u.applicationCache&&u.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),c}}async function j(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await S(f(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=w.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=await w.fromPortalItem(e)}return C(i,a,r,n,l,s)}export{N as constructAssociationMetaDataFeatureSetFromUrl,C as constructFeatureSet,b as constructFeatureSetFromPortalItem,T as constructFeatureSetFromRelationship,_ as constructFeatureSetFromUrl,M as convertToFeatureSet,E as createFeatureSetCollectionFromMap,D as createFeatureSetCollectionFromService,L as initialiseMetaDataCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{id as t}from"../../../kernel.js";import r from"../../../request.js";import{neverAbortedSignal as i}from"../../arcadeEnvironment.js";import s from"../../Attachment.js";import a from"../../Dictionary.js";import{throwIfCancelled as l,FeatureSetError as n}from"../support/errorsupport.js";import{FeatureSet as o,emptyFeaturesResult as u}from"../support/FeatureSet.js";import{defaultMaxRecords as c,stableStringify as h,extractServiceUrl as y}from"../support/shared.js";import{toWhereClause as d,isSingleField as p}from"../support/sqlUtils.js";import{decodeStatType as _}from"../support/stats.js";import{sliceEquals as m}from"../../../core/arrayUtils.js";import{createMD5Hash as f,outputTypes as F}from"../../../core/MD5.js";import{sqlAnd as g}from"../../../core/sql.js";import w from"../../../core/sql/WhereClause.js";import{fromJSON as S}from"../../../geometry/support/jsonUtils.js";import b from"../../../layers/FeatureLayer.js";import{toQueryStringParameters as R}from"../../../rest/query/operations/queryRelatedRecords.js";import I from"../../../rest/support/AttachmentQuery.js";import q from"../../../rest/support/Query.js";import T from"../../../rest/support/StatisticDefinition.js";function Q(e){if(0===e.length)throw new n("NeverReach");const t=[];for(let i=0;i<e.length;i++){const r=e[i],s=[`"${r.name.replaceAll('"','""')}" ${r.asc?">":"<"} @last_${i}`];for(let t=0;t<i;t++){const r=e[t];s.push(`"${r.name.replaceAll('"','""')}" = @last_${t}`)}t.push(s.join(" AND "))}const r=t.join(" OR ");return w.create(r)}function v(e,t){null==e.clause&&(e.clause=Q(e.keyFields));for(let r=0;r<e.keyFields.length;r++){const i=e.keyFields[r].name;e.clause.parameters[`last_${r}`]=t.attributes[i]}}class j extends o{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this._requestStandardised=!1,this._useDefinitionExpression=!0,this._recentlyUsedQueries=null,this._featureSetQueryInterceptor=null,this._featureSetInfo=null,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry),e.lrucache&&(this._recentlyUsedQueries=e.lrucache),e.interceptor&&(this._featureSetQueryInterceptor=e.interceptor)}_maxQueryRate(){return c}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+h(e.toJSON());return f(t,F.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer.capabilities?.data?.supportsZ,this.hasM=!0===this._layer.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=1,null!=e&&e>=10.61&&(this._databaseType=0)):null!=e&&(e>=10.5&&(this._databaseType=1,this._requestStandardised=!0),e>=10.61&&(this._databaseType=0))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new q;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch{return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}async _queryAll(){return(await this.query({abortSignal:i})).features}async query(e){return await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter?u:this._canUsePagination()?this._queryUsingPaging(e):this._queryUsingIdSetTraversal(e)}async _queryUsingPaging(e){let t="",r=!1;null!=e.orderBy&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(t=e.orderBy.constructClause(),r=!0);const i=await this.databaseType(),s=null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,i);let a=this._maxQueryRate();const l=this._layer.capabilities?.query.maxRecordCount;null!=l&&l<a&&(a=l);const n=!0!==this._removeGeometry,o=this._overrideFields??this._fieldsIncludingObjectId(["*"]),u=this._createQuery();return u.where=g(u.where,s),null!=e.spatialFilter&&(u.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),u.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),u.geometry=e.spatialFilter.geometry),u.orderByFields=""!==t?t.split(","):null,u.outFields=o,u.returnGeometry=n,u.outSpatialReference=this.spatialReference,{ordered:r,filterApplied:!0,spatialFilterApplied:!0,features:this._queryPaginated(u,a,e.abortSignal)}}async*_queryPaginated(e,t,r){let i;e.num=t,e.start=0;do{l(r),i=await this.executeQuery(e,"execute"),yield i.features,e.start+=t}while(void 0===i.exceededTransferLimit&&i.features.length===t||!1!==i.exceededTransferLimit)}async _queryUsingIdSetTraversal(e){let t="",r=!1;null!=e.orderBy&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(t=e.orderBy.constructClause(),r=!0);const i=await this.databaseType(),s=null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,i),a=this._createQuery();a.where=g(a.where,s),null!=e.spatialFilter&&(a.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),a.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),a.geometry=e.spatialFilter.geometry),a.orderByFields=""!==t?t.split(","):null,a.outSpatialReference=this.spatialReference;const n=await this.executeQuery(a,"executeForIds");if(l(e.abortSignal),null==n||n.length<=0)return u;let o=this._maxQueryRate();const c=this._layer.capabilities?.query.maxRecordCount;null!=c&&c<o&&(o=c);const h=this._createQuery();return a.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),a.returnGeometry=!0!==this._removeGeometry,a.outSpatialReference=this.spatialReference,{ordered:r,filterApplied:!0,spatialFilterApplied:!0,features:this._traverseIdSet(h,n,o,e.abortSignal)}}async*_traverseIdSet(e,t,r,i){for(let s=0;s<t.length;s+=r){e.objectIds=t.slice(s,s+r),l(i);const a=await this.executeQuery(e,"execute");yield a.features}}async queryStat(e){await this._ensureLoaded();const t=this._layer.capabilities?.query,r=!!t?.supportsSqlExpression,i=!!t?.supportsStatistics,s=!!t?.supportsDistinct,a=_(e.stat);if("count"===a)return s?this._queryCount(e):{calculated:!1};const l=e.field;if(null==l)return{calculated:!1};if(!1===i||!1===p(l)&&!1===r||!1===l.isStandardized)return null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(e.stat,l,e.limit??c,e.abortSignal);if("distinct"===a)return!1===s?null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(a,l,e.limit??c,e.abortSignal):{calculated:!1};const o=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:null};const u=this._createQuery();u.where=g(u.where,null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,o)),null!=e.spatialFilter&&(u.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),u.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),u.geometry=e.spatialFilter.geometry);const h=new T;h.statisticType=a,h.onStatisticField=d(l,o),h.outStatisticFieldName="ARCADE_STAT_RESULT",u.returnGeometry=!1;let y="ARCADE_STAT_RESULT";u.outStatistics=[h];const m=await this.executeQuery(u,"execute");if(!m.hasOwnProperty("features")||0===m.features.length)throw new n("InvalidStatResponse");let f=!1;const F=m.fields??[];for(const n of F)if("ARCADE_STAT_RESULT"===n.name.toUpperCase()){y=n.name,"date"===n.type&&(f=!0);break}const w=m.features[0].attributes[y];return{calculated:!0,result:f&&null!=w?new Date(w):w}}async _queryCount(e){const t=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:0};const r=this._createQuery();r.where=g(r.where,null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,t)),null!=e.spatialFilter&&(r.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),r.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),r.geometry=e.spatialFilter.geometry),r.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(r,"executeForCount")}}async canQueryAggregate(e){await this._ensureLoaded();let t=!1;const r=this._layer.capabilities?.query,i=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(t=!0),t)for(const s of e.statistics)(!1===s.workingexpr?.isStandardized||!1===p(s.workingexpr)&&!1===i)&&(t=!1);return t}async queryAggregate(e){if(await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter)return u;const t=await this.databaseType(),r=e.groupBy,i=e.orderBy;let s=null;if(!this._layer.capabilities.query.supportsPaginationOnAggregatedQueries){const e=this.getFieldsIndex();s={keyFields:r.map((t,r)=>({name:e.normalizeFieldName(t)??t,asc:null==i||1===i._directions[r]}))}}let a="",l=!1;null!=i&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(null==s||m(r,0,r.length,i._fields,0,Math.min(i._fields.length,r.length),(e,t)=>e.toLowerCase()===t.toLowerCase()))&&(a=i.constructClause(),l=!0),""===a&&(a=r.join(","));const n=e.statistics.map(e=>new T({onStatisticField:null!==e.workingexpr?d(e.workingexpr,t):"",outStatisticFieldName:e.field,statisticType:e.toStatisticsName()}));let o=this._maxQueryRate();const c=this._layer.capabilities?.query.maxRecordCount;null!=c&&c<o&&(o=c);const h=null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,t),y=this._createQuery();return y.where=g(y.where,h),null!=e.spatialFilter&&(y.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),y.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),y.geometry=e.spatialFilter.geometry),y.orderByFields=""!==a?a.split(","):null,y.outFields=["*"],y.outStatistics=n,y.groupByFieldsForStatistics=r,y.returnGeometry=!1,null==s?{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryPaginated(y,o,e.abortSignal)}:{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryKeysetPaginated(y,s,e.abortSignal)}}async*_queryKeysetPaginated(e,t,r){const i=e.where;for(;;){if(null!=t.clause){if(!this._layer.capabilities.query.supportsOrderBy)throw new n("NotImplemented");e.where=g(i,d(t.clause,await this.databaseType()))}const s=await this.executeQuery(e,"execute");if(l(r),!s.hasOwnProperty("features"))throw new n("InvalidStatResponse");if(yield s.features,0===s.features.length||!s.exceededTransferLimit)break;v(t,s.features.at(-1))}}_createQuery(){const e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,this.datesInUnknownTimezone&&(e.timeReferenceUnknownClient=!0),this._requestStandardised&&(e.sqlFormat="standard"),this._useDefinitionExpression?"subtype-group"===this._layer.type&&(e.where=this._layer.definitionExpression):e.where=null,e}executeQuery(e,t){const r="execute"===t?this._layer.queryFeatures.bind(this._layer):"executeForCount"===t?this._layer.queryFeatureCount.bind(this._layer):this._layer.queryObjectIds.bind(this._layer);let i=null;if(this._recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);i=this._recentlyUsedQueries.getFromCache(t),null===i&&(i=r(e),this._recentlyUsedQueries.addToCache(t,i),i=i.catch(e=>{throw this._recentlyUsedQueries?.removeFromCache(t),e}))}return this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===i&&(i=r(e)),i}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return r||t.push(this.objectIdField),t}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}static create(e,t,r,i,s){const a=new b({url:e,outFields:null===t?["*"]:t});return new j({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetadata(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return y(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,i,l){function n(e){const t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}const o=this._layer;if(!n(o))return[];const u=new I({objectIds:[e],returnMetadata:l});(t&&t>0||r&&r>0)&&(u.size=[t&&t>0?t:0,r&&r>0?r:t+1]),i&&i.length>0&&(u.attachmentTypes=i),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:o,query:u,method:"attachments"});const c=await o.queryAttachments(u);return c?.[e]?c[e].map(t=>{const r=`${this._layer.parsedUrl.path}/${e}/attachments/${t.id}`;let i=null;return l&&t.exifInfo&&(i=a.convertJsonToArcade(t.exifInfo,"system",!0)),new s(t.id,t.name,t.contentType,t.size,r,i,t.keywords??null)}):[]}async queryRelatedFeatures(t){const i=R(t);i.f="json",this._requestStandardised&&(i.sqlFormat="standard"),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await r(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i});if(s.data){const t={},r=s.data;if(r?.relatedRecordGroups){const i=r.spatialReference,s=!0===r.exceededTransferLimit;for(const a of r.relatedRecordGroups){const r=a.relatedRecords.map(t=>(t.geometry&&(t.geometry.spatialReference=i),new e({geometry:t.geometry?S(t.geometry):null,attributes:t.attributes})));t[a.objectId]={features:r,exceededTransferLimit:s}}}return t}throw new n("InvalidRequest")}async getFeatureByObjectId(e,t){const r=this._createQuery();r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=g(r.where,this.objectIdField+"="+e.toString()),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"});const i=await this._layer.queryFeatures(r);return 1===i.features.length?i.features[0]:null}async getIdentityUser(){await this.load();const e=t?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=t?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl??"";let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");if(i=s>-1?i.slice(0,s):i,i){i+="/rest/info";try{const e=await r(i,{query:{f:"json"}});let t="";return e.data?.owningSystemUrl&&(t=e.data.owningSystemUrl),t}catch{return""}}return""}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this._recentlyUsedQueries??void 0,interceptor:this._featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this._featureSetInfo)return this._featureSetInfo;let e=null,t="serviceItemId"in this._layer?this._layer.serviceItemId:null;const i=this._layer.parsedUrl?.path??null;if(i){const s=await r(i,{responseType:"json",query:{f:"json"}});e=s?.data?.name??null,t=s?.data?.serviceItemId??null}const s=this._layer.title&&null!==(this._layer.parent??null);return this._featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===t?null:t,serviceLayerUrl:""===i?null:i,webMapLayerId:s?this._layer.id??null:null,webMapLayerTitle:s?this._layer.title??null:null,className:null,objectClassId:null},this._featureSetInfo}}export{j as default};
5
+ import e from"../../../Graphic.js";import{id as t}from"../../../kernel.js";import r from"../../../request.js";import{neverAbortedSignal as i}from"../../arcadeEnvironment.js";import a from"../../Attachment.js";import s from"../../Dictionary.js";import{throwIfCancelled as l,FeatureSetError as n}from"../support/errorsupport.js";import{RootFeatureSet as o,emptyFeaturesResult as u}from"../support/FeatureSet.js";import{defaultMaxRecords as c,stableStringify as h,extractServiceUrl as y}from"../support/shared.js";import{toWhereClause as d,isSingleField as p}from"../support/sqlUtils.js";import{decodeStatType as _}from"../support/stats.js";import{sliceEquals as m}from"../../../core/arrayUtils.js";import{createMD5Hash as f,outputTypes as F}from"../../../core/MD5.js";import{sqlAnd as w}from"../../../core/sql.js";import g from"../../../core/sql/WhereClause.js";import{fromJSON as S}from"../../../geometry/support/jsonUtils.js";import b from"../../../layers/FeatureLayer.js";import{toQueryStringParameters as R}from"../../../rest/query/operations/queryRelatedRecords.js";import I from"../../../rest/support/AttachmentQuery.js";import q from"../../../rest/support/Query.js";import T from"../../../rest/support/StatisticDefinition.js";function Q(e){if(0===e.length)throw new n("NeverReach");const t=[];for(let i=0;i<e.length;i++){const r=e[i],a=[`"${r.name.replaceAll('"','""')}" ${r.asc?">":"<"} @last_${i}`];for(let t=0;t<i;t++){const r=e[t];a.push(`"${r.name.replaceAll('"','""')}" = @last_${t}`)}t.push(a.join(" AND "))}const r=t.join(" OR ");return g.create(r)}function v(e,t){null==e.clause&&(e.clause=Q(e.keyFields));for(let r=0;r<e.keyFields.length;r++){const i=e.keyFields[r].name;e.clause.parameters[`last_${r}`]=t.attributes[i]}}class j extends o{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this._requestStandardised=!1,this._useDefinitionExpression=!0,this._recentlyUsedQueries=null,this._featureSetQueryInterceptor=null,this._featureSetInfo=null,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry),e.lrucache&&(this._recentlyUsedQueries=e.lrucache),e.interceptor&&(this._featureSetQueryInterceptor=e.interceptor)}_maxQueryRate(){return c}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+h(e.toJSON());return f(t,F.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(this.spatialReference??=this._layer.spatialReference,this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer.capabilities?.data?.supportsZ,this.hasM=!0===this._layer.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=new Set(this._overrideFields.map(e=>e.toLowerCase()));this.fields=this.fields.filter(({type:t,name:r})=>"oid"===t||e.has(r.toLowerCase())),this._overrideFields=this.fields.map(({name:e})=>e)}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=1,null!=e&&e>=10.61&&(this._databaseType=0)):null!=e&&(e>=10.5&&(this._databaseType=1,this._requestStandardised=!0),e>=10.61&&(this._databaseType=0))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new q;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch{return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}async _queryAll(){return(await this.query({abortSignal:i})).features}async query(e){return await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter?u:this._canUsePagination()?this._queryUsingPaging(e):this._queryUsingIdSetTraversal(e)}async _queryUsingPaging(e){let t="",r=!1;null!=e.orderBy&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(t=e.orderBy.constructClause(),r=!0);const i=await this.databaseType(),a=null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,i);let s=this._maxQueryRate();const l=this._layer.capabilities?.query.maxRecordCount;null!=l&&l<s&&(s=l);const n=!0!==this._removeGeometry,o=this._overrideFields??this._fieldsIncludingObjectId(["*"]),u=this._createQuery();return u.where=w(u.where,a),null!=e.spatialFilter&&(u.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),u.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),u.geometry=e.spatialFilter.geometry),u.orderByFields=""!==t?t.split(","):null,u.outFields=o,u.returnGeometry=n,u.outSpatialReference=this.spatialReference,{ordered:r,filterApplied:!0,spatialFilterApplied:!0,features:this._queryPaginated(u,s,e.abortSignal)}}async*_queryPaginated(e,t,r){let i;e.num=t,e.start=0;do{l(r),i=await this.executeQuery(e,"execute"),yield i.features,e.start+=t}while(void 0===i.exceededTransferLimit&&i.features.length===t||!1!==i.exceededTransferLimit)}async _queryUsingIdSetTraversal(e){let t="",r=!1;null!=e.orderBy&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(t=e.orderBy.constructClause(),r=!0);const i=await this.databaseType(),a=null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,i),s=this._createQuery();s.where=w(s.where,a),null!=e.spatialFilter&&(s.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),s.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),s.geometry=e.spatialFilter.geometry),s.orderByFields=""!==t?t.split(","):null,s.outSpatialReference=this.spatialReference;const n=await this.executeQuery(s,"executeForIds");if(l(e.abortSignal),null==n||n.length<=0)return u;let o=this._maxQueryRate();const c=this._layer.capabilities?.query.maxRecordCount;null!=c&&c<o&&(o=c);const h=this._createQuery();return s.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),s.returnGeometry=!0!==this._removeGeometry,s.outSpatialReference=this.spatialReference,{ordered:r,filterApplied:!0,spatialFilterApplied:!0,features:this._traverseIdSet(h,n,o,e.abortSignal)}}async*_traverseIdSet(e,t,r,i){for(let a=0;a<t.length;a+=r){e.objectIds=t.slice(a,a+r),l(i);const s=await this.executeQuery(e,"execute");yield s.features}}async queryStat(e){await this._ensureLoaded();const t=this._layer.capabilities?.query,r=!!t?.supportsSqlExpression,i=!!t?.supportsStatistics,a=!!t?.supportsDistinct,s=_(e.stat);if("count"===s)return a?this._queryCount(e):{calculated:!1};const l=e.field;if(null==l)return{calculated:!1};if(!1===i||!1===p(l)&&!1===r||!1===l.isStandardized)return null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(e.stat,l,e.limit??c,e.abortSignal);if("distinct"===s)return!1===a?null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(s,l,e.limit??c,e.abortSignal):{calculated:!1};const o=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:null};const u=this._createQuery();u.where=w(u.where,null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,o)),null!=e.spatialFilter&&(u.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),u.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),u.geometry=e.spatialFilter.geometry);const h=new T;h.statisticType=s,h.onStatisticField=d(l,o),h.outStatisticFieldName="ARCADE_STAT_RESULT",u.returnGeometry=!1;let y="ARCADE_STAT_RESULT";u.outStatistics=[h];const m=await this.executeQuery(u,"execute");if(!m.hasOwnProperty("features")||0===m.features.length)throw new n("InvalidStatResponse");let f=!1;const F=m.fields??[];for(const n of F)if("ARCADE_STAT_RESULT"===n.name.toUpperCase()){y=n.name,"date"===n.type&&(f=!0);break}const g=m.features[0].attributes[y];return{calculated:!0,result:f&&null!=g?new Date(g):g}}async _queryCount(e){const t=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:0};const r=this._createQuery();r.where=w(r.where,null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,t)),null!=e.spatialFilter&&(r.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),r.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),r.geometry=e.spatialFilter.geometry),r.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(r,"executeForCount")}}async canQueryAggregate(e){await this._ensureLoaded();let t=!1;const r=this._layer.capabilities?.query,i=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(t=!0),t)for(const a of e.statistics)(!1===a.workingexpr?.isStandardized||!1===p(a.workingexpr)&&!1===i)&&(t=!1);return t}async queryAggregate(e){if(await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter)return u;const t=await this.databaseType(),r=e.groupBy,i=e.orderBy;let a=null;if(!this._layer.capabilities.query.supportsPaginationOnAggregatedQueries){const e=this.getFieldsIndex();a={keyFields:r.map((t,r)=>({name:e.normalizeFieldName(t)??t,asc:null==i||1===i._directions[r]}))}}let s="",l=!1;null!=i&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(null==a||m(r,0,r.length,i._fields,0,Math.min(i._fields.length,r.length),(e,t)=>e.toLowerCase()===t.toLowerCase()))&&(s=i.constructClause(),l=!0),""===s&&(s=r.join(","));const n=e.statistics.map(e=>new T({onStatisticField:null!==e.workingexpr?d(e.workingexpr,t):"",outStatisticFieldName:e.field,statisticType:e.toStatisticsName()}));let o=this._maxQueryRate();const c=this._layer.capabilities?.query.maxRecordCount;null!=c&&c<o&&(o=c);const h=null==e.where?null==e.spatialFilter?"1=1":"":d(e.where,t),y=this._createQuery();return y.where=w(y.where,h),null!=e.spatialFilter&&(y.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),y.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),y.geometry=e.spatialFilter.geometry),y.orderByFields=""!==s?s.split(","):null,y.outFields=["*"],y.outStatistics=n,y.groupByFieldsForStatistics=r,y.returnGeometry=!1,null==a?{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryPaginated(y,o,e.abortSignal)}:{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryKeysetPaginated(y,a,e.abortSignal)}}async*_queryKeysetPaginated(e,t,r){const i=e.where;for(;;){if(null!=t.clause){if(!this._layer.capabilities.query.supportsOrderBy)throw new n("NotImplemented");e.where=w(i,d(t.clause,await this.databaseType()))}const a=await this.executeQuery(e,"execute");if(l(r),!a.hasOwnProperty("features"))throw new n("InvalidStatResponse");if(yield a.features,0===a.features.length||!a.exceededTransferLimit)break;v(t,a.features.at(-1))}}_createQuery(){const e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,this.datesInUnknownTimezone&&(e.timeReferenceUnknownClient=!0),this._requestStandardised&&(e.sqlFormat="standard"),this._useDefinitionExpression?"subtype-group"===this._layer.type&&(e.where=this._layer.definitionExpression):e.where=null,e}executeQuery(e,t){const r="execute"===t?this._layer.queryFeatures.bind(this._layer):"executeForCount"===t?this._layer.queryFeatureCount.bind(this._layer):this._layer.queryObjectIds.bind(this._layer);let i=null;if(this._recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);i=this._recentlyUsedQueries.getFromCache(t),null===i&&(i=r(e),this._recentlyUsedQueries.addToCache(t,i),i=i.catch(e=>{throw this._recentlyUsedQueries?.removeFromCache(t),e}))}return this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===i&&(i=r(e)),i}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return r||t.push(this.objectIdField),t}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}static create(e,t,r,i,a){const s=new b({url:e,outFields:null===t?["*"]:t});return new j({layer:s,spatialReference:r,lrucache:i,interceptor:a})}relationshipMetadata(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return y(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,i,l){function n(e){const t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}const o=this._layer;if(!n(o))return[];const u=new I({objectIds:[e],returnMetadata:l});(t&&t>0||r&&r>0)&&(u.size=[t&&t>0?t:0,r&&r>0?r:t+1]),i&&i.length>0&&(u.attachmentTypes=i),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:o,query:u,method:"attachments"});const c=await o.queryAttachments(u);return c?.[e]?c[e].map(t=>{const r=`${this._layer.parsedUrl.path}/${e}/attachments/${t.id}`;let i=null;return l&&t.exifInfo&&(i=s.convertJsonToArcade(t.exifInfo,"system",!0)),new a(t.id,t.name,t.contentType,t.size,r,i,t.keywords??null)}):[]}async queryRelatedFeatures(t){const i=R(t);i.f="json",this._requestStandardised&&(i.sqlFormat="standard"),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const a=await r(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i});if(a.data){const t={},r=a.data;if(r?.relatedRecordGroups){const i=r.spatialReference,a=!0===r.exceededTransferLimit;for(const s of r.relatedRecordGroups){const r=s.relatedRecords.map(t=>(t.geometry&&(t.geometry.spatialReference=i),new e({geometry:t.geometry?S(t.geometry):null,attributes:t.attributes})));t[s.objectId]={features:r,exceededTransferLimit:a}}}return t}throw new n("InvalidRequest")}async getFeatureByObjectId(e,t){const r=this._createQuery();r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=w(r.where,this.objectIdField+"="+e.toString()),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"});const i=await this._layer.queryFeatures(r);return 1===i.features.length?i.features[0]:null}async getIdentityUser(){await this.load();const e=t?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=t?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl??"";let i=this._layer.url;const a=i.toLowerCase().indexOf("/rest/services");if(i=a>-1?i.slice(0,a):i,i){i+="/rest/info";try{const e=await r(i,{query:{f:"json"}});let t="";return e.data?.owningSystemUrl&&(t=e.data.owningSystemUrl),t}catch{return""}}return""}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this._recentlyUsedQueries??void 0,interceptor:this._featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this._featureSetInfo)return this._featureSetInfo;let e=null,t="serviceItemId"in this._layer?this._layer.serviceItemId:null;const i=this._layer.parsedUrl?.path??null;if(i){const a=await r(i,{responseType:"json",query:{f:"json"}});e=a?.data?.name??null,t=a?.data?.serviceItemId??null}const a=this._layer.title&&null!==(this._layer.parent??null);return this._featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===t?null:t,serviceLayerUrl:""===i?null:i,webMapLayerId:a?this._layer.id??null:null,webMapLayerTitle:a?this._layer.title??null:null,className:null,objectClassId:null},this._featureSetInfo}}export{j 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{neverAbortedSignal as t}from"../../arcadeEnvironment.js";import{throwIfCancelled as r,FeatureSetError as i}from"../support/errorsupport.js";import{FeatureSet as s,emptyFeaturesResult as a}from"../support/FeatureSet.js";import{defaultMaxRecords as l}from"../support/shared.js";import{toWhereClause as n}from"../support/sqlUtils.js";import{splitIntoChunks as o}from"../../../core/arrayUtils.js";import{sqlAnd as y}from"../../../core/sql.js";import u from"../../../geometry/Geometry.js";import p from"../../../layers/FeatureLayer.js";import h from"../../../layers/support/FeatureType.js";import d from"../../../layers/support/Field.js";class c extends s{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return l}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type||this._layer.objectIdField===r.name)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this._databaseType=0,this.hasZ=!0===this._layer.capabilities?.data?.supportsZ,this.hasM=!0===this._layer.capabilities?.data?.supportsM,this.subtypeField=("subtypeField"in this._layer?this._layer.subtypeField:null)??"",this.subtypes="subtypes"in this._layer?this._layer.subtypes:null,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}isTable(){return this._forceIsTable||"isTable"in this._layer&&this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}async _queryAll(){return(await this.query({abortSignal:t})).features}async query(e){await this._ensureLoaded();let t="",i=!1;if(null!=e.orderBy&&(t=e.orderBy.constructClause(),i=!0),this.isTable()&&null!=e.spatialFilter)return a;const s=this._createQuery();return s.where=y(s.where,null==e.where?null==e.spatialFilter?"1=1":"":n(e.where,0)),null!=e.spatialFilter&&(s.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),s.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),s.geometry=e.spatialFilter.geometry),s.outSpatialReference=this.spatialReference,s.orderByFields=""!==t?t.split(","):null,{filterApplied:!0,spatialFilterApplied:!0,ordered:i,features:async function*(){const t=await this._layer.queryFeatures(s);r(e.abortSignal);for(const e of o(t.features,this._maxQueryRate()))yield e.map(e=>this._changeFeature(e))}.apply(this)}}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new i("NeverReach")}_createQuery(){const e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,e.outFields=this._overrideFields??["*"],e.returnGeometry=!this._removeGeometry,e}_changeFeature(t){const r={};for(const e of this.fields)r[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:r})}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}relationshipMetadata(){return[]}nativeCapabilities(){return{title:this._layer.title??"",canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let r=e.layerDefinition.objectIdField;const i=e.layerDefinition.typeIdField??"",s=[];if(e.layerDefinition.types)for(const u of e.layerDefinition.types)s.push(h.fromJSON(u));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let l=e.featureSet.features;if(!r){let t=!1;for(const i of e.layerDefinition.fields)if("oid"===i.type||"esriFieldTypeOID"===i.type){r=i.name,t=!0;break}if(!1===t){let t="FID",i=!0,s=0;for(;i;){let r=!0;for(const i of e.layerDefinition.fields)if(i.name===t){r=!1;break}!0===r?i=!1:(s++,t="FID"+s.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const a=[];for(let r=0;r<l.length;r++)a.push({geometry:e.featureSet.features[r].geometry,attributes:{...e.featureSet.features[r].attributes,[t]:r}});l=a,r=t}}const n=[];for(const u of e.layerDefinition.fields)u instanceof d?n.push(u):n.push(d.fromJSON(u));let o=a;switch(o||(o=""),o){case"esriGeometryPoint":o="point";break;case"esriGeometryPolyline":o="polyline";break;case"esriGeometryPolygon":o="polygon";break;case"esriGeometryEnvelope":o="extent";break;case"esriGeometryMultipoint":o="multipoint";break;case"":case"esriGeometryNull":o="esriGeometryNull"}if("esriGeometryNull"!==o){const e=t.toJSON();for(const t of l)t.geometry&&t.geometry instanceof u==!1&&(t.geometry.type=o,void 0===t.geometry.spatialReference&&(t.geometry.spatialReference=e))}else for(const u of l)u.geometry&&(u.geometry=null);const y={outFields:["*"],source:l,fields:n,hasZ:!0===e.layerDefinition.hasZ||!0===e.featureSet.hasZ,hasM:!0===e.layerDefinition.hasM||!0===e.featureSet.hasM,types:s,typeIdField:i,objectIdField:r,spatialReference:t},f="esriGeometryNull"===o||null===o;f||(y.geometryType=o);const m=new p(y);return e.layerDefinition.subtypeField&&e.layerDefinition.subtypes&&m.read({subtypes:e.layerDefinition.subtypes,subtypeField:e.layerDefinition.subtypeField}),new c({layer:m,spatialReference:t,isTable:f})}async queryAttachments(){return[]}async getFeatureByObjectId(e){const t=this._createQuery();t.where=this.objectIdField+"="+e.toString();const r=await this._layer.queryFeatures(t);return 1===r.features.length?r.features[0]:null}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}get preferredTimeZone(){return"preferredTimeZone"in this._layer?this._layer.preferredTimeZone:null}get dateFieldsTimeZone(){return"dateFieldsTimeZone"in this._layer?this._layer.dateFieldsTimeZone:null}get datesInUnknownTimezone(){return"datesInUnknownTimezone"in this._layer&&this._layer.datesInUnknownTimezone}get editFieldsInfo(){return"editFieldsInfo"in this._layer?this._layer.editFieldsInfo:null}get timeInfo(){return this._layer.timeInfo}async getFeatureSetInfo(){const e=this._layer.title&&this._layer.parent;return{layerId:null,layerName:null,itemId:null,serviceLayerUrl:null,webMapLayerId:e?this._layer.id??null:null,webMapLayerTitle:e?this._layer.title??null:null,className:null,objectClassId:null}}}export{c as default};
5
+ import e from"../../../Graphic.js";import{neverAbortedSignal as t}from"../../arcadeEnvironment.js";import{throwIfCancelled as r,FeatureSetError as i}from"../support/errorsupport.js";import{RootFeatureSet as s,emptyFeaturesResult as a}from"../support/FeatureSet.js";import{defaultMaxRecords as l}from"../support/shared.js";import{toWhereClause as n}from"../support/sqlUtils.js";import{splitIntoChunks as o}from"../../../core/arrayUtils.js";import{sqlAnd as y}from"../../../core/sql.js";import u from"../../../geometry/Geometry.js";import p from"../../../layers/FeatureLayer.js";import h from"../../../layers/support/FeatureType.js";import d from"../../../layers/support/Field.js";class c extends s{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return l}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}get gdbVersion(){return""}_initialiseFeatureSet(){if(this.spatialReference??=this._layer.spatialReference,this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=new Set(this._overrideFields.map(e=>e.toLowerCase()));this.fields=this.fields.filter(({type:t,name:r})=>"oid"===t||this._layer.objectIdField===r||e.has(r.toLowerCase())),this._overrideFields=this.fields.map(({name:e})=>e)}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this._databaseType=0,this.hasZ=!0===this._layer.capabilities?.data?.supportsZ,this.hasM=!0===this._layer.capabilities?.data?.supportsM,this.subtypeField=("subtypeField"in this._layer?this._layer.subtypeField:null)??"",this.subtypes="subtypes"in this._layer?this._layer.subtypes:null,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}isTable(){return this._forceIsTable||"isTable"in this._layer&&this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}async _queryAll(){return(await this.query({abortSignal:t})).features}async query(e){await this._ensureLoaded();let t="",i=!1;if(null!=e.orderBy&&(t=e.orderBy.constructClause(),i=!0),this.isTable()&&null!=e.spatialFilter)return a;const s=this._createQuery();return s.where=y(s.where,null==e.where?null==e.spatialFilter?"1=1":"":n(e.where,0)),null!=e.spatialFilter&&(s.spatialRelationship=this._makeRelationshipEnum(e.spatialFilter.relation),s.relationParameter=this._makeRelationshipParam(e.spatialFilter.relation),s.geometry=e.spatialFilter.geometry),s.outSpatialReference=this.spatialReference,s.orderByFields=""!==t?t.split(","):null,{filterApplied:!0,spatialFilterApplied:!0,ordered:i,features:async function*(){const t=await this._layer.queryFeatures(s);r(e.abortSignal);for(const e of o(t.features,this._maxQueryRate()))yield e.map(e=>this._changeFeature(e))}.apply(this)}}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new i("NeverReach")}_createQuery(){const e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,e.outFields=this._overrideFields??["*"],e.returnGeometry=!this._removeGeometry,e}_changeFeature(t){const r={};for(const e of this.fields)r[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:r})}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}relationshipMetadata(){return[]}nativeCapabilities(){return{title:this._layer.title??"",canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let r=e.layerDefinition.objectIdField;const i=e.layerDefinition.typeIdField??"",s=[];if(e.layerDefinition.types)for(const u of e.layerDefinition.types)s.push(h.fromJSON(u));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let l=e.featureSet.features;if(!r){let t=!1;for(const i of e.layerDefinition.fields)if("oid"===i.type||"esriFieldTypeOID"===i.type){r=i.name,t=!0;break}if(!1===t){let t="FID",i=!0,s=0;for(;i;){let r=!0;for(const i of e.layerDefinition.fields)if(i.name===t){r=!1;break}!0===r?i=!1:(s++,t="FID"+s.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const a=[];for(let r=0;r<l.length;r++)a.push({geometry:e.featureSet.features[r].geometry,attributes:{...e.featureSet.features[r].attributes,[t]:r}});l=a,r=t}}const n=[];for(const u of e.layerDefinition.fields)u instanceof d?n.push(u):n.push(d.fromJSON(u));let o=a;switch(o||(o=""),o){case"esriGeometryPoint":o="point";break;case"esriGeometryPolyline":o="polyline";break;case"esriGeometryPolygon":o="polygon";break;case"esriGeometryEnvelope":o="extent";break;case"esriGeometryMultipoint":o="multipoint";break;case"":case"esriGeometryNull":o="esriGeometryNull"}if("esriGeometryNull"!==o){const e=t.toJSON();for(const t of l)t.geometry&&t.geometry instanceof u==!1&&(t.geometry.type=o,void 0===t.geometry.spatialReference&&(t.geometry.spatialReference=e))}else for(const u of l)u.geometry&&(u.geometry=null);const y={outFields:["*"],source:l,fields:n,hasZ:!0===e.layerDefinition.hasZ||!0===e.featureSet.hasZ,hasM:!0===e.layerDefinition.hasM||!0===e.featureSet.hasM,types:s,typeIdField:i,objectIdField:r,spatialReference:t},f="esriGeometryNull"===o||null===o;f||(y.geometryType=o);const m=new p(y);return e.layerDefinition.subtypeField&&e.layerDefinition.subtypes&&m.read({subtypes:e.layerDefinition.subtypes,subtypeField:e.layerDefinition.subtypeField}),new c({layer:m,spatialReference:t,isTable:f})}async queryAttachments(){return[]}async getFeatureByObjectId(e){const t=this._createQuery();t.where=this.objectIdField+"="+e.toString();const r=await this._layer.queryFeatures(t);return 1===r.features.length?r.features[0]:null}serviceUrl(){return""}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}get preferredTimeZone(){return"preferredTimeZone"in this._layer?this._layer.preferredTimeZone:null}get dateFieldsTimeZone(){return"dateFieldsTimeZone"in this._layer?this._layer.dateFieldsTimeZone:null}get datesInUnknownTimezone(){return"datesInUnknownTimezone"in this._layer&&this._layer.datesInUnknownTimezone}get editFieldsInfo(){return"editFieldsInfo"in this._layer?this._layer.editFieldsInfo:null}get timeInfo(){return this._layer.timeInfo}async getFeatureSetInfo(){const e=this._layer.title&&this._layer.parent;return{layerId:null,layerName:null,itemId:null,serviceLayerUrl:null,webMapLayerId:e?this._layer.id??null:null,webMapLayerTitle:e?this._layer.title??null:null,className:null,objectClassId:null}}}export{c as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ import e from"../../../Graphic.js";import{neverAbortedSignal as t}from"../../arcadeEnvironment.js";import{throwIfCancelled as r,FeatureSetError as a}from"../support/errorsupport.js";import{RootFeatureSet as i}from"../support/FeatureSet.js";import{isCurvedGeometry as s}from"../../../geometry/support/curves/curveUtils.js";class l extends i{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerOGC",this._outFields=null,this._returnGeometry=!0,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),null!=e.outFields&&(this._outFields=e.outFields),null!=e.includeGeometry&&(this._returnGeometry=e.includeGeometry)}_maxQueryRate(){return this._layer.effectiveMaxRecordCount}async loadImpl(){return this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(this.spatialReference??=this._layer.spatialReference,this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),null!=this._outFields)if(1===this._outFields.length&&"*"===this._outFields[0])this._outFields=null;else{const e=new Set(this._outFields.map(e=>e.toLowerCase()));this.fields=this.fields.filter(({name:t})=>t===this._layer.objectIdField||e.has(t.toLowerCase())),this._outFields=this.fields.map(({name:e})=>e)}this.objectIdField=this._layer.objectIdField,this.hasZ=!!this._layer.hasZ,this.hasM=!1,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types??null;const e=this._layer.source.getSource().layerDefinition.featureCount;null!=e&&e>=0&&(this._totalCount=e)}isTable(){return this._layer.isTable}async _queryAll(){const e=this._layer.createQuery();return e.outSpatialReference=this.spatialReference,this._queryPaginated(e,this._layer.effectiveMaxRecordCount,t)}async query(e){await this._ensureLoaded();const t=this._layer.createQuery();if(t.outSpatialReference=this.spatialReference,null!=e.spatialFilter&&!s(e.spatialFilter.geometry))switch(e.spatialFilter.relation){case"esriSpatialRelIntersects":case"esriSpatialRelContains":case"esriSpatialRelOverlaps":case"esriSpatialRelWithin":case"esriSpatialRelTouches":case"esriSpatialRelCrosses":t.geometry=e.spatialFilter.geometry.extent}return this._hasCachedFeatures||null==t.geometry?{filterApplied:null==e.where,spatialFilterApplied:null==e.spatialFilter,ordered:!1,features:await this.queryAll(e.abortSignal)}:{filterApplied:null==e.where,spatialFilterApplied:null==e.spatialFilter||"extent"===e.spatialFilter.geometry.type&&"esriSpatialRelIntersects"===e.spatialFilter.relation,ordered:!1,features:this._queryPaginated(t,this._layer.effectiveMaxRecordCount,e.abortSignal)}}async*_queryPaginated(t,a,i){let s;t.num=a,t.start=0;do{r(i),s=await this._layer.queryFeatures(t),yield s.features.map(t=>{const r={};for(const e of this.fields)r[e.name]=t.attributes[e.name];return new e({geometry:this._returnGeometry&&!this.isTable()?t.geometry:null,attributes:r})}),t.start+=s.features.length}while(s.exceededTransferLimit)}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new a("NeverReach")}nativeCapabilities(){return{title:this._layer.title??"",canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}async queryAttachments(){return[]}serviceUrl(){return""}relationshipMetadata(){return[]}get gdbVersion(){return""}getFeatureByObjectId(){throw new a("NeverReach")}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}get preferredTimeZone(){return null}get dateFieldsTimeZone(){return null}get datesInUnknownTimezone(){return!1}get editFieldsInfo(){return null}get timeInfo(){return this._layer.timeInfo}async getFeatureSetInfo(){const e=this._layer.title&&this._layer.parent;return{layerId:null,layerName:null,itemId:null,serviceLayerUrl:null,webMapLayerId:e?this._layer.id??null:null,webMapLayerTitle:e?this._layer.title??null:null,className:null,objectClassId:null}}}export{l 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{throwIfCancelled as t,FeatureSetError as r}from"../support/errorsupport.js";import{FeatureSet as i,emptyFeaturesResult as a}from"../support/FeatureSet.js";import{defaultMaxRecords as s}from"../support/shared.js";import l from"../../../rest/support/RelationshipQuery.js";class d extends i{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._removeGeometry=!1,this._overrideFields=null,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),this._findObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return s}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(),this.hasZ=this._relatedLayer.hasZ,this.hasM=this._relatedLayer.hasM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types,this.subtypeField=this._relatedLayer.subtypeField,this.subtypes=this._relatedLayer.subtypes}async databaseType(){return this._databaseType=await this._relatedLayer.databaseType(),this._databaseType}isTable(){return this._relatedLayer.isTable()}async _queryAll(){return(await this.query({abortSignal:e})).features}async query(e){if(await this._ensureLoaded(),await this.databaseType(),this.isTable()&&null!=e.spatialFilter)return a;const r=this._layer.nativeCapabilities();if(!1===r.canQueryRelated)return a;if(r.capabilities?.queryRelated.supportsPagination)return this._queryUsingPaging(r.source,e);let i="",s=!1;null!=e.orderBy&&!0===r.capabilities?.queryRelated.supportsOrderBy&&(i=e.orderBy.constructClause(),s=!0);const d=new l;return d.objectIds=[this._findObjectId],d.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map(e=>e.name):["*"]),d.relationshipId=this.relationship.id,d.where="1=1",d.returnGeometry=!0!==this._removeGeometry,d.outSpatialReference=this.spatialReference,d.orderByFields=""!==i?i.split(","):null,{filterApplied:null==e.where,spatialFilterApplied:null==e.spatialFilter,ordered:s,features:async function*(){const i=await r.source.queryRelatedFeatures(d);t(e.abortSignal),yield i[this._findObjectId]?i[this._findObjectId].features:[]}.apply(this)}}async _queryUsingPaging(e,t){let r="",i=!1;const a=this._layer.nativeCapabilities();null!=t.orderBy&&!0===a.capabilities?.queryRelated.supportsOrderBy&&(r=t.orderBy.constructClause(),i=!0),await this.databaseType();let s=this._maxQueryRate();const d=a.capabilities?.query.maxRecordCount;null!=d&&d<s&&(s=d);const n=new l;return n.relationshipId=this.relationship.id,n.objectIds=[this._findObjectId],n.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map(e=>e.name):["*"]),n.where="1=1",n.orderByFields=""!==r?r.split(","):null,n.returnGeometry=!0!==this._removeGeometry,n.outSpatialReference=this.spatialReference,{filterApplied:null==t.where,spatialFilterApplied:null==t.spatialFilter,ordered:i,features:this._queryPaginated(e,n,s,t.abortSignal)}}async*_queryPaginated(e,r,i,a){let s;r.num=i,r.start=0;do{t(a);s=(await e.queryRelatedFeatures(r))[this._findObjectId]??{exceededTransferLimit:!1,features:[]},yield s.features,r.start+=i}while(void 0===s.exceededTransferLimit&&s.features.length===i||!1!==s.exceededTransferLimit)}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new r("NeverReach")}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return r||t.push(this.objectIdField),t}get gdbVersion(){return this._relatedLayer.gdbVersion}relationshipMetadata(){return this._relatedLayer.relationshipMetadata()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,r,i,a){return this._relatedLayer.queryAttachments(e,t,r,i,a)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}get preferredTimeZone(){return this._relatedLayer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._relatedLayer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._relatedLayer.datesInUnknownTimezone}get editFieldsInfo(){return this._relatedLayer.editFieldsInfo??null}get timeInfo(){return this._relatedLayer.timeInfo??null}getFeatureSetInfo(){return this._relatedLayer.getFeatureSetInfo()}}export{d as default};
5
+ import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{throwIfCancelled as t,FeatureSetError as r}from"../support/errorsupport.js";import{RootFeatureSet as i,emptyFeaturesResult as a}from"../support/FeatureSet.js";import{defaultMaxRecords as s}from"../support/shared.js";import l from"../../../rest/support/RelationshipQuery.js";class d extends i{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._removeGeometry=!1,this._overrideFields=null,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),this._findObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return s}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(),this.hasZ=this._relatedLayer.hasZ,this.hasM=this._relatedLayer.hasM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=new Set(this._overrideFields.map(e=>e.toLowerCase()));this.fields=this.fields.filter(({type:t,name:r})=>"oid"===t||e.has(r.toLowerCase())),this._overrideFields=this.fields.map(({name:e})=>e)}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types,this.subtypeField=this._relatedLayer.subtypeField,this.subtypes=this._relatedLayer.subtypes}async databaseType(){return this._databaseType=await this._relatedLayer.databaseType(),this._databaseType}isTable(){return this._relatedLayer.isTable()}async _queryAll(){return(await this.query({abortSignal:e})).features}async query(e){if(await this._ensureLoaded(),await this.databaseType(),this.isTable()&&null!=e.spatialFilter)return a;const r=this._layer.nativeCapabilities();if(!1===r.canQueryRelated)return a;if(r.capabilities?.queryRelated.supportsPagination)return this._queryUsingPaging(r.source,e);let i="",s=!1;null!=e.orderBy&&!0===r.capabilities?.queryRelated.supportsOrderBy&&(i=e.orderBy.constructClause(),s=!0);const d=new l;return d.objectIds=[this._findObjectId],d.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map(e=>e.name):["*"]),d.relationshipId=this.relationship.id,d.where="1=1",d.returnGeometry=!0!==this._removeGeometry,d.outSpatialReference=this.spatialReference,d.orderByFields=""!==i?i.split(","):null,{filterApplied:null==e.where,spatialFilterApplied:null==e.spatialFilter,ordered:s,features:async function*(){const i=await r.source.queryRelatedFeatures(d);t(e.abortSignal),yield i[this._findObjectId]?i[this._findObjectId].features:[]}.apply(this)}}async _queryUsingPaging(e,t){let r="",i=!1;const a=this._layer.nativeCapabilities();null!=t.orderBy&&!0===a.capabilities?.queryRelated.supportsOrderBy&&(r=t.orderBy.constructClause(),i=!0),await this.databaseType();let s=this._maxQueryRate();const d=a.capabilities?.query.maxRecordCount;null!=d&&d<s&&(s=d);const n=new l;return n.relationshipId=this.relationship.id,n.objectIds=[this._findObjectId],n.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map(e=>e.name):["*"]),n.where="1=1",n.orderByFields=""!==r?r.split(","):null,n.returnGeometry=!0!==this._removeGeometry,n.outSpatialReference=this.spatialReference,{filterApplied:null==t.where,spatialFilterApplied:null==t.spatialFilter,ordered:i,features:this._queryPaginated(e,n,s,t.abortSignal)}}async*_queryPaginated(e,r,i,a){let s;r.num=i,r.start=0;do{t(a);s=(await e.queryRelatedFeatures(r))[this._findObjectId]??{exceededTransferLimit:!1,features:[]},yield s.features,r.start+=i}while(void 0===s.exceededTransferLimit&&s.features.length===i||!1!==s.exceededTransferLimit)}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new r("NeverReach")}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return r||t.push(this.objectIdField),t}get gdbVersion(){return this._relatedLayer.gdbVersion}relationshipMetadata(){return this._relatedLayer.relationshipMetadata()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,r,i,a){return this._relatedLayer.queryAttachments(e,t,r,i,a)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}get preferredTimeZone(){return this._relatedLayer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._relatedLayer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._relatedLayer.datesInUnknownTimezone}get editFieldsInfo(){return this._relatedLayer.editFieldsInfo??null}get timeInfo(){return this._relatedLayer.timeInfo??null}getFeatureSetInfo(){return this._relatedLayer.getFeatureSetInfo()}}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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import t from"./cache.js";import{throwIfCancelled as a,FeatureSetError as s}from"./errorsupport.js";import{QueryIterator as i}from"./FeatureSetIterator.js";import{layerGeometryEsriConstants as r,esriFieldToJson as n,layerGeometryEsriRestConstants as l}from"./shared.js";import{max as o,min as u,sum as h,variance as d,stdev as p,mean as c,distinct as y}from"./stats.js";import{invokeRemoteGeometryOp as m}from"../../geometry/operatorsWorkerConnection.js";import{cacheAsync as f}from"../../../core/iteratorUtils.js";import _ from"../../../core/sql/WhereClause.js";import b from"../../../geometry/SpatialReference.js";import g from"../../../layers/support/FieldsIndex.js";const T=Object.freeze({ordered:!0,filterApplied:!0,spatialFilterApplied:!0,features:Object.freeze({next:()=>Promise.resolve({done:!0,value:void 0}),[Symbol.asyncIterator](){return this}})});class F{constructor(){this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._parent=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=7,this._databaseTypeProbed=null,this._loadPromise=null,this._allFeatures=null,this._fieldsIndex=null,this.typeIdField=null,this.types=null,this.subtypeField=null,this.subtypes=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return await(this._parent?.load()),this._initialiseFeatureSet(),this}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(),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.subtypeField=this._parent.subtypeField,this.subtypes=this._parent.subtypes):(this.fields=[],this.typeIdField="",this.subtypeField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new b({wkid:4326}),this.geometryType=r.point)}getField(e,t){return e=e.toLowerCase(),(t||this.fields).find(t=>t.name.toLowerCase()===e)}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=g.fromLayer({timeInfo:this.timeInfo,editFieldsInfo:this.editFieldsInfo,dateFieldsTimeZone:this.dateFieldsTimeZone,datesInUnknownTimezone:this.datesInUnknownTimezone,fields:this.fields})),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}nativeCapabilities(){return this._parent.nativeCapabilities()}async queryAll(t){null==this._allFeatures&&(this._allFeatures=this._queryAll().then(e=>f(e)));const s=(await this._allFeatures)();return null==t||t===e?s:async function*(){for await(const e of s)a(t),yield e}()}async databaseType(){if(7===this._databaseType){if(null!==t.applicationCache){const e=t.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==e)return e}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==t.applicationCache&&t.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw null!==t.applicationCache&&t.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{dbType:2,probeSql:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{dbType:3,probeSql:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{dbType:1,probeSql:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.probeSql))return t.dbType}return 1}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new s("NotImplemented")}isTable(){return this._parent?.isTable()??!1}first(e){return this.iterator(e).next()}async isEmpty(e){return this._totalCount>=0?0===this._totalCount:null==await this.first(e)}async calculateStatistic(e,t,a,s){await this._ensureLoaded();let i=await this.queryStat({stat:e,field:t,limit:a,abortSignal:s});return!1===i.calculated&&(i=await this._manualStat(e,t,a,s)),i.result}async _manualStat(e,t,a,s){let i=null;switch(e.toLowerCase()){case"count":{if(this._totalCount>=0)return{calculated:!0,result:this._totalCount};const e=await this.queryAll(s);let t=0;for await(const a of e)t+=a.length;return this._totalCount=t,{calculated:!0,result:t}}case"distinct":return i=await y(this,t,a,s),{calculated:!0,result:i};case"avg":case"mean":return i=await c(this,t,s),{calculated:!0,result:i};case"stdev":return i=await p(this,t,s),{calculated:!0,result:i};case"variance":return i=await d(this,t,s),{calculated:!0,result:i};case"sum":return i=await h(this,t,s),{calculated:!0,result:i};case"min":return i=await u(this,t,s),{calculated:!0,result:i};case"max":return i=await o(this,t,s),{calculated:!0,result:i};default:return{calculated:!0,result:0}}}iterator(e){return new i(this,e)}async sumArea(e,t,a){const s=this.iterator(a);let i,r=0;for(;null!=(i=await s.next());)null!=i.geometry&&(r+=null!=t?await m("geodeticArea",[i.geometry.toJSON(),e,t]):await m("area",[i.geometry.toJSON(),e]));return r}async sumLength(e,t,a){const s=this.iterator(a);let i,r=0;for(;null!=(i=await s.next());)null!=i.geometry&&(r+=null!=t?await m("geodeticLength",[i.geometry.toJSON(),e,t]):await m("length",[i.geometry.toJSON(),e]));return r}async count(t){return await this.load(),this.calculateStatistic("count",_.create("1",{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),-1,t??e)}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,a,s,i){return this._parent.queryAttachments(e,t,a,s,i)}serviceUrl(){return this._parent.serviceUrl()}subtypeMetadata(){return this.subtypeField&&this.subtypes?{subtypeField:this.subtypeField,subtypes:this.subtypes?this.subtypes.map(e=>({name:e.name,code:e.code})):[]}:this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map(e=>({name:e.name,code:e.id})):[]}:null}relationshipMetadata(){return this._parent.relationshipMetadata()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(n(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===l[this.geometryType]?"esriGeometryNull":l[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];for await(const a of await this.queryAll(t))for(const t of a){const a={geometry:t.geometry?t.geometry.toJSON():null,attributes:t.attributes};null!==a.geometry&&a.geometry.spatialReference&&delete a.geometry.spatialReference,e.push(a)}return JSON.stringify({...this.schema(),features:e,spatialReference:this.spatialReference.toJSON()})}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const a=[];for await(const s of await this.queryAll(e))for(const e of s){const s={geometry:e.geometry?!0===t?.keepGeometryType?e.geometry:e.geometry.toJSON():null,attributes:e.attributes};null!==s.geometry&&s.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete s.geometry.spatialReference,a.push(s)}return{...this.schema(),features:a,spatialReference:!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON()}}fieldTimeZone(e){return this.getFieldsIndex().getTimeZone(e)}get preferredTimeZone(){return this._parent?.preferredTimeZone??null}get dateFieldsTimeZone(){return this._parent?.dateFieldsTimeZone??null}get dateFieldsTimeZoneDefaultUTC(){return this.datesInUnknownTimezone?"unknown":this.dateFieldsTimeZone||"UTC"}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}getFeatureSetInfo(){return this._parent?this._parent.getFeatureSetInfo():Promise.resolve(null)}}export{F as FeatureSet,T as emptyFeaturesResult};
5
+ import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import t from"./cache.js";import{throwIfCancelled as a,FeatureSetError as s}from"./errorsupport.js";import{QueryIterator as r}from"./FeatureSetIterator.js";import{layerGeometryEsriConstants as i,esriFieldToJson as n,layerGeometryEsriRestConstants as l}from"./shared.js";import{max as o,min as u,sum as h,variance as d,stdev as p,mean as c,distinct as y}from"./stats.js";import{invokeRemoteGeometryOp as m}from"../../geometry/operatorsWorkerConnection.js";import{cacheAsync as f}from"../../../core/iteratorUtils.js";import _ from"../../../core/sql/WhereClause.js";import b from"../../../geometry/SpatialReference.js";import g from"../../../layers/support/FieldsIndex.js";const T=Object.freeze({ordered:!0,filterApplied:!0,spatialFilterApplied:!0,features:Object.freeze({next:()=>Promise.resolve({done:!0,value:void 0}),[Symbol.asyncIterator](){return this}})});class F{constructor(){this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._parent=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=7,this._databaseTypeProbed=null,this._loadPromise=null,this._allFeatures=null,this._fieldsIndex=null,this.typeIdField=null,this.types=null,this.subtypeField=null,this.subtypes=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return await(this._parent?.load()),this._initialiseFeatureSet(),this}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(),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.subtypeField=this._parent.subtypeField,this.subtypes=this._parent.subtypes):(this.fields=[],this.typeIdField="",this.subtypeField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new b({wkid:4326}),this.geometryType=i.point)}getField(e,t){return e=e.toLowerCase(),(t||this.fields).find(t=>t.name.toLowerCase()===e)}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=g.fromLayer({timeInfo:this.timeInfo,editFieldsInfo:this.editFieldsInfo,dateFieldsTimeZone:this.dateFieldsTimeZone,datesInUnknownTimezone:this.datesInUnknownTimezone,fields:this.fields})),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}nativeCapabilities(){return this._parent.nativeCapabilities()}get _hasCachedFeatures(){return null!=this._allFeatures}async queryAll(t){null==this._allFeatures&&(this._allFeatures=this._queryAll().then(e=>f(e)));const s=(await this._allFeatures)();return null==t||t===e?s:async function*(){for await(const e of s)a(t),yield e}()}async databaseType(){if(7===this._databaseType){if(null!==t.applicationCache){const e=t.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==e)return e}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==t.applicationCache&&t.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw null!==t.applicationCache&&t.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{dbType:2,probeSql:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{dbType:3,probeSql:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{dbType:1,probeSql:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.probeSql))return t.dbType}return 1}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new s("NotImplemented")}isTable(){return this._parent?.isTable()??!1}first(e){return this.iterator(e).next()}async isEmpty(e){return this._totalCount>=0?0===this._totalCount:null==await this.first(e)}async calculateStatistic(e,t,a,s){await this._ensureLoaded();let r=await this.queryStat({stat:e,field:t,limit:a,abortSignal:s});return!1===r.calculated&&(r=await this._manualStat(e,t,a,s)),r.result}async _manualStat(e,t,a,s){let r=null;switch(e.toLowerCase()){case"count":{if(this._totalCount>=0)return{calculated:!0,result:this._totalCount};const e=await this.queryAll(s);let t=0;for await(const a of e)t+=a.length;return this._totalCount=t,{calculated:!0,result:t}}case"distinct":return r=await y(this,t,a,s),{calculated:!0,result:r};case"avg":case"mean":return r=await c(this,t,s),{calculated:!0,result:r};case"stdev":return r=await p(this,t,s),{calculated:!0,result:r};case"variance":return r=await d(this,t,s),{calculated:!0,result:r};case"sum":return r=await h(this,t,s),{calculated:!0,result:r};case"min":return r=await u(this,t,s),{calculated:!0,result:r};case"max":return r=await o(this,t,s),{calculated:!0,result:r};default:return{calculated:!0,result:0}}}iterator(e){return new r(this,e)}async sumArea(e,t,a){const s=this.iterator(a);let r,i=0;for(;null!=(r=await s.next());)null!=r.geometry&&(i+=null!=t?await m("geodeticArea",[r.geometry.toJSON(),e,t]):await m("area",[r.geometry.toJSON(),e]));return i}async sumLength(e,t,a){const s=this.iterator(a);let r,i=0;for(;null!=(r=await s.next());)null!=r.geometry&&(i+=null!=t?await m("geodeticLength",[r.geometry.toJSON(),e,t]):await m("length",[r.geometry.toJSON(),e]));return i}async count(t){return await this.load(),this.calculateStatistic("count",_.create("1",{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),-1,t??e)}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,a,s,r){return this._parent.queryAttachments(e,t,a,s,r)}serviceUrl(){return this._parent.serviceUrl()}subtypeMetadata(){return this.subtypeField&&this.subtypes?{subtypeField:this.subtypeField,subtypes:this.subtypes?this.subtypes.map(e=>({name:e.name,code:e.code})):[]}:this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map(e=>({name:e.name,code:e.id})):[]}:null}relationshipMetadata(){return this._parent.relationshipMetadata()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(n(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===l[this.geometryType]?"esriGeometryNull":l[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];for await(const a of await this.queryAll(t))for(const t of a){const a={geometry:t.geometry?t.geometry.toJSON():null,attributes:t.attributes};null!==a.geometry&&a.geometry.spatialReference&&delete a.geometry.spatialReference,e.push(a)}return JSON.stringify({...this.schema(),features:e,spatialReference:this.spatialReference.toJSON()})}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return this._parent.getRootFeatureSet()}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const a=[];for await(const s of await this.queryAll(e))for(const e of s){const s={geometry:e.geometry?!0===t?.keepGeometryType?e.geometry:e.geometry.toJSON():null,attributes:e.attributes};null!==s.geometry&&s.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete s.geometry.spatialReference,a.push(s)}return{...this.schema(),features:a,spatialReference:!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON()}}fieldTimeZone(e){return this.getFieldsIndex().getTimeZone(e)}get preferredTimeZone(){return this._parent?.preferredTimeZone??null}get dateFieldsTimeZone(){return this._parent?.dateFieldsTimeZone??null}get dateFieldsTimeZoneDefaultUTC(){return this.datesInUnknownTimezone?"unknown":this.dateFieldsTimeZone||"UTC"}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}getFeatureSetInfo(){return this._parent?this._parent.getFeatureSetInfo():Promise.resolve(null)}}class I extends F{constructor(){super(...arguments),this._parent=null}getRootFeatureSet(){return this}}export{F as FeatureSet,I as RootFeatureSet,T as emptyFeaturesResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as i}from"../../../core/sql/DateOnly.js";import{TimeOnly as r}from"../../../core/sql/TimeOnly.js";import t from"../../../layers/support/Field.js";import{DateTime as n}from"luxon";function o(e){return t.fromJSON(e.toJSON())}function l(e){return e.toJSON?e.toJSON():e}function s(e){return"string"==typeof e||e instanceof String}function y(e){return"boolean"==typeof e}function p(e){return"number"==typeof e}function u(e){return Array.isArray(e)}function c(e){return e instanceof Date}function m(e){return e instanceof n}function a(i){return i instanceof e}function f(e){return e instanceof i}function d(e){return e instanceof r}function T(e,i){return e===i||!(!c(e)&&!a(e)||!c(i)&&!a(i))&&e.getTime()===i.getTime()}function g(e){const i={};for(const r in e)i[r]=e[r];return i}function F(e,i){return e===i||("point"===e&&"esriGeometryPoint"===i||("polyline"===e&&"esriGeometryPolyline"===i||("polygon"===e&&"esriGeometryPolygon"===i||("extent"===e&&"esriGeometryEnvelope"===i||("multipoint"===e&&"esriGeometryMultipoint"===i||("point"===i&&"esriGeometryPoint"===e||("polyline"===i&&"esriGeometryPolyline"===e||("polygon"===i&&"esriGeometryPolygon"===e||("extent"===i&&"esriGeometryEnvelope"===e||"multipoint"===i&&"esriGeometryMultipoint"===e)))))))))}const G=1e3;function O(e){return function(i){e.reject(i)}}function b(e,i){return function(){try{e.apply(null,arguments)}catch(r){i.reject(r)}}}const S={point:"point",polygon:"polygon",polyline:"polyline",multipoint:"multipoint",extent:"extent",esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint",esriGeometryEnvelope:"extent",envelope:"extent"},D={point:"esriGeometryPoint",polygon:"esriGeometryPolygon",polyline:"esriGeometryPolyline",multipoint:"esriGeometryMultipoint",extent:"esriGeometryEnvelope",esriGeometryPoint:"esriGeometryPoint",esriGeometryPolygon:"esriGeometryPolygon",esriGeometryPolyline:"esriGeometryPolyline",esriGeometryMultipoint:"esriGeometryMultipoint",esriGeometryEnvelope:"esriGeometryEnvelope",envelope:"esriGeometryEnvelope"},P={"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 v(e){switch(e){case"point":default:return"esriGeometryPoint";case"polygon":return"esriGeometryPolygon";case"multipoint":return"esriGeometryMultipoint";case"polyline":return"esriGeometryPolyline"}}function I(e){return void 0===e?"":e=(e=(e=e.replace(/\/featureserver\/[0-9]*/i,"/FeatureServer")).replace(/\/mapserver\/[0-9]*/i,"/MapServer")).split("?")[0]}function J(e,i){i||(i={}),"function"==typeof i&&(i={cmp:i});const r="boolean"==typeof i.cycles&&i.cycles,t=i.cmp&&(n=i.cmp,function(e){return function(i,r){const t={key:i,value:e[i]},o={key:r,value:e[r]};return n(t,o)}});var n;const o=[];return function e(i){if(i?.toJSON&&"function"==typeof i.toJSON&&(i=i.toJSON()),void 0===i)return;if("number"==typeof i)return isFinite(i)?""+i:"null";if("object"!=typeof i)return JSON.stringify(i);let n,l;if(Array.isArray(i)){for(l="[",n=0;n<i.length;n++)n&&(l+=","),l+=e(i[n])||"null";return l+"]"}if(null===i)return"null";if(o.includes(i)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const s=o.push(i)-1,y=Object.keys(i).sort(t?.(i));for(l="",n=0;n<y.length;n++){const r=y[n],t=e(i[r]);t&&(l&&(l+=","),l+=JSON.stringify(r)+":"+t)}return o.splice(s,1),"{"+l+"}"}(e)}function M(e){switch(e.type){case"catalog":case"csv":case"feature":case"geojson":case"knowledge-graph-sublayer":case"oriented-imagery":case"subtype-group":case"wfs":return!0;default:return!1}}function N(e){switch(e.type){case"catalog-footprint":case"subtype-sublayer":return!0;default:return M(e)}}export{b as callback,g as cloneAttributes,o as cloneField,G as defaultMaxRecords,T as equalityTest,O as errback,l as esriFieldToJson,I as extractServiceUrl,a as isArcadeDate,f as isArcadeDateOnly,d as isArcadeTime,u as isArray,y as isBoolean,c as isDate,m as isLuxonDate,p as isNumber,s as isString,N as isSupportedLayer,M as isSupportedSourceLayer,P as layerFieldEsriConstants,S as layerGeometryEsriConstants,D as layerGeometryEsriRestConstants,F as sameGeomType,J as stableStringify,v as toEsriGeometryType};
5
+ import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as i}from"../../../core/sql/DateOnly.js";import{TimeOnly as r}from"../../../core/sql/TimeOnly.js";import t from"../../../layers/support/Field.js";import{DateTime as n}from"luxon";function o(e){return t.fromJSON(e.toJSON())}function l(e){return e.toJSON?e.toJSON():e}function s(e){return"string"==typeof e||e instanceof String}function y(e){return"boolean"==typeof e}function p(e){return"number"==typeof e}function u(e){return Array.isArray(e)}function c(e){return e instanceof Date}function m(e){return e instanceof n}function a(i){return i instanceof e}function f(e){return e instanceof i}function d(e){return e instanceof r}function T(e,i){return e===i||!(!c(e)&&!a(e)||!c(i)&&!a(i))&&e.getTime()===i.getTime()}function g(e){const i={};for(const r in e)i[r]=e[r];return i}function F(e,i){return e===i||("point"===e&&"esriGeometryPoint"===i||("polyline"===e&&"esriGeometryPolyline"===i||("polygon"===e&&"esriGeometryPolygon"===i||("extent"===e&&"esriGeometryEnvelope"===i||("multipoint"===e&&"esriGeometryMultipoint"===i||("point"===i&&"esriGeometryPoint"===e||("polyline"===i&&"esriGeometryPolyline"===e||("polygon"===i&&"esriGeometryPolygon"===e||("extent"===i&&"esriGeometryEnvelope"===e||"multipoint"===i&&"esriGeometryMultipoint"===e)))))))))}const G=1e3;function O(e){return function(i){e.reject(i)}}function b(e,i){return function(){try{e.apply(null,arguments)}catch(r){i.reject(r)}}}const S={point:"point",polygon:"polygon",polyline:"polyline",multipoint:"multipoint",extent:"extent",esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint",esriGeometryEnvelope:"extent",envelope:"extent"},D={point:"esriGeometryPoint",polygon:"esriGeometryPolygon",polyline:"esriGeometryPolyline",multipoint:"esriGeometryMultipoint",extent:"esriGeometryEnvelope",esriGeometryPoint:"esriGeometryPoint",esriGeometryPolygon:"esriGeometryPolygon",esriGeometryPolyline:"esriGeometryPolyline",esriGeometryMultipoint:"esriGeometryMultipoint",esriGeometryEnvelope:"esriGeometryEnvelope",envelope:"esriGeometryEnvelope"},P={"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 v(e){switch(e){case"point":default:return"esriGeometryPoint";case"polygon":return"esriGeometryPolygon";case"multipoint":return"esriGeometryMultipoint";case"polyline":return"esriGeometryPolyline"}}function I(e){return void 0===e?"":e=(e=(e=e.replace(/\/featureserver\/[0-9]*/i,"/FeatureServer")).replace(/\/mapserver\/[0-9]*/i,"/MapServer")).split("?")[0]}function J(e,i){i||(i={}),"function"==typeof i&&(i={cmp:i});const r="boolean"==typeof i.cycles&&i.cycles,t=i.cmp&&(n=i.cmp,function(e){return function(i,r){const t={key:i,value:e[i]},o={key:r,value:e[r]};return n(t,o)}});var n;const o=[];return function e(i){if(i?.toJSON&&"function"==typeof i.toJSON&&(i=i.toJSON()),void 0===i)return;if("number"==typeof i)return isFinite(i)?""+i:"null";if("object"!=typeof i)return JSON.stringify(i);let n,l;if(Array.isArray(i)){for(l="[",n=0;n<i.length;n++)n&&(l+=","),l+=e(i[n])||"null";return l+"]"}if(null===i)return"null";if(o.includes(i)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const s=o.push(i)-1,y=Object.keys(i).sort(t?.(i));for(l="",n=0;n<y.length;n++){const r=y[n],t=e(i[r]);t&&(l&&(l+=","),l+=JSON.stringify(r)+":"+t)}return o.splice(s,1),"{"+l+"}"}(e)}function M(e){switch(e.type){case"catalog":case"csv":case"feature":case"geojson":case"knowledge-graph-sublayer":case"ogc-feature":case"oriented-imagery":case"subtype-group":case"wfs":return!0;default:return!1}}function N(e){switch(e.type){case"catalog-footprint":case"subtype-sublayer":return!0;default:return M(e)}}export{b as callback,g as cloneAttributes,o as cloneField,G as defaultMaxRecords,T as equalityTest,O as errback,l as esriFieldToJson,I as extractServiceUrl,a as isArcadeDate,f as isArcadeDateOnly,d as isArcadeTime,u as isArray,y as isBoolean,c as isDate,m as isLuxonDate,p as isNumber,s as isString,N as isSupportedLayer,M as isSupportedSourceLayer,P as layerFieldEsriConstants,S as layerGeometryEsriConstants,D as layerGeometryEsriRestConstants,F as sameGeomType,J as stableStringify,v as toEsriGeometryType};