@arcgis/core 5.2.0-next.30 → 5.2.0-next.31
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.
- package/WebDocument2D.js +1 -1
- package/WebScene.js +1 -1
- package/arcade/ArcadePortal.js +1 -1
- package/arcade/Attachment.js +1 -1
- package/arcade/Dictionary.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/containerUtils.js +1 -1
- package/arcade/debug.js +1 -1
- package/arcade/deepClone.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/arcade/functions/feature.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/maths.js +1 -1
- package/arcade/functions/stats.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/geometry/constructors.js +1 -1
- package/arcade/geometry/functions.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{e5d2fab228d54b18a8a8.js → 08405116b5feb2d00101.js} +1 -1
- package/assets/esri/core/workers/chunks/{774615303c1cc9a77e20.js → 11af659688cf963ea6cd.js} +1 -1
- package/assets/esri/core/workers/chunks/{2665337e1b665e7e2b70.js → 15081b361fc42f40b865.js} +1 -1
- package/assets/esri/core/workers/chunks/{bcb2092c87d8d21c6458.js → 197b9f8483fad2258650.js} +1 -1
- package/assets/esri/core/workers/chunks/1cd8dff4373494b01ad4.js +1 -0
- package/assets/esri/core/workers/chunks/1d92da90fbbc3f98b201.js +1 -0
- package/assets/esri/core/workers/chunks/210ffc448c73a7bf63aa.js +1 -0
- package/assets/esri/core/workers/chunks/{a14e5607c5c091c77e3d.js → 2540beb53f1443a070d7.js} +1 -1
- package/assets/esri/core/workers/chunks/{689673173ca1c0e098fe.js → 25932fa010f9a32475c1.js} +1 -1
- package/assets/esri/core/workers/chunks/{e2d500ac1a264d09c857.js → 32b5d2537feefe6e94a3.js} +1 -1
- package/assets/esri/core/workers/chunks/34a024eda22d228e1fbe.js +1 -0
- package/assets/esri/core/workers/chunks/3f63b14b53b5ca716e3a.js +1 -0
- package/assets/esri/core/workers/chunks/{6df54132299b9e8f6dad.js → 456b77b8f13933a75b68.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c342e662c13a05f4caf.js → 49713dfa4c8b788079d1.js} +1 -1
- package/assets/esri/core/workers/chunks/{45e4b9069263adeae394.js → 49a45083a9a155614c1c.js} +1 -1
- package/assets/esri/core/workers/chunks/4be31fcc5482a2526d2b.js +1 -0
- package/assets/esri/core/workers/chunks/{31d92ba9089617aa59ab.js → 57c003c6745d450558a7.js} +1 -1
- package/assets/esri/core/workers/chunks/{8104ac2eee69d79ada86.js → 6048c89fc4dcd2e9988d.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b9c68e8431bb4608209.js → 6162f6735ea4622e54d8.js} +1 -1
- package/assets/esri/core/workers/chunks/684c9b4bd9590d2db12f.js +1 -0
- package/assets/esri/core/workers/chunks/684d3cb4fb233180b2d0.js +1 -0
- package/assets/esri/core/workers/chunks/{fe6385115d76e16e8da0.js → 75baf6dff6e7658b17b3.js} +1 -1
- package/assets/esri/core/workers/chunks/{166a0df6e37627e18976.js → 7a2dfa42610fe8414ed7.js} +1 -1
- package/assets/esri/core/workers/chunks/{43847d66726fd0bcbbb7.js → 83ae56c7fa8d84865605.js} +1 -1
- package/assets/esri/core/workers/chunks/8722e2790272e90a1897.js +1 -0
- package/assets/esri/core/workers/chunks/{1282598516cd0e3056b7.js → 977e6f589bd266d6067d.js} +2 -2
- package/assets/esri/core/workers/chunks/9f3d37e5f42bf1529673.js +1 -0
- package/assets/esri/core/workers/chunks/a833fc9250635eb4152f.js +1 -0
- package/assets/esri/core/workers/chunks/{47290f27375c76bcc9c7.js → b0253fe7b3529bc22270.js} +1 -1
- package/assets/esri/core/workers/chunks/b324bdb9c74fc3f956db.js +1 -0
- package/assets/esri/core/workers/chunks/{1bd7b7f4ee7ea6cb7ef9.js → b60f24a6c777301803f4.js} +1 -1
- package/assets/esri/core/workers/chunks/bd155794e9bc16dd0474.js +1 -0
- package/assets/esri/core/workers/chunks/{906f4c0fa8135e6c2f03.js → c660a5a1086870a3a6b9.js} +1 -1
- package/assets/esri/core/workers/chunks/cb58aff1ff186fa18345.js +1 -0
- package/assets/esri/core/workers/chunks/{17b98787a0698f584882.js → e7cb1b72f0b54e845741.js} +1 -1
- package/assets/esri/core/workers/chunks/{21122f3f3e19a7fd7d33.js → f69d3ff8a69c1985bca3.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/chunks/ShadowCastVisualize.glsl.js +4 -10
- package/chunks/aiServices.js +1 -1
- package/chunks/array.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/graphic/AnnotationFeatureGraphicOrigin.d.ts +3 -3
- package/graphic/AnnotationFeatureGraphicOrigin.js +1 -1
- package/intl/messages.d.ts +12 -2
- package/intl/t9n.d.ts +8 -1
- package/intl.d.ts +4 -0
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.d.ts +1 -4
- package/layers/AnnotationFeatureLayer.js +1 -1
- package/layers/DimensionFeatureLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/mixins/DataElementMixin.js +2 -0
- package/layers/support/AnnotationFeatureSublayer.js +1 -1
- package/layers/support/parquetUtils.js +1 -1
- package/package.json +1 -1
- package/support/ArcadeExpression.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/supportUtils.js +2 -0
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/util/DimensionMatcher.js +1 -1
- package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/2d/layers/support/annodime/annotationSchema.js +1 -1
- package/views/2d/layers/support/annodime/dimensionSchema.js +1 -1
- package/views/2d/layers/support/annodime/utils.js +1 -1
- package/views/2d/layers/support/annodime/virtualFields.js +1 -1
- package/views/3d/camera/constraintUtils.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/PatchRenderDataWaterproofness.js +2 -0
- package/views/3d/terrain/PlanarPatch.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/OpaqueEnvironment.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/ObjectAndLayerID.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlightBuffer.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
- package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillComputation.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
- package/views/3d/webgl.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/layers/FeatureLikeLayerView.js +1 -1
- package/views/popupAdapter.js +1 -1
- package/webdoc/support/thumbnailUtils.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/support/widget.d.ts +1 -0
- package/assets/esri/core/workers/chunks/125edba5c618c6257cb8.js +0 -1
- package/assets/esri/core/workers/chunks/168be2eac0fa3c67ae27.js +0 -1
- package/assets/esri/core/workers/chunks/32740b075d7a890d7888.js +0 -1
- package/assets/esri/core/workers/chunks/5189413a83faf3480e29.js +0 -1
- package/assets/esri/core/workers/chunks/a2be8784f2cfdbb42681.js +0 -1
- package/assets/esri/core/workers/chunks/a9db775210ebeee41738.js +0 -1
- package/assets/esri/core/workers/chunks/bca6abc185dedec0f41b.js +0 -1
- package/assets/esri/core/workers/chunks/bee56a6ac99312f03109.js +0 -1
- package/assets/esri/core/workers/chunks/d1d135a54233092ad637.js +0 -1
- package/assets/esri/core/workers/chunks/d750e4abeb777caa8c36.js +0 -1
- package/assets/esri/core/workers/chunks/daf539e9f88fc9e101e4.js +0 -1
- package/assets/esri/core/workers/chunks/e774303efefee31952d0.js +0 -1
- package/assets/esri/core/workers/chunks/e8546ab510fc9515bd23.js +0 -1
- package/assets/esri/core/workers/chunks/fc9664d3282b052ef40f.js +0 -1
- package/views/2d/layers/support/annodime/DimensionMatcherSchema.js +0 -2
- package/views/2d/layers/support/annodime/unsupported.js +0 -2
package/arcade/arcadeRuntime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as r}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as s,flattenAccessChain as i}from"./compilerUtils.js";import{getNestedOptionalValue as a,getGeometryKeys as l,getGeometryMember as c,tryGetMember as u,getMember as f}from"./containerUtils.js";import p from"./Dictionary.js";import{ArcadeExecutionError as h,ensureLocatableError as d}from"./executionError.js";import{Feature as w}from"./Feature.js";import{NativeFunction as m,ArcadeFunction as g,ScopeMarshalledFunction as b,wrapModuleScopedResponse as y}from"./FunctionWrapper.js";import{R as v,I as x,q as S,i as R,z as F,A as k,v as j,B as I,j as O,y as A,h as N,w as C,r as M,s as E,u as B,x as U,k as G}from"../chunks/languageUtils.js";import{addFunctionDeclaration as z}from"./treeAnalysis.js";import{A as D}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as _}from"./functions/feature.js";import{registerFunctions as Z}from"./functions/geometry.js";import{registerFunctions as q}from"./functions/geomsync.js";import{registerFunctions as W}from"./functions/maths.js";import{registerFunctions as P}from"./functions/stats.js";import{registerFunctions as V}from"./functions/string.js";import{registerFunctions as T}from"./functions/track.js";import K from"../core/Logger.js";import Y from"../geometry/SpatialReference.js";import{isGraphic as $}from"../support/graphicInstanceUtils.js";import{isBoolean as H,isArray as J,isString as Q,isNumber as X}from"../support/guards.js";const ee=()=>K.getLogger("esri.arcade.arcadeRuntime"),te=Symbol("uninitialized");function re(e){if(e===te)throw new h("InvalidIdentifier",null)}function ne(e){return re(e),e}function oe(t,r){const n=e(r);if(null!==t.localScope){const e=t.localScope[n];if(void 0!==e)return{scope:t.localScope,id:n,var:e}}const o=t.globalScope[n];if(void 0!==o)return{scope:t.globalScope,id:n,var:o};throw new h("InvalidIdentifier",r)}function se(t,r,n="InvalidIdentifier"){const o=e(r);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return re(e),e.value}const s=t.globalScope[o];if(void 0!==s)return re(s),s.value;throw new h(n,r)}const ie=function(){};ie.prototype=Object.freeze(Object.create(null));class ae extends g{constructor(e,t,r,n){super(),this.definition=e,this.context=t,this._params=r,this._locals=n}get debugName(){return null}createFunction(e){return(...t)=>{const r={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,abortSignal:this.context.abortSignal,localScope:new ie,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,track:this.context.track};if(r.depthCounter.depth>64)throw new h("MaximumCallDepth",null);return le(r,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return fe(e,t,(r,n,o)=>{const s={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ie,track:e.track};if(s.depthCounter.depth>64)throw new h("MaximumCallDepth",t);return le(s,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,r,n){return n(e,t,(o,s,i)=>{const a={spatialReference:e.spatialReference,globalScope:r.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ie,track:e.track};return i=i.map(t=>!R(t)||t instanceof b?t:y(t,e,n)),y(le(a,this.definition.body,this._params,this._locals,i,t),r,n)})}}function le(e,t,r,n,o,s){try{if(r.length!==o.length)throw new h("WrongNumberOfParameters",s);if(null!=e.localScope){for(let t=0;t<r.length;t++)e.localScope[r[t]]={value:o[t]};for(const t of n)e.localScope[t]=te}const i=he(e,t);if(i instanceof v)return i.value;if(i===F)throw new h("UnexpectedToken",s);if(i===k)throw new h("UnexpectedToken",s);return i instanceof x?i.value:i}catch(i){throw i}}class ce extends r{constructor(e){super(),this.moduleGlobalContext=e}global(t){const r=e(t);if(!this.moduleGlobalContext.exports.has(r))throw new h("ModuleExportNotFound",null);const n=this.moduleGlobalContext.globalScope[r];if(re(n),R(n.value)&&!(n.value instanceof b)){const e=new b;return e.fn=n.value,e.parameterEvaluator=fe,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[r]={value:e},e}return n.value}setGlobal(t,r){if(R(r))throw new h("AssignModuleFunction",null);const n=e(t);if(!this.moduleGlobalContext.exports.has(n))throw new h("ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[n]={value:r}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static load(e,r){const{globals:s,exports:i}=o(r),a=new Xe;for(const t of s.keys())t in a||(a[t]=te);const l=e.spatialReference??Y.WebMercator,c={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:l,track:e.track,depthCounter:{depth:1},libraryResolver:new n(e.libraryResolver._moduleSingletons,r.loadedModules),exports:i,localScope:null,globalScope:a};return ke(c,r),new ce(c)}}function ue(e,t){const r=[];for(let n=0;n<t.arguments.length;n++)r.push(pe(e,t.arguments[n]));return r}function fe(e,t,r){try{return!0===t.preparsed?r(e,null,t.arguments):r(e,t,ue(e,t))}catch(n){throw n}}function pe(e,t){try{switch(t.type){case"AssignmentExpression":return Se(e,t);case"UpdateExpression":return ve(e,t);case"TemplateLiteral":return qe(e,t);case"Identifier":return We(e,t);case"MemberExpression":return Me(e,t);case"Literal":return t.value;case"CallExpression":return Pe(e,t);case"UnaryExpression":return ze(e,t);case"BinaryExpression":return Le(e,t);case"LogicalExpression":return _e(e,t);case"ArrayExpression":return De(e,t);case"ObjectExpression":return de(e,t);case"MemberAccessChainExpression":return Ge(e,t);case"SafeMemberExpression":throw ee().error("SafeMemberExpression outside of MemberAccessChainExpression"),new h("Unrecognized",t);default:throw new h("Unrecognized",t)}}catch(r){throw d(r,t)}}function he(e,t){switch(t.type){case"EmptyStatement":return j;case"VariableDeclaration":return Ne(e,t);case"ImportDeclaration":return Oe(e,t);case"ExportNamedDeclaration":return Ae(e,t);case"BlockStatement":return ke(e,t);case"FunctionDeclaration":return Ie(e,t);case"ReturnStatement":return je(e,t);case"IfStatement":return Fe(e,t);case"ExpressionStatement":return Re(e,t);case"BreakStatement":return F;case"ContinueStatement":return k;case"ForStatement":return ge(e,t);case"ForInStatement":return we(e,t);case"ForOfStatement":return me(e,t);case"WhileStatement":return be(e,t);default:throw new h("Unrecognized",t)}}function de(e,t){const r=Object.create(null),n=new Map;for(let s=0;s<t.properties.length;s++){const o=t.properties[s],i="Identifier"===o.key.type?o.key.name:pe(e,o.key),a=pe(e,o.value);if(R(a))throw new h("NoFunctionInDictionary",t);if(!1===Q(i))throw new h("KeyMustBeString",t);let l=i.toString();const c=l.toLowerCase();n.has(c)?l=n.get(c):n.set(c,l),r[l]=a===j?null:a}const o=new p(r);return o.immutable=!1,o}function we(e,t){const r=pe(e,t.right);"VariableDeclaration"===t.left.type&&Ne(e,t.left);const n=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(J(r)||Q(r)){const o=r.length;for(let r=0;r<o;r++){n.scope[n.id]={value:r};const o=he(e,t.body);if(o===F)break;if(o instanceof v)return o}return j}if(O(r)){for(let o=0;o<r.length();o++){n.scope[n.id]={value:o};const r=he(e,t.body);if(r===F)break;if(r instanceof v)return r}return j}if(r instanceof p||A(r)){const o=r.keys();for(let r=0;r<o.length;r++){n.scope[n.id]={value:o[r]};const s=he(e,t.body);if(s===F)break;if(s instanceof v)return s}return j}if(N(r)){for(const o of l(r)){n.scope[n.id]={value:o};const r=he(e,t.body);if(r===F)break;if(r instanceof v)return r}return j}return j}function me(e,t){const r=pe(e,t.right);"VariableDeclaration"===t.left.type&&he(e,t.left);const n=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(J(r)||Q(r)){const o=r.length;for(let s=0;s<o;s++){if(s>=r.length)throw new h("OutOfBounds",t);n.scope[n.id]={value:r[s]};const o=he(e,t.body);if(o===F)break;if(o instanceof v)return o}return j}if(O(r)){for(let o=0;o<r.length();o++){n.scope[n.id]={value:r.get(o)};const s=he(e,t.body);if(s===F)break;if(s instanceof v)return s}return j}if(r instanceof p||A(r)){for(const o of r.keys()){const s=r.field(o);n.scope[n.id]={value:p.containerEntry(o,s)};const i=he(e,t.body);if(i===F)break;if(i instanceof v)return i}return j}if(N(r)){for(const o of l(r)){const s=c(r,o,t);n.scope[n.id]={value:p.containerEntry(o,s)};const i=he(e,t.body);if(i===F)break;if(i instanceof v)return i}return j}return j}function ge(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?he(e,t.init):pe(e,t.init));const r={testResult:!0,lastAction:j};do{ye(e,t,r)}while(!0===r.testResult);return r.lastAction instanceof v?r.lastAction:j}function be(e,t){const r={testResult:!0,lastAction:j};if(r.testResult=pe(e,t.test),!1===r.testResult)return j;if(!0!==r.testResult)throw new h("BooleanConditionRequired",t);for(;!0===r.testResult&&(r.lastAction=he(e,t.body),r.lastAction!==F)&&!(r.lastAction instanceof v);)if(r.testResult=pe(e,t.test),!0!==r.testResult&&!1!==r.testResult)throw new h("BooleanConditionRequired",t);return r.lastAction instanceof v?r.lastAction:j}function ye(e,t,r){if(null!==t.test){if(r.testResult=pe(e,t.test),!1===r.testResult)return;if(!0!==r.testResult)throw new h("BooleanConditionRequired",t)}r.lastAction=he(e,t.body),r.lastAction!==F?r.lastAction instanceof v?r.testResult=!1:null!==t.update&&pe(e,t.update):r.testResult=!1}function ve(e,t){if("CallExpression"===t.argument.type)throw new h("NeverReach",t);let r;if("MemberExpression"===t.argument.type){const n=pe(e,t.argument.object);let o;if(!0===t.argument.computed)o=pe(e,t.argument.property);else{if("Identifier"!==t.argument.property.type)throw new h("Unrecognized",t);o=t.argument.property.name}if(J(n)){if(!X(o))throw new h("ArrayAccessMustBeNumber",t);if(o<0&&(o=n.length+o),o<0||o>=n.length)throw new h("OutOfBounds",t);r=M(n[o]),n[o]="++"===t.operator?r+1:r-1}else if(n instanceof p){if(!1===Q(o))throw new h("KeyAccessorMustBeString",t);if(!0!==n.hasField(o))throw new h("FieldNotFound",t,{key:o});r=M(n.field(o)),n.setField(o,"++"===t.operator?r+1:r-1)}else if(G(n)){if(!1===Q(o))throw new h("KeyAccessorMustBeString",t);if(!0!==n.hasField(o))throw new h("FieldNotFound",t,{key:o});r=M(n.field(o)),n.setField(o,"++"===t.operator?r+1:r-1)}else{if(O(n))throw new h("Immutable",t);if(!(n instanceof ce))throw new h("InvalidParameter",t);if(!1===Q(o))throw new h("ModuleAccessorMustBeString",t);if(!0!==n.hasGlobal(o))throw new h("ModuleExportNotFound",t);r=M(n.global(o)),n.setGlobal(o,"++"===t.operator?r+1:r-1)}return!1===t.prefix?r:"++"===t.operator?r+1:r-1}const n=oe(e,t.argument);r=M(ne(n.var).value);const o="++"===t.operator?r+1:r-1;return n.scope[n.id]={value:o},!1===t.prefix?r:"++"===t.operator?r+1:r-1}function xe(e,t,r,n){switch(t){case"=":return e===j?null:e;case"/=":return M(r)/M(e);case"*=":return M(r)*M(e);case"-=":return M(r)-M(e);case"+=":return Q(r)||Q(e)?E(r)+E(e):M(r)+M(e);case"%=":return M(r)%M(e);default:throw new h("UnsupportedOperator",n)}}function Se(e,t){if("MemberExpression"===t.left.type){const r=pe(e,t.left.object);let n;if(!0===t.left.computed)n=pe(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new h("InvalidIdentifier",t);n=t.left.property.name}const o=pe(e,t.right);if(J(r)){if(!X(n))throw new h("ArrayAccessMustBeNumber",t);if(n<0&&(n=r.length+n),n<0||n>r.length)throw new h("OutOfBounds",t);if(n===r.length){if("="!==t.operator)throw new h("OutOfBounds",t);r[n]=xe(o,t.operator,r[n],t)}else r[n]=xe(o,t.operator,r[n],t)}else if(r instanceof p){if(!1===Q(n))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(n))r.setField(n,xe(o,t.operator,r.field(n),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:n});r.setField(n,xe(o,t.operator,null,t))}}else if(G(r)){if(!1===Q(n))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(n))r.setField(n,xe(o,t.operator,r.field(n),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:n});r.setField(n,xe(o,t.operator,null,t))}}else{if(O(r))throw new h("Immutable",t);if(!(r instanceof ce))throw new h("InvalidIdentifier",t);if(!1===Q(n))throw new h("ModuleAccessorMustBeString",t);if(!0!==r.hasGlobal(n))throw new h("ModuleExportNotFound",t);r.setGlobal(n,xe(o,t.operator,r.global(n),t))}return j}const r=oe(e,t.left),n=pe(e,t.right);return r.scope[r.id]={value:xe(n,t.operator,"="!==t.operator?ne(r.var).value:null,t)},j}function Re(e,t){const r=pe(e,t.expression);return r===j?j:new x(r)}function Fe(e,t){const r=pe(e,t.test);if(!0===r)return he(e,t.consequent);if(!1===r)return null!==t.alternate?he(e,t.alternate):j;throw new h("BooleanConditionRequired",t)}function ke(e,t){let r=j;for(let n=0;n<t.body.length;n++)if(r=he(e,t.body[n]),r instanceof v||r===F||r===k)return r;return r}function je(e,t){if(null===t.argument)return new v(j);const r=pe(e,t.argument);return new v(r)}function Ie(t,r){if(null!=t.localScope)throw ee().error("Function declarations are only valid in global scope."),new h("NeverReach",r);const n=e(r.id);if(!(n in t.globalScope))throw ee().error(`Function "${n}" not declared.`),new h("NeverReach",r);const o=s(r),i=r.params.map(t=>e(t)),a=Array.from(o.keys()).filter(e=>!i.includes(e));return t.globalScope[n]={value:new ae(r,t,i,a)},j}function Oe(e,t){const r=oe(e,t.specifiers[0].local),n=e.libraryResolver;if(null==n)throw ee().error("Internal error: module loader not initialized"),new h("NeverReach",t);const o=n.loadLibrary(r.id);let s;return n._moduleSingletons?.has(o.uri)?s=n._moduleSingletons.get(o.uri):(s=ce.load(e,o.syntax),n._moduleSingletons?.set(o.uri,s)),r.scope[r.id]={value:s},j}function Ae(e,t){return he(e,t.declaration),j}function Ne(e,t){for(let r=0;r<t.declarations.length;r++)Ce(e,t.declarations[r]);return j}function Ce(e,t){let r=null===t.init?null:pe(e,t.init);if(r===j&&(r=null),"Identifier"!==t.id.type)throw new h("InvalidIdentifier",t);const n=oe(e,t.id);n.scope[n.id]={value:r}}function Me(e,t){return Ee(e,pe(e,t.object),t)}function Ee(e,t,r){const n=r.computed?pe(e,r.property):r.property.name;return f(t,n)}function Be(e,t,r){for(const n of r)switch(n.type){case"MemberExpression":t=Ee(e,t,n);break;case"CallExpression":t=Ve(e,t,n);break;default:throw new h("Unrecognized",n)}return t}function Ue(e,t,r){const n=r.computed?pe(e,r.property):r.property.name;return u(t,n)}function Ge(e,t){const r=i(t);let n=pe(e,r.root);for(const o of r.sections){const t=Ue(e,n,o.checked);if(null==t)return null;n=Be(e,t,o.unchecked)}return n}function ze(e,t){try{const r=pe(e,t.argument);if(H(r)){if("!"===t.operator)return!r;if("-"===t.operator)return-1*M(r);if("+"===t.operator)return 1*M(r);if("~"===t.operator)return~M(r);throw new h("UnsupportUnaryOperator",t)}if("~"===t.operator)return~M(r);if("-"===t.operator)return-1*M(r);if("+"===t.operator)return 1*M(r);throw new h("UnsupportUnaryOperator",t)}catch(r){throw r}}function De(e,t){try{const r=[];for(let n=0;n<t.elements.length;n++){const o=pe(e,t.elements[n]);if(R(o))throw new h("NoFunctionInArray",t);o===j?r.push(null):r.push(o)}return r}catch(r){throw r}}function Le(e,t){try{const r=pe(e,t.left),n=pe(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return U(M(r),M(n),t.operator);case"==":return C(r,n);case"!=":return!C(r,n);case"<":case">":case"<=":case">=":return B(r,n,t.operator);case"+":return Q(r)||Q(n)?E(r)+E(n):M(r)+M(n);case"-":return M(r)-M(n);case"*":return M(r)*M(n);case"/":return M(r)/M(n);case"%":return M(r)%M(n);default:throw t.operator,new h("UnsupportedOperator",t)}}catch(r){throw r}}function _e(e,t){try{const r=pe(e,t.left);if(H(r))switch(t.operator){case"||":{if(!0===r)return r;const n=pe(e,t.right);if(H(n))return n;throw new h("LogicExpressionOrAnd",t)}case"&&":{if(!1===r)return r;const n=pe(e,t.right);if(H(n))return n;throw new h("LogicExpressionOrAnd",t)}default:throw t.operator,new h("LogicExpressionOrAnd",t)}throw new h("LogicalExpressionOnlyBoolean",t)}catch(r){throw r}}function Ze(e,t){if(R(e))throw new h("NoFunctionInTemplateLiteral",t);return e}function qe(e,t){let r="",n=0;for(const o of t.quasis)if(r+=o.value?o.value.cooked:"",!1===o.tail){r+=t.expressions[n]?E(Ze(pe(e,t.expressions[n]),t)):"",n++}return r}function We(e,t){return se(e,t)}function Pe(e,t){return Ve(e,"Identifier"===t.callee.type?se(e,t.callee,"FunctionNotFound"):pe(e,t.callee),t)}function Ve(e,t,r){if(R(t))return t.call(e,r);throw new h("CallNonFunction",r)}function Te(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;I(null===r?[]:r,3,3,t);const n=pe(e,r[0]);if(!1===H(n))throw new h("BooleanConditionRequired",t);return pe(e,!0===n?r[1]:r[2])}catch(r){throw r}}function Ke(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;I(null===r?[]:r,2,3,t);const n=pe(e,r[0]);if(3===r.length){const t=pe(e,r[1]),o=a(n,t);return null!=o&&""!==o?o:pe(e,r[2])}return null===n||""===n||void 0===n?pe(e,r[1]):n}catch(r){throw r}}function Ye(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;if(r.length<2)throw new h("WrongNumberOfParameters",t);if(2===r.length)return pe(e,r[1]);{if((r.length-1)%2==0)throw new h("WrongNumberOfParameters",t);const n=pe(e,r[0]);return $e(e,t,1,n)}}catch(r){throw r}}function $e(e,t,r,n){try{const o=t.arguments,s=pe(e,o[r]);if(C(s,n))return pe(e,o[r+1]);{const s=o.length-r;return 1===s?pe(e,o[r]):2===s?null:3===s?pe(e,o[r+2]):$e(e,t,r+2,n)}}catch(o){throw o}}function He(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;if(r.length<3)throw new h("WrongNumberOfParameters",t);if(r.length%2==0)throw new h("WrongNumberOfParameters",t);const n=pe(e,r[0]);if(!1===H(n))throw new h("BooleanConditionRequired",r[0]);return Je(e,t,0,n)}catch(r){throw r}}function Je(e,t,r,n){try{const o=t.arguments;if(!0===n)return pe(e,o[r+1]);if(3===o.length-r)return pe(e,o[r+2]);{const n=pe(e,o[r+2]);if(!1===H(n))throw new h("BooleanConditionRequired",o[r+2]);return Je(e,t,r+2,n)}}catch(o){throw o}}function Qe(){const e=Object.create(null);L(e,fe),V(e,fe),_(e,fe,We),W(e,fe),Z(e,fe),P(e,fe),q(e,fe),T(e,fe),e.iif=Te,e.defaultvalue=Ke,e.decode=Ye,e.when=He;const t=function(){this.textformatting={value:p.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.nan=Object.freeze({value:Number.NaN}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[r,n]of Object.entries(e))t.prototype[r]=Object.freeze({value:new m(n)});return t}const Xe=Qe();function et(e){const t={mode:"sync",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:fe,evaluateIdentifier:We};for(let r=0;r<e.length;r++)e[r].registerFunctions(t);for(const[r,n]of Object.entries(t.functions))Xe.prototype[r]=Object.freeze({value:new m(n)});for(let r=0;r<t.signatures.length;r++)z(t.signatures[r],"sync")}function tt(e){console.log(e)}function rt(r,s){const i=new Set(Object.keys(s?.vars||{}).map(t=>e(t))),a=new Set(Object.keys(s?.customfunctions||{}).map(t=>e(t))),{globals:l,exports:c}=o(r),u=new Set(l.keys());return e=>{const o=e.spatialReference??Y.WebMercator;let s=null;r.usesModules&&(s=new n(new Map,r.loadedModules));const l=new Xe;for(const t of a)null!=e.customfunctions&&t in e.customfunctions?l[t]={value:new m(e.customfunctions[t])}:l[t]=te;for(const t of i){if(null==e.vars||!(t in e.vars)){t in l||(l[t]=te);continue}const r=e.vars[t]??null;$(r)?l[t]={value:w.createFromGraphic(r,e.timeZone??null)}:l[t]={value:r}}for(const t of u)t in l||(l[t]=te);const f=ke({lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:s,exports:c,localScope:null,globalScope:l},r);if(f instanceof v||f instanceof x){const e=f.value;if(S(e))return null;if(R(e))throw new h("IllegalResult",null);return e}if(S(f))return null;if(f===F)throw new h("IllegalResult",null);if(f===k)throw new h("IllegalResult",null);throw new h("NeverReach",null)}}function nt(e,t){return rt(e,t)(t)}et([D]);export{nt as executeScript,et as extend,rt as prepareScript};
|
|
2
|
+
import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as r}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as s,flattenAccessChain as i}from"./compilerUtils.js";import{getNestedOptionalValue as a,getGeometryKeys as l,getGeometryMember as c,tryGetMember as u,getMember as f}from"./containerUtils.js";import p from"./Dictionary.js";import{ArcadeExecutionError as h,ensureLocatableError as d}from"./executionError.js";import{Feature as w}from"./Feature.js";import{NativeFunction as m,ArcadeFunction as g,ScopeMarshalledFunction as b,wrapModuleScopedResponse as y}from"./FunctionWrapper.js";import{R as v,I as x,q as S,i as R,z as F,A as k,v as j,B as I,g as O,y as A,f as N,w as C,r as M,s as E,u as B,x as U,h as G}from"../chunks/languageUtils.js";import{addFunctionDeclaration as z}from"./treeAnalysis.js";import{A as D}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as _}from"./functions/feature.js";import{registerFunctions as Z}from"./functions/geometry.js";import{registerFunctions as q}from"./functions/geomsync.js";import{registerFunctions as W}from"./functions/maths.js";import{registerFunctions as P}from"./functions/stats.js";import{registerFunctions as V}from"./functions/string.js";import{registerFunctions as T}from"./functions/track.js";import K from"../core/Logger.js";import Y from"../geometry/SpatialReference.js";import{isGraphic as $}from"../support/graphicInstanceUtils.js";import{isBoolean as H,isArray as J,isString as Q,isNumber as X}from"../support/guards.js";const ee=()=>K.getLogger("esri.arcade.arcadeRuntime"),te=Symbol("uninitialized");function re(e){if(e===te)throw new h("InvalidIdentifier",null)}function ne(e){return re(e),e}function oe(t,r){const n=e(r);if(null!==t.localScope){const e=t.localScope[n];if(void 0!==e)return{scope:t.localScope,id:n,var:e}}const o=t.globalScope[n];if(void 0!==o)return{scope:t.globalScope,id:n,var:o};throw new h("InvalidIdentifier",r)}function se(t,r,n="InvalidIdentifier"){const o=e(r);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return re(e),e.value}const s=t.globalScope[o];if(void 0!==s)return re(s),s.value;throw new h(n,r)}const ie=function(){};ie.prototype=Object.freeze(Object.create(null));class ae extends g{constructor(e,t,r,n){super(),this.definition=e,this.context=t,this._params=r,this._locals=n}get debugName(){return null}createFunction(e){return(...t)=>{const r={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,abortSignal:this.context.abortSignal,localScope:new ie,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,track:this.context.track};if(r.depthCounter.depth>64)throw new h("MaximumCallDepth",null);return le(r,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return fe(e,t,(r,n,o)=>{const s={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ie,track:e.track};if(s.depthCounter.depth>64)throw new h("MaximumCallDepth",t);return le(s,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,r,n){return n(e,t,(o,s,i)=>{const a={spatialReference:e.spatialReference,globalScope:r.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ie,track:e.track};return i=i.map(t=>!R(t)||t instanceof b?t:y(t,e,n)),y(le(a,this.definition.body,this._params,this._locals,i,t),r,n)})}}function le(e,t,r,n,o,s){try{if(r.length!==o.length)throw new h("WrongNumberOfParameters",s);if(null!=e.localScope){for(let t=0;t<r.length;t++)e.localScope[r[t]]={value:o[t]};for(const t of n)e.localScope[t]=te}const i=he(e,t);if(i instanceof v)return i.value;if(i===F)throw new h("UnexpectedToken",s);if(i===k)throw new h("UnexpectedToken",s);return i instanceof x?i.value:i}catch(i){throw i}}class ce extends r{constructor(e){super(),this.moduleGlobalContext=e}global(t){const r=e(t);if(!this.moduleGlobalContext.exports.has(r))throw new h("ModuleExportNotFound",null);const n=this.moduleGlobalContext.globalScope[r];if(re(n),R(n.value)&&!(n.value instanceof b)){const e=new b;return e.fn=n.value,e.parameterEvaluator=fe,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[r]={value:e},e}return n.value}setGlobal(t,r){if(R(r))throw new h("AssignModuleFunction",null);const n=e(t);if(!this.moduleGlobalContext.exports.has(n))throw new h("ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[n]={value:r}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static load(e,r){const{globals:s,exports:i}=o(r),a=new Xe;for(const t of s.keys())t in a||(a[t]=te);const l=e.spatialReference??Y.WebMercator,c={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:l,track:e.track,depthCounter:{depth:1},libraryResolver:new n(e.libraryResolver._moduleSingletons,r.loadedModules),exports:i,localScope:null,globalScope:a};return ke(c,r),new ce(c)}}function ue(e,t){const r=[];for(let n=0;n<t.arguments.length;n++)r.push(pe(e,t.arguments[n]));return r}function fe(e,t,r){try{return!0===t.preparsed?r(e,null,t.arguments):r(e,t,ue(e,t))}catch(n){throw n}}function pe(e,t){try{switch(t.type){case"AssignmentExpression":return Se(e,t);case"UpdateExpression":return ve(e,t);case"TemplateLiteral":return qe(e,t);case"Identifier":return We(e,t);case"MemberExpression":return Me(e,t);case"Literal":return t.value;case"CallExpression":return Pe(e,t);case"UnaryExpression":return ze(e,t);case"BinaryExpression":return Le(e,t);case"LogicalExpression":return _e(e,t);case"ArrayExpression":return De(e,t);case"ObjectExpression":return de(e,t);case"MemberAccessChainExpression":return Ge(e,t);case"SafeMemberExpression":throw ee().error("SafeMemberExpression outside of MemberAccessChainExpression"),new h("Unrecognized",t);default:throw new h("Unrecognized",t)}}catch(r){throw d(r,t)}}function he(e,t){switch(t.type){case"EmptyStatement":return j;case"VariableDeclaration":return Ne(e,t);case"ImportDeclaration":return Oe(e,t);case"ExportNamedDeclaration":return Ae(e,t);case"BlockStatement":return ke(e,t);case"FunctionDeclaration":return Ie(e,t);case"ReturnStatement":return je(e,t);case"IfStatement":return Fe(e,t);case"ExpressionStatement":return Re(e,t);case"BreakStatement":return F;case"ContinueStatement":return k;case"ForStatement":return ge(e,t);case"ForInStatement":return we(e,t);case"ForOfStatement":return me(e,t);case"WhileStatement":return be(e,t);default:throw new h("Unrecognized",t)}}function de(e,t){const r=Object.create(null),n=new Map;for(let s=0;s<t.properties.length;s++){const o=t.properties[s],i="Identifier"===o.key.type?o.key.name:pe(e,o.key),a=pe(e,o.value);if(R(a))throw new h("NoFunctionInDictionary",t);if(!1===Q(i))throw new h("KeyMustBeString",t);let l=i.toString();const c=l.toLowerCase();n.has(c)?l=n.get(c):n.set(c,l),r[l]=a===j?null:a}const o=new p(r);return o.immutable=!1,o}function we(e,t){const r=pe(e,t.right);"VariableDeclaration"===t.left.type&&Ne(e,t.left);const n=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(J(r)||Q(r)){const o=r.length;for(let r=0;r<o;r++){n.scope[n.id]={value:r};const o=he(e,t.body);if(o===F)break;if(o instanceof v)return o}return j}if(O(r)){for(let o=0;o<r.length();o++){n.scope[n.id]={value:o};const r=he(e,t.body);if(r===F)break;if(r instanceof v)return r}return j}if(r instanceof p||A(r)){const o=r.keys();for(let r=0;r<o.length;r++){n.scope[n.id]={value:o[r]};const s=he(e,t.body);if(s===F)break;if(s instanceof v)return s}return j}if(N(r)){for(const o of l(r)){n.scope[n.id]={value:o};const r=he(e,t.body);if(r===F)break;if(r instanceof v)return r}return j}return j}function me(e,t){const r=pe(e,t.right);"VariableDeclaration"===t.left.type&&he(e,t.left);const n=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(J(r)||Q(r)){const o=r.length;for(let s=0;s<o;s++){if(s>=r.length)throw new h("OutOfBounds",t);n.scope[n.id]={value:r[s]};const o=he(e,t.body);if(o===F)break;if(o instanceof v)return o}return j}if(O(r)){for(let o=0;o<r.length();o++){n.scope[n.id]={value:r.get(o)};const s=he(e,t.body);if(s===F)break;if(s instanceof v)return s}return j}if(r instanceof p||A(r)){for(const o of r.keys()){const s=r.field(o);n.scope[n.id]={value:p.containerEntry(o,s)};const i=he(e,t.body);if(i===F)break;if(i instanceof v)return i}return j}if(N(r)){for(const o of l(r)){const s=c(r,o,t);n.scope[n.id]={value:p.containerEntry(o,s)};const i=he(e,t.body);if(i===F)break;if(i instanceof v)return i}return j}return j}function ge(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?he(e,t.init):pe(e,t.init));const r={testResult:!0,lastAction:j};do{ye(e,t,r)}while(!0===r.testResult);return r.lastAction instanceof v?r.lastAction:j}function be(e,t){const r={testResult:!0,lastAction:j};if(r.testResult=pe(e,t.test),!1===r.testResult)return j;if(!0!==r.testResult)throw new h("BooleanConditionRequired",t);for(;!0===r.testResult&&(r.lastAction=he(e,t.body),r.lastAction!==F)&&!(r.lastAction instanceof v);)if(r.testResult=pe(e,t.test),!0!==r.testResult&&!1!==r.testResult)throw new h("BooleanConditionRequired",t);return r.lastAction instanceof v?r.lastAction:j}function ye(e,t,r){if(null!==t.test){if(r.testResult=pe(e,t.test),!1===r.testResult)return;if(!0!==r.testResult)throw new h("BooleanConditionRequired",t)}r.lastAction=he(e,t.body),r.lastAction!==F?r.lastAction instanceof v?r.testResult=!1:null!==t.update&&pe(e,t.update):r.testResult=!1}function ve(e,t){if("CallExpression"===t.argument.type)throw new h("NeverReach",t);let r;if("MemberExpression"===t.argument.type){const n=pe(e,t.argument.object);let o;if(!0===t.argument.computed)o=pe(e,t.argument.property);else{if("Identifier"!==t.argument.property.type)throw new h("Unrecognized",t);o=t.argument.property.name}if(J(n)){if(!X(o))throw new h("ArrayAccessMustBeNumber",t);if(o<0&&(o=n.length+o),o<0||o>=n.length)throw new h("OutOfBounds",t);r=M(n[o]),n[o]="++"===t.operator?r+1:r-1}else if(n instanceof p){if(!1===Q(o))throw new h("KeyAccessorMustBeString",t);if(!0!==n.hasField(o))throw new h("FieldNotFound",t,{key:o});r=M(n.field(o)),n.setField(o,"++"===t.operator?r+1:r-1)}else if(G(n)){if(!1===Q(o))throw new h("KeyAccessorMustBeString",t);if(!0!==n.hasField(o))throw new h("FieldNotFound",t,{key:o});r=M(n.field(o)),n.setField(o,"++"===t.operator?r+1:r-1)}else{if(O(n))throw new h("Immutable",t);if(!(n instanceof ce))throw new h("InvalidParameter",t);if(!1===Q(o))throw new h("ModuleAccessorMustBeString",t);if(!0!==n.hasGlobal(o))throw new h("ModuleExportNotFound",t);r=M(n.global(o)),n.setGlobal(o,"++"===t.operator?r+1:r-1)}return!1===t.prefix?r:"++"===t.operator?r+1:r-1}const n=oe(e,t.argument);r=M(ne(n.var).value);const o="++"===t.operator?r+1:r-1;return n.scope[n.id]={value:o},!1===t.prefix?r:"++"===t.operator?r+1:r-1}function xe(e,t,r,n){switch(t){case"=":return e===j?null:e;case"/=":return M(r)/M(e);case"*=":return M(r)*M(e);case"-=":return M(r)-M(e);case"+=":return Q(r)||Q(e)?E(r)+E(e):M(r)+M(e);case"%=":return M(r)%M(e);default:throw new h("UnsupportedOperator",n)}}function Se(e,t){if("MemberExpression"===t.left.type){const r=pe(e,t.left.object);let n;if(!0===t.left.computed)n=pe(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new h("InvalidIdentifier",t);n=t.left.property.name}const o=pe(e,t.right);if(J(r)){if(!X(n))throw new h("ArrayAccessMustBeNumber",t);if(n<0&&(n=r.length+n),n<0||n>r.length)throw new h("OutOfBounds",t);if(n===r.length){if("="!==t.operator)throw new h("OutOfBounds",t);r[n]=xe(o,t.operator,r[n],t)}else r[n]=xe(o,t.operator,r[n],t)}else if(r instanceof p){if(!1===Q(n))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(n))r.setField(n,xe(o,t.operator,r.field(n),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:n});r.setField(n,xe(o,t.operator,null,t))}}else if(G(r)){if(!1===Q(n))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(n))r.setField(n,xe(o,t.operator,r.field(n),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:n});r.setField(n,xe(o,t.operator,null,t))}}else{if(O(r))throw new h("Immutable",t);if(!(r instanceof ce))throw new h("InvalidIdentifier",t);if(!1===Q(n))throw new h("ModuleAccessorMustBeString",t);if(!0!==r.hasGlobal(n))throw new h("ModuleExportNotFound",t);r.setGlobal(n,xe(o,t.operator,r.global(n),t))}return j}const r=oe(e,t.left),n=pe(e,t.right);return r.scope[r.id]={value:xe(n,t.operator,"="!==t.operator?ne(r.var).value:null,t)},j}function Re(e,t){const r=pe(e,t.expression);return r===j?j:new x(r)}function Fe(e,t){const r=pe(e,t.test);if(!0===r)return he(e,t.consequent);if(!1===r)return null!==t.alternate?he(e,t.alternate):j;throw new h("BooleanConditionRequired",t)}function ke(e,t){let r=j;for(let n=0;n<t.body.length;n++)if(r=he(e,t.body[n]),r instanceof v||r===F||r===k)return r;return r}function je(e,t){if(null===t.argument)return new v(j);const r=pe(e,t.argument);return new v(r)}function Ie(t,r){if(null!=t.localScope)throw ee().error("Function declarations are only valid in global scope."),new h("NeverReach",r);const n=e(r.id);if(!(n in t.globalScope))throw ee().error(`Function "${n}" not declared.`),new h("NeverReach",r);const o=s(r),i=r.params.map(t=>e(t)),a=Array.from(o.keys()).filter(e=>!i.includes(e));return t.globalScope[n]={value:new ae(r,t,i,a)},j}function Oe(e,t){const r=oe(e,t.specifiers[0].local),n=e.libraryResolver;if(null==n)throw ee().error("Internal error: module loader not initialized"),new h("NeverReach",t);const o=n.loadLibrary(r.id);let s;return n._moduleSingletons?.has(o.uri)?s=n._moduleSingletons.get(o.uri):(s=ce.load(e,o.syntax),n._moduleSingletons?.set(o.uri,s)),r.scope[r.id]={value:s},j}function Ae(e,t){return he(e,t.declaration),j}function Ne(e,t){for(let r=0;r<t.declarations.length;r++)Ce(e,t.declarations[r]);return j}function Ce(e,t){let r=null===t.init?null:pe(e,t.init);if(r===j&&(r=null),"Identifier"!==t.id.type)throw new h("InvalidIdentifier",t);const n=oe(e,t.id);n.scope[n.id]={value:r}}function Me(e,t){return Ee(e,pe(e,t.object),t)}function Ee(e,t,r){const n=r.computed?pe(e,r.property):r.property.name;return f(t,n)}function Be(e,t,r){for(const n of r)switch(n.type){case"MemberExpression":t=Ee(e,t,n);break;case"CallExpression":t=Ve(e,t,n);break;default:throw new h("Unrecognized",n)}return t}function Ue(e,t,r){const n=r.computed?pe(e,r.property):r.property.name;return u(t,n)}function Ge(e,t){const r=i(t);let n=pe(e,r.root);for(const o of r.sections){const t=Ue(e,n,o.checked);if(null==t)return null;n=Be(e,t,o.unchecked)}return n}function ze(e,t){try{const r=pe(e,t.argument);if(H(r)){if("!"===t.operator)return!r;if("-"===t.operator)return-1*M(r);if("+"===t.operator)return 1*M(r);if("~"===t.operator)return~M(r);throw new h("UnsupportUnaryOperator",t)}if("~"===t.operator)return~M(r);if("-"===t.operator)return-1*M(r);if("+"===t.operator)return 1*M(r);throw new h("UnsupportUnaryOperator",t)}catch(r){throw r}}function De(e,t){try{const r=[];for(let n=0;n<t.elements.length;n++){const o=pe(e,t.elements[n]);if(R(o))throw new h("NoFunctionInArray",t);o===j?r.push(null):r.push(o)}return r}catch(r){throw r}}function Le(e,t){try{const r=pe(e,t.left),n=pe(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return U(M(r),M(n),t.operator);case"==":return C(r,n);case"!=":return!C(r,n);case"<":case">":case"<=":case">=":return B(r,n,t.operator);case"+":return Q(r)||Q(n)?E(r)+E(n):M(r)+M(n);case"-":return M(r)-M(n);case"*":return M(r)*M(n);case"/":return M(r)/M(n);case"%":return M(r)%M(n);default:throw t.operator,new h("UnsupportedOperator",t)}}catch(r){throw r}}function _e(e,t){try{const r=pe(e,t.left);if(H(r))switch(t.operator){case"||":{if(!0===r)return r;const n=pe(e,t.right);if(H(n))return n;throw new h("LogicExpressionOrAnd",t)}case"&&":{if(!1===r)return r;const n=pe(e,t.right);if(H(n))return n;throw new h("LogicExpressionOrAnd",t)}default:throw t.operator,new h("LogicExpressionOrAnd",t)}throw new h("LogicalExpressionOnlyBoolean",t)}catch(r){throw r}}function Ze(e,t){if(R(e))throw new h("NoFunctionInTemplateLiteral",t);return e}function qe(e,t){let r="",n=0;for(const o of t.quasis)if(r+=o.value?o.value.cooked:"",!1===o.tail){r+=t.expressions[n]?E(Ze(pe(e,t.expressions[n]),t)):"",n++}return r}function We(e,t){return se(e,t)}function Pe(e,t){return Ve(e,"Identifier"===t.callee.type?se(e,t.callee,"FunctionNotFound"):pe(e,t.callee),t)}function Ve(e,t,r){if(R(t))return t.call(e,r);throw new h("CallNonFunction",r)}function Te(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;I(null===r?[]:r,3,3,t);const n=pe(e,r[0]);if(!1===H(n))throw new h("BooleanConditionRequired",t);return pe(e,!0===n?r[1]:r[2])}catch(r){throw r}}function Ke(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;I(null===r?[]:r,2,3,t);const n=pe(e,r[0]);if(3===r.length){const t=pe(e,r[1]),o=a(n,t);return null!=o&&""!==o?o:pe(e,r[2])}return null===n||""===n||void 0===n?pe(e,r[1]):n}catch(r){throw r}}function Ye(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;if(r.length<2)throw new h("WrongNumberOfParameters",t);if(2===r.length)return pe(e,r[1]);{if((r.length-1)%2==0)throw new h("WrongNumberOfParameters",t);const n=pe(e,r[0]);return $e(e,t,1,n)}}catch(r){throw r}}function $e(e,t,r,n){try{const o=t.arguments,s=pe(e,o[r]);if(C(s,n))return pe(e,o[r+1]);{const s=o.length-r;return 1===s?pe(e,o[r]):2===s?null:3===s?pe(e,o[r+2]):$e(e,t,r+2,n)}}catch(o){throw o}}function He(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;if(r.length<3)throw new h("WrongNumberOfParameters",t);if(r.length%2==0)throw new h("WrongNumberOfParameters",t);const n=pe(e,r[0]);if(!1===H(n))throw new h("BooleanConditionRequired",r[0]);return Je(e,t,0,n)}catch(r){throw r}}function Je(e,t,r,n){try{const o=t.arguments;if(!0===n)return pe(e,o[r+1]);if(3===o.length-r)return pe(e,o[r+2]);{const n=pe(e,o[r+2]);if(!1===H(n))throw new h("BooleanConditionRequired",o[r+2]);return Je(e,t,r+2,n)}}catch(o){throw o}}function Qe(){const e=Object.create(null);L(e,fe),V(e,fe),_(e,fe,We),W(e,fe),Z(e,fe),P(e,fe),q(e,fe),T(e,fe),e.iif=Te,e.defaultvalue=Ke,e.decode=Ye,e.when=He;const t=function(){this.textformatting={value:p.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.nan=Object.freeze({value:Number.NaN}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[r,n]of Object.entries(e))t.prototype[r]=Object.freeze({value:new m(n)});return t}const Xe=Qe();function et(e){const t={mode:"sync",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:fe,evaluateIdentifier:We};for(let r=0;r<e.length;r++)e[r].registerFunctions(t);for(const[r,n]of Object.entries(t.functions))Xe.prototype[r]=Object.freeze({value:new m(n)});for(let r=0;r<t.signatures.length;r++)z(t.signatures[r],"sync")}function tt(e){console.log(e)}function rt(r,s){const i=new Set(Object.keys(s?.vars||{}).map(t=>e(t))),a=new Set(Object.keys(s?.customfunctions||{}).map(t=>e(t))),{globals:l,exports:c}=o(r),u=new Set(l.keys());return e=>{const o=e.spatialReference??Y.WebMercator;let s=null;r.usesModules&&(s=new n(new Map,r.loadedModules));const l=new Xe;for(const t of a)null!=e.customfunctions&&t in e.customfunctions?l[t]={value:new m(e.customfunctions[t])}:l[t]=te;for(const t of i){if(null==e.vars||!(t in e.vars)){t in l||(l[t]=te);continue}const r=e.vars[t]??null;$(r)?l[t]={value:w.createFromGraphic(r,e.timeZone??null)}:l[t]={value:r}}for(const t of u)t in l||(l[t]=te);const f=ke({lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:s,exports:c,localScope:null,globalScope:l},r);if(f instanceof v||f instanceof x){const e=f.value;if(S(e))return null;if(R(e))throw new h("IllegalResult",null);return e}if(S(f))return null;if(f===F)throw new h("IllegalResult",null);if(f===k)throw new h("IllegalResult",null);throw new h("NeverReach",null)}}function nt(e,t){return rt(e,t)(t)}et([D]);export{nt as executeScript,et as extend,rt as prepareScript};
|
package/arcade/containerUtils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"./Dictionary.js";import{ArcadeExecutionError as n}from"./executionError.js";import t from"./ImmutablePathArray.js";import a from"./ImmutablePointArray.js";import{
|
|
2
|
+
import e from"./Dictionary.js";import{ArcadeExecutionError as n}from"./executionError.js";import t from"./ImmutableArray.js";import r from"./ImmutablePathArray.js";import a from"./ImmutablePointArray.js";import{P as l,g as s,y as c,f as i,G as u}from"../chunks/languageUtils.js";import o from"../core/Accessor.js";import{isArray as f,isString as h,isNumber as m}from"../support/guards.js";const p={point:["hasZ","hasM","spatialReference","type","x","y","z","m"],multipoint:["hasZ","hasM","spatialReference","type","points"],polyline:["hasZ","hasM","spatialReference","type","paths"],polygon:["hasZ","hasM","spatialReference","type","rings"],extent:["hasZ","hasM","spatialReference","type","xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]};function y(e){return p[e.type]}function w(e,t,r){const a=b(e,t);if(a===d)throw new n("InvalidMemberAccessKey",r);return a}const d=Symbol("keyNotFound");let g=0;function b(n,t){switch(t=t.toLowerCase()){case"hasz":return n.hasZ??!1;case"hasm":return n.hasM??!1;case"spatialreference":{let t=n.spatialReference._arcadeCacheId;null!=t||o.isFrozen(n.spatialReference)||(g++,n.spatialReference._arcadeCacheId=g,t=g);const r=new e({__proto__:null,wkt:n.spatialReference.wkt,wkid:n.spatialReference.wkid});return null!=t&&(r._arcadeCacheId="SPREF"+t.toString()),r}}switch(n.type){case"extent":switch(t){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":return n[t]??null;case"type":return"Extent"}break;case"polygon":switch(t){case"rings":{let e=n.cache._arcadeCacheId;return null==e&&(g++,e=g,n.cache._arcadeCacheId=e),new r(n.rings,n.spatialReference,!0===n.hasZ,!0===n.hasM,e)}case"type":return"Polygon"}break;case"point":switch(t){case"x":case"y":case"z":case"m":return n[t]??null;case"type":return"Point"}break;case"polyline":switch(t){case"paths":{let e=n.cache._arcadeCacheId;return null==e&&(g++,e=g,n.cache._arcadeCacheId=e),new r(n.paths,n.spatialReference,!0===n.hasZ,!0===n.hasM,e)}case"type":return"Polyline"}break;case"multipoint":switch(t){case"points":{let e=n.cache._arcadeCacheId;return null==e&&(g++,e=g,n.cache._arcadeCacheId=e),new a(n.points,n.spatialReference,!0===n.hasZ,!0===n.hasM,e,1)}case"type":return"Multipoint"}}return d}function I(e,n){let t,r=e;if(null==r)return null;if(f(n))t=n;else if(s(n))t=n.toArray();else{if(null==n)return null;t=[n]}for(const a of t)if(r=M(r,a),null==r)return null;return r}function x(e){return!!l(e)||(f(e)?0===e.length:s(e)?0===e.length():!!c(e)&&e.isEmpty())}function M(n,t){if(null==n)return null;if(n instanceof e||c(n))return h(t)&&n.hasField(t)?n.field(t):null;if(i(n)){if(!h(t))return null;const e=b(n,t);return e===d?null:e}return f(n)||h(n)?m(t)&&Number.isInteger(t)?(t<0&&(t=n.length+t),t>=n.length||t<0?null:n[t]):null:s(n)?m(t)&&Number.isInteger(t)?(t<0&&(t=n.length()+t),t>=n.length()||t<0?null:n.get(t)):null:u(n)&&h(t)&&n.hasGlobal(t)?n.global(t):null}function A(t,r){if(null==t)throw new n("MemberOfNull",null);if(t instanceof e||c(t)){if(h(r))return t.field(r);throw new n("InvalidMemberAccessKey",null)}if(i(t)){if(h(r))return w(t,r,null);throw new n("InvalidMemberAccessKey",null)}if(f(t)||h(t)){if(m(r)&&Number.isInteger(r)){if(r<0&&(r=t.length+r),r>=t.length||r<0)throw new n("OutOfBounds",null);return t[r]}throw new n("InvalidMemberAccessKey",null)}if(s(t)){if(m(r)&&Number.isInteger(r)){if(r<0&&(r=t.length()+r),r>=t.length()||r<0)throw new n("OutOfBounds",null);return t.get(r)}throw new n("InvalidMemberAccessKey",null)}if(u(t)){if(h(r))return t.global(r);throw new n("InvalidMemberAccessKey",null)}throw new n("InvalidMemberAccessKey",null)}function R(e){return j(e,!0)}function _(e){return j(e,!1)}function j(n,r){if(null==n)return null;if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)return n;if(Array.isArray(n)){const e=n.map(e=>j(e,r));return r?new t(e):e}if("object"==typeof n){const t=Object.create(null);for(const e of Object.entries(n))void 0!==e[1]&&(t[e[0]]=j(e[1],r));const a=new e(t);return a.immutable=r,a}throw new Error(`Unsupported json value: ${n}`)}export{R as convertJsonValueToImmutableArcadeValue,_ as convertJsonValueToMutableArcadeValue,y as getGeometryKeys,w as getGeometryMember,A as getMember,I as getNestedOptionalValue,x as isEmpty,M as tryGetMember};
|
package/arcade/debug.js
CHANGED
|
@@ -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{getGeometryKeys as a,getGeometryMember as t}from"./containerUtils.js";import
|
|
2
|
+
import{neverAbortedSignal as e}from"./arcadeEnvironment.js";import{getGeometryKeys as a,getGeometryMember as t,convertJsonValueToImmutableArcadeValue as n}from"./containerUtils.js";import{ArcadeExecutionError as r}from"./executionError.js";import{q as i,e as c,n as o,o as p,i as u,g as l,l as s,C as m,D as y,f as d,h as f,E as T,F as g,k as v,j as h,m as w,G as F}from"../chunks/languageUtils.js";import{getLocale as b}from"../intl/locale.js";import{isNumber as j,isString as x,isBoolean as S,isArray as A}from"../support/guards.js";const Z=Object.freeze({type:"primitive",arcadeType:"",value:null}),k=Object.freeze({type:"minimal",arcadeType:"Unrecognized Type"}),q=Object.freeze({type:"minimal",arcadeType:"KnowledgeGraph"}),z=Object.freeze({type:"minimal",arcadeType:"Module"});function D(e){return{type:"simple",arcadeType:"Date",render:()=>e.toFormat(e.isUnknownTimeZone?"FF":"FF ZZZZZ",{locale:b()})}}function M(e){return{type:"simple",arcadeType:"Time",render:()=>e.toString()}}function O(e){return{type:"simple",arcadeType:"DateOnly",render:()=>e.toString()}}function N(e,a){return{type:"sequence-container",arcadeType:"Array",mutable:!0,length:e.length,expand:()=>e.map(e=>V(e,a))}}function U(e,a){return{type:"sequence-container",arcadeType:"Array",mutable:!1,length:e.length(),expand:()=>e.toArray().map(e=>V(e,a))}}function B(e,a,t){return{type:"associative-container",arcadeType:a,mutable:"Dictionary"===a?!e.immutable:void 0,expand(){const a=e.values().map(e=>V(e,t));return new Map(e.keys().map((e,t)=>[e,a[t]]))}}}function E(e,n){return{type:"associative-container",arcadeType:t(e,"type",null),expand(){const r=a(e);return new Map(r.map(a=>[a,V(t(e,a,null),n)]))}}}function G(e,a){return{type:"associative-container",arcadeType:"Feature",expand(){const t=e.keys(),n=new Map(t.map(t=>[t,V(e.field(t),a)])),r=e.geometry();return null!=r&&n.set("Geometry()",E(r,a)),n}}}function C(e,a,t){return{type:"associative-container",arcadeType:a,expand:()=>new Map(e.keys().map(a=>[a,V(e.field(a),t)]))}}function P(a,t){return{type:"feature-set",arcadeType:"FeatureSet",async schema(){await a.load();return V(n(a.schema()),t)},querySample:async n=>({fields:(await a.load()).fields.map(e=>e.name),features:(await a.iterator(n??e).nextBatchAsArcadeFeatures(100,t.defaultTimeZone)??[]).map(e=>G(e,t))})}}function I(e,a,t){let n;async function i(){if(null==n){const i=await e.featureSetById(t,!0,["*"]);if(null==i)throw new r("NeverReach",null);n=P(i,a)}return n}return{type:"feature-set",arcadeType:"FeatureSet",schema:async()=>(await i()).schema(),querySample:async e=>(await i()).querySample(e)}}function K(e,a){return{type:"feature-set-collection",arcadeType:"FeatureSetCollection",load:async()=>(await e.listAll()).map(({id:t,name:n})=>({id:t,name:n,featureSet:I(e,a,t)}))}}function R(e){return null!=e.debugName?`ƒ ${e.debugName}(...)`:"ƒ <anonymous>(...)"}function V(e,a){return null==e||i(e)?Z:j(e)?{type:"primitive",arcadeType:"Number",value:e}:x(e)?{type:"primitive",arcadeType:"String",value:e}:S(e)?{type:"primitive",arcadeType:"Boolean",value:e}:c(e)?D(e):o(e)?M(e):p(e)?O(e):u(e)?{type:"simple",arcadeType:"Function",render:(a.renderFunction??R).bind(null,e)}:A(e)?N(e,a):l(e)?U(e,a):s(e)?B(e,"Dictionary",a):m(e)?B(e,"Portal",a):y(e)?B(e,"Attachment",a):d(e)?E(e,a):f(e)?G(e,a):T(e)?C(e,"Pixel",a):g(e)?C(e,"Voxel",a):v(e)?P(e,a):h(e)?K(e,a):w(e)?q:F(e)?z:k}export{R as renderFunctionDebugName,V as wrapDebugValue};
|
package/arcade/deepClone.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{ArcadeModule as a}from"./ArcadeModule.js";import{e,b as r,
|
|
2
|
+
import{ArcadeModule as a}from"./ArcadeModule.js";import{e,b as r,f as s,g as o,h as t,j as l,k as n,l as c,m as d,i as m}from"../chunks/languageUtils.js";import{isArray as u}from"../support/guards.js";function i(a){p=a}let p;function f(i){return null===i?null:e(i)?i.clone():r(i)?i:s(i)?i.clone():o(i)?i.toArray().map(a=>f(a)):u(i)?i.map(a=>f(a)):t(i)?p.createFromArcadeFeature(i):l(i)||n(i)?i:c(i)||"esri.arcade.Attachment"===i?.declaredClass?i.deepClone():("esri.arcade.Portal"===i?.declaredClass||d(i)||i instanceof a||m(i),i)}export{i as configureDeepClone,f as deepClone};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a4 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import s from"./featureset/sources/FeatureLayerMemory.js";import i from"./featureset/sources/FeatureLayerParquet.js";import o from"./featureset/sources/FeatureLayerRelated.js";import u from"./featureset/support/cache.js";import{FeatureSetError as c}from"./featureset/support/errorsupport.js";import{isSupportedLayer as d,extractServiceUrl as p}from"./featureset/support/shared.js";import{isLoadable as y}from"../core/Loadable.js";import f from"../core/sql/WhereClause.js";import m from"../layers/FeatureLayer.js";import h from"../layers/Layer.js";import w from"../layers/ParquetLayer.js";import I from"../layers/support/ParquetPortalItemData.js";import L from"../portal/PortalItem.js";function _(){null===u.applicationCache&&(u.applicationCache=new u)}async function S(e,t,a){if(u.applicationCache){const a=u.applicationCache.getLayerInfo(e);if(a){const r=await a;return new m({url:e,outFields:t,sourceJSON:r})}const n=new m({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(u.applicationCache){u.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw u.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new m({url:e,outFields:t,sourceJSON:a})}const l=new m({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new m({url:e,outFields:t})}async function C(e,t,a,r,n,l=null){return F(await S(e,["*"],n),t,a,r,n,l)}function F(e,t=null,a=null,r=!0,o=null,u=null){switch(e.type){case"catalog-footprint":return F(e.parent,t,a,r,o,u);case"subtype-sublayer":{const l=F(e.parent,t,a,r,o,u);return new n({parentfeatureset:l,whereclause:f.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:l.dateFieldsTimeZoneDefaultUTC})})}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new s({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u});case"parquet":return new i({layer:e,spatialReference:t,outFields:a,includeGeometry:r});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const n={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u};return!e.url&&e.source?new s(n):new l(n)}default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function k(t){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw u.applicationCache.clearLayerInfo(t),r}}return a}async function g(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements?.[0])return e.layerDataElements[0]}throw new c("DataElementsNotFound")})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw u.applicationCache.clearLayerInfo(r),l}}return n}async function N(t,a){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"},authMode:"no-prompt"});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw u.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function T(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},l=await N(e,null);if(r.metadata=l,void 0!==l.controllerDatasetLayers?.utilityNetworkLayerId&&null!==l.controllerDatasetLayers.utilityNetworkLayerId){if(l.layers)for(const e of l.layers)r.layerNameLkp[e.id]=e.name;if(l.tables)for(const e of l.tables)r.layerNameLkp[e.id]=e.name;const s=l.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;const i=await g(e,s);if(i){r.queryelem=i,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const l=await k(e+"/"+s);if(void 0!==l.systemLayers?.associationsTableId&&null!==l.systemLayers.associationsTableId){let s=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),s=await C(e+"/"+l.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await s.load(),r.unVersion>=4&&(s=new n({parentfeatureset:s,whereclause:f.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})}),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function A(e,t,a,r=null,n=null,l=!0,s=null,i=null){let u=e.serviceUrl();if(!u)return null;u=u.endsWith("/")?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString();const c=await C(u,r,n,l,s,i);return new o({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=F(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async listAll(){y(this._map)&&!this._map.loaded&&await this._map.load();const e=this._map.allLayers.toArray().filter(e=>d(e)).map(e=>({id:e.id,name:e.title})),t=this._map.allTables.toArray().filter(e=>d(e)).map(e=>({id:e.id,name:e.title}));return e.concat(t)}async featureSetByName(e,t=!0,a=null){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>d(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>d(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>d(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>d(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class E extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=F(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await N(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new E(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async listAll(){const e=await this._loadMetaData();return e.layers.concat(e.tables)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function D(e,t,a=null,r=null){return new O(e,t,a,r)}function M(e,t,a=null,r=null){return new E(e,t,a,r)}function b(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof h&&d(e)){switch(t){case"datasource":return F(e,s,"outFields"in e?e.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return F(e,s,"outFields"in e?e.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return F(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return F(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function j(e,t,a,r,n,l,s,i=null){if(u.applicationCache){const o=u.applicationCache.getLayerInfo(e+":"+l.url);if(o)return v(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await v(await o,t,a,r,n,s,i)}const o=new L({id:e,portal:l}).load();u.applicationCache?u.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await v(await o,t,a,r,n,s,i)}catch(c){throw u.applicationCache&&u.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),c}}const q=new Set(["Apache Parquet","Parquet layer","Parquet Layer","Parquet feature layer","Parquet Feature Layer"]);async function v(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await S(p(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=q.has(e.type)?Promise.resolve(new w({data:new I({portalItem:e})})):h.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=q.has(e.type)?new w({data:new I({portalItem:e})}):await h.fromPortalItem(e)}return F(i,a,r,n,l,s)}export{T as constructAssociationMetaDataFeatureSetFromUrl,F as constructFeatureSet,j as constructFeatureSetFromPortalItem,A as constructFeatureSetFromRelationship,C as constructFeatureSetFromUrl,b as convertToFeatureSet,D as createFeatureSetCollectionFromMap,M as createFeatureSetCollectionFromService,_ as initialiseMetaDataCache};
|
|
2
|
+
import e from"../request.js";import t from"./featureSetCollection.js";import{k as a,a4 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import s from"./featureset/sources/FeatureLayerMemory.js";import i from"./featureset/sources/FeatureLayerParquet.js";import o from"./featureset/sources/FeatureLayerRelated.js";import u from"./featureset/support/cache.js";import{FeatureSetError as c}from"./featureset/support/errorsupport.js";import{isSupportedLayer as d,extractServiceUrl as p}from"./featureset/support/shared.js";import{isLoadable as y}from"../core/Loadable.js";import f from"../core/sql/WhereClause.js";import m from"../layers/FeatureLayer.js";import h from"../layers/Layer.js";import w from"../layers/ParquetLayer.js";import I from"../layers/support/ParquetPortalItemData.js";import L from"../portal/PortalItem.js";function _(){null===u.applicationCache&&(u.applicationCache=new u)}async function S(e,t,a){if(u.applicationCache){const a=u.applicationCache.getLayerInfo(e);if(a){const r=await a;return new m({url:e,outFields:t,sourceJSON:r})}const n=new m({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(u.applicationCache){u.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw u.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new m({url:e,outFields:t,sourceJSON:a})}const l=new m({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new m({url:e,outFields:t})}async function C(e,t,a,r,n,l=null){return k(await S(e,["*"],n),t,a,r,n,l)}function k(e,t=null,a=null,r=!0,o=null,u=null){switch(e.type){case"catalog-footprint":return k(e.parent,t,a,r,o,u);case"subtype-sublayer":{const l=k(e.parent,t,a,r,o,u);return new n({parentfeatureset:l,whereclause:f.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:l.dateFieldsTimeZoneDefaultUTC})})}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new s({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u});case"parquet":return new i({layer:e,spatialReference:t,outFields:a,includeGeometry:r});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const n={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u};return!e.url&&e.source?new s(n):new l(n)}default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function F(t){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw u.applicationCache.clearLayerInfo(t),r}}return a}async function g(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements?.[0])return e.layerDataElements[0]}throw new c("DataElementsNotFound")})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw u.applicationCache.clearLayerInfo(r),l}}return n}async function N(t,a){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"},authMode:"no-prompt"});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw u.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function T(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},l=await N(e,null);if(r.metadata=l,void 0!==l.controllerDatasetLayers?.utilityNetworkLayerId&&null!==l.controllerDatasetLayers.utilityNetworkLayerId){if(l.layers)for(const e of l.layers)r.layerNameLkp[e.id]=e.name;if(l.tables)for(const e of l.tables)r.layerNameLkp[e.id]=e.name;const s=l.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;const i=await g(e,s);if(i){r.queryelem=i,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const l=await F(e+"/"+s);if(void 0!==l.systemLayers?.associationsTableId&&null!==l.systemLayers.associationsTableId){let s=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),s=await C(e+"/"+l.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await s.load(),r.unVersion>=4&&(s=new n({parentfeatureset:s,whereclause:f.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})}),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function A(e,t,a,r=null,n=null,l=!0,s=null,i=null){let u=e.serviceUrl();if(!u)return null;u=u.endsWith("/")?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString();const c=await C(u,r,n,l,s,i);return new o({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=k(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async listAll(){y(this._map)&&!this._map.loaded&&await this._map.load();const e=this._map.allLayers.toArray().filter(e=>d(e)).map(e=>({id:e.id,name:e.title})),t=this._map.allTables.toArray().filter(e=>d(e)).map(e=>({id:e.id,name:e.title}));return e.concat(t)}async featureSetByName(e,t=!0,a=null){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>d(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>d(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>d(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>d(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class E extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=k(e,this._overrideSpatialReference,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await N(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new E(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async listAll(){const e=await this._loadMetaData();return e.layers.concat(e.tables)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function D(e,t,a=null,r=null){return new O(e,t,a,r)}function M(e,t,a=null,r=null){return new E(e,t,a,r)}function b(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof h&&d(e)){switch(t){case"datasource":return k(e,s,"outFields"in e?e.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return k(e,s,"outFields"in e?e.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return k(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return k(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function j(e,t,a,r,n,l,s,i=null){if(u.applicationCache){const o=u.applicationCache.getLayerInfo(e+":"+l.url);if(o)return v(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await v(await o,t,a,r,n,s,i)}const o=new L({id:e,portal:l}).load();u.applicationCache?u.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await v(await o,t,a,r,n,s,i)}catch(c){throw u.applicationCache&&u.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),c}}const q=new Set(["Apache Parquet","Parquet layer","Parquet Layer","Parquet feature layer","Parquet Feature Layer"]);async function v(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await S(p(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=q.has(e.type)?Promise.resolve(new w({data:new I({portalItem:e})})):h.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=q.has(e.type)?new w({data:new I({portalItem:e})}):await h.fromPortalItem(e)}return k(i,a,r,n,l,s)}export{T as constructAssociationMetaDataFeatureSetFromUrl,k as constructFeatureSet,j as constructFeatureSetFromPortalItem,A as constructFeatureSetFromRelationship,C as constructFeatureSetFromUrl,b as convertToFeatureSet,D as createFeatureSetCollectionFromMap,M as createFeatureSetCollectionFromService,_ as initialiseMetaDataCache};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{id as e}from"../../../kernel.js";import t from"../../../request.js";import{neverAbortedSignal as r}from"../../arcadeEnvironment.js";import a from"../../Attachment.js";import i from"../../Dictionary.js";import{throwIfCancelled as s,FeatureSetError as l}from"../support/errorsupport.js";import{RootFeatureSet as n,emptyFeaturesResult as o,getSpatialFilterRelationRestQueryParams as u,assignSpatialReferenceOnFeatures as c}from"../support/FeatureSet.js";import{defaultMaxRecords as d,stableStringify as h,extractServiceUrl as y}from"../support/shared.js";import{toWhereClause as p,isSingleField as _}from"../support/sqlUtils.js";import{decodeStatType as f}from"../support/stats.js";import{splitIntoChunks as m,sliceEquals as F}from"../../../core/arrayUtils.js";import{createMD5Hash as w,outputTypes as g}from"../../../core/MD5.js";import{sqlAnd as S}from"../../../core/sql.js";import b from"../../../core/sql/WhereClause.js";import I from"../../../layers/FeatureLayer.js";import{toQueryStringParameters as R}from"../../../rest/query/operations/queryRelatedRecords.js";import q from"../../../rest/support/AttachmentQuery.js";import T from"../../../rest/support/Query.js";import Q from"../../../rest/support/StatisticDefinition.js";function x(e){if(0===e.length)throw new l("NeverReach");const t=[];for(let a=0;a<e.length;a++){const r=e[a],i=[`"${r.name.replaceAll('"','""')}" ${r.asc?">":"<"} @last_${a}`];for(let t=0;t<a;t++){const r=e[t];i.push(`"${r.name.replaceAll('"','""')}" = @last_${t}`)}t.push(i.join(" AND "))}const r=t.join(" OR ");return b.create(r)}function v(e,t){null==e.clause&&(e.clause=x(e.keyFields));for(let r=0;r<e.keyFields.length;r++){const a=e.keyFields[r].name;e.clause.parameters[`last_${r}`]=t.attributes[a]}}class j extends n{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this._requestStandardised=!1,this._useDefinitionExpression=!0,this._recentlyUsedQueries=null,this._featureSetQueryInterceptor=null,this._featureSetInfo=null,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry),e.lrucache&&(this._recentlyUsedQueries=e.lrucache),e.interceptor&&(this._featureSetQueryInterceptor=e.interceptor)}_maxQueryRate(){return d}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+h(e.toJSON());return w(t,g.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(this.spatialReference??=this._layer.spatialReference,this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer.capabilities?.data?.supportsZ,this.hasM=!0===this._layer.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=new Set(this._overrideFields.map(e=>e.toLowerCase()));this.fields=this.fields.filter(({type:t,name:r})=>"oid"===t||e.has(r.toLowerCase())),this._overrideFields=this.fields.map(({name:e})=>e)}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=1,null!=e&&e>=10.61&&(this._databaseType=0)):null!=e&&(e>=10.5&&(this._databaseType=1,this._requestStandardised=!0),e>=10.61&&(this._databaseType=0))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new T;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch{return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}async _queryAll(){return(await this.query({abortSignal:r})).features}async query(e){return await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter?o:this._canUsePagination()?this._queryUsingPaging(e):this._queryUsingIdSetTraversal(e)}async _queryUsingPaging(e){const t=this._layer.capabilities.query;let r=!0,a=null,i=!1;null!=e.orderBy&&(t.supportsOrderBy?(a=e.orderBy.toOrderByFields(),i=!0):r=!1);const s=await this.databaseType(),l=null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,s),n=!0!==this._removeGeometry,o=this._overrideFields??this._fieldsIncludingObjectId(["*"]),c=o.includes("*")?this._layer.fields.length:o.length,d=(this.isTable()||!n?t.standardMaxRecordCountNoGeometry:void 0)??t.standardMaxRecordCount??t.maxRecordCount??this._maxQueryRate(),h=c<=50?1:c<=100?.5:c<=200?.25:.125,y=Math.max(Math.ceil(d*h),t.maxRecordCount??this._maxQueryRate()),_=this._createQuery();if(_.where=S(_.where,l),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);_.spatialRelationship=t.spatialRelationship,_.relationParameter=t.relationParameter,_.geometry=e.spatialFilter.geometry}return _.orderByFields=a,_.outFields=o,_.returnGeometry=n,_.outSpatialReference=this.spatialReference,_.resultType="standard",{ordered:i,filterApplied:!0,spatialFilterApplied:!0,features:this._queryPaginated(_,y,r?e.limit:null,e.abortSignal)}}async*_queryPaginated(e,t,r,a){let i;e.num=null!=r?Math.min(r,t):t,e.start=0;do{s(a),i=await this.executeQuery(e,"execute"),yield*m(i.features,this._maxQueryRate()),e.start+=i.features.length,e.num=null!=r?Math.min(r-e.start,t):t}while(e.num>0&&!0===i.exceededTransferLimit)}async _queryUsingIdSetTraversal(e){let t=!0,r=null,a=!1;null!=e.orderBy&&(this._layer.capabilities?.query?.supportsOrderBy?(r=e.orderBy.toOrderByFields(),a=!0):t=!1);const i=await this.databaseType(),l=null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,i),n=this._createQuery();if(n.where=S(n.where,l),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);n.spatialRelationship=t.spatialRelationship,n.relationParameter=t.relationParameter,n.geometry=e.spatialFilter.geometry}n.orderByFields=r,n.outSpatialReference=this.spatialReference,n.num=t?e.limit:null;const c=await this.executeQuery(n,"executeForIds");if(s(e.abortSignal),null==c||c.length<=0)return o;let d=this._maxQueryRate();const h=this._layer.capabilities?.query.maxRecordCount;null!=h&&h<d&&(d=h);const y=this._createQuery();return n.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),n.returnGeometry=!0!==this._removeGeometry,n.outSpatialReference=this.spatialReference,{ordered:a,filterApplied:!0,spatialFilterApplied:!0,features:this._traverseIdSet(y,c,d,e.abortSignal)}}async*_traverseIdSet(e,t,r,a){for(let i=0;i<t.length;i+=r){e.objectIds=t.slice(i,i+r),s(a);const l=await this.executeQuery(e,"execute");yield l.features}}async queryStat(e){await this._ensureLoaded();const t=this._layer.capabilities?.query,r=!!t?.supportsSqlExpression,a=!!t?.supportsStatistics,i=!!t?.supportsDistinct,s=f(e.stat);if("count"===s)return i?this._queryCount(e):{calculated:!1};const n=e.field;if(null==n)return{calculated:!1};if(!1===a||!1===_(n)&&!1===r||!1===n.isStandardized)return null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(e.stat,n,e.limit??d,e.abortSignal);if("distinct"===s)return!1===i?null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(s,n,e.limit??d,e.abortSignal):{calculated:!1};const o=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:null};const c=this._createQuery();if(c.where=S(c.where,null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,o)),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);c.spatialRelationship=t.spatialRelationship,c.relationParameter=t.relationParameter,c.geometry=e.spatialFilter.geometry}const h=new Q;h.statisticType=s,h.onStatisticField=p(n,o),h.outStatisticFieldName="ARCADE_STAT_RESULT",c.returnGeometry=!1;let y="ARCADE_STAT_RESULT";c.outStatistics=[h];const m=await this.executeQuery(c,"execute");if(!m.hasOwnProperty("features")||0===m.features.length)throw new l("InvalidStatResponse");let F=!1;const w=m.fields??[];for(const l of w)if("ARCADE_STAT_RESULT"===l.name.toUpperCase()){y=l.name,"esriFieldTypeDate"===l.type&&(F=!0);break}const g=m.features[0].attributes[y];return{calculated:!0,result:F&&null!=g?new Date(g):g}}async _queryCount(e){const t=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:0};const r=this._createQuery();if(r.where=S(r.where,null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,t)),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);r.spatialRelationship=t.spatialRelationship,r.relationParameter=t.relationParameter,r.geometry=e.spatialFilter.geometry}r.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(r,"executeForCount")}}async canQueryAggregate(e){await this._ensureLoaded();let t=!1;const r=this._layer.capabilities?.query,a=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(t=!0),t)for(const i of e.statistics)(!1===i.workingexpr?.isStandardized||!1===_(i.workingexpr)&&!1===a)&&(t=!1);return t}async queryAggregate(e){if(await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter)return o;const t=await this.databaseType(),r=e.groupBy,a=e.orderBy;let i=null;if(!this._layer.capabilities.query.supportsPaginationOnAggregatedQueries){const e=this.getFieldsIndex();i={keyFields:r.map((t,r)=>({name:e.normalizeFieldName(t)??t,asc:null==a||1===a._directions[r]}))}}let s=null,l=!1;null!=a&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(null==i||F(r,0,r.length,a._fields,0,Math.min(a._fields.length,r.length),(e,t)=>e.toLowerCase()===t.toLowerCase()))&&(s=a.toOrderByFields(),l=!0),null==s&&(s=r.slice());const n=e.statistics.map(e=>new Q({onStatisticField:null!==e.workingexpr?p(e.workingexpr,t):"",outStatisticFieldName:e.field,statisticType:e.toStatisticsName()}));let c=this._maxQueryRate();const d=this._layer.capabilities?.query.maxRecordCount;null!=d&&d<c&&(c=d);const h=null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,t),y=this._createQuery();if(y.where=S(y.where,h),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);y.spatialRelationship=t.spatialRelationship,y.relationParameter=t.relationParameter,y.geometry=e.spatialFilter.geometry}return y.orderByFields=s,y.outFields=["*"],y.outStatistics=n,y.groupByFieldsForStatistics=r,y.returnGeometry=!1,null==i?{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryPaginated(y,c,null,e.abortSignal)}:{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryKeysetPaginated(y,i,e.abortSignal)}}async*_queryKeysetPaginated(e,t,r){const a=e.where;for(;;){if(null!=t.clause){if(!this._layer.capabilities.query.supportsOrderBy)throw new l("NotImplemented");e.where=S(a,p(t.clause,await this.databaseType()))}const i=await this.executeQuery(e,"execute");if(s(r),!i.hasOwnProperty("features"))throw new l("InvalidStatResponse");if(yield i.features,0===i.features.length||!0!==i.exceededTransferLimit)break;v(t,i.features.at(-1))}}_createQuery(){const e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,this.datesInUnknownTimezone&&(e.timeReferenceUnknownClient=!0),this._requestStandardised&&(e.sqlFormat="standard"),this._useDefinitionExpression?"subtype-group"===this._layer.type&&(e.where=this._layer.definitionExpression):e.where=null,e}executeQuery(e,t){const r="execute"===t?async e=>{const t=await this._layer.source.queryFeaturesJSON(e);return c(t.features,t.spatialReference??this.spatialReference.toJSON()),t}:"executeForCount"===t?this._layer.queryFeatureCount.bind(this._layer):this._layer.queryObjectIds.bind(this._layer);let a=null;if(this._recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);a=this._recentlyUsedQueries.getFromCache(t),null===a&&(a=r(e),this._recentlyUsedQueries.addToCache(t,a),a=a.catch(e=>{throw this._recentlyUsedQueries?.removeFromCache(t),e}))}return this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===a&&(a=r(e)),a}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let r=!1;for(const a of t)if(a.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return r||t.push(this.objectIdField),t}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}static create(e,t,r,a,i){const s=new I({url:e,outFields:null===t?["*"]:t});return new j({layer:s,spatialReference:r,lrucache:a,interceptor:i})}relationshipMetadata(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return y(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,s,l){function n(e){const t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}const o=this._layer;if(!n(o))return[];const u=new q({objectIds:[e],returnMetadata:l});(t&&t>0||r&&r>0)&&(u.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(u.attachmentTypes=s),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:o,query:u,method:"attachments"});const c=await o.queryAttachments(u);return c?.[e]?c[e].map(t=>{const r=`${this._layer.parsedUrl.path}/${e}/attachments/${t.id}`;let s=null;return l&&t.exifInfo&&(s=i.convertJsonToArcade(t.exifInfo,"system",!0)),new a(t.id,t.name,t.contentType,t.size,r,s,t.keywords??null)}):[]}async queryRelatedFeatures(e){const r=R(e);r.f="json",this._requestStandardised&&(r.sqlFormat="standard"),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const a=await t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:r});if(a.data){const e={},t=a.data;if(t?.relatedRecordGroups){const r=t.spatialReference,a=!0===t.exceededTransferLimit;for(const i of t.relatedRecordGroups)c(i.relatedRecords,r),e[i.objectId]={features:i.relatedRecords,exceededTransferLimit:a}}return e}throw new l("InvalidRequest")}async getFeatureByObjectId(e,t){const r=this._createQuery();r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=S(r.where,this.objectIdField+"="+e.toString()),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"});const a=await this._layer.source.queryFeaturesJSON(r);return 1===a.features.length?(c(a.features,a.spatialReference??this.spatialReference.toJSON()),a.features[0]):null}async getIdentityUser(){await this.load();const t=e?.findCredential(this._layer.url);return t?t.userId:null}async getOwningSystemUrl(){await this.load();const r=e?.findServerInfo(this._layer.url);if(r)return r.owningSystemUrl??"";let a=this._layer.url;const i=a.toLowerCase().indexOf("/rest/services");if(a=i>-1?a.slice(0,i):a,a){a+="/rest/info";try{const e=await t(a,{query:{f:"json"}});let r="";return e.data?.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch{return""}}return""}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this._recentlyUsedQueries??void 0,interceptor:this._featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this._featureSetInfo)return this._featureSetInfo;let e=null,r="serviceItemId"in this._layer?this._layer.serviceItemId:null;const a=this._layer.parsedUrl?.path??null;if(a){const i=await t(a,{responseType:"json",query:{f:"json"}});e=i?.data?.name??null,r=i?.data?.serviceItemId??null}const i=this._layer.title&&null!==(this._layer.parent??null);return this._featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===r?null:r,serviceLayerUrl:""===a?null:a,webMapLayerId:i?this._layer.id??null:null,webMapLayerTitle:i?this._layer.title??null:null,className:null,objectClassId:null},this._featureSetInfo}}export{j as default};
|
|
2
|
+
import{id as e}from"../../../kernel.js";import t from"../../../request.js";import{neverAbortedSignal as r}from"../../arcadeEnvironment.js";import a from"../../Attachment.js";import{convertJsonValueToImmutableArcadeValue as i}from"../../containerUtils.js";import{throwIfCancelled as s,FeatureSetError as l}from"../support/errorsupport.js";import{RootFeatureSet as n,emptyFeaturesResult as o,getSpatialFilterRelationRestQueryParams as u,assignSpatialReferenceOnFeatures as c}from"../support/FeatureSet.js";import{defaultMaxRecords as d,stableStringify as h,extractServiceUrl as y}from"../support/shared.js";import{toWhereClause as p,isSingleField as _}from"../support/sqlUtils.js";import{decodeStatType as f}from"../support/stats.js";import{splitIntoChunks as m,sliceEquals as F}from"../../../core/arrayUtils.js";import{createMD5Hash as w,outputTypes as g}from"../../../core/MD5.js";import{sqlAnd as S}from"../../../core/sql.js";import b from"../../../core/sql/WhereClause.js";import I from"../../../layers/FeatureLayer.js";import{toQueryStringParameters as R}from"../../../rest/query/operations/queryRelatedRecords.js";import q from"../../../rest/support/AttachmentQuery.js";import T from"../../../rest/support/Query.js";import Q from"../../../rest/support/StatisticDefinition.js";function x(e){if(0===e.length)throw new l("NeverReach");const t=[];for(let a=0;a<e.length;a++){const r=e[a],i=[`"${r.name.replaceAll('"','""')}" ${r.asc?">":"<"} @last_${a}`];for(let t=0;t<a;t++){const r=e[t];i.push(`"${r.name.replaceAll('"','""')}" = @last_${t}`)}t.push(i.join(" AND "))}const r=t.join(" OR ");return b.create(r)}function j(e,t){null==e.clause&&(e.clause=x(e.keyFields));for(let r=0;r<e.keyFields.length;r++){const a=e.keyFields[r].name;e.clause.parameters[`last_${r}`]=t.attributes[a]}}class v extends n{constructor(e){super(),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this._requestStandardised=!1,this._useDefinitionExpression=!0,this._recentlyUsedQueries=null,this._featureSetQueryInterceptor=null,this._featureSetInfo=null,this._maxProcessing=1e3,this._layer=e.layer,e.spatialReference&&(this.spatialReference=e.spatialReference),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry),e.lrucache&&(this._recentlyUsedQueries=e.lrucache),e.interceptor&&(this._featureSetQueryInterceptor=e.interceptor)}_maxQueryRate(){return d}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+h(e.toJSON());return w(t,g.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(this.spatialReference??=this._layer.spatialReference,this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer.capabilities?.data?.supportsZ,this.hasM=!0===this._layer.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=new Set(this._overrideFields.map(e=>e.toLowerCase()));this.fields=this.fields.filter(({type:t,name:r})=>"oid"===t||e.has(r.toLowerCase())),this._overrideFields=this.fields.map(({name:e})=>e)}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=1,null!=e&&e>=10.61&&(this._databaseType=0)):null!=e&&(e>=10.5&&(this._databaseType=1,this._requestStandardised=!0),e>=10.61&&(this._databaseType=0))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new T;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch{return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}async _queryAll(){return(await this.query({abortSignal:r})).features}async query(e){return await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter?o:this._canUsePagination()?this._queryUsingPaging(e):this._queryUsingIdSetTraversal(e)}async _queryUsingPaging(e){const t=this._layer.capabilities.query;let r=!0,a=null,i=!1;null!=e.orderBy&&(t.supportsOrderBy?(a=e.orderBy.toOrderByFields(),i=!0):r=!1);const s=await this.databaseType(),l=null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,s),n=!0!==this._removeGeometry,o=this._overrideFields??this._fieldsIncludingObjectId(["*"]),c=o.includes("*")?this._layer.fields.length:o.length,d=(this.isTable()||!n?t.standardMaxRecordCountNoGeometry:void 0)??t.standardMaxRecordCount??t.maxRecordCount??this._maxQueryRate(),h=c<=50?1:c<=100?.5:c<=200?.25:.125,y=Math.max(Math.ceil(d*h),t.maxRecordCount??this._maxQueryRate()),_=this._createQuery();if(_.where=S(_.where,l),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);_.spatialRelationship=t.spatialRelationship,_.relationParameter=t.relationParameter,_.geometry=e.spatialFilter.geometry}return _.orderByFields=a,_.outFields=o,_.returnGeometry=n,_.outSpatialReference=this.spatialReference,_.resultType="standard",{ordered:i,filterApplied:!0,spatialFilterApplied:!0,features:this._queryPaginated(_,y,r?e.limit:null,e.abortSignal)}}async*_queryPaginated(e,t,r,a){let i;e.num=null!=r?Math.min(r,t):t,e.start=0;do{s(a),i=await this.executeQuery(e,"execute"),yield*m(i.features,this._maxQueryRate()),e.start+=i.features.length,e.num=null!=r?Math.min(r-e.start,t):t}while(e.num>0&&!0===i.exceededTransferLimit)}async _queryUsingIdSetTraversal(e){let t=!0,r=null,a=!1;null!=e.orderBy&&(this._layer.capabilities?.query?.supportsOrderBy?(r=e.orderBy.toOrderByFields(),a=!0):t=!1);const i=await this.databaseType(),l=null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,i),n=this._createQuery();if(n.where=S(n.where,l),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);n.spatialRelationship=t.spatialRelationship,n.relationParameter=t.relationParameter,n.geometry=e.spatialFilter.geometry}n.orderByFields=r,n.outSpatialReference=this.spatialReference,n.num=t?e.limit:null;const c=await this.executeQuery(n,"executeForIds");if(s(e.abortSignal),null==c||c.length<=0)return o;let d=this._maxQueryRate();const h=this._layer.capabilities?.query.maxRecordCount;null!=h&&h<d&&(d=h);const y=this._createQuery();return n.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),n.returnGeometry=!0!==this._removeGeometry,n.outSpatialReference=this.spatialReference,{ordered:a,filterApplied:!0,spatialFilterApplied:!0,features:this._traverseIdSet(y,c,d,e.abortSignal)}}async*_traverseIdSet(e,t,r,a){for(let i=0;i<t.length;i+=r){e.objectIds=t.slice(i,i+r),s(a);const l=await this.executeQuery(e,"execute");yield l.features}}async queryStat(e){await this._ensureLoaded();const t=this._layer.capabilities?.query,r=!!t?.supportsSqlExpression,a=!!t?.supportsStatistics,i=!!t?.supportsDistinct,s=f(e.stat);if("count"===s)return i?this._queryCount(e):{calculated:!1};const n=e.field;if(null==n)return{calculated:!1};if(!1===a||!1===_(n)&&!1===r||!1===n.isStandardized)return null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(e.stat,n,e.limit??d,e.abortSignal);if("distinct"===s)return!1===i?null!=e.spatialFilter||null!=e.where?{calculated:!1}:this._manualStat(s,n,e.limit??d,e.abortSignal):{calculated:!1};const o=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:null};const c=this._createQuery();if(c.where=S(c.where,null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,o)),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);c.spatialRelationship=t.spatialRelationship,c.relationParameter=t.relationParameter,c.geometry=e.spatialFilter.geometry}const h=new Q;h.statisticType=s,h.onStatisticField=p(n,o),h.outStatisticFieldName="ARCADE_STAT_RESULT",c.returnGeometry=!1;let y="ARCADE_STAT_RESULT";c.outStatistics=[h];const m=await this.executeQuery(c,"execute");if(!m.hasOwnProperty("features")||0===m.features.length)throw new l("InvalidStatResponse");let F=!1;const w=m.fields??[];for(const l of w)if("ARCADE_STAT_RESULT"===l.name.toUpperCase()){y=l.name,"esriFieldTypeDate"===l.type&&(F=!0);break}const g=m.features[0].attributes[y];return{calculated:!0,result:F&&null!=g?new Date(g):g}}async _queryCount(e){const t=await this.databaseType();if(this.isTable()&&null!=e.spatialFilter)return{calculated:!0,result:0};const r=this._createQuery();if(r.where=S(r.where,null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,t)),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);r.spatialRelationship=t.spatialRelationship,r.relationParameter=t.relationParameter,r.geometry=e.spatialFilter.geometry}r.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(r,"executeForCount")}}async canQueryAggregate(e){await this._ensureLoaded();let t=!1;const r=this._layer.capabilities?.query,a=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(t=!0),t)for(const i of e.statistics)(!1===i.workingexpr?.isStandardized||!1===_(i.workingexpr)&&!1===a)&&(t=!1);return t}async queryAggregate(e){if(await this._ensureLoaded(),this.isTable()&&null!=e.spatialFilter)return o;const t=await this.databaseType(),r=e.groupBy,a=e.orderBy;let i=null;if(!this._layer.capabilities.query.supportsPaginationOnAggregatedQueries){const e=this.getFieldsIndex();i={keyFields:r.map((t,r)=>({name:e.normalizeFieldName(t)??t,asc:null==a||1===a._directions[r]}))}}let s=null,l=!1;null!=a&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(null==i||F(r,0,r.length,a._fields,0,Math.min(a._fields.length,r.length),(e,t)=>e.toLowerCase()===t.toLowerCase()))&&(s=a.toOrderByFields(),l=!0),null==s&&(s=r.slice());const n=e.statistics.map(e=>new Q({onStatisticField:null!==e.workingexpr?p(e.workingexpr,t):"",outStatisticFieldName:e.field,statisticType:e.toStatisticsName()}));let c=this._maxQueryRate();const d=this._layer.capabilities?.query.maxRecordCount;null!=d&&d<c&&(c=d);const h=null==e.where?null==e.spatialFilter?"1=1":"":p(e.where,t),y=this._createQuery();if(y.where=S(y.where,h),null!=e.spatialFilter){const t=u(e.spatialFilter.relation);y.spatialRelationship=t.spatialRelationship,y.relationParameter=t.relationParameter,y.geometry=e.spatialFilter.geometry}return y.orderByFields=s,y.outFields=["*"],y.outStatistics=n,y.groupByFieldsForStatistics=r,y.returnGeometry=!1,null==i?{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryPaginated(y,c,null,e.abortSignal)}:{filterApplied:!0,spatialFilterApplied:!0,ordered:l,features:this._queryKeysetPaginated(y,i,e.abortSignal)}}async*_queryKeysetPaginated(e,t,r){const a=e.where;for(;;){if(null!=t.clause){if(!this._layer.capabilities.query.supportsOrderBy)throw new l("NotImplemented");e.where=S(a,p(t.clause,await this.databaseType()))}const i=await this.executeQuery(e,"execute");if(s(r),!i.hasOwnProperty("features"))throw new l("InvalidStatResponse");if(yield i.features,0===i.features.length||!0!==i.exceededTransferLimit)break;j(t,i.features.at(-1))}}_createQuery(){const e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,this.datesInUnknownTimezone&&(e.timeReferenceUnknownClient=!0),this._requestStandardised&&(e.sqlFormat="standard"),this._useDefinitionExpression?"subtype-group"===this._layer.type&&(e.where=this._layer.definitionExpression):e.where=null,e}executeQuery(e,t){const r="execute"===t?async e=>{const t=await this._layer.source.queryFeaturesJSON(e);return c(t.features,t.spatialReference??this.spatialReference.toJSON()),t}:"executeForCount"===t?this._layer.queryFeatureCount.bind(this._layer):this._layer.queryObjectIds.bind(this._layer);let a=null;if(this._recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);a=this._recentlyUsedQueries.getFromCache(t),null===a&&(a=r(e),this._recentlyUsedQueries.addToCache(t,a),a=a.catch(e=>{throw this._recentlyUsedQueries?.removeFromCache(t),e}))}return this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===a&&(a=r(e)),a}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let r=!1;for(const a of t)if(a.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return r||t.push(this.objectIdField),t}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}static create(e,t,r,a,i){const s=new I({url:e,outFields:null===t?["*"]:t});return new v({layer:s,spatialReference:r,lrucache:a,interceptor:i})}relationshipMetadata(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return y(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,s,l){function n(e){const t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}const o=this._layer;if(!n(o))return[];const u=new q({objectIds:[e],returnMetadata:l});(t&&t>0||r&&r>0)&&(u.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(u.attachmentTypes=s),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:o,query:u,method:"attachments"});const c=await o.queryAttachments(u);return c?.[e]?c[e].map(t=>{const r=`${this._layer.parsedUrl.path}/${e}/attachments/${t.id}`;let s=null;return l&&t.exifInfo&&(s=i(t.exifInfo)),new a(t.id,t.name,t.contentType,t.size,r,s,t.keywords??null)}):[]}async queryRelatedFeatures(e){const r=R(e);r.f="json",this._requestStandardised&&(r.sqlFormat="standard"),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const a=await t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:r});if(a.data){const e={},t=a.data;if(t?.relatedRecordGroups){const r=t.spatialReference,a=!0===t.exceededTransferLimit;for(const i of t.relatedRecordGroups)c(i.relatedRecords,r),e[i.objectId]={features:i.relatedRecords,exceededTransferLimit:a}}return e}throw new l("InvalidRequest")}async getFeatureByObjectId(e,t){const r=this._createQuery();r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=S(r.where,this.objectIdField+"="+e.toString()),this._featureSetQueryInterceptor&&this._featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"});const a=await this._layer.source.queryFeaturesJSON(r);return 1===a.features.length?(c(a.features,a.spatialReference??this.spatialReference.toJSON()),a.features[0]):null}async getIdentityUser(){await this.load();const t=e?.findCredential(this._layer.url);return t?t.userId:null}async getOwningSystemUrl(){await this.load();const r=e?.findServerInfo(this._layer.url);if(r)return r.owningSystemUrl??"";let a=this._layer.url;const i=a.toLowerCase().indexOf("/rest/services");if(a=i>-1?a.slice(0,i):a,a){a+="/rest/info";try{const e=await t(a,{query:{f:"json"}});let r="";return e.data?.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch{return""}}return""}getDataSourceFeatureSet(){const e=new v({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this._recentlyUsedQueries??void 0,interceptor:this._featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this._featureSetInfo)return this._featureSetInfo;let e=null,r="serviceItemId"in this._layer?this._layer.serviceItemId:null;const a=this._layer.parsedUrl?.path??null;if(a){const i=await t(a,{responseType:"json",query:{f:"json"}});e=i?.data?.name??null,r=i?.data?.serviceItemId??null}const i=this._layer.title&&null!==(this._layer.parent??null);return this._featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===r?null:r,serviceLayerUrl:""===a?null:a,webMapLayerId:i?this._layer.id??null:null,webMapLayerTitle:i?this._layer.title??null:null,className:null,objectClassId:null},this._featureSetInfo}}export{v as default};
|
|
@@ -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 i}from"../../../core/sql/DateOnly.js";import{TimeOnly as r}from"../../../core/sql/TimeOnly.js";import t from"../../../layers/support/Field.js";import{DateTime as n}from"luxon";function o(e){return t.fromJSON(e.toJSON())}function l(e){return e
|
|
2
|
+
import{ArcadeDate as e}from"../../ArcadeDate.js";import{DateOnly as i}from"../../../core/sql/DateOnly.js";import{TimeOnly as r}from"../../../core/sql/TimeOnly.js";import t from"../../../layers/support/Field.js";import{DateTime as n}from"luxon";function o(e){return t.fromJSON(e.toJSON())}function l(e){return"toJSON"in e?e.toJSON():e}function s(e){return"string"==typeof e||e instanceof String}function y(e){return"boolean"==typeof e}function p(e){return"number"==typeof e}function u(e){return Array.isArray(e)}function c(e){return e instanceof Date}function m(e){return e instanceof n}function a(i){return i instanceof e}function f(e){return e instanceof i}function d(e){return e instanceof r}function T(e,i){return e===i||!(!c(e)&&!a(e)||!c(i)&&!a(i))&&e.getTime()===i.getTime()}function g(e){const i={};for(const r in e)i[r]=e[r];return i}function F(e,i){return e===i||("point"===e&&"esriGeometryPoint"===i||("polyline"===e&&"esriGeometryPolyline"===i||("polygon"===e&&"esriGeometryPolygon"===i||("extent"===e&&"esriGeometryEnvelope"===i||("multipoint"===e&&"esriGeometryMultipoint"===i||("point"===i&&"esriGeometryPoint"===e||("polyline"===i&&"esriGeometryPolyline"===e||("polygon"===i&&"esriGeometryPolygon"===e||("extent"===i&&"esriGeometryEnvelope"===e||"multipoint"===i&&"esriGeometryMultipoint"===e)))))))))}const G=1e3;function O(e){return function(i){e.reject(i)}}function b(e,i){return function(){try{e.apply(null,arguments)}catch(r){i.reject(r)}}}const S={point:"point",polygon:"polygon",polyline:"polyline",multipoint:"multipoint",extent:"extent",esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint",esriGeometryEnvelope:"extent",envelope:"extent"},D={point:"esriGeometryPoint",polygon:"esriGeometryPolygon",polyline:"esriGeometryPolyline",multipoint:"esriGeometryMultipoint",extent:"esriGeometryEnvelope",esriGeometryPoint:"esriGeometryPoint",esriGeometryPolygon:"esriGeometryPolygon",esriGeometryPolyline:"esriGeometryPolyline",esriGeometryMultipoint:"esriGeometryMultipoint",esriGeometryEnvelope:"esriGeometryEnvelope",envelope:"esriGeometryEnvelope"},P={"small-integer":"esriFieldTypeSmallInteger",integer:"esriFieldTypeInteger",long:"esriFieldTypeLong",single:"esriFieldTypeSingle",double:"esriFieldTypeDouble",string:"esriFieldTypeString",date:"esriFieldTypeDate","date-only":"esriFieldTypeDateOnly","time-only":"esriFieldTypeTimeOnly","timestamp-offset":"esriFieldTypeTimestampOffset",oid:"esriFieldTypeOID",geometry:"esriFieldTypeGeometry",blob:"esriFieldTypeBlob",raster:"esriFieldTypeRaster",guid:"esriFieldTypeGUID","global-id":"esriFieldTypeGlobalID",xml:"esriFieldTypeXML","big-integer":"esriFieldTypeBigInteger",esriFieldTypeSmallInteger:"esriFieldTypeSmallInteger",esriFieldTypeInteger:"esriFieldTypeInteger",esriFieldTypeLong:"esriFieldTypeLong",esriFieldTypeSingle:"esriFieldTypeSingle",esriFieldTypeDouble:"esriFieldTypeDouble",esriFieldTypeString:"esriFieldTypeString",esriFieldTypeDate:"esriFieldTypeDate",esriFieldTypeDateOnly:"esriFieldTypeDateOnly",esriFieldTypeTimeOnly:"esriFieldTypeTimeOnly",esriFieldTypeTimestampOffset:"esriFieldTypeTimestampOffset",esriFieldTypeOID:"esriFieldTypeOID",esriFieldTypeGeometry:"esriFieldTypeGeometry",esriFieldTypeBlob:"esriFieldTypeBlob",esriFieldTypeRaster:"esriFieldTypeRaster",esriFieldTypeGUID:"esriFieldTypeGUID",esriFieldTypeGlobalID:"esriFieldTypeGlobalID",esriFieldTypeXML:"esriFieldTypeXML",esriFieldTypeBigInteger:"esriFieldTypeBigInteger"};function v(e){switch(e){case"point":default:return"esriGeometryPoint";case"polygon":return"esriGeometryPolygon";case"multipoint":return"esriGeometryMultipoint";case"polyline":return"esriGeometryPolyline"}}function I(e){return void 0===e?"":e=(e=(e=e.replace(/\/featureserver\/[0-9]*/i,"/FeatureServer")).replace(/\/mapserver\/[0-9]*/i,"/MapServer")).split("?")[0]}function J(e,i){i||(i={}),"function"==typeof i&&(i={cmp:i});const r="boolean"==typeof i.cycles&&i.cycles,t=i.cmp&&(n=i.cmp,function(e){return function(i,r){const t={key:i,value:e[i]},o={key:r,value:e[r]};return n(t,o)}});var n;const o=[];return function e(i){if(i?.toJSON&&"function"==typeof i.toJSON&&(i=i.toJSON()),void 0===i)return;if("number"==typeof i)return isFinite(i)?""+i:"null";if("object"!=typeof i)return JSON.stringify(i);let n,l;if(Array.isArray(i)){for(l="[",n=0;n<i.length;n++)n&&(l+=","),l+=e(i[n])||"null";return l+"]"}if(null===i)return"null";if(o.includes(i)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const s=o.push(i)-1,y=Object.keys(i).sort(t?.(i));for(l="",n=0;n<y.length;n++){const r=y[n],t=e(i[r]);t&&(l&&(l+=","),l+=JSON.stringify(r)+":"+t)}return o.splice(s,1),"{"+l+"}"}(e)}function M(e){switch(e.type){case"catalog-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{b as callback,g as cloneAttributes,o as cloneField,G as defaultMaxRecords,T as equalityTest,O as errback,l as esriFieldToJson,I as extractServiceUrl,a as isArcadeDate,f as isArcadeDateOnly,d as isArcadeTime,u as isArray,y as isBoolean,c as isDate,m as isLuxonDate,p as isNumber,s as isString,M as isSupportedLayer,P as layerFieldEsriConstants,S as layerGeometryEsriConstants,D as layerGeometryEsriRestConstants,F as sameGeomType,J as stableStringify,v as toEsriGeometryType};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../Dictionary.js";import{StringEnum as n}from"../enum.js";import{ArcadeExecutionError as t}from"../executionError.js";import{s as r,r as s,j as i}from"../../chunks/languageUtils.js";import{assertIsSome as o}from"../../core/maybe.js";import{isString as c,isNumber as a,isArray as u}from"../../support/guards.js";const l=e=>(n,t,r=14)=>+e(n,t).toFixed(r),d=(e,n)=>e+n,h=(e,n)=>e-n,g=(e,n)=>e*n,m=(e,n)=>e/n,f=(e,n,t)=>l(d)(e,n,t),w=(e,n,t)=>l(h)(e,n,t),A=(e,n,t)=>l(g)(e,n,t),D=(e,n,t)=>l(m)(e,n,t),p=360,T=400,E=2*Math.PI,S=3600,_=3240,R=60,F=60,M=180*S/Math.PI,v=p*R*F,L=90*S,U=180*S,x=270*S,N=String.fromCharCode(7501),b="°";function O(e){if(!1===c(e))throw new t("InvalidParameter",null);return e}function G(e,n){const t=10**n;return Math.round(e*t)/t}function I(e,n){return e%n}function y(e){const n=parseFloat(e.toString().replace(Math.trunc(e).toString(),"0"))*Math.sign(e);if(e<0){return{fraction:n,integer:Math.ceil(e)}}return{fraction:n,integer:Math.floor(e)}}function H(e,n){switch(e){case 0:return"SHORT"===n?"N":"North";case 1:return"SHORT"===n?"E":"East";case 2:return"SHORT"===n?"S":"South";case 3:return"SHORT"===n?"W":"West"}}function k(e,n){return e-Math.floor(e/n)*n}function P(e){switch(e){case 6:case 1:return p;case 4:return E;case 5:return T;case 2:return v;case 7:return R;case 8:return F;default:throw new t("LogicError",null,{reason:"unsupported evaluations"})}}const j=new n([],[["NORTH",1],["NORTH AZIMUTH",1],["POLAR",2],["QUADRANT",3],["SOUTH",4],["SOUTH AZIMUTH",4]]);function z(e){const n=j.lookup(e);if(null==n)throw new t("LogicError",null,{reason:"unsupported directionType"});return n}const Q=new n([],[["D",1],["DD",1],["DECIMAL DEGREE",1],["DEGREE",1],["DECIMAL DEGREES",1],["DEGREES",1],["DMS",3],["DEGREES MINUTES SECONDS",3],["R",4],["RAD",4],["RADS",4],["RADIAN",4],["RADIANS",4],["G",5],["GON",5],["GONS",5],["GRAD",5],["GRADS",5],["GRADIAN",5],["GRADIANS",5]]);function C(e){const n=Q.lookup(e);if(null==n)throw new t("LogicError",null,{reason:"unsupported units"});return n}class W{constructor(e,n,t){this.m_degrees=e,this.m_minutes=n,this.m_seconds=t}getField(e){switch(e){case 1:case 6:return this.m_degrees;case 7:return this.m_minutes;case 2:case 8:return this.m_seconds;default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}}static secondsToDMS(e){const n=y(e).fraction;let t=y(e).integer;const r=Math.floor(t/S);t-=r*S;const s=Math.floor(t/F);return t-=s*F,new W(r,s,t+n)}static numberToDms(e){const n=y(e).fraction,t=y(e).integer,r=A(y(100*n).fraction,100),s=y(100*n).integer;return new W(t,s,r)}format(e,n){let t=G(this.m_seconds,n),r=this.m_minutes,s=this.m_degrees;if(2===e||8===e)F<=t&&(t-=F,++r),R<=r&&(r=0,++s),p<=s&&(s=0);else if(7===e)t=0,r=30<=this.m_seconds?this.m_minutes+1:this.m_minutes,s=this.m_degrees,R<=r&&(r=0,++s),p<=s&&(s=0);else if(1===e||6===e){const e=D(this.m_seconds,S),n=D(this.m_minutes,R);s=Math.round(this.m_degrees+n+e),r=0,t=0}return new W(s,r,t)}static dmsToSeconds(e,n,t){return e*S+n*F+t}}class B{constructor(e,n,t){this.meridian=e,this.angle=n,this.direction=t}fetchAzimuth(e){return 0===e?this.meridian:this.direction}}class V{constructor(e){this._angle=e}static createFromAngleAndDirection(e,n){return new V(new Z(V._convertDirectionFormat(e.extractAngularUnits(2),n,1)))}getAngle(e){const n=this._angle.extractAngularUnits(2);switch(e){case 1:case 4:case 2:return new Z(V._convertDirectionFormat(n,1,e));case 3:{const e=V.secondsNorthAzimuthToQuadrant(n);return new Z(e.angle)}}}getMeridian(e){const n=this._angle.extractAngularUnits(2);switch(e){case 1:return 0;case 4:return 2;case 2:return 1;case 3:return V.secondsNorthAzimuthToQuadrant(n).meridian}}getDirection(e){const n=this._angle.extractAngularUnits(2);switch(e){case 1:return 1;case 4:return 3;case 2:return 0;case 3:return V.secondsNorthAzimuthToQuadrant(n).direction}}static secondsNorthAzimuthToQuadrant(e){const n=e<=L||e>=x?0:2,t=0===n?Math.min(v-e,e):Math.abs(e-U);return new B(n,t,e>U?3:1)}static createFromAngleMeridianAndDirection(e,n,t){return new V(new Z(V.secondsQuadrantToNorthAzimuth(e.extractAngularUnits(2),n,t)))}static secondsQuadrantToNorthAzimuth(e,n,t){return 0===n?1===t?e:v-e:1===t?U-e:U+e}static _convertDirectionFormat(e,n,r){let s=0;switch(n){case 1:s=e;break;case 2:s=L-e;break;case 3:throw new t("LogicError",null,{reason:"unexpected evaluation"});case 4:s=e+U}let i=0;switch(r){case 1:i=s;break;case 2:i=L-s;break;case 3:throw new t("LogicError",null,{reason:"unexpected evaluation"});case 4:i=s-U}return i=I(i,v),i<0?v+i:i}}function X(e,n,r){let s=null;switch(n){case 1:s=A(e,S);break;case 2:s=e;break;case 5:s=A(e,_);break;case 4:s=A(e,M);break;default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}switch(r){case 1:return D(s,S);case 2:return s;case 5:return D(s,_);case 4:return s/M;default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}}class Z{constructor(e){this._seconds=e}static createFromAngleAndUnits(e,n){return new Z(X(e,n,2))}extractAngularUnits(e){return X(this._seconds,2,q(e))}static createFromDegreesMinutesSeconds(e,n,t){return new Z(f(f(A(e,S),A(n,F)),t))}}function q(e){switch(o(e),e){case 1:case 6:case 3:return 1;case 5:return 5;case 7:return 7;case 4:return 4;case 2:case 8:return 2}}class J{constructor(e,n,t,r){this.view=e,this.angle=n,this.merdian=t,this.direction=r,this._dms=null,this._formattedDms=null}static createFromStringAndBearing(e,n,t){return new J(e,n.getAngle(t),n.getMeridian(t),n.getDirection(t))}fetchAngle(){return this.angle}fetchMeridian(){return this.merdian}fetchDirection(){return this.direction}fetchView(){return this.view}fetchDms(){return null===this._dms&&this._calculateDms(),this._dms}fetchFormattedDms(){return null===this._formattedDms&&this._calculateDms(),this._formattedDms}_calculateDms(){let e=null,n=6,t=0;for(let r=0;r<this.view.length;r++){const s=this.view[r];switch(s){case"m":e=ae(this.view,r,s),n=6===n?7:n,r=e.newpos;continue;case"s":e=ae(this.view,r,s),n=8,t=t<e.rounding?e.rounding:t,r=e.newpos;continue;default:continue}}this._dms=W.secondsToDMS(this.angle.extractAngularUnits(2)),this._formattedDms=W.secondsToDMS(this.angle.extractAngularUnits(2)).format(n,t)}}function K(e,n,r,s,i){let o=null;switch(n){case 1:case 4:case 5:return o=k(G(e.extractAngularUnits(n),s),P(n)),o.toFixed(s).padStart(r+s+(s>0?1:0),"0");case 6:case 7:return o=k(i.fetchFormattedDms().getField(n),P(n)),o.toFixed(s).padStart(r+s+(s>0?1:0),"0");case 8:return o=k(G(i.fetchDms().getField(n),s),P(n)),o.toFixed(s).padStart(r+s+(s>0?1:0),"0");default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}}function Y(e,n,r){if(3===r)throw new t("LogicError",null,{reason:"conversion error"});if(3===n){const n=W.numberToDms(e);return V.createFromAngleAndDirection(Z.createFromDegreesMinutesSeconds(n.m_degrees,n.m_minutes,n.m_seconds),r)}return V.createFromAngleAndDirection(Z.createFromAngleAndUnits(e,q(n)),r)}function $(e){switch(s(e)){case 1:return{first:0,second:1};case 2:return{first:2,second:1};case 3:return{first:2,second:3};case 4:return{first:0,second:3}}return null}function ee(e){switch(e.toUpperCase().trim()){case"N":case"NORTH":return 0;case"E":case"EAST":return 1;case"S":case"SOUTH":return 2;case"W":case"WEST":return 3}return null}function ne(e){const n=parseFloat(e);if(a(n)){if(isNaN(n))throw new t("LogicError",null,{reason:"invalid conversion"});return n}throw new t("LogicError",null,{reason:"invalid conversion"})}function te(e,n,s){const i=3===s;let o=null,c=null,a=0,u=0,l=0;if(i){if(e.length<2)throw new t("LogicError",null,{reason:"conversion error"});l=1;const n=$(r(e[e.length-1]));if(n?(o=n.first,c=n.second):(a=1,o=ee(r(e[0])),c=ee(r(e[e.length-1]))),null===o||null===c)throw new t("LogicError",null,{reason:"invalid conversion"})}switch(n){case 1:case 4:case 5:if(0===e.length)throw new t("LogicError",null,{reason:"invalid conversion"});return i?V.createFromAngleMeridianAndDirection(Z.createFromAngleAndUnits(ne(e[a]),q(n)),o,c):V.createFromAngleAndDirection(Z.createFromAngleAndUnits(ne(e[a]),q(n)),s);case 3:if(u=e.length-l-a,3===u){const n=Z.createFromDegreesMinutesSeconds(ne(e[a]),ne(e[a+1]),ne(e[a+2]));return i?V.createFromAngleMeridianAndDirection(n,o,c):V.createFromAngleAndDirection(n,s)}if(1===u){const n=ne(e[a]),t=W.numberToDms(n),r=Z.createFromDegreesMinutesSeconds(t.m_degrees,t.m_minutes,t.m_seconds);return i?V.createFromAngleMeridianAndDirection(r,o,c):V.createFromAngleAndDirection(r,s)}}throw new t("LogicError",null,{reason:"invalid conversion"})}function re(e){const n=new Set([" ","-","/","'",'"',"\\","^",b,N,"\t","\r","\n","*"]);let t="";for(let r=0;r<e.length;r++){const s=e.charAt(r);n.has(s)?t+="RRSPLITRRSPLITRR":t+=s}return t.split("RRSPLITRRSPLITRR").filter(e=>""!==e)}function se(e,n,r){if(a(e))return Y(s(e),n,r);if(c(e))return te(re(e),n,r);if(u(e))return te(e,n,r);if(i(e))return te(e.toArray(),n,r);throw new t("LogicError",null,{reason:"conversion error"})}function ie(e,n,r){const s=q(r);if(s&&3!==r){return e.getAngle(n).extractAngularUnits(s)}throw new t("LogicError",null,{reason:"conversion error"})}function oe(e,n,t){const r=e.getAngle(n);if(3===n&&3===t){const t=W.secondsToDMS(r.extractAngularUnits(2));return[H(e.getMeridian(n),"SHORT"),t.m_degrees,t.m_minutes,t.m_seconds,H(e.getDirection(n),"SHORT")]}if(3===t){const e=W.secondsToDMS(r.extractAngularUnits(2));return[e.m_degrees,e.m_minutes,e.m_seconds]}return 3===n?[H(e.getMeridian(n),"SHORT"),r.extractAngularUnits(t),H(e.getDirection(n),"SHORT")]:[r.extractAngularUnits(t)]}function ce(e,n){let r="";switch(e){case 1:r=3===n?"DD.DD"+b:"DDD.DD"+b;break;case 3:r=3===n?"dd"+b+" mm' ss\"":"ddd"+b+" mm' ss.ss\"";break;case 4:r="R.RR";break;case 5:r="GGG.GG"+N;break;default:throw new t("LogicError",null,{reason:"conversion error"})}return 3===n&&(r="p "+r+" b"),r}function ae(e,n,t){const r={padding:0,rounding:0,newpos:n};let s=!1;for(;n<e.length;){const i=e[n];if(i===t)s?r.rounding++:r.padding++,n++;else{if("."!==i)break;s=!0,n++}}return r.newpos=n-1,r}function ue(e,n,t){const r={escaped:"",newpos:n};for(n++;n<e.length;){const t=e[n];if(n++,"]"===t)break;r.escaped+=t}return r.newpos=n-1,r}function le(e,n,t){let r="",s=null,i=null;const o=J.createFromStringAndBearing(n,e,t),c={D:1,d:6,m:7,s:8,R:4,G:5};for(let a=0;a<n.length;a++){const u=n[a];switch(u){case"[":s=ue(n,a),r+=s.escaped,a=s.newpos;continue;case"D":case"d":case"m":case"s":case"R":case"G":s=ae(n,a,u),i=e.getAngle(t),r+=K(i,c[u],s.padding,s.rounding,o),a=s.newpos;continue;case"P":case"p":r+=H(o.fetchMeridian(),"p"===u?"SHORT":"LONG");continue;case"B":case"b":r+=H(o.fetchDirection(),"b"===u?"SHORT":"LONG");continue;default:r+=u}}return r}const de=new n(["TEXT","VALUE"]);function he(n,s,i){if(!(s instanceof e))throw new t("InvalidParameter",null);if(!1===s.hasField("directionType"))throw new t("LogicError",null,{reason:"missing directionType"});if(!1===s.hasField("angleType"))throw new t("LogicError",null,{reason:"missing angleType"});const o=z(O(s.field("directiontype"))),c=se(n,C(O(s.field("angletype"))),o);if(!(i instanceof e))throw new t("InvalidParameter",null);if(!1===i.hasField("directionType"))throw new t("LogicError",null,{reason:"missing directionType"});if(!1===i.hasField("outputType"))throw new t("LogicError",null,{reason:"missing angleType"});const a=z(O(i.field("directiontype"))),u=i.hasField("angleType")?C(O(i.field("angletype"))):null,l=de.get(O(i.field("outputType")));if(!a||!l)throw new t("LogicError",null,{reason:"conversion error"});if(!(u||"TEXT"===l&&i.hasField("format")))throw new t("LogicError",null,{reason:"invalid unit"});switch(l){case"VALUE":return 3===a||3===u?oe(c,a,u):ie(c,a,u);case"TEXT":{let e="";return i.hasField("format")&&(e=r(i.field("format"))),null!==e&&""!==e||(e=ce(u,a)),le(c,e,a)}default:throw new t("InvalidParameter",null)}}export{he as convertDirection,f as preciseAdd,D as preciseDivide,w as preciseMinus,A as preciseMultiply};
|
|
2
|
+
import e from"../Dictionary.js";import{StringEnum as n}from"../enum.js";import{ArcadeExecutionError as t}from"../executionError.js";import{s as r,r as s,g as i}from"../../chunks/languageUtils.js";import{assertIsSome as o}from"../../core/maybe.js";import{isString as c,isNumber as a,isArray as u}from"../../support/guards.js";const l=e=>(n,t,r=14)=>+e(n,t).toFixed(r),d=(e,n)=>e+n,h=(e,n)=>e-n,g=(e,n)=>e*n,m=(e,n)=>e/n,f=(e,n,t)=>l(d)(e,n,t),w=(e,n,t)=>l(h)(e,n,t),A=(e,n,t)=>l(g)(e,n,t),D=(e,n,t)=>l(m)(e,n,t),p=360,T=400,E=2*Math.PI,S=3600,_=3240,R=60,F=60,M=180*S/Math.PI,v=p*R*F,L=90*S,U=180*S,x=270*S,N=String.fromCharCode(7501),b="°";function O(e){if(!1===c(e))throw new t("InvalidParameter",null);return e}function G(e,n){const t=10**n;return Math.round(e*t)/t}function I(e,n){return e%n}function y(e){const n=parseFloat(e.toString().replace(Math.trunc(e).toString(),"0"))*Math.sign(e);if(e<0){return{fraction:n,integer:Math.ceil(e)}}return{fraction:n,integer:Math.floor(e)}}function H(e,n){switch(e){case 0:return"SHORT"===n?"N":"North";case 1:return"SHORT"===n?"E":"East";case 2:return"SHORT"===n?"S":"South";case 3:return"SHORT"===n?"W":"West"}}function k(e,n){return e-Math.floor(e/n)*n}function P(e){switch(e){case 6:case 1:return p;case 4:return E;case 5:return T;case 2:return v;case 7:return R;case 8:return F;default:throw new t("LogicError",null,{reason:"unsupported evaluations"})}}const z=new n([],[["NORTH",1],["NORTH AZIMUTH",1],["POLAR",2],["QUADRANT",3],["SOUTH",4],["SOUTH AZIMUTH",4]]);function Q(e){const n=z.lookup(e);if(null==n)throw new t("LogicError",null,{reason:"unsupported directionType"});return n}const j=new n([],[["D",1],["DD",1],["DECIMAL DEGREE",1],["DEGREE",1],["DECIMAL DEGREES",1],["DEGREES",1],["DMS",3],["DEGREES MINUTES SECONDS",3],["R",4],["RAD",4],["RADS",4],["RADIAN",4],["RADIANS",4],["G",5],["GON",5],["GONS",5],["GRAD",5],["GRADS",5],["GRADIAN",5],["GRADIANS",5]]);function C(e){const n=j.lookup(e);if(null==n)throw new t("LogicError",null,{reason:"unsupported units"});return n}class W{constructor(e,n,t){this.m_degrees=e,this.m_minutes=n,this.m_seconds=t}getField(e){switch(e){case 1:case 6:return this.m_degrees;case 7:return this.m_minutes;case 2:case 8:return this.m_seconds;default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}}static secondsToDMS(e){const n=y(e).fraction;let t=y(e).integer;const r=Math.floor(t/S);t-=r*S;const s=Math.floor(t/F);return t-=s*F,new W(r,s,t+n)}static numberToDms(e){const n=y(e).fraction,t=y(e).integer,r=A(y(100*n).fraction,100),s=y(100*n).integer;return new W(t,s,r)}format(e,n){let t=G(this.m_seconds,n),r=this.m_minutes,s=this.m_degrees;if(2===e||8===e)F<=t&&(t-=F,++r),R<=r&&(r=0,++s),p<=s&&(s=0);else if(7===e)t=0,r=30<=this.m_seconds?this.m_minutes+1:this.m_minutes,s=this.m_degrees,R<=r&&(r=0,++s),p<=s&&(s=0);else if(1===e||6===e){const e=D(this.m_seconds,S),n=D(this.m_minutes,R);s=Math.round(this.m_degrees+n+e),r=0,t=0}return new W(s,r,t)}static dmsToSeconds(e,n,t){return e*S+n*F+t}}class B{constructor(e,n,t){this.meridian=e,this.angle=n,this.direction=t}fetchAzimuth(e){return 0===e?this.meridian:this.direction}}class V{constructor(e){this._angle=e}static createFromAngleAndDirection(e,n){return new V(new Z(V._convertDirectionFormat(e.extractAngularUnits(2),n,1)))}getAngle(e){const n=this._angle.extractAngularUnits(2);switch(e){case 1:case 4:case 2:return new Z(V._convertDirectionFormat(n,1,e));case 3:{const e=V.secondsNorthAzimuthToQuadrant(n);return new Z(e.angle)}}}getMeridian(e){const n=this._angle.extractAngularUnits(2);switch(e){case 1:return 0;case 4:return 2;case 2:return 1;case 3:return V.secondsNorthAzimuthToQuadrant(n).meridian}}getDirection(e){const n=this._angle.extractAngularUnits(2);switch(e){case 1:return 1;case 4:return 3;case 2:return 0;case 3:return V.secondsNorthAzimuthToQuadrant(n).direction}}static secondsNorthAzimuthToQuadrant(e){const n=e<=L||e>=x?0:2,t=0===n?Math.min(v-e,e):Math.abs(e-U);return new B(n,t,e>U?3:1)}static createFromAngleMeridianAndDirection(e,n,t){return new V(new Z(V.secondsQuadrantToNorthAzimuth(e.extractAngularUnits(2),n,t)))}static secondsQuadrantToNorthAzimuth(e,n,t){return 0===n?1===t?e:v-e:1===t?U-e:U+e}static _convertDirectionFormat(e,n,r){let s=0;switch(n){case 1:s=e;break;case 2:s=L-e;break;case 3:throw new t("LogicError",null,{reason:"unexpected evaluation"});case 4:s=e+U}let i=0;switch(r){case 1:i=s;break;case 2:i=L-s;break;case 3:throw new t("LogicError",null,{reason:"unexpected evaluation"});case 4:i=s-U}return i=I(i,v),i<0?v+i:i}}function X(e,n,r){let s=null;switch(n){case 1:s=A(e,S);break;case 2:s=e;break;case 5:s=A(e,_);break;case 4:s=A(e,M);break;default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}switch(r){case 1:return D(s,S);case 2:return s;case 5:return D(s,_);case 4:return s/M;default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}}class Z{constructor(e){this._seconds=e}static createFromAngleAndUnits(e,n){return new Z(X(e,n,2))}extractAngularUnits(e){return X(this._seconds,2,q(e))}static createFromDegreesMinutesSeconds(e,n,t){return new Z(f(f(A(e,S),A(n,F)),t))}}function q(e){switch(o(e),e){case 1:case 6:case 3:return 1;case 5:return 5;case 7:return 7;case 4:return 4;case 2:case 8:return 2}}class J{constructor(e,n,t,r){this.view=e,this.angle=n,this.merdian=t,this.direction=r,this._dms=null,this._formattedDms=null}static createFromStringAndBearing(e,n,t){return new J(e,n.getAngle(t),n.getMeridian(t),n.getDirection(t))}fetchAngle(){return this.angle}fetchMeridian(){return this.merdian}fetchDirection(){return this.direction}fetchView(){return this.view}fetchDms(){return null===this._dms&&this._calculateDms(),this._dms}fetchFormattedDms(){return null===this._formattedDms&&this._calculateDms(),this._formattedDms}_calculateDms(){let e=null,n=6,t=0;for(let r=0;r<this.view.length;r++){const s=this.view[r];switch(s){case"m":e=ae(this.view,r,s),n=6===n?7:n,r=e.newpos;continue;case"s":e=ae(this.view,r,s),n=8,t=t<e.rounding?e.rounding:t,r=e.newpos;continue;default:continue}}this._dms=W.secondsToDMS(this.angle.extractAngularUnits(2)),this._formattedDms=W.secondsToDMS(this.angle.extractAngularUnits(2)).format(n,t)}}function K(e,n,r,s,i){let o=null;switch(n){case 1:case 4:case 5:return o=k(G(e.extractAngularUnits(n),s),P(n)),o.toFixed(s).padStart(r+s+(s>0?1:0),"0");case 6:case 7:return o=k(i.fetchFormattedDms().getField(n),P(n)),o.toFixed(s).padStart(r+s+(s>0?1:0),"0");case 8:return o=k(G(i.fetchDms().getField(n),s),P(n)),o.toFixed(s).padStart(r+s+(s>0?1:0),"0");default:throw new t("LogicError",null,{reason:"unexpected evaluation"})}}function Y(e,n,r){if(3===r)throw new t("LogicError",null,{reason:"conversion error"});if(3===n){const n=W.numberToDms(e);return V.createFromAngleAndDirection(Z.createFromDegreesMinutesSeconds(n.m_degrees,n.m_minutes,n.m_seconds),r)}return V.createFromAngleAndDirection(Z.createFromAngleAndUnits(e,q(n)),r)}function $(e){switch(s(e)){case 1:return{first:0,second:1};case 2:return{first:2,second:1};case 3:return{first:2,second:3};case 4:return{first:0,second:3}}return null}function ee(e){switch(e.toUpperCase().trim()){case"N":case"NORTH":return 0;case"E":case"EAST":return 1;case"S":case"SOUTH":return 2;case"W":case"WEST":return 3}return null}function ne(e){const n=parseFloat(e);if(a(n)){if(isNaN(n))throw new t("LogicError",null,{reason:"invalid conversion"});return n}throw new t("LogicError",null,{reason:"invalid conversion"})}function te(e,n,s){const i=3===s;let o=null,c=null,a=0,u=0,l=0;if(i){if(e.length<2)throw new t("LogicError",null,{reason:"conversion error"});l=1;const n=$(r(e[e.length-1]));if(n?(o=n.first,c=n.second):(a=1,o=ee(r(e[0])),c=ee(r(e[e.length-1]))),null===o||null===c)throw new t("LogicError",null,{reason:"invalid conversion"})}switch(n){case 1:case 4:case 5:if(0===e.length)throw new t("LogicError",null,{reason:"invalid conversion"});return i?V.createFromAngleMeridianAndDirection(Z.createFromAngleAndUnits(ne(e[a]),q(n)),o,c):V.createFromAngleAndDirection(Z.createFromAngleAndUnits(ne(e[a]),q(n)),s);case 3:if(u=e.length-l-a,3===u){const n=Z.createFromDegreesMinutesSeconds(ne(e[a]),ne(e[a+1]),ne(e[a+2]));return i?V.createFromAngleMeridianAndDirection(n,o,c):V.createFromAngleAndDirection(n,s)}if(1===u){const n=ne(e[a]),t=W.numberToDms(n),r=Z.createFromDegreesMinutesSeconds(t.m_degrees,t.m_minutes,t.m_seconds);return i?V.createFromAngleMeridianAndDirection(r,o,c):V.createFromAngleAndDirection(r,s)}}throw new t("LogicError",null,{reason:"invalid conversion"})}function re(e){const n=new Set([" ","-","/","'",'"',"\\","^",b,N,"\t","\r","\n","*"]);let t="";for(let r=0;r<e.length;r++){const s=e.charAt(r);n.has(s)?t+="RRSPLITRRSPLITRR":t+=s}return t.split("RRSPLITRRSPLITRR").filter(e=>""!==e)}function se(e,n,r){if(a(e))return Y(s(e),n,r);if(c(e))return te(re(e),n,r);if(u(e))return te(e,n,r);if(i(e))return te(e.toArray(),n,r);throw new t("LogicError",null,{reason:"conversion error"})}function ie(e,n,r){const s=q(r);if(s&&3!==r){return e.getAngle(n).extractAngularUnits(s)}throw new t("LogicError",null,{reason:"conversion error"})}function oe(e,n,t){const r=e.getAngle(n);if(3===n&&3===t){const t=W.secondsToDMS(r.extractAngularUnits(2));return[H(e.getMeridian(n),"SHORT"),t.m_degrees,t.m_minutes,t.m_seconds,H(e.getDirection(n),"SHORT")]}if(3===t){const e=W.secondsToDMS(r.extractAngularUnits(2));return[e.m_degrees,e.m_minutes,e.m_seconds]}return 3===n?[H(e.getMeridian(n),"SHORT"),r.extractAngularUnits(t),H(e.getDirection(n),"SHORT")]:[r.extractAngularUnits(t)]}function ce(e,n){let r="";switch(e){case 1:r=3===n?"DD.DD"+b:"DDD.DD"+b;break;case 3:r=3===n?"dd"+b+" mm' ss\"":"ddd"+b+" mm' ss.ss\"";break;case 4:r="R.RR";break;case 5:r="GGG.GG"+N;break;default:throw new t("LogicError",null,{reason:"conversion error"})}return 3===n&&(r="p "+r+" b"),r}function ae(e,n,t){const r={padding:0,rounding:0,newpos:n};let s=!1;for(;n<e.length;){const i=e[n];if(i===t)s?r.rounding++:r.padding++,n++;else{if("."!==i)break;s=!0,n++}}return r.newpos=n-1,r}function ue(e,n,t){const r={escaped:"",newpos:n};for(n++;n<e.length;){const t=e[n];if(n++,"]"===t)break;r.escaped+=t}return r.newpos=n-1,r}function le(e,n,t){let r="",s=null,i=null;const o=J.createFromStringAndBearing(n,e,t),c={D:1,d:6,m:7,s:8,R:4,G:5};for(let a=0;a<n.length;a++){const u=n[a];switch(u){case"[":s=ue(n,a),r+=s.escaped,a=s.newpos;continue;case"D":case"d":case"m":case"s":case"R":case"G":s=ae(n,a,u),i=e.getAngle(t),r+=K(i,c[u],s.padding,s.rounding,o),a=s.newpos;continue;case"P":case"p":r+=H(o.fetchMeridian(),"p"===u?"SHORT":"LONG");continue;case"B":case"b":r+=H(o.fetchDirection(),"b"===u?"SHORT":"LONG");continue;default:r+=u}}return r}const de=new n(["TEXT","VALUE"]);function he(n,s,i){if(!(s instanceof e))throw new t("InvalidParameter",null);if(!1===s.hasField("directionType"))throw new t("LogicError",null,{reason:"missing directionType"});if(!1===s.hasField("angleType"))throw new t("LogicError",null,{reason:"missing angleType"});const o=Q(O(s.field("directiontype"))),c=se(n,C(O(s.field("angletype"))),o);if(!(i instanceof e))throw new t("InvalidParameter",null);if(!1===i.hasField("directionType"))throw new t("LogicError",null,{reason:"missing directionType"});if(!1===i.hasField("outputType"))throw new t("LogicError",null,{reason:"missing angleType"});const a=Q(O(i.field("directiontype"))),u=i.hasField("angleType")?C(O(i.field("angletype"))):null,l=de.get(O(i.field("outputType")));if(!a||!l)throw new t("LogicError",null,{reason:"conversion error"});if(!(u||"TEXT"===l&&i.hasField("format")))throw new t("LogicError",null,{reason:"invalid unit"});switch(l){case"VALUE":return 3===a||3===u?oe(c,a,u):ie(c,a,u);case"TEXT":{let e="";return i.hasField("format")&&(e=r(i.field("format"))),null!==e&&""!==e||(e=ce(u,a)),le(c,e,a)}default:throw new t("InvalidParameter",null)}}export{he as convertDirection,f as preciseAdd,D as preciseDivide,w as preciseMinus,A as preciseMultiply};
|
package/arcade/functions/date.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{ArcadeDate as n,createDateTimeZone as r}from"../ArcadeDate.js";import{toStringEnumKey as e,StringEnum as t}from"../enum.js";import{ArcadeExecutionError as o}from"../executionError.js";import{B as u,
|
|
2
|
+
import{ArcadeDate as n,createDateTimeZone as r}from"../ArcadeDate.js";import{toStringEnumKey as e,StringEnum as t}from"../enum.js";import{ArcadeExecutionError as o}from"../executionError.js";import{B as u,T as l,r as i,n as a,e as s,o as c,s as f,U as m,O as d,V as h,W as N}from"../../chunks/languageUtils.js";import{DateOnly as y}from"../../core/sql/DateOnly.js";import{TimeOnly as w}from"../../core/sql/TimeOnly.js";import{getLocale as g}from"../../intl/locale.js";import{DateTime as T}from"luxon";import{isString as A}from"../../support/guards.js";function D(n,r,e){return n+(k(e)?P:p)[r]}function k(n){return n%4==0&&(n%100!=0||n%400==0)}const p=[0,31,59,90,120,151,181,212,243,273,304,334],P=[0,31,60,91,121,152,182,213,244,274,305,335];function S(n){return null===n?n:!1===n.isValid?null:n}function Z(n,r){switch(e(n)){case"":case"default":return l(r);case"z":return"UTC";default:return n}}function O(n,r){return c(n)?n.toArcadeDate():m(n,l(r))}const C=new t(["days","months","minutes","seconds","hours","years","milliseconds"],[["day","days"],["d","days"],["month","months"],["minute","minutes"],["m","minutes"],["second","seconds"],["s","seconds"],["hour","hours"],["h","hours"],["year","years"],["y","years"],["millisecond","milliseconds"],["ms","milliseconds"]]);function U(n){return"M"===n?"months":C.lookup(f(n))??"milliseconds"}function j(e,t){e.today=function(r,e){return t(r,e,(t,o,i)=>{u(i,0,0,e);const a=new Date;return a.setHours(0,0,0,0),n.dateJSAndZoneToArcadeDate(a,l(r))})},e.time=function(r,e){return t(r,e,(t,f,m)=>{switch(u(m,0,4,e),m.length){case 0:{const e=n.nowToArcadeDate(l(r));return new w(e.hour,e.minute,e.second,e.millisecond)}case 1:{if(a(m[0]))return m[0].clone();if(s(m[0]))return new w(m[0].hour,m[0].minute,m[0].second,m[0].millisecond);if(c(m[0]))return new w(0,0,0,0);if(A(m[0]))return w.fromString(m[0]);const n=i(m[0]);return!1===isNaN(n)?w.fromMilliseconds(n):null}case 2:return A(m[0])&&A(m[1])?w.fromString(m[0],m[1]):w.fromParts(i(m[0]),i(m[1]),0,0);case 3:return w.fromParts(i(m[0]),i(m[1]),i(m[2]),0);case 4:return w.fromParts(i(m[0]),i(m[1]),i(m[2]),i(m[3]))}throw new o("InvalidParameter",e)})},e.dateonly=function(r,e){return t(r,e,(t,o,a)=>{if(u(a,0,3,e),3===a.length)return y.fromParts(i(a[0]),i(a[1])+1,i(a[2]));if(2===a.length){const n=f(a[1]);return""===n?null:"X"===n?y.fromSeconds(i(a[0])):"x"===n?y.fromMilliseconds(i(a[0])):y.fromString(f(a[0]),n)}if(1===a.length){if(A(a[0])){if(""===a[0].replaceAll(/^\s+|\s+$/g,""))return null;if(!0===/^[0-9][0-9][0-9][0-9]$/.test(a[0]))return y.fromString(a[0]+"-01-01")}if(c(a[0]))return a[0].clone();if(s(a[0]))return y.fromParts(a[0].year,a[0].monthJS+1,a[0].day);const n=i(a[0]);return!1===isNaN(n)?y.fromMilliseconds(n):A(a[0])?y.fromString(a[0]):null}if(0===a.length){const e=n.nowToArcadeDate(l(r));return!1===e.isValid?null:y.fromParts(e.year,e.monthJS+1,e.day)}return null})},e.changetimezone=function(e,i){return t(e,i,(t,a,s)=>{if(u(s,2,2,i),null===s[0])return null;if(c(s[0]))throw new o("CannotChangeTimeZoneDateOnly",i);if(c(s[0]))throw new o("CannotChangeTimeZoneTime",i);const d=m(s[0],l(e));if(null===d)throw new o("InvalidParameter",i);const h=r(Z(f(s[1]),e),!1);if(null===h)return null;const N=n.arcadeDateAndZoneToArcadeDate(d,h);return!1===N.isValid?null:N})},e.timezone=function(r,e){return t(r,e,(t,o,i)=>{if(u(i,1,2,e),a(i[0]))return"Unknown";if(c(i[0]))return"Unknown";const s=m(i[0],l(r));if(null===s)return null;const f=s.timeZone;return"system"===f?n.systemTimeZoneCanonicalName:"utc"===f.toLowerCase()?"UTC":"unknown"===f.toLowerCase()?"Unknown":f})},e.timezoneoffset=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=m(o[0],l(n));return null===i?null:60*i.timeZoneOffset*1e3})},e.now=function(r,e){return t(r,e,(t,o,i)=>{u(i,0,0,e);const a=n.nowToArcadeDate(l(r));return!1===a.isValid?null:a})},e.timestamp=function(r,e){return t(r,e,(r,t,o)=>{u(o,0,0,e);const l=n.nowUTCToArcadeDate();return!1===l.isValid?null:l})},e.toutc=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=m(o[0],l(n));return null===i?null:i.toUTC()})},e.tolocal=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=m(o[0],l(n));return null===i?null:i.toLocal()})},e.day=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.day})},e.month=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.monthJS})},e.year=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.year})},e.hour=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,r),a(o[0]))return o[0].hour;const i=m(o[0],l(n));return null===i?NaN:i.hour})},e.second=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,r),a(o[0]))return o[0].second;const i=m(o[0],l(n));return null===i?NaN:i.second})},e.millisecond=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,r),a(o[0]))return o[0].millisecond;const i=m(o[0],l(n));return null===i?NaN:i.millisecond})},e.minute=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,r),a(o[0]))return o[0].minute;const i=m(o[0],l(n));return null===i?NaN:i.minute})},e.week=function(n,r){return t(n,r,(e,t,a)=>{u(a,1,2,r);const s=O(a[0],l(n));if(null===s)return NaN;const c=i(d(a[1],0));if(c<0||c>6)throw new o("InvalidParameter",r);const f=s.day,m=s.monthJS,h=s.year,N=s.dayOfWeekJS,y=D(f,m,h)-1,w=Math.floor(y/7);return N-c+(N-c<0?7:0)<y-7*w?w+1:w})},e.weekday=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.dayOfWeekJS})},e.isoweekday=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.dayOfWeekISO})},e.isomonth=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.monthISO})},e.isoweek=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.weekISO})},e.isoyear=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,r);const i=O(o[0],l(n));return null===i?NaN:i.yearISO})},e.date=function(e,o){return t(e,o,(t,s,d)=>{if(u(d,0,8,o),3===d.length){if(c(d[0])&&a(d[1])&&A(d[2])){const t=r(Z(f(d[2])??"unknown",e),!1);return null===t?null:S(n.fromParts(d[0].year,d[0].month,d[0].day,d[1].hour,d[1].minute,d[1].second,d[1].millisecond,t))}return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),0,0,0,0,l(e)))}if(4===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),0,0,0,l(e)));if(5===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),0,0,l(e)));if(6===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),0,l(e)));if(7===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),i(d[6]),l(e)));if(8===d.length){const t=r(Z(f(d[7])??"unknown",e),!1);return null===t?null:S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),i(d[6]),t))}if(2===d.length){if(c(d[0])&&A(d[1])){const t=r(Z(f(d[1])??"unknown",e),!1);return null===t?null:S(n.fromParts(d[0].year,d[0].month,d[0].day,0,0,0,0,t))}if(c(d[0])&&a(d[1]))return S(n.fromParts(d[0].year,d[0].month,d[0].day,d[1].hour,d[1].minute,d[1].second,d[1].millisecond,"unknown"));let t,o=f(d[1]);return""===o?null:(o=h(o,!0),t="X"===o?T.fromSeconds(i(d[0])):"x"===o?T.fromMillis(i(d[0])):T.fromFormat(f(d[0]),o,{locale:g(),numberingSystem:"latn"}),t.isValid?n.dateTimeToArcadeDate(t):null)}if(1===d.length){if(c(d[0]))return S(n.fromParts(d[0].year,d[0].month,d[0].day,0,0,0,0,"unknown"));if(A(d[0])){if(""===d[0].replaceAll(/^\s+|\s+$/g,""))return null;if(!0===/^[0-9][0-9][0-9][0-9]$/.test(d[0]))return m(d[0]+"-01-01",l(e))}const r=i(d[0]);if(!1===isNaN(r)){const t=T.fromMillis(r);return t.isValid?n.dateTimeAndZoneToArcadeDate(t,l(e)):null}return m(d[0],l(e))}return 0===d.length?n.nowToArcadeDate(l(e)):null})},e.datediff=function(r,e){return t(r,e,(t,o,i)=>{if(u(i,2,4,e),a(i[0]))return a(i[1])?i[0].difference(i[1],f(i[2])):NaN;if(a(i[1]))return NaN;if(c(i[0]))return c(i[1])?i[0].difference(i[1],f(i[2])):NaN;if(c(i[1]))return NaN;let s=m(i[0],l(r)),h=m(i[1],l(r));if(null===s||null===h)return NaN;let N=d(i[3],"");return""!==N&&null!==N?(N=Z(f(N),r),s=n.arcadeDateAndZoneToArcadeDate(s,N),h=n.arcadeDateAndZoneToArcadeDate(h,N)):s.timeZone!==h.timeZone&&(s.isUnknownTimeZone?s=n.arcadeDateAndZoneToArcadeDate(s,h.timeZone):h=(h.isUnknownTimeZone,n.arcadeDateAndZoneToArcadeDate(h,s.timeZone))),s.diff(h,U(i[2]))})},e.dateadd=function(n,r){return t(n,r,(e,t,o)=>{u(o,2,3,r);let s=i(o[1]);if(isNaN(s)||s===1/0||s===-1/0)return a(o[0])||c(o[0])?o[0].clone():m(o[0],l(n));const f=U(o[2]);if("days"!==f&&"months"!==f||(s=c(o[0])?s:N(s)),a(o[0]))return o[0].plus(f,s);if(c(o[0]))return o[0].plus(f,s);const d=m(o[0],l(n));return null===d?null:d.plus({[f]:s})})}}export{j as registerFunctions};
|
|
@@ -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{toSymbolId as r}from"../arcadeEnvironment.js";import t
|
|
2
|
+
import{ArcadeDate as e}from"../ArcadeDate.js";import{toSymbolId as r}from"../arcadeEnvironment.js";import{convertJsonValueToImmutableArcadeValue as t}from"../containerUtils.js";import{ArcadeExecutionError as n}from"../executionError.js";import{Feature as o}from"../Feature.js";import{B as i,h as a,X as u,s,Y as m,Z as d,v as f,_ as l,$ as c,e as p}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as w}from"../featureset/support/shared.js";import{SqlTimeStampOffset as y}from"../../core/sql/SqlTimestampOffset.js";import h from"../../core/sql/WhereClause.js";import{internalTimeReceivedField as v}from"../../layers/support/streamLayerUtils.js";import{isString as b,isNumber as I}from"../../support/guards.js";function F(e){const r=e?.fullSchema();return r?.datesInUnknownTimezone?"unknown":r?.dateFieldsTimeZone||"UTC"}function T(e){const r=e.fullSchema()?.fieldsIndex;return null==r&&e instanceof o?e.fieldsIndex:r}const g={getAttributeSQL(e,r){const t=e.field(r);if(null==t)return t;if(p(t)){const n=t.toDateTime(),o=T(e)?.get(r)?.type;return"esriFieldTypeTimestampOffset"===o||"timestamp-offset"===o?y.fromDateTime(n):n}return t}};function j(o,y,j){o.domain=function(e,r){return y(e,r,(e,o,m)=>{if(i(m,2,3,r),a(m[0])){const e=u(m[0],s(m[1]),void 0===m[2]?void 0:m[2]);return null==e?.domain?null:"coded-value"===e.domain.type||"codedValue"===e.domain.type?t({type:"codedValue",name:e.domain.name,dataType:w[e.field.type],codedValues:e.domain.codedValues.map(e=>({name:e.name,code:e.code}))}):t({type:"range",name:e.domain.name,dataType:w[e.field.type],min:e.domain.minValue,max:e.domain.maxValue})}throw new n("InvalidParameter",r)})},o.domaincode=function(e,r){return y(e,r,(e,t,o)=>{if(i(o,2,4,r),a(o[0]))return m(o[0],s(o[1]),o[2],void 0===o[3]?void 0:o[3]);throw new n("InvalidParameter",r)})},o.domainname=function(e,r){return y(e,r,(e,t,o)=>{if(i(o,2,4,r),a(o[0]))return d(o[0],s(o[1]),o[2],void 0===o[3]?void 0:o[3]);throw new n("InvalidParameter",r)})},o.expects=function(e,r){return y(e,r,(e,t,o)=>{if(o.length<1)throw new n("WrongNumberOfParameters",r);return f})},o.featureinfilter=function(e,r){return y(e,r,(e,r,t)=>{i(t,2,2,r);const[o,u]=t;if(null==o)return!1;if(""===u||null==u)return!0;if(!a(o)||!b(u))throw new n("InvalidParameter",r);const s=h.create(u,{fieldsIndex:T(o),timeZone:F(o)}),m=s.getVariables();for(const n of m)s.parameters[n]=j(e,{name:n});return s.testFeature(o,g)})},o.gdbversion=function(e,r){return y(e,r,(e,t,o)=>{if(i(o,1,1,r),a(o[0]))return o[0].gdbVersion();throw new n("InvalidParameter",r)})},o.schema=function(e,r){return y(e,r,(e,o,i)=>{if(a(i[0]))return t(l(i[0]));throw new n("InvalidParameter",r)})},o.subtypecode=function(e,r){return y(e,r,(e,t,o)=>{if(i(o,1,1,r),a(o[0])){const e=c(o[0]);if(!e)return null;if(e.subtypeField&&o[0].hasField(e.subtypeField)){const r=o[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.code;return null}return null}throw new n("InvalidParameter",r)})},o.subtypename=function(e,r){return y(e,r,(e,t,o)=>{if(i(o,1,1,r),a(o[0])){const e=c(o[0]);if(!e)return"";if(e.subtypeField&&o[0].hasField(e.subtypeField)){const r=o[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.name;return""}return""}throw new n("InvalidParameter",r)})},o.subtypes=function(e,r){return y(e,r,(e,o,u)=>{if(i(u,1,1,r),a(u[0]))return t(c(u[0]));throw new n("InvalidParameter",r)})},o[r("TimeReceived")]=function(r,t){return y(r,t,(r,t,o)=>{if(i(o,1,1,t),a(o[0])){if(o[0].hasField(v)){const t=o[0].field(v);return I(t)?e.epochToArcadeDate(t,r.timeZone??"system"):p(t)?t:null}return null}throw new n("InvalidParameter",t)})}}export{j as registerFunctions};
|