@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
493 lines (491 loc) • 26.7 kB
TypeScript
import type Layer from "../layers/Layer.js";
import type WebMap from "../WebMap.js";
import type Collection from "../core/Collection.js";
import type Network from "../networks/Network.js";
import type PostResult from "../rest/versionManagement/gdbVersion/support/PostResult.js";
import type ReconcileResult from "../rest/versionManagement/gdbVersion/support/ReconcileResult.js";
import type { ReadonlyCollection } from "../core/Collection.js";
import type { JSONSupportMixin } from "../core/JSONSupport.js";
import type { Loadable, LoadableMixinProperties } from "../core/Loadable.js";
import type { AbortOptions } from "../core/promiseUtils.js";
import type { AlterVersionParametersProperties } from "../rest/versionManagement/gdbVersion/support/AlterVersionParameters.js";
import type { ReconcileParametersProperties } from "../rest/versionManagement/gdbVersion/support/ReconcileParameters.js";
import type { CreateVersionParametersProperties } from "../rest/versionManagement/support/CreateVersionParameters.js";
import type { GetVersionInfosParametersProperties } from "../rest/versionManagement/support/GetVersionInfosParameters.js";
import type { VersionManagementServiceCapabilities as VersionManagementServiceCapabilitiesJSON, VersionInfo as VersionInfoJSON, VersionInfoExtended as VersionInfoExtendedJSON, VersionIdentifier, ServiceResult } from "./support/jsonTypes.js";
import type { LockType } from "./support/type.js";
import type { VersionAdapter } from "./versionAdapters/types.js";
export interface VersionManagementServiceProperties extends LoadableMixinProperties, Partial<Pick<VersionManagementService, "capabilities" | "defaultVersionIdentifier" | "name" | "url">> {}
/**
* This class contains metadata about the version management service.
* The class can be constructed via a url to a version management service.
* The VersionManagementService grants users to plethora of functionality.
* The VersionManagementService contains methods for [creating a new version](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#createVersion), [deleting a version](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#deleteVersion),
* [altering a version](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#alterVersion), [changing a version on layers](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#changeVersion), [start](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#startReading)/[stop](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#stopReading) reading, [start](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#startEditing)/[stop](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#stopEditing) editing, [reconciling](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#reconcile), [posting](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#post), and [getting version infos](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#getVersionInfos).
* The [Version Management Component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-version-management) offers another way to handle versioning using a UI.
*
* @since 4.28
* @see [Version Management Service](https://developers.arcgis.com/rest/services-reference/enterprise/version-management-service.htm)
* @see [Version Management Component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-version-management)
* @example
* // Initialize the VersionManagementService from a url
* const versionManagementService = new VersionManagementService({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
* });
*
* // The layers that will be managed under the VersionManagementService
* const layer1 = new FeatureLayer({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/12"
* });
* const layer2 = new FeatureLayer({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/13"
* });
* const layers = [layer1, layer2];
*
* // The VersionManagementService must be loaded before any methods can be called
* await versionManagementService.load();
*
* // Change the version of two layers
* versionManagementService.changeVersion(
* layers,
* { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"},
* { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}
* );
*/
export default class VersionManagementService extends VersionManagementServiceSuperclass {
/**
* @example
* // Create a Version Management Service from a url
* const versionManagementService = new VersionManagementService({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
* });
*/
constructor(properties?: VersionManagementServiceProperties);
/** Describes the version management service's supported capabilities. */
accessor capabilities: VersionManagementServiceCapabilitiesJSON | null | undefined;
/** Contains the value for the default version's name and GUID. */
accessor defaultVersionIdentifier: VersionIdentifier;
/**
* Indicates whether the instance has loaded. When `true`, the properties of the object can be accessed.
*
* @default false
*/
get loaded(): boolean;
/** The name of the version management service. */
accessor name: string;
/** The absolute URL of the REST endpoint for the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online. */
accessor url: string;
/**
* The alter operation allows you to change the geodatabase version's name, description, owner, and access permissions.
*
* > [!CAUTION]
* >
* > **License**
* >
* > This method requires the feature service and version management service to be published with [ArcGIS Enterprise](https://enterprise.arcgis.com/en/get-started/latest/windows/what-is-arcgis-enterprise-.htm) version 11.2 or higher.
* > Organization members must be assigned a license for the [ArcGIS Advanced Editing user type extension](https://enterprise.arcgis.com/en/portal/latest/administer/windows/license-user-type-extensions.htm#ESRI_SECTION1_B75DA80066744473AD5DD1312734654A) to use this method.
*
* @param versionIdentifier - Identifier for a version.
* @param props - Contains properties that will be altered.
* @returns Returns true if version was altered successfully.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* const result = await versionManagementService.alterVersion(
* { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" },
* {
* versionName: "versionName",
* ownerName: "newOwner",
* description: "newDescription",
* access: "public"
* }
* );
*/
alterVersion(versionIdentifier: VersionIdentifier, props: AlterVersionParametersProperties): Promise<boolean>;
/**
* `canRedo` may be used to verify that a [redo()](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#redo) operation is possible.
*
* @param versionIdentifier - Identifier for a version.
* @returns Indicates whether a redo operation is possible.
* @since 4.28
*/
canRedo(versionIdentifier: VersionIdentifier): boolean;
/**
* `canUndo` may be used to verify that an [undo()](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#undo) operation is possible.
*
* @param versionIdentifier - Identifier for a version.
* @returns Indicates whether an undo operation is possible.
* @since 4.28
*/
canUndo(versionIdentifier: VersionIdentifier): boolean;
/**
* Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version,
* or from default version to a moment and vice versa.
*
* @param input - Input used to change version on layers or network.
* @param fromVersion - Current Version or Date moment.
* @param toVersion - Incoming Version or Date.
* @returns When resolved, response is `true` if change version was successful.
* @since 4.28
* @example
* // Initialize the VersionManagementService from a url
* const versionManagementService = new VersionManagementService({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
* });
*
* const layer1 = new FeatureLayer({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/12"
* });
* const layer2 = new FeatureLayer({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/13"
* });
* const layers = [layer1, layer2];
*
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* await versionManagementService.changeVersion(
* layers,
* { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"},
* { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}
* );
*/
changeVersion(input: WebMap | ReadonlyCollection<Layer> | Layer[] | Network, fromVersion: Date | VersionIdentifier, toVersion: Date | VersionIdentifier): Promise<boolean>;
/**
* Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version,
* or from default version to a moment and vice versa.
*
* @param input - Input used to change version on layers.
* @param fromVersion - Current Version or Date moment.
* @param toVersion - Incoming Version or Date.
* @returns When resolved, returns a map of version adapter to result.
* @since 4.30
* @example
* const [utils, VersionManagementService, FeatureLayer] = await $arcgis.import([
* "@arcgis/core/versionManagement/versionAdapters/utils.js",
* "@arcgis/core/versionManagement/VersionManagementService.js",
* "@arcgis/core/layers/FeatureLayer.js"
* ]);
* // Initialize the VersionManagementService from a url
* const versionManagementService = new VersionManagementService({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
* });
*
* const layer1 = new FeatureLayer({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/12"
* });
* const layer2 = new FeatureLayer({
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/13"
* });
* const adapters = utils.createVersionAdapters([layer1, layer2]);
*
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* await versionManagementService.changeVersionWithResult(
* adapters,
* { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"},
* { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}
* );
*/
changeVersionWithResult(input: WebMap | Collection<VersionAdapter> | VersionAdapter[], fromVersion: Date | VersionIdentifier, toVersion: Date | VersionIdentifier): Promise<Map<VersionAdapter, ServiceResult>>;
/**
* Creates a new version given the following parameters.
*
* @param props - Contains properties required to create a version.
* @returns Contains information about newly created version.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* // Create a version by passing the new version name, description, and access type set to 'public'.
* const version = await versionManagementService.createVersion({
* versionName: "versionName",
* description: "description",
* access: "public"
* });
*/
createVersion(props: CreateVersionParametersProperties): Promise<VersionInfoExtendedJSON>;
/**
* Deletes a version given the following parameters.
*
* > [!CAUTION]
* >
* > **License**
* >
* > This method requires the feature service and version management service to be published with [ArcGIS Enterprise](https://enterprise.arcgis.com/en/get-started/latest/windows/what-is-arcgis-enterprise-.htm) version 11.2 or higher.
* > Organization members must be assigned a license for the [ArcGIS Advanced Editing user type extension](https://enterprise.arcgis.com/en/portal/latest/administer/windows/license-user-type-extensions.htm#ESRI_SECTION1_B75DA80066744473AD5DD1312734654A) to use this method.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if the selected version was deleted.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.deleteVersion({
* name: "versionName",
* guid: "{422D1B63-D795-4478-A4B1-AD6109377075}"
* });
*/
deleteVersion(versionIdentifier: VersionIdentifier): Promise<boolean>;
/**
* Returns the current client lock type on a given version.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies the lock type on the version. Returns either `"edit"`, `"none"`, or `"read"`.
* @since 4.28
* @example versionManagementService.getLockType({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
getLockType(versionIdentifier: VersionIdentifier): LockType;
/**
* This method will return the [VersionIdentifier](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/support/jsonTypes/#VersionIdentifier) given the guid of the version.
*
* @param guid - GUID of version.
* @returns Returns VersionIdentifier.
* @since 4.28
*/
getVersionIdentifierFromGuid(guid: string): Promise<VersionIdentifier | null | undefined>;
/**
* This method will return the [VersionIdentifier](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/support/jsonTypes/#VersionIdentifier) given the name of the version.
*
* @param name - Name of version.
* @returns Returns VersionIdentifier.
* @since 4.28
*/
getVersionIdentifierFromName(name: string): Promise<VersionIdentifier | null | undefined>;
/**
* Method used to get extended information about a version.
*
* @param versionIdentifier - Identifier for a version.
* @returns Contains extended info about given version.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* const version = await versionManagementService.getVersionInfoExtended({
* guid: "{422D1B63-D795-4478-A4B1-AD6109377075}",
* name: "versionName"
* });
*/
getVersionInfoExtended(versionIdentifier: VersionIdentifier): Promise<VersionInfoExtendedJSON | null | undefined>;
/**
* Returns information about a version or versions. If no arguments are provided, this method will return all versions accessible to the currently logged-in user.
*
* @param props
* @returns Contains info of versions.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* const versions = await versionManagementService.getVersionInfos({ ownerFilter: "publisher1", includeHidden: true });
*/
getVersionInfos(props?: GetVersionInfosParametersProperties): Promise<VersionInfoJSON[]>;
/**
* Triggers the loading of the version management service instance.
*
* Fully loads the Version Management Service definition.
*
* @param options - Additional options.
* @returns Resolves when the Feature Service is [loaded](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#loaded).
*/
load(options?: AbortOptions | null | undefined): Promise<this>;
/**
* The Post operation allows the client to post the changes in their version to the default version. A reconcile operation must be performed prior to post.
*
* > [!CAUTION]
* >
* > **License**
* >
* > This method requires the feature service and version management service to be published with [ArcGIS Enterprise](https://enterprise.arcgis.com/en/get-started/latest/windows/what-is-arcgis-enterprise-.htm) version 11.2 or higher.
* > Organization members must be assigned a license for the [ArcGIS Advanced Editing user type extension](https://enterprise.arcgis.com/en/portal/latest/administer/windows/license-user-type-extensions.htm#ESRI_SECTION1_B75DA80066744473AD5DD1312734654A) to use this method.
*
* @param versionIdentifier - Identifier for a version.
* @returns Returns the result of the post.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* const postResult = await versionManagementService.post({
* guid: "{422D1B63-D795-4478-A4B1-AD6109377075}",
* name: "versionName"
* });
*/
post(versionIdentifier: VersionIdentifier): Promise<PostResult>;
/**
* Use the reconcile operation to reconcile a branch version with the default version.
* The reconcile operation requires that you are the only user currently editing the version and remain so throughout the reconcile process until you save or post your edits.
* You must have full permissions to all the feature classes that have been modified in the version being edited.
* This operation detects differences between the branch version and the default version and flags these differences as conflicts.
*
* > [!CAUTION]
* >
* > **License**
* >
* > This method requires the feature service and version management service to be published with [ArcGIS Enterprise](https://enterprise.arcgis.com/en/get-started/latest/windows/what-is-arcgis-enterprise-.htm) version 11.2 or higher.
* > Organization members must be assigned a license for the [ArcGIS Advanced Editing user type extension](https://enterprise.arcgis.com/en/portal/latest/administer/windows/license-user-type-extensions.htm#ESRI_SECTION1_B75DA80066744473AD5DD1312734654A) to use this method.
*
* > **Changes to Reconcile**
* >
* > Starting with ArcGIS Server 12.0, calling [reconcile](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#reconcile) will now save pending edits to the version as part of the operation.
* > In addition, calling [stopEditing](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#stopEditing) will block [post](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#post) until another [reconcile](https://developers.arcgis.com/javascript/latest/references/core/versionManagement/VersionManagementService/#reconcile) is performed.
*
* @param versionIdentifier - Identifier for a version.
* @param props - Properties used for a reconcile.
* @returns Returns the result of the reconcile.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* const reconcileResult = await versionManagementService.reconcile({
* guid: "{422D1B63-D795-4478-A4B1-AD6109377075}",
* name: "versionName"
* },
* {
* abortIfConflicts: true,
* conflictDetection: "by-object",
* withPost: false
* });
*/
reconcile(versionIdentifier: VersionIdentifier, props?: ReconcileParametersProperties): Promise<ReconcileResult>;
/**
* This method redos the last edit made while in an edit session.
*
* @param versionIdentifier - Identifier for a version.
* @since 4.28
*/
redo(versionIdentifier: VersionIdentifier): void;
/**
* Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock.
* The exclusive lock ensures read and write isolation for the session holding the lock.
* The exclusive lock is downgraded to a shared lock by using the stopEditing operation.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if start editing was successful.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.startEditing({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
startEditing(versionIdentifier: VersionIdentifier): Promise<boolean>;
/**
* Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock.
* The exclusive lock ensures read and write isolation for the session holding the lock.
* The exclusive lock is downgraded to a shared lock by using the stopEditing operation.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if start editing was successful.
* @since 4.30
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.startEditingWithResult({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
startEditingWithResult(versionIdentifier: VersionIdentifier): Promise<ServiceResult>;
/**
* Using the specified client generated session ID, a shared lock is obtained for the session if the version is not already being edited by another user/session.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if start reading was successful.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.startReading({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
startReading(versionIdentifier: VersionIdentifier): Promise<boolean>;
/**
* Using the specified client generated session ID, a shared lock is obtained for the session if the version is not already being edited by another user/session.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if start reading was successful.
* @since 4.30
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.startReadingWithResult({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
startReadingWithResult(versionIdentifier: VersionIdentifier): Promise<ServiceResult>;
/**
* Using the specified session id, the exclusive lock for the version is downgraded to a shared lock.
* The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).
*
* @param versionIdentifier - Identifier for a version.
* @param saveEdits - If set to true edits will be saved, if false edits will not be saved.
* @returns Specifies if stop editing was successful.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.stopEditing(
* { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" },
* true,
* );
*/
stopEditing(versionIdentifier: VersionIdentifier, saveEdits: boolean): Promise<boolean>;
/**
* Using the specified session id, the exclusive lock for the version is downgraded to a shared lock.
* The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).
*
* @param versionIdentifier - Identifier for a version.
* @param saveEdits - If set to true edits will be saved, if false edits will not be saved.
* @returns Specifies if stop editing was successful.
* @since 4.30
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.stopEditingWithResult(
* { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" },
* true,
* );
*/
stopEditingWithResult(versionIdentifier: VersionIdentifier, saveEdits: boolean): Promise<ServiceResult>;
/**
* The shared lock is released on the version.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if stop reading was successful.
* @since 4.28
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.stopReading({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
stopReading(versionIdentifier: VersionIdentifier): Promise<boolean>;
/**
* The shared lock is released on the version.
*
* @param versionIdentifier - Identifier for a version.
* @returns Specifies if stop reading was successful.
* @since 4.30
* @example
* // Make sure the VersionManagementService is loaded
* await versionManagementService.load();
*
* versionManagementService.stopReadingWithResult({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });
*/
stopReadingWithResult(versionIdentifier: VersionIdentifier): Promise<ServiceResult>;
/**
* This method undos the last edit made while in an edit session.
*
* @param versionIdentifier - Identifier for a version.
* @since 4.28
*/
undo(versionIdentifier: VersionIdentifier): void;
}
declare const VersionManagementServiceSuperclass: typeof Loadable & typeof JSONSupportMixin