@vertigis/arcgis-extensions 45.3.3 → 45.4.0
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/data/ArcGISServiceTableExtension.js +1 -1
- package/data/Attachment.d.ts +7 -2
- package/data/Attachment.js +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/mapping_ArcGISSublayerExtension.ArcGISSublayerExtension.html +4 -3
- package/docs/html/classes/mapping_MapImageSublayerExtension.MapImageSublayerExtension.html +4 -3
- package/docs/html/classes/mapping_TileSublayerExtension.TileSublayerExtension.html +4 -3
- package/docs/html/functions/data_Attachment.toAttachment.html +5 -3
- package/docs/html/functions/utilities__version.getGdbVersion.html +4 -0
- package/docs/html/interfaces/mapping_MapImageLayerExtension.MapImageLayerExtensionProperties.html +2 -2
- package/docs/html/interfaces/mapping_MapImageSublayerExtension.MapImageSublayerExtensionProperties.html +2 -2
- package/docs/html/modules/utilities__version.html +2 -0
- package/docs/html/variables/version.version.html +1 -1
- package/mapping/ArcGISSublayerExtension.d.ts +1 -0
- package/mapping/ArcGISSublayerExtension.js +1 -1
- package/mapping/FeatureLayerExtension.js +1 -1
- package/mapping/SubtypeGroupLayerExtension.js +1 -1
- package/mapping/SubtypeSublayerExtension.js +1 -1
- package/mapping/support/featureService.js +1 -1
- package/package.json +1 -1
- package/utilities/_version.d.ts +7 -0
- package/utilities/_version.js +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import i from"@arcgis/core/geometry/Extent";import r from"@arcgis/core/layers/support/FeatureType";import s from"@arcgis/core/layers/support/Field";import{InvalidOperationError as a}from"../InvalidOperationError.js";import{toAttachment as
|
|
1
|
+
import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import i from"@arcgis/core/geometry/Extent";import r from"@arcgis/core/layers/support/FeatureType";import s from"@arcgis/core/layers/support/Field";import{InvalidOperationError as a}from"../InvalidOperationError.js";import{toAttachment as n}from"../data/Attachment.js";import{jsonToGeometryType as o}from"../json/GeometryJson.js";import{applyJsonToSublayer as l,jsonToSublayer as u,sublayerToJson as p}from"../json/SublayerJson.js";import{DefaultArcGISRequestHelper as y}from"../support/ArcGISRequestHelper.js";import{serializable as c}from"../support/Serializable.js";import{ArcGISRelationshipCollection as d}from"../support/_ArcGISRelationshipCollection.js";import{ReadOnlyCollection as h}from"../utilities/ReadOnlyCollection.js";import{getGdbVersion as m}from"../utilities/_version.js";import{isMapImageLayerExtension as _}from"../utilities/extensions.js";import{isFeatureLayer as g,isMapImageLayer as b,isMapImageSublayer as f}from"../utilities/layers.js";import{parse as S}from"../utilities/number.js";import{SublayerExtension as x,SublayerSchema as E}from"./_SublayerExtension.js";import{ExtensionBaseLayerListSettings as C}from"./support/LayerListSettings.js";import{PopupTemplateFeatureSettings as F}from"./support/PopupTemplateFeatureSettings.js";const w="This schema property is read-only.",I=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!1});export class ArcGISSublayerExtension extends x{get canToggleVisibility(){const e=t=>t.parentSublayerExtension?e(t.parentSublayerExtension):t.layerExtension,t=e(this),i=t?.layer??this.sublayer?.layer,r=i?.capabilities?.exportMap;return r?r.supportsSublayerVisibility:i?b(i):t?_(t):super.canToggleVisibility}get supportsSublayers(){return!0}get renderer(){return this.sublayer?.renderer}get supportsPagination(){return this._supportsPagination}get hasFeatures(){return 0===this.sublayerExtensions.length}get requestHelper(){return this._requestHelper?this._requestHelper:this.layerExtension?this.layerExtension.requestHelper:(this._autoCreatedRequestHelper||(this._autoCreatedRequestHelper=this._createRequestHelper()),this._autoCreatedRequestHelper)}set requestHelper(e){this._requestHelper=e}get sublayer(){return super.sublayer}get sublayerExtensions(){return super.sublayerExtensions}get _gdbVersion(){const e=t=>t.parentSublayerExtension?e(t.parentSublayerExtension):t.layerExtension,t=e(this);let i;const r=t?.layer??this.sublayer?.layer;return r&&b(r)?i=r?.gdbVersion??m(r?.customParameters):t&&_(t)&&(i=t?.layer?.gdbVersion??m(t?.layer?.customParameters)),i}_supportsPagination;_capabilitiesField;_hasAttachments;_requestHelper;_autoCreatedRequestHelper;constructor(e){super(e),this._capabilitiesField=I}_getSerializableProperties(){return{...super._getSerializableProperties(),requestHelper:{serialize:!1}}}_isSupportedSublayer(e){return f(e)}async _getAttachments(e){const t=this.sublayer?.url;if(!this._hasAttachments||!t)return[];const i=`${t}/${e.primaryKey}/attachments`,r=this._gdbVersion,s=await this.requestHelper.request(i,{query:{f:"json"}});return s?.data?.attachmentInfos?s.data.attachmentInfos.map((e=>n(e,{attachmentInfoUrl:i,gdbVersion:r}))):[]}async*_getFeatures(e,t){const i=this.sublayer.createQuery();i.where=void 0,i.objectIds=e.map((e=>S(e))),i.outFields=t.outFields,i.returnGeometry=t.returnGeometry,yield*(await import("../support/_query.js")).executeQuery(i,this,this.sublayer,t.cancelToken)}_createLayerListSettings(e){return new q(e,this)}_createFeatureSettings(){return new z(this)}_createRelationships(){return new ArcGISSublayerRelationshipCollection(this)}_createRequestHelper(){return new y}_createSublayer(e){return u(e,"ArcGISMapServiceLayer")}_createSchema(){return new j(this)}async _applySublayerProperties(e,t){return l(e,t)}_capabilities(){return this._capabilitiesField}async _onInitialize(){await super._onInitialize(),this._effectiveFullExtent=this.sublayer?.fullExtent;const e=await this._getSublayerDefinition();if(e){if(this._hasAttachments=!!e.hasAttachments,e.capabilities){const t=e.capabilities.split(",").map((e=>e.trim()));this._capabilitiesField={supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsUpdate:!1,supportsQuery:t.includes("Data"),supportsStandardizedQueries:e.useStandardizedQueries,supportsAttachmentEditing:!1},this.notifyChange("capabilities")}e.advancedQueryCapabilities?.hasOwnProperty("supportsPagination")&&(this._supportsPagination=e.advancedQueryCapabilities.supportsPagination),e.extent&&(this._effectiveFullExtent=this._effectiveFullExtent??i.fromJSON(e.extent)),this.schema.initialize(e)}await this.relationships.initialize()}async _postInitialize(){await super._postInitialize(),this.layerListSettings.onLayerExtensionInitialized()}_serializeSublayer(e){return p(e)}async _getSublayerDefinition(){const e=this.sublayer?.url;if(!e)return;return(await this.requestHelper.request(e,{query:{f:"json"}})).data}}let j=class extends E{get types(){return this._typeCollection}get _fields(){return this._fieldCollection}get primaryKeyField(){return this._primaryKeyField??this._sublayerExtension.sublayer?.objectIdField}set primaryKeyField(e){throw new a(w)}get geometryType(){return this._geometryType}set geometryType(e){throw new a(w)}get displayField(){return this._displayField}set displayField(e){throw new a(w)}get typeIdField(){return this._sublayerExtension.sublayer?.typeIdField}set typeIdField(e){throw new a(w)}_geometryType;_displayField;_primaryKeyField;_fieldBackingCollection;_fieldCollection;_typeBackingCollection;_typeCollection;constructor(e){super(e),this._fieldBackingCollection=new t,this._fieldCollection=new h(this._fieldBackingCollection),this._typeBackingCollection=new t,this._typeCollection=new h(this._typeBackingCollection),this.notifyChange("_fields")}initialize(e){if(e.fields&&(this._fieldBackingCollection.removeAll(),this._fieldBackingCollection.addMany(e.fields.map((e=>s.fromJSON(e))))),e.types){this._typeBackingCollection.removeAll();for(const t of e.types)this._typeBackingCollection.add(r.fromJSON(t))}this._geometryType=e.geometryType?o(e.geometryType):void 0,this.notifyChange("geometryType"),this._displayField=e.displayField,this.notifyChange("displayField"),this._primaryKeyField=e.objectIdField,this.notifyChange("primaryKeyField")}};j=e([c],j);let z=class extends F{get zoomScale(){const e="point"===this._layerExtension.schema.geometryType?this._layerExtension.sublayer.maxScale:void 0;return this._getSetting("zoomScale",e)}set zoomScale(e){this._setSetting("zoomScale",e)}};z=e([c],z);let q=class extends C{get _layerSupportsHideChildren(){return!0}get _esriLayer(){return this._extension.sublayer}get _listModePath(){return"sublayer.listMode"}get _supportsChildren(){return!0}};q=e([c],q);export class ArcGISSublayerRelationshipCollection extends d{get _sourceUrl(){return this._source.sublayer?this._source.sublayer.url:void 0}get _sourceLayerId(){return this._source.sublayer?this._source.sublayer.id:void 0}_findRelatedSource(e){if(!this._source.layerExtension||!this._source.sublayer?.url)return;const t=this._source.layerExtension.allSublayerExtensions.initializedItems.find((t=>t.sublayer.id===e));return t||(this._source.layerExtension.mapExtension?this._source.layerExtension.mapExtension.tableExtensions.initializedItems.find((t=>g(t.table)&&t.table.url===this._source.sublayer.layer.url&&t.table.layerId===e)):void 0)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import r from"@arcgis/core/layers/support/FeatureType.js";import a from"@arcgis/core/rest/support/AttachmentQuery.js";import{InvalidOperationError as s}from"../InvalidOperationError.js";import{config as i}from"../config.js";import{toAttachment as o}from"../data/Attachment.js";import{FeatureSaveError as l}from"../data/FeatureSaveError.js";import{addAttachment as n,deleteAttachments as u}from"../data/support/attachments.js";import{_isFeatureCollection as d}from"../json/FeatureLayerJson.js";import{applyJsonToLayer as h}from"../json/LayerJson.js";import{DefaultArcGISRequestHelper as p}from"../support/ArcGISRequestHelper.js";import{cancelify as y}from"../support/Cancellable.js";import{serializable as c}from"../support/Serializable.js";import{ArcGISRelationshipCollection as m}from"../support/_ArcGISRelationshipCollection.js";import{isFeatureLayerExtension as
|
|
1
|
+
import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import r from"@arcgis/core/layers/support/FeatureType.js";import a from"@arcgis/core/rest/support/AttachmentQuery.js";import{InvalidOperationError as s}from"../InvalidOperationError.js";import{config as i}from"../config.js";import{toAttachment as o}from"../data/Attachment.js";import{FeatureSaveError as l}from"../data/FeatureSaveError.js";import{addAttachment as n,deleteAttachments as u}from"../data/support/attachments.js";import{_isFeatureCollection as d}from"../json/FeatureLayerJson.js";import{applyJsonToLayer as h}from"../json/LayerJson.js";import{DefaultArcGISRequestHelper as p}from"../support/ArcGISRequestHelper.js";import{cancelify as y}from"../support/Cancellable.js";import{serializable as c}from"../support/Serializable.js";import{ArcGISRelationshipCollection as m}from"../support/_ArcGISRelationshipCollection.js";import{getGdbVersion as f}from"../utilities/_version.js";import{isFeatureLayerExtension as _,isSubtypeGroupLayerExtension as w}from"../utilities/extensions.js";import{isFeatureLayer as b}from"../utilities/layers.js";import{isNumeric as g}from"../utilities/number.js";import{isEmpty as F}from"../utilities/object.js";import{FeatureLayerExtensionBase as S,FeatureLayerReadOnlySchema as j}from"./FeatureLayerExtensionBase.js";import{addOutFields as E,getGlobalIdField as I,getReturnServiceEditsOption as v,isGlobalIdUsed as C}from"./support/layers.js";const R="Cannot use feature layer that has a source collection and no url.";let $=class extends S{attachmentTypes;get enableClientSideData(){return void 0===this._enableClientSideData?"cluster"===this.layer?.featureReduction?.type:this._enableClientSideData}set enableClientSideData(e){this._enableClientSideData=e,this._updateClientSideFields()}get renderer(){return this.layer?.renderer}get canChangeLabels(){return!0}_enableClientSideData;async _addAttachment(e,t){return n(e,this.layer,t,{attachmentTypes:this.attachmentTypes})}async _deleteAttachments(e,t){return u(e,this.layer,t)}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,attachmentTypes:["initial"],requestHelper:{...this._toPropertyDef(e.requestHelper),default:new p({batchLayerRequests:!1})},enableClientSideData:{serializeModes:["initial"],isDefault:e=>e===!("cluster"!==this.layer?.featureReduction?.type)}}}_isSupportedLayer(e){return super._isSupportedLayer(e)&&!t.isCollection(e.source)}async _getAttachments(e){if(!this.layer?.capabilities?.data?.supportsAttachment)return[];const t=+e.primaryKey,r=this.layer?.gdbVersion??f(this.layer?.customParameters),s=new a({objectIds:[t]}),i=await this.layer.queryAttachments(s);return i?.[t]?.length?i[t].map((e=>o(e,{gdbVersion:r}))):[]}async _addFeatures(e,t){const r=Array.from(e);if(0===r.length)return;const a=await this._applyEdits({addFeatures:r.map((e=>e.toGraphic()))},t);if(!a.addFeatureResults||a.addFeatureResults.length!==r.length)throw new l("Received malformed response from server while saving feature(s).");let s;if(a.addFeatureResults.forEach(((e,t)=>{const{objectId:a,globalId:i,error:o}=e,n=r[t];if(o){s=s||new l("Errors encountered when adding features.");const{title:r}=n;s.errors.set(`${r}-${t}`,new Error(`Failed to add feature '${r}'. ${e.error.name} : ${e.error.message}`))}else{const{primaryKeyField:e}=n.schema;n.attributes.set(e,a);const t=I(this.layer);t&&i&&n.attributes.set(t,i)}})),s)throw s}async _updateFeatures(e,t){const r=Array.from(e);if(0===r.length)return;const a=await this._applyEdits({updateFeatures:Array.from(e).map((e=>e.toGraphic()))},t);if(!a.updateFeatureResults||a.updateFeatureResults.length!==r.length)throw new l("Received malformed response from server while saving feature(s).");let s;if(a.updateFeatureResults.forEach(((e,t)=>{if(e.error){s=s||new l("Errors encountered when updating features.");const{primaryKey:a}=r[t];s.errors.set(a,new Error(`Failed to update feature with id ${a}. ${e.error.name} : ${e.error.message}`))}})),s)throw s}async _deleteFeatures(e,t){if(0===e.length)return;const r=await this._applyEdits({deleteFeatures:e.map((e=>({objectId:e})))},t);if(!r.deleteFeatureResults)throw new l("Received malformed response from server while saving feature(s).");let a;if(r.deleteFeatureResults.forEach(((t,r)=>{if(t.error){a=a||new l("Errors encountered when deleting features.");const s=e[r];a.errors.set(s,new Error(`Failed to delete feature with id ${s}. ${t.error.name} : ${t.error.message}`))}})),a)throw a}_createRelationships(){return new D(this)}_createSchema(){return new j(this)}async _onInitialize(){if(this.layer&&!this._isSupportedLayer(this.layer))throw new s(R);if(await super._onInitialize(),await this.relationships.initialize(),this.layer.renderer&&"heatmap"===this.layer.renderer.type&&!i.heatmapsEnabled)throw new s("Heatmap rendering has been disabled. They are not supported in this browser.");this._updateClientSideFields(),this._watchHandles.push(this.watch("layer",(()=>{this._updateClientSideFields()}),!0)),this._addSubtypeDomains(),this.notifyChange("capabilities")}_applyLayerProperties(e,t){if(d(e))throw new s(R);return super._applyLayerProperties(e,t)}async _applyPortalItemProperties(e){if("Feature Service"!==e.type)throw new Error(`Cannot create Feature Layer from Portal item that has type: ${e.type}`);let{url:t}=e;t.match(".*MapServer/\\d{1,}/?$")||t.match(".*FeatureServer/\\d{1,}/?$")||(t=`${t}/0`),this.layer.url=t||this.layer.url;const r=await e.fetchData();if(r?.layers){const e=r.layers.find((e=>e.id===this.layer.layerId));if(e){const{id:t,...r}=e;await h(r,this.layer)}}}_addSubtypeDomains(){if(!this.layer?.subtypes)return;this.layer.typeIdField=this.layer.typeIdField||this.layer.subtypeField,this.layer.types=this.layer.types??[];const e=!this.layer.types.length;this.layer.subtypes.forEach((t=>{const a=this.layer.types.find((e=>e.id===t.code));a&&F(a.domains)?a.domains=t.domains:!a&&e&&this.layer.types.push(new r({id:t.code,domains:t.domains,name:t.name}))}))}_updateClientSideFields(){this.layer&&this._enableClientSideData&&E(this.layer,this.featureSettings.outFields)}async _applyEdits(e,t={}){const r=C(this.layer,e),a=this.layer.applyEdits(e,{globalIdUsed:r,returnServiceEditsOption:v(this.layer)}),s=await y(a,t.cancelToken);if(!s)throw new l("Received malformed response from server while saving feature(s).");return s}get _layerUrl(){return g(this.layer.layerId)?`${this.layer.url}/${this.layer.layerId}`:this.layer.url}};$=e([c],$);export{$ as FeatureLayerExtension};class D extends m{get _sourceUrl(){if(this._source.layer?.url)return g(this._source.layer.layerId)?`${this._source.layer.url}/${this._source.layer.layerId}`:this._source.layer.url}get _sourceLayerId(){return this._source.layer?this._source.layer.layerId:void 0}_findRelatedSource(e){if(!this._source.mapExtension||!this._source.layer?.url)return;const t=this._source.mapExtension.allLayerExtensions.initializedItems.find((t=>(_(t)||w(t))&&t.layer.url===this._source.layer.url&&t.layer.layerId===e));return t||this._source.mapExtension.tableExtensions.initializedItems.find((t=>b(t.table)&&t.table.url===this._source.layer.url&&t.table.layerId===e))}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as e}from"tslib";import t from"@arcgis/core/layers/support/FeatureTemplate.js";import r from"@arcgis/core/layers/support/FeatureType.js";import s from"@arcgis/core/rest/support/AttachmentQuery";import{toAttachment as a}from"../data/Attachment.js";import{FeatureSaveError as i}from"../data/FeatureSaveError.js";import{addAttachment as l,deleteAttachments as n,supportsAttachmentEditing as o}from"../data/support/attachments.js";import{applyJsonToLayer as u,layerToJson as p}from"../json/LayerJson.js";import{cancelify as y}from"../support/Cancellable.js";import{serializable as d}from"../support/Serializable.js";import{ArcGISRelationshipCollection as c}from"../support/_ArcGISRelationshipCollection.js";import{ReadOnlyCollection as h}from"../utilities/ReadOnlyCollection.js";import{isFeatureLayer as m,isSubtypeGroupLayer as f}from"../utilities/_layers.js";import{
|
|
1
|
+
import{__decorate as e}from"tslib";import t from"@arcgis/core/layers/support/FeatureTemplate.js";import r from"@arcgis/core/layers/support/FeatureType.js";import s from"@arcgis/core/rest/support/AttachmentQuery";import{toAttachment as a}from"../data/Attachment.js";import{FeatureSaveError as i}from"../data/FeatureSaveError.js";import{addAttachment as l,deleteAttachments as n,supportsAttachmentEditing as o}from"../data/support/attachments.js";import{applyJsonToLayer as u,layerToJson as p}from"../json/LayerJson.js";import{cancelify as y}from"../support/Cancellable.js";import{serializable as d}from"../support/Serializable.js";import{ArcGISRelationshipCollection as c}from"../support/_ArcGISRelationshipCollection.js";import{ReadOnlyCollection as h}from"../utilities/ReadOnlyCollection.js";import{isFeatureLayer as m,isSubtypeGroupLayer as f}from"../utilities/_layers.js";import{getGdbVersion as b}from"../utilities/_version.js";import{parse as _}from"../utilities/number.js";import{caseInsensitiveEquals as g}from"../utilities/string.js";import{onCollectionPropertyChange as w}from"../utilities/watch.js";import{SubtypeSublayerExtension as S}from"./SubtypeSublayerExtension.js";import{LayerExtension as F,LayerExtensionReadOnlySchema as E}from"./_LayerExtension.js";import{ArrayWrappedCollection as C}from"./support/ArrayWrappedCollection.js";import{addOutFields as j,getGlobalIdField as x,getReturnServiceEditsOption as I,isGlobalIdUsed as v}from"./support/layers.js";let R=class extends F{attachmentTypes;get enableClientSideData(){return this._enableClientSideData}set enableClientSideData(e){this._enableClientSideData=e,this._updateClientSideFields()}get layer(){return super.layer}get sublayerExtensions(){return super.sublayerExtensions}get supportsSublayers(){return!0}get sublayersAreReadOnly(){return!1}get hasFeatures(){return!0}get canChangeDefinitionExpression(){return!0}get _layerView(){return this.layer&&this.mapExtension?._allLayerViews.find((e=>e.layer===this.layer))}_subtypes;_enableClientSideData;constructor(e){super(e),w(this,"layer.sublayers",this._onSubtypeSublayersChange)}_getProjectWebmapJSON(){const e=super._getProjectWebmapJSON();if(!e||this.dynamicallyAddedLayer)return e;const t=p(this.layer);return e.layers&&(e.layers=t.layers.map((e=>{const{layerDefinition:t,visibility:r,subtypeCode:s,layerType:a}=e,i={layerType:a,visibility:r,subtypeCode:s};return t?.drawingInfo&&(i.layerDefinition={drawingInfo:t.drawingInfo}),i}))),e}_createRelationships(){return new SubtypeGroupLayerRelationshipCollection(this)}async _onInitialize(){await super._onInitialize(),await this.relationships.initialize(),this._updateSubtypes(),this._addTemplatesToSublayers(),this._addDomainsToFields()}async _postInitialize(){await super._postInitialize(),this._updateClientSideFields(),this._watchHandles.push(this.watch("layer",(()=>{this._updateClientSideFields()}),!0))}_capabilities(){const e=o(this.layer);return this.layer?.capabilities?.operations?{...this.layer.capabilities.operations,supportsAttachmentEditing:e,supportsStandardizedQueries:this.layer.capabilities?.query?.supportsStandardizedQueriesOnly}:{...super._capabilities(),supportsAttachmentEditing:e}}_createSublayerExtension(e){return new S(e)}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"SubtypeGroupLayer"}},enableClientSideData:{serializeModes:["initial"],default:!1},attachmentTypes:["initial"]}}_isSupportedLayer(e){return f(e)}_createSchema(){return new T(this)}async _getAttachments(e){if(!this.layer?.capabilities?.data?.supportsAttachment)return[];const t=+e.primaryKey,r=this.layer?.gdbVersion??b(this.layer?.customParameters),i=new s({objectIds:[t]}),l=await this.layer.queryAttachments(i);return l?.[t]?.length?l[t].map((e=>a(e,{gdbVersion:r}))):[]}async _addAttachment(e,t){return l(e,this.layer,t,{attachmentTypes:this.attachmentTypes})}async _deleteAttachments(e,t){return n(e,this.layer,t)}async _applyPortalItemProperties(e){if("Feature Service"!==e.type)throw new Error(`Cannot create SubtypeGroupLayer from Portal item that has type: ${e.type}`);let{url:t}=e;t.match(".*MapServer/\\d{1,}/?$")||t.match(".*FeatureServer/\\d{1,}/?$")||(t=`${t}/0`),this.layer.url=t||this.layer.url;const r=await e.fetchData();r&&await u(r,this.layer)}async*_getFeatures(e,t){this.layer||(yield*super._getFeatures(e,t));const r=this.layer.createQuery();r.objectIds=e.map((e=>_(e))),r.where=void 0,r.outFields=t.outFields,r.returnGeometry=t.returnGeometry,yield*(await import("../support/_query.js")).executeQuery(r,this,this.layer,t.cancelToken)}async _addFeatures(e,t){const r=Array.from(e);if(0===r.length||!this.layer)return;const s=await this._applyEdits({addFeatures:r.map((e=>e.toGraphic()))},t);if(!s.addFeatureResults||s.addFeatureResults.length!==r.length)throw new i("Received malformed response from server while saving feature(s).");let a;if(s.addFeatureResults.forEach(((e,t)=>{const{objectId:s,globalId:l,error:n}=e,o=r[t];if(n){a=a||new i("Errors encountered when adding features.");const{title:r}=o;a.errors.set(`${r}-${t}`,new Error(`Failed to add feature '${r}'. ${e.error.name} : ${e.error.message}`))}else{const{primaryKeyField:e}=o.schema;o.attributes.set(e,s);const t=x(this.layer);t&&l&&o.attributes.set(t,l)}})),a)throw a}async _updateFeatures(e,t){const r=Array.from(e);if(0===r.length)return;const s=await this._applyEdits({updateFeatures:Array.from(e).map((e=>e.toGraphic()))},t);if(!s.updateFeatureResults||s.updateFeatureResults.length!==r.length)throw new i("Received malformed response from server while saving feature(s).");let a;if(s.updateFeatureResults.forEach(((e,t)=>{if(e.error){a=a||new i("Errors encountered when updating features.");const{primaryKey:s}=r[t];a.errors.set(s,new Error(`Failed to update feature with id ${s}. ${e.error.name} : ${e.error.message}`))}})),a)throw a}async _deleteFeatures(e,t){if(0===e.length)return;const r=await this._applyEdits({deleteFeatures:e.map((e=>({objectId:e})))},t);if(!r.deleteFeatureResults)throw new i("Received malformed response from server while saving feature(s).");let s;if(r.deleteFeatureResults.forEach(((t,r)=>{if(t.error){s=s||new i("Errors encountered when deleting features.");const a=e[r];s.errors.set(a,new Error(`Failed to delete feature with id ${a}. ${t.error.name} : ${t.error.message}`))}})),s)throw s}_onSubtypeSublayersChange=e=>{e.removed?.length&&(this.sublayerExtensions.removeMany(this.sublayerExtensions.filter((e=>!e.sublayer))),this._updateSubtypes())};async _applyEdits(e,t={}){const r=v(this.layer,e),s=this.layer.applyEdits(e,{globalIdUsed:r,returnServiceEditsOption:I(this.layer)}),a=await y(s,t.cancelToken);if(!a)throw new i("Received malformed response from server while saving feature(s).");return a}_updateClientSideFields(){this.layer&&this._enableClientSideData&&(j(this.layer,this.featureSettings.outFields),this.allSublayerExtensions.forEach((e=>j(this.layer,e.featureSettings.outFields))))}_updateSubtypes(){if(!this.layer.subtypes)return;const e=[];for(const t of this.layer.sublayers){const s=this.layer.subtypes.find((e=>e.code===t.subtypeCode));s&&e.push(new r({id:s.code,name:s.name,domains:s.domains??{},templates:t.templates}))}this._subtypes=e}_addTemplatesToSublayers(){const e=this.layer.sourceJSON?.templates?.map((e=>t.fromJSON(e)));for(let r=0;r<this.sublayerExtensions.length;r++){const s=this.sublayerExtensions.getItemAt(r);if(null==s.sublayer)continue;const a=this.layer.sourceJSON?.types.filter((e=>e.name===s.title))[0]?.templates;(null==s.sublayer.templates||0===s.sublayer.templates.length||A(s))&&a?s.sublayer.templates=a.map((e=>t.fromJSON(e))):1!==e.length||1===this.sublayerExtensions.length||s.sublayer.templates?A(s)&&(s.sublayer.templates[0].name=s.sublayer.title):s.sublayer.templates=e.map((e=>{const r=t.fromJSON(e.toJSON());r.name=s.title;const a=r.prototype?.attributes;return"number"==typeof a?.[this.layer.subtypeField]&&(a[this.layer.subtypeField]=s.sublayer.subtypeCode),r}))}}_addDomainsToFields(){if(this._subtypes)for(const e of this._subtypes)for(const[t,r]of Object.entries(e.domains)){const e=this.layer.fields.find((e=>g(e.name,t)));e&&!e.domain&&(e.domain=r)}}};R=e([d],R);export{R as SubtypeGroupLayerExtension};let T=class extends E{_fieldCollection;_typesCollection;constructor(e){super(e),this._fieldCollection=this._createFieldCollection(),this._typesCollection=this._createTypesCollection(),this.notifyChange("_fields")}get types(){return this._typesCollection}get _fields(){return this._fieldCollection}_createFieldCollection(){return new h(new C({parent:this._layerExtension,targetProperty:"layer",arrayProperty:"fields"}))}_createTypesCollection(){return new h(new C({parent:this._layerExtension,arrayProperty:"_subtypes"}))}_getPropertyBindings(){return{primaryKeyField:"objectIdField",geometryType:"geometryType",spatialReference:"spatialReference",displayField:"displayField",typeIdField:"subtypeField"}}};T=e([d],T);export{T as SubtypeGroupLayerSchema};export class SubtypeGroupLayerRelationshipCollection extends c{get _sourceUrl(){const e=this._source.layer;if(e)return`${e.url}/${e.layerId}`}get _sourceLayerId(){const e=this._source.layer;return e?.layerId}_findRelatedSource(e){if(!this._source.mapExtension||!this._source.layer||!this._sourceUrl)return;const t=this._sourceUrl.slice(0,this._sourceUrl.length-`${this._sourceLayerId}`.length-1),r=this._source.mapExtension.allLayerExtensions.initializedItems.find((r=>(m(r.layer)||f(r.layer))&&r.layer.url===t&&r.layer.layerId===e));return r||this._source.mapExtension.tableExtensions.initializedItems.find((r=>m(r.table)&&r.table.url===t&&r.table.layerId===e))}}function A(e){return 1===e.sublayer?.templates?.length&&"New Feature"===e.sublayer.templates[0].name}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import r from"@arcgis/core/rest/support/AttachmentQuery";import{InvalidOperationError as s}from"../InvalidOperationError.js";import{toAttachment as a}from"../data/Attachment.js";import{FeatureSaveError as i}from"../data/FeatureSaveError.js";import{addAttachment as n,deleteAttachments as o}from"../data/support/attachments.js";import{applyJsonToSublayer as l,jsonToSublayer as u,sublayerToJson as y}from"../json/SublayerJson.js";import{cancelify as p}from"../support/Cancellable.js";import{serializable as d}from"../support/Serializable.js";import{ArcGISRelationshipCollection as c}from"../support/_ArcGISRelationshipCollection.js";import{ReadOnlyCollection as h}from"../utilities/ReadOnlyCollection.js";import{isFeatureLayer as
|
|
1
|
+
import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import r from"@arcgis/core/rest/support/AttachmentQuery";import{InvalidOperationError as s}from"../InvalidOperationError.js";import{toAttachment as a}from"../data/Attachment.js";import{FeatureSaveError as i}from"../data/FeatureSaveError.js";import{addAttachment as n,deleteAttachments as o}from"../data/support/attachments.js";import{applyJsonToSublayer as l,jsonToSublayer as u,sublayerToJson as y}from"../json/SublayerJson.js";import{cancelify as p}from"../support/Cancellable.js";import{serializable as d}from"../support/Serializable.js";import{ArcGISRelationshipCollection as c}from"../support/_ArcGISRelationshipCollection.js";import{ReadOnlyCollection as h}from"../utilities/ReadOnlyCollection.js";import{getGdbVersion as m}from"../utilities/_version.js";import{isFeatureLayer as b,isSubtypeGroupLayer as f,isSubtypeSublayer as _}from"../utilities/layers.js";import{parse as g}from"../utilities/number.js";import{caseInsensitiveEquals as w}from"../utilities/string.js";import{SublayerExtension as E,SublayerSchema as F}from"./_SublayerExtension.js";import{ArrayWrappedCollection as x}from"./support/ArrayWrappedCollection.js";import{ExtensionBaseLayerListSettings as S}from"./support/LayerListSettings.js";import{PopupTemplateFeatureSettings as j}from"./support/PopupTemplateFeatureSettings.js";import{getGlobalIdField as C,getReturnServiceEditsOption as I,isGlobalIdUsed as R}from"./support/layers.js";let T=class extends E{get supportsSublayers(){return!1}get layerExtension(){return super.layerExtension}get renderer(){return this.sublayer?.renderer}get hasFeatures(){return!0}get sublayer(){return super.sublayer}get sublayerExtensions(){return super.sublayerExtensions}get attachmentTypes(){return this.layerExtension?.attachmentTypes}get canChangeLabels(){return!0}get canChangeRenderer(){return!0}get canChangeOpacity(){return!1}async _addAttachment(e,t){return n(e,this.sublayer.layer,t,{attachmentTypes:this.layerExtension?.attachmentTypes})}async _deleteAttachments(e,t){return o(e,this.sublayer.layer,t)}_isSupportedSublayer(e){return _(e)}_createLayerListSettings(e){return new A(e,this)}_createFeatureSettings(){return new $(this)}_createSublayer(e){return u(e,"SubtypeGroupLayer")}_createSchema(){return new z(this)}_createRelationships(){return new SubtypeSublayerRelationshipCollection(this)}async _applySublayerProperties(e,t){return l(e,t)}_capabilities(){return this.layerExtension?.capabilities}async _onInitialize(){const e=(await import("@arcgis/core/layers/support/SubtypeSublayer.js")).default;"layer"in e.prototype||Object.defineProperty(e.prototype,"layer",{get:function(){return this.parent},set:function(e){this.parent=e}}),await super._onInitialize(),await this.relationships.initialize(),this._watchHandles.push(this.watch("layerExtension.attachmentTypes",(()=>this.notifyChange("attachmentTypes")))),this._addDomainsToFields()}async _postInitialize(){await super._postInitialize(),this.layerListSettings.onLayerExtensionInitialized()}_getFeatures(e,t){if(!this.sublayer?.layer)return super._getFeatures(e,t);const r=this.sublayer?.layer.createQuery();r.objectIds=e.map((e=>g(e))),r.where=void 0,r.outFields=t.outFields,r.returnGeometry=t.returnGeometry;const s=this;return{async*[Symbol.asyncIterator](){yield*(await import("../support/_query.js")).executeQuery(r,s,s.sublayer.layer,t.cancelToken)}}}async _getAttachments(e){if(!this.sublayer?.layer?.capabilities?.data?.supportsAttachment)return[];const t=+e.primaryKey,s=this.sublayer?.layer?.gdbVersion??m(this.sublayer?.layer?.customParameters),i=new r({objectIds:[t]}),n=await this.sublayer.layer.queryAttachments(i);return n?.[t]?.length?n[t].map((e=>a(e,{gdbVersion:s}))):[]}async _addFeatures(e,t){const r=Array.from(e);if(0===r.length||!this.sublayer?.layer)return;const s=await this._applyEdits({addFeatures:r.map((e=>e.toGraphic()))},t);if(!s.addFeatureResults||s.addFeatureResults.length!==r.length)throw new i("Received malformed response from server while saving feature(s).");let a;if(s.addFeatureResults.forEach(((e,t)=>{const{objectId:s,globalId:n,error:o}=e,l=r[t];if(o){a=a||new i("Errors encountered when adding features.");const{title:r}=l;a.errors.set(`${r}-${t}`,new Error(`Failed to add feature '${r}'. ${e.error.name} : ${e.error.message}`))}else{const{primaryKeyField:e}=l.schema;l.attributes.set(e,s);const t=C(this.sublayer.layer);t&&n&&l.attributes.set(t,n)}})),a)throw a}async _updateFeatures(e,t){const r=Array.from(e);if(0===r.length)return;const s=await this._applyEdits({updateFeatures:Array.from(e).map((e=>e.toGraphic()))},t);if(!s.updateFeatureResults||s.updateFeatureResults.length!==r.length)throw new i("Received malformed response from server while saving feature(s).");let a;if(s.updateFeatureResults.forEach(((e,t)=>{if(e.error){a=a||new i("Errors encountered when updating features.");const{primaryKey:s}=r[t];a.errors.set(s,new Error(`Failed to update feature with id ${s}. ${e.error.name} : ${e.error.message}`))}})),a)throw a}async _deleteFeatures(e,t){if(0===e.length)return;const r=await this._applyEdits({deleteFeatures:e.map((e=>({objectId:e})))},t);if(!r.deleteFeatureResults)throw new i("Received malformed response from server while saving feature(s).");let s;if(r.deleteFeatureResults.forEach(((t,r)=>{if(t.error){s=s||new i("Errors encountered when deleting features.");const a=e[r];s.errors.set(a,new Error(`Failed to delete feature with id ${a}. ${t.error.name} : ${t.error.message}`))}})),s)throw s}_serializeSublayer(e){return y(e)}async _applyEdits(e,t={}){const r=R(this.sublayer.layer,e),s=this.sublayer.layer.applyEdits(e,{globalIdUsed:r,returnServiceEditsOption:I(this.sublayer.layer)}),a=await p(s,t.cancelToken);if(!a)throw new i("Received malformed response from server while saving feature(s).");return a}_addDomainsToFields(){const e=this.sublayer.parent.subtypes.find((e=>e.code===this.sublayer.subtypeCode));if(e?.domains)for(const[t,r]of Object.entries(e.domains)){const e=this.sublayer.fields.find((e=>w(e.name,t)));e&&!e.domain&&(e.domain=r)}}};T=e([d],T);export{T as SubtypeSublayerExtension};const v="This schema property is read-only.";let z=class extends F{_fieldCollection;_readonlyTypesCollection;_typesCollection;get primaryKeyField(){return this._sublayerExtension.sublayer?.layer?.objectIdField}set primaryKeyField(e){throw new s(v)}get geometryType(){return this._sublayerExtension.sublayer?.layer?.geometryType}set geometryType(e){throw new s(v)}get displayField(){return this._sublayerExtension.sublayer?.layer?.displayField}set displayField(e){throw new s(v)}get typeIdField(){return this._sublayerExtension.sublayer?.layer?.subtypeField}set typeIdField(e){throw new s(v)}get types(){return this._readonlyTypesCollection}constructor(e){super(e),this._fieldCollection=this._createFieldCollection(),this._typesCollection=new t,this._readonlyTypesCollection=new h(this._typesCollection);const r=()=>this._sublayerExtension.sublayer?.subtypeCode,s=()=>{const e=this._sublayerExtension.layerExtension?._subtypes?.find((e=>e.id===r()));return!!e&&(this._typesCollection.add(e),!0)};if(this._sublayerExtension.layerExtension?._subtypes?.some((e=>e.id===r())))s();else{const e=this._sublayerExtension.watch("layerExtension._subtypes",(()=>{s()&&e.remove()}),!0)}this.notifyChange("_fields")}get _fields(){return this._fieldCollection}_createFieldCollection(){return new h(new x({parent:this._sublayerExtension,targetProperty:"sublayer",arrayProperty:"fields"}))}_getPropertyBindings(){return{primaryKeyField:"parent.objectIdField",geometryType:"parent.geometryType",spatialReference:"parent.spatialReference",displayField:"parent.displayField",typeIdField:"parent.typeIdField"}}};z=e([d],z);export{z as SubtypeSublayerSchema};let $=class extends j{get zoomScale(){const e="point"===this._layerExtension.schema.geometryType?this._layerExtension.sublayer.maxScale:void 0;return this._getSetting("zoomScale",e)}set zoomScale(e){this._setSetting("zoomScale",e)}};$=e([d],$);let A=class extends S{get _layerSupportsHideChildren(){return!1}get _esriLayer(){return this._extension.sublayer}get _listModePath(){return"sublayer.listMode"}get _supportsChildren(){return!1}};A=e([d],A);export class SubtypeSublayerRelationshipCollection extends c{get _sourceUrl(){const e=this._source.sublayer?.layer;if(e)return`${e.url}/${e.layerId}`}get _sourceLayerId(){const e=this._source.sublayer?.layer;return e?.layerId}_findRelatedSource(e){if(!this._source.layerExtension?.mapExtension||!this._source.sublayer||!this._sourceUrl)return;const t=this._sourceUrl.slice(0,this._sourceUrl.length-`${this._sourceLayerId}`.length-1),r=this._source.layerExtension.mapExtension.allLayerExtensions.initializedItems.find((r=>(b(r.layer)||f(r.layer))&&r.layer.url===t&&r.layer.layerId===e));return r||this._source.layerExtension.mapExtension.tableExtensions.initializedItems.find((r=>b(r.table)&&r.table.url===t&&r.table.layerId===e))}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createFeatureServices as e}from"@arcgis/core/rest/featureService/utils";import{FeatureSaveError as
|
|
1
|
+
import{createFeatureServices as e}from"@arcgis/core/rest/featureService/utils";import{FeatureSaveError as t}from"../../data/FeatureSaveError.js";import{getGdbVersion as r}from"../../utilities/_version.js";import{isFeatureLayerExtension as s,isSubtypeGroupLayerExtension as a,isSubtypeSublayerExtension as u}from"../../utilities/extensions.js";import{map as d}from"../../utilities/iterable.js";import{getGlobalIdField as o,isGlobalIdUsed as i}from"./layers.js";export async function applyEdits(l){const{addFeatures:c=[],updateFeatures:n=[],deleteFeatures:p=[]}=l,F=new Map,f=[],h=new WeakMap,m=(e,t)=>{const r=(e=>s(e.source)||a(e.source)?e.source.layer:u(e.source)?e.source.layerExtension.layer:e.source.table)(e);F.has(r)||F.set(r,{id:r.layerId,identifierFields:{globalIdField:o(r),objectIdField:r.objectIdField},addFeatures:[],updateFeatures:[],deleteFeatures:[]});const d=F.get(r),i=e.toGraphic();d[t].push(i),"addFeatures"===t&&(h.has(r)||h.set(r,[]),h.get(r).push(e))};c.forEach((e=>m(e,"addFeatures"))),n.forEach((e=>m(e,"updateFeatures"))),p.forEach((e=>m(e,"deleteFeatures")));const y=await e([...F.keys()]),g=await Promise.all(d(y.values(),(async({featureService:e,layers:t})=>{await e.load();const s=[];t.forEach((e=>{s.push(F.get(e))}));const a=e.applyEdits(s,{globalIdUsed:t.every((e=>i(e,F.get(e)))),gdbVersion:t[0].gdbVersion??r(t[0].customParameters)});return f.push((async()=>{const e=await a;for(const r of e){const e=t.find((e=>e.layerId===r.id));e&&(e.emit("edits",{deletedFeatures:r.deleteFeatureResults??[],updatedFeatures:r.updateFeatureResults??[],addedFeatures:r.addFeatureResults??[],deletedAttachments:[],updatedAttachments:[]}),(r.addFeatureResults??[]).forEach((({objectId:t,globalId:r,error:s},a)=>{if(s)return;const u=h.get(e)?.[a];if(u){const{primaryKeyField:s}=u.schema;u.attributes.set(s,t);const a=o(e);a&&r&&u.attributes.set(a,r)}})))}})),a}))),b=g?.flat().flatMap((e=>{const t=[];return e.addFeatureResults&&t.push(...e.addFeatureResults),e.deleteFeatureResults&&t.push(...e.deleteFeatureResults),e.updateFeatureResults&&t.push(...e.updateFeatureResults),t}))?.filter((e=>!!e?.error));if(b?.length){const e=new t("Errors encountered when applying edits.");throw b.forEach((t=>e.errors.set(t.id,t.error))),e}return await Promise.all(f.map((e=>e()))),g}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getGdbVersion=e=>e?.gdbversion??e?.gdbVersion;
|
package/version.d.ts
CHANGED
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version="45.
|
|
1
|
+
export const version="45.4.0";
|