@arcgis/core 5.2.0-next.138 → 5.2.0-next.139

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 (34) hide show
  1. package/arcade/featureset/actions/GroupBy.js +1 -1
  2. package/arcade/featureset/support/FeatureSet.js +1 -1
  3. package/arcade/featureset/support/shared.js +1 -1
  4. package/arcade/featureset/support/sqlUtils.js +1 -1
  5. package/arcade/featureset/support/stats.js +1 -1
  6. package/arcade/functions/featuresetstats.js +1 -1
  7. package/arcade/functions/fieldStats.js +1 -1
  8. package/arcgisGlobal.d.ts +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/1380cec385426673f294.js +1 -0
  11. package/assets/esri/core/workers/chunks/2671035cc08027185737.js +1 -0
  12. package/assets/esri/core/workers/chunks/3f946c13ad97fbed867b.js +1 -0
  13. package/assets/esri/core/workers/chunks/8b1c17cc52d989924313.js +1 -0
  14. package/assets/esri/core/workers/chunks/acfa03c65ba3ca6c5685.js +1 -0
  15. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  16. package/core/sql/AggregateFunctions.js +1 -1
  17. package/legend/ActiveLayerInfo.d.ts +2 -2
  18. package/legend/{LegendContent.d.ts → LegendModel.d.ts} +10 -10
  19. package/legend/{LegendContent.js → LegendModel.js} +1 -1
  20. package/legend/types.d.ts +4 -4
  21. package/package.json +2 -2
  22. package/popup/FeatureContent.d.ts +17 -8
  23. package/popup/FeatureContent.js +1 -1
  24. package/popup/FeatureContentCollection.d.ts +0 -1
  25. package/popup/FeatureContentCollection.js +1 -1
  26. package/symbols/cim/cimAnalyzer.js +1 -1
  27. package/symbols/cim/types.d.ts +493 -8
  28. package/widgets/Legend/LegendViewModel.d.ts +3 -3
  29. package/widgets/Legend/LegendViewModel.js +1 -1
  30. package/assets/esri/core/workers/chunks/37fc47373c1c8fcdfd1a.js +0 -1
  31. package/assets/esri/core/workers/chunks/537dbd3b870bbef7433e.js +0 -1
  32. package/assets/esri/core/workers/chunks/703411e4a18a6a36048a.js +0 -1
  33. package/assets/esri/core/workers/chunks/879b2f0ff1977bca9376.js +0 -1
  34. package/assets/esri/core/workers/chunks/b748faaa5ebdeba73103.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{StringEnum as t}from"../../enum.js";import{a5 as n}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as r,OriginalField as i,AdaptedFeatureSet as a}from"./Adapted.js";import o from"./AttributeFilter.js";import s from"./OrderBy.js";import{FeatureSetError as c,throwIfCancelled as l}from"../support/errorsupport.js";import{FeatureSet as u,emptyFeaturesResult as d}from"../support/FeatureSet.js";import f from"../support/OrderbyClause.js";import{isSingleField as p,toWhereClause as m,predictType as h,scanForField as g,reformulateWithoutField as _}from"../support/sqlUtils.js";import v from"../support/StatsField.js";import{createMD5Hash as y,outputTypes as b}from"../../../core/MD5.js";import{aggregateFunction as x}from"../../../core/sql/AggregateFunctions.js";import{DateOnly as S}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as C}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as w}from"../../../core/sql/TimeOnly.js";import T from"../../../core/sql/WhereClause.js";import E from"../../../layers/support/Field.js";const D=new t([`MIN`,`MAX`,`VAR`,`STDDEV`,`COUNT`,`SUM`,`AVG`],[[`VARIANCE`,`VAR`],[`AVERAGE`,`AVG`],[`MEAN`,`AVG`],[`STDEV`,`STDDEV`]]);class O extends u{constructor(e){super(),this.declaredClass=`esri.arcade.featureset.actions.Aggregate`,this._decodedStatsFields=[],this._decodedGroupByFields=[],this._canDoSimpleGroupBy=!0,this._physicalGroupByFields=[],this.objectIdField=`ROW__ID`,this._adaptedFields=[],this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_nextUniqueName(e){for(;e[`T`+this._uniqueIds.toString()]===1;)this._uniqueIds++;let t=`T`+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){let e=this._parent.getFieldsIndex();this.objectIdField=`ROW__ID`,this.globalIdField=``;let t=!1,n=1;for(;t===!1;){let e=!1;for(let t of this._config.groupbyfields)if(t.name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(e===!1){for(let t of this._config.statsfields)if(t.name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}}e===!1?t=!0:(this.objectIdField=`ROW__ID`+n.toString(),n++)}for(let t of this._config.statsfields){let n=new v;n.field=t.name,n.tofieldname=t.name,n.workingexpr=t.expression instanceof T?t.expression:T.create(t.expression,{fieldsIndex:e,timeZone:this.dateFieldsTimeZoneDefaultUTC}),n.typeofstat=D.lookup(t.statistic)??`COUNT`,this._decodedStatsFields.push(n)}this._decodedGroupByFields=[];for(let t of this._config.groupbyfields){let n={name:t.name,singlefield:null,tofieldname:t.name,expression:t.expression instanceof T?t.expression:T.create(t.expression,{fieldsIndex:e,timeZone:this.dateFieldsTimeZoneDefaultUTC}),sqlType:null};this._decodedGroupByFields.push(n)}let a={};this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=``;for(let e of this._parent.fields)a[e.name.toUpperCase()]=1;this.types=null,this.subtypes=null,this.subtypeField=``,this.fields=[];let o=new v;o.field=this._nextUniqueName(a),o.tofieldname=this.objectIdField,o.workingexpr=T.create(this._parent.objectIdField,{fieldsIndex:this._parent.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),o.typeofstat=`MIN`,this._decodedStatsFields.push(o);for(let e of this._decodedGroupByFields){let t=new E;if(e.name=this._nextUniqueName(a),t.name=e.tofieldname,t.alias=t.name,p(e.expression)){let n=this._parent.getField(m(e.expression,0));if(!n)throw new c(`AggregationFieldNotFound`);e.name=n.name,e.singlefield=n.name,this._physicalGroupByFields.push(n.name),t.type=n.type,e.sqlType=n.type}else{t.type=this._convertToEsriFieldType(h(e.expression,this._parent.fields));let n=new E;n.name=e.name,n.alias=n.name,this._physicalGroupByFields.push(e.name),this._adaptedFields.push(new r(n,e.expression)),this._canDoSimpleGroupBy=!1,e.sqlType=t.type}this.fields.push(t)}if(this._adaptedFields.length>0)for(let e of this._parent.fields)this._adaptedFields.push(new i(e));for(let e of this._decodedStatsFields){let t=new E,n=null;e.field=this._nextUniqueName(a),t.name=e.tofieldname,t.alias=t.name;let r=e.workingexpr===null?``:p(e.workingexpr)?m(e.workingexpr,0):``;switch(e.typeofstat){case`SUM`:if(r!==``){if(n=this._parent.getField(r),!n)throw new c(`AggregationFieldNotFound`);t.type=n.type}else t.type=`double`;break;case`MIN`:case`MAX`:if(r!==``){if(n=this._parent.getField(r),!n)throw new c(`AggregationFieldNotFound`);t.type=n.type}else t.type=`double`;break;case`COUNT`:t.type=`integer`;break;case`STDDEV`:case`VAR`:case`AVG`:if(r!==``&&(n=this._parent.getField(r),!n))throw new c(`AggregationFieldNotFound`);t.type=`double`}this.fields.push(t)}}async _queryAll(){return(await this.query({abortSignal:e})).features}async query(e){if(e.spatialFilter!=null)return d;let t={ordered:!1,nowhereclause:!1};await this._ensureLoaded();let n=e.where;if(n!=null){for(let e of this._decodedStatsFields)if(g(n,e.tofieldname)===!0){t.nowhereclause=!0,n=null;break}}let r=e.orderBy;if(r!=null){t.ordered=!0;for(let e of this._decodedStatsFields)if(r.scanForField(e.tofieldname)===!0){r=null,t.ordered=!1;break}if(r!==null){for(let e of this._decodedGroupByFields)if(e.singlefield===null&&r.scanForField(e.tofieldname)===!0){r=null,t.ordered=!1;break}}}if(this._canDoSimpleGroupBy!==!1&&await this._parent.canQueryAggregate({groupBy:this._physicalGroupByFields,statistics:this._decodedStatsFields,where:null,spatialFilter:null,abortSignal:e.abortSignal})){let i=await this._parent.queryAggregate({groupBy:this._physicalGroupByFields,statistics:this._decodedStatsFields,where:n?this._reformulateWhereClauseWithoutGroupByFields(n):null,spatialFilter:null,orderBy:r?this._reformulateOrderClauseWithoutGroupByFields(r):null,abortSignal:e.abortSignal});return l(e.abortSignal),{...i,filterApplied:!t.nowhereclause&&i.filterApplied,ordered:t.ordered===!0&&i.ordered,features:this._fixAggregateAttributeNames(i.features)}}let i=this._adaptedFields.length>0?new a({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null}):this._parent;if(t.nowhereclause===!0){let t=new s({parentfeatureset:i,orderbyclause:new f(this._physicalGroupByFields.join(`,`)+`,`+this._parent.objectIdField+` ASC`)});return{filterApplied:!1,spatialFilterApplied:!1,ordered:!1,features:this._aggregateSortedFeatureGroups((await t.query({abortSignal:e.abortSignal})).features,this._maxQuery,e.abortSignal)}}let c=i;n!=null&&(c=new o({parentfeatureset:c,whereclause:this._reformulateWhereClauseWithoutGroupByFields(n)}));let u=new s({parentfeatureset:c,orderbyclause:new f(this._physicalGroupByFields.join(`,`)+`,`+this._parent.objectIdField+` ASC`)});return{filterApplied:!1,spatialFilterApplied:!1,ordered:!1,features:this._aggregateSortedFeatureGroups((await u.query({abortSignal:e.abortSignal})).features,this._maxQuery,e.abortSignal)}}async*_fixAggregateAttributeNames(e){for await(let t of e)yield t.map(e=>{let t={geometry:e.geometry,attributes:{}},n={};for(let t in e.attributes)n[t.toLowerCase()]=e.attributes[t];for(let e of this._decodedGroupByFields)t.attributes[e.tofieldname]=n[e.name.toLowerCase()];for(let e of this._decodedStatsFields)t.attributes[e.tofieldname]=n[e.field.toLowerCase()];return t})}async*_aggregateSortedFeatureGroups(e,t,r){let i=null,a=[];for await(let o of e){await n(),l(r);for(let e of o){let t=this._generateAggregateHash(e);i==null?i={features:[e],id:t}:t===i.id?i.features.push(e):(a.push(this._calculateAndAppendAggregateItem(i)),i={features:[e],id:t})}a.length>=t&&(yield a,a=[])}i!=null&&(a.push(this._calculateAndAppendAggregateItem(i)),yield a)}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new c(`NeverReach`)}_reformulateWhereClauseWithoutStatsFields(e){for(let t of this._decodedStatsFields)e=_(e,t.tofieldname,m(t.workingexpr,0),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(let t of this._decodedGroupByFields)t.tofieldname!==t.name&&(e=_(e,t.tofieldname,m(t.expression,0),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){let t=[];for(let e of this._decodedGroupByFields)e.tofieldname!==e.name&&t.push({field:e.tofieldname,newfield:e.name});return t.length>0?e.replaceFields(t):e}_calculateFieldStat(e,t,n){let r=[];for(let n of e.features)if(t.workingexpr!==null){let e=t.workingexpr.calculateValue(n);e!==null&&(e instanceof S||e instanceof w?r.push(e.toNumber()):e instanceof C?r.push(e.toMilliseconds()):r.push(e))}else r.push(null);n.attributes[t.tofieldname]=x(t.typeofstat,[r])}_calculateAndAppendAggregateItem(e){let t={attributes:{}};for(let n of this._decodedGroupByFields){let r=n.singlefield?e.features[0].attributes[n.singlefield]:T.convertValueToStorageFormat(n.expression.calculateValue(e.features[0]),n.sqlType);t.attributes[n.tofieldname]=r}for(let n of this._decodedStatsFields)this._calculateFieldStat(e,n,t);return t}_generateAggregateHash(e){let t=``;for(let n of this._decodedGroupByFields){let r=n.singlefield?e.attributes[n.singlefield]:n.expression.calculateValue(e);t+=r==null?`:`:`:`+r.toString()}return y(t,b.String)}async getFeatureByObjectId(){throw new c(`NotImplemented`)}}export{O as default};
2
+ import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{StringEnum as t}from"../../enum.js";import{a5 as n}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as r,OriginalField as i,AdaptedFeatureSet as a}from"./Adapted.js";import o from"./AttributeFilter.js";import s from"./OrderBy.js";import{FeatureSetError as c,throwIfCancelled as l}from"../support/errorsupport.js";import{FeatureSet as u,emptyFeaturesResult as d}from"../support/FeatureSet.js";import f from"../support/OrderbyClause.js";import{isSingleField as p,toWhereClause as m,predictType as h,scanForField as g,reformulateWithoutField as _}from"../support/sqlUtils.js";import v from"../support/StatsField.js";import{createMD5Hash as y,outputTypes as b}from"../../../core/MD5.js";import{aggregateFunction as x}from"../../../core/sql/AggregateFunctions.js";import S from"../../../core/sql/WhereClause.js";import C from"../../../layers/support/Field.js";const w=new t([`MIN`,`MAX`,`VAR`,`STDDEV`,`COUNT`,`SUM`,`AVG`],[[`VARIANCE`,`VAR`],[`AVERAGE`,`AVG`],[`MEAN`,`AVG`],[`STDEV`,`STDDEV`]]);class T extends u{constructor(e){super(),this.declaredClass=`esri.arcade.featureset.actions.Aggregate`,this._decodedStatsFields=[],this._decodedGroupByFields=[],this._canDoSimpleGroupBy=!0,this._physicalGroupByFields=[],this.objectIdField=`ROW__ID`,this._adaptedFields=[],this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_nextUniqueName(e){for(;e[`T`+this._uniqueIds.toString()]===1;)this._uniqueIds++;let t=`T`+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){let e=this._parent.getFieldsIndex();this.objectIdField=`ROW__ID`,this.globalIdField=``;let t=!1,n=1;for(;t===!1;){let e=!1;for(let t of this._config.groupbyfields)if(t.name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(e===!1){for(let t of this._config.statsfields)if(t.name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}}e===!1?t=!0:(this.objectIdField=`ROW__ID`+n.toString(),n++)}for(let t of this._config.statsfields){let n=new v;n.field=t.name,n.tofieldname=t.name,n.workingexpr=t.expression instanceof S?t.expression:S.create(t.expression,{fieldsIndex:e,timeZone:this.dateFieldsTimeZoneDefaultUTC}),n.typeofstat=w.lookup(t.statistic)??`COUNT`,this._decodedStatsFields.push(n)}this._decodedGroupByFields=[];for(let t of this._config.groupbyfields){let n={name:t.name,singlefield:null,tofieldname:t.name,expression:t.expression instanceof S?t.expression:S.create(t.expression,{fieldsIndex:e,timeZone:this.dateFieldsTimeZoneDefaultUTC}),sqlType:null};this._decodedGroupByFields.push(n)}let a={};this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=``;for(let e of this._parent.fields)a[e.name.toUpperCase()]=1;this.types=null,this.subtypes=null,this.subtypeField=``,this.fields=[];let o=new v;o.field=this._nextUniqueName(a),o.tofieldname=this.objectIdField,o.workingexpr=S.create(this._parent.objectIdField,{fieldsIndex:this._parent.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),o.typeofstat=`MIN`,this._decodedStatsFields.push(o);for(let e of this._decodedGroupByFields){let t=new C;if(e.name=this._nextUniqueName(a),t.name=e.tofieldname,t.alias=t.name,p(e.expression)){let n=this._parent.getField(m(e.expression,0));if(!n)throw new c(`AggregationFieldNotFound`);e.name=n.name,e.singlefield=n.name,this._physicalGroupByFields.push(n.name),t.type=n.type,e.sqlType=n.type}else{t.type=this._convertToEsriFieldType(h(e.expression,this._parent.fields));let n=new C;n.name=e.name,n.alias=n.name,this._physicalGroupByFields.push(e.name),this._adaptedFields.push(new r(n,e.expression)),this._canDoSimpleGroupBy=!1,e.sqlType=t.type}this.fields.push(t)}if(this._adaptedFields.length>0)for(let e of this._parent.fields)this._adaptedFields.push(new i(e));for(let e of this._decodedStatsFields){let t=new C;e.field=this._nextUniqueName(a),t.name=e.tofieldname,t.alias=t.name;let n=null;if(e.workingexpr!=null&&p(e.workingexpr)){let t=m(e.workingexpr,0);if(n=this._parent.getField(t),!n)throw new c(`AggregationFieldNotFound`)}switch(e.typeofstat){case`SUM`:t.type=n==null?`double`:n.type;break;case`MIN`:case`MAX`:t.type=n==null?h(e.workingexpr,this._parent.fields)||`double`:n.type;break;case`COUNT`:t.type=`integer`;break;case`STDDEV`:case`VAR`:case`AVG`:t.type=`double`;break;default:e.typeofstat}this.fields.push(t)}}async _queryAll(){return(await this.query({abortSignal:e})).features}async query(e){if(e.spatialFilter!=null)return d;let t={ordered:!1,nowhereclause:!1};await this._ensureLoaded();let n=e.where;if(n!=null){for(let e of this._decodedStatsFields)if(g(n,e.tofieldname)===!0){t.nowhereclause=!0,n=null;break}}let r=e.orderBy;if(r!=null){t.ordered=!0;for(let e of this._decodedStatsFields)if(r.scanForField(e.tofieldname)===!0){r=null,t.ordered=!1;break}if(r!==null){for(let e of this._decodedGroupByFields)if(e.singlefield===null&&r.scanForField(e.tofieldname)===!0){r=null,t.ordered=!1;break}}}if(this._canDoSimpleGroupBy!==!1&&await this._parent.canQueryAggregate({groupBy:this._physicalGroupByFields,statistics:this._decodedStatsFields,where:null,spatialFilter:null,abortSignal:e.abortSignal})){let i=await this._parent.queryAggregate({groupBy:this._physicalGroupByFields,statistics:this._decodedStatsFields,where:n?this._reformulateWhereClauseWithoutGroupByFields(n):null,spatialFilter:null,orderBy:r?this._reformulateOrderClauseWithoutGroupByFields(r):null,abortSignal:e.abortSignal});return l(e.abortSignal),{...i,filterApplied:!t.nowhereclause&&i.filterApplied,ordered:t.ordered===!0&&i.ordered,features:this._fixAggregateAttributeNames(i.features)}}let i=this._adaptedFields.length>0?new a({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null}):this._parent;if(t.nowhereclause===!0){let t=new s({parentfeatureset:i,orderbyclause:new f(this._physicalGroupByFields.join(`,`)+`,`+this._parent.objectIdField+` ASC`)});return{filterApplied:!1,spatialFilterApplied:!1,ordered:!1,features:this._aggregateSortedFeatureGroups((await t.query({abortSignal:e.abortSignal})).features,this._maxQuery,e.abortSignal)}}let c=i;n!=null&&(c=new o({parentfeatureset:c,whereclause:this._reformulateWhereClauseWithoutGroupByFields(n)}));let u=new s({parentfeatureset:c,orderbyclause:new f(this._physicalGroupByFields.join(`,`)+`,`+this._parent.objectIdField+` ASC`)});return{filterApplied:!1,spatialFilterApplied:!1,ordered:!1,features:this._aggregateSortedFeatureGroups((await u.query({abortSignal:e.abortSignal})).features,this._maxQuery,e.abortSignal)}}async*_fixAggregateAttributeNames(e){for await(let t of e)yield t.map(e=>{let t={geometry:e.geometry,attributes:{}},n={};for(let t in e.attributes)n[t.toLowerCase()]=e.attributes[t];for(let e of this._decodedGroupByFields)t.attributes[e.tofieldname]=n[e.name.toLowerCase()];for(let e of this._decodedStatsFields)t.attributes[e.tofieldname]=n[e.field.toLowerCase()];return t})}async*_aggregateSortedFeatureGroups(e,t,r){let i=null,a=[];for await(let o of e){await n(),l(r);for(let e of o){let t=this._generateAggregateHash(e);i==null?i={features:[e],id:t}:t===i.id?i.features.push(e):(a.push(this._calculateAndAppendAggregateItem(i)),i={features:[e],id:t})}a.length>=t&&(yield a,a=[])}i!=null&&(a.push(this._calculateAndAppendAggregateItem(i)),yield a)}async queryStat(e){return{calculated:!1}}async canQueryAggregate(e){return!1}async queryAggregate(e){throw new c(`NeverReach`)}_reformulateWhereClauseWithoutStatsFields(e){for(let t of this._decodedStatsFields)e=_(e,t.tofieldname,m(t.workingexpr,0),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(let t of this._decodedGroupByFields)t.tofieldname!==t.name&&(e=_(e,t.tofieldname,m(t.expression,0),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){let t=[];for(let e of this._decodedGroupByFields)e.tofieldname!==e.name&&t.push({field:e.tofieldname,newfield:e.name});return t.length>0?e.replaceFields(t):e}_calculateFieldStat(e,t,n){let r=[];for(let n of e.features)t.workingexpr===null?r.push(null):r.push(t.workingexpr.calculateValue(n));n.attributes[t.tofieldname]=S.convertValueToStorageFormat(x(t.typeofstat,[r]))}_calculateAndAppendAggregateItem(e){let t={attributes:{}};for(let n of this._decodedGroupByFields){let r=n.singlefield?e.features[0].attributes[n.singlefield]:S.convertValueToStorageFormat(n.expression.calculateValue(e.features[0]),n.sqlType);t.attributes[n.tofieldname]=r}for(let n of this._decodedStatsFields)this._calculateFieldStat(e,n,t);return t}_generateAggregateHash(e){let t=``;for(let n of this._decodedGroupByFields){let r=n.singlefield?e.attributes[n.singlefield]:n.expression.calculateValue(e);t+=r==null?`:`:`:`+r.toString()}return y(t,b.String)}async getFeatureByObjectId(){throw new c(`NotImplemented`)}}export{T as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../Graphic.js";import{neverAbortedSignal as t}from"../../arcadeEnvironment.js";import{getSpatialReferenceAsGxJson as n}from"../../geometry.js";import r from"./cache.js";import{throwIfCancelled as i,FeatureSetError as a}from"./errorsupport.js";import{QueryIterator as o}from"./FeatureSetIterator.js";import{layerGeometryEsriConstants as s,esriFieldToJson as c,layerGeometryEsriRestConstants as l}from"./shared.js";import{max as u,min as d,sum as f,variance as p,stdev as m,mean as h,distinct as g}from"./stats.js";import{invokeRemoteGeometryOp as _}from"../../geometry/operatorsWorkerConnection.js";import{cacheAsync as v}from"../../../core/iteratorUtils.js";import y from"../../../core/sql/WhereClause.js";import b from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/FieldsIndex.js";function S(e){switch(e){case`esriSpatialRelIntersects`:return{spatialRelationship:`intersects`,relationParameter:null};case`esriSpatialRelContains`:return{spatialRelationship:`contains`,relationParameter:null};case`esriSpatialRelOverlaps`:return{spatialRelationship:`overlaps`,relationParameter:null};case`esriSpatialRelWithin`:return{spatialRelationship:`within`,relationParameter:null};case`esriSpatialRelTouches`:return{spatialRelationship:`touches`,relationParameter:null};case`esriSpatialRelCrosses`:return{spatialRelationship:`crosses`,relationParameter:null};case`esriSpatialRelEnvelopeIntersects`:return{spatialRelationship:`envelope-intersects`,relationParameter:null};default:if(e.includes(`esriSpatialRelRelation`))return{spatialRelationship:`relation`,relationParameter:e.split(`:`)[1]};throw new a(`NeverReach`)}}function C(e,t){for(let n of e)n.geometry!=null&&(n.geometry.spatialReference??=t)}const w=Object.freeze({ordered:!0,filterApplied:!0,spatialFilterApplied:!0,features:Object.freeze({next:()=>Promise.resolve({done:!0,value:void 0}),[Symbol.asyncIterator](){return this}})});class T{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 this._loadPromise===null&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return await this._parent?.load(),this._initialiseFeatureSet(),this}_initialiseFeatureSet(){this._parent===null?(this.fields=[],this.typeIdField=``,this.subtypeField=``,this.objectIdField=``,this.globalIdField=``,this.spatialReference=new b({wkid:4326}),this.geometryType=s.point):(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)}getField(e,t){return e=e.toLowerCase(),(t||this.fields).find(t=>t.name.toLowerCase()===e)}getFieldsIndex(){return this._fieldsIndex===null&&(this._fieldsIndex=x.fromLayer({timeInfo:this.timeInfo,editFieldsInfo:this.editFieldsInfo,dateFieldsTimeZone:this.dateFieldsTimeZone,datesInUnknownTimezone:this.datesInUnknownTimezone,fields:this.fields})),this._fieldsIndex}_maxProcessingRate(){return this._parent===null?Math.min(this._maxProcessing,this._maxQueryRate()):Math.min(this._maxProcessing,this._parent._maxProcessingRate())}_maxQueryRate(){return this._parent===null?this._maxQuery:Math.max(this._maxQuery,this._parent._maxQueryRate())}nativeCapabilities(){return this._parent.nativeCapabilities()}get _hasCachedFeatures(){return this._allFeatures!=null}async queryAll(e){this._allFeatures??=this._queryAll().then(e=>v(e));let n=(await this._allFeatures)();return e==null||e===t?n:(async function*(){for await(let t of n)i(e),yield t})()}async databaseType(){if(this._databaseType===7){if(r.applicationCache!==null){let e=r.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(e!==null)return e}if(this._databaseTypeProbed!==null)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),r.applicationCache!==null&&r.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw r.applicationCache!==null&&r.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){for(let e of[{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`}])if(await this._runDatabaseProbe(e.probeSql)===!0)return e.dbType;return 1}_cacheableFeatureSetSourceKey(){return`MUSTBESET`}async _runDatabaseProbe(e){if(this._parent!==null)return this._parent._runDatabaseProbe(e);throw new a(`NotImplemented`)}isTable(){return this._parent?.isTable()??!1}async first(t){if(this._hasCachedFeatures)return this.iterator(t).next();let n=await this.query({limit:1,abortSignal:t});for await(let t of n.features)if(t.length>0)return e.fromJSON(t[0]);return null}async isEmpty(e){return this._totalCount>=0?this._totalCount===0:await this.first(e)==null}async calculateStatistic(e,t,n,r){await this._ensureLoaded();let i=await this.queryStat({stat:e,field:t,limit:n,abortSignal:r});return i.calculated===!1&&(i=await this._manualStat(e,t,n,r)),i.result}async _manualStat(e,t,n,r){let i=null;switch(e.toLowerCase()){case`count`:{if(this._totalCount>=0)return{calculated:!0,result:this._totalCount};let e=await this.queryAll(r),t=0;for await(let n of e)t+=n.length;return this._totalCount=t,{calculated:!0,result:t}}case`distinct`:return i=await g(this,t,n,r),{calculated:!0,result:i};case`avg`:case`mean`:return i=await h(this,t,r),{calculated:!0,result:i};case`stdev`:return i=await m(this,t,r),{calculated:!0,result:i};case`variance`:return i=await p(this,t,r),{calculated:!0,result:i};case`sum`:return i=await f(this,t,r),{calculated:!0,result:i};case`min`:return i=await d(this,t,r),{calculated:!0,result:i};case`max`:return i=await u(this,t,r),{calculated:!0,result:i};default:return{calculated:!0,result:0}}}iterator(e){return new o(this,e)}async sumArea(e,t,r){let i=0;for await(let a of await this.queryAll(r))for(let r of a)r.geometry!=null&&(i+=t==null?await _(`area`,[r.geometry,n(this.spatialReference),e]):await _(`geodeticArea`,[r.geometry,n(this.spatialReference),e,t]));return i}async sumLength(e,t,r){let i=0;for await(let a of await this.queryAll(r))for(let r of a)r.geometry!=null&&(i+=t==null?await _(`length`,[r.geometry,n(this.spatialReference),e]):await _(`geodeticLength`,[r.geometry,n(this.spatialReference),e,t]));return i}async count(e){return await this.load(),this.calculateStatistic(`count`,y.create(`1`,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),-1,e??t)}castToText(e=!1){return`object, FeatureSet`}queryAttachments(e,t,n,r,i){return this._parent.queryAttachments(e,t,n,r,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(){let e=[];for(let t of this.fields)e.push(c(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:l[this.geometryType]===void 0?`esriGeometryNull`:l[this.geometryType],fields:e}}async convertToText(e,t){return e===`schema`?(await this._ensureLoaded(),JSON.stringify(this.schema())):e===`featureset`?JSON.stringify(await this.castAsJsonAsync(t)):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 this._parent===null?this:this._parent.getDataSourceFeatureSet()}castAsJson(){return{type:`FeatureSet`}}async castAsJsonAsync(e=null){await this._ensureLoaded();let t=[];for await(let n of await this.queryAll(e))for(let e of n){let n=e.attributes,r=null;if(e.geometry!=null){if(e.geometry.spatialReference){let{spatialReference:t,...n}=e.geometry;r=n}else r=e.geometry}t.push({geometry:r,attributes:n})}return{...this.schema(),features:t,spatialReference:this.spatialReference?.toJSON()??null}}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 E extends T{constructor(){super(...arguments),this._parent=null}getRootFeatureSet(){return this}}export{T as FeatureSet,E as RootFeatureSet,C as assignSpatialReferenceOnFeatures,w as emptyFeaturesResult,S as getSpatialFilterRelationRestQueryParams};
2
+ import e from"../../../Graphic.js";import{neverAbortedSignal as t}from"../../arcadeEnvironment.js";import{getSpatialReferenceAsGxJson as n}from"../../geometry.js";import r from"./cache.js";import{throwIfCancelled as i,FeatureSetError as a}from"./errorsupport.js";import{QueryIterator as o}from"./FeatureSetIterator.js";import{layerGeometryEsriConstants as s,esriFieldToJson as c,layerGeometryEsriRestConstants as l}from"./shared.js";import{isSingleField as u,predictType as d}from"./sqlUtils.js";import{calculateSqlAggregateStatistic as f,distinct as p}from"./stats.js";import{invokeRemoteGeometryOp as m}from"../../geometry/operatorsWorkerConnection.js";import{cacheAsync as h}from"../../../core/iteratorUtils.js";import g from"../../../core/sql/WhereClause.js";import _ from"../../../geometry/SpatialReference.js";import v from"../../../layers/support/FieldsIndex.js";function y(e){switch(e){case`esriSpatialRelIntersects`:return{spatialRelationship:`intersects`,relationParameter:null};case`esriSpatialRelContains`:return{spatialRelationship:`contains`,relationParameter:null};case`esriSpatialRelOverlaps`:return{spatialRelationship:`overlaps`,relationParameter:null};case`esriSpatialRelWithin`:return{spatialRelationship:`within`,relationParameter:null};case`esriSpatialRelTouches`:return{spatialRelationship:`touches`,relationParameter:null};case`esriSpatialRelCrosses`:return{spatialRelationship:`crosses`,relationParameter:null};case`esriSpatialRelEnvelopeIntersects`:return{spatialRelationship:`envelope-intersects`,relationParameter:null};default:if(e.includes(`esriSpatialRelRelation`))return{spatialRelationship:`relation`,relationParameter:e.split(`:`)[1]};throw new a(`NeverReach`)}}function b(e,t){for(let n of e)n.geometry!=null&&(n.geometry.spatialReference??=t)}const x=Object.freeze({ordered:!0,filterApplied:!0,spatialFilterApplied:!0,features:Object.freeze({next:()=>Promise.resolve({done:!0,value:void 0}),[Symbol.asyncIterator](){return this}})});class S{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 this._loadPromise===null&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return await this._parent?.load(),this._initialiseFeatureSet(),this}_initialiseFeatureSet(){this._parent===null?(this.fields=[],this.typeIdField=``,this.subtypeField=``,this.objectIdField=``,this.globalIdField=``,this.spatialReference=new _({wkid:4326}),this.geometryType=s.point):(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)}getField(e,t){return e=e.toLowerCase(),(t||this.fields).find(t=>t.name.toLowerCase()===e)}getFieldsIndex(){return this._fieldsIndex===null&&(this._fieldsIndex=v.fromLayer({timeInfo:this.timeInfo,editFieldsInfo:this.editFieldsInfo,dateFieldsTimeZone:this.dateFieldsTimeZone,datesInUnknownTimezone:this.datesInUnknownTimezone,fields:this.fields})),this._fieldsIndex}_maxProcessingRate(){return this._parent===null?Math.min(this._maxProcessing,this._maxQueryRate()):Math.min(this._maxProcessing,this._parent._maxProcessingRate())}_maxQueryRate(){return this._parent===null?this._maxQuery:Math.max(this._maxQuery,this._parent._maxQueryRate())}nativeCapabilities(){return this._parent.nativeCapabilities()}get _hasCachedFeatures(){return this._allFeatures!=null}async queryAll(e){this._allFeatures??=this._queryAll().then(e=>h(e));let n=(await this._allFeatures)();return e==null||e===t?n:(async function*(){for await(let t of n)i(e),yield t})()}async databaseType(){if(this._databaseType===7){if(r.applicationCache!==null){let e=r.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(e!==null)return e}if(this._databaseTypeProbed!==null)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),r.applicationCache!==null&&r.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw r.applicationCache!==null&&r.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){for(let e of[{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`}])if(await this._runDatabaseProbe(e.probeSql)===!0)return e.dbType;return 1}_cacheableFeatureSetSourceKey(){return`MUSTBESET`}async _runDatabaseProbe(e){if(this._parent!==null)return this._parent._runDatabaseProbe(e);throw new a(`NotImplemented`)}isTable(){return this._parent?.isTable()??!1}async first(t){if(this._hasCachedFeatures)return this.iterator(t).next();let n=await this.query({limit:1,abortSignal:t});for await(let t of n.features)if(t.length>0)return e.fromJSON(t[0]);return null}async isEmpty(e){return this._totalCount>=0?this._totalCount===0:await this.first(e)==null}async calculateStatistic(e,t,n,r){await this._ensureLoaded();let i=await this.queryStat({stat:e,field:t,limit:n,abortSignal:r});return i.calculated===!1&&(i=await this._manualStat(e,t,n,r)),i.result}async _manualStat(e,t,n,r){let i=null;switch(e.toLowerCase()){case`count`:{if(this._totalCount>=0)return{calculated:!0,result:this._totalCount};let e=await this.queryAll(r),t=0;for await(let n of e)t+=n.length;return this._totalCount=t,{calculated:!0,result:t}}case`distinct`:return i=await p(this,t,n,r),{calculated:!0,result:i};case`avg`:case`mean`:return i=await f(this,t,`avg`,r),t&&!u(t)&&d(t,this.fields)===`integer`?{calculated:!0,result:i==null?null:Math.trunc(i)}:{calculated:!0,result:i};case`stdev`:return i=await f(this,t,`stddev`,r),{calculated:!0,result:i};case`variance`:return i=await f(this,t,`var`,r),{calculated:!0,result:i};case`sum`:return i=await f(this,t,`sum`,r),{calculated:!0,result:i};case`min`:return i=await f(this,t,`min`,r),{calculated:!0,result:i};case`max`:return i=await f(this,t,`max`,r),{calculated:!0,result:i};default:return{calculated:!0,result:0}}}iterator(e){return new o(this,e)}async sumArea(e,t,r){let i=0;for await(let a of await this.queryAll(r))for(let r of a)r.geometry!=null&&(i+=t==null?await m(`area`,[r.geometry,n(this.spatialReference),e]):await m(`geodeticArea`,[r.geometry,n(this.spatialReference),e,t]));return i}async sumLength(e,t,r){let i=0;for await(let a of await this.queryAll(r))for(let r of a)r.geometry!=null&&(i+=t==null?await m(`length`,[r.geometry,n(this.spatialReference),e]):await m(`geodeticLength`,[r.geometry,n(this.spatialReference),e,t]));return i}async count(e){return await this.load(),this.calculateStatistic(`count`,g.create(`1`,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),-1,e??t)}castToText(e=!1){return`object, FeatureSet`}queryAttachments(e,t,n,r,i){return this._parent.queryAttachments(e,t,n,r,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(){let e=[];for(let t of this.fields)e.push(c(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:l[this.geometryType]===void 0?`esriGeometryNull`:l[this.geometryType],fields:e}}async convertToText(e,t){return e===`schema`?(await this._ensureLoaded(),JSON.stringify(this.schema())):e===`featureset`?JSON.stringify(await this.castAsJsonAsync(t)):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 this._parent===null?this:this._parent.getDataSourceFeatureSet()}castAsJson(){return{type:`FeatureSet`}}async castAsJsonAsync(e=null){await this._ensureLoaded();let t=[];for await(let n of await this.queryAll(e))for(let e of n){let n=e.attributes,r=null;if(e.geometry!=null){if(e.geometry.spatialReference){let{spatialReference:t,...n}=e.geometry;r=n}else r=e.geometry}t.push({geometry:r,attributes:n})}return{...this.schema(),features:t,spatialReference:this.spatialReference?.toJSON()??null}}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 C extends S{constructor(){super(...arguments),this._parent=null}getRootFeatureSet(){return this}}export{S as FeatureSet,C as RootFeatureSet,b as assignSpatialReferenceOnFeatures,x as emptyFeaturesResult,y as getSpatialFilterRelationRestQueryParams};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as t}from"../../../core/sql/DateOnly.js";import{TimeOnly as n}from"../../../core/sql/TimeOnly.js";import r from"../../../layers/support/Field.js";import{DateTime as i}from"luxon";function a(e){return r.fromJSON(e.toJSON())}function o(e){return`toJSON`in e?e.toJSON():e}function s(e){return typeof e==`string`||e instanceof String}function c(e){return typeof e==`boolean`}function l(e){return typeof e==`number`}function u(e){return Array.isArray(e)}function d(e){return e instanceof Date}function f(e){return e instanceof i}function p(t){return t instanceof e}function m(e){return e instanceof t}function h(e){return e instanceof n}function g(e,t){return e===t?!0:(d(e)||p(e))&&(d(t)||p(t))?e.getTime()===t.getTime():!1}function _(e){let t={};for(let n in e)t[n]=e[n];return t}function v(e,t){return e===t||e===`point`&&t===`esriGeometryPoint`||e===`polyline`&&t===`esriGeometryPolyline`||e===`polygon`&&t===`esriGeometryPolygon`||e===`extent`&&t===`esriGeometryEnvelope`||e===`multipoint`&&t===`esriGeometryMultipoint`||t===`point`&&e===`esriGeometryPoint`||t===`polyline`&&e===`esriGeometryPolyline`||t===`polygon`&&e===`esriGeometryPolygon`||t===`extent`&&e===`esriGeometryEnvelope`||t===`multipoint`&&e===`esriGeometryMultipoint`}const y=1e3;function b(e){return function(t){e.reject(t)}}function x(e,t){return function(){try{e.apply(null,arguments)}catch(e){t.reject(e)}}}const S={point:`point`,polygon:`polygon`,polyline:`polyline`,multipoint:`multipoint`,extent:`extent`,esriGeometryPoint:`point`,esriGeometryPolygon:`polygon`,esriGeometryPolyline:`polyline`,esriGeometryMultipoint:`multipoint`,esriGeometryEnvelope:`extent`,envelope:`extent`},C={point:`esriGeometryPoint`,polygon:`esriGeometryPolygon`,polyline:`esriGeometryPolyline`,multipoint:`esriGeometryMultipoint`,extent:`esriGeometryEnvelope`,esriGeometryPoint:`esriGeometryPoint`,esriGeometryPolygon:`esriGeometryPolygon`,esriGeometryPolyline:`esriGeometryPolyline`,esriGeometryMultipoint:`esriGeometryMultipoint`,esriGeometryEnvelope:`esriGeometryEnvelope`,envelope:`esriGeometryEnvelope`},w={"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 T(e){switch(e){case`point`:return`esriGeometryPoint`;case`polygon`:return`esriGeometryPolygon`;case`multipoint`:return`esriGeometryMultipoint`;case`polyline`:return`esriGeometryPolyline`;default:return`esriGeometryPoint`}}function E(e){return e===void 0?``:(e=e.replace(/\/featureserver\/[0-9]*/i,`/FeatureServer`),e=e.replace(/\/mapserver\/[0-9]*/i,`/MapServer`),e=e.split(`?`)[0],e)}function D(e,t){t||={},typeof t==`function`&&(t={cmp:t});let n=typeof t.cycles==`boolean`&&t.cycles,r=t.cmp&&(function(e){return function(t){return function(n,r){return e({key:n,value:t[n]},{key:r,value:t[r]})}}})(t.cmp),i=[];return(function e(t){if(t?.toJSON&&typeof t.toJSON==`function`&&(t=t.toJSON()),t===void 0)return;if(typeof t==`number`)return isFinite(t)?``+t:`null`;if(typeof t!=`object`)return JSON.stringify(t);let a,o;if(Array.isArray(t)){for(o=`[`,a=0;a<t.length;a++)a&&(o+=`,`),o+=e(t[a])||`null`;return o+`]`}if(t===null)return`null`;if(i.includes(t)){if(n)return JSON.stringify(`__cycle__`);throw TypeError(`Converting circular structure to JSON`)}let s=i.push(t)-1,c=Object.keys(t).sort(r?.(t));for(o=``,a=0;a<c.length;a++){let n=c[a],r=e(t[n]);r&&(o&&(o+=`,`),o+=JSON.stringify(n)+`:`+r)}return i.splice(s,1),`{`+o+`}`})(e)}function O(e){switch(e.type){case`catalog-footprint`:case`catalog`:case`csv`:case`feature`:case`geojson`:case`knowledge-graph-sublayer`:case`oriented-imagery`:case`parquet`:case`subtype-group`:case`subtype-sublayer`:case`wfs`:return!0;default:return!1}}export{x as callback,_ as cloneAttributes,a as cloneField,y as defaultMaxRecords,g as equalityTest,b as errback,o as esriFieldToJson,E as extractServiceUrl,p as isArcadeDate,m as isArcadeDateOnly,h as isArcadeTime,u as isArray,c as isBoolean,d as isDate,f as isLuxonDate,l as isNumber,s as isString,O as isSupportedLayer,w as layerFieldEsriConstants,S as layerGeometryEsriConstants,C as layerGeometryEsriRestConstants,v as sameGeomType,D as stableStringify,T as toEsriGeometryType};
2
+ import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as t}from"../../../core/sql/DateOnly.js";import{TimeOnly as n}from"../../../core/sql/TimeOnly.js";import r from"../../../layers/support/Field.js";import{DateTime as i}from"luxon";function a(e){return r.fromJSON(e.toJSON())}function o(e){return`toJSON`in e?e.toJSON():e}function s(e){return e instanceof Date}function c(e){return e instanceof i}function l(t){return t instanceof e}function u(e){return e instanceof t}function d(e){return e instanceof n}const f=1e3,p={point:`point`,polygon:`polygon`,polyline:`polyline`,multipoint:`multipoint`,extent:`extent`,esriGeometryPoint:`point`,esriGeometryPolygon:`polygon`,esriGeometryPolyline:`polyline`,esriGeometryMultipoint:`multipoint`,esriGeometryEnvelope:`extent`,envelope:`extent`},m={point:`esriGeometryPoint`,polygon:`esriGeometryPolygon`,polyline:`esriGeometryPolyline`,multipoint:`esriGeometryMultipoint`,extent:`esriGeometryEnvelope`,esriGeometryPoint:`esriGeometryPoint`,esriGeometryPolygon:`esriGeometryPolygon`,esriGeometryPolyline:`esriGeometryPolyline`,esriGeometryMultipoint:`esriGeometryMultipoint`,esriGeometryEnvelope:`esriGeometryEnvelope`,envelope:`esriGeometryEnvelope`},h={"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 g(e){return e===void 0?``:(e=e.replace(/\/featureserver\/[0-9]*/i,`/FeatureServer`),e=e.replace(/\/mapserver\/[0-9]*/i,`/MapServer`),e=e.split(`?`)[0],e)}function _(e,t){t||={},typeof t==`function`&&(t={cmp:t});let n=typeof t.cycles==`boolean`&&t.cycles,r=t.cmp&&(function(e){return function(t){return function(n,r){return e({key:n,value:t[n]},{key:r,value:t[r]})}}})(t.cmp),i=[];return(function e(t){if(t?.toJSON&&typeof t.toJSON==`function`&&(t=t.toJSON()),t===void 0)return;if(typeof t==`number`)return isFinite(t)?``+t:`null`;if(typeof t!=`object`)return JSON.stringify(t);let a,o;if(Array.isArray(t)){for(o=`[`,a=0;a<t.length;a++)a&&(o+=`,`),o+=e(t[a])||`null`;return o+`]`}if(t===null)return`null`;if(i.includes(t)){if(n)return JSON.stringify(`__cycle__`);throw TypeError(`Converting circular structure to JSON`)}let s=i.push(t)-1,c=Object.keys(t).sort(r?.(t));for(o=``,a=0;a<c.length;a++){let n=c[a],r=e(t[n]);r&&(o&&(o+=`,`),o+=JSON.stringify(n)+`:`+r)}return i.splice(s,1),`{`+o+`}`})(e)}function v(e){switch(e.type){case`catalog-footprint`:case`catalog`:case`csv`:case`feature`:case`geojson`:case`knowledge-graph-sublayer`:case`oriented-imagery`:case`parquet`:case`subtype-group`:case`subtype-sublayer`:case`wfs`:return!0;default:return!1}}export{a as cloneField,f as defaultMaxRecords,o as esriFieldToJson,g as extractServiceUrl,l as isArcadeDate,u as isArcadeDateOnly,d as isArcadeTime,s as isDate,c as isLuxonDate,v as isSupportedLayer,h as layerFieldEsriConstants,p as layerGeometryEsriConstants,m as layerGeometryEsriRestConstants,_ as stableStringify};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{ArcadeDate as e}from"../../ArcadeDate.js";import{isDate as t,isLuxonDate as n,isArcadeTime as r,isArcadeDate as i,isArcadeDateOnly as a}from"./shared.js";import{SqlError as o}from"../../../core/sql/errorSupport.js";import{TimeOnly as s}from"../../../core/sql/TimeOnly.js";import c from"../../../core/sql/WhereClause.js";import{DateTime as l}from"luxon";function u(e,t){return h(e?.parseTree,t,e?.parameters)}function d(e,t,n){return h(e,t,n)}function f(e,t,n,r){let i=h(e.parseTree,0,e.parameters,t,n);return c.create(i,{fieldsIndex:r,timeZone:e.timeZone,currentUser:e.currentUser})}function p(e,t,n=`AND`){return c.create(`((`+u(e,0)+`)`+n+`(`+u(t,0)+`))`,{fieldsIndex:e.fieldsIndex,timeZone:e.timeZone,currentUser:e.currentUser})}function m(e){return e.delimited===!0?`"${e.column.split(`"`).join(`""`)}"`:e.column}function h(e,s,c,l=null,u=null){let d,f,p,S;switch(e.type){case`interval`:return A(h(e.value,s,c,l,u),e.qualifier,e.op);case`case-expression`:{let t=` CASE `;e.format===`simple`&&(t+=h(e.operand,s,c,l,u));for(let n=0;n<e.clauses.length;n++)t+=` WHEN `+h(e.clauses[n].operand,s,c,l,u)+` THEN `+h(e.clauses[n].value,s,c,l,u);return e.else!==null&&(t+=` ELSE `+h(e.else,s,c,l,u)),t+=` END `,t}case`parameter`:{let o=c[e.value.toLowerCase()];if(typeof o==`string`)return`'`+c[e.value.toLowerCase()].toString().replaceAll(`'`,`''`)+`'`;if(t(o)||n(o))return b(o,s);if(r(o))return y(o,s);if(i(o))return _(o,s);if(a(o))return v(o,s);if(Array.isArray(o)){let e=[];for(let c=0;c<o.length;c++)typeof o[c]==`string`?e.push(`'`+o[c].toString().replaceAll(`'`,`''`)+`'`):t(o[c])||n(o[c])?e.push(b(o[c],s)):r(o[c])?e.push(y(o[c],s)):i(o[c])?e.push(_(o[c],s)):a(o[c])?e.push(v(o[c],s)):e.push(o[c].toString());return e}return o.toString()}case`expression-list`:f=[];for(let t of e.value)f.push(h(t,s,c,l,u));return f;case`unary-expression`:return` ( NOT `+h(e.expr,s,c,l,u)+` ) `;case`binary-expression`:switch(e.operator){case`AND`:return` (`+h(e.left,s,c,l,u)+` AND `+h(e.right,s,c,l,u)+`) `;case`OR`:return` (`+h(e.left,s,c,l,u)+` OR `+h(e.right,s,c,l,u)+`) `;case`IS`:if(e.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return` (`+h(e.left,s,c,l,u)+` IS NULL )`;case`ISNOT`:if(e.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return` (`+h(e.left,s,c,l,u)+` IS NOT NULL )`;case`IN`:return d=[],e.right.type===`expression-list`?(d=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` IN (`+d.join(`,`)+`)) `):(S=h(e.right,s,c,l,u),Array.isArray(S)?` (`+h(e.left,s,c,l,u)+` IN (`+S.join(`,`)+`)) `:` (`+h(e.left,s,c,l,u)+` IN (`+S+`)) `);case`NOT IN`:return d=[],e.right.type===`expression-list`?(d=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` NOT IN (`+d.join(`,`)+`)) `):(S=h(e.right,s,c,l,u),Array.isArray(S)?` (`+h(e.left,s,c,l,u)+` NOT IN (`+S.join(`,`)+`)) `:` (`+h(e.left,s,c,l,u)+` NOT IN (`+S+`)) `);case`BETWEEN`:return p=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` BETWEEN `+p[0]+` AND `+p[1]+` ) `;case`NOTBETWEEN`:return p=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` NOT BETWEEN `+p[0]+` AND `+p[1]+` ) `;case`LIKE`:return e.escape===``?` (`+h(e.left,s,c,l,u)+` LIKE `+h(e.right,s,c,l,u)+`) `:` (`+h(e.left,s,c,l,u)+` LIKE `+h(e.right,s,c,l,u)+` ESCAPE '`+e.escape+`') `;case`NOT LIKE`:return e.escape===``?` (`+h(e.left,s,c,l,u)+` NOT LIKE `+h(e.right,s,c,l,u)+`) `:` (`+h(e.left,s,c,l,u)+` NOT LIKE `+h(e.right,s,c,l,u)+` ESCAPE '`+e.escape+`') `;case`<>`:case`<`:case`>`:case`>=`:case`<=`:case`=`:case`*`:case`-`:case`+`:case`/`:return` (`+h(e.left,s,c,l,u)+` `+e.operator+` `+h(e.right,s,c,l,u)+`) `;case`||`:return` (`+h(e.left,s,c,l,u)+` `+(s===2?`+`:e.operator)+` `+h(e.right,s,c,l,u)+`) `}throw new o(`UnsupportedOperator`,{operator:e.operator});case`null`:return`null`;case`boolean`:return e.value===!0?`1`:`0`;case`string`:return`'`+e.value.toString().replaceAll(`'`,`''`)+`'`;case`timestamp`:return`timestamp '${e.value}'`;case`date`:return`date '${e.value}'`;case`time`:return`time '${e.value}'`;case`number`:return e.value.toString();case`current-time`:return x(e.mode,s);case`current-user`:return`CURRENT_USER`;case`column-reference`:return l&&l.toLowerCase()===e.column.toLowerCase()?`(`+u+`)`:m(e);case`data-type`:return e.value;case`function`:{let t=h(e.args,s,c,l,u);return g(e.name,t,s)}}throw new o(`UnsupportedSyntax`,{node:e.type})}function g(e,t,n){switch(e.toLowerCase().trim()){case`cos`:case`sin`:case`tan`:case`cosh`:case`tanh`:case`sinh`:case`acos`:case`asin`:case`atan`:case`floor`:case`log10`:case`log`:case`abs`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${t[0]})`;case`ceiling`:case`ceil`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`ceiling`});switch(n){case 0:case 1:return`CEILING(`+t[0]+`)`;default:return`CEILING(`+t[0]+`)`}case`mod`:case`power`:case`nullif`:if(t.length!==2)throw new o(`InvalidFunctionParameters`,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${t[0]},${t[1]})`;case`round`:if(t.length===2)return`ROUND(`+t[0]+`,`+t[1]+`)`;if(t.length===1)return`ROUND(`+t[0]+`)`;throw new o(`InvalidFunctionParameters`,{function:`round`});case`truncate`:if(t.length<1||t.length>2)throw new o(`InvalidFunctionParameters`,{function:`truncate`});switch(n){case 2:return`ROUND(`+t[0]+(t.length===1?`0`:`,`+t[1])+`,1)`;default:return`TRUNCATE(`+t[0]+(t.length===1?`)`:`,`+t[1]+`)`)}case`char_length`:case`len`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`char_length`});switch(n){case 2:return`LEN(`+t[0]+`)`;case 3:return`LENGTH(`+t[0]+`)`;default:return`CHAR_LENGTH(`+t[0]+`)`}case`coalesce`:case`concat`:{if(t.length<1)throw new o(`InvalidFunctionParameters`,{function:e.toLowerCase()});let n=e.toUpperCase().trim()+`(`;for(let e=0;e<t.length;e++)e!==0&&(n+=`,`),n+=t[e];return n+=`)`,n}case`lower`:case`lcase`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`lower`});return`LOWER(`+t[0]+`)`;case`upper`:case`ucase`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`upper`});return`UPPER(`+t[0]+`)`;case`substring`:{let e=``;switch(n){case 3:return e=`SUBSTR(`+t[0]+`,`+t[1],t.length===3&&(e+=`,`+t[2]),e+=`)`,e;case 2:return e=t.length===3?`SUBSTRING(`+t[0]+`,`+t[1]+`,`+t[2]+`)`:`SUBSTRING(`+t[0]+`, `+t[1]+`, LEN(`+t[0]+`) - `+t[1]+`)`,e;default:return e=`SUBSTRING(`+t[0]+` FROM `+t[1],t.length===3&&(e+=` FOR `+t[2]),e+=`)`,e}}case`extract`:return`EXTRACT(`+t[0].replaceAll(`'`,``)+` FROM `+t[1]+`)`;case`cast`:{let e=``;switch(n){case 3:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`DOUBLE`;break;case`integer`:e=`INTEGER`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`TIMESTAMP`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`;case 4:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`DOUBLE PRECISION`;break;case`integer`:e=`INT`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`TIMESTAMP`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`;case 2:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`FLOAT`;break;case`integer`:e=`INT`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`DATETIME`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`;default:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`FLOAT`;break;case`integer`:e=`INTEGER`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`TIMESTAMP`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`}}}throw new o(`InvalidFunctionParameters`,{function:e})}function _(e,t){let n=e.toDateTime(),r=n.hour===0&&n.minute===0&&n.second===0&&n.millisecond===0;switch(t){case 6:case 0:case 1:return r?`date '${n.toFormat(`yyyy-LL-dd`)}'`:`timestamp '${n.toFormat(`yyyy-LL-dd HH:mm:ss`)}'`;case 3:return r?`TO_DATE('${n.toFormat(`yyyy-LL-dd`)}','YYYY-MM-DD')`:`TO_DATE('${n.toFormat(`yyyy-LL-dd HH:mm:ss`)}','YYYY-MM-DD HH24:MI:SS')`;case 2:return`'${n.toFormat(r?`yyyy-LL-dd`:`yyyy-LL-dd HH:mm:ss`)}'`;case 5:return`#${n.toFormat(r?`LL-dd-yyyy`:`LL-dd-yyyy HH:mm:ss`)}#`;case 4:return`TIMESTAMP '${n.toFormat(r?`yyyy-LL-dd`:`yyyy-LL-dd HH:mm:ss`)}'`;default:return`timestamp '${n.toFormat(`yyyy-LL-dd HH:mm:ss`)}'`}}function v(e,t){switch(t){case 6:case 0:case 1:return e.toSQLWithKeyword();case 3:return`TO_DATE('${e.toFormat(`Y-MM-DD`)}'`;case 2:return`'${e.toFormat(`Y-MM-DD`)}'`;case 5:return`#${e.toFormat(`Y-MM-DD`)}#`;case 4:return`TIMESTAMP '${e.toFormat(`Y-MM-DD`)}'`;default:return e.toSQLWithKeyword()}}function y(e,t){switch(e instanceof s&&(e=e.toStorageString()),t){case 3:return`TO_DATE('${e}', 'HH24:MI:SS')`;case 2:return`'${e}'`;default:return`time '${e}'`}}function b(t,r){return _(e.dateTimeToArcadeDate(n(t)?t:l.fromJSDate(t)),r)}function x(e,t){switch(t){case 6:case 0:case 1:case 3:case 5:default:return e===`date`?`CURRENT_DATE`:e===`time`?`CURRENT_TIME`:`CURRENT_TIMESTAMP`;case 2:return e===`date`?`CAST(GETDATE() AS DATE)`:e===`time`?`CAST(GETDATE() AS TIME)`:`GETDATE()`;case 4:return e===`date`?`CURRENT_DATE`:e===`time`?`LOCALTIME`:`CURRENT_TIMESTAMP`}}function S(e,t,n={}){let r={},i={},a={esriFieldTypeSmallInteger:`integer`,esriFieldTypeInteger:`integer`,esriFieldTypeBigInteger:`integer`,esriFieldTypeSingle:`double`,esriFieldTypeDouble:`double`,esriFieldTypeString:`string`,esriFieldTypeTimeOnly:`time-only`,esriFieldTypeDateOnly:`date-only`,esriFieldTypeTimestampOffset:`timestamp-offset`,esriFieldTypeDate:`date`,esriFieldTypeOID:`integer`,esriFieldTypeGUID:`guid`,esriFieldTypeGlobalID:`guid`,oid:`integer`,long:`integer`,"small-integer":`integer`,integer:`integer`,"big-integer":`integer`,single:`double`,"time-only":`time-only`,"date-only":`date-only`,"timestamp-offset":`timestemp-offset`,double:`double`,date:`date`,guid:`guid`,"global-id":`guid`,string:`string`};for(let e of t){let t=e.type?a[e.type]:void 0;r[e.name.toLowerCase()]=t===void 0?``:t}for(let e in n){let t=a[n[e]];i[e.toLowerCase()]=t===void 0?``:t}switch(C(r,e.parseTree,e.parameters,i)){case`double`:return`double`;case`integer`:return`integer`;case`date`:return`date`;case`date-only`:return`date-only`;case`time-only`:return`time-only`;case`timestamp-offset`:return`timestamp-offset`;case`string`:return`string`;case`global-id`:return`guid`;case`guid`:return`guid`}return``}function C(e,n,s,c){let l;switch(n.type){case`interval`:return`integer`;case`case-expression`:{let t=[];if(n.format===`simple`){for(let r=0;r<n.clauses.length;r++)t.push(C(e,n.clauses[r].value,s,c));n.else!==null&&t.push(C(e,n.else,s,c))}else{for(let r=0;r<n.clauses.length;r++)t.push(C(e,n.clauses[r].value,s,c));n.else!==null&&t.push(C(e,n.else,s,c))}return T(t)}case`parameter`:{let e=c[n.value.toLowerCase()];if(e===void 0&&s){let e=s[n.value.toLowerCase()];if(e==null)return``;if(typeof e==`string`||e instanceof String)return`string`;if(typeof e==`boolean`)return`boolean`;if(t(e)||i(e))return`date`;if(a(e))return`date-only`;if(r(e))return`time-only`;if(typeof e==`number`)return e%1==0?`integer`:`double`}return e===void 0?``:e}case`expression-list`:{let t=[];for(let r of n.value)t.push(C(e,r,s,c));return t}case`unary-expression`:return`boolean`;case`binary-expression`:switch(n.operator){case`AND`:return`boolean`;case`OR`:return`boolean`;case`IS`:if(n.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return`boolean`;case`ISNOT`:if(n.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return`boolean`;case`IN`:return`boolean`;case`NOT IN`:return`boolean`;case`BETWEEN`:return`boolean`;case`NOTBETWEEN`:return`boolean`;case`LIKE`:return`boolean`;case`NOT LIKE`:return`boolean`;case`<>`:case`<`:case`>`:case`>=`:case`<=`:case`=`:return`boolean`;case`*`:case`-`:case`+`:case`/`:return T([C(e,n.left,s,c),C(e,n.right,s,c)]);case`||`:return`string`;default:throw new o(`UnsupportedOperator`,{operator:n.operator})}case`null`:return``;case`boolean`:return`boolean`;case`string`:return`string`;case`number`:return n.value===null?``:n.value%1==0?`integer`:`double`;case`date`:return`date`;case`timestamp`:return n.withtimezone?`timestamp-offset`:`date`;case`time`:return`time-only`;case`current-time`:return n.mode===`time`?`time-only`:`date`;case`current-user`:return`string`;case`column-reference`:{let t=e[n.column.toLowerCase()];return t===void 0?``:t}case`function`:switch(n.name.toLowerCase()){case`cast`:switch(n.args?.value[1]?.value.type??``){case`integer`:case`smallint`:return`integer`;case`real`:case`float`:return`double`;case`date`:case`timestamp`:return n.args?.value[1]?.value?.withtimezone===!0?`timestamp-offset`:`date`;case`time`:return`time-only`;case`varchar`:return`string`;default:return``}case`position`:case`extract`:case`char_length`:case`mod`:return`integer`;case`round`:if(l=C(e,n.args,s,c),Array.isArray(l)){if(l.length<=0)return`double`;l=l[0]}return l;case`sign`:return`integer`;case`ceiling`:case`floor`:case`abs`:return l=C(e,n.args,s,c),Array.isArray(l)&&(l=T(l)),l===`integer`||l===`double`?l:`double`;case`area`:case`length`:case`log`:case`log10`:case`sin`:case`cos`:case`tan`:case`asin`:case`acos`:case`atan`:case`cosh`:case`sinh`:case`tanh`:case`power`:return`double`;case`substring`:case`trim`:case`concat`:case`lower`:case`upper`:return`string`;case`truncate`:return`double`;case`nullif`:return l=C(e,n.args,s,c),Array.isArray(l)?l.length>0?l[0]:``:l;case`coalesce`:return l=C(e,n.args,s,c),Array.isArray(l)?l.length>0?l[0]:``:l}return``}throw new o(`UnsupportedSyntax`,{node:n.type})}const w={boolean:1,string:2,integer:3,double:4,date:5};function T(e){if(e){let t=``;for(let n of e)n!==``&&(t=t===``||w[t]<w[n]?n:t);return t}return``}function E(e,t){return O(e.parseTree,t)}function D(e){return e?.parseTree.type===`column-reference`}function O(e,t){if(e==null)return!1;switch(e.type){case`when-clause`:return O(e.operand,t)||O(e.value,t);case`case-expression`:for(let n of e.clauses)if(O(n,t))return!0;return!!(e.format===`simple`&&O(e.operand,t)||e.else!==null&&O(e.else,t));case`parameter`:return!1;case`expression-list`:for(let n of e.value)if(O(n,t))return!0;return!1;case`unary-expression`:return O(e.expr,t);case`binary-expression`:return O(e.left,t)||O(e.right,t);case`null`:case`boolean`:case`date`:case`timestamp`:case`time`:case`string`:case`number`:return!1;case`column-reference`:return t.toLowerCase()===e.column.toLowerCase();case`function`:return O(e.args,t)}return!1}function k(e){let t=``;return t+=e.period.toUpperCase(),t}function A(e,t,n){let r=``;return r=t.type===`interval-period`?k(t):k(t.start)+` TO `+k(t.end),`INTERVAL `+n+` `+e+` `+r}export{v as arcadeDateOnlyToSqlString,_ as arcadeDateToSqlString,p as combine,m as convertColumnReferenceToSql,A as convertIntervalToSql,D as isSingleField,b as makeSqlFromDateTimeParameter,y as makeTimeString,x as makeToday,S as predictType,f as reformulateWithoutField,E as scanForField,u as toWhereClause,d as toWhereClauseFromTree,g as translateFunctionToDatabaseSpecific};
2
+ import{ArcadeDate as e}from"../../ArcadeDate.js";import{isDate as t,isLuxonDate as n,isArcadeTime as r,isArcadeDate as i,isArcadeDateOnly as a}from"./shared.js";import{SqlError as o}from"../../../core/sql/errorSupport.js";import{TimeOnly as s}from"../../../core/sql/TimeOnly.js";import c from"../../../core/sql/WhereClause.js";import{DateTime as l}from"luxon";function u(e,t){return h(e?.parseTree,t,e?.parameters)}function d(e,t,n){return h(e,t,n)}function f(e,t,n,r){let i=h(e.parseTree,0,e.parameters,t,n);return c.create(i,{fieldsIndex:r,timeZone:e.timeZone,currentUser:e.currentUser})}function p(e,t,n=`AND`){return c.create(`((`+u(e,0)+`)`+n+`(`+u(t,0)+`))`,{fieldsIndex:e.fieldsIndex,timeZone:e.timeZone,currentUser:e.currentUser})}function m(e){return e.delimited===!0?`"${e.column.split(`"`).join(`""`)}"`:e.column}function h(e,s,c,l=null,u=null){let d,f,p,S;switch(e.type){case`interval`:return A(h(e.value,s,c,l,u),e.qualifier,e.op);case`case-expression`:{let t=` CASE `;e.format===`simple`&&(t+=h(e.operand,s,c,l,u));for(let n=0;n<e.clauses.length;n++)t+=` WHEN `+h(e.clauses[n].operand,s,c,l,u)+` THEN `+h(e.clauses[n].value,s,c,l,u);return e.else!==null&&(t+=` ELSE `+h(e.else,s,c,l,u)),t+=` END `,t}case`parameter`:{let o=c[e.value.toLowerCase()];if(typeof o==`string`)return`'`+c[e.value.toLowerCase()].toString().replaceAll(`'`,`''`)+`'`;if(t(o)||n(o))return b(o,s);if(r(o))return y(o,s);if(i(o))return _(o,s);if(a(o))return v(o,s);if(Array.isArray(o)){let e=[];for(let c=0;c<o.length;c++)typeof o[c]==`string`?e.push(`'`+o[c].toString().replaceAll(`'`,`''`)+`'`):t(o[c])||n(o[c])?e.push(b(o[c],s)):r(o[c])?e.push(y(o[c],s)):i(o[c])?e.push(_(o[c],s)):a(o[c])?e.push(v(o[c],s)):e.push(o[c].toString());return e}return o.toString()}case`expression-list`:f=[];for(let t of e.value)f.push(h(t,s,c,l,u));return f;case`unary-expression`:return` ( NOT `+h(e.expr,s,c,l,u)+` ) `;case`binary-expression`:switch(e.operator){case`AND`:return` (`+h(e.left,s,c,l,u)+` AND `+h(e.right,s,c,l,u)+`) `;case`OR`:return` (`+h(e.left,s,c,l,u)+` OR `+h(e.right,s,c,l,u)+`) `;case`IS`:if(e.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return` (`+h(e.left,s,c,l,u)+` IS NULL )`;case`ISNOT`:if(e.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return` (`+h(e.left,s,c,l,u)+` IS NOT NULL )`;case`IN`:return d=[],e.right.type===`expression-list`?(d=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` IN (`+d.join(`,`)+`)) `):(S=h(e.right,s,c,l,u),Array.isArray(S)?` (`+h(e.left,s,c,l,u)+` IN (`+S.join(`,`)+`)) `:` (`+h(e.left,s,c,l,u)+` IN (`+S+`)) `);case`NOT IN`:return d=[],e.right.type===`expression-list`?(d=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` NOT IN (`+d.join(`,`)+`)) `):(S=h(e.right,s,c,l,u),Array.isArray(S)?` (`+h(e.left,s,c,l,u)+` NOT IN (`+S.join(`,`)+`)) `:` (`+h(e.left,s,c,l,u)+` NOT IN (`+S+`)) `);case`BETWEEN`:return p=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` BETWEEN `+p[0]+` AND `+p[1]+` ) `;case`NOTBETWEEN`:return p=h(e.right,s,c,l,u),` (`+h(e.left,s,c,l,u)+` NOT BETWEEN `+p[0]+` AND `+p[1]+` ) `;case`LIKE`:return e.escape===``?` (`+h(e.left,s,c,l,u)+` LIKE `+h(e.right,s,c,l,u)+`) `:` (`+h(e.left,s,c,l,u)+` LIKE `+h(e.right,s,c,l,u)+` ESCAPE '`+e.escape+`') `;case`NOT LIKE`:return e.escape===``?` (`+h(e.left,s,c,l,u)+` NOT LIKE `+h(e.right,s,c,l,u)+`) `:` (`+h(e.left,s,c,l,u)+` NOT LIKE `+h(e.right,s,c,l,u)+` ESCAPE '`+e.escape+`') `;case`<>`:case`<`:case`>`:case`>=`:case`<=`:case`=`:case`*`:case`-`:case`+`:case`/`:return` (`+h(e.left,s,c,l,u)+` `+e.operator+` `+h(e.right,s,c,l,u)+`) `;case`||`:return` (`+h(e.left,s,c,l,u)+` `+(s===2?`+`:e.operator)+` `+h(e.right,s,c,l,u)+`) `}throw new o(`UnsupportedOperator`,{operator:e.operator});case`null`:return`null`;case`boolean`:return e.value===!0?`1`:`0`;case`string`:return`'`+e.value.toString().replaceAll(`'`,`''`)+`'`;case`timestamp`:return`timestamp '${e.value}'`;case`date`:return`date '${e.value}'`;case`time`:return`time '${e.value}'`;case`number`:return e.value.toString();case`current-time`:return x(e.mode,s);case`current-user`:return`CURRENT_USER`;case`column-reference`:return l&&l.toLowerCase()===e.column.toLowerCase()?`(`+u+`)`:m(e);case`data-type`:return e.value;case`function`:{let t=h(e.args,s,c,l,u);return g(e.name,t,s)}}throw new o(`UnsupportedSyntax`,{node:e.type})}function g(e,t,n){switch(e.toLowerCase().trim()){case`cos`:case`sin`:case`tan`:case`cosh`:case`tanh`:case`sinh`:case`acos`:case`asin`:case`atan`:case`floor`:case`log10`:case`log`:case`abs`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${t[0]})`;case`ceiling`:case`ceil`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`ceiling`});switch(n){case 0:case 1:return`CEILING(`+t[0]+`)`;default:return`CEILING(`+t[0]+`)`}case`mod`:case`power`:case`nullif`:if(t.length!==2)throw new o(`InvalidFunctionParameters`,{function:e.toLowerCase().trim()});return`${e.toUpperCase().trim()}(${t[0]},${t[1]})`;case`round`:if(t.length===2)return`ROUND(`+t[0]+`,`+t[1]+`)`;if(t.length===1)return`ROUND(`+t[0]+`)`;throw new o(`InvalidFunctionParameters`,{function:`round`});case`truncate`:if(t.length<1||t.length>2)throw new o(`InvalidFunctionParameters`,{function:`truncate`});switch(n){case 2:return`ROUND(`+t[0]+(t.length===1?`0`:`,`+t[1])+`,1)`;default:return`TRUNCATE(`+t[0]+(t.length===1?`)`:`,`+t[1]+`)`)}case`char_length`:case`len`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`char_length`});switch(n){case 2:return`LEN(`+t[0]+`)`;case 3:return`LENGTH(`+t[0]+`)`;default:return`CHAR_LENGTH(`+t[0]+`)`}case`coalesce`:case`concat`:{if(t.length<1)throw new o(`InvalidFunctionParameters`,{function:e.toLowerCase()});let n=e.toUpperCase().trim()+`(`;for(let e=0;e<t.length;e++)e!==0&&(n+=`,`),n+=t[e];return n+=`)`,n}case`lower`:case`lcase`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`lower`});return`LOWER(`+t[0]+`)`;case`upper`:case`ucase`:if(t.length!==1)throw new o(`InvalidFunctionParameters`,{function:`upper`});return`UPPER(`+t[0]+`)`;case`substring`:{let e=``;switch(n){case 3:return e=`SUBSTR(`+t[0]+`,`+t[1],t.length===3&&(e+=`,`+t[2]),e+=`)`,e;case 2:return e=t.length===3?`SUBSTRING(`+t[0]+`,`+t[1]+`,`+t[2]+`)`:`SUBSTRING(`+t[0]+`, `+t[1]+`, LEN(`+t[0]+`) - `+t[1]+`)`,e;default:return e=`SUBSTRING(`+t[0]+` FROM `+t[1],t.length===3&&(e+=` FOR `+t[2]),e+=`)`,e}}case`extract`:return`EXTRACT(`+t[0].replaceAll(`'`,``)+` FROM `+t[1]+`)`;case`cast`:{let e=``;switch(n){case 3:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`DOUBLE`;break;case`integer`:e=`INTEGER`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`TIMESTAMP`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`;case 4:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`DOUBLE PRECISION`;break;case`integer`:e=`INT`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`TIMESTAMP`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`;case 2:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`FLOAT`;break;case`integer`:e=`INT`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`DATETIME`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`;default:switch(t[1].type){case`date`:e=`DATE`;break;case`float`:e=`FLOAT`;break;case`integer`:e=`INTEGER`;break;case`real`:e=`REAL`;break;case`smallint`:e=`SMALLINT`;break;case`timestamp`:e=`TIMESTAMP`;break;case`varchar`:e=`VARCHAR(`+t[1].size.toString()+`)`}return`CAST(${t[0]} AS ${e})`}}}throw new o(`InvalidFunctionParameters`,{function:e})}function _(e,t){let n=e.toDateTime(),r=n.hour===0&&n.minute===0&&n.second===0&&n.millisecond===0;switch(t){case 6:case 0:case 1:return r?`date '${n.toFormat(`yyyy-LL-dd`)}'`:`timestamp '${n.toFormat(`yyyy-LL-dd HH:mm:ss`)}'`;case 3:return r?`TO_DATE('${n.toFormat(`yyyy-LL-dd`)}','YYYY-MM-DD')`:`TO_DATE('${n.toFormat(`yyyy-LL-dd HH:mm:ss`)}','YYYY-MM-DD HH24:MI:SS')`;case 2:return`'${n.toFormat(r?`yyyy-LL-dd`:`yyyy-LL-dd HH:mm:ss`)}'`;case 5:return`#${n.toFormat(r?`LL-dd-yyyy`:`LL-dd-yyyy HH:mm:ss`)}#`;case 4:return`TIMESTAMP '${n.toFormat(r?`yyyy-LL-dd`:`yyyy-LL-dd HH:mm:ss`)}'`;default:return`timestamp '${n.toFormat(`yyyy-LL-dd HH:mm:ss`)}'`}}function v(e,t){switch(t){case 6:case 0:case 1:return e.toSQLWithKeyword();case 3:return`TO_DATE('${e.toFormat(`Y-MM-DD`)}'`;case 2:return`'${e.toFormat(`Y-MM-DD`)}'`;case 5:return`#${e.toFormat(`Y-MM-DD`)}#`;case 4:return`TIMESTAMP '${e.toFormat(`Y-MM-DD`)}'`;default:return e.toSQLWithKeyword()}}function y(e,t){switch(e instanceof s&&(e=e.toStorageString()),t){case 3:return`TO_DATE('${e}', 'HH24:MI:SS')`;case 2:return`'${e}'`;default:return`time '${e}'`}}function b(t,r){return _(e.dateTimeToArcadeDate(n(t)?t:l.fromJSDate(t)),r)}function x(e,t){switch(t){case 6:case 0:case 1:case 3:case 5:default:return e===`date`?`CURRENT_DATE`:e===`time`?`CURRENT_TIME`:`CURRENT_TIMESTAMP`;case 2:return e===`date`?`CAST(GETDATE() AS DATE)`:e===`time`?`CAST(GETDATE() AS TIME)`:`GETDATE()`;case 4:return e===`date`?`CURRENT_DATE`:e===`time`?`LOCALTIME`:`CURRENT_TIMESTAMP`}}function S(e,t,n={}){let r={},i={},a={esriFieldTypeSmallInteger:`integer`,esriFieldTypeInteger:`integer`,esriFieldTypeBigInteger:`integer`,esriFieldTypeSingle:`double`,esriFieldTypeDouble:`double`,esriFieldTypeString:`string`,esriFieldTypeTimeOnly:`time-only`,esriFieldTypeDateOnly:`date-only`,esriFieldTypeTimestampOffset:`timestamp-offset`,esriFieldTypeDate:`date`,esriFieldTypeOID:`integer`,esriFieldTypeGUID:`guid`,esriFieldTypeGlobalID:`guid`,oid:`integer`,long:`integer`,"small-integer":`integer`,integer:`integer`,"big-integer":`integer`,single:`double`,"time-only":`time-only`,"date-only":`date-only`,"timestamp-offset":`timestamp-offset`,double:`double`,date:`date`,guid:`guid`,"global-id":`guid`,string:`string`};for(let e of t){let t=e.type?a[e.type]:void 0;r[e.name.toLowerCase()]=t===void 0?``:t}for(let e in n){let t=a[n[e]];i[e.toLowerCase()]=t===void 0?``:t}switch(C(r,e.parseTree,e.parameters,i)){case`double`:return`double`;case`integer`:return`integer`;case`date`:return`date`;case`date-only`:return`date-only`;case`time-only`:return`time-only`;case`timestamp-offset`:return`timestamp-offset`;case`string`:return`string`;case`global-id`:return`guid`;case`guid`:return`guid`}return``}function C(e,n,s,c){let l;switch(n.type){case`interval`:return`integer`;case`case-expression`:{let t=[];if(n.format===`simple`){for(let r=0;r<n.clauses.length;r++)t.push(C(e,n.clauses[r].value,s,c));n.else!==null&&t.push(C(e,n.else,s,c))}else{for(let r=0;r<n.clauses.length;r++)t.push(C(e,n.clauses[r].value,s,c));n.else!==null&&t.push(C(e,n.else,s,c))}return T(t)}case`parameter`:{let e=c[n.value.toLowerCase()];if(e===void 0&&s){let e=s[n.value.toLowerCase()];if(e==null)return``;if(typeof e==`string`||e instanceof String)return`string`;if(typeof e==`boolean`)return`boolean`;if(t(e)||i(e))return`date`;if(a(e))return`date-only`;if(r(e))return`time-only`;if(typeof e==`number`)return e%1==0?`integer`:`double`}return e===void 0?``:e}case`expression-list`:{let t=[];for(let r of n.value)t.push(C(e,r,s,c));return t}case`unary-expression`:return`boolean`;case`binary-expression`:switch(n.operator){case`AND`:return`boolean`;case`OR`:return`boolean`;case`IS`:if(n.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return`boolean`;case`ISNOT`:if(n.right.type!==`null`)throw new o(`UnsupportedIsRhs`);return`boolean`;case`IN`:return`boolean`;case`NOT IN`:return`boolean`;case`BETWEEN`:return`boolean`;case`NOTBETWEEN`:return`boolean`;case`LIKE`:return`boolean`;case`NOT LIKE`:return`boolean`;case`<>`:case`<`:case`>`:case`>=`:case`<=`:case`=`:return`boolean`;case`*`:case`-`:case`+`:case`/`:return T([C(e,n.left,s,c),C(e,n.right,s,c)]);case`||`:return`string`;default:throw new o(`UnsupportedOperator`,{operator:n.operator})}case`null`:return``;case`boolean`:return`boolean`;case`string`:return`string`;case`number`:return n.value===null?``:n.value%1==0?`integer`:`double`;case`date`:return`date`;case`timestamp`:return n.withtimezone?`timestamp-offset`:`date`;case`time`:return`time-only`;case`current-time`:return n.mode===`time`?`time-only`:`date`;case`current-user`:return`string`;case`column-reference`:{let t=e[n.column.toLowerCase()];return t===void 0?``:t}case`function`:switch(n.name.toLowerCase()){case`cast`:switch(n.args?.value[1]?.value.type??``){case`integer`:case`smallint`:return`integer`;case`real`:case`float`:return`double`;case`date`:case`timestamp`:return n.args?.value[1]?.value?.withtimezone===!0?`timestamp-offset`:`date`;case`time`:return`time-only`;case`varchar`:return`string`;default:return``}case`position`:case`extract`:case`char_length`:case`mod`:return`integer`;case`round`:if(l=C(e,n.args,s,c),Array.isArray(l)){if(l.length<=0)return`double`;l=l[0]}return l;case`sign`:return`integer`;case`ceiling`:case`floor`:case`abs`:return l=C(e,n.args,s,c),Array.isArray(l)&&(l=T(l)),l===`integer`||l===`double`?l:`double`;case`area`:case`length`:case`log`:case`log10`:case`sin`:case`cos`:case`tan`:case`asin`:case`acos`:case`atan`:case`cosh`:case`sinh`:case`tanh`:case`power`:return`double`;case`substring`:case`trim`:case`concat`:case`lower`:case`upper`:return`string`;case`truncate`:return`double`;case`nullif`:return l=C(e,n.args,s,c),Array.isArray(l)?l.length>0?l[0]:``:l;case`coalesce`:return l=C(e,n.args,s,c),Array.isArray(l)?l.length>0?l[0]:``:l}return``}throw new o(`UnsupportedSyntax`,{node:n.type})}const w={boolean:1,string:2,integer:3,double:4,date:5};function T(e){if(e){let t=``;for(let n of e)n!==``&&(t=t===``||w[t]<w[n]?n:t);return t}return``}function E(e,t){return O(e.parseTree,t)}function D(e){return e?.parseTree.type===`column-reference`}function O(e,t){if(e==null)return!1;switch(e.type){case`when-clause`:return O(e.operand,t)||O(e.value,t);case`case-expression`:for(let n of e.clauses)if(O(n,t))return!0;return!!(e.format===`simple`&&O(e.operand,t)||e.else!==null&&O(e.else,t));case`parameter`:return!1;case`expression-list`:for(let n of e.value)if(O(n,t))return!0;return!1;case`unary-expression`:return O(e.expr,t);case`binary-expression`:return O(e.left,t)||O(e.right,t);case`null`:case`boolean`:case`date`:case`timestamp`:case`time`:case`string`:case`number`:return!1;case`column-reference`:return t.toLowerCase()===e.column.toLowerCase();case`function`:return O(e.args,t)}return!1}function k(e){let t=``;return t+=e.period.toUpperCase(),t}function A(e,t,n){let r=``;return r=t.type===`interval-period`?k(t):k(t.start)+` TO `+k(t.end),`INTERVAL `+n+` `+e+` `+r}export{v as arcadeDateOnlyToSqlString,_ as arcadeDateToSqlString,p as combine,m as convertColumnReferenceToSql,A as convertIntervalToSql,D as isSingleField,b as makeSqlFromDateTimeParameter,y as makeTimeString,x as makeToday,S as predictType,f as reformulateWithoutField,E as scanForField,u as toWhereClause,d as toWhereClauseFromTree,g as translateFunctionToDatabaseSpecific};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{FeatureSetError as e}from"./errorsupport.js";import{isNumber as t,isString as n,equalityTest as r}from"./shared.js";import{isSingleField as i,predictType as a}from"./sqlUtils.js";import{DateOnly as o}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as s}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as c}from"../../../core/sql/TimeOnly.js";function l(e){return e=+e,isFinite(e)?e-e%1||(e<0?-0:e===0?e:0):e}function u(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}function d(e){let t=u(e),n=0;for(let r=0;r<e.length;r++)n+=(t-e[r])**2;return n/e.length}function f(e){let t=u(e),n=0;for(let r=0;r<e.length;r++)n+=(t-e[r])**2;return n/(e.length-1)}function p(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function m(e,i){let a=[],o={},s=[];for(let c=0;c<e.length;c++){if(e[c]!==void 0&&e[c]!==null){let i=e[c];if(t(i)||n(i))o[i]===void 0&&(a.push(i),o[i]=1);else{let e=!1;for(let t=0;t<s.length;t++)r(s[t],i)===!0&&(e=!0);e===!1&&(s.push(i),a.push(i))}}if(a.length>=i&&i!==-1)return a}return a}function h(e){switch(e.toLowerCase()){case`distinct`:return`distinct`;case`avg`:case`mean`:return`avg`;case`min`:return`min`;case`sum`:return`sum`;case`max`:return`max`;case`stdev`:case`stddev`:return`stddev`;case`var`:case`variance`:return`var`;case`count`:return`count`}return null}function g(e,t,n=1e3){switch(e.toLowerCase()){case`distinct`:return m(t,n);case`avg`:case`mean`:return u(t);case`min`:return Math.min.apply(Math,t);case`sum`:return p(t);case`max`:return Math.max.apply(Math,t);case`stdev`:case`stddev`:return Math.sqrt(d(t));case`var`:case`variance`:return d(t);case`count`:return t.length}return 0}async function _(e,t,n){let r=await C(e,t,n);return r.length===0?null:Math.min.apply(Math,r)}async function v(e,t,n){let r=await C(e,t,n);return r.length===0?null:Math.max.apply(Math,r)}async function y(e,t,n){let r=``;t&&!i(t)&&(r=a(t,e.fields));let o=await C(e,t,n);if(o.length===0)return null;let s=u(o);return s===null?s:r===`integer`?l(s):s}async function b(e,t,n){let r=await C(e,t,n);return r.length===0?null:f(r)}async function x(e,t,n){let r=await C(e,t,n);return r.length===0?null:Math.sqrt(f(r))}async function S(e,t,n){let r=await C(e,t,n);return r.length===0?null:p(r)}async function C(t,n,r){let i=await t.queryAll(r),a=[],l={ticker:0};for await(let t of i){if(l.ticker+=t.length,l.ticker>=100&&(l.ticker=0,await new Promise(e=>{setTimeout(e,0)})),r?.aborted)throw new e(`Cancelled`);for(let e of t){let t=n?.calculateValue(e);t===null||(t instanceof o||t instanceof c?a[a.length]=t.toNumber():t instanceof s?a[a.length]=t.toMilliseconds():a[a.length]=t)}}return a}async function w(t,n,r=1e3,i=null){if(n==null)return[];let a=await t.queryAll(i),l=[],u=new Set,d={ticker:0};for await(let t of a){if(d.ticker+=t.length,d.ticker>=100&&(d.ticker=0,await new Promise(e=>{setTimeout(e,0)})),i?.aborted)throw new e(`Cancelled`);for(let e of t){let t=n.calculateValue(e),i=t;if(t instanceof o?i=`!!DATEONLY!!-`+t.toString():t instanceof s?i=`!!TSOFFSETONLY!!-`+t.toString():t instanceof c?i=`!!TIMEONLY!!-`+t.toString():t instanceof Date&&(i=`!!DATE!!-`+t.toString()),t!=null&&(u.has(i)||(l.push(t),u.add(i))),l.length>=r&&r!==-1)return l}}return l}export{g as calculateStat,h as decodeStatType,w as distinct,v as max,y as mean,_ as min,x as stdev,S as sum,b as variance};
2
+ import{FeatureSetError as e}from"./errorsupport.js";import{aggregateFunction as t}from"../../../core/sql/AggregateFunctions.js";import{DateOnly as n}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as r}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as i}from"../../../core/sql/TimeOnly.js";function a(e){switch(e.toLowerCase()){case`distinct`:return`distinct`;case`avg`:case`mean`:return`avg`;case`min`:return`min`;case`sum`:return`sum`;case`max`:return`max`;case`stdev`:case`stddev`:return`stddev`;case`var`:case`variance`:return`var`;case`count`:return`count`}return null}async function o(n,r,i,a){let o=await n.queryAll(a),s=[];if(r!=null){let t={ticker:0};for await(let n of o){if(t.ticker+=n.length,t.ticker>=100&&(t.ticker=0,await new Promise(e=>{setTimeout(e,0)})),a?.aborted)throw new e(`Cancelled`);for(let e of n)s.push(r.calculateValue(e))}}return t(i,[s])}async function s(t,a,o=1e3,s=null){if(a==null)return[];let c=await t.queryAll(s),l=[],u=new Set,d={ticker:0};for await(let t of c){if(d.ticker+=t.length,d.ticker>=100&&(d.ticker=0,await new Promise(e=>{setTimeout(e,0)})),s?.aborted)throw new e(`Cancelled`);for(let e of t){let t=a.calculateValue(e),s=t;if(t instanceof n?s=`!!DATEONLY!!-`+t.toString():t instanceof r?s=`!!TSOFFSETONLY!!-`+t.toString():t instanceof i?s=`!!TIMEONLY!!-`+t.toString():t instanceof Date&&(s=`!!DATE!!-`+t.toString()),t!=null&&(u.has(s)||(l.push(t),u.add(s))),l.length>=o&&o!==-1)return l}}return l}export{o as calculateSqlAggregateStatistic,a as decodeStatType,s as distinct};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{ArcadeDate as e}from"../ArcadeDate.js";import{isEmpty as t}from"../containerUtils.js";import{ArcadeExecutionError as n}from"../executionError.js";import{E as r,k as i,g as a,l as o,F as s,G as c,N as l,O as u,S as d}from"../../chunks/languageUtils.js";import{calculateStat as f}from"./fieldStats.js";import{SqlTimeStampOffset as p}from"../../core/sql/SqlTimestampOffset.js";import m from"../../core/sql/WhereClause.js";import{DateTime as h}from"luxon";import{isArray as g,isString as _,isBoolean as v,isDate as y}from"../../support/guards.js";async function b(e,t,n,r){if(n.length===1){if(g(n[0]))return f(e,n[0]);if(a(n[0]))return f(e,n[0].toArray())}else if(n.length===2){if(g(n[0]))return f(e,n[0]);if(a(n[0]))return f(e,n[0].toArray());if(i(n[0])){let i=await n[0].load(),a=await S(m.create(n[1],{fieldsIndex:i.getFieldsIndex(),timeZone:i.dateFieldsTimeZoneDefaultUTC}),r,t);return x(t,await n[0].calculateStatistic(e,a,-1,t.abortSignal))}}else if(n.length===3&&i(n[0])){let i=await n[0].load(),a=await S(m.create(n[1],{fieldsIndex:i.getFieldsIndex(),timeZone:i.dateFieldsTimeZoneDefaultUTC}),r,t);return x(t,await n[0].calculateStatistic(e,a,-1,t.abortSignal))}return f(e,n)}function x(t,n){return p.isTimestampOffset(n)?e.fromReaderAsTimeStampOffset(n.toStorageFormat()):y(n)?e.dateJSAndZoneToArcadeDate(n,d(t)):h.isDateTime(n)?e.dateTimeToArcadeDate(n):n}async function S(e,t,n){let r=e.getVariables();if(r.length>0){let i={};for(let e of r)i[e]=t.evaluateIdentifier(n,{name:e});e.parameters=i}return e}function C(e){e.mode===`async`&&(e.functions.stdev=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`stdev`,t,i,e))},e.functions.variance=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`variance`,t,i,e))},e.functions.average=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`mean`,t,i,e))},e.functions.mean=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`mean`,t,i,e))},e.functions.sum=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`sum`,t,i,e))},e.functions.min=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`min`,t,i,e))},e.functions.max=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>b(`max`,t,i,e))},e.functions.count=function(t,l){return e.standardFunctionAsync(t,l,async(e,t,u)=>{if(r(u,1,1,l),u[0]==null)return 0;if(i(u[0]))return u[0].count(e.abortSignal);if(g(u[0])||_(u[0]))return u[0].length;if(a(u[0]))return u[0].length();if(o(u[0])||s(u[0])||c(u[0]))return u[0].entryCount();throw new n(`InvalidParameter`,l)})},e.functions.isempty=function(a,o){return e.standardFunctionAsync(a,o,async(e,a,o)=>{if(r(o,1,2,a),o.length>=2&&!v(o[1]))throw new n(`InvalidParameter`,a);return l(o[1],!1)?i(o[0])?await o[0].isEmpty(e.abortSignal):t(o[0]):u(o[0])})})}export{C as registerFunctions};
2
+ import{ArcadeDate as e}from"../ArcadeDate.js";import{isEmpty as t}from"../containerUtils.js";import{ArcadeExecutionError as n}from"../executionError.js";import{E as r,k as i,g as a,l as o,F as s,G as c,N as l,O as u,w as d,S as f}from"../../chunks/languageUtils.js";import{calculateStat as p}from"./fieldStats.js";import{SqlTimeStampOffset as m}from"../../core/sql/SqlTimestampOffset.js";import h from"../../core/sql/WhereClause.js";import{DateTime as g}from"luxon";import{isArray as _,isString as v,isBoolean as y,isDate as b}from"../../support/guards.js";async function x(e,t,n,r){if(n.length>0&&i(n[0])){let i=await n[0].load(),a=await C(h.create(d(n[1]),{fieldsIndex:i.getFieldsIndex(),timeZone:i.dateFieldsTimeZoneDefaultUTC}),r,t);return S(t,await n[0].calculateStatistic(e,a,-1,t.abortSignal))}if(n.length===1){if(_(n[0]))return p(e,n[0]);if(a(n[0]))return p(e,n[0].toArray())}return p(e,n)}function S(t,n){return m.isTimestampOffset(n)?e.fromReaderAsTimeStampOffset(n.toStorageFormat()):b(n)?e.dateJSAndZoneToArcadeDate(n,f(t)):g.isDateTime(n)?e.dateTimeToArcadeDate(n):n}async function C(e,t,n){let r=e.getVariables();if(r.length>0){let i={};for(let e of r)i[e]=t.evaluateIdentifier(n,{name:e});e.parameters=i}return e}function w(e){e.mode===`async`&&(e.functions.stdev=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`stdev`,t,i,e))},e.functions.variance=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`variance`,t,i,e))},e.functions.average=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`mean`,t,i,e))},e.functions.mean=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`mean`,t,i,e))},e.functions.sum=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`sum`,t,i,e))},e.functions.min=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`min`,t,i,e))},e.functions.max=function(t,n){return e.standardFunctionAsync(t,n,(n,r,i)=>x(`max`,t,i,e))},e.functions.count=function(t,l){return e.standardFunctionAsync(t,l,async(e,t,u)=>{if(r(u,1,1,l),u[0]==null)return 0;if(i(u[0]))return u[0].count(e.abortSignal);if(_(u[0])||v(u[0]))return u[0].length;if(a(u[0]))return u[0].length();if(o(u[0])||s(u[0])||c(u[0]))return u[0].entryCount();throw new n(`InvalidParameter`,l)})},e.functions.isempty=function(a,o){return e.standardFunctionAsync(a,o,async(e,a,o)=>{if(r(o,1,2,a),o.length>=2&&!y(o[1]))throw new n(`InvalidParameter`,a);return l(o[1],!1)?i(o[0])?await o[0].isEmpty(e.abortSignal):t(o[0]):u(o[0])})})}export{w as registerFunctions};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{u as e,z as t,a3 as n}from"../../chunks/languageUtils.js";import{isNumber as r,isString as i}from"../../support/guards.js";function a(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}function o(e){let t=a(e),n=0;for(let r=0;r<e.length;r++)n+=(t-e[r])**2;return n/e.length}function s(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function c(n,a){let o=[],s={},c=[];for(let l of n){if(l!=null&&!e(l)){if(r(l)||i(l))s[l]===void 0&&(o.push(l),s[l]=1);else{let e=!1;for(let n=0;n<c.length;n++)t(c[n],l)===!0&&(e=!0);e===!1&&(c.push(l),o.push(l))}}if(o.length>=a&&a!==-1)return o}return o}function l(e){switch(e.toLowerCase()){case`distinct`:return`distinct`;case`avg`:case`mean`:return`avg`;case`min`:return`min`;case`sum`:return`sum`;case`max`:return`max`;case`stdev`:case`stddev`:return`stddev`;case`var`:case`variance`:return`var`;case`count`:return`count`}return``}function u(e,t){switch(e){case`avg`:case`mean`:return a(n(t));case`min`:return Math.min.apply(Math,n(t));case`sum`:return s(n(t));case`max`:return Math.max.apply(Math,n(t));case`stdev`:case`stddev`:return Math.sqrt(o(n(t)));case`var`:case`variance`:return o(n(t));case`count`:return t.length;case`product`:return n(t).reduce((e,t)=>e*t,1);default:return 0}}export{u as calculateStat,l as decodeStatType,c as distinct};
2
+ import{u as e,z as t,a3 as n}from"../../chunks/languageUtils.js";import{isNumber as r,isString as i}from"../../support/guards.js";function a(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}function o(e){let t=a(e),n=0;for(let r=0;r<e.length;r++)n+=(t-e[r])**2;return n/e.length}function s(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function c(n,a){let o=[],s={},c=[];for(let l of n){if(l!=null&&!e(l)){if(r(l)||i(l))s[l]===void 0&&(o.push(l),s[l]=1);else{let e=!1;for(let n=0;n<c.length;n++)t(c[n],l)===!0&&(e=!0);e===!1&&(c.push(l),o.push(l))}}if(o.length>=a&&a!==-1)return o}return o}function l(e){switch(e.toLowerCase()){case`distinct`:return`distinct`;case`avg`:case`mean`:return`avg`;case`min`:return`min`;case`sum`:return`sum`;case`max`:return`max`;case`stdev`:case`stddev`:return`stddev`;case`var`:case`variance`:return`var`;case`count`:return`count`}return``}function u(e,t){switch(e){case`avg`:case`mean`:return a(n(t));case`min`:return n(t).reduce((e,t)=>Math.min(e,t),1/0);case`sum`:return s(n(t));case`max`:return n(t).reduce((e,t)=>Math.max(e,t),-1/0);case`stdev`:case`stddev`:return Math.sqrt(o(n(t)));case`var`:case`variance`:return o(n(t));case`count`:return t.length;case`product`:return n(t).reduce((e,t)=>e*t,1);default:return 0}}export{u as calculateStat,l as decodeStatType,c as distinct};
package/arcgisGlobal.d.ts CHANGED
@@ -550,7 +550,7 @@ export interface ArcgisImportModules {
550
550
  "@arcgis/core/layers/voxel/VoxelVolume.js": typeof import("./layers/voxel/VoxelVolume.js").default;
551
551
  "@arcgis/core/layers/voxel/VoxelVolumeStyle.js": typeof import("./layers/voxel/VoxelVolumeStyle.js").default;
552
552
  "@arcgis/core/legend/ActiveLayerInfo.js": typeof import("./legend/ActiveLayerInfo.js").default;
553
- "@arcgis/core/legend/LegendContent.js": typeof import("./legend/LegendContent.js").default;
553
+ "@arcgis/core/legend/LegendModel.js": typeof import("./legend/LegendModel.js").default;
554
554
  "@arcgis/core/linkChart/ChronologicalLayoutSettings.js": typeof import("./linkChart/ChronologicalLayoutSettings.js").default;
555
555
  "@arcgis/core/linkChart/LayoutSettings.js": typeof import("./linkChart/LayoutSettings.js").default;
556
556
  "@arcgis/core/linkChart/LinkChartProperties.js": typeof import("./linkChart/LinkChartProperties.js").default;