@vertigis/arcgis-extensions 37.7.0 → 38.0.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/AppConfig.schema.json +24 -11
- package/data/Feature.js +1 -1
- package/data/FeatureList.d.ts +1 -1
- package/data/FeatureList.js +1 -1
- package/data/FeatureSettings.js +1 -1
- package/data/FeatureSourceBase.d.ts +1 -1
- package/data/FeatureSourceBase.js +1 -1
- package/data/PopupContentExtension.js +1 -1
- package/data/Schema.js +1 -1
- package/declarations/arcgis-js-api-extensions/index.d.ts +12 -10
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/data_FeatureList.FeatureList.html +8 -8
- package/docs/html/classes/data_FeatureSourceBase.RelationshipCollection.html +8 -8
- package/docs/html/classes/data_FeatureStream.FeatureStream.html +1 -1
- package/docs/html/classes/mapping_ArcGISSublayerExtension.ArcGISSublayerRelationshipCollection.html +8 -8
- package/docs/html/classes/mapping_GroupLayerExtension.GroupLayerExtensionCollection.html +8 -8
- package/docs/html/classes/mapping_SubtypeGroupLayerExtension.SubtypeGroupLayerRelationshipCollection.html +8 -8
- package/docs/html/classes/mapping_SubtypeSublayerExtension.SubtypeSublayerRelationshipCollection.html +8 -8
- package/docs/html/classes/mapping__SublayerExtension.SubSublayerExtensionCollection.html +8 -8
- package/docs/html/classes/mapping_support_ArrayWrappedCollection.ArrayWrappedCollection.html +8 -8
- package/docs/html/classes/mapping_support__LayerExtensionCollection.LayerExtensionCollectionBase.html +8 -8
- package/docs/html/classes/mapping_support__SublayerExtensionCollection.SublayerExtensionCollectionBase.html +8 -8
- package/docs/html/classes/support_InitializableCollectionProxy.InitializableCollectionProxy.html +8 -8
- package/docs/html/classes/support_ReadOnlyInitializableCollection.ReadOnlyInitializableCollection.html +8 -8
- package/docs/html/classes/support__ArcGISRelationshipCollection.ArcGISRelationshipCollection.html +8 -8
- package/docs/html/classes/utilities_CollectionProxy.CollectionProxy.html +8 -8
- package/docs/html/classes/utilities_CopyOnWriteCollection.CopyOnWriteCollection.html +8 -8
- package/docs/html/classes/utilities_MapTransformCollection.MapTransformCollection.html +8 -8
- package/docs/html/classes/utilities_ReadOnlyCollection.ReadOnlyCollection.html +8 -8
- package/docs/html/classes/utilities_asyncIterable.AsyncQueue.html +1 -1
- package/docs/html/functions/portal_ElevationInfo.ElevationInfo.fromEsriApiElevationInfo.html +2 -2
- package/docs/html/functions/portal_Lighting.Lighting.fromEsriApiLighting.html +2 -2
- package/docs/html/functions/utilities_esri.getAllFieldInfos.html +1 -0
- package/docs/html/functions/utilities_esri.getAllReferencedFieldNames.html +1 -0
- package/docs/html/functions/utilities_esri.isAttachmentsContent.html +1 -0
- package/docs/html/functions/utilities_esri.isCodedValueDomain.html +1 -0
- package/docs/html/functions/utilities_esri.isColor.html +1 -0
- package/docs/html/functions/utilities_esri.isCustomContent.html +1 -0
- package/docs/html/functions/utilities_esri.isEsriObject.html +1 -0
- package/docs/html/functions/utilities_esri.isExpressionContent.html +1 -0
- package/docs/html/functions/utilities_esri.isFeatureSet.html +1 -0
- package/docs/html/functions/utilities_esri.isFeatureType.html +1 -0
- package/docs/html/functions/utilities_esri.isField.html +1 -0
- package/docs/html/functions/utilities_esri.isFieldsContent.html +1 -0
- package/docs/html/functions/utilities_esri.isGraphic.html +1 -0
- package/docs/html/functions/utilities_esri.isImageMediaInfo.html +1 -0
- package/docs/html/functions/utilities_esri.isMediaContent.html +1 -0
- package/docs/html/functions/utilities_esri.isPopupContent.html +1 -0
- package/docs/html/functions/utilities_esri.isPopupTemplate.html +1 -0
- package/docs/html/functions/utilities_esri.isPortalItem.html +1 -0
- package/docs/html/functions/utilities_esri.isRelationshipContent.html +626 -0
- package/docs/html/functions/utilities_esri.isSpatialReference.html +1 -0
- package/docs/html/functions/utilities_esri.isTextContent.html +1 -0
- package/docs/html/functions/utilities_esri.isViewpoint.html +1 -0
- package/docs/html/functions/utilities_esri.load.html +1 -0
- package/docs/html/functions/utilities_esri.ready.html +1 -0
- package/docs/html/interfaces/data_PopupContentExtension.ContentProperties.html +33 -3
- package/docs/html/interfaces/data_support_attachments.AttachmentEnabledLayer.html +1 -13
- package/docs/html/interfaces/portal_PopupInfo.PopupElement.html +30 -3
- package/docs/html/interfaces/portal_SubtypeGroupLayer.SubtypeGroupLayer-1.html +1 -1
- package/docs/html/interfaces/portal_SubtypeGroupLayer.SubtypeSubtypeGroupLayer.html +1 -1
- package/docs/html/interfaces/portal_WMSLayer.WMSLayer-1.html +1 -1
- package/docs/html/modules/utilities_esri.html +2 -0
- package/docs/html/types/portal_PopupInfo.PopupElementType.html +1 -1
- package/docs/html/types/portal__LayerBase.LayerType.html +1 -1
- package/docs/html/types/support_esri.FeatureLayerElevationInfo.html +1 -1
- package/docs/html/variables/version.version.html +1 -1
- package/mapping/BasemapExtension.js +1 -1
- package/mapping/BuildingGroupSublayerExtension.js +1 -1
- package/mapping/BuildingSceneLayerExtension.js +1 -1
- package/mapping/GroundExtension.js +1 -1
- package/mapping/GroupLayerExtension.d.ts +1 -1
- package/mapping/GroupLayerExtension.js +1 -1
- package/mapping/ImageryLayerExtension.js +1 -1
- package/mapping/KMLLayerExtension.js +1 -1
- package/mapping/KMLSublayerExtension.js +1 -1
- package/mapping/MapExtension.js +1 -1
- package/mapping/SubtypeGroupLayerExtension.js +1 -1
- package/mapping/SubtypeSublayerExtension.js +1 -1
- package/mapping/WMSLayerExtension.js +1 -1
- package/mapping/WMSSublayerExtension.js +1 -1
- package/mapping/WMTSLayerExtension.js +1 -1
- package/mapping/_LayerExtension.js +1 -1
- package/mapping/_SublayerExtension.d.ts +1 -1
- package/mapping/_SublayerExtension.js +1 -1
- package/mapping/support/ArrayWrappedCollection.d.ts +1 -1
- package/mapping/support/ArrayWrappedCollection.js +1 -1
- package/mapping/support/DefaultLayerExtensionFactory.js +1 -1
- package/mapping/support/_LayerExtensionCollection.d.ts +2 -2
- package/mapping/support/_LayerExtensionCollection.js +1 -1
- package/mapping/support/_SublayerExtensionCollection.d.ts +2 -2
- package/mapping/support/_SublayerExtensionCollection.js +1 -1
- package/menus/Menu.js +1 -1
- package/package.json +3 -3
- package/portal/LayerBase.js +1 -1
- package/portal/PopupInfo.d.ts +22 -4
- package/portal/PopupInfo.js +1 -1
- package/portal/SubtypeGroupLayer.d.ts +2 -2
- package/portal/SubtypeGroupLayer.js +1 -1
- package/portal/SubtypeSublayer.js +1 -1
- package/portal/WMSLayer.d.ts +1 -1
- package/portal/WMSLayer.js +1 -1
- package/portal/_LayerBase.d.ts +1 -1
- package/support/esri.d.ts +1 -1
- package/tasks/identify/CSVLayerClientSideQueryIdentifyProvider.js +1 -1
- package/tasks/identify/ImageryLayerIdentifyProvider.js +1 -1
- package/utilities/CollectionProxy.d.ts +4 -4
- package/utilities/CollectionProxy.js +1 -1
- package/utilities/CopyOnWriteCollection.d.ts +2 -2
- package/utilities/CopyOnWriteCollection.js +1 -1
- package/utilities/ReadOnlyCollection.d.ts +3 -4
- package/utilities/esri.d.ts +7 -0
- package/utilities/esri.js +1 -1
- package/utilities/extensions.js +1 -1
- package/utilities/geometry.js +1 -1
- package/utilities/symbol.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/AppConfig.schema.json
CHANGED
|
@@ -388,7 +388,6 @@
|
|
|
388
388
|
],
|
|
389
389
|
"type": "object"
|
|
390
390
|
},
|
|
391
|
-
"Chai.Assertion": {},
|
|
392
391
|
"ContentProperties": {
|
|
393
392
|
"description": "Properties that extend the ArcGis portal representation of a PopupContent.",
|
|
394
393
|
"properties": {
|
|
@@ -403,8 +402,12 @@
|
|
|
403
402
|
"description": "An optional string value describing the element in detail. This property\ndoes not apply when the type is text or expression.",
|
|
404
403
|
"type": "string"
|
|
405
404
|
},
|
|
405
|
+
"displayCount": {
|
|
406
|
+
"description": "This property applies to elements of type relationship. An integer that\nindicates the maximum number of records to display.",
|
|
407
|
+
"type": "number"
|
|
408
|
+
},
|
|
406
409
|
"displayType": {
|
|
407
|
-
"description": "This property applies to elements of type attachments. A
|
|
410
|
+
"description": "This property applies to elements of type attachments and relationship. A\nstring value indicating how to display the attachment. Possible values\nare, 'preview', and 'list' for attachments types, and 'list' for\nrelationship types. If list is specified, attachments show as links.",
|
|
408
411
|
"type": "string"
|
|
409
412
|
},
|
|
410
413
|
"expressionInfo": {
|
|
@@ -425,6 +428,17 @@
|
|
|
425
428
|
},
|
|
426
429
|
"type": "array"
|
|
427
430
|
},
|
|
431
|
+
"orderByFields": {
|
|
432
|
+
"description": "This property applies to elements of type relationship. Array of\norderByFields objects indicating the field display order for the related\nrecords and whether they should be sorted in ascending 'asc' or\ndescending 'desc' order.",
|
|
433
|
+
"items": {
|
|
434
|
+
"$ref": "#/definitions/esri.webmap.PopupInfo.OrderByFields"
|
|
435
|
+
},
|
|
436
|
+
"type": "array"
|
|
437
|
+
},
|
|
438
|
+
"relationshipId": {
|
|
439
|
+
"description": "This property applies to elements of type relationship. The id of the\nrelationship as defined in the feature layer definition.",
|
|
440
|
+
"type": "number"
|
|
441
|
+
},
|
|
428
442
|
"text": {
|
|
429
443
|
"description": "This property applies to elements of type text. This is string value\nindicating the text to be displayed within the popupElement. If no text\nproperty is provided, the popupElement will display whatever is specified\nin the popupInfo.description property.",
|
|
430
444
|
"type": "string"
|
|
@@ -892,7 +906,6 @@
|
|
|
892
906
|
},
|
|
893
907
|
"type": "object"
|
|
894
908
|
},
|
|
895
|
-
"Function": {},
|
|
896
909
|
"GeocoderProperties": {
|
|
897
910
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
898
911
|
"definitions": {},
|
|
@@ -3160,6 +3173,10 @@
|
|
|
3160
3173
|
],
|
|
3161
3174
|
"type": "string"
|
|
3162
3175
|
},
|
|
3176
|
+
"itemPageUrl": {
|
|
3177
|
+
"description": "The URL to the [Item page](https://doc.arcgis.com/en/arcgis-online/manage-data/item-details.htm) on the portal.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#itemPageUrl)",
|
|
3178
|
+
"type": "string"
|
|
3179
|
+
},
|
|
3163
3180
|
"itemUrl": {
|
|
3164
3181
|
"description": "The URL to the item.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#itemUrl)",
|
|
3165
3182
|
"type": "string"
|
|
@@ -3295,6 +3312,7 @@
|
|
|
3295
3312
|
"initialized",
|
|
3296
3313
|
"isLayer",
|
|
3297
3314
|
"itemControl",
|
|
3315
|
+
"itemPageUrl",
|
|
3298
3316
|
"itemUrl",
|
|
3299
3317
|
"licenseInfo",
|
|
3300
3318
|
"loadError",
|
|
@@ -3324,9 +3342,6 @@
|
|
|
3324
3342
|
},
|
|
3325
3343
|
"esri.PortalItemApplicationProxies": {
|
|
3326
3344
|
"properties": {
|
|
3327
|
-
"constructor": {
|
|
3328
|
-
"$ref": "#/definitions/Function"
|
|
3329
|
-
},
|
|
3330
3345
|
"proxyId": {
|
|
3331
3346
|
"description": "The proxy ID registered in ArcGIS Online or ArcGIS Enterprise Portal.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#applicationProxies)",
|
|
3332
3347
|
"type": "string"
|
|
@@ -3335,19 +3350,14 @@
|
|
|
3335
3350
|
"description": "The proxy URL for the source URL.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#applicationProxies)",
|
|
3336
3351
|
"type": "string"
|
|
3337
3352
|
},
|
|
3338
|
-
"should": {
|
|
3339
|
-
"$ref": "#/definitions/Chai.Assertion"
|
|
3340
|
-
},
|
|
3341
3353
|
"sourceUrl": {
|
|
3342
3354
|
"description": "The URL of the premium map service layer.\n\n[Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#applicationProxies)",
|
|
3343
3355
|
"type": "string"
|
|
3344
3356
|
}
|
|
3345
3357
|
},
|
|
3346
3358
|
"required": [
|
|
3347
|
-
"constructor",
|
|
3348
3359
|
"proxyId",
|
|
3349
3360
|
"proxyUrl",
|
|
3350
|
-
"should",
|
|
3351
3361
|
"sourceUrl"
|
|
3352
3362
|
],
|
|
3353
3363
|
"type": "object"
|
|
@@ -3685,6 +3695,9 @@
|
|
|
3685
3695
|
"esri.webmap.PopupExpressionInfo.PopupExpressionInfo": {
|
|
3686
3696
|
"description": "Arcade expression added to the pop-up.{@linkhttps://developers.arcgis.com/web-map-specification/objects/popupExpressionInfo/}."
|
|
3687
3697
|
},
|
|
3698
|
+
"esri.webmap.PopupInfo.OrderByFields": {
|
|
3699
|
+
"description": "Object indicating the field display order for the related records and whether\nthey should be sorted in ascending or descending order.{@linkhttps://developers.arcgis.com/web-map-specification/objects/orderByFields/}{@linkhttps://developers.arcgis.com/web-scene-specification/objects/orderByFields/}."
|
|
3700
|
+
},
|
|
3688
3701
|
"esri.webmap.PopupInfo.PopupElement": {
|
|
3689
3702
|
"description": "Popup elements allow users to author popups, using multiple elements such as\ntabular views, string description, media (charts and images), and attachments\nof the attributes and control the order in which they appear. Specifically,\npopupElements do the following: 1) provide the ability to explicitly add a\nfield/ value table in addition to a description, 2) allow adding multiple\ndescription elements, and 3) allow a user to author and consume elements of a\npopup in the order of their choosing.\n\nEach popupElement has a type property. This string value indicates the type\nof popupElement used.\n\nSee https://developers.arcgis.com/web-map-specification/objects/popupElement/\nand\nhttps://developers.arcgis.com/web-scene-specification/objects/popupElement/."
|
|
3690
3703
|
},
|
package/data/Feature.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import Graphic from"@arcgis/core/Graphic";import*as Arcade from"@arcgis/core/arcade/arcade";import{EntityBase}from"../Entity.js";import{Hyperlink}from"../Hyperlink.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{toEsriApiGeometry,toPortalGeometry}from"../portal/Geometry.js";import{serializable}from"../support/Serializable.js";import{MapTransformCollection}from"../utilities/MapTransformCollection.js";import{ObservableMap}from"../utilities/ObservableMap.js";import{ReadOnlyMap}from"../utilities/ReadOnlyMap.js";import{arcadeScriptUsesGeometry,isArcadeScriptAsync,runArcadeExpression,runAsyncArcadeExpression}from"../utilities/arcade.js";import{flatten,groupBy}from"../utilities/array.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{parse as parseDate,esriFormatToGeocortexFormat}from"../utilities/date.js";import{isCodedValueDomain}from"../utilities/esri.js";import{some,map as mapIterable,concat,forEach,find}from"../utilities/iterable.js";import{getLogger}from"../utilities/log.js";import{parse as parseNumber,NumberFormat}from"../utilities/number.js";import{map as promiseMap}from"../utilities/promise.js";import{format as formatString}from"../utilities/string.js";import{onCollectionPropertyChange}from"../utilities/watch.js";import{FeatureSettings}from"./FeatureSettings.js";import{fieldWithArcadeXRegex,fieldWithRelationshipRegex,Schema}from"./Schema.js";const log=getLogger("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let Feature=class extends EntityBase{constructor(e){super(e),this._itemType=ItemType.FEATURE,this._expressionFieldValues=new ObservableMap,this._expressionValuesUpdatePending=!1,this._attachmentsInitialized=!1,this._expressionsInitialized=!1,this._initializedRelationships=new WeakSet,this.settings=new FeatureSettings,this.settings._setFeature(this),this.schema=new Schema,this.schema._featureSettings=this.settings,this.attachments=new Collection,this.attributes=new ObservableMap,this._relatedFeatures=new ObservableMap,this.expressionFieldValues=new ExpressionFieldsValuesImpl(this._expressionFieldValues,this),onCollectionPropertyChange(this,"source.relationships",(()=>{this.notifyChange("relatedFeaturesInitialized")}),!0),this.settings.watch("popupTemplate",((e,t)=>{e!==t&&(this._expressionsInitialized=!1,this.notifyChange("expressionsInitialized"))}),!0)}get geometry(){return this._geometry}set geometry(e){this.notifyChange("geometryType"),this._geometry=toEsriApiGeometry(e),this.schema.spatialReference=this._geometry?.spatialReference}get geometryType(){return this.geometry?this.geometry.type:void 0}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),this.notifyChange("attachmentsInitialized"),this.notifyChange("relatedFeaturesInitialized")}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get hasGlobalId(){return!!this.schema.fields.find((e=>"global-id"===e.type))}get globalId(){const e=this.schema.fields.find((e=>"global-id"===e.type));return e?this.attributes.get(e.name):void 0}set globalId(e){const t=this.schema.fields.find((e=>"global-id"===e.type));if(!t)throw new InvalidOperationError("Cannot set global ID on feature -- no global ID field.");this.attributes.set(t.name,e)}get presentableAttributes(){return this._presentableAttributes=this._presentableAttributes||new PresentableAttributesImpl(this),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new HyperlinksCollection(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get attachmentsInitialized(){return!this.source||this._attachmentsInitialized}get relatedFeaturesInitialized(){return!this.source||this.source.relationships.every((e=>this._initializedRelationships.has(e)))}get expressionsInitialized(){return!this.settings.popupTemplate||!this.settings.popupTemplate.expressionInfos?.length||this._expressionsInitialized}get _hydrationStatus(){return this._featureHydrationStatus?this._featureHydrationStatus:this.source?.capabilities?.supportsQuery&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _key(){return`${this.source?.id}//${this.primaryKey??this.globalId??this.id}`}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){if(this.settings.popupTemplate?.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}format(e,...t){let s="string"==typeof e?{format:e}:e;checkArg("options",s).isNotMissing();const{format:i}=s;checkArg("format",i).isNotMissing();let r=s.format.replace(escapedBraceRegex,escapedBracePlaceholder);return r=r.replace(fieldTokenRegex,((e,t,i,r,a)=>formatAttribute(this,t||i,r,{...s,format:a?`{0:${a}}`:"{0}"}))),r=r.replace(escapedBracePlaceholderRegex,"{{"),s={...s},s.format=r,formatString(s,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}async fetchExpressionInfos(e=!1){const{expressionInfos:t}=this.settings.popupTemplate??{};if(t){if(await Promise.all(t.map((async e=>{try{const t=this.source?.layer??this.source?.sublayer;let s=this.source?.mapExtension;if(!s){const e=this.source?.layerExtension;s=e?.mapExtension}this._expressionFieldValues.set(e.name,await runAsyncArcadeExpression(e.expression,{layer:t,map:s?.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,invalidRelationshipOrExpression)}}))),e)return this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))}));this._expressionsInitialized=!0,this.notifyChange("expressionsInitialized")}}async fetchRelatedFeatures(e,t){if(!this.source)return;let s=[];if(e){const t=new Set(Array.isArray(e)?e:[e]);for(const e of t){const t="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!t||!this.source.relationships.includes(t))throw new InvalidOperationError("Relationship not found in feature source.");s.push(t)}}else s=this.source.relationships.toArray();const i=await promiseMap(s,(async e=>[e,await(async()=>{const s=await e.getRelatedFeatures(this,t);return this._initializedRelationships.add(e),s})()]));for(const e of i)this._relatedFeatures.set(e[0],e[1]);this.notifyChange("relatedFeaturesInitialized")}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);compare(this.attachments,e,{equals:(e,t)=>e.id===t.id,onMissing:(e,t)=>this.attachments.remove(e),onNew:(e,t)=>this.attachments.add(e),onMatch:(e,t,s,i)=>{this.attachments.splice(s,1,t)}}),this._attachmentsInitialized=!0,this.notifyChange("attachmentsInitialized")}}async addAttachment(e){return this.source?.addAttachment(this,e)}async deleteAttachments(e){return this.source?.deleteAttachments(this,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{const t={};if("project"===e&&this.primaryKey&&this.source?.capabilities.supportsQuery)t[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,s]of this.attributes.entries())t[e]=s;return t},deserialize:e=>{if(this.attributes.clear(),e instanceof Map)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,s]of Object.entries(e))this.attributes.set(t,s)}},geometry:{serializeModes:["project"],serialize:e=>"project"===e&&this.source?.capabilities.supportsQuery?this.getDefault("geometry"):toPortalGeometry(this.geometry),deserialize:e=>this.geometry=toEsriApiGeometry(e)},settings:{serializeModes:["project"],serialize:e=>"project"===e&&this.source?.capabilities.supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)},schema:{serializeModes:["project"],serialize:e=>"project"===e&&this.source?.capabilities.supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)},source:["project"]}}_watchProperty(e,t,s,i){if("title"===e||"description"===e){const r=super._watchProperty(e,t,s,i),a="title"===e?"settings.popupTemplate.title":"settings.popupTemplate.content",o=this.watch(a,(()=>{this.notifyChange(e)})),n=this.presentableAttributes.on("change",(()=>{this.notifyChange(e)}));return{remove(){r.remove(),o.remove(),n.remove()}}}return super._watchProperty(e,t,s,i)}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],s=[];for(const i of e)t.includes(i)?s.push(this.fetchRelatedFeatures(i)):log.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(s)}_findRelationshipIds(...e){const t=[];for(const s of e){let e;const i=s.replace(escapedBraceRegex,escapedBracePlaceholder);for(;e=relationshipIdRegex.exec(i),null!==e;){const s=e[0];t.includes(s)||t.push(e[1])}}return t}};Feature=__decorate([serializable],Feature);export{Feature};export function toFeature(e,t){const s=new Feature(t);if(e.attributes)for(const t of Object.keys(e.attributes))s.attributes.set(t,e.attributes[t]);return s.geometry=e.geometry,e.popupTemplate&&(s.settings.popupTemplate=e.popupTemplate),s}export function toGraphic(e){const t=new Graphic;t.attributes={};for(const s of e.attributes.keys())t.attributes[s]=e.attributes.get(s);return e.source?.layer&&(t.layer=e.source?.layer),t.geometry=e.geometry,e.settings.popupTemplate&&(t.popupTemplate=e.settings.popupTemplate),t}const ERR_PRESENTABLE_ATTRIBUTES_READONLY="Presentable attributes are read-only.",ERR_HYPERLINK_READONLY="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class ExpressionFieldsValuesImpl extends ReadOnlyMap{constructor(e,t){super(e),this._feature=t}get(e){if(!super.has(e)){const{spatialReference:t}=this._feature.schema,s=this._feature.settings.popupTemplate?.expressionInfos?.find((t=>t.name===e));if(!s)return;(async()=>{try{if(isArcadeScriptAsync(s.expression,t)){const i=this._feature.source?.layer??this._feature.source?.sublayer;let r=this._feature.source?.mapExtension;if(!r){const e=this._feature.source?.layerExtension;r=e?.mapExtension}this._originalMap.set(e,await runAsyncArcadeExpression(s.expression,{feature:this._feature,layer:i,map:r?.map,spatialReference:t}))}else arcadeScriptUsesGeometry(s.expression,t)&&await Arcade.enableGeometrySupport(),this._originalMap.set(e,runArcadeExpression(s.expression,{feature:this._feature,spatialReference:t}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,invalidRelationshipOrExpression)}})()}return super.get(e)}}class PresentableAttributesImpl extends ReadOnlyMap{constructor(e){super(new ObservableMap),this._feature=e}get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}clear(){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}delete(e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}forEach(e,t){checkArg("callback",e).isNotMissing();for(const s of this.keys())e.call(t,this.get(s),s,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){return some(this.keys(),(t=>t===e))}set(...e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}*entries(){yield*mapIterable(this.keys(),(e=>[e,this.get(e)]))}*keys(){const e=this._feature.schema.fields.expressionFields.map((e=>e.name)),t=[];this._feature.source?.relationships&&this._feature.source.relationships.filter((e=>"one-to-one"===e.cardinality||"many-to-one"===e.cardinality)).forEach((e=>t.push(...e.relatedSource.schema.fields.map((t=>`relationships/${e.id}/${t.name}`)).toArray()))),yield*concat(this._feature.attributes.keys(),e.toArray(),t)}*values(){yield*mapIterable(this.keys(),(e=>this.get(e)))}[(Symbol.toStringTag,Symbol.iterator)](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(checkArg("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,s=()=>{t.forEach((e=>e.remove())),t.clear()},i=()=>{const t={added:Array.from(this.entries()).filter((t=>t[1]!==e.get(t[0]))),removed:Array.from(e.entries()).filter((e=>!this.has(e[0])||e[1]!==this.get(e[0]))),target:this};(t.added.length||t.removed.length)&&(this.emit("change",t),r())},r=()=>{e.clear(),s(),forEach(this.keys(),(s=>{const r=this._getFieldExtension(s);let a="{0}";if(r){const e=r.watch("format",(()=>{i()}));t.add(e),r.format&&(a=r.format)}e.set(s,this._formatAttribute(s,a))}))};r();const a=this._feature.attributes.on("change",(()=>{i()})),o=this._feature.schema.fieldExtensions.on("change",(()=>{i()})),n=this._feature.settings.formatSettings.watch(["numberFormat","dateFormat","locale"],(()=>{i()})),l=this._feature.expressionFieldValues.on("change",(()=>{i()})),p=this._feature.schema.fields.on("change",(e=>{(e.added?.some((e=>null!==e.name.match(fieldWithArcadeXRegex)))||e.removed?.some((e=>null!==e.name.match(fieldWithArcadeXRegex))))&&i()})),h=this._feature.settings.watch("popupTemplate",(()=>{i()}));this._onAllObserversRemoved=()=>{l.remove(),a.remove(),o.remove(),p.remove(),n.remove(),h.remove(),e.clear(),s()}}const s=super.on("change",t);return this._numObservers++,{remove:()=>{s.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}watch(e,t){if("size"===e){const e=this._feature.attributes.watch("size",((e,s)=>{t(e+this._feature.schema.fields._expressionFieldsLength,s+this._feature.schema.fields._expressionFieldsLength,"size",this)})),s=this._feature.schema.fields.watch("_expressionFieldsLength",((e,s)=>{t(e+this._feature.attributes.size,s+this._feature.attributes.size,"size",this)}));return{remove:()=>{e.remove(),s.remove()}}}return super.watch(e,t)}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const s=e.match(fieldWithArcadeXRegex),i=e.match(fieldWithRelationshipRegex);if(s)return formatAttribute(this._feature,"expression",s[1],{format:t});if(i){const[,e,s]=i;return formatAttribute(this._feature,e,s,{format:t})}return formatAttribute(this._feature,void 0,e,{format:t})}}const fieldTokenRegex=/\{(?:relationships[\\/](\w\w*)[\\/])?(?:(expression)[\\/])?([a-zA-Z][.\w]*)(?::([^}]*))?\}/g,relationshipIdRegex=/\{relationships\/(\w\w*)[\\/]([^}]*)\}/g,escapedBraceRegex=/{{/g,escapedBracePlaceholder="\0MAGIC\0",escapedBracePlaceholderRegex=new RegExp(escapedBracePlaceholder,"g"),invalidRelationshipOrExpression="#INVALID";class HyperlinksCollection extends MapTransformCollection{constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}_getHyperlink(e){return this._hyperlinks=this._hyperlinks||new WeakMap,this._hyperlinks.has(e)||this._hyperlinks.set(e,new FeatureHyperlink(this._feature,e)),this._hyperlinks.get(e)}}let FeatureHyperlink=class extends Hyperlink{constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t}get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}_watchProperty(e,t,s,i){const r=super._watchProperty(e,t,s,i),a=this._template.watch(e,(()=>{this.notifyChange(e)})),o=this._feature.presentableAttributes.on("change",(()=>{this.notifyChange(e)})),n=this._feature.relatedFeatures.on("change",(()=>{this._notifyChange(e)}));return{remove:()=>{r.remove(),a.remove(),o.remove(),n.remove()}}}_getSerializableProperties(){return{}}};function formatAttribute(e,t,s,i={format:"{0}"}){if("expression"!==t){if(t){const r=find(e.relatedFeatures.keys(),(e=>e.id===t));if(!r)return log.debug("Could not resolve related field '{0}/{1}",t,s),invalidRelationshipOrExpression;const a=Array.from(e.relatedFeatures.get(r));return"many-to-one"===r.cardinality||"one-to-one"===r.cardinality?a.length<1?(log.debug("Could not resolve related field '{0}/{1}",t,s),invalidRelationshipOrExpression):formatAttributeValue(a[0],s,i):a.map((e=>formatAttributeValue(e,s,i))).filter((e=>""!==e)).join(",")}return formatAttributeValue(e,s,i)}if(!e.settings.popupTemplate?.expressionInfos?.find((e=>e.name===s)))return log.debug("Could not find expression '{0}'.",s),invalidRelationshipOrExpression;try{const t=e.expressionFieldValues.get(s)??i.defaultExpressionValue??"",r=e.schema.findFieldByName(`expression/${s}`);let a=i;if(r){const t=e.schema.fieldExtensions.forField(r);a=formatOptionsForField(e,s,formatOptionsFromSettings(t.formatSettings),a)}return formatValue(e,t,a)}catch(e){if(e instanceof Error)return log.error({message:"Error evaluating expression '{0}': {1}.",error:e},s,e.message),invalidRelationshipOrExpression;throw e}}function formatAttributeValue(e,t,s){let i=e.attributes.get(t);if(null==i)return"";const r=e.schema.findFieldByName(t);let a={format:"{0}"};const o=e.type?.domains?.[t];if(t===e.schema.typeIdField)i=e.type?e.type.name:i;else if(isCodedValueDomain(o)){const e=o.codedValues.find((e=>`${e.code}`==`${i.toString()}`));i=e?e.name:i}else if(r)if(isCodedValueDomain(r.domain)){const e=r.domain.codedValues.find((e=>`${e.code}`==`${i.toString()}`));e&&(i=e.name)}else{switch(r.type){case"integer":case"small-integer":case"single":case"double":i=parseNumber(i);break;case"date":i=parseDate({timeZone:e.schema.timeZone},i);break;default:i=`${i.toString()}`}a=formatOptionsFromSettings(e.schema.fieldExtensions.forField(r).formatSettings)}return formatValue(e,i,formatOptionsForField(e,t,a,s))}function formatValue(e,t,s){let i=s;if("number"==typeof t||t instanceof Date){i={...formatOptionsFromSettings(e.settings.formatSettings),...s}}return"{0}"===i.format&&"string"==typeof t?t:formatString(i,t)}function formatOptionsFromSettings(e){return{format:"{0}",dateFormat:e.dateFormat,numberFormat:e.numberFormat,currency:e.currency,fractionalDigits:e.fractionalDigits,locale:e.locale,timeZone:e.timeZone}}function formatOptionsForField(e,t,s,i){const{popupTemplate:r}=e.settings,a=r?.fieldInfos?r.fieldInfos.find((e=>e.fieldName===t)):void 0,o=a?a.format:void 0;let n;return o&&(n={format:"{0}",numberFormat:o.digitSeparator?NumberFormat.NUMBER:NumberFormat.FIXED_POINT,dateFormat:esriFormatToGeocortexFormat(o.dateFormat),fractionalDigits:o.places}),{...n,...s,...i}}FeatureHyperlink=__decorate([serializable],FeatureHyperlink);export async function resolveRelatedFeatures(e){const t=groupBy(e,(e=>e.source));await Promise.all(flatten([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,s])=>{t.relatedFeatures.set(e,s)}))})(e))))}
|
|
1
|
+
import{__decorate}from"tslib";import Graphic from"@arcgis/core/Graphic";import*as Arcade from"@arcgis/core/arcade/arcade";import{EntityBase}from"../Entity.js";import{Hyperlink}from"../Hyperlink.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{toEsriApiGeometry,toPortalGeometry}from"../portal/Geometry.js";import{serializable}from"../support/Serializable.js";import{MapTransformCollection}from"../utilities/MapTransformCollection.js";import{ObservableMap}from"../utilities/ObservableMap.js";import{ReadOnlyMap}from"../utilities/ReadOnlyMap.js";import{arcadeScriptUsesGeometry,isArcadeScriptAsync,runArcadeExpression,runAsyncArcadeExpression}from"../utilities/arcade.js";import{flatten,groupBy}from"../utilities/array.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{parse as parseDate,esriFormatToGeocortexFormat}from"../utilities/date.js";import{isCodedValueDomain}from"../utilities/esri.js";import{some,map as mapIterable,concat,forEach,find}from"../utilities/iterable.js";import{getLogger}from"../utilities/log.js";import{parse as parseNumber,NumberFormat}from"../utilities/number.js";import{map as promiseMap}from"../utilities/promise.js";import{format as formatString}from"../utilities/string.js";import{onCollectionPropertyChange}from"../utilities/watch.js";import{FeatureSettings}from"./FeatureSettings.js";import{fieldWithArcadeXRegex,fieldWithRelationshipRegex,Schema}from"./Schema.js";const log=getLogger("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let Feature=class extends EntityBase{constructor(e){super(e),this._itemType=ItemType.FEATURE,this._expressionFieldValues=new ObservableMap,this._expressionValuesUpdatePending=!1,this._attachmentsInitialized=!1,this._expressionsInitialized=!1,this._initializedRelationships=new WeakSet,this.settings=new FeatureSettings,this.settings._setFeature(this),this.schema=new Schema,this.schema._featureSettings=this.settings,this.attachments=new Collection,this.attributes=new ObservableMap,this._relatedFeatures=new ObservableMap,this.expressionFieldValues=new ExpressionFieldsValuesImpl(this._expressionFieldValues,this),onCollectionPropertyChange(this,"source.relationships",(()=>{this.notifyChange("relatedFeaturesInitialized")}),!0),this.settings.watch("popupTemplate",((e,t)=>{e!==t&&(this._expressionsInitialized=!1,this.notifyChange("expressionsInitialized"))}),!0)}get geometry(){return this._geometry}set geometry(e){this.notifyChange("geometryType"),this._geometry=toEsriApiGeometry(e),this.schema.spatialReference=this._geometry?.spatialReference}get geometryType(){return this.geometry?this.geometry.type:void 0}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),this.notifyChange("attachmentsInitialized"),this.notifyChange("relatedFeaturesInitialized")}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get hasGlobalId(){return!!this.schema.fields.find((e=>"global-id"===e.type))}get globalId(){const e=this.schema.fields.find((e=>"global-id"===e.type));return e?this.attributes.get(e.name):void 0}set globalId(e){const t=this.schema.fields.find((e=>"global-id"===e.type));if(!t)throw new InvalidOperationError("Cannot set global ID on feature -- no global ID field.");this.attributes.set(t.name,e)}get presentableAttributes(){return this._presentableAttributes=this._presentableAttributes||new PresentableAttributesImpl(this),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new HyperlinksCollection(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get attachmentsInitialized(){return!this.source||this._attachmentsInitialized}get relatedFeaturesInitialized(){return!this.source||this.source.relationships.every((e=>this._initializedRelationships.has(e)))}get expressionsInitialized(){return!this.settings.popupTemplate||!this.settings.popupTemplate.expressionInfos?.length||this._expressionsInitialized}get _hydrationStatus(){return this._featureHydrationStatus?this._featureHydrationStatus:this.source?.capabilities?.supportsQuery&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _key(){return`${this.source?.id}//${this.primaryKey??this.globalId??this.id}`}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){if(this.settings.popupTemplate?.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}format(e,...t){let s="string"==typeof e?{format:e}:e;checkArg("options",s).isNotMissing();const{format:i}=s;checkArg("format",i).isNotMissing();let r=s.format.replace(escapedBraceRegex,escapedBracePlaceholder);return r=r.replace(fieldTokenRegex,((e,t,i,r,a)=>formatAttribute(this,t||i,r,{...s,format:a?`{0:${a}}`:"{0}"}))),r=r.replace(escapedBracePlaceholderRegex,"{{"),s={...s},s.format=r,formatString(s,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}async fetchExpressionInfos(e=!1){const{expressionInfos:t}=this.settings.popupTemplate??{};if(t){if(await Promise.all(t.map((async e=>{try{const t=this.source?.layer??this.source?.sublayer;let s=this.source?.mapExtension;if(!s){const e=this.source?.layerExtension;s=e?.mapExtension}this._expressionFieldValues.set(e.name,await runAsyncArcadeExpression(e.expression,{layer:t,map:s?.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,invalidRelationshipOrExpression)}}))),e)return this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))}));this._expressionsInitialized=!0,this.notifyChange("expressionsInitialized")}}async fetchRelatedFeatures(e,t){if(!this.source)return;let s=[];if(e){const t=new Set(Array.isArray(e)?e:[e]);for(const e of t){const t="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!t||!this.source.relationships.includes(t))throw new InvalidOperationError("Relationship not found in feature source.");s.push(t)}}else s=this.source.relationships.toArray();const i=await promiseMap(s,(async e=>[e,await(async()=>{const s=await e.getRelatedFeatures(this,t);return this._initializedRelationships.add(e),s})()]));for(const e of i)this._relatedFeatures.set(e[0],e[1]);this.notifyChange("relatedFeaturesInitialized")}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);compare(this.attachments,e,{equals:(e,t)=>e.id===t.id,onMissing:(e,t)=>this.attachments.remove(e),onNew:(e,t)=>{this.attachments.add(e)},onMatch:(e,t,s,i)=>{this.attachments.splice(s,1,t)}}),this._attachmentsInitialized=!0,this.notifyChange("attachmentsInitialized")}}async addAttachment(e){return this.source?.addAttachment(this,e)}async deleteAttachments(e){return this.source?.deleteAttachments(this,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{const t={};if("project"===e&&this.primaryKey&&this.source?.capabilities.supportsQuery)t[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,s]of this.attributes.entries())t[e]=s;return t},deserialize:e=>{if(this.attributes.clear(),e instanceof Map)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,s]of Object.entries(e))this.attributes.set(t,s)}},geometry:{serializeModes:["project"],serialize:e=>"project"===e&&this.source?.capabilities.supportsQuery?this.getDefault("geometry"):toPortalGeometry(this.geometry),deserialize:e=>this.geometry=toEsriApiGeometry(e)},settings:{serializeModes:["project"],serialize:e=>"project"===e&&this.source?.capabilities.supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)},schema:{serializeModes:["project"],serialize:e=>"project"===e&&this.source?.capabilities.supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)},source:["project"]}}_watchProperty(e,t,s,i){if("title"===e||"description"===e){const r=super._watchProperty(e,t,s,i),a="title"===e?"settings.popupTemplate.title":"settings.popupTemplate.content",o=this.watch(a,(()=>{this.notifyChange(e)})),n=this.presentableAttributes.on("change",(()=>{this.notifyChange(e)}));return{remove(){r.remove(),o.remove(),n.remove()}}}return super._watchProperty(e,t,s,i)}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],s=[];for(const i of e)t.includes(i)?s.push(this.fetchRelatedFeatures(i)):log.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(s)}_findRelationshipIds(...e){const t=[];for(const s of e){let e;const i=s.replace(escapedBraceRegex,escapedBracePlaceholder);for(;e=relationshipIdRegex.exec(i),null!==e;){const s=e[0];t.includes(s)||t.push(e[1])}}return t}};Feature=__decorate([serializable],Feature);export{Feature};export function toFeature(e,t){const s=new Feature(t);if(e.attributes)for(const t of Object.keys(e.attributes))s.attributes.set(t,e.attributes[t]);return s.geometry=e.geometry,e.popupTemplate&&(s.settings.popupTemplate=e.popupTemplate),s}export function toGraphic(e){const t=new Graphic;t.attributes={};for(const s of e.attributes.keys())t.attributes[s]=e.attributes.get(s);return e.source?.layer&&(t.layer=e.source?.layer),t.geometry=e.geometry,e.settings.popupTemplate&&(t.popupTemplate=e.settings.popupTemplate),t}const ERR_PRESENTABLE_ATTRIBUTES_READONLY="Presentable attributes are read-only.",ERR_HYPERLINK_READONLY="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class ExpressionFieldsValuesImpl extends ReadOnlyMap{constructor(e,t){super(e),this._feature=t}get(e){if(!super.has(e)){const{spatialReference:t}=this._feature.schema,s=this._feature.settings.popupTemplate?.expressionInfos?.find((t=>t.name===e));if(!s)return;(async()=>{try{if(isArcadeScriptAsync(s.expression,t)){const i=this._feature.source?.layer??this._feature.source?.sublayer;let r=this._feature.source?.mapExtension;if(!r){const e=this._feature.source?.layerExtension;r=e?.mapExtension}this._originalMap.set(e,await runAsyncArcadeExpression(s.expression,{feature:this._feature,layer:i,map:r?.map,spatialReference:t}))}else arcadeScriptUsesGeometry(s.expression,t)&&await Arcade.enableGeometrySupport(),this._originalMap.set(e,runArcadeExpression(s.expression,{feature:this._feature,spatialReference:t}))}catch(t){t instanceof Error&&log.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,invalidRelationshipOrExpression)}})()}return super.get(e)}}class PresentableAttributesImpl extends ReadOnlyMap{constructor(e){super(new ObservableMap),this._feature=e}get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}clear(){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}delete(e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}forEach(e,t){checkArg("callback",e).isNotMissing();for(const s of this.keys())e.call(t,this.get(s),s,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){return some(this.keys(),(t=>t===e))}set(...e){throw new InvalidOperationError(ERR_PRESENTABLE_ATTRIBUTES_READONLY)}*entries(){yield*mapIterable(this.keys(),(e=>[e,this.get(e)]))}*keys(){const e=this._feature.schema.fields.expressionFields.map((e=>e.name)),t=[];this._feature.source?.relationships&&this._feature.source.relationships.filter((e=>"one-to-one"===e.cardinality||"many-to-one"===e.cardinality)).forEach((e=>t.push(...e.relatedSource.schema.fields.map((t=>`relationships/${e.id}/${t.name}`)).toArray()))),yield*concat(this._feature.attributes.keys(),e.toArray(),t)}*values(){yield*mapIterable(this.keys(),(e=>this.get(e)))}[(Symbol.toStringTag,Symbol.iterator)](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(checkArg("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,s=()=>{t.forEach((e=>e.remove())),t.clear()},i=()=>{const t={added:Array.from(this.entries()).filter((t=>t[1]!==e.get(t[0]))),removed:Array.from(e.entries()).filter((e=>!this.has(e[0])||e[1]!==this.get(e[0]))),target:this};(t.added.length||t.removed.length)&&(this.emit("change",t),r())},r=()=>{e.clear(),s(),forEach(this.keys(),(s=>{const r=this._getFieldExtension(s);let a="{0}";if(r){const e=r.watch("format",(()=>{i()}));t.add(e),r.format&&(a=r.format)}e.set(s,this._formatAttribute(s,a))}))};r();const a=this._feature.attributes.on("change",(()=>{i()})),o=this._feature.schema.fieldExtensions.on("change",(()=>{i()})),n=this._feature.settings.formatSettings.watch(["numberFormat","dateFormat","locale"],(()=>{i()})),l=this._feature.expressionFieldValues.on("change",(()=>{i()})),p=this._feature.schema.fields.on("change",(e=>{(e.added?.some((e=>null!==e.name.match(fieldWithArcadeXRegex)))||e.removed?.some((e=>null!==e.name.match(fieldWithArcadeXRegex))))&&i()})),h=this._feature.settings.watch("popupTemplate",(()=>{i()}));this._onAllObserversRemoved=()=>{l.remove(),a.remove(),o.remove(),p.remove(),n.remove(),h.remove(),e.clear(),s()}}const s=super.on("change",t);return this._numObservers++,{remove:()=>{s.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}watch(e,t){if("size"===e){const e=this._feature.attributes.watch("size",((e,s)=>{t(e+this._feature.schema.fields._expressionFieldsLength,s+this._feature.schema.fields._expressionFieldsLength,"size",this)})),s=this._feature.schema.fields.watch("_expressionFieldsLength",((e,s)=>{t(e+this._feature.attributes.size,s+this._feature.attributes.size,"size",this)}));return{remove:()=>{e.remove(),s.remove()}}}return super.watch(e,t)}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const s=e.match(fieldWithArcadeXRegex),i=e.match(fieldWithRelationshipRegex);if(s)return formatAttribute(this._feature,"expression",s[1],{format:t});if(i){const[,e,s]=i;return formatAttribute(this._feature,e,s,{format:t})}return formatAttribute(this._feature,void 0,e,{format:t})}}const fieldTokenRegex=/\{(?:relationships[\\/](\w\w*)[\\/])?(?:(expression)[\\/])?([a-zA-Z][.\w]*)(?::([^}]*))?\}/g,relationshipIdRegex=/\{relationships\/(\w\w*)[\\/]([^}]*)\}/g,escapedBraceRegex=/{{/g,escapedBracePlaceholder="\0MAGIC\0",escapedBracePlaceholderRegex=new RegExp(escapedBracePlaceholder,"g"),invalidRelationshipOrExpression="#INVALID";class HyperlinksCollection extends MapTransformCollection{constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}_getHyperlink(e){return this._hyperlinks=this._hyperlinks||new WeakMap,this._hyperlinks.has(e)||this._hyperlinks.set(e,new FeatureHyperlink(this._feature,e)),this._hyperlinks.get(e)}}let FeatureHyperlink=class extends Hyperlink{constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t}get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new InvalidOperationError(ERR_HYPERLINK_READONLY)}_watchProperty(e,t,s,i){const r=super._watchProperty(e,t,s,i),a=this._template.watch(e,(()=>{this.notifyChange(e)})),o=this._feature.presentableAttributes.on("change",(()=>{this.notifyChange(e)})),n=this._feature.relatedFeatures.on("change",(()=>{this._notifyChange(e)}));return{remove:()=>{r.remove(),a.remove(),o.remove(),n.remove()}}}_getSerializableProperties(){return{}}};function formatAttribute(e,t,s,i={format:"{0}"}){if("expression"!==t){if(t){const r=find(e.relatedFeatures.keys(),(e=>e.id===t));if(!r)return log.debug("Could not resolve related field '{0}/{1}",t,s),invalidRelationshipOrExpression;const a=Array.from(e.relatedFeatures.get(r));return"many-to-one"===r.cardinality||"one-to-one"===r.cardinality?a.length<1?(log.debug("Could not resolve related field '{0}/{1}",t,s),invalidRelationshipOrExpression):formatAttributeValue(a[0],s,i):a.map((e=>formatAttributeValue(e,s,i))).filter((e=>""!==e)).join(",")}return formatAttributeValue(e,s,i)}if(!e.settings.popupTemplate?.expressionInfos?.find((e=>e.name===s)))return log.debug("Could not find expression '{0}'.",s),invalidRelationshipOrExpression;try{const t=e.expressionFieldValues.get(s)??i.defaultExpressionValue??"",r=e.schema.findFieldByName(`expression/${s}`);let a=i;if(r){const t=e.schema.fieldExtensions.forField(r);a=formatOptionsForField(e,s,formatOptionsFromSettings(t.formatSettings),a)}return formatValue(e,t,a)}catch(e){if(e instanceof Error)return log.error({message:"Error evaluating expression '{0}': {1}.",error:e},s,e.message),invalidRelationshipOrExpression;throw e}}function formatAttributeValue(e,t,s){let i=e.attributes.get(t);if(null==i)return"";const r=e.schema.findFieldByName(t);let a={format:"{0}"};const o=e.type?.domains?.[t];if(t===e.schema.typeIdField)i=e.type?e.type.name:i;else if(isCodedValueDomain(o)){const e=o.codedValues.find((e=>`${e.code}`==`${i.toString()}`));i=e?e.name:i}else if(r)if(isCodedValueDomain(r.domain)){const e=r.domain.codedValues.find((e=>`${e.code}`==`${i.toString()}`));e&&(i=e.name)}else{switch(r.type){case"integer":case"small-integer":case"single":case"double":i=parseNumber(i);break;case"date":i=parseDate({timeZone:e.schema.timeZone},i);break;default:i=`${i.toString()}`}a=formatOptionsFromSettings(e.schema.fieldExtensions.forField(r).formatSettings)}return formatValue(e,i,formatOptionsForField(e,t,a,s))}function formatValue(e,t,s){let i=s;if("number"==typeof t||t instanceof Date){i={...formatOptionsFromSettings(e.settings.formatSettings),...s}}return"{0}"===i.format&&"string"==typeof t?t:formatString(i,t)}function formatOptionsFromSettings(e){return{format:"{0}",dateFormat:e.dateFormat,numberFormat:e.numberFormat,currency:e.currency,fractionalDigits:e.fractionalDigits,locale:e.locale,timeZone:e.timeZone}}function formatOptionsForField(e,t,s,i){const{popupTemplate:r}=e.settings,a=r?.fieldInfos?r.fieldInfos.find((e=>e.fieldName===t)):void 0,o=a?a.format:void 0;let n;return o&&(n={format:"{0}",numberFormat:o.digitSeparator?NumberFormat.NUMBER:NumberFormat.FIXED_POINT,dateFormat:esriFormatToGeocortexFormat(o.dateFormat),fractionalDigits:o.places}),{...n,...s,...i}}FeatureHyperlink=__decorate([serializable],FeatureHyperlink);export async function resolveRelatedFeatures(e){const t=groupBy(e,(e=>e.source));await Promise.all(flatten([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,s])=>{t.relatedFeatures.set(e,s)}))})(e))))}
|
package/data/FeatureList.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export declare class FeatureList extends ReadOnlyCollection<Feature> implements
|
|
|
123
123
|
*
|
|
124
124
|
* @param criteria The criteria to sort by.
|
|
125
125
|
*/
|
|
126
|
-
sort(criteria: string | SortClause | FeatureCompareFunction | (SortClause | string)[]):
|
|
126
|
+
sort(criteria: string | SortClause | FeatureCompareFunction | (SortClause | string)[]): this;
|
|
127
127
|
/**
|
|
128
128
|
* Filters the list in place to only include items that match the given
|
|
129
129
|
* criteria.
|
package/data/FeatureList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import Field from"@arcgis/core/layers/support/Field";import{ArgumentError}from"../ArgumentError.js";import{generateId}from"../Entity.js";import{isFeatureSet,ItemType}from"../ItemType.js";import{assignProperties,filterJSONProperties,getDefaults,getSerializableProperties,serializable}from"../support/Serializable.js";import{getSearchableValue}from"../tasks/search/_utilities.js";import{ReadOnlyCollection}from"../utilities/ReadOnlyCollection.js";import{Collection}from"../utilities/collection.js";import{parse as parseDate}from"../utilities/date.js";import{isCodedValueDomain}from"../utilities/esri.js";import{parse as parseNumber}from"../utilities/number.js";import{escapeRegExp}from"../utilities/string.js";import{FeatureSet}from"./FeatureSet.js";let FeatureList=class extends ReadOnlyCollection{constructor(e){if(super(new Collection),this.id=e?.id??generateId(),isFeatureSet(e))this.featureSet=e;else if(e){const t=e;Array.isArray(t.featureSet)?this.featureSet=new FeatureSet({features:t.featureSet}):isFeatureSet(t.featureSet)?this.featureSet=t.featureSet:this.featureSet=new FeatureSet(t.featureSet)}else this.featureSet=new FeatureSet;for(const e of this.featureSet)this._collection.add(e);this.featureSet.on("change",(e=>this._onFeatureSetChange(e)))}get itemType(){return ItemType.FEATURE_LIST}toItemUri(){return`item://${encodeURIComponent(ItemType.FEATURE_LIST)}/${encodeURIComponent(this.id)}`}assignProperties(e){assignProperties(this._getSerializableProperties(),this,e)}toJSON(e="all"){return filterJSONProperties(this._getSerializableProperties(),this,e)}getDefaults(){return getDefaults(this._getSerializableProperties())}getDefault(e){return this.getDefaults()[e]}sort(e){if("function"==typeof e)this._sortFunc=e;else if(Array.isArray(e))this._sortFunc=this._createSortFunc(e);else if("object"==typeof e&&e.field)this._sortFunc=this._createSortFunc([e]);else{if("string"!=typeof e)throw new ArgumentError("criteria","Invalid sort criteria.");this._sortFunc=this._createSortFunc([{field:e}])}this._sortFunc=this._stabilizeSortFunc(this._sortFunc),this._sort(this._sortFunc),this.emit("change",{moved:this._collection.toArray(),target:this})}applyFilter(e){if(e)if("function"==typeof e)this._filterFunc=e;else if(Array.isArray(e))this._filterFunc=this._createFilterFunc(e);else if("object"==typeof e&&e.field)this._filterFunc=this._createFilterFunc([e]);else{if("string"!=typeof e)throw new ArgumentError("criteria","Invalid filter criteria.");{const t=this.featureSet.schema.fieldExtensions.initializedItems.filter((e=>e.searchable)).map((t=>({field:t.field.name,match:e}))).toArray();this._filterFunc=this._createFilterFunc(t)}}else delete this._filterFunc;const t=new Set,i=[],r=[];let s=0;for(;s<this._collection.length;){const e=this._collection.getItemAt(s);this._filterFunc&&!this._filterFunc(e)?(i.push(e),this._collection.removeAt(s)):(t.add(e),s++)}for(const e of this.featureSet)t.has(e)||this._filterFunc&&!this._filterFunc(e)||(this._collection.add(e),r.push(e));this._sortFunc&&r.length&&(r.length<=10?this._insertionSort(this._sortFunc):this._sort(this._sortFunc)),(r.length||i.length)&&this.emit("change",{added:r,removed:i,target:this})}removeFilter(){this.applyFilter(void 0)}getSerializableProperties(e="all"){return getSerializableProperties(this._getSerializableProperties(),e)}_getSerializableProperties(){return{title:["project"],featureSet:{serializeModes:["project"],deserialize:e=>{isFeatureSet(e)?this.featureSet.assignProperties({title:e.title,features:[...e]}):Array.isArray(e)?this.featureSet.assignProperties({features:e}):this.featureSet.assignProperties(e)}}}}_onFeatureSetChange(e){if(e.removed?.length&&this._collection.removeMany(e.removed),e.added?.length){const t=this._filterFunc?e.added.filter(this._filterFunc):e.added;t.length&&(this._collection.addMany(t),this._sortFunc&&(t.length<=10?this._insertionSort(this._sortFunc):this._sort(this._sortFunc)))}}_createSortFunc(e){return(t,i)=>{for(let r of e){if("string"==typeof r&&(r={field:r}),!r.field)throw new ArgumentError("criteria","Invalid sort criteria.");const e=this._getField(r.field),s=this._getSortValue(t,e),o=this._getSortValue(i,e);let a="string"==typeof s?s.localeCompare(o):s-o;if("desc"===r.direction&&(a*=-1),0!==a)return a}return 0}}_stabilizeSortFunc(e){return(t,i)=>{const r=e(t,i);return 0===r?this._collection.indexOf(t)-this._collection.indexOf(i):r}}_createFilterFunc(e){const t=new Map;for(const i of e){if(!i.field)throw new ArgumentError("criteria","Invalid sort criteria.");if(!i.match)continue;const e=this._getField(i.field),r=this._getFilterRegex(i.match,e);t.set(e.name,r)}return t.size?e=>{for(const i of t.keys()){const r=this._getField(i),s=getSearchableValue(e,r),o=t.get(i);let a=o[0];if(o.length>1&&"string"!==r.type&&isCodedValueDomain(e.type?.domains?.[r.name])&&(a=o[1]),a.exec(s))return!0}return!1}:()=>!0}_getSortValue(e,t){if(isCodedValueDomain(e.type?.domains?.[t.name])||isCodedValueDomain(t.domain))return e.presentableAttributes.get(t.name);switch(t.type){case"integer":case"small-integer":case"double":case"single":case"oid":{const i=e.attributes.get(t.name);return null==i||isNaN(i)?Number.MIN_VALUE:parseNumber(i)}case"date":{const i=parseDate(e.attributes.get(t.name)).getTime();return isNaN(i)?0:i}default:return e.presentableAttributes.get(t.name)??""}}_getFilterRegex(e,t){if(t.domain&&"coded-value"===t.domain.type)return[new RegExp(`${escapeRegExp(e)}`,"i")];switch(t.type){case"integer":case"small-integer":case"double":case"single":case"oid":{const i=new RegExp(`(^|${SEPARATOR})${escapeRegExp(e)}`,"i");return this.featureSet.schema.types.some((e=>isCodedValueDomain(e.domains?.[t.name])))?[i,new RegExp(`${escapeRegExp(e)}`,"i")]:[i]}default:return[new RegExp(`${escapeRegExp(e)}`,"i")]}}_getField(e){let t=this.featureSet.schema.findFieldByName(e);return t||(t=new Field({name:e,type:this._inferFieldType(e),editable:!1}),this.featureSet.schema.fields.add(t)),t}_inferFieldType(e){for(const t of this.featureSet.values()){const i=t.attributes.get(e);if(null!=i)return"number"==typeof i?"double":i instanceof Date?"date":"string"}return"string"}_sort(e){this._collection._items.sort(e)}_insertionSort(e){const t=this._collection._items;for(let i=1;i<this.length;i++){const r=t[i];let s=i-1;for(;s>=0&&e(t[s],r)>0;)t[s+1]=t[s],s--;t[s+1]=r}}};FeatureList=__decorate([serializable],FeatureList);export{FeatureList};const SEPARATOR="\t";
|
|
1
|
+
import{__decorate}from"tslib";import Field from"@arcgis/core/layers/support/Field";import{ArgumentError}from"../ArgumentError.js";import{generateId}from"../Entity.js";import{isFeatureSet,ItemType}from"../ItemType.js";import{assignProperties,filterJSONProperties,getDefaults,getSerializableProperties,serializable}from"../support/Serializable.js";import{getSearchableValue}from"../tasks/search/_utilities.js";import{ReadOnlyCollection}from"../utilities/ReadOnlyCollection.js";import{Collection}from"../utilities/collection.js";import{parse as parseDate}from"../utilities/date.js";import{isCodedValueDomain}from"../utilities/esri.js";import{parse as parseNumber}from"../utilities/number.js";import{escapeRegExp}from"../utilities/string.js";import{FeatureSet}from"./FeatureSet.js";let FeatureList=class extends ReadOnlyCollection{constructor(e){if(super(new Collection),this.id=e?.id??generateId(),isFeatureSet(e))this.featureSet=e;else if(e){const t=e;Array.isArray(t.featureSet)?this.featureSet=new FeatureSet({features:t.featureSet}):isFeatureSet(t.featureSet)?this.featureSet=t.featureSet:this.featureSet=new FeatureSet(t.featureSet)}else this.featureSet=new FeatureSet;for(const e of this.featureSet)this._collection.add(e);this.featureSet.on("change",(e=>this._onFeatureSetChange(e)))}get itemType(){return ItemType.FEATURE_LIST}toItemUri(){return`item://${encodeURIComponent(ItemType.FEATURE_LIST)}/${encodeURIComponent(this.id)}`}assignProperties(e){assignProperties(this._getSerializableProperties(),this,e)}toJSON(e="all"){return filterJSONProperties(this._getSerializableProperties(),this,e)}getDefaults(){return getDefaults(this._getSerializableProperties())}getDefault(e){return this.getDefaults()[e]}sort(e){if("function"==typeof e)this._sortFunc=e;else if(Array.isArray(e))this._sortFunc=this._createSortFunc(e);else if("object"==typeof e&&e.field)this._sortFunc=this._createSortFunc([e]);else{if("string"!=typeof e)throw new ArgumentError("criteria","Invalid sort criteria.");this._sortFunc=this._createSortFunc([{field:e}])}return this._sortFunc=this._stabilizeSortFunc(this._sortFunc),this._sort(this._sortFunc),this.emit("change",{moved:this._collection.toArray(),target:this}),this}applyFilter(e){if(e)if("function"==typeof e)this._filterFunc=e;else if(Array.isArray(e))this._filterFunc=this._createFilterFunc(e);else if("object"==typeof e&&e.field)this._filterFunc=this._createFilterFunc([e]);else{if("string"!=typeof e)throw new ArgumentError("criteria","Invalid filter criteria.");{const t=this.featureSet.schema.fieldExtensions.initializedItems.filter((e=>e.searchable)).map((t=>({field:t.field.name,match:e}))).toArray();this._filterFunc=this._createFilterFunc(t)}}else delete this._filterFunc;const t=new Set,i=[],r=[];let s=0;for(;s<this._collection.length;){const e=this._collection.getItemAt(s);this._filterFunc&&!this._filterFunc(e)?(i.push(e),this._collection.removeAt(s)):(t.add(e),s++)}for(const e of this.featureSet)t.has(e)||this._filterFunc&&!this._filterFunc(e)||(this._collection.add(e),r.push(e));this._sortFunc&&r.length&&(r.length<=10?this._insertionSort(this._sortFunc):this._sort(this._sortFunc)),(r.length||i.length)&&this.emit("change",{added:r,removed:i,target:this})}removeFilter(){this.applyFilter(void 0)}getSerializableProperties(e="all"){return getSerializableProperties(this._getSerializableProperties(),e)}_getSerializableProperties(){return{title:["project"],featureSet:{serializeModes:["project"],deserialize:e=>{isFeatureSet(e)?this.featureSet.assignProperties({title:e.title,features:[...e]}):Array.isArray(e)?this.featureSet.assignProperties({features:e}):this.featureSet.assignProperties(e)}}}}_onFeatureSetChange(e){if(e.removed?.length&&this._collection.removeMany(e.removed),e.added?.length){const t=this._filterFunc?e.added.filter(this._filterFunc):e.added;t.length&&(this._collection.addMany(t),this._sortFunc&&(t.length<=10?this._insertionSort(this._sortFunc):this._sort(this._sortFunc)))}}_createSortFunc(e){return(t,i)=>{for(let r of e){if("string"==typeof r&&(r={field:r}),!r.field)throw new ArgumentError("criteria","Invalid sort criteria.");const e=this._getField(r.field),s=this._getSortValue(t,e),o=this._getSortValue(i,e);let a="string"==typeof s?s.localeCompare(o):s-o;if("desc"===r.direction&&(a*=-1),0!==a)return a}return 0}}_stabilizeSortFunc(e){return(t,i)=>{const r=e(t,i);return 0===r?this._collection.indexOf(t)-this._collection.indexOf(i):r}}_createFilterFunc(e){const t=new Map;for(const i of e){if(!i.field)throw new ArgumentError("criteria","Invalid sort criteria.");if(!i.match)continue;const e=this._getField(i.field),r=this._getFilterRegex(i.match,e);t.set(e.name,r)}return t.size?e=>{for(const i of t.keys()){const r=this._getField(i),s=getSearchableValue(e,r),o=t.get(i);let a=o[0];if(o.length>1&&"string"!==r.type&&isCodedValueDomain(e.type?.domains?.[r.name])&&(a=o[1]),a.exec(s))return!0}return!1}:()=>!0}_getSortValue(e,t){if(isCodedValueDomain(e.type?.domains?.[t.name])||isCodedValueDomain(t.domain))return e.presentableAttributes.get(t.name);switch(t.type){case"integer":case"small-integer":case"double":case"single":case"oid":{const i=e.attributes.get(t.name);return null==i||isNaN(i)?Number.MIN_VALUE:parseNumber(i)}case"date":{const i=parseDate(e.attributes.get(t.name)).getTime();return isNaN(i)?0:i}default:return e.presentableAttributes.get(t.name)??""}}_getFilterRegex(e,t){if(t.domain&&"coded-value"===t.domain.type)return[new RegExp(`${escapeRegExp(e)}`,"i")];switch(t.type){case"integer":case"small-integer":case"double":case"single":case"oid":{const i=new RegExp(`(^|${SEPARATOR})${escapeRegExp(e)}`,"i");return this.featureSet.schema.types.some((e=>isCodedValueDomain(e.domains?.[t.name])))?[i,new RegExp(`${escapeRegExp(e)}`,"i")]:[i]}default:return[new RegExp(`${escapeRegExp(e)}`,"i")]}}_getField(e){let t=this.featureSet.schema.findFieldByName(e);return t||(t=new Field({name:e,type:this._inferFieldType(e),editable:!1}),this.featureSet.schema.fields.add(t)),t}_inferFieldType(e){for(const t of this.featureSet.values()){const i=t.attributes.get(e);if(null!=i)return"number"==typeof i?"double":i instanceof Date?"date":"string"}return"string"}_sort(e){this._collection._items.sort(e)}_insertionSort(e){const t=this._collection._items;for(let i=1;i<this.length;i++){const r=t[i];let s=i-1;for(;s>=0&&e(t[s],r)>0;)t[s+1]=t[s],s--;t[s+1]=r}}};FeatureList=__decorate([serializable],FeatureList);export{FeatureList};const SEPARATOR="\t";
|
package/data/FeatureSettings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import PopupTemplate from"@arcgis/core/PopupTemplate";import{Hyperlink}from"../Hyperlink.js";import{isPopupContentExtension}from"../ItemType.js";import{ArrayWrappedCollection}from"../mapping/support/ArrayWrappedCollection.js";import{PopupInfo as PopupInfoJson}from"../portal/PopupInfo.js";import{FormatSettings}from"../support/FormatSettings.js";import{InitializableCollectionProxy}from"../support/InitializableCollectionProxy.js";import{filterJSONProperties,isDefault,serializable,shouldExcludeDefaults}from"../support/Serializable.js";import{Settings}from"../support/Settings.js";import{compare}from"../utilities/array.js";import{checkArg}from"../utilities/checkArg.js";import{getAllFieldInfos,getAllReferencedFieldNames,isPopupTemplate}from"../utilities/esri.js";import{isQueryBasedRelationship}from"../utilities/relationships.js";import{onCollectionPropertyChange}from"../utilities/watch.js";import{PopupContentExtension,_popupContentExtensionMap}from"./PopupContentExtension.js";import{fieldWithArcadeXRegex,fieldWithRelationshipRegex}from"./Schema.js";let FeatureSettings=class extends Settings{constructor(t){super(t),this._isDefaultPopupTemplate=!1,this._popupContentCollection=this._createPopupContentCollection(),this.popupContentExtensions=new PopupContentExtensionCollectionImpl(this)}get _popupContent(){return this._popupContentCollection}get hyperlinkTemplates(){return this._getCollectionSetting("hyperlinkTemplates")}get popupTemplate(){return this._getSetting("popupTemplate")}set popupTemplate(t){
|
|
1
|
+
import{__decorate}from"tslib";import PopupTemplate from"@arcgis/core/PopupTemplate";import{Hyperlink}from"../Hyperlink.js";import{isPopupContentExtension}from"../ItemType.js";import{ArrayWrappedCollection}from"../mapping/support/ArrayWrappedCollection.js";import{PopupInfo as PopupInfoJson}from"../portal/PopupInfo.js";import{FormatSettings}from"../support/FormatSettings.js";import{InitializableCollectionProxy}from"../support/InitializableCollectionProxy.js";import{filterJSONProperties,isDefault,serializable,shouldExcludeDefaults}from"../support/Serializable.js";import{Settings}from"../support/Settings.js";import{compare}from"../utilities/array.js";import{checkArg}from"../utilities/checkArg.js";import{getAllFieldInfos,getAllReferencedFieldNames,isPopupTemplate}from"../utilities/esri.js";import{isQueryBasedRelationship}from"../utilities/relationships.js";import{onCollectionPropertyChange}from"../utilities/watch.js";import{PopupContentExtension,_popupContentExtensionMap}from"./PopupContentExtension.js";import{fieldWithArcadeXRegex,fieldWithRelationshipRegex}from"./Schema.js";let FeatureSettings=class extends Settings{constructor(t){super(t),this._isDefaultPopupTemplate=!1,this._popupContentCollection=this._createPopupContentCollection(),this.popupContentExtensions=new PopupContentExtensionCollectionImpl(this)}get _popupContent(){return this._popupContentCollection}get hyperlinkTemplates(){return this._getCollectionSetting("hyperlinkTemplates")}get popupTemplate(){return this._getSetting("popupTemplate")}set popupTemplate(t){let e;e=t instanceof Object&&!isPopupTemplate(t)?PopupInfoJson.toEsriApiPopupTemplate(t):t;const i=this?._feature?.schema?.createPopupTemplate()??this?._featureSource?.schema?.createPopupTemplate();e&&i&&(e.content=e.content??i.content,e.fieldInfos=e.fieldInfos??i.fieldInfos),this._setSetting("popupTemplate",e),this._isDefaultPopupTemplate=!1}get formatSettings(){return this._getNestedSettings("formatSettings",(()=>new FormatSettings))}get returnGeometry(){return this._getSetting("returnGeometry",!0)}set returnGeometry(t){this._setSetting("returnGeometry",t)}get outFields(){return this._getSetting("outFields",this._defaultOutFields)}set outFields(t){this._setSetting("outFields",t)}get outSpatialReference(){return this._getSetting("outSpatialReference")}set outSpatialReference(t){this._setSetting("outSpatialReference",t)}get maxAllowableOffset(){return this._getSetting("maxAllowableOffset")}set maxAllowableOffset(t){this._setSetting("maxAllowableOffset",t)}get zoomScale(){return this._getSetting("zoomScale")}set zoomScale(t){this._setSetting("zoomScale",t)}get zoomFactor(){const t=this._feature?this._feature.schema:this._featureSource?.schema,e=t&&"point"===t.geometryType?void 0:1.5;return this._getSetting("zoomFactor",e)}set zoomFactor(t){this._setSetting("zoomFactor",t)}get featureSource(){return this._featureSource}get feature(){return this._feature}get _defaultOutFields(){const t=getAllFieldInfos(this.popupTemplate),e=this.featureSource?.schema?.primaryKeyField;if(t&&e){const i=new Set;i.add(e);const n=this.featureSource.schema.fields.toArray().map((t=>t.name)),o=getAllReferencedFieldNames(this.popupTemplate),s=t.filter((t=>t.visible||t.isEditable&&this.featureSource.capabilities.supportsEditing)).map((t=>t.fieldName)).concat(...o).filter((t=>n.includes(t)));return this._featureSource.relationships.forEach((t=>{isQueryBasedRelationship(t)&&s.push(t.keyField)})),s.filter((t=>!(t.match(fieldWithArcadeXRegex)||t.match(fieldWithRelationshipRegex)))).forEach((t=>i.add(t))),Array.from(i.values())}return["*"]}_setFeatureSource(t){this._featureSource=t,this.notifyChange("featureSource")}_setFeature(t){this._feature=t,this.notifyChange("feature")}toJSON(t="all"){const e=filterJSONProperties(this._getSerializableProperties(),this,t)||{},i=e.popupContentExtensions?.filter((t=>!this.parent?.popupContentExtensions?.some((e=>e.id===t.id))));if(e)for(const t of Object.keys(e))this.isModified(t)||delete e[t];if(i?.length&&(e.popupContentExtensions=i),!shouldExcludeDefaults(t)||!isDefault(e))return e}_createPopupContentCollection(){return new ArrayWrappedCollection({parent:this,targetProperty:"popupTemplate",arrayProperty:"content"})}_getSerializableProperties(){return{hyperlinkTemplates:{serializeModes:["initial"],deserialize:t=>{t.forEach((t=>{this.hyperlinkTemplates.find((e=>this._hyperlinksAreEquivalent(e,t)))||this.hyperlinkTemplates.add(t instanceof Hyperlink?t:new Hyperlink(t))})),this.hyperlinkTemplates.toArray().forEach((e=>{const i=this.hyperlinkTemplates.indexOf(e),n=t.findIndex((t=>this._hyperlinksAreEquivalent(t,e)));n<0?this.hyperlinkTemplates.removeAt(i):n!==i&&this.hyperlinkTemplates.reorder(e,n)}))}},popupTemplate:{serialize:!1},formatSettings:"initial",outFields:{serializeModes:["initial"],serialize:()=>this.isModified("outFields")?this.outFields:void 0},returnGeometry:{serializeModes:["initial"],default:!0},outSpatialReference:"initial",maxAllowableOffset:"initial",zoomScale:"initial",zoomFactor:{serializeModes:["initial"],isDefault:t=>{const e=this._feature?this._feature.schema:this._featureSource?.schema;return t===(e&&"point"===e.geometryType?void 0:1.5)}},popupContentExtensions:{serializeModes:["initial"],serialize:t=>this.popupContentExtensions.map((e=>e.toJSON(t))).filter((t=>!(t&&2===Object.keys(t).length&&t.id&&t.content))).toArray(),deserialize:t=>{t&&compare(this.popupContentExtensions,t,{onNew:(t,e)=>{this.popupContentExtensions.add(isPopupContentExtension(t)?t:new PopupContentExtension(t),e)},onMatch:(t,e,i,n)=>{isPopupContentExtension(e)||t.assignProperties(e),i!==n&&this.popupContentExtensions.reorder(t,n)},onMissing:t=>{this.popupContentExtensions.remove(t)},equals:(t,e)=>isPopupContentExtension(e)?e===t||e.id===t.id:!(!e?.content||!PopupContentExtension.matchesRef(this.popupContentExtensions.toArray(),this.popupContentExtensions.indexOf(t),e.content))||t.id===e.id})}}}}_hyperlinksAreEquivalent(t,e){if(t===e)return!0;const i=t=>t||"";return i(t.text)===i(e.text)&&i(t.url)===i(e.url)&&i(t.iconUrl)===i(e.iconUrl)&&i(t.target)===i(e.target)&&i(t.tooltip)===i(e.tooltip)}};FeatureSettings=__decorate([serializable],FeatureSettings);export{FeatureSettings};class PopupContentExtensionCollectionImpl extends InitializableCollectionProxy{constructor(t){super(),this._uninitializedPopupContentExtensions=new Set,this._featureSettings=t,onCollectionPropertyChange(this._featureSettings,"_popupContent",(t=>{const e={added:(t.added||[]).map((t=>this._forContent(t))),moved:(t.moved||[]).map((t=>this._forContent(t))),removed:(t.removed||[]).map((t=>this._forContent(t))),target:this};this.emit("change",e)})),t.watch("_popupContent.length",(()=>this.notifyChange("length")))}get _collection(){return this._featureSettings._popupContent.map((t=>this._forContent(t))).concat(Array.from(this._uninitializedPopupContentExtensions))}get _popupTemplateIsInherited(){return this._featureSettings.parent&&this._featureSettings.popupTemplate===this._featureSettings.parent.popupTemplate}forContent(t){if(checkArg("content",t).isNotMissing(),this._featureSettings._popupContent.includes(t))return this._forContent(t)}add(t,e){if(checkArg("contentX",t).isNotMissing(),this._popupTemplateIsInherited&&(this._featureSettings.popupTemplate=new PopupTemplate({content:this._featureSettings._popupContent.toArray()})),t.featureSettings&&t.featureSettings.popupContentExtensions.remove(t),t._setFeatureSettings(this._featureSettings),t.content){const i=_popupContentExtensionMap.get(t.content);if(_popupContentExtensionMap.set(t.content,t),i&&i!==t&&this._onRemoved(i),this._featureSettings._popupContent.includes(t.content))if(void 0===e){const e={added:[t],moved:[],removed:i?[i]:[],target:this};this.emit("change",e)}else this._featureSettings._popupContent.reorder(t.content,e);else this._featureSettings._popupContent.add(t.content,e)}else{this._uninitializedPopupContentExtensions.add(t);const e={added:[t],moved:[],removed:[],target:this};this.emit("change",e)}return this._onAdded(t),this}removeAt(t){const e=this.getItemAt(t);if(void 0!==e){if(this._popupTemplateIsInherited&&(this._featureSettings.popupTemplate=new PopupTemplate({content:this._featureSettings._popupContent.toArray()})),this._uninitializedPopupContentExtensions.has(e)){this._uninitializedPopupContentExtensions.delete(e);const t={added:[],moved:[],removed:[e],target:this};this.emit("change",t)}else this._featureSettings._popupContent.remove(e.content);return this._onRemoved(e),e}}reorder(t,e){if(t&&this._featureSettings._popupContent.includes(t.content))return this._popupTemplateIsInherited&&(this._featureSettings.popupTemplate=new PopupTemplate({content:this._featureSettings._popupContent.toArray()})),this._featureSettings._popupContent.reorder(t.content,e),t}sort(t){return this._popupTemplateIsInherited&&(this._featureSettings.popupTemplate=new PopupTemplate({content:this._featureSettings._popupContent.toArray()})),this._featureSettings._popupContent.sort(((e,i)=>t(this._forContent(e),this._forContent(i)))),this}_itemIsInitialized(t){return super._itemIsInitialized(t)&&!!t.content}_onAdded(t){}_onRemoved(t){t.featureSettings===this._featureSettings&&t._setFeatureSettings(void 0)}_forContent(t){if(this._uninitializedPopupContentExtensions.size)for(const t of this._uninitializedPopupContentExtensions)t._resolveContent(),t.content&&(_popupContentExtensionMap.set(t.content,t),this._uninitializedPopupContentExtensions.delete(t));if(!_popupContentExtensionMap.has(t)){const e=new PopupContentExtension({content:t});_popupContentExtensionMap.set(t,e),e._setFeatureSettings(this._featureSettings),this._onAdded(e)}return _popupContentExtensionMap.get(t)}}
|
|
@@ -256,7 +256,7 @@ export declare class RelationshipCollection extends CollectionProxy<Relationship
|
|
|
256
256
|
/**
|
|
257
257
|
* @inheritDoc
|
|
258
258
|
*/
|
|
259
|
-
add(relationship: Relationship, index?: number):
|
|
259
|
+
add(relationship: Relationship, index?: number): this;
|
|
260
260
|
/**
|
|
261
261
|
* @inheritDoc
|
|
262
262
|
*/
|
|
@@ -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)).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){return 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 +1 @@
|
|
|
1
|
-
var PopupContentExtension_1;import{__decorate}from"tslib";import Content from"@arcgis/core/popup/content/Content.js";import{EntityBase}from"../Entity.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{PopupContent}from"../portal/PopupInfo.js";import{serializable}from"../support/Serializable.js";import{Collection}from"../support/esri.js";import{compare}from"../utilities/array.js";import{isCustomContent,isExpressionContent,isPopupContent,isTextContent}from"../utilities/esri.js";import{deepClone}from"../utilities/object.js";export const _popupContentExtensionMap=new WeakMap;let PopupContentExtension=PopupContentExtension_1=class extends EntityBase{constructor(t){super(t),this.summaryHiddenFields=new Collection,this._itemType=ItemType.POPUP_CONTENT_EXTENSION;const{content:e,visibleInSummary:n}=t??{};isPopupContent(e)?this._setContent(e):"string"==typeof e?this._deferredContentProperties={$ref:e}:e?e.$ref?this._deferredContentProperties=e:this._setContent(PopupContent.toEsriApiPopupContent(e)):this._setContent(new Content),this.visibleInSummary=n??this._getDefaultSummaryVisibility()}get content(){return this._content}get featureSettings(){return this._featureSettings}get _index(){return Array.isArray(this.featureSettings.popupTemplate?.content)?this.featureSettings.popupTemplate.content.indexOf(this.content):-1}static matchesRef(t,e,n){const i=t.map(((t,e)=>contentToRef(t,t instanceof PopupContentExtension_1?t._index:e))),o=i[e],{type:r,index:s,title:p,text:a}=n.$ref;if(r!==o.type)return!1;if("text"===r&&a===o.text)return!0;if(p&&p===o.title)return!0;if("number"==typeof s&&s===o.index)return!0;return 1===i.map(((t,e)=>t.type===r?t.index:void 0)).filter((t=>"number"==typeof t)).length}_setFeatureSettings(t){this._featureSettings=t,this._resolveContent(),this.notifyChange("featureSettings")}_resolveContent(){if(this._content||!this._deferredContentProperties||!this._featureSettings)return;const t=this._featureSettings._popupContent.find(((t,e)=>PopupContentExtension_1.matchesRef(this.featureSettings._popupContent.toArray(),e,this._deferredContentProperties)));t&&(this._setContent(t),this.assignProperties({content:this._deferredContentProperties}),this._originalRef={...this._deferredContentProperties.$ref},delete this._deferredContentProperties,_popupContentExtensionMap.set(t,this))}_getSerializableProperties(){return{...super._getSerializableProperties(),content:{serializeModes:["initial"],serialize:()=>this.content?this._originalRef?{$ref:this._originalRef}:this._featureSettings?._popupContent.includes(this._content)?{$ref:contentToRef(this.content,this._index)}:PopupContent.fromEsriApiPopupContent(this.content):this._deferredContentProperties?deepClone(this._deferredContentProperties):void 0,deserialize:t=>{if(isPopupContent(t)){if(t!==this.content)throw new Error("Property 'popupContent' is read-only.")}else t&&this.content&&PopupContent.applyToEsriApiPopupContent(t,this.content)}},visibleInSummary:{serializeModes:["initial"],isDefault:(t,e)=>t===this._getDefaultSummaryVisibility()},summaryHiddenFields:{serializeModes:["initial"],serialize:()=>this.summaryHiddenFields.toArray(),deserialize:t=>{compare(this.summaryHiddenFields,t,{onMatch:(t,e,n,i)=>{this.summaryHiddenFields.reorder(t,i)},onMissing:t=>this.summaryHiddenFields.remove(t),onNew:t=>this.summaryHiddenFields.add(t)})}}}}async _onInitialize(){if(this._resolveContent(),!this._content){const t=this._deferredContentProperties.$ref;throw this._featureSettings?new InvalidOperationError(`PopupContent not found with reference: ${JSON.stringify(t)}. PopupContent does not exist.`):new InvalidOperationError(`PopupContent not found with reference: ${JSON.stringify(t)}. PopupContent does not have a parent featureSettings.`)}}_setContent(t){this._content=t,this.notifyChange("content")}_getDefaultSummaryVisibility(){return"text"===(this.content?.type??this._deferredContentProperties?.type??this._deferredContentProperties?.$ref?.type)}};PopupContentExtension=PopupContentExtension_1=__decorate([serializable],PopupContentExtension);export{PopupContentExtension};function contentToRef(t,e){const n=t instanceof PopupContentExtension?t.content:t;if(!n)return t._deferredContentProperties?.$ref;const i={type:n.type};return e>=0&&(i.index=e),isExpressionContent(n)?i.title=n.expressionInfo.title:isTextContent(n)?i.text=n.text:isCustomContent(n)||(i.title=n.title),i}
|
|
1
|
+
var PopupContentExtension_1;import{__decorate}from"tslib";import Content from"@arcgis/core/popup/content/Content.js";import{EntityBase}from"../Entity.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{PopupContent}from"../portal/PopupInfo.js";import{serializable}from"../support/Serializable.js";import{Collection}from"../support/esri.js";import{compare}from"../utilities/array.js";import{isCustomContent,isExpressionContent,isPopupContent,isTextContent}from"../utilities/esri.js";import{deepClone}from"../utilities/object.js";export const _popupContentExtensionMap=new WeakMap;let PopupContentExtension=PopupContentExtension_1=class extends EntityBase{constructor(t){super(t),this.summaryHiddenFields=new Collection,this._itemType=ItemType.POPUP_CONTENT_EXTENSION;const{content:e,visibleInSummary:n}=t??{};isPopupContent(e)?this._setContent(e):"string"==typeof e?this._deferredContentProperties={$ref:e}:e?e.$ref?this._deferredContentProperties=e:this._setContent(PopupContent.toEsriApiPopupContent(e)):this._setContent(new Content),this.visibleInSummary=n??this._getDefaultSummaryVisibility()}get content(){return this._content}get featureSettings(){return this._featureSettings}get _index(){return Array.isArray(this.featureSettings.popupTemplate?.content)?this.featureSettings.popupTemplate.content.indexOf(this.content):-1}static matchesRef(t,e,n){const i=t.map(((t,e)=>contentToRef(t,t instanceof PopupContentExtension_1?t._index:e))),o=i[e],{type:r,index:s,title:p,text:a}=n.$ref;if(r!==o.type)return!1;if("text"===r&&a===o.text)return!0;if(p&&p===o.title)return!0;if("number"==typeof s&&s===o.index)return!0;return 1===i.map(((t,e)=>t.type===r?t.index:void 0)).filter((t=>"number"==typeof t)).length}_setFeatureSettings(t){this._featureSettings=t,this._resolveContent(),this.notifyChange("featureSettings")}_resolveContent(){if(this._content||!this._deferredContentProperties||!this._featureSettings)return;const t=this._featureSettings._popupContent.find(((t,e)=>PopupContentExtension_1.matchesRef(this.featureSettings._popupContent.toArray(),e,this._deferredContentProperties)));t&&(this._setContent(t),this.assignProperties({content:this._deferredContentProperties}),this._originalRef={...this._deferredContentProperties.$ref},delete this._deferredContentProperties,_popupContentExtensionMap.set(t,this))}_getSerializableProperties(){return{...super._getSerializableProperties(),content:{serializeModes:["initial"],serialize:()=>this.content?this._originalRef?{$ref:this._originalRef}:this._featureSettings?._popupContent.includes(this._content)?{$ref:contentToRef(this.content,this._index)}:PopupContent.fromEsriApiPopupContent(this.content):this._deferredContentProperties?deepClone(this._deferredContentProperties):void 0,deserialize:t=>{if(isPopupContent(t)){if(t!==this.content)throw new Error("Property 'popupContent' is read-only.")}else t&&this.content&&PopupContent.applyToEsriApiPopupContent(t,this.content)}},visibleInSummary:{serializeModes:["initial"],isDefault:(t,e)=>t===this._getDefaultSummaryVisibility()},summaryHiddenFields:{serializeModes:["initial"],serialize:()=>this.summaryHiddenFields.toArray(),deserialize:t=>{compare(this.summaryHiddenFields,t,{onMatch:(t,e,n,i)=>{this.summaryHiddenFields.reorder(t,i)},onMissing:t=>this.summaryHiddenFields.remove(t),onNew:t=>{this.summaryHiddenFields.add(t)}})}}}}async _onInitialize(){if(this._resolveContent(),!this._content){const t=this._deferredContentProperties.$ref;throw this._featureSettings?new InvalidOperationError(`PopupContent not found with reference: ${JSON.stringify(t)}. PopupContent does not exist.`):new InvalidOperationError(`PopupContent not found with reference: ${JSON.stringify(t)}. PopupContent does not have a parent featureSettings.`)}}_setContent(t){this._content=t,this.notifyChange("content")}_getDefaultSummaryVisibility(){return"text"===(this.content?.type??this._deferredContentProperties?.type??this._deferredContentProperties?.$ref?.type)}};PopupContentExtension=PopupContentExtension_1=__decorate([serializable],PopupContentExtension);export{PopupContentExtension};function contentToRef(t,e){const n=t instanceof PopupContentExtension?t.content:t;if(!n)return t._deferredContentProperties?.$ref;const i={type:n.type};return e>=0&&(i.index=e),isExpressionContent(n)?i.title=n.expressionInfo.title:isTextContent(n)?i.text=n.text:isCustomContent(n)||(i.title=n.title),i}
|
package/data/Schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Schema_1;import{__decorate}from"tslib";import PopupTemplate from"@arcgis/core/PopupTemplate";import Field from"@arcgis/core/layers/support/Field";import FieldInfo from"@arcgis/core/popup/FieldInfo";import{InvalidOperationError}from"../InvalidOperationError.js";import{isFieldExtension}from"../ItemType.js";import{Field as PortalField}from"../portal/Field.js";import{GeometryType as PortalGeometryType}from"../portal/Geometry.js";import{Type as PortalType}from"../portal/Type.js";import{InitializableCollectionProxy}from"../support/InitializableCollectionProxy.js";import{filterJSONProperties,isDefault,serializable,shouldExcludeDefaults}from"../support/Serializable.js";import{Settings}from"../support/Settings.js";import{CollectionProxy}from"../utilities/CollectionProxy.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{isValidTimeZone,ERR_TIME_ZONE_INVALID}from"../utilities/date.js";import{isFeatureType,isField}from"../utilities/esri.js";import{onCollectionPropertyChange}from"../utilities/watch.js";import{_fieldExtensionMap,FieldExtension}from"./FieldExtension.js";const esriFields=new Map;esriFields.set("objectid","oid"),esriFields.set("oid","oid"),esriFields.set("fid","oid"),esriFields.set("shape","geometry"),esriFields.set("shape__length","double"),esriFields.set("shape_length","double"),esriFields.set("shape__area","double"),esriFields.set("shape_area","double"),esriFields.set("area","double"),esriFields.set("perimeter","double"),esriFields.set("length","double"),esriFields.set("fnode_","double"),esriFields.set("tnode_","double"),esriFields.set("lpoly_","double"),esriFields.set("rpoly_","double"),esriFields.set("cover_","integer"),esriFields.set("cover_id","integer"),esriFields.set("idtic","integer"),esriFields.set("xtic","double"),esriFields.set("ytic","double"),esriFields.set("xmin","double"),esriFields.set("ymin","double"),esriFields.set("xmax","double"),esriFields.set("ymax","double"),esriFields.set("arc_","double"),esriFields.set("subclass_","integer"),esriFields.set("subclass_id","integer"),esriFields.set("routelink","integer"),esriFields.set("arclink","integer"),esriFields.set("f_meas","double"),esriFields.set("t_meas","double"),esriFields.set("f_pos","double"),esriFields.set("t_pos","double"),esriFields.set("f_meas","double"),esriFields.set("globalid","global-id"),esriFields.set("guid","guid");export const fieldWithArcadeXRegex=/expression\/((\w|-)*)/;export const fieldWithRelationshipRegex=/relationships\/(\d*)\/(\w*)/;const FIELD_INFO_MAP=new WeakMap;let Schema=Schema_1=class extends Settings{constructor(e){super(e),this.fieldExtensions=new FieldExtensionCollectionImpl(this),this.fields=new FieldCollectionImpl(this)}get spatialReference(){return this._getSetting("spatialReference")}set spatialReference(e){this._setSetting("spatialReference",e)}get primaryKeyField(){const e=this._getSetting("primaryKeyField");if(!e){const e=this.fields.filter((e=>"oid"===e.type));if(1===e.length)return e.getItemAt(0).name}return e}set primaryKeyField(e){this._setSetting("primaryKeyField",e)}get displayField(){return this._getSetting("displayField",this.primaryKeyField)}set displayField(e){!this._featureSettings?.popupTemplate||this._featureSettings.popupTemplate.title&&this._featureSettings.popupTemplate.title!==`{${this.displayField}}`||(this._featureSettings.popupTemplate.title=`{${e}}`),this._setSetting("displayField",e)}get geometryType(){return this._getSetting("geometryType")}set geometryType(e){this._setSetting("geometryType",e)}get hasGeometry(){return void 0!==this.geometryType&&null!==this.geometryType}get timeZone(){return this._getSetting("timeZone","UTC")}set timeZone(e){checkArg("timeZone",e).satisfies((e=>isValidTimeZone(e)),ERR_TIME_ZONE_INVALID(e)),this._setSetting("timeZone",e)}get typeIdField(){return this._getSetting("typeIdField")}set typeIdField(e){this._setSetting("typeIdField",e)}get types(){return this._getCollectionSetting("types")}get _fields(){return this._getCollectionSetting("_fields")}static createFieldInfoFromField(e){let i=!0;const t=e.name.toLowerCase();return("oid"===e.type||"geometry"===e.type||esriFields.has(t)&&esriFields.get(t)===e.type)&&(i=!1),new FieldInfo({visible:i,fieldName:e.name,format:void 0,label:e.alias,stringFieldOption:void 0,tooltip:void 0,isEditable:e.editable})}findFieldByName(e){return this.fields.find((i=>i.name===e))}toJSON(e="all"){const i=filterJSONProperties(this._getSerializableProperties(),this,e)||{};let t=i.fieldExtensions;this.parent&&(t=t?.filter((e=>!this.parent?.fieldExtensions?.some((i=>i.id===e.id)))));const{fields:s}=i;if(i)for(const e of Object.keys(i))this.isModified(e)||delete i[e];if(s&&(i.fields=s),t?.length&&(i.fieldExtensions=t),!shouldExcludeDefaults(e)||!isDefault(i))return i}createPopupTemplate(){const e=this.createAllFieldInfos();return new PopupTemplate({fieldInfos:e,content:[{type:"fields"},{type:"attachments"}]})}createAllFieldInfos(){return this.fields.toArray().filter((e=>!!e.name)).map((e=>Schema_1.createFieldInfoFromField(e)))}_getSerializableProperties(){return{geometryType:{serialize:!1,deserialize:e=>{this.geometryType=PortalGeometryType.toEsriApiGeometryType(e)}},spatialReference:{serialize:!1},primaryKeyField:{serialize:!1},displayField:{serialize:!1},typeIdField:{serialize:!1},fields:{serializeModes:["initial"],serialize:()=>this.isModified("_fields")?this.fields.toArray().map((e=>PortalField.fromEsriApiField(e))):void 0,deserialize:e=>{if(!e)return;const i=e.map((e=>isField(e)?e:PortalField.toEsriApiField(e)));compare(this.fields,i,{onNew:(e,i)=>{this.fields.add(e,i)},onMatch:(e,i,t,s)=>{e!==i&&(e.alias=i.alias,e.editable=i.editable,e.length=i.length,e.nullable=i.nullable,e.type=i.type),t!==s&&this.fields.reorder(e,s)},onMissing:e=>{this.fields.remove(e)},equals:(e,i)=>e.name===i.name})}},fieldExtensions:{serializeModes:["initial"],serialize:e=>this.fieldExtensions.toArray().map((i=>i.toJSON(e))).filter((e=>this._alwaysSerializeFieldExtensions||!(e&&2===Object.keys(e).length&&e.id&&e.field))),deserialize:e=>{e&&compare(this.fieldExtensions,e,{onNew:(e,i)=>{this.fieldExtensions.add(isFieldExtension(e)?e:new FieldExtension(e),i)},onMatch:(e,i,t,s)=>{isFieldExtension(i)||e.assignProperties(i),t!==s&&this.fieldExtensions.reorder(e,s)},onMissing:e=>{this._alwaysSerializeFieldExtensions&&this.fieldExtensions.remove(e)},equals:(e,i)=>isFieldExtension(i)?i===e:!(!i?.field||!FieldExtension.matchesRef(e,i.field))||e.id===i.id})}},types:{serialize:!1,deserialize:e=>{if(!e)return;const i=e.map((e=>isFeatureType(e)?e:PortalType.toEsriApiFeatureType(e)));compare(this.types,i,{onNew:(e,i)=>{this.types.add(e,i)},onMatch:(e,i,t,s)=>{e!==i&&(e.name=i.name,e.templates=i.templates?[...i.templates]:[],e.domains=i.domains),t!==s&&this.types.reorder(e,s)},onMissing:e=>{this.types.remove(e)},equals:(e,i)=>e.id===i.id})}},timeZone:{serialize:!1,deserialize:e=>{e&&(this.timeZone=e)}}}}};Schema=Schema_1=__decorate([serializable],Schema);export{Schema};class FieldCollectionImpl extends CollectionProxy{constructor(e){super(),this._schema=e,onCollectionPropertyChange(this._schema,"_fields",(e=>{this.emit("change",e),this._fieldLookup=void 0})),e.watch("_fields.length",(()=>this.notifyChange("length")))}get _createFieldLookup(){return this._collection.reduce(((e,i)=>(e.add(i),e)),new WeakSet)}get _expressionFieldsLength(){return this.expressionFields.length}get expressionFields(){if(!this._popupTemplate||!this._popupTemplate.fieldInfos||!this._popupTemplate.expressionInfos)return new Collection;const e=new Collection;for(const i of this._popupTemplate.fieldInfos){const t=i.fieldName.match(fieldWithArcadeXRegex);if(t){const s=this._popupTemplate.expressionInfos.find((e=>e.name===t[1]));if(s){if(!FIELD_INFO_MAP.has(i)){const e=new Field({name:i.fieldName,alias:i.label||s.title||i.fieldName,type:"number"===s.returnType?"double":"string",editable:!1});FIELD_INFO_MAP.set(i,e)}e.add(FIELD_INFO_MAP.get(i))}}}return e}get _collection(){return this._schema._fields.concat(this.expressionFields)}get _popupTemplate(){return this._schema._featureSettings?this._schema._featureSettings.popupTemplate:void 0}includes(e){return this._fieldLookup=this._fieldLookup??this._createFieldLookup,this._fieldLookup.has(e)}clone(){return new FieldCollectionImpl(this._schema)}add(e,i){checkArg("field",e).isNotMissing(),this._fieldLookup=void 0;const t=e.name?e.name.match(fieldWithArcadeXRegex):void 0;if(t){if(!this._popupTemplate)throw new InvalidOperationError("Cannot create a field that references an arcade expression without a feature source and popup template.");const i=this._popupTemplate.expressionInfos.find((e=>e.name===t[1]));if(!i)throw new InvalidOperationError("Cannot create a field that references a non-existent arcade expression.");this._popupTemplate.fieldInfos||(this._popupTemplate.fieldInfos=[]);let s=this._popupTemplate.fieldInfos.find((i=>i.fieldName===e.name));s||(s=new FieldInfo({fieldName:e.name,label:i.title}),this._popupTemplate.fieldInfos.push(s));const l=FIELD_INFO_MAP.get(s);FIELD_INFO_MAP.set(s,e);const o={added:[e],moved:[],removed:l?[l]:[],target:this};this.emit("change",o),this.notifyChange("length"),this.notifyChange("_expressionFieldsLength")}else this._schema._fields.add(e,i)}removeAt(e){checkArg("index",e).isNotMissing();const i=this.getItemAt(e);if(!i)return;this._fieldLookup=void 0;if(i.name?i.name.match(fieldWithArcadeXRegex):void 0){const e=this._popupTemplate.fieldInfos.findIndex((e=>e.fieldName===i.name));this._popupTemplate.fieldInfos.splice(e,1);const t={added:[],moved:[],removed:[i],target:this};this.emit("change",t),this.notifyChange("length"),this.notifyChange("_expressionFieldsLength")}else this._schema._fields.remove(i);return i}reorder(e,i){if(e&&this._schema._fields.includes(e))return this._schema._fields.reorder(e,i),e}sort(e){this._schema._fields.sort(e)}}class FieldExtensionCollectionImpl extends InitializableCollectionProxy{constructor(e){super(),this._uninitializedFieldExtensions=new Set,this._schema=e,onCollectionPropertyChange(this._schema,"fields",(e=>{const i={added:(e.added||[]).map((e=>this._forField(e))),moved:(e.moved||[]).map((e=>this._forField(e))),removed:(e.removed||[]).map((e=>this._forField(e))),target:this};this.emit("change",i)})),e.watch("fields.length",(()=>this.notifyChange("length")))}get _collection(){return this._schema.fields.map((e=>this._forField(e))).concat(Array.from(this._uninitializedFieldExtensions))}forField(e){if(checkArg("field",e).isNotMissing(),this._schema.fields.includes(e))return this._forField(e)}add(e,i){if(checkArg("fieldX",e).isNotMissing(),e.schema&&e.schema.fieldExtensions.remove(e),e._setSchema(this._schema),e.field){const t=_fieldExtensionMap.get(e.field);if(_fieldExtensionMap.set(e.field,e),t&&t!==e&&this._onRemoved(t),this._schema.fields.includes(e.field))if(void 0===i){const i={added:[e],moved:[],removed:t?[t]:[],target:this};this.emit("change",i)}else this._schema.fields.reorder(e.field,i);else this._schema.fields.add(e.field,i)}else{this._uninitializedFieldExtensions.add(e);const i={added:[e],moved:[],removed:[],target:this};this.emit("change",i)}this._onAdded(e)}removeAt(e){const i=this.getItemAt(e);if(void 0!==i){if(this._uninitializedFieldExtensions.has(i)){this._uninitializedFieldExtensions.delete(i);const e={added:[],moved:[],removed:[i],target:this};this.emit("change",e)}else this._schema.fields.remove(i.field);return this._onRemoved(i),i}}reorder(e,i){if(e&&this._schema.fields.includes(e.field))return this._schema.fields.reorder(e.field,i),e}sort(e){this._schema.fields.sort(((i,t)=>e(this._forField(i),this._forField(t))))}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.field}_onAdded(e){}_onRemoved(e){e.schema===this._schema&&e._setSchema(void 0)}_forField(e){if(this._uninitializedFieldExtensions.size)for(const e of this._uninitializedFieldExtensions)e._resolveField(),e.field&&(_fieldExtensionMap.set(e.field,e),this._uninitializedFieldExtensions.delete(e));if(!_fieldExtensionMap.has(e)){const i=new FieldExtension({field:e});_fieldExtensionMap.set(e,i),i._setSchema(this._schema),this._onAdded(i)}return _fieldExtensionMap.get(e)}}
|
|
1
|
+
var Schema_1;import{__decorate}from"tslib";import PopupTemplate from"@arcgis/core/PopupTemplate";import Field from"@arcgis/core/layers/support/Field";import FieldInfo from"@arcgis/core/popup/FieldInfo";import{InvalidOperationError}from"../InvalidOperationError.js";import{isFieldExtension}from"../ItemType.js";import{Field as PortalField}from"../portal/Field.js";import{GeometryType as PortalGeometryType}from"../portal/Geometry.js";import{Type as PortalType}from"../portal/Type.js";import{InitializableCollectionProxy}from"../support/InitializableCollectionProxy.js";import{filterJSONProperties,isDefault,serializable,shouldExcludeDefaults}from"../support/Serializable.js";import{Settings}from"../support/Settings.js";import{CollectionProxy}from"../utilities/CollectionProxy.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{isValidTimeZone,ERR_TIME_ZONE_INVALID}from"../utilities/date.js";import{isFeatureType,isField}from"../utilities/esri.js";import{onCollectionPropertyChange}from"../utilities/watch.js";import{_fieldExtensionMap,FieldExtension}from"./FieldExtension.js";const esriFields=new Map;esriFields.set("objectid","oid"),esriFields.set("oid","oid"),esriFields.set("fid","oid"),esriFields.set("shape","geometry"),esriFields.set("shape__length","double"),esriFields.set("shape_length","double"),esriFields.set("shape__area","double"),esriFields.set("shape_area","double"),esriFields.set("area","double"),esriFields.set("perimeter","double"),esriFields.set("length","double"),esriFields.set("fnode_","double"),esriFields.set("tnode_","double"),esriFields.set("lpoly_","double"),esriFields.set("rpoly_","double"),esriFields.set("cover_","integer"),esriFields.set("cover_id","integer"),esriFields.set("idtic","integer"),esriFields.set("xtic","double"),esriFields.set("ytic","double"),esriFields.set("xmin","double"),esriFields.set("ymin","double"),esriFields.set("xmax","double"),esriFields.set("ymax","double"),esriFields.set("arc_","double"),esriFields.set("subclass_","integer"),esriFields.set("subclass_id","integer"),esriFields.set("routelink","integer"),esriFields.set("arclink","integer"),esriFields.set("f_meas","double"),esriFields.set("t_meas","double"),esriFields.set("f_pos","double"),esriFields.set("t_pos","double"),esriFields.set("f_meas","double"),esriFields.set("globalid","global-id"),esriFields.set("guid","guid");export const fieldWithArcadeXRegex=/expression\/((\w|-)*)/;export const fieldWithRelationshipRegex=/relationships\/(\d*)\/(\w*)/;const FIELD_INFO_MAP=new WeakMap;let Schema=Schema_1=class extends Settings{constructor(e){super(e),this.fieldExtensions=new FieldExtensionCollectionImpl(this),this.fields=new FieldCollectionImpl(this)}get spatialReference(){return this._getSetting("spatialReference")}set spatialReference(e){this._setSetting("spatialReference",e)}get primaryKeyField(){const e=this._getSetting("primaryKeyField");if(!e){const e=this.fields.filter((e=>"oid"===e.type));if(1===e.length)return e.getItemAt(0).name}return e}set primaryKeyField(e){this._setSetting("primaryKeyField",e)}get displayField(){return this._getSetting("displayField",this.primaryKeyField)}set displayField(e){!this._featureSettings?.popupTemplate||this._featureSettings.popupTemplate.title&&this._featureSettings.popupTemplate.title!==`{${this.displayField}}`||(this._featureSettings.popupTemplate.title=`{${e}}`),this._setSetting("displayField",e)}get geometryType(){return this._getSetting("geometryType")}set geometryType(e){this._setSetting("geometryType",e)}get hasGeometry(){return void 0!==this.geometryType&&null!==this.geometryType}get timeZone(){return this._getSetting("timeZone","UTC")}set timeZone(e){checkArg("timeZone",e).satisfies((e=>isValidTimeZone(e)),ERR_TIME_ZONE_INVALID(e)),this._setSetting("timeZone",e)}get typeIdField(){return this._getSetting("typeIdField")}set typeIdField(e){this._setSetting("typeIdField",e)}get types(){return this._getCollectionSetting("types")}get _fields(){return this._getCollectionSetting("_fields")}static createFieldInfoFromField(e){let i=!0;const t=e.name.toLowerCase();return("oid"===e.type||"geometry"===e.type||esriFields.has(t)&&esriFields.get(t)===e.type)&&(i=!1),new FieldInfo({visible:i,fieldName:e.name,format:void 0,label:e.alias,stringFieldOption:void 0,tooltip:void 0,isEditable:e.editable})}findFieldByName(e){return this.fields.find((i=>i.name===e))}toJSON(e="all"){const i=filterJSONProperties(this._getSerializableProperties(),this,e)||{};let t=i.fieldExtensions;this.parent&&(t=t?.filter((e=>!this.parent?.fieldExtensions?.some((i=>i.id===e.id)))));const{fields:s}=i;if(i)for(const e of Object.keys(i))this.isModified(e)||delete i[e];if(s&&(i.fields=s),t?.length&&(i.fieldExtensions=t),!shouldExcludeDefaults(e)||!isDefault(i))return i}createPopupTemplate(){const e=this.createAllFieldInfos();return new PopupTemplate({fieldInfos:e,content:[{type:"fields"},{type:"attachments"}]})}createAllFieldInfos(){return this.fields.toArray().filter((e=>!!e.name)).map((e=>Schema_1.createFieldInfoFromField(e)))}_getSerializableProperties(){return{geometryType:{serialize:!1,deserialize:e=>{this.geometryType=PortalGeometryType.toEsriApiGeometryType(e)}},spatialReference:{serialize:!1},primaryKeyField:{serialize:!1},displayField:{serialize:!1},typeIdField:{serialize:!1},fields:{serializeModes:["initial"],serialize:()=>this.isModified("_fields")?this.fields.toArray().map((e=>PortalField.fromEsriApiField(e))):void 0,deserialize:e=>{if(!e)return;const i=e.map((e=>isField(e)?e:PortalField.toEsriApiField(e)));compare(this.fields,i,{onNew:(e,i)=>{this.fields.add(e,i)},onMatch:(e,i,t,s)=>{e!==i&&(e.alias=i.alias,e.editable=i.editable,e.length=i.length,e.nullable=i.nullable,e.type=i.type),t!==s&&this.fields.reorder(e,s)},onMissing:e=>{this.fields.remove(e)},equals:(e,i)=>e.name===i.name})}},fieldExtensions:{serializeModes:["initial"],serialize:e=>this.fieldExtensions.toArray().map((i=>i.toJSON(e))).filter((e=>this._alwaysSerializeFieldExtensions||!(e&&2===Object.keys(e).length&&e.id&&e.field))),deserialize:e=>{e&&compare(this.fieldExtensions,e,{onNew:(e,i)=>{this.fieldExtensions.add(isFieldExtension(e)?e:new FieldExtension(e),i)},onMatch:(e,i,t,s)=>{isFieldExtension(i)||e.assignProperties(i),t!==s&&this.fieldExtensions.reorder(e,s)},onMissing:e=>{this._alwaysSerializeFieldExtensions&&this.fieldExtensions.remove(e)},equals:(e,i)=>isFieldExtension(i)?i===e:!(!i?.field||!FieldExtension.matchesRef(e,i.field))||e.id===i.id})}},types:{serialize:!1,deserialize:e=>{if(!e)return;const i=e.map((e=>isFeatureType(e)?e:PortalType.toEsriApiFeatureType(e)));compare(this.types,i,{onNew:(e,i)=>{this.types.add(e,i)},onMatch:(e,i,t,s)=>{e!==i&&(e.name=i.name,e.templates=i.templates?[...i.templates]:[],e.domains=i.domains),t!==s&&this.types.reorder(e,s)},onMissing:e=>{this.types.remove(e)},equals:(e,i)=>e.id===i.id})}},timeZone:{serialize:!1,deserialize:e=>{e&&(this.timeZone=e)}}}}};Schema=Schema_1=__decorate([serializable],Schema);export{Schema};class FieldCollectionImpl extends CollectionProxy{constructor(e){super(),this._schema=e,onCollectionPropertyChange(this._schema,"_fields",(e=>{this.emit("change",e),this._fieldLookup=void 0})),e.watch("_fields.length",(()=>this.notifyChange("length")))}get _createFieldLookup(){return this._collection.reduce(((e,i)=>(e.add(i),e)),new WeakSet)}get _expressionFieldsLength(){return this.expressionFields.length}get expressionFields(){if(!this._popupTemplate||!this._popupTemplate.fieldInfos||!this._popupTemplate.expressionInfos)return new Collection;const e=new Collection;for(const i of this._popupTemplate.fieldInfos){const t=i.fieldName.match(fieldWithArcadeXRegex);if(t){const s=this._popupTemplate.expressionInfos.find((e=>e.name===t[1]));if(s){if(!FIELD_INFO_MAP.has(i)){const e=new Field({name:i.fieldName,alias:i.label||s.title||i.fieldName,type:"number"===s.returnType?"double":"string",editable:!1});FIELD_INFO_MAP.set(i,e)}e.add(FIELD_INFO_MAP.get(i))}}}return e}get _collection(){return this._schema._fields.concat(this.expressionFields)}get _popupTemplate(){return this._schema._featureSettings?this._schema._featureSettings.popupTemplate:void 0}includes(e){return this._fieldLookup=this._fieldLookup??this._createFieldLookup,this._fieldLookup.has(e)}clone(){return new FieldCollectionImpl(this._schema)}add(e,i){checkArg("field",e).isNotMissing(),this._fieldLookup=void 0;const t=e.name?e.name.match(fieldWithArcadeXRegex):void 0;if(t){if(!this._popupTemplate)throw new InvalidOperationError("Cannot create a field that references an arcade expression without a feature source and popup template.");const i=this._popupTemplate.expressionInfos.find((e=>e.name===t[1]));if(!i)throw new InvalidOperationError("Cannot create a field that references a non-existent arcade expression.");this._popupTemplate.fieldInfos||(this._popupTemplate.fieldInfos=[]);let s=this._popupTemplate.fieldInfos.find((i=>i.fieldName===e.name));s||(s=new FieldInfo({fieldName:e.name,label:i.title}),this._popupTemplate.fieldInfos.push(s));const l=FIELD_INFO_MAP.get(s);FIELD_INFO_MAP.set(s,e);const o={added:[e],moved:[],removed:l?[l]:[],target:this};this.emit("change",o),this.notifyChange("length"),this.notifyChange("_expressionFieldsLength")}else this._schema._fields.add(e,i);return this}removeAt(e){checkArg("index",e).isNotMissing();const i=this.getItemAt(e);if(!i)return;this._fieldLookup=void 0;if(i.name?i.name.match(fieldWithArcadeXRegex):void 0){const e=this._popupTemplate.fieldInfos.findIndex((e=>e.fieldName===i.name));this._popupTemplate.fieldInfos.splice(e,1);const t={added:[],moved:[],removed:[i],target:this};this.emit("change",t),this.notifyChange("length"),this.notifyChange("_expressionFieldsLength")}else this._schema._fields.remove(i);return i}reorder(e,i){if(e&&this._schema._fields.includes(e))return this._schema._fields.reorder(e,i),e}sort(e){return this._schema._fields.sort(e),this}}class FieldExtensionCollectionImpl extends InitializableCollectionProxy{constructor(e){super(),this._uninitializedFieldExtensions=new Set,this._schema=e,onCollectionPropertyChange(this._schema,"fields",(e=>{const i={added:(e.added||[]).map((e=>this._forField(e))),moved:(e.moved||[]).map((e=>this._forField(e))),removed:(e.removed||[]).map((e=>this._forField(e))),target:this};this.emit("change",i)})),e.watch("fields.length",(()=>this.notifyChange("length")))}get _collection(){return this._schema.fields.map((e=>this._forField(e))).concat(Array.from(this._uninitializedFieldExtensions))}forField(e){if(checkArg("field",e).isNotMissing(),this._schema.fields.includes(e))return this._forField(e)}add(e,i){if(checkArg("fieldX",e).isNotMissing(),e.schema&&e.schema.fieldExtensions.remove(e),e._setSchema(this._schema),e.field){const t=_fieldExtensionMap.get(e.field);if(_fieldExtensionMap.set(e.field,e),t&&t!==e&&this._onRemoved(t),this._schema.fields.includes(e.field))if(void 0===i){const i={added:[e],moved:[],removed:t?[t]:[],target:this};this.emit("change",i)}else this._schema.fields.reorder(e.field,i);else this._schema.fields.add(e.field,i)}else{this._uninitializedFieldExtensions.add(e);const i={added:[e],moved:[],removed:[],target:this};this.emit("change",i)}return this._onAdded(e),this}removeAt(e){const i=this.getItemAt(e);if(void 0!==i){if(this._uninitializedFieldExtensions.has(i)){this._uninitializedFieldExtensions.delete(i);const e={added:[],moved:[],removed:[i],target:this};this.emit("change",e)}else this._schema.fields.remove(i.field);return this._onRemoved(i),i}}reorder(e,i){if(e&&this._schema.fields.includes(e.field))return this._schema.fields.reorder(e.field,i),e}sort(e){return this._schema.fields.sort(((i,t)=>e(this._forField(i),this._forField(t)))),this}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.field}_onAdded(e){}_onRemoved(e){e.schema===this._schema&&e._setSchema(void 0)}_forField(e){if(this._uninitializedFieldExtensions.size)for(const e of this._uninitializedFieldExtensions)e._resolveField(),e.field&&(_fieldExtensionMap.set(e.field,e),this._uninitializedFieldExtensions.delete(e));if(!_fieldExtensionMap.has(e)){const i=new FieldExtension({field:e});_fieldExtensionMap.set(e,i),i._setSchema(this._schema),this._onAdded(i)}return _fieldExtensionMap.get(e)}}
|
|
@@ -232,7 +232,7 @@ declare namespace __esri {
|
|
|
232
232
|
usesGeometry: boolean | number;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
//
|
|
235
|
+
// ESRI426 - Check if the extended interfaces below are still necessary.
|
|
236
236
|
|
|
237
237
|
export interface SceneLayer {
|
|
238
238
|
associatedLayer: __esri.FeatureLayer;
|
|
@@ -248,22 +248,23 @@ declare namespace __esri {
|
|
|
248
248
|
|
|
249
249
|
export interface FeatureLayer {
|
|
250
250
|
mode: number;
|
|
251
|
-
deleteAttachments(feature: Graphic, attachmentIds: number[]): Promise<FeatureEditResult[]>;
|
|
252
251
|
}
|
|
253
252
|
|
|
254
253
|
export interface SubtypeSublayer extends Accessor {
|
|
255
|
-
visible: boolean;
|
|
256
|
-
opacity: number;
|
|
257
254
|
listMode: "show" | "hide" | "hide-children";
|
|
258
255
|
parent: __esri.SubtypeGroupLayer;
|
|
259
256
|
layer: __esri.SubtypeGroupLayer;
|
|
260
257
|
}
|
|
261
258
|
|
|
259
|
+
export interface Subtype {
|
|
260
|
+
code: number;
|
|
261
|
+
defaultValues: Record<string, unknown>;
|
|
262
|
+
domains: Record<string, CodedValueDomain | RangeDomain>;
|
|
263
|
+
name: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
262
266
|
export interface SubtypeGroupLayer {
|
|
263
|
-
|
|
264
|
-
queryAttachments: __esri.FeatureLayer["queryAttachments"];
|
|
265
|
-
addAttachment: __esri.FeatureLayer["addAttachment"];
|
|
266
|
-
deleteAttachments: __esri.FeatureLayer["deleteAttachments"];
|
|
267
|
+
subtypes: Subtype[];
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
export interface Renderer {
|
|
@@ -307,8 +308,9 @@ declare namespace __esri {
|
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
export interface ImageryLayer {
|
|
310
|
-
// This
|
|
311
|
-
|
|
311
|
+
// This used to be exposed publicly, now it's private and their docs
|
|
312
|
+
// specify that raster fields are always prefixed with "Raster."
|
|
313
|
+
_rasterAttributeTableFieldPrefix: string;
|
|
312
314
|
}
|
|
313
315
|
|
|
314
316
|
export interface StreamLayerView {
|