UNPKG

@itwin/core-backend

Version:
161 lines 8.48 kB
/** @packageDocumentation * @module iModels */ import { AccessToken, GuidString, Id64String } from "@itwin/core-bentley"; import { ChangedValueState, ChangeOpCode, ChangesetRange } from "@itwin/core-common"; import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb"; /** Represents an instance of the `ChangeSummary` ECClass from the `ECDbChange` ECSchema * combined with the information from the related `Changeset` instance (from the `IModelChange` ECSchema) from * which the Change Summary was extracted. * * See also * - [ChangeSummaryManager.queryChangeSummary]($backend) * - [ChangeSummary Overview]($docs/learning/ChangeSummaries) * @beta */ export interface ChangeSummary { id: Id64String; changeSet: { wsgId: GuidString; parentWsgId: GuidString; description: string; pushDate: string; userCreated: GuidString; }; } /** Represents an instance of the `InstanceChange` ECClass from the `ECDbChange` ECSchema * * See also * - [ChangeSummaryManager.queryInstanceChange]($backend) * - [ChangeSummary Overview]($docs/learning/ChangeSummaries) * @beta */ export interface InstanceChange { id: Id64String; summaryId: Id64String; changedInstance: { id: Id64String; className: string; }; opCode: ChangeOpCode; isIndirect: boolean; } /** Options for [ChangeSummaryManager.createChangeSummaries]($backend). * @beta */ export interface CreateChangeSummaryArgs extends TokenArg { /** Id of the iTwin that contains the iModel */ iTwinId: GuidString; /** Id of the iModel */ iModelId: GuidString; /** * Range of change sets * - the Change Summary for the first and last versions are also included * - if unspecified, all change sets until the latest version are processed */ range: ChangesetRange; } /** Class to extract Change Summaries for a briefcase. * * See also: * - [ChangeSummary Overview]($docs/learning/ChangeSummaries) * @beta */ export declare class ChangeSummaryManager { private static readonly _currentIModelChangeSchemaVersion; /** Determines whether the *Change Cache file* is attached to the specified iModel or not * @param iModel iModel to check whether a *Change Cache file* is attached * @returns Returns true if the *Change Cache file* is attached to the iModel. false otherwise */ static isChangeCacheAttached(iModel: IModelDb): boolean; /** Attaches the *Change Cache file* to the specified iModel if it hasn't been attached yet. * A new *Change Cache file* will be created for the iModel if it hasn't existed before. * @param iModel iModel to attach the *Change Cache file* file to * @throws [IModelError]($common) */ static attachChangeCache(iModel: IModelDb): void; /** Detaches the *Change Cache file* from the specified iModel. * - note that this method will cause any pending (currently running or queued) queries to fail * @param iModel iModel to detach the *Change Cache file* to * @throws [IModelError]($common) in case of errors, e.g. if no *Change Cache file* was attached before. */ static detachChangeCache(iModel: IModelDb): void; private static openOrCreateChangesFile; private static createChangeCacheFile; private static openChangeCacheFile; private static getExtendedSchemaPath; private static isSummaryAlreadyExtracted; private static addExtendedInfos; /** Queries the ChangeSummary for the specified change summary id * * See also * - `ECDbChange.ChangeSummary` ECClass in the *ECDbChange* ECSchema * - [Change Summary Overview]($docs/learning/ChangeSummaries) * @param iModel iModel * @param changeSummaryId ECInstanceId of the ChangeSummary * @returns Returns the requested ChangeSummary object * @throws [IModelError]($common) If change summary does not exist for the specified id, or if the * change cache file hasn't been attached, or in case of other errors. */ static queryChangeSummary(iModel: BriefcaseDb, changeSummaryId: Id64String): ChangeSummary; /** Queries the InstanceChange for the specified instance change id. * * See also * - `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema * - [Change Summary Overview]($docs/learning/ChangeSummaries) * @param iModel iModel * @param instanceChangeId ECInstanceId of the InstanceChange (see `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema) * @returns Returns the requested InstanceChange object (see `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema) * @throws [IModelError]($common) if instance change does not exist for the specified id, or if the * change cache file hasn't been attached, or in case of other errors. */ static queryInstanceChange(iModel: BriefcaseDb, instanceChangeId: Id64String): InstanceChange; /** Retrieves the names of the properties whose values have changed for the given instance change * * See also [Change Summary Overview]($docs/learning/ChangeSummaries) * @param iModel iModel * @param instanceChangeId Id of the InstanceChange to query the properties whose values have changed * @returns Returns names of the properties whose values have changed for the given instance change * @throws [IModelError]($common) if the change cache file hasn't been attached, or in case of other errors. */ static getChangedPropertyValueNames(iModel: IModelDb, instanceChangeId: Id64String): string[]; /** Builds the ECSQL to query the property value changes for the specified instance change and the specified ChangedValueState. * * See also [Change Summary Overview]($docs/learning/ChangeSummaries) * @param iModel iModel * @param instanceChangeInfo InstanceChange to query the property value changes for * changedInstance.className must be fully qualified and schema and class name must be escaped with square brackets if they collide with reserved ECSQL words: `[schema name].[class name]` * @param changedValueState The Changed State to query the values for. This must correspond to the [InstanceChange.OpCode]($backend) of the InstanceChange. * @param changedPropertyNames List of the property names for which values have changed for the specified instance change. * The list can be obtained by calling [ChangeSummaryManager.getChangedPropertyValueNames]($core-backend). * If omitted, the method will call the above method by itself. The parameter allows for checking first whether * an instance change has any property value changes at all. If there are no property value changes, this method * should not be called, as it will throw an error. * @returns Returns the ECSQL that will retrieve the property value changes * @throws [IModelError]($common) if instance change does not exist, if there are not property value changes for the instance change, * if the change cache file hasn't been attached, or in case of other errors. */ static buildPropertyValueChangesECSql(iModel: IModelDb, instanceChangeInfo: { id: Id64String; summaryId: Id64String; changedInstance: { id: Id64String; className: string; }; }, changedValueState: ChangedValueState, changedPropertyNames?: string[]): string; /** * Creates a change summary for the last applied change set to the iModel * @param accessToken A valid access token string * @param iModel iModel to extract change summaries for. The iModel must not be a standalone iModel, and must have at least one change set applied to it. * @returns The id of the extracted change summary. * @beta */ static createChangeSummary(accessToken: AccessToken, iModel: BriefcaseDb): Promise<Id64String>; /** * Creates change summaries for the specified iModel and a specified range of versions * @note This may be an expensive operation - downloads the first version and starts applying the change sets, extracting summaries one by one * @param args Arguments including the range of versions for which Change Summaries are to be created, and other necessary input for creation */ static createChangeSummaries(args: CreateChangeSummaryArgs): Promise<Id64String[]>; } //# sourceMappingURL=ChangeSummaryManager.d.ts.map