import type { AbortOptions } from "../../core/promiseUtils.js";
import type { CustomParameters } from "../mixins/CustomParametersMixin.js";

/** An OGC API-Features collection. */
export interface Collection {
  /** The description of the collection. */
  description?: string;
  /**
   * The collection identifier.
   *
   * @see [OGCFeatureLayer#collectionId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OGCFeatureLayer.html#collectionId)
   */
  id: string;
  /** The landing page of the OGC API-Features server hosting the collection. */
  landingPage: LandingPage;
  /** The title of the collection. */
  title?: string;
}

/** The collections page for an OGC API-Features server. */
export interface CollectionsPage {
  /** An array of collections available from the OGC API-Features server. */
  collections: Collection[];
}

/** The landing page of an OGC API-Features server. */
export interface LandingPage {
  /** The description of the OGC API-Features server. */
  description?: string;
  /** The title of the OGC API-Features server. */
  title?: string;
  /** The url to the OGC API-Features server. */
  url: string;
}

export interface QueryParameters {
  /**
   * An authorization string used to access a resource or service.
   * This property will append the API key to all requests made by the layer to the service.
   * [API keys](https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/) are generated and managed in the portal.
   * An API key is tied explicitly to an ArcGIS account; it is also used to monitor service usage.
   * Setting a fine-grained API key on a specific class overrides the [global API key](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#ConfigWithApiKey).
   *
   * If loading a secure layer with API authentication via a [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html), the API key needs to be set on the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-PortalLayer.html#portalItem).
   *
   * @see [Item access privileges](https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/api-key-credentials/#item-access-privileges)
   * @see [API key guide](https://developers.arcgis.com/javascript/latest/secure-resources/#api-keys)
   * @example
   * // set the api key to access a protected service
   * const layer = new FeatureLayer({
   *   url: serviceUrl,
   *   apiKey: "YOUR_API_KEY"
   * });
   */
  apiKey?: string | null;
  /**
   * A list of custom parameters appended to the URL of all resources fetched by the layer.
   * It's an object with key-value pairs where value is a string.
   * The layer's `refresh()` method needs to be called if the customParameters are updated at runtime.
   *
   * @example
   * // send a custom parameter to your special service
   * let layer = new MapImageLayer({
   *   url: serviceUrl,
   *   customParameters: {
   *     "key": "my-special-key"
   *   }
   * });
   */
  customParameters?: CustomParameters | null;
}

export interface QueryOptions extends QueryParameters, AbortOptions {}