import type GraphObjectType from "./GraphObjectType.js";
import type { GraphObjectTypeProperties } from "./GraphObjectType.js";

export interface RelationshipTypeProperties extends GraphObjectTypeProperties, Partial<Pick<RelationshipType, "endPoints">> {}

/**
 * A relationship type defines a homogenous collection of [relationships](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-Relationship.html) that can exist between two [entity types](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-EntityType.html),
 * with a common set of properties. For example, a relationship type defining vehicle
 * ownership can associate a vehicle with a person, and the relationship can have properties such as the date a person
 * bought the car and the date a person sold the car.
 *
 * Many instances of a relationship type can be added to the knowledge graph. For example, to describe a family, multiple instances of the spouse-of,
 * parent-of, and child-of relationships can be defined between two-person entities. Multiple instances of owns, leases,
 * or rents relationship types can be defined between a person entity and vehicle or building entities.
 *
 * @since 4.25
 * @see [EntityType](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-EntityType.html)
 * @see [Relationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-Relationship.html)
 */
export default class RelationshipType extends GraphObjectType {
  constructor(properties?: RelationshipTypeProperties);
  /**
   * Specifies valid origin and destination [entity type](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-EntityType.html) pairs for this relationship.
   *
   * @example
   * //endpoints for the employed_by relationship
   * "endpoints": [
   *  {
   *   "originEntityType": "Person",
   *   "destinationEntityType": "Company"
   *  }
   * ]
   */
  accessor endPoints: RelationshipTypeEndPoint[];
}

export interface RelationshipTypeEndPoint {
  /** The `name` of the destination [entity type](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-EntityType.html). */
  destinationEntityType: string;
  /** The `name` of the origin [entity type](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-knowledgeGraph-EntityType.html). */
  originEntityType: string;
}