UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

322 lines (315 loc) • 14.2 kB
import type Accessor from "../../core/Accessor.js"; import type EsriError from "../../core/Error.js"; export interface GraphApplyEditsResultProperties extends Partial<Pick<GraphApplyEditsResult, "cascadeProvenanceDeleteResults" | "cascadeRelationshipDeleteResults" | "editResults" | "error" | "hasError">> {} /** * The result of an [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) performed on a knowledge graph service's * [graph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) resource. Summarizes the edits to the graph * and provides any errors encountered in performing the edits. * * @since 4.25 * @see [GraphApplyEdits](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphApplyEdits/) * @example * // sample executeApplyEdits() to add a new entity * const newEntity = new Entity({ * typeName: "Supplier", * properties: { * Name: "Supplier 5", * EmployeeCount: 681 * } * }) * * KnowledgeGraphModule.executeApplyEdits(graph, { * entityAdds: [newEntity], * }) * .then((editResult) => { * console.log("Graph Add Result", editResult); * }); * @example * // Results of adding one entity to the `Supplier` entity type * { * editResults:[{ * adds:[ * { * id: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}", * error: {errorCode: 0, errorMessage: ""} * }], * deletes:[], * typeName: "Supplier", * updates:[] * }], * hasError: false, * error: undefined * } * @example * // example results of a complex executeApplyEdits that involved * // adding, updating and deleting multiple types. * { * editResults:[{ * adds:[ * { * id: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}", * error: {errorCode: 0, errorMessage: ""} * }], * deletes:[], * typeName: "Supplier", * updates:[] * },{ * adds:[{ * id: "{ANWIFHSAS-AW6F-G9W4-8412-A1A8W4F1A5S6F}", * error: {errorCode: 0, errorMessage: ""} * }], * deletes:[{ * id: "{AN4E4G85-Q15F4-49A4-8412-A1W8F4S6A5S4}", * error: {errorCode: 0, errorMessage: ""} * },{ * id: "{AF15W4F8S-A1W5-A1W8F-G1E8-AF1W5F4S8F4W}", * error: {errorCode: 0, errorMessage: ""} * }], * typeName: "Part", * updates:[{ * id: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}", * error: {errorCode: 0, errorMessage: ""} * }] * }], * hasError: false, * error: undefined * } * @example * // example of an error message due to misspelled entity type * { * editResults:[], * hasError: true, * error: { * errorCode: 112020, * errorMessage: "The Entity/Relationship type definition, Suppplier, was not found." * } * } */ export default class GraphApplyEditsResult extends Accessor { constructor(properties?: GraphApplyEditsResultProperties); /** * Returns a list of the Provenance entities that were deleted as a result of the [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) * call with the `cascadeProvenanceDeletes` option enabled. * * If [hasError](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphApplyEditsResult/#hasError) is `true`, `cascadeProvenanceDeletes` will be empty. * * @example * cascadeProvenanceDeleteResults:[{ * id: "{FB74F4DD-CBD7-4C94-BA89-0C044ECCC273}", * error: {errorCode: 0, errorMessage: ""} * }] */ accessor cascadeProvenanceDeleteResults: Array<CascadeProvenanceDeleteResults>; /** * Returns a list of objects for each [relationship type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) * that was deleted by as a result of deleting its origin or destination entity during an [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) * call with the `cascadeDeletes` option enabled. * * If [hasError](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphApplyEditsResult/#hasError) is `true`, `cascadeRelationshipDeletes` will be empty. * * @example * cascadeRelationshipDeleteResults:[{ * typeName: "supplies", * cascadeRelationshipDeletes: [ * { * id: "{FB74F4DD-CBD7-4C94-BA89-0C044ECCC273}", * error: {errorCode: 0, errorMessage: ""} * originId: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}", * destinationId: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}" * } * ] * }] */ accessor cascadeRelationshipDeleteResults: Array<CascadeRelationshipDeleteResults>; /** * Returns a list of objects for each [entity type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) or * [relationship type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) that added, updated or deleted records by * [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits). * * If [hasError](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphApplyEditsResult/#hasError) is `true`, `editResults` will be empty. * * @example * editResults:[{ * adds:[ * { * id: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}", * error: {errorCode: 0, errorMessage: ""} * }], * deletes:[], * typeName: "Supplier", * updates:[] * },{ * adds:[{ * id: "{ANWIFHSAS-AW6F-G9W4-8412-A1A8W4F1A5S6F}", * error: {errorCode: 0, errorMessage: ""} * }], * deletes:[{ * id: "{AN4E4G85-Q15F4-49A4-8412-A1W8F4S6A5S4}", * error: {errorCode: 0, errorMessage: ""} * },{ * id: "{AF15W4F8S-A1W5-A1W8F-G1E8-AF1W5F4S8F4W}", * error: {errorCode: 0, errorMessage: ""} * }], * typeName: "Part", * updates:[{ * id: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}", * error: {errorCode: 0, errorMessage: ""} * }] * }], */ accessor editResults: Array<EditResultsObject>; /** * The error message explaining information about why [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits) failed. * Will only be defined if [hasError](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphApplyEditsResult/#hasError) is `true`. * * @example * // example of an error message due to misspelled entity type * { * editResults:[], * hasError: false, * error: { * errorCode: 112020, * errorMessage: "The Entity/Relationship type definition, Suppplier, was not found." * } * } */ accessor error: EsriError | null | undefined; /** * If `true` there was an error processing [executeApplyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeApplyEdits). * The error message is captured in the [error](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphApplyEditsResult/#error) property. * * @default false */ accessor hasError: boolean; } /** * EditResultsObject returns a list of all [entities](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Entity/) * and [relationships](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/) of each [type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphObjectType/) * that was added, updated or deleted from the [KnowledgeGraph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) as well as any errors that occurred during the operation. * * @example * { * adds:[{ * id: "{ANWIFHSAS-AW6F-G9W4-8412-A1A8W4F1A5S6F}", * error: {errorCode: 0, errorMessage: ""} * }], * deletes:[{ * id: "{AN4E4G85-Q15F4-49A4-8412-A1W8F4S6A5S4}", * error: {errorCode: 0, errorMessage: ""} * },{ * id: "{AF15W4F8S-A1W5-A1W8F-G1E8-AF1W5F4S8F4W}", * error: {errorCode: 0, errorMessage: ""} * }], * typeName: "Part", * updates:[{ * id: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}", * error: {errorCode: 0, errorMessage: ""} * }] * } */ export interface EditResultsObject { /** * The name of the [EntityType](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) or [RelationshipType](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) * that had changed items. */ typeName: string; /** * A list of objects containing the * id and error information for every added entity or relationship. */ adds: Array<NamedObjectEditResults>; /** * A list of objects containing the * id and error information for every updated entity or relationship. */ updates: Array<NamedObjectEditResults>; /** * A list of objects containing the * id and error information for every deleted entity or relationship. */ deletes: Array<NamedObjectEditResults>; } /** * NamedObjectEditResults contains the `id` of the [GraphNamedObject](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphNamedObject/) * ([Entity](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Entity/) or [Relationship](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/)) that * was added, updated or deleted from the [KnowledgeGraph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) as well as any errors that occurred during the operation. * * @example * // typical structure * { * id: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}", //id of entity or relationship added, updated or deleted * error: {errorCode: 0, errorMessage: ""} * } */ export interface NamedObjectEditResults { /** * The id of the [Entity](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Entity/) or [Relationship](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/) * that was added, updated or deleted from the knowledge graph. */ id: string; /** Indicates any errors caused during the operation applied to this object. */ error?: EsriError; } /** * cascadeRelationshipDeletesResults returns a list of all [relationships](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/) of each [type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphObjectType/) * that were deleted from the [KnowledgeGraph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) due to one of their endpoints being deleted, as well as any errors that occurred during the operation. * * @example * { * typeName: "supplies", * cascadeRelationshipDeletes: [ * { * id: "{FB74F4DD-CBD7-4C94-BA89-0C044ECCC273}", * error: {errorCode: 0, errorMessage: ""} * originId: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}", * destinationId: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}" * } * ] * } */ export interface CascadeRelationshipDeleteResults { /** The name of the [RelationshipType](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) that had deleted relationships. */ typeName: string; /** * A list of objects containing the * id, origin id, destination id and error information for every deleted relationship. */ cascadeRelationshipDeletes: Array<NamedObjectCascadeRelationshipDeleteResults>; } /** * NamedObjectCascadeRelationshipDeleteResults contains the `id` of the [Relationship](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/) that * was deleted from the [KnowledgeGraph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) along with its origin id, destination id and error information. * * @example * // typical structure * { * id: "{FB74F4DD-CBD7-4C94-BA89-0C044ECCC273}", * error: {errorCode: 0, errorMessage: ""} * originId: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}", * destinationId: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}" * } */ export interface NamedObjectCascadeRelationshipDeleteResults extends NamedObjectEditResults { /** The id of the origin entity of the deleted relationship. */ originId: string; /** The id of the destination entity of the deleted relationship. */ destinationId: string; } /** * CascadeProvenanceDeleteResults contains the `id` of the Provenance [GraphNamedObject](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphNamedObject/) * that was deleted from the [KnowledgeGraph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) as well as any errors that occurred during the operation, * when edits were applied with `cascadeProvenanceDelete` set to true. * * @example * // typical structure * { * id: "{2WS8F4SA-41F1-S1E8-8412-F2G5S4D8GE1S}", //id of Provenance entity deleted * error: {errorCode: 0, errorMessage: ""} * } */ export interface CascadeProvenanceDeleteResults { /** The id of the Provenance [Entity](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Entity/) deleted from the knowledge graph. */ id: string; /** Indicates any errors caused during the operation applied to this object. */ error?: EsriError; }