import type Accessor from "../../../core/Accessor.js"; import type Collection from "../../../core/Collection.js"; import type Relationship from "../../../layers/support/Relationship.js"; import type AttachmentInfo from "../../../rest/query/support/AttachmentInfo.js"; import type TimeExtent from "../../../time/TimeExtent.js"; import type SelectionManager from "../../../views/SelectionManager.js"; import type LayerView from "../../../views/layers/LayerView.js"; import type { FeatureEditResult } from "../../../editing/types.js"; import type { GeometryUnion } from "../../../geometry/types.js"; import type { TimeZone } from "../../../time/types.js"; import type { MapViewOrSceneView } from "../../../views/MapViewOrSceneView.js"; import type { ObjectId } from "../../../views/types.js"; import type { HighlightableLayerView } from "../../../views/layers/HighlightableLayerView.js"; import type { DiscardPendingEditsParameters, FeatureStoreEdits, QueryPageParameters, State } from "../Grid/types.js"; import type { ColumnSortOrder, FailedOperation, FeatureStoreItem, FeatureTableSupportedLayer } from "./types.js"; import type { MeshProperties } from "../../../geometry/Mesh.js"; import type { PolylineProperties } from "../../../geometry/Polyline.js"; import type { PolygonProperties } from "../../../geometry/Polygon.js"; import type { PointProperties } from "../../../geometry/Point.js"; import type { MultipointProperties } from "../../../geometry/Multipoint.js"; import type { ExtentProperties } from "../../../geometry/Extent.js"; import type { TimeExtentProperties } from "../../../time/TimeExtent.js"; /** @internal */ export interface FeatureStoreProperties extends Partial> { /** * Geometry used to filter the current table. * * @internal */ filterGeometry?: ((ExtentProperties & { type: "extent" }) | (MultipointProperties & { type: "multipoint" }) | (PointProperties & { type: "point" }) | (PolygonProperties & { type: "polygon" }) | (PolylineProperties & { type: "polyline" }) | (MeshProperties & { type: "mesh" })) | null; /** * The [TimeExtent](https://developers.arcgis.com/javascript/latest/references/core/time/TimeExtent/) in which to filter and display data. * * @internal */ timeExtent?: TimeExtentProperties | null; } /** * Manages data for a set of features, usually displayed in a table. * * @internal */ export default class FeatureStore extends Accessor { /** @internal */ constructor(properties?: FeatureStoreProperties); /** * When `true`, attachment information will be fetched, stored locally and returned by `query()`. * * @default false * @internal */ accessor attachmentsEnabled: boolean; /** * Indicates whether the table should automatically save edits, or store all edits locally until * the 'savePendingEdits' or 'discardPendingEdits' methods are called. * * @default true * @internal */ accessor autoSaveEnabled: boolean; /** * Indicates the number of pages currently cached in the store. * * @internal */ get cachedPageCount(): number; /** * Indicates whether the table supports adding a related record based on the current relationship * configuration. This accounts for whether table is currently configured to show related features. * If the table is not displaying related features, then the value of this property is always false. * * @internal */ get canAddRelatedFeature(): boolean; /** * The default selection manager used when a user does not provide one and 'syncViewSelection' is false. * * @internal */ get defaultSelectionManager(): SelectionManager; /** * Indicates features should be editable in the table. This does not account for whether the layer supports editing or not. * * @default false * @internal */ accessor editingEnabled: boolean; /** * Effective set of fields to be returned by data queries. * * @internal */ get effectiveOutFields(): string[]; /** * Reference to the effective selection manager currently in use by the store. * * @internal */ get effectiveSelectionManager(): SelectionManager; /** * Reference to the effective size of the store, accounting for 'maxSize'. * * @internal */ get effectiveSize(): number; /** * The 'effective' [TimeExtent](https://developers.arcgis.com/javascript/latest/references/core/time/TimeExtent/) used to filter and display data. * * @internal */ get effectiveTimeExtent(): TimeExtent | undefined; /** * The 'effective' where clause used by data queries. * * @internal */ get effectiveWhere(): string; /** * An array of objects containing information specific to any failed editing operations. * In addition to the error(s), options to `retry()` or `cancel()` are provided. * * @internal */ get failures(): Collection; /** * Set of all layer fields with contingent values. * * @internal */ get fieldsWithContingentValues(): Set; /** * Indicates the table should honor layer view scale visibility. If the layerView is out of scale, the table will be empty. * * @default false * @internal */ accessor filterByLayerScaleRange: boolean; /** * Indicates that the table should only display rows for features that are currently in the view's extent. * This property has no effect if the table has not been provided a view. If this property is true, the view's extent * will overwrite the current value of [FeatureTable.filterGeometry](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/#filterGeometry). * * @default false * @internal */ accessor filterByViewExtent: boolean; /** * Geometry used to filter the current table. * * @internal */ get filterGeometry(): GeometryUnion | null | undefined; set filterGeometry(value: ((ExtentProperties & { type: "extent" }) | (MultipointProperties & { type: "multipoint" }) | (PointProperties & { type: "point" }) | (PolygonProperties & { type: "polygon" }) | (PolylineProperties & { type: "polyline" }) | (MeshProperties & { type: "mesh" })) | null | undefined); /** * Convenience property indicating the current data contains contingent values. * * @internal */ get hasContingentValues(): boolean; /** * Indicates there are unsaved edits and that they are invalid. * * @internal */ get hasInvalidPendingEdits(): boolean; /** * Indicates there are unsaved edits. This does not account for whether the edits are valid or not. * * @internal */ get hasPendingEdits(): boolean; /** * Reference to a supported layerView used for highlighting. The current layer must be added to * the provided view for the layer view to be detectable. * * @internal */ get highlightableLayerView(): HighlightableLayerView | null | undefined; /** * Indicates selected features should be highlighted on the view, as long as a view is provided. * This also applies to features temporarily highlighted when hovering over a table row. * * @default true * @internal */ accessor highlightEnabled: boolean; /** * User provided value for the total number of features available from the data source. * When the store is first loaded, this value is used instead of querying the provided layer. * Table will still make additional count queries when data integrity needs to be verified, or is * requested via the use of 'refresh()'. * * @internal */ accessor initialSize: number | null | undefined; /** * When `true`, there is at least one query request being processed. * * @internal */ get isQuerying(): boolean; /** * When `true`, there is at least one edit request being processed. * * @internal */ get isSyncing(): boolean; /** * Indicates the store is currently syncing attachment edits with the service. * * @internal */ get isSyncingAttachmentEdits(): boolean; /** * Indicates the store is currently syncing feature attribute edits with the service. * * @internal */ get isSyncingFeatureEdits(): boolean; /** * A collection of item objects containing features and associated attachments. * Indices of items in the Collection do not represent the actual row index. * Instead, use the 'getItemIndexByObjectId()' utility method. * * @internal */ get itemCache(): Collection; /** * A reference to the layer from which to fetch feature data. * * @internal */ accessor layer: FeatureTableSupportedLayer | null | undefined; /** * The layer view associated with the current layer. * * @internal */ get layerView(): LayerView | null | undefined; /** * This property controls the upper limit of features that can be displayed in the table. When `null`, all features are displayed. * * @internal */ accessor maxSize: number | null | undefined; /** * Indicates which features should be displayed in the table. When `null`, all features are displayed. * * @internal */ accessor objectIds: ObjectId[] | null | undefined; /** * Indicates the order in which features should be sorted in the table, accounting for the 'sortOrders' property. * * @internal */ get orderByFields(): string[]; /** * Indicates which fields should be returned by data queries. When `null`, data for all fields are returned. * * @internal */ accessor outFields: string[] | null | undefined; /** * Indicates the number of pages to be displayed in the table, accounting for size and pageSize. * * @internal */ get pageCount(): number; /** * Controls the current page of data to be displayed in the table. * This is only relevant when 'paginationEnabled' is true. * * @internal */ accessor pageIndex: number; /** * Controls the number of features per page of data. Data queries will be limited to this number of features per request. * * @default 50 * @internal */ accessor pageSize: number; /** * Indicates the table should only display a single page at any time. * * @default false * @internal */ accessor paginationEnabled: boolean; /** * The total number of individual cells with pending edits. * * @internal */ get pendingEditsCount(): number; /** * Indicates the store should query for related records if at least one relationship and related layer has been found on the provided view. * * @default false * @internal */ accessor relatedRecordsEnabled: boolean; /** * Reference to the relationship being displayed in the table, based on the current relationship configuration. * * @internal */ get relationship(): Relationship | null | undefined; /** * An array of unique identifiers for all relationships found on the provided layer. * This information is used to fetch related records for each relationship, in order to * determine related feature counts for each individual feature or row. * * @internal */ get relationshipIds(): number[]; /** * A reference to all relationships on the current layer, if applicable. * * @internal */ get relationships(): Relationship[] | null | undefined; /** * Indicates the store should request geometries when querying for feature data. * By default, geometries are not requested to improve performance. * * @default false * @internal */ accessor returnGeometry: boolean; /** * Indicates the store should request m geometry information when querying for feature data. * * @default false * @internal */ accessor returnM: boolean; /** * Indicates the store should request z geometry information when querying for feature data. * * @default false * @internal */ accessor returnZ: boolean; /** * This property can be used to provide a custom selection manager that overrides the default selection manager. * This is useful when applications want to share selection sets between components, without relying on the view's selection manager. * This property is ignored if [syncViewSelection](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FeatureStore/#syncViewSelection) is `true` and a 'view' has been provided. * * @internal */ accessor selectionManager: SelectionManager | null | undefined; /** * Indicates the current number of features on the provided layer, accounting for any active filters. * * @internal */ get size(): number; /** * Indicates the order in which features should be returned via data queries. * * @internal */ accessor sortOrders: ColumnSortOrder[]; /** * Indicates the current state of the store. * * @internal */ get state(): State; /** * Indicates the provided layer supports adding new features. * * @internal */ get supportsAdd(): boolean; /** * Indicates the provided layer supports adding new attachments. * * @internal */ get supportsAddAttachments(): boolean; /** * Indicates the provided layer supports viewing attachments. * * @internal */ get supportsAttachments(): boolean; /** * Indicates the provided layer supports cache hint for data queries. * * @internal */ get supportsCacheHint(): boolean; /** * Indicates the provided layer supports cache hint for querying related feature data. * * @internal */ get supportsCacheHintQueryRelated(): boolean; /** * Indicates the provided layer supports deletion of existing features. * * @internal */ get supportsDelete(): boolean; /** * Indicates the provided layer supports general editing. * * @internal */ get supportsEditing(): boolean; /** * Indicates the provided layer supports m values in geometries. * * @internal */ get supportsM(): boolean; /** * Indicates the provided layer supports the 'orderByFields' parameter in data queries. * * @internal */ get supportsOrderBy(): boolean; /** * Indicates the provided layer supports pagination for data queries. * * @internal */ get supportsPagination(): boolean; /** * Indicates the provided layer supports querying for feature data. * If this value is false, the store will be unable to fetch any data to display. * * @internal */ get supportsQuery(): boolean; /** * Indicates the provided layer supports querying for related feature data. * * @internal */ get supportsQueryRelated(): boolean; /** * Indicates the provided layer supports resizing attachment thumbnails. * * @internal */ get supportsResizeAttachments(): boolean; /** * Indicates the provided layer supports updating feature attributes and geometries. * * @internal */ get supportsUpdate(): boolean; /** * Indicates the provided layer supports adding or updating existing attachments. * * @internal */ get supportsUpdateAttachments(): boolean; /** * Indicates the provided layer supports geometries with z values. * * @internal */ get supportsZ(): boolean; /** * Indicates whether the FeatureTable should sync with the view's [selection manager](https://developers.arcgis.com/javascript/latest/references/core/views/SelectionManager/). * Enabling this does not automatically inherit the [selection sources](https://developers.arcgis.com/javascript/latest/references/core/views/SelectionManager/#sources) from the [SelectionManager](https://developers.arcgis.com/javascript/latest/references/core/views/SelectionManager/), (e.g. which layers or graphics collections the view listens to for selections). * If you need specific selection sources, configure them separately via [SelectionManager.sources](https://developers.arcgis.com/javascript/latest/references/core/views/SelectionManager/#sources). * * This property takes precedence over the [selectionManager](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/FeatureStore/#selectionManager) property. * * @default false * @internal */ accessor syncViewSelection: boolean; /** * Controls temporary highlight of a specific row. * * @internal */ accessor temporaryHighlightId: ObjectId | undefined; /** * The [TimeExtent](https://developers.arcgis.com/javascript/latest/references/core/time/TimeExtent/) in which to filter and display data. * * @internal */ get timeExtent(): TimeExtent | null | undefined; set timeExtent(value: TimeExtentProperties | null | undefined); /** * The time zone that the data is displayed in. * * @internal */ accessor timeZone: TimeZone | null | undefined; /** * A reference to a view. If the provided layer exists on this view, then the store will attempt to look for related layers on the view. * * @internal */ accessor view: MapViewOrSceneView | null | undefined; /** * Controls time extent filtering behavior for the table. When `true`, the table's time extent will be derived from the intersection of the * view and layer's time extent. When `false`, only the layer's time extent will be considered. * * When 'timeExtent' is defined, only that time extent will be used and this property will be ignored. * * @default false * @internal */ accessor viewTimeEnabled: boolean; /** * A reference to a where clause to use when querying for feature data. This value overrides the layer's definitionExpression. * * @internal */ accessor where: string | null | undefined; /** * Attempts to add an attachment to a specific feature. If editing is disabled, or the layer does not * support adding attachments, this method will return an empty result. * * @param objectId - The object ID of the feature to which the attachment should be added. * @param form - The form data containing the attachment information. * @returns A promise that resolves to a FeatureEditResult indicating the success or failure of the operation. * @internal */ addAttachment(objectId: ObjectId, form: HTMLFormElement | FormData): Promise; /** * Attempts to create a cached edit with the specified parameters. Editing must be enabled and supported by the provided layer. * A cached edit is not immediately saved to the layer. * Cached edits must be saved or discarded with the 'savePendingEdits' or 'discardPendingEdits' methods, respectively. * * @param edits - An array of FeatureStoreEdits objects representing the edits to be added to the cache. * @internal */ addPendingEdits(edits: FeatureStoreEdits[]): void; /** * Attempts to delete attachments from a specific feature. If editing is disabled, or the layer does not support * deleting attachments, this method will return an empty result. * * @param objectId - The object ID of the feature from which the attachments should be deleted. * @param attachmentIds - The IDs of the attachments to be deleted. * @returns A promise that resolves to an array of FeatureEditResult objects indicating the success or failure of each operation. * @internal */ deleteAttachments(objectId: ObjectId, attachmentIds: number[]): Promise; /** @internal */ destroy(): void; /** * Cancels any pending edits. This might be edits for a specific field or column, or * all edits for a specific feature. If no parameters are supplied, all pending edits * are discarded. * * @param edits - An optional array of DiscardPendingEditsParameters objects representing the edits to be discarded. If not provided, all pending edits will be discarded. * @internal */ discardPendingEdits(edits?: DiscardPendingEditsParameters[] | null | undefined): void; /** * Returns attachments for a provided feature. If 'force' is true, the store will query the server for attachments if none can be found locally. * * @param objectId - The object ID of the feature for which to retrieve attachments. * @param force - An optional boolean indicating whether to force a server query for attachments if none are found locally. Defaults to false. * @returns A promise that resolves to an array of AttachmentInfo objects representing the attachments for the specified feature. * @internal */ getAttachmentsByObjectId(objectId: ObjectId, force?: boolean): Promise; /** * Returns cached features for a specific page index. If no cached features are found for the specified page, undefined is returned. * * @param pageIndex - The index of the page for which to retrieve cached features. * @returns An array of FeatureStoreItem objects representing the cached features for the specified page, or undefined if no cached features are found for that page. * @internal */ getCachedFeaturesByPageIndex(pageIndex: number): FeatureStoreItem[] | undefined; /** * Returns a string representing the provided feature. If the feature does not exist locally an extra query is * made to the server to retrieve the feature information. Additionally, if 'force' is true, the store will query the * server regardless of whether the feature exists locally or not. * * @param objectId - The object ID of the feature for which to retrieve the title. * @param force - An optional boolean indicating whether to force a server query for the feature title. Defaults to false. * @returns A promise that resolves to a string representing the title of the specified feature. * @internal */ getFeatureTitle(objectId: ObjectId, force?: boolean): Promise; /** * Returns a reference to the item in the store that matches the provided object ID. If no item is found, undefined is returned. * * @param objectId - The object ID of the feature for which to retrieve the item. * @returns An item object containing the feature and any associated attachments or related features, or undefined if no item is found. * @internal */ getItemByObjectId(objectId: ObjectId): FeatureStoreItem | undefined; /** * Returns the index of the item in the store that matches the provided object ID. If no item is found, -1 is returned. * * @param objectId - The object ID of the feature for which to retrieve the index. * @returns The index of the item in the store, or -1 if no item is found. * @internal */ getItemIndexByObjectId(objectId: ObjectId): number; /** * Indicates the associated feature (row) and field (cell) has an invalid pending edit. * * @param objectId - The object ID of the feature to check for invalid pending edits. * @param fieldName - An optional field name to check for invalid pending edits. If not provided, the method will check for any invalid pending edits on the feature. * @returns A boolean indicating whether the feature and field have an invalid pending edit. * @internal */ itemHasInvalidPendingEdits(objectId: ObjectId, fieldName?: string): boolean; /** * Indicates the associated feature (row) and field (cell) has a pending edit. * * @param objectId - The object ID of the feature to check for pending edits. * @param fieldName - An optional field name to check for pending edits. If not provided, the method will check for any pending edits on the feature. * @returns A boolean indicating whether the feature and field have a pending edit. * @internal */ itemHasPendingEdits(objectId: ObjectId, fieldName?: string): boolean; /** * Attempts to load or re-load the store. This will cause the store to discard all cached data and * request an updated count from the provided layer. This method also causes the store to discard any pending edits. * * @internal */ load(): Promise; /** * Used to request data for a specific page of features. If the store is not in a loaded state, or * the layer is not set, or the layer does not support querying, an empty array is returned. * * @param params - An object containing the parameters for the data query, including the page index and page size. * @returns A promise that resolves to an array of FeatureStoreItem objects representing the features for the requested page. * @internal */ queryPage(params: QueryPageParameters): Promise; /** * Attempts to load or re-load the store. This will cause the store to discard all cached data and * request an updated count from the provided layer. However, this will not cause the store to unload, preserving * the current page index and any other client-side changes, including any pending edits. * * @internal */ refresh(): Promise; /** * Discards all cached data and resets the store to its initial state. * The store will not automatically re-load, so the 'load' method must be called. * * @internal */ reset(): void; /** * Attempts to save any pending edits. If any edits are invalid, the save will be rejected until the edits are in a valid state. * * @internal */ savePendingEdits(): Promise; /** * Syncs the internal selection manager. This includes updating the view reference and * adding the current layer to its selection sources. This is typically done automatically. * * @internal */ syncSelectionSources(): void; /** * Attempts to update an attachment for a specific feature. If editing is disabled, or the layer does not * support updating attachments, this method will return an empty result. * * @param objectId - The object ID of the feature for which the attachment should be updated. * @param attachmentId - The ID of the attachment to be updated. * @param form - The form data containing the updated attachment information. * @returns A promise that resolves to a FeatureEditResult indicating the success or failure of the operation. * @internal */ updateAttachment(objectId: ObjectId, attachmentId: number, form: HTMLFormElement | FormData): Promise; /** * Updates an item in the store, or caches a (pending) edit to save at a later time. * This is a convenience method used by the Column classes instead of having to * determine if the edit is pending (should be cached). * * @param edits - The edits to apply to the item. * @returns A promise that resolves when the update is complete, or rejects if an error occurs. * @internal */ updateItem(edits: FeatureStoreEdits): Promise; /** * Used to ensure any provided features still exist on the provided layer. This is useful for determining if a feature has * been deleted or otherwise removed from the layer from outside the store. * * @param ids - The object IDs of the features to verify. * @returns A promise that resolves with an array of booleans, where each boolean corresponds to the provided object IDs. A value of 'true' indicates the feature still exists, while 'false' indicates it does not. * @internal */ verifyFeaturesByObjectId(ids: ObjectId[]): Promise; }