import type Accessor from "../../core/Accessor.js";
import type EsriError from "../../core/Error.js";
import type KnowledgeGraph from "./KnowledgeGraph.js";

export interface GraphDataModelOperationResultProperties extends Partial<Pick<GraphDataModelOperationResult, "decoderError" | "results" | "resultsCount" | "updatedKnowledgeGraph">> {}

/**
 * The result returned after modifying a knowledge graph data model. This contains information on the number of modifications made,
 * errors encountered when executing the operation or errors encountered decoding the results.
 *
 * @since 4.33
 */
export default class GraphDataModelOperationResult extends Accessor {
  constructor(properties?: GraphDataModelOperationResultProperties);
  /** Any errors encountered while decoding the results. */
  accessor decoderError: EsriError | null;
  /** Information about the add, update or delete modifications made to the data model. */
  accessor results: Array<ResultsObject>;
  /**
   * The number of modifications made to the graph.
   *
   * @default 0
   */
  accessor resultsCount: number;
  /** The updated knowledge graph with the applied additions, updates, and deletions. */
  accessor updatedKnowledgeGraph: KnowledgeGraph | null;
}

/** Information about the success of adding a new entity type or relationship type to the graph. */
export interface ResultsObject {
  /** The name based on the operation that created the results e.g. namedType, graph property name, index names etc. */
  name: string;
  /** Any errors encountered while adding, deleting or updating the data model. */
  error?: EsriError;
}