import type SpatialReference from "../../geometry/SpatialReference.js";
import type { JSONSupport } from "../../core/JSONSupport.js";

export interface ServiceDefinitionProperties {}

/**
 * Outlines the service capabilities for a [knowledgeGraphService](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/).
 *
 * @since 4.26
 * @example
 * {
 * 	"allowGeometryUpdates": false,
 * 	"capabilities": [
 * 		"Delete",
 * 		"Query",
 * 		"Create",
 * 		"Editing",
 * 		"Update"
 * 	],
 * 	"copyrightText": "2023 Esri, all rights reserved",
 * 	"currentVersion": 11.0,
 * 	"dataEditingNotSupported": false,
 * 	"dateFieldsTimeReference": {
 * 		"respectsDaylightSaving": false,
 * 		"timeZone": "UTC"
 * 	},
 * 	"description": "Supply chain data",
 * 	"maxRecordCount": 2000,
 * 	"schemaEditingNotSupported": false,
 * 	"searchMaxRecordCount": 2000,
 * 	"serviceCapabilities": {
 * 		"applyEditsCapabilities": {
 * 			"graphDefaultRollbackOnFailure": false
 * 		},
 * 		"geometryCapabilities": {
 * 			"geometryMaxBoundingRectangleSizeX": 180,
 * 			"geometryMaxBoundingRectangleSizeY": 180,
 * 			"supportedGeometryTypes": [
 * 				"Point",
 * 				"Mulitpoint",
 * 				"Polyline",
 * 				"Polygon"
 * 			],
 * 			"supportsMValues": false,
 * 			"supportsZValues": false
 * 		},
 * 		"indexCapabilities": {
 * 			"supportsDecendingIndex": false,
 * 			"supportsRelationshipIndex": true,
 * 			"supportsUniqueRelationshipConstraint": false
 * 		}
 * 	},
 * 	"searchCapabilities": {
 * 		"allowLeadingWildcardQueries": true,
 * 		"searchTypeFilterCapabilities": [
 * 			"esriTypeEntity",
 * 			"esriTypeRelationship",
 * 			"esriTypeBoth"
 * 		]
 * 	},
 * 	"serviceItemId": "87941a7420e84933882502ff2e9a5c34",
 * 	"spatialReference": {
 * 		"wkid": 4326
 * 	},
 * 	"supportedQueryFormats": [
 * 		"PBF"
 * 	],
 * 	"supportsDocuments": true,
 * 	"supportsSearch": true,
 * 	"units": "esriDecimalDegrees",
 * 	"url": "https://myHostName.domain.com/server/rest/services/Hosted/myServiceName/KnowledgeGraphServer"
 * }
 */
export default class ServiceDefinition extends JSONSupport {
  constructor(properties?: ServiceDefinitionProperties);
  /**
   * Indicates if geometry data in the graph can be modified. If `false` [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) on geometry properties will fail.
   *
   * @default false
   */
  get allowGeometryUpdates(): boolean;
  /**
   * Specifies the operational capabilities of the knowledge graph.
   *
   * @example ["Query", "Editing", "Delete", "Create", "Update"]
   */
  get capabilities(): string[];
  /**
   * Copyright information for the knowledge graph.
   *
   * @default ""
   */
  get copyrightText(): string;
  /** The version number of the ArcGIS Enterprise instance where the knowledge graph service is hosted. */
  get currentVersion(): number | null | undefined;
  /**
   * Indicates if data editing is not supported. If `true` [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) will fail.
   *
   * @default false
   */
  get dataEditingNotSupported(): boolean;
  /** Specifies the timezone for dateTime fields. */
  get dateFieldsTimeReference(): ServiceDefinitionDateFieldsTimeReference | null | undefined;
  /**
   * The description of the service.
   *
   * @default ""
   */
  get description(): string;
  /** The maximum number of records returned by a [query](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeQuery) operation. */
  get maxRecordCount(): number | null | undefined;
  /**
   * Indicates if the knowledge graph schema (data model) can be edited. Schema editing is not currently supported in the JS API,
   * if `false` any updates to the schema must be made through the [ArcGIS REST API for Knowledge Graph](https://developers.arcgis.com/rest/services-reference/enterprise/kgs-datamodel-edit-update-admin.htm).
   *
   * @default false
   */
  get schemaEditingNotSupported(): boolean;
  /** The maximum number of records returned by a [search](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeSearch) operation. */
  get searchMaxRecordCount(): number | null | undefined;
  /**
   * specifies the details of the index, edit, search and  geometry capabilities of the service.
   *
   * @example
   * "serviceCapabilities": {
   * 	"applyEditsCapabilities": {
   * 		"graphDefaultRollbackOnFailure": false
   * 	},
   * 	"geometryCapabilities": {
   * 		"geometryMaxBoundingRectangleSizeX": 180,
   * 		"geometryMaxBoundingRectangleSizeY": 180,
   * 		"supportedGeometryTypes": [
   * 			"Point",
   * 			"Mulitpoint",
   * 			"Polyline",
   * 			"Polygon"
   * 		],
   * 		"supportsMValues": false,
   * 		"supportsZValues": false
   * 	},
   * 	"indexCapabilities": {
   * 		"supportsDecendingIndex": false,
   * 		"supportsRelationshipIndex": true,
   * 		"supportsUniqueRelationshipConstraint": false
   * 	}
   * 	},
   * 	"searchCapabilities": {
   * 	"allowLeadingWildcardQueries": true,
   * 	"searchTypeFilterCapabilities": [
   * 		"esriTypeEntity",
   * 		"esriTypeRelationship",
   * 		"esriTypeBoth"
   * 	]
   * }
   */
  get serviceCapabilities(): ServiceDefinitionServiceCapabilities;
  /**
   * The ArcGIS Enterprise Portal item id of the knowledge graph service.
   *
   * @default ""
   */
  get serviceItemId(): string;
  /** Specifies the [SpatialReference](https://developers.arcgis.com/javascript/latest/references/core/geometry/SpatialReference/) information for the knowledge graph service. */
  get spatialReference(): SpatialReference | null | undefined;
  /** The query formats supported by the service. */
  get supportedQueryFormats(): string[];
  /**
   * Indicates if the service supports entity types with a document [GraphProperty.role](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphProperty/#role).
   *
   * @default false
   */
  get supportsDocuments(): boolean;
  /**
   * Indicates if the service supports provenance. If `false` provenance cannot be used or returned in
   * [GraphQueryStreaming.provenanceBehavior](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphQueryStreaming/#provenanceBehavior).
   *
   * @default false
   * @see [An introduction to provenance](https://pro.arcgis.com/en/pro-app/latest/help/data/knowledge/essential-arcgis-knowledge-vocabulary.htm#ESRI_SECTION1_C9608B7C05C8496CB93CE310F1335AE8)
   * @see [Adding provenance to a knowledge graph](https://pro.arcgis.com/en/pro-app/latest/help/data/knowledge/add-provenance-to-a-knowledge-graph.htm)
   */
  get supportsProvenance(): boolean;
  /**
   * Indicates if the services supports search operations. If false, [executeSearch()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeSearch) will fail.
   *
   * @default false
   */
  get supportsSearch(): boolean;
  /**
   * The units for the spatial reference.
   *
   * @default ""
   * @example units: "esriDecimalDegrees"
   */
  get units(): string;
}

export interface ServiceDefinitionServiceCapabilities {
  /** Information on the supported capabilities of indexes in the knowledge graph service. */
  indexCapabilities: ServiceDefinitionServiceCapabilitiesIndexCapabilities;
  /**
   * Information on the supported capabilities of the the
   * [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) operation.
   */
  applyEditsCapabilities: ServiceDefinitionServiceCapabilitiesApplyEditsCapabilities;
  /**
   * Information on the supported capabilities of
   * [search](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeSearch) operations in the knowledge graph service.
   */
  searchCapabilities: ServiceDefinitionServiceCapabilitiesSearchCapabilities;
  /** Information on the supported capabilities of geometries in the knowledge graph service. */
  geometryCapabilities: ServiceDefinitionServiceCapabilitiesGeometryCapabilities;
}

export interface ServiceDefinitionServiceCapabilitiesIndexCapabilities {
  /** Specifies if the service supports indexes in descending order. */
  supportsDescendingIndex: boolean;
  /** Specifies if the system supports creating unique constraints for relationship types */
  supportsUniqueRelationshipConstraint: boolean;
  /** Specifies if the service supports indexes on relationships. */
  supportsRelationshipIndex: boolean;
}

export interface ServiceDefinitionServiceCapabilitiesApplyEditsCapabilities {
  /** If `true`, when an apply edits operation fails, the data will revert to it's state before the change. */
  graphDefaultRollbackOnFailure: boolean;
}

export interface ServiceDefinitionServiceCapabilitiesSearchCapabilities {
  /** The search category filters supported by this service. */
  searchTypeFilterCapabilities: ("esriTypeEntity" | "esriTypeRelationship" | "esriTypeBoth")[];
  /** Specifies if search strings can contain a leading wildcard operator (`*`). */
  allowLeadingWildcardQueries: boolean;
}

export interface ServiceDefinitionServiceCapabilitiesGeometryCapabilities {
  /** The maximum bounding rectangle size along the x-axis. */
  geometryMaxBoundingRectangleSizeX: number;
  /** The maximum bounding rectangle size along the y-axis. */
  geometryMaxBoundingRectangleSizeY: number;
  /** Specifies if the knowledge graph service supports m-values on geometry. */
  supportsMValues: boolean;
  /** Specifies if the knowledge graph service supports z-values on geometry. */
  supportsZValues: boolean;
  /** Specifies what geometry types are supported by the graph such as `Point`, `Multipoint`, `Polyline`, `Polygon`. */
  supportedGeometryTypes: string[];
}

export interface ServiceDefinitionDateFieldsTimeReference {
  /** Indicates if datetime fields respects daylight savings. */
  respectsDaylightSaving: boolean;
  /** the timezone for all datetime fields. */
  timeZone: string;
}