@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 12.5 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import{clone as i}from"../../core/lang.js";import r from"../../core/Logger.js";import{hasSameOrigin as o,getHost as s,changeHost as n}from"../../core/urlUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{reader as l}from"../../core/accessorSupport/decorators/reader.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../../core/accessorSupport/decorators/writer.js";import{excludeTables as u}from"../../core/accessorSupport/layerContainerType.js";import{OriginId as c,idToName as y}from"../../core/accessorSupport/PropertyOrigin.js";import f from"../../geometry/Extent.js";import m from"../../geometry/HeightModelInfo.js";import h from"../../geometry/SpatialReference.js";import{sanitizeUrlWithLayerId as v,writeUrlWithLayerId as g}from"../support/arcgisLayerUrl.js";import{elevationInfo as I,maxScale as F,minScale as S,url as j}from"../support/commonProperties.js";import b from"../support/EditFieldsInfo.js";import{FeatureIndex as E}from"../support/FeatureIndex.js";import{geometryTypeKebabDict as U,hasCurrentUser as x,isLayerCacheStale as O,supportsQueryOnly as M,readGlobalIdField as D,readObjectIdField as T,readVersion as w}from"../support/featureLayerUtils.js";import R from"../support/GeometryFieldsInfo.js";import H from"../support/LayerFloorInfo.js";import{isPreferredUrlApplicable as C,getPreferredUrl as B,applyPreferredHostToPortalItem as A,getPreferredHost as Q}from"../support/layerUtils.js";import _ from"../support/Relationship.js";import{getFeatureLayerCapabilities as P}from"../support/serviceCapabilitiesUtils.js";import q from"../support/Subtype.js";import{hasTypeKeyword as V,typeKeyword as G}from"../../portal/support/portalItemUtils.js";import{timeZoneProperty as Z}from"../../time/timeZoneUtils.js";const k=k=>{let L=class extends k{constructor(){super(...arguments),this.copyright=null,this.capabilities=null,this.dateFieldsTimeZone=null,this.datesInUnknownTimezone=!1,this.definitionExpression=null,this.displayField=null,this.editFieldsInfo=null,this.editingInfo=null,this.elevationInfo=null,this.fieldsIndex=null,this.floorInfo=null,this.fullExtent=null,this.gdbVersion=null,this.geometryFieldsInfo=null,this.geometryType=null,this.globalIdField=null,this.hasM=void 0,this.hasZ=void 0,this.heightModelInfo=null,this.historicMoment=null,this.indexes=new(t.ofType(E)),this.isTable=!1,this.layerId=void 0,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.preferredTimeZone=null,this.relationships=null,this.returnM=void 0,this.returnZ=void 0,this.serviceDefinitionExpression=null,this.serviceItemId=null,this.sourceJSON=null,this.spatialReference=h.WGS84,this.subtypeField=null,this.subtypes=null,this.trackIdField=null,this.uniqueIdFields=null,this.version=void 0,this._isUrlHostModified=!1,this._isUrlHostModificationEnabled=!1}getFieldDomain(){throw new Error("Not implemented")}getField(e){return this.fieldsIndex.get(e)}get authenticationTriggerEvent(){if(!this.url)return null;const{capabilities:e}=this;if(e){const{query:t,operations:i,editing:r}=e;if(!t.supportsQueryByOthers||!t.supportsQueryByAnonymous)return"load";if(i.supportsEditing&&!(r.supportsUpdateByOthers&&r.supportsUpdateByAnonymous&&r.supportsDeleteByOthers&&r.supportsDeleteByAnonymous))return"load"}if(x(this.serviceDefinitionExpression)||x(this.definitionExpression))return"load";if(this.userHasUpdateItemPrivileges){if(O(this))return"load";if(this.hasUpdateItemRestrictions)return e.operations.supportsQuery?"editing":"load"}if(this.userHasFullEditingPrivileges&&this.hasFullEditingRestrictions)return"editing";const t=this.editFieldsInfo;return(t?.creatorField||t?.editorField)&&e?.operations.supportsEditing?"editing":null}readCapabilitiesFromService(e,t){return P(t,this.url)}readEditingInfo(e,t){const{editingInfo:i}=t;return i?{lastEditDate:null!=i.lastEditDate?new Date(i.lastEditDate):null}:null}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=i(e),{operations:r,editing:o}=t;return M(this)?(this.userHasUpdateItemPrivileges&&(r.supportsQuery=!0),t):this.userHasUpdateItemPrivileges?(r.supportsAdd=r.supportsDelete=r.supportsEditing=r.supportsQuery=r.supportsUpdate=o.supportsDeleteByOthers=o.supportsGeometryUpdate=o.supportsUpdateByOthers=!0,t):(this.userHasFullEditingPrivileges&&r.supportsEditing&&(r.supportsAdd=r.supportsDelete=r.supportsUpdate=o.supportsGeometryUpdate=!0),t)}get effectiveEditingEnabled(){return!1}readGlobalIdFieldFromService(e,t){return D(t)}get hasFullEditingRestrictions(){const e=this.capabilities;if(!e||M(this))return!1;const{operations:t,editing:i}=e;return t.supportsEditing&&!(t.supportsAdd&&t.supportsDelete&&t.supportsUpdate&&i.supportsGeometryUpdate)}get hasUpdateItemRestrictions(){const e=this.capabilities;if(!e)return!1;const{operations:t,editing:i}=e;return M(this)?!t.supportsQuery:!(t.supportsAdd&&t.supportsDelete&&t.supportsEditing&&t.supportsQuery&&t.supportsUpdate&&i.supportsDeleteByOthers&&i.supportsGeometryUpdate&&i.supportsUpdateByOthers)}readIsTableFromService(e,t){return"Table"===t.type}readMaxScale(e,t){return t.effectiveMaxScale||e||0}readMinScale(e,t){return t.effectiveMinScale||e||0}readObjectIdFieldFromService(e,t){return T(t)}readServiceDefinitionExpression(e,t){return t.definitionQuery||t.definitionExpression}readUniqueIdFields(e,t){return t.uniqueIdInfo?.OIDFieldContainsHashValue?t.uniqueIdInfo.fields:null}set url(e){if(null==e)return void this._set("url",e);const t=v({layer:this,url:e,nonStandardUrlAllowed:!0,logger:r.getLogger(this)});this._set("url",t.url),null!=t.layerId&&this._set("layerId",t.layerId)}writeUrl(e,t,i,r){g(this,e,null,t,r)}readVersion(e,t){return w(t)}get isUrlHostModified(){const{loaded:e,url:t,_isUrlHostModified:i}=this;if(i)return!0;if(!e||!t)return!1;if(this.originIdOf("url")<c.USER)return!1;const r=this.sourceJSON?.preferredHost;if(!r)return!1;if(!o(t,`https://${r}`,!0))return!1;for(let s=c.USER-1;s>=c.PORTAL_ITEM;s--){const e=this.getAtOrigin("url",y(s));if(e)return!o(t,e,!0)}return!1}applyPreferredHost(e){const{url:t,portalItem:i}=this;if(!t||!C(i))return;const r=B();r&&this._isUrlHostModificationEnabled&&(this._set("url",r),this._isUrlHostModified=!0,i&&A(i,Q()))}applyHostFromPortalItem(){const{url:e,portalItem:t}=this;if(!e||this.originIdOf("url")===c.USER||!t?.url||!C(t)||!V(t,G.HOSTED_SERVICE)||o(e,t.url,!0)||!this._isUrlHostModificationEnabled)return;const i=s(t.url);this._set("url",n(e,i)),this._isUrlHostModified=!0}};return e([p({readOnly:!0})],L.prototype,"authenticationTriggerEvent",null),e([p({type:String,json:{origins:{service:{read:{source:"copyrightText"}}}}})],L.prototype,"copyright",void 0),e([p({readOnly:!0,json:{read:!1,origins:{service:{read:{source:["advancedQueryCapabilities","allowGeometryUpdates","allowUpdateWithoutMValues","archivingInfo","capabilities","datesInUnknownTimezone","hasAttachments","hasM","hasZ","isDataBranchVersioned","isDataVersioned","maxRecordCount","maxRecordCountFactor","maxUniqueIDCount","ownershipBasedAccessControlForFeatures","standardMaxRecordCount","supportedQueryFormats","supportsAdvancedQueries","supportsApplyEditsWithGlobalIds","supportsAttachmentsByUploadId","supportsAttachmentsResizing","supportsCalculate","supportsCoordinatesQuantization","supportsExceedsLimitStatistics","supportsFieldDescriptionProperty","supportsQuantizationEditMode","supportsRollbackOnFailureParameter","supportsStatistics","supportsTruncate","supportsValidateSql","tileMaxRecordCount","useStandardizedQueries"]}}}}})],L.prototype,"capabilities",void 0),e([l("service","capabilities")],L.prototype,"readCapabilitiesFromService",null),e([p(Z("dateFieldsTimeReference"))],L.prototype,"dateFieldsTimeZone",void 0),e([p({type:Boolean})],L.prototype,"datesInUnknownTimezone",void 0),e([p({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],L.prototype,"definitionExpression",void 0),e([p({type:String,json:{origins:{service:{read:{source:"displayField"}}}}})],L.prototype,"displayField",void 0),e([p({readOnly:!0,type:b})],L.prototype,"editFieldsInfo",void 0),e([p({readOnly:!0})],L.prototype,"editingInfo",void 0),e([l("editingInfo")],L.prototype,"readEditingInfo",null),e([p({readOnly:!0})],L.prototype,"effectiveCapabilities",null),e([p()],L.prototype,"effectiveEditingEnabled",null),e([p((()=>{const e=i(I),t=e.json.origins;return t["web-map"]={read:!1,write:!1},t["portal-item"]={read:!1,write:!1},e})())],L.prototype,"elevationInfo",void 0),e([p()],L.prototype,"fieldsIndex",void 0),e([p({type:H,json:{name:"layerDefinition.floorInfo",write:{layerContainerTypes:u}}})],L.prototype,"floorInfo",void 0),e([p({type:f,json:{origins:{service:{read:{source:"extent"}}}}})],L.prototype,"fullExtent",void 0),e([p()],L.prototype,"gdbVersion",void 0),e([p({readOnly:!0,type:R,json:{read:{source:"geometryProperties"}}})],L.prototype,"geometryFieldsInfo",void 0),e([p({type:["point","polygon","polyline","multipoint","multipatch","mesh"],json:{origins:{service:{read:U.read}}}})],L.prototype,"geometryType",void 0),e([p({type:String})],L.prototype,"globalIdField",void 0),e([l("service","globalIdField",["globalIdField","fields"])],L.prototype,"readGlobalIdFieldFromService",null),e([p({readOnly:!0})],L.prototype,"hasFullEditingRestrictions",null),e([p({type:Boolean,json:{origins:{service:{read:!0}}}})],L.prototype,"hasM",void 0),e([p({readOnly:!0})],L.prototype,"hasUpdateItemRestrictions",null),e([p({type:Boolean,json:{origins:{service:{read:!0}}}})],L.prototype,"hasZ",void 0),e([p({readOnly:!0,type:m})],L.prototype,"heightModelInfo",void 0),e([p({type:Date})],L.prototype,"historicMoment",void 0),e([p({type:t.ofType(E),readOnly:!0})],L.prototype,"indexes",void 0),e([p({readOnly:!0})],L.prototype,"isTable",void 0),e([l("service","isTable",["type"])],L.prototype,"readIsTableFromService",null),e([p({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{read:!1,write:{target:"id"}}},read:!1}})],L.prototype,"layerId",void 0),e([p(F)],L.prototype,"maxScale",void 0),e([l("service","maxScale",["maxScale","effectiveMaxScale"])],L.prototype,"readMaxScale",null),e([p(S)],L.prototype,"minScale",void 0),e([l("service","minScale",["minScale","effectiveMinScale"])],L.prototype,"readMinScale",null),e([p({type:String})],L.prototype,"objectIdField",void 0),e([l("service","objectIdField",["objectIdField","fields"])],L.prototype,"readObjectIdFieldFromService",null),e([p(Z("preferredTimeReference"))],L.prototype,"preferredTimeZone",void 0),e([p({type:[_],readOnly:!0})],L.prototype,"relationships",void 0),e([p({type:Boolean})],L.prototype,"returnM",void 0),e([p({type:Boolean})],L.prototype,"returnZ",void 0),e([p({readOnly:!0,json:{write:!1}})],L.prototype,"serverGens",void 0),e([p({readOnly:!0})],L.prototype,"serviceDefinitionExpression",void 0),e([l("service","serviceDefinitionExpression",["definitionQuery","definitionExpression"])],L.prototype,"readServiceDefinitionExpression",null),e([p({type:String,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],L.prototype,"serviceItemId",void 0),e([p()],L.prototype,"sourceJSON",void 0),e([p({type:h,json:{origins:{service:{read:{source:"extent.spatialReference"}}}}})],L.prototype,"spatialReference",void 0),e([p({type:String,readOnly:!0,json:{origins:{service:{read:!0}}}})],L.prototype,"subtypeField",void 0),e([p({type:[q],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],L.prototype,"subtypes",void 0),e([p({type:String,json:{read:{source:"timeInfo.trackIdField"}}})],L.prototype,"trackIdField",void 0),e([p({type:[String],readOnly:!0})],L.prototype,"uniqueIdFields",void 0),e([l("service","uniqueIdFields",["uniqueIdInfo.OIDFieldContainsHashValue","uniqueIdInfo.fields"])],L.prototype,"readUniqueIdFields",null),e([p(j)],L.prototype,"url",null),e([a("url")],L.prototype,"writeUrl",null),e([p({json:{origins:{service:{read:!0}},read:!1}})],L.prototype,"version",void 0),e([l("service","version",["currentVersion","capabilities","drawingInfo","hasAttachments","htmlPopupType","relationships","timeInfo","typeIdField","types"])],L.prototype,"readVersion",null),e([p({readOnly:!0})],L.prototype,"isUrlHostModified",null),L=e([d("esri.layers.mixins.FeatureLayerBase")],L),L};export{k as FeatureLayerBase};