import Layer from '@arcgis/core/layers/Layer'; import Sublayer from '@arcgis/core/layers/support/Sublayer'; import { AsyncStore } from 'store-api/api'; /** * Provides an API to create custom store instances. * * @example * Use the service name `agssearch.AGSStoreFactory` to obtain a {@link AGSStoreFactory} reference for your component: * ```json * "components": [ * { * "name": "MyExampleComponent", * "references": [ * { * "name": "_storeFactory", * "providing": "agssearch.AGSStoreFactory" * } * ] * } * ] * ``` * * @example * Use the obtained {@link AGSStoreFactory} to create new store instances. * ```ts * class MyExampleComponent { * _storeFactory: InjectedReference; * async exampleMethod() { * const store = await this._storeFactory!.createStore({ * id: "my-new-store", * layerId: "a-valid-layer-id" * // or url: "https://example.com/some/FeatureServer" * }); * } * } * ``` * * @module */ /** * Factory used to created new store instances. * * Use service name `"agssearch.AGSStoreFactory"` to inject an instance of this factory. */ interface AGSStoreFactory { /** * Creates a new store instance backed by an ArcGIS Feature Server or Map Server. * Either the `layerId` parameter or the `url` parameter must be specified. * * @example * ```ts * const store = await this._storeFactory.createStore({ * id: "my-new-store", * layerId: "a-valid-layer-id" * // or url: "https://example.com/some/FeatureServer" * }); * await store.load(); // Need to load metadata before store can be used. * ``` */ createStore(options: AGSStoreFromLayerOptions | AGSStoreFromURLOptions): Promise; } /** * Properties supported by AGSStores. */ interface AGSStoreCommonOptions { /** The id of the new store. */ id: string; } /** * Specifies an AGSStore constructed from a layer or sublayer id. */ interface AGSStoreFromLayerOptions extends AGSStoreCommonOptions { /** A valid layer id (e.g. `"mylayer"`) or sub layer id (e.g. `"mylayer/1"`). */ layerId: string; } /** * Specifies an AGSStore constructed from a URL. */ interface AGSStoreFromURLOptions extends AGSStoreCommonOptions { /** * A service url, for services that are not in the map. */ url: string; /** * The type of the service. Defaults to "feature". */ type?: "feature" | "geojson" | "csv" | "wfs" | "ogc-feature" | "scene"; /** * An API key (or token) required to access the service. * * See also https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#apiKey */ apiKey?: string; /** * Specifies the name of the WFS layer. */ name?: string; /** * A list of URL parameters which will be appended during fetching of the layer. */ customParameters?: object; /** * Specifies the collectionId of a ogc-feature layer. */ collectionId?: string; /** * Specifies the objectIdField of a ogc-feature layer. * Default is 'id' */ objectIdField?: string; /** * Flag for ogc-feature layer, to enable queries for features using the objectIdField property. * Default is false. */ supportsIdQueries?: boolean; /** * Flag to indicate that the layer supports filtering using POST requests. * Default is `false` for non ArcGIS OGCFeaturesServices, * which means that requests with long query strings will fail. * If `supportsIdQueries` is `true` and `supportsPostQueries` is `false` * then these id queries are split to ensure GET requests are used for feature lookup by ids. */ supportsPostQueries?: boolean; /** * Name of the geometry field for polygon queries against OGCFeatureServices. */ geometryFieldName?: string; } /** * The type of stores created by the {@link AGSStoreFactory}. */ interface AGSStore extends AsyncStore { /** * The URL of the layer queried by this store. * Undefined if this store works on a client side layer. */ url: string | undefined; /** @deprecated Use {@link url} instead. */ target: string | undefined; /** * The layer used by this store. */ layer: Layer | Sublayer; /** * Manually loads required metadata from backend services if needed. * * Some methods (such as query) may not be available before metadata have been loaded. * * > Note: Metadata can also be loaded by calling {@link AsyncStore.getMetadata}. */ load(): Promise; } export type { AGSStore, AGSStoreCommonOptions, AGSStoreFactory, AGSStoreFromLayerOptions, AGSStoreFromURLOptions };