@vertigis/arcgis-extensions 37.5.0 → 37.7.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.
Files changed (54) hide show
  1. package/data/FeatureSet.js +1 -1
  2. package/data/FeatureSourceBase.js +1 -1
  3. package/declarations/arcgis-js-api-extensions/index.d.ts +4 -0
  4. package/docs/html/assets/search.js +1 -1
  5. package/docs/html/functions/utilities__layers.basemapsAreEquivalent.html +1 -0
  6. package/docs/html/functions/utilities__layers.hasMmapLayer.html +1 -0
  7. package/docs/html/functions/utilities__layers.isBuildingComponentSublayer.html +1 -0
  8. package/docs/html/functions/utilities__layers.isBuildingGroupSublayer.html +1 -0
  9. package/docs/html/functions/utilities__layers.isBuildingSceneLayer.html +1 -0
  10. package/docs/html/functions/utilities__layers.isCSVLayer.html +1 -0
  11. package/docs/html/functions/utilities__layers.isElevationLayer.html +1 -0
  12. package/docs/html/functions/utilities__layers.isFeatureLayer.html +1 -0
  13. package/docs/html/functions/utilities__layers.isFeatureLayerBase.html +1 -0
  14. package/docs/html/functions/utilities__layers.isGeoJSONLayer.html +1 -0
  15. package/docs/html/functions/utilities__layers.isGeoRssLayer.html +1 -0
  16. package/docs/html/functions/utilities__layers.isGraphicsLayer.html +1 -0
  17. package/docs/html/functions/utilities__layers.isGroupLayer.html +1 -0
  18. package/docs/html/functions/utilities__layers.isImageryLayer.html +1 -0
  19. package/docs/html/functions/utilities__layers.isImageryTileLayer.html +1 -0
  20. package/docs/html/functions/utilities__layers.isIntegratedMeshLayer.html +1 -0
  21. package/docs/html/functions/utilities__layers.isKMLLayer.html +1 -0
  22. package/docs/html/functions/utilities__layers.isKMLSublayer.html +1 -0
  23. package/docs/html/functions/utilities__layers.isLayer.html +1 -0
  24. package/docs/html/functions/utilities__layers.isLayerWithLegendEnabledProperty.html +1 -0
  25. package/docs/html/functions/utilities__layers.isMapImageLayer.html +1 -0
  26. package/docs/html/functions/utilities__layers.isMapImageSublayer.html +1 -0
  27. package/docs/html/functions/utilities__layers.isOpenStreetMapLayer.html +1 -0
  28. package/docs/html/functions/utilities__layers.isPointCloudLayer.html +1 -0
  29. package/docs/html/functions/utilities__layers.isSceneLayer.html +1 -0
  30. package/docs/html/functions/utilities__layers.isStreamLayer.html +1 -0
  31. package/docs/html/functions/utilities__layers.isSublayer.html +643 -0
  32. package/docs/html/functions/utilities__layers.isSubtypeGroupLayer.html +1 -0
  33. package/docs/html/functions/utilities__layers.isSubtypeSublayer.html +1 -0
  34. package/docs/html/functions/utilities__layers.isTileLayer.html +1 -0
  35. package/docs/html/functions/utilities__layers.isTiledImageServiceLayer.html +1 -0
  36. package/docs/html/functions/utilities__layers.isTiledMapServiceLayer.html +1 -0
  37. package/docs/html/functions/utilities__layers.isTimeAwareLayer.html +1 -0
  38. package/docs/html/functions/utilities__layers.isVectorTileLayer.html +1 -0
  39. package/docs/html/functions/utilities__layers.isWMSLayer.html +1 -0
  40. package/docs/html/functions/utilities__layers.isWMSSublayer.html +1 -0
  41. package/docs/html/functions/utilities__layers.isWMTSLayer.html +1 -0
  42. package/docs/html/functions/utilities__layers.isWMTSSublayer.html +1 -0
  43. package/docs/html/functions/utilities__layers.isWebTileLayer.html +1 -0
  44. package/docs/html/functions/utilities__layers.layersAreEquivalent.html +1 -0
  45. package/docs/html/interfaces/utilities_arcade.RunArcadeExpressionParams.html +10 -2
  46. package/docs/html/modules/utilities__layers.html +2 -0
  47. package/docs/html/variables/version.version.html +1 -1
  48. package/package.json +1 -1
  49. package/utilities/_layers.d.ts +7 -0
  50. package/utilities/_layers.js +1 -1
  51. package/utilities/arcade.d.ts +5 -0
  52. package/utilities/arcade.js +1 -1
  53. package/version.d.ts +1 -1
  54. package/version.js +1 -1
@@ -1 +1 @@
1
- var FeatureSet_1;import{__decorate}from"tslib";import Collection from"@arcgis/core/core/Collection";import{generateId}from"../Entity.js";import{isFeature,ItemType}from"../ItemType.js";import{Observable}from"../support/Observable.js";import{assignProperties,filterJSONProperties,getDefaults,getSerializableProperties,serializable}from"../support/Serializable.js";import{ObservableMap}from"../utilities/ObservableMap.js";import{groupBy}from"../utilities/array.js";import{toArray,from,empty}from"../utilities/asyncIterable.js";import{compare,find}from"../utilities/iterable.js";import{getLogger}from"../utilities/log.js";import{watchEach}from"../utilities/watch.js";import{Feature}from"./Feature.js";import{FeatureSettings}from"./FeatureSettings.js";import{Schema}from"./Schema.js";const log=getLogger("feature-set");let FeatureSet=FeatureSet_1=class extends Observable{constructor(e){super(),this.settings=new FeatureSettings,this.schema=new Schema,this._rehydratingFeatureCount=0,this._rehydratingFeatures=new Collection,this._features=new ObservableMap,this.schema._featureSettings=this.settings,this.id=e?.id??generateId(),watchEach(this._rehydratingFeatures,"_featureHydrationStatus",((e,t,r,s)=>{if(this._rehydratingFeatureCount--,!this._rehydratingFeatureCount){const e=this._rehydratingFeatures.toArray();this.addMany(e),this.emit("feature-hydration-complete",e)}})),this.on("dehydrated-features-added",(async e=>{this._rehydratingFeatures.addMany(e);const t=groupBy(e,(e=>e.source)),r=groupBy(await toArray(from([...t.entries()].map((([e,t])=>{let r;try{r=e?.getFeatures(t.map((e=>e.primaryKey)).filter((e=>!!e)))??empty()}catch(t){r=empty(),log.error({error:t,message:`Failed to hydrate features from source '${e?.title??e?.id}`})}return r})))),(e=>e.source));[...t.entries()].forEach((([e,t])=>{const s=r.get(e);t.forEach((e=>{const t=s?.find((t=>t.primaryKey===e.primaryKey));t&&(e.geometry=t.geometry,[...t.attributes.entries()].forEach((([t,r])=>{e.attributes.set(t,r)}))),e._hydrationStatus=void 0}))}))})),this.assignProperties(e)}get size(){return this._features.size}get source(){return this._source}set source(e){this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.settings.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0)}get itemType(){return ItemType.FEATURE_SET}static async fromFeatureStream(e,t){const r=new FeatureSet_1(t);for await(const t of e)r.add(t);return r}on(e,t){return super.on(e,t)}assignProperties(e){assignProperties(this._getSerializableProperties(),this,e)}has(e){return this._features.has(e._key)}entries(){return[...this._features].map((([e,t])=>[t,t]))[Symbol.iterator]()}keys(){return this._features.values()}values(){return this._features.values()}toJSON(e="all"){return filterJSONProperties(this._getSerializableProperties(),this,e)}toItemUri(){return`item://${encodeURIComponent(ItemType.FEATURE_SET)}/${encodeURIComponent(this.id)}`}add(e){return this._add(e)}addMany(e){const t=[],r=[];for(const s of e){const e=this._features.get(s._key);s!==e&&(this._add(s,!1),t.push(s),e&&r.push(e))}return t.length&&(this.notifyChange("size"),this.emit("change",{added:t,removed:r,moved:[],target:this})),this}clear(){const e=Array.from(this.values());this._features.clear(),this.notifyChange("size"),this.emit("change",{added:[],removed:e,moved:[],target:this})}delete(e){return this._delete(e)}deleteMany(e){const t=[];for(const r of e){const e=this._features.get(r._key);this._delete(r,!1)&&t.push(e)}return t.length&&(this.notifyChange("size"),this.emit("change",{added:[],removed:t,moved:[],target:this})),!!t.length}forEach(e,t){this._features.forEach((t=>e(t,t,this)),t)}findById(e){return find(this,(t=>t.id===e))}findByPrimaryKey(e){return find(this,(t=>t.primaryKey===e))}getSerializableProperties(e="all"){return getSerializableProperties(this._getSerializableProperties(),e)}getDefaults(){return getDefaults(this._getSerializableProperties())}getDefault(e){return this.getDefaults()[e]}[(Symbol.toStringTag,Symbol.iterator)](){return this._features.values()[Symbol.iterator]()}_add(e,t=!0){const r=this._features.get(e._key);return r&&r!==e&&this._delete(r,!1),this._features.set(e._key,e),t&&r!==e&&(this.notifyChange("size"),this.emit("change",{added:[e],removed:r?[r]:[],moved:[],target:this})),this.source&&!e.source&&(e.source=this.source),e.schema.parent||(e.schema.parent=this.schema),e.settings.parent||(e.settings.parent=this.settings),this}_delete(e,t=!0){if(!this.has(e))return!1;const r=this._features.get(e._key);return this._features.delete(e._key),t&&(this.notifyChange("size"),this.emit("change",{added:[],removed:[r],moved:[],target:this})),e.schema.parent===this.schema&&(e.schema.parent=void 0),e.settings.parent===this.settings&&(e.settings.parent=void 0),!0}_getSerializableProperties(){return{id:["project"],features:{serializeModes:["project"],serialize:()=>[...this],deserialize:e=>{const t=[],r=[];compare(this._rehydratingFeatures.concat([...this]),e,{onNew:e=>{if(isFeature(e))"dehydrated"===e._hydrationStatus?(e._hydrationStatus="rehydrating",this._rehydratingFeatureCount++,t.push(e)):"rehydrating"===e._hydrationStatus?(this._rehydratingFeatureCount++,this._rehydratingFeatures.push(e)):(r.push(e),this.add(e));else{const t=new Feature(e);r.push(t),this.add(t)}},onMatch:(e,r)=>{isFeature(r)?"dehydrated"===e._hydrationStatus?(e._hydrationStatus="rehydrating",this._rehydratingFeatureCount++,t.push(e)):e!==r&&this.add(r):e.assignProperties(r)},onMissing:e=>{this.delete(e)},equals:(e,t)=>isFeature(t)?e._key===t._key:e.id===t.id}),t.length?this.emit("dehydrated-features-added",t):this._rehydratingFeatureCount||this.emit("feature-hydration-complete",r)}},title:["project"],source:[],schema:[],settings:[]}}};FeatureSet=FeatureSet_1=__decorate([serializable],FeatureSet);export{FeatureSet};
1
+ var FeatureSet_1;import{__decorate}from"tslib";import Collection from"@arcgis/core/core/Collection";import{generateId}from"../Entity.js";import{isFeature,ItemType}from"../ItemType.js";import{Observable}from"../support/Observable.js";import{assignProperties,filterJSONProperties,getDefaults,getSerializableProperties,serializable}from"../support/Serializable.js";import{ObservableMap}from"../utilities/ObservableMap.js";import{groupBy}from"../utilities/array.js";import{toArray,from,empty}from"../utilities/asyncIterable.js";import{compare,find}from"../utilities/iterable.js";import{getLogger}from"../utilities/log.js";import{watchEach}from"../utilities/watch.js";import{Feature}from"./Feature.js";import{FeatureSettings}from"./FeatureSettings.js";import{Schema}from"./Schema.js";const log=getLogger("feature-set");let FeatureSet=FeatureSet_1=class extends Observable{constructor(e){super(),this.settings=new FeatureSettings,this.schema=new Schema,this._rehydratingFeatureCount=0,this._rehydratingFeatures=new Collection,this._features=new ObservableMap,this.schema._featureSettings=this.settings,this.id=e?.id??generateId(),watchEach(this._rehydratingFeatures,"_featureHydrationStatus",((e,t,r,s)=>{if(this._rehydratingFeatureCount--,!this._rehydratingFeatureCount){const e=this._rehydratingFeatures.toArray();this.addMany(e),this.emit("feature-hydration-complete",e)}})),this.on("dehydrated-features-added",(async e=>{this._rehydratingFeatures.addMany(e);const t=groupBy(e,(e=>e.source)),r=groupBy(await toArray(from([...t.entries()].map((([e,t])=>{let r;try{r=e?.getFeatures(t.map((e=>e.primaryKey)).filter((e=>!!e)))??empty()}catch(t){r=empty(),log.error({error:t,message:`Failed to hydrate features from source '${e?.title??e?.id}`})}return r})))),(e=>e.source));[...t.entries()].forEach((([e,t])=>{const s=r.get(e);t.forEach((e=>{const t=s?.find((t=>t.primaryKey===e.primaryKey));t&&(e.geometry=t.geometry,[...t.attributes.entries()].forEach((([t,r])=>{e.attributes.set(t,r)}))),e._hydrationStatus=void 0}))}))})),this.assignProperties(e)}get size(){return this._features.size}get source(){return this._source}set source(e){this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.schema.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0)}get itemType(){return ItemType.FEATURE_SET}static async fromFeatureStream(e,t){const r=new FeatureSet_1(t);for await(const t of e)r.add(t);return r}on(e,t){return super.on(e,t)}assignProperties(e){assignProperties(this._getSerializableProperties(),this,e)}has(e){return this._features.has(e._key)}entries(){return[...this._features].map((([e,t])=>[t,t]))[Symbol.iterator]()}keys(){return this._features.values()}values(){return this._features.values()}toJSON(e="all"){return filterJSONProperties(this._getSerializableProperties(),this,e)}toItemUri(){return`item://${encodeURIComponent(ItemType.FEATURE_SET)}/${encodeURIComponent(this.id)}`}add(e){return this._add(e)}addMany(e){const t=[],r=[];for(const s of e){const e=this._features.get(s._key);s!==e&&(this._add(s,!1),t.push(s),e&&r.push(e))}return t.length&&(this.notifyChange("size"),this.emit("change",{added:t,removed:r,moved:[],target:this})),this}clear(){const e=Array.from(this.values());this._features.clear(),this.notifyChange("size"),this.emit("change",{added:[],removed:e,moved:[],target:this})}delete(e){return this._delete(e)}deleteMany(e){const t=[];for(const r of e){const e=this._features.get(r._key);this._delete(r,!1)&&t.push(e)}return t.length&&(this.notifyChange("size"),this.emit("change",{added:[],removed:t,moved:[],target:this})),!!t.length}forEach(e,t){this._features.forEach((t=>e(t,t,this)),t)}findById(e){return find(this,(t=>t.id===e))}findByPrimaryKey(e){return find(this,(t=>t.primaryKey===e))}getSerializableProperties(e="all"){return getSerializableProperties(this._getSerializableProperties(),e)}getDefaults(){return getDefaults(this._getSerializableProperties())}getDefault(e){return this.getDefaults()[e]}[(Symbol.toStringTag,Symbol.iterator)](){return this._features.values()[Symbol.iterator]()}_add(e,t=!0){const r=this._features.get(e._key);return r&&r!==e&&this._delete(r,!1),this._features.set(e._key,e),t&&r!==e&&(this.notifyChange("size"),this.emit("change",{added:[e],removed:r?[r]:[],moved:[],target:this})),this.source&&!e.source&&(e.source=this.source),e.schema.parent||(e.schema.parent=this.schema),e.settings.parent||(e.settings.parent=this.settings),this}_delete(e,t=!0){if(!this.has(e))return!1;const r=this._features.get(e._key);return this._features.delete(e._key),t&&(this.notifyChange("size"),this.emit("change",{added:[],removed:[r],moved:[],target:this})),e.schema.parent===this.schema&&(e.schema.parent=void 0),e.settings.parent===this.settings&&(e.settings.parent=void 0),!0}_getSerializableProperties(){return{id:["project"],features:{serializeModes:["project"],serialize:()=>[...this],deserialize:e=>{const t=[],r=[];compare(this._rehydratingFeatures.concat([...this]),e,{onNew:e=>{if(isFeature(e))"dehydrated"===e._hydrationStatus?(e._hydrationStatus="rehydrating",this._rehydratingFeatureCount++,t.push(e)):"rehydrating"===e._hydrationStatus?(this._rehydratingFeatureCount++,this._rehydratingFeatures.push(e)):(r.push(e),this.add(e));else{const t=new Feature(e);r.push(t),this.add(t)}},onMatch:(e,r)=>{isFeature(r)?"dehydrated"===e._hydrationStatus?(e._hydrationStatus="rehydrating",this._rehydratingFeatureCount++,t.push(e)):e!==r&&this.add(r):e.assignProperties(r)},onMissing:e=>{this.delete(e)},equals:(e,t)=>isFeature(t)?e._key===t._key:e.id===t.id}),t.length?this.emit("dehydrated-features-added",t):this._rehydratingFeatureCount||this.emit("feature-hydration-complete",r)}},title:["project"],source:[],schema:[],settings:[]}}};FeatureSet=FeatureSet_1=__decorate([serializable],FeatureSet);export{FeatureSet};
@@ -1 +1 @@
1
- import TextContent from"@arcgis/core/popup/content/TextContent.js";import{ArgumentError}from"../ArgumentError.js";import{EntityBase}from"../Entity.js";import{Hyperlink}from"../Hyperlink.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{isMenu,isRelationship}from"../ItemType.js";import{NotFoundError}from"../NotFoundError.js";import{FeatureReadOptions}from"../data/FeatureSource.js";import{Menu}from"../menus/Menu.js";import{initializeCollection}from"../support/InitializableBase.js";import{CollectionProxy}from"../utilities/CollectionProxy.js";import{first}from"../utilities/asyncIterable.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{getLogger}from"../utilities/log.js";import{FeatureSettings}from"./FeatureSettings.js";import{Schema}from"./Schema.js";import{TaskSettings}from"./TaskSettings.js";import{Relationship}from"./_Relationship.js";const ERR_GET_FEATURES_NOT_SUPPORTED="Querying features is not supported.",ERR_ADD_FEATURES_NOT_SUPPORTED="Adding features is not supported.",ERR_ADD_ATTACHMENTS_NOT_SUPPORTED="Adding attachments is not supported.",ERR_DELETE_ATTACHMENTS_NOT_SUPPORTED="Deleting attachments is not supported.",ERR_UPDATE_FEATURES_NOT_SUPPORTED="Updating features is not supported.",ERR_DELETE_FEATURES_NOT_SUPPORTED="Deleting features is not supported.",DEFAULT_CAPABILITIES=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsAttachmentEditing:!1}),log=getLogger("FeatureSourceBase");export class FeatureSourceBase extends EntityBase{constructor(t){super(t),this.featureSettings=this._createAndSetupFeatureSettings(),this.taskSettings=this._createTaskSettings(),this.schema=this._createAndSetupSchema(),this.relationships=this._createRelationships(),this.hyperlinks=this._createHyperlinks()}get featureActions(){return this._featureActions}set featureActions(t){this._featureActions=t,t&&this.isInitialized&&!t.isInitialized&&(async()=>{try{await t.initialize()}catch(t){t instanceof Error&&log.error({message:"An error occurred while initializing feature action menu.",error:t})}})()}get capabilities(){return this._capabilities()}getFullExtent(){}async getAttachments(t){return checkArg("feature",t).isNotMissing(),await this.initialize(),this._getAttachments(t)}async addAttachment(t,e){if(checkArg("feature",t).isNotMissing(),checkArg("attachment",e).isNotMissing(),t.source&&t.source!==this)throw new ArgumentError("feature",`Cannot add an attachment to a feature not of this source (${this.title??this.id})`);return await this.initialize(),this._addAttachment(t,e)}async deleteAttachments(t,e){if(checkArg("feature",t).isNotMissing(),checkArg("attachmentIds",e).isNotMissing(),t.source&&t.source!==this)throw new ArgumentError("feature",`Cannot delete attachments from a feature not of this source (${this.title??this.id})`);await this.initialize(),await this._deleteAttachments(t,e)}async getFeature(t,e){checkArg("id",t).isNotMissing();const i=this.getFeatures([t],e),s=await first(i);if(!s)throw new NotFoundError("No feature exists with ID '{0}'.",t);return s}getFeatures(t,e){checkArg("ids",t).isNotMissing();const i=this;return async function*(){await i.initialize(),yield*i._getFeatures(t,{...FeatureReadOptions.DEFAULTS,...FeatureReadOptions.fromFeatureSource(i),...e})}()}async addFeature(t,e){checkArg("feature",t).isNotMissing(),await this.addFeatures([t])}async addFeatures(t,e){if(checkArg("features",t).isNotMissing(),await this.initialize(),!this.capabilities.supportsAdd)throw new InvalidOperationError(ERR_ADD_FEATURES_NOT_SUPPORTED);await this._addFeatures(t,e)}async updateFeature(t,e){checkArg("feature",t).isNotMissing(),await this.updateFeatures([t])}async updateFeatures(t,e){if(checkArg("features",t).isNotMissing(),await this.initialize(),!this.capabilities.supportsUpdate)throw new InvalidOperationError(ERR_UPDATE_FEATURES_NOT_SUPPORTED);await this._updateFeatures(t,e)}async deleteFeature(t,e){checkArg("feature",t).isNotMissing(),await this.deleteFeatures([t])}async deleteFeatures(t,e){if(checkArg("features",t).isNotMissing(),await this.initialize(),!this.capabilities.supportsDelete)throw new InvalidOperationError(ERR_DELETE_FEATURES_NOT_SUPPORTED);const i=[];for(const e of t)i.push("string"==typeof e?e:e.primaryKey);await this._deleteFeatures(i,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),featureSettings:{serializeModes:["initial"],isDefault:t=>{if(!t)return!0;if(t.constructor===Object){if(!Object.keys(t).length)return!0}return!1}},taskSettings:"initial",onAddFeature:"initial",onEditFeature:"initial",schema:"initial",relationships:{serializeModes:["initial"],serialize:t=>this.relationships?this.relationships.filter((t=>"ArcGISRelationship"!==t.relationshipType)).map((e=>e.toJSON(t))).toArray():[],deserialize:t=>{compare(this.relationships,t,{onNew:t=>{isRelationship(t)?this.relationships.add(t):this.relationships.add(Relationship.create(t))},onMatch:(t,e)=>{isRelationship(t)&&t.assignProperties({title:e.title})},onMissing:t=>{"ArcGISRelationship"!==t.relationshipType&&this.relationships.remove(t)},equals:(t,e)=>t.id===e.id})},default:[]},hyperlinks:{serialize:!1,deserialize:t=>{this.hyperlinks.removeAll(),this.hyperlinks.addMany(t.map((t=>t instanceof Hyperlink?t:new Hyperlink(t))))}},featureActions:{serializeModes:["initial"],deserialize:t=>{t?isMenu(t)?this.featureActions=t:this.featureActions?this.featureActions.assignProperties(t):this.featureActions=Menu.create(t):this.featureActions=void 0}}}}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.schema.fieldExtensions}async _onInitialize(){await super._onInitialize(),this.featureActions&&await this.featureActions.initialize()}async _postInitialize(){await super._postInitialize(),this.featureSettings.popupTemplate||(this.featureSettings.popupTemplate=this.schema.createPopupTemplate(),this.featureSettings._isDefaultPopupTemplate=!0);const{popupTemplate:t}=this.featureSettings;"function"==typeof t.content&&(t.content=t.content()),t.content=await t.content,"string"==typeof t.content&&(t.content=[new TextContent({text:t.content})]),!t.title&&this.schema.displayField&&(t.title=`{${this.schema.displayField}}`),await initializeCollection(this.featureSettings.popupContentExtensions,{target:this,onInitializeWarning:t=>this.emit("initializeWarning",t)})}_createSchema(){return new Schema}_createFeatureSettings(){return new FeatureSettings}_createTaskSettings(){return new TaskSettings}_createRelationships(){return new RelationshipCollection(this)}_createHyperlinks(){return new Collection}async _getAttachments(t){return[]}async _addAttachment(t,e){throw new InvalidOperationError(ERR_ADD_ATTACHMENTS_NOT_SUPPORTED)}async _deleteAttachments(t,e){throw new InvalidOperationError(ERR_DELETE_ATTACHMENTS_NOT_SUPPORTED)}_getFeatures(t,e){const{primaryKeyField:i}=this.schema;if(this.queryService&&i){const s=t.map((t=>`${i} = ${t}`)).join(" OR ");return this.queryService.query(this,s,e)}throw new InvalidOperationError(ERR_GET_FEATURES_NOT_SUPPORTED)}_addFeatures(t,e){throw new InvalidOperationError(ERR_ADD_FEATURES_NOT_SUPPORTED)}_updateFeatures(t,e){throw new InvalidOperationError(ERR_UPDATE_FEATURES_NOT_SUPPORTED)}_deleteFeatures(t,e){throw new InvalidOperationError(ERR_DELETE_FEATURES_NOT_SUPPORTED)}_capabilities(){return DEFAULT_CAPABILITIES}_isRelationship(t){return"function"==typeof t.getRelatedFeatures}_createAndSetupSchema(){const t=this._createSchema();return t._featureSettings=this.featureSettings,t}_createAndSetupFeatureSettings(){const t=this._createFeatureSettings();return t._setFeatureSource(this),t}}export class RelationshipCollection extends CollectionProxy{constructor(t){super(new Collection),this._source=t}add(t,e){checkArg("relationship",t).isNotMissing(),t.source&&t.source.relationships.remove(t),isRelationship(t)&&t._setSource(this._source),super.add(t,e)}removeAt(t){const e=super.removeAt(t);return isRelationship(e)&&e._setSource(void 0),e}}
1
+ import TextContent from"@arcgis/core/popup/content/TextContent.js";import{ArgumentError}from"../ArgumentError.js";import{EntityBase}from"../Entity.js";import{Hyperlink}from"../Hyperlink.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{isMenu,isRelationship}from"../ItemType.js";import{NotFoundError}from"../NotFoundError.js";import{FeatureReadOptions}from"../data/FeatureSource.js";import{Menu}from"../menus/Menu.js";import{initializeCollection}from"../support/InitializableBase.js";import{CollectionProxy}from"../utilities/CollectionProxy.js";import{first}from"../utilities/asyncIterable.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{getLogger}from"../utilities/log.js";import{FeatureSettings}from"./FeatureSettings.js";import{Schema}from"./Schema.js";import{TaskSettings}from"./TaskSettings.js";import{Relationship}from"./_Relationship.js";const ERR_GET_FEATURES_NOT_SUPPORTED="Querying features is not supported.",ERR_ADD_FEATURES_NOT_SUPPORTED="Adding features is not supported.",ERR_ADD_ATTACHMENTS_NOT_SUPPORTED="Adding attachments is not supported.",ERR_DELETE_ATTACHMENTS_NOT_SUPPORTED="Deleting attachments is not supported.",ERR_UPDATE_FEATURES_NOT_SUPPORTED="Updating features is not supported.",ERR_DELETE_FEATURES_NOT_SUPPORTED="Deleting features is not supported.",DEFAULT_CAPABILITIES=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsAttachmentEditing:!1}),log=getLogger("FeatureSourceBase");export class FeatureSourceBase extends EntityBase{constructor(t){super(t),this.featureSettings=this._createAndSetupFeatureSettings(),this.taskSettings=this._createTaskSettings(),this.schema=this._createAndSetupSchema(),this.relationships=this._createRelationships(),this.hyperlinks=this._createHyperlinks()}get featureActions(){return this._featureActions}set featureActions(t){this._featureActions=t,t&&this.isInitialized&&!t.isInitialized&&(async()=>{try{await t.initialize()}catch(t){t instanceof Error&&log.error({message:"An error occurred while initializing feature action menu.",error:t})}})()}get capabilities(){return this._capabilities()}getFullExtent(){}async getAttachments(t){return checkArg("feature",t).isNotMissing(),await this.initialize(),this._getAttachments(t)}async addAttachment(t,e){if(checkArg("feature",t).isNotMissing(),checkArg("attachment",e).isNotMissing(),t.source&&t.source!==this)throw new ArgumentError("feature",`Cannot add an attachment to a feature not of this source (${this.title??this.id})`);return await this.initialize(),this._addAttachment(t,e)}async deleteAttachments(t,e){if(checkArg("feature",t).isNotMissing(),checkArg("attachmentIds",e).isNotMissing(),t.source&&t.source!==this)throw new ArgumentError("feature",`Cannot delete attachments from a feature not of this source (${this.title??this.id})`);await this.initialize(),await this._deleteAttachments(t,e)}async getFeature(t,e){checkArg("id",t).isNotMissing();const i=this.getFeatures([t],e),s=await first(i);if(!s)throw new NotFoundError("No feature exists with ID '{0}'.",t);return s}getFeatures(t,e){checkArg("ids",t).isNotMissing();const i=this;return async function*(){await i.initialize(),yield*i._getFeatures(t,{...FeatureReadOptions.DEFAULTS,...FeatureReadOptions.fromFeatureSource(i),...e})}()}async addFeature(t,e){checkArg("feature",t).isNotMissing(),await this.addFeatures([t])}async addFeatures(t,e){if(checkArg("features",t).isNotMissing(),await this.initialize(),!this.capabilities.supportsAdd)throw new InvalidOperationError(ERR_ADD_FEATURES_NOT_SUPPORTED);await this._addFeatures(t,e)}async updateFeature(t,e){checkArg("feature",t).isNotMissing(),await this.updateFeatures([t])}async updateFeatures(t,e){if(checkArg("features",t).isNotMissing(),await this.initialize(),!this.capabilities.supportsUpdate)throw new InvalidOperationError(ERR_UPDATE_FEATURES_NOT_SUPPORTED);await this._updateFeatures(t,e)}async deleteFeature(t,e){checkArg("feature",t).isNotMissing(),await this.deleteFeatures([t])}async deleteFeatures(t,e){if(checkArg("features",t).isNotMissing(),await this.initialize(),!this.capabilities.supportsDelete)throw new InvalidOperationError(ERR_DELETE_FEATURES_NOT_SUPPORTED);const i=[];for(const e of t)i.push("string"==typeof e?e:e.primaryKey);await this._deleteFeatures(i,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),featureSettings:{serializeModes:["initial"],isDefault:t=>{if(!t)return!0;if(t.constructor===Object){if(!Object.keys(t).length)return!0}return!1}},taskSettings:"initial",onAddFeature:"initial",onEditFeature:"initial",schema:"initial",relationships:{serializeModes:["initial"],serialize:t=>this.relationships?this.relationships.filter((t=>"ArcGISRelationship"!==t.relationshipType)).toArray():[],deserialize:t=>{compare(this.relationships,t,{onNew:t=>{isRelationship(t)?this.relationships.add(t):this.relationships.add(Relationship.create(t))},onMatch:(t,e)=>{isRelationship(t)&&t.assignProperties({title:e.title})},onMissing:t=>{"ArcGISRelationship"!==t.relationshipType&&this.relationships.remove(t)},equals:(t,e)=>t.id===e.id})},default:[]},hyperlinks:{serialize:!1,deserialize:t=>{this.hyperlinks.removeAll(),this.hyperlinks.addMany(t.map((t=>t instanceof Hyperlink?t:new Hyperlink(t))))}},featureActions:{serializeModes:["initial"],deserialize:t=>{t?isMenu(t)?this.featureActions=t:this.featureActions?this.featureActions.assignProperties(t):this.featureActions=Menu.create(t):this.featureActions=void 0}}}}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.schema.fieldExtensions}async _onInitialize(){await super._onInitialize(),this.featureActions&&await this.featureActions.initialize()}async _postInitialize(){await super._postInitialize(),this.featureSettings.popupTemplate||(this.featureSettings.popupTemplate=this.schema.createPopupTemplate(),this.featureSettings._isDefaultPopupTemplate=!0);const{popupTemplate:t}=this.featureSettings;"function"==typeof t.content&&(t.content=t.content()),t.content=await t.content,"string"==typeof t.content&&(t.content=[new TextContent({text:t.content})]),!t.title&&this.schema.displayField&&(t.title=`{${this.schema.displayField}}`),await initializeCollection(this.featureSettings.popupContentExtensions,{target:this,onInitializeWarning:t=>this.emit("initializeWarning",t)})}_createSchema(){return new Schema}_createFeatureSettings(){return new FeatureSettings}_createTaskSettings(){return new TaskSettings}_createRelationships(){return new RelationshipCollection(this)}_createHyperlinks(){return new Collection}async _getAttachments(t){return[]}async _addAttachment(t,e){throw new InvalidOperationError(ERR_ADD_ATTACHMENTS_NOT_SUPPORTED)}async _deleteAttachments(t,e){throw new InvalidOperationError(ERR_DELETE_ATTACHMENTS_NOT_SUPPORTED)}_getFeatures(t,e){const{primaryKeyField:i}=this.schema;if(this.queryService&&i){const s=t.map((t=>`${i} = ${t}`)).join(" OR ");return this.queryService.query(this,s,e)}throw new InvalidOperationError(ERR_GET_FEATURES_NOT_SUPPORTED)}_addFeatures(t,e){throw new InvalidOperationError(ERR_ADD_FEATURES_NOT_SUPPORTED)}_updateFeatures(t,e){throw new InvalidOperationError(ERR_UPDATE_FEATURES_NOT_SUPPORTED)}_deleteFeatures(t,e){throw new InvalidOperationError(ERR_DELETE_FEATURES_NOT_SUPPORTED)}_capabilities(){return DEFAULT_CAPABILITIES}_isRelationship(t){return"function"==typeof t.getRelatedFeatures}_createAndSetupSchema(){const t=this._createSchema();return t._featureSettings=this.featureSettings,t}_createAndSetupFeatureSettings(){const t=this._createFeatureSettings();return t._setFeatureSource(this),t}}export class RelationshipCollection extends CollectionProxy{constructor(t){super(new Collection),this._source=t}add(t,e){checkArg("relationship",t).isNotMissing(),t.source&&t.source.relationships.remove(t),isRelationship(t)&&t._setSource(this._source),super.add(t,e)}removeAt(t){const e=super.removeAt(t);return isRelationship(e)&&e._setSource(void 0),e}}
@@ -153,6 +153,7 @@ declare module "@arcgis/core/arcade/Feature" {
153
153
 
154
154
  interface FeatureConstructor {
155
155
  new (): Feature;
156
+ createFromGraphic(graphic: __esri.Graphic): Feature;
156
157
  }
157
158
 
158
159
  const Feature: FeatureConstructor;
@@ -162,6 +163,8 @@ declare module "@arcgis/core/arcade/Feature" {
162
163
  declare module "@arcgis/core/arcade/Dictionary" {
163
164
  interface Dictionary {
164
165
  attributes: any;
166
+ immutable: boolean;
167
+ setField(key: string, value: unknown);
165
168
  }
166
169
 
167
170
  interface DictionaryProperties {
@@ -170,6 +173,7 @@ declare module "@arcgis/core/arcade/Dictionary" {
170
173
 
171
174
  interface DictionaryConstructor {
172
175
  new (properties?: DictionaryProperties): Dictionary;
176
+ convertObjectToArcadeDictionary(object: Object): Dictionary;
173
177
  }
174
178
 
175
179
  const Dictionary: DictionaryConstructor;