@itwin/core-backend 4.0.0-dev.98 → 4.1.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,13 +66,13 @@ export declare namespace BlobContainer {
66
66
  metadata: Metadata;
67
67
  }
68
68
  /** The URI and Id of the container. */
69
- interface Address {
70
- uri: string;
69
+ interface UriAndId {
70
+ baseUri: string;
71
71
  id: ContainerId;
72
72
  }
73
73
  /** Information required to access an existing container. */
74
74
  interface AccessContainerProps {
75
- address: Address;
75
+ address: UriAndId;
76
76
  userToken: UserToken;
77
77
  }
78
78
  /** Information required to request an access token for a container. */
@@ -105,7 +105,7 @@ export declare namespace BlobContainer {
105
105
  /**
106
106
  * Create a new blob container. Throws on failure (e.g. access denied or container already exists.)
107
107
  */
108
- create(props: CreateNewContainerProps): Promise<Address>;
108
+ create(props: CreateNewContainerProps): Promise<UriAndId>;
109
109
  /**
110
110
  * Delete an existing blob container.
111
111
  * @note This method requires that the user be authorized with "delete container" RBAC role for the iTwin.
@@ -1 +1 @@
1
- {"version":3,"file":"BlobContainerService.d.ts","sourceRoot":"","sources":["../../src/BlobContainerService.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAE7B,+FAA+F;IACxF,IAAI,OAAO,EAAE,aAAa,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAE/D,8CAA8C;IAC9C,KAAY,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAElD,mDAAmD;IACnD,KAAY,WAAW,GAAG,MAAM,CAAC;IAEjC,4FAA4F;IAC5F,KAAY,SAAS,GAAG,WAAW,CAAC;IAEpC,+EAA+E;IAC/E,KAAY,cAAc,GAAG,WAAW,CAAC;IAEzC;;;;;;;;OAQG;IACH,UAAiB,KAAK;QACpB,8CAA8C;QA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ACtB,8BAA8B;QAC9B,KAAK,EAAE,KAAK,CAAC;QACb,yCAAyC;QACzC,QAAQ,EAAE,QAAQ,CAAC;QACnB,sIAAsI;QACtI,UAAU,EAAE,IAAI,CAAC;QACjB,iCAAiC;QACjC,QAAQ,EAAE,QAAQ,CAAC;KACpB;IAED,uCAAuC;IACvC,UAAiB,QAAQ;QACvB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,WAAW,CAAC;KACjB;IAED,4DAA4D;IAC5D,UAAiB,oBAAoB;QACnC,OAAO,EAAE,QAAQ,CAAC;QAClB,SAAS,EAAE,SAAS,CAAC;KACtB;IAED,uEAAuE;IACvE,UAAiB,iBAAkB,SAAQ,oBAAoB;QAC7D;;WAEG;QACH,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB;;WAEG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IAED,sDAAsD;IACtD,UAAiB,uBAAuB;QACtC,qCAAqC;QACrC,KAAK,EAAE,KAAK,CAAC;QACb,iDAAiD;QACjD,QAAQ,EAAE,QAAQ,CAAC;QACnB,4GAA4G;QAC5G,SAAS,EAAE,SAAS,CAAC;QACrB;;;WAGG;QACH,EAAE,CAAC,EAAE,WAAW,CAAC;KAClB;IAED,6DAA6D;IAC7D,UAAiB,gBAAgB;QAC/B;;WAEG;QACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE1D;;;WAGG;QACH,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnD;;WAEG;QACH,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KAC7D;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"BlobContainerService.js","sourceRoot":"","sources":["../../src/BlobContainerService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,IAAiB,aAAa,CA6H7B;AA7HD,WAAiB,aAAa;AA6H9B,CAAC,EA7HgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA6H7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module BlobContainers\r\n */\r\n\r\n// spell:ignore datacenter\r\n\r\nimport { AccessToken, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/**\r\n * Types and functions for creating, deleting and authorizing access to cloud-based blob containers for an iTwin.\r\n * @beta\r\n */\r\nexport namespace BlobContainer {\r\n\r\n /** Object that implements the methods to create, delete, and request access to a container. */\r\n export let service: BlobContainer.ContainerService | undefined;\r\n\r\n /** name of cloud provider for a container. */\r\n export type Provider = \"azure\" | \"google\" | \"aws\";\r\n\r\n /** the name of the container within its `Scope` */\r\n export type ContainerId = string;\r\n\r\n /** token that authenticates a user. This token is required to obtain a `ContainerToken`. */\r\n export type UserToken = AccessToken;\r\n\r\n /** token that authenticates access to a container for either read or write. */\r\n export type ContainerToken = AccessToken;\r\n\r\n /**\r\n * The scope for a container. This determines:\r\n * - the \"owner\" organization, including the contract that governs its legal and commercial terms and obligations\r\n * - the administrators who may configure RBAC permissions\r\n * - the datacenter for the container. Every container resides in a datacenter as determined by the iTwinId. This\r\n * determines the region for data residency requirements.\r\n * - the lifecycle constraints for the container. No container can outlive its iTwin or its iModel (if defined). That is,\r\n * when the iTwin/iModel is deleted (either explicitly or due to contract expiration), the container is also deleted.\r\n */\r\n export interface Scope {\r\n /** iTwinId of the owner of this container. */\r\n iTwinId: Id64String;\r\n /** optionally, an iModelId within the iTwin. If present, container is deleted when the iModel is deleted. */\r\n iModelId?: Id64String;\r\n }\r\n\r\n /**\r\n * Metadata about the use of a container so that:\r\n * - administrators can understand why a container exists for assigning RBAC permissions appropriately\r\n * - usage reports can aggregate types of containers\r\n * - applications can identify their containers\r\n * - applications can store important (to them) properties \"on\" their containers\r\n */\r\n export interface Metadata {\r\n /** Human readable explanation of the information held in the container. This will be displayed in the administrator RBAC panel, and on usage reports. */\r\n description: string;\r\n /** a machine-readable string that describes the \"format\" of the data in this container (e.g. \"CloudSqlite\") */\r\n format: string;\r\n /** an identifier of the application that uses this this container */\r\n application: string;\r\n /** Additional properties stored on the container */\r\n [propertyName: string]: string;\r\n }\r\n\r\n /** Properties returned by `Service.requestToken` */\r\n export interface TokenProps {\r\n /**\r\n * expiring token that provides the requested access to the container. Should be used in all subsequent requests for blobs within the container,\r\n * and must be refreshed before it expires\r\n */\r\n token: ContainerToken;\r\n /** scope of the container. */\r\n scope: Scope;\r\n /** name of the blob storage provider. */\r\n provider: Provider;\r\n /** Time at which the token will expire. The token should be refreshed (that is, a new token should be requested) before this time. */\r\n expiration: Date;\r\n /** Metadata of the container. */\r\n metadata: Metadata;\r\n }\r\n\r\n /** The URI and Id of the container. */\r\n export interface Address {\r\n uri: string;\r\n id: ContainerId;\r\n }\r\n\r\n /** Information required to access an existing container. */\r\n export interface AccessContainerProps {\r\n address: Address;\r\n userToken: UserToken;\r\n }\r\n\r\n /** Information required to request an access token for a container. */\r\n export interface RequestTokenProps extends AccessContainerProps {\r\n /** If true, token should provide write access.\r\n * @note if write access is requested and the user is authorized for read but not write, an exception will be thrown (i.e. a read token is *not* returned).\r\n */\r\n forWriteAccess?: boolean;\r\n /** the number of seconds before the token should expire.\r\n * @note A maximum duration is determined by the service. If no value is supplied, or the value is larger than the maximum, the maximum duration is used.\r\n */\r\n durationSeconds?: number;\r\n }\r\n\r\n /** Information required to create a new container. */\r\n export interface CreateNewContainerProps {\r\n /** the scope of the new container */\r\n scope: Scope;\r\n /** metadata to be stored on the new container */\r\n metadata: Metadata;\r\n /** The user's access token. The user must be authorized with \"create container\" RBAC role for the iTwin. */\r\n userToken: UserToken;\r\n /**\r\n * the id for the container. Useful for tests.\r\n * @internal\r\n */\r\n id?: ContainerId;\r\n }\r\n\r\n /** Methods to create, delete, and access blob containers. */\r\n export interface ContainerService {\r\n /**\r\n * Create a new blob container. Throws on failure (e.g. access denied or container already exists.)\r\n */\r\n create(props: CreateNewContainerProps): Promise<Address>;\r\n\r\n /**\r\n * Delete an existing blob container.\r\n * @note This method requires that the user be authorized with \"delete container\" RBAC role for the iTwin.\r\n */\r\n delete(props: AccessContainerProps): Promise<void>;\r\n\r\n /**\r\n * Request a `ContainerToken` for a container. Throws on failure.\r\n */\r\n requestToken(props: RequestTokenProps): Promise<TokenProps>;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BlobContainerService.js","sourceRoot":"","sources":["../../src/BlobContainerService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,IAAiB,aAAa,CA6H7B;AA7HD,WAAiB,aAAa;AA6H9B,CAAC,EA7HgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA6H7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module BlobContainers\r\n */\r\n\r\n// spell:ignore datacenter\r\n\r\nimport { AccessToken, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/**\r\n * Types and functions for creating, deleting and authorizing access to cloud-based blob containers for an iTwin.\r\n * @beta\r\n */\r\nexport namespace BlobContainer {\r\n\r\n /** Object that implements the methods to create, delete, and request access to a container. */\r\n export let service: BlobContainer.ContainerService | undefined;\r\n\r\n /** name of cloud provider for a container. */\r\n export type Provider = \"azure\" | \"google\" | \"aws\";\r\n\r\n /** the name of the container within its `Scope` */\r\n export type ContainerId = string;\r\n\r\n /** token that authenticates a user. This token is required to obtain a `ContainerToken`. */\r\n export type UserToken = AccessToken;\r\n\r\n /** token that authenticates access to a container for either read or write. */\r\n export type ContainerToken = AccessToken;\r\n\r\n /**\r\n * The scope for a container. This determines:\r\n * - the \"owner\" organization, including the contract that governs its legal and commercial terms and obligations\r\n * - the administrators who may configure RBAC permissions\r\n * - the datacenter for the container. Every container resides in a datacenter as determined by the iTwinId. This\r\n * determines the region for data residency requirements.\r\n * - the lifecycle constraints for the container. No container can outlive its iTwin or its iModel (if defined). That is,\r\n * when the iTwin/iModel is deleted (either explicitly or due to contract expiration), the container is also deleted.\r\n */\r\n export interface Scope {\r\n /** iTwinId of the owner of this container. */\r\n iTwinId: Id64String;\r\n /** optionally, an iModelId within the iTwin. If present, container is deleted when the iModel is deleted. */\r\n iModelId?: Id64String;\r\n }\r\n\r\n /**\r\n * Metadata about the use of a container so that:\r\n * - administrators can understand why a container exists for assigning RBAC permissions appropriately\r\n * - usage reports can aggregate types of containers\r\n * - applications can identify their containers\r\n * - applications can store important (to them) properties \"on\" their containers\r\n */\r\n export interface Metadata {\r\n /** Human readable explanation of the information held in the container. This will be displayed in the administrator RBAC panel, and on usage reports. */\r\n description: string;\r\n /** a machine-readable string that describes the \"format\" of the data in this container (e.g. \"CloudSqlite\") */\r\n format: string;\r\n /** an identifier of the application that uses this this container */\r\n application: string;\r\n /** Additional properties stored on the container */\r\n [propertyName: string]: string;\r\n }\r\n\r\n /** Properties returned by `Service.requestToken` */\r\n export interface TokenProps {\r\n /**\r\n * expiring token that provides the requested access to the container. Should be used in all subsequent requests for blobs within the container,\r\n * and must be refreshed before it expires\r\n */\r\n token: ContainerToken;\r\n /** scope of the container. */\r\n scope: Scope;\r\n /** name of the blob storage provider. */\r\n provider: Provider;\r\n /** Time at which the token will expire. The token should be refreshed (that is, a new token should be requested) before this time. */\r\n expiration: Date;\r\n /** Metadata of the container. */\r\n metadata: Metadata;\r\n }\r\n\r\n /** The URI and Id of the container. */\r\n export interface UriAndId {\r\n baseUri: string;\r\n id: ContainerId;\r\n }\r\n\r\n /** Information required to access an existing container. */\r\n export interface AccessContainerProps {\r\n address: UriAndId;\r\n userToken: UserToken;\r\n }\r\n\r\n /** Information required to request an access token for a container. */\r\n export interface RequestTokenProps extends AccessContainerProps {\r\n /** If true, token should provide write access.\r\n * @note if write access is requested and the user is authorized for read but not write, an exception will be thrown (i.e. a read token is *not* returned).\r\n */\r\n forWriteAccess?: boolean;\r\n /** the number of seconds before the token should expire.\r\n * @note A maximum duration is determined by the service. If no value is supplied, or the value is larger than the maximum, the maximum duration is used.\r\n */\r\n durationSeconds?: number;\r\n }\r\n\r\n /** Information required to create a new container. */\r\n export interface CreateNewContainerProps {\r\n /** the scope of the new container */\r\n scope: Scope;\r\n /** metadata to be stored on the new container */\r\n metadata: Metadata;\r\n /** The user's access token. The user must be authorized with \"create container\" RBAC role for the iTwin. */\r\n userToken: UserToken;\r\n /**\r\n * the id for the container. Useful for tests.\r\n * @internal\r\n */\r\n id?: ContainerId;\r\n }\r\n\r\n /** Methods to create, delete, and access blob containers. */\r\n export interface ContainerService {\r\n /**\r\n * Create a new blob container. Throws on failure (e.g. access denied or container already exists.)\r\n */\r\n create(props: CreateNewContainerProps): Promise<UriAndId>;\r\n\r\n /**\r\n * Delete an existing blob container.\r\n * @note This method requires that the user be authorized with \"delete container\" RBAC role for the iTwin.\r\n */\r\n delete(props: AccessContainerProps): Promise<void>;\r\n\r\n /**\r\n * Request a `ContainerToken` for a container. Throws on failure.\r\n */\r\n requestToken(props: RequestTokenProps): Promise<TokenProps>;\r\n }\r\n}\r\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module iModels
3
3
  */
4
4
  import { AccessToken, GuidString, Id64String } from "@itwin/core-bentley";
5
- import { ChangedValueState, ChangeOpCode, ChangesetRange, IModelVersion } from "@itwin/core-common";
5
+ import { ChangedValueState, ChangeOpCode, ChangesetRange } from "@itwin/core-common";
6
6
  import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb";
7
7
  /** Represents an instance of the `ChangeSummary` ECClass from the `ECDbChange` ECSchema
8
8
  * combined with the information from the related `Changeset` instance (from the `IModelChange` ECSchema) from
@@ -40,20 +40,6 @@ export interface InstanceChange {
40
40
  opCode: ChangeOpCode;
41
41
  isIndirect: boolean;
42
42
  }
43
- /** Options for [ChangeSummaryManager.extractChangeSummaries]($backend).
44
- * @beta
45
- * @deprecated in 2.x. Use [CreateChangeSummaryArgs]($core-backend) instead
46
- */
47
- export interface ChangeSummaryExtractOptions {
48
- /** If specified, change summaries are extracted from the start version to the current version as of which the iModel
49
- * was opened. If undefined, the extraction starts at the first version of the iModel.
50
- */
51
- startVersion?: IModelVersion;
52
- /** If specified, the change summary will be extracted only for current version as of which the iModel
53
- * was opened.
54
- */
55
- currentVersionOnly?: boolean;
56
- }
57
43
  /** Options for [ChangeSummaryManager.createChangeSummaries]($backend).
58
44
  * @beta
59
45
  */
@@ -94,19 +80,6 @@ export declare class ChangeSummaryManager {
94
80
  * @throws [IModelError]($common) in case of errors, e.g. if no *Change Cache file* was attached before.
95
81
  */
96
82
  static detachChangeCache(iModel: IModelDb): void;
97
- /** Extracts change summaries from the specified iModel.
98
- * Change summaries are extracted from the version the iModel was opened with up through the specified start version.
99
- * If no start version has been specified, the first version will be used.
100
- * @param accessToken A valid access token string
101
- * @param iModel iModel to extract change summaries for. The iModel must not be a standalone iModel.
102
- * Note: For every version to extract a summary from, the method moves the iModel to that version before extraction. After
103
- * the extraction has completed, the iModel is moved back to the original version.
104
- * @param options Extraction options
105
- * @return the Ids of the extracted change summaries.
106
- * @throws [IModelError]($common) if the iModel is standalone
107
- * @deprecated in 2.x. Use [ChangeSummaryManager.createChangeSummaries]($core-backend) instead
108
- */
109
- static extractChangeSummaries(accessToken: AccessToken, iModel: BriefcaseDb, options?: ChangeSummaryExtractOptions): Promise<Id64String[]>;
110
83
  private static openOrCreateChangesFile;
111
84
  private static createChangeCacheFile;
112
85
  private static openChangeCacheFile;
@@ -1 +1 @@
1
- {"version":3,"file":"ChangeSummaryManager.d.ts","sourceRoot":"","sources":["../../src/ChangeSummaryManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,O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AAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IA4C3G;;;;OAIG;WACiB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAwChG"}
@@ -68,105 +68,6 @@ class ChangeSummaryManager {
68
68
  if (res !== core_bentley_1.DbResult.BE_SQLITE_OK)
69
69
  throw new core_common_1.IModelError(res, `Failed to detach Change Cache file from ${iModel.pathName}.`);
70
70
  }
71
- /** Extracts change summaries from the specified iModel.
72
- * Change summaries are extracted from the version the iModel was opened with up through the specified start version.
73
- * If no start version has been specified, the first version will be used.
74
- * @param accessToken A valid access token string
75
- * @param iModel iModel to extract change summaries for. The iModel must not be a standalone iModel.
76
- * Note: For every version to extract a summary from, the method moves the iModel to that version before extraction. After
77
- * the extraction has completed, the iModel is moved back to the original version.
78
- * @param options Extraction options
79
- * @return the Ids of the extracted change summaries.
80
- * @throws [IModelError]($common) if the iModel is standalone
81
- * @deprecated in 2.x. Use [ChangeSummaryManager.createChangeSummaries]($core-backend) instead
82
- */
83
- static async extractChangeSummaries(accessToken, iModel, options) {
84
- if (!iModel?.isOpen)
85
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Briefcase must be open");
86
- const iModelId = iModel.iModelId;
87
- const endChangeSetId = iModel.changeset.id;
88
- (0, core_bentley_1.assert)(endChangeSetId.length !== 0);
89
- let startChangeSetId = "";
90
- if (options) {
91
- if (options.startVersion) {
92
- startChangeSetId = (await IModelHost_1.IModelHost.hubAccess.getChangesetFromVersion({ version: options.startVersion, accessToken, iModelId })).id;
93
- }
94
- else if (options.currentVersionOnly) {
95
- startChangeSetId = endChangeSetId;
96
- }
97
- }
98
- core_bentley_1.Logger.logInfo(loggerCategory, "Started Change Summary extraction...", () => ({ iModelId, startChangeSetId, endChangeSetId }));
99
- const totalPerf = new core_bentley_1.PerfLogger(`ChangeSummaryManager.extractChangeSummaries [ChangeSets: ${startChangeSetId} through ${endChangeSetId}, iModel: ${iModelId}]`);
100
- // download necessary changesets if they were not downloaded before and retrieve infos about those changesets
101
- let perfLogger = new core_bentley_1.PerfLogger("ChangeSummaryManager.extractChangeSummaries>Retrieve ChangeSetInfos and download Changesets from Hub");
102
- const first = (await IModelHost_1.IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: startChangeSetId }, accessToken })).index;
103
- const end = (await IModelHost_1.IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: endChangeSetId }, accessToken })).index;
104
- const changeSetInfos = await IModelHost_1.IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager_1.BriefcaseManager.getChangeSetsPath(iModelId) });
105
- perfLogger.dispose();
106
- core_bentley_1.Logger.logTrace(loggerCategory, "Retrieved changesets to extract from from cache or from hub.", () => ({ iModelId, startChangeSetId, endChangeSetId, changeSets: changeSetInfos }));
107
- // Ensure change cache is detached as it's being written to during the extraction
108
- if (this.isChangeCacheAttached(iModel)) {
109
- throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Change cache must be detached before extraction");
110
- }
111
- perfLogger = new core_bentley_1.PerfLogger("ChangeSummaryManager.extractChangeSummaries>Open or create local Change Cache file");
112
- const changesFile = ChangeSummaryManager.openOrCreateChangesFile(iModel);
113
- (0, core_bentley_1.assert)(changesFile.nativeDb !== undefined, "Should not happen as an exception should have been thrown in that case");
114
- perfLogger.dispose();
115
- core_bentley_1.Logger.logTrace(loggerCategory, "Opened or created Changes Cachefile.", () => ({ iModelId, startChangeSetId, endChangeSetId }));
116
- try {
117
- // extract summaries from end changeset through start changeset, so that we only have to go back in history
118
- const changeSetCount = changeSetInfos.length;
119
- const endChangeSetIx = changeSetCount - 1;
120
- const summaries = [];
121
- for (let i = endChangeSetIx; i >= 0; i--) {
122
- const currentChangeSetInfo = changeSetInfos[i];
123
- const currentChangeSetId = currentChangeSetInfo.id;
124
- core_bentley_1.Logger.logInfo(loggerCategory, `Started Change Summary extraction for changeset #${i + 1}...`, () => ({ iModelId, changeSetId: currentChangeSetId }));
125
- const existingSummaryId = ChangeSummaryManager.isSummaryAlreadyExtracted(changesFile, currentChangeSetId);
126
- if (!!existingSummaryId) {
127
- core_bentley_1.Logger.logInfo(loggerCategory, `Change Summary for changeset #${i + 1} already exists. It is not extracted again.`, () => ({ iModelId, changeSetId: currentChangeSetId }));
128
- summaries.push(existingSummaryId);
129
- continue;
130
- }
131
- // iModel is at end changeset, so no need to reverse for it.
132
- if (i !== endChangeSetIx) {
133
- perfLogger = new core_bentley_1.PerfLogger("ChangeSummaryManager.extractChangeSummaries>Roll iModel to previous changeset");
134
- await iModel.pullChanges({ accessToken, toIndex: currentChangeSetInfo.index });
135
- perfLogger.dispose();
136
- core_bentley_1.Logger.logTrace(loggerCategory, `Moved iModel to changeset #${i + 1} to extract summary from.`, () => ({ iModelId, changeSetId: currentChangeSetId }));
137
- }
138
- const changeSetFilePath = currentChangeSetInfo.pathname;
139
- if (!IModelJsFs_1.IModelJsFs.existsSync(changeSetFilePath))
140
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.FileNotFound, `Failed to extract change summary: ChangeSet file "${changeSetFilePath}" does not exist.`);
141
- perfLogger = new core_bentley_1.PerfLogger("ChangeSummaryManager.extractChangeSummaries>Extract ChangeSummary");
142
- const stat = iModel.nativeDb.extractChangeSummary(changesFile.nativeDb, changeSetFilePath);
143
- perfLogger.dispose();
144
- if (stat.error && stat.error.status !== core_bentley_1.DbResult.BE_SQLITE_OK)
145
- throw new core_common_1.IModelError(stat.error.status, stat.error.message);
146
- core_bentley_1.Logger.logTrace(loggerCategory, `Actual Change summary extraction done for changeset #${i + 1}.`, () => ({ iModelId, changeSetId: currentChangeSetId }));
147
- perfLogger = new core_bentley_1.PerfLogger("ChangeSummaryManager.extractChangeSummaries>Add ChangeSet info to ChangeSummary");
148
- (0, core_bentley_1.assert)(undefined !== stat.result);
149
- const changeSummaryId = stat.result;
150
- summaries.push(changeSummaryId);
151
- ChangeSummaryManager.addExtendedInfos(changesFile, changeSummaryId, currentChangeSetId, currentChangeSetInfo.parentId, currentChangeSetInfo.description, currentChangeSetInfo.pushDate, currentChangeSetInfo.userCreated);
152
- perfLogger.dispose();
153
- core_bentley_1.Logger.logTrace(loggerCategory, `Added extended infos to Change Summary for changeset #${i + 1}.`, () => ({ iModelId, changeSetId: currentChangeSetId }));
154
- core_bentley_1.Logger.logInfo(loggerCategory, `Finished Change Summary extraction for changeset #${i + 1}.`, () => ({ iModelId, changeSetId: currentChangeSetId }));
155
- }
156
- changesFile.saveChanges();
157
- return summaries;
158
- }
159
- finally {
160
- changesFile.dispose();
161
- perfLogger = new core_bentley_1.PerfLogger("ChangeSummaryManager.extractChangeSummaries>Move iModel to original changeset");
162
- if (iModel.changeset.id !== endChangeSetId)
163
- await iModel.pullChanges({ accessToken });
164
- perfLogger.dispose();
165
- core_bentley_1.Logger.logTrace(loggerCategory, "Moved iModel to initial changeset (the end changeset).", () => ({ iModelId, startChangeSetId, endChangeSetId }));
166
- totalPerf.dispose();
167
- core_bentley_1.Logger.logInfo(loggerCategory, "Finished Change Summary extraction.", () => ({ iModelId, startChangeSetId, endChangeSetId }));
168
- }
169
- }
170
71
  static openOrCreateChangesFile(iModel) {
171
72
  if (!iModel?.isOpen)
172
73
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid iModel handle. iModel must be open.");
@@ -1 +1 @@
1
- {"version":3,"file":"ChangeSummaryManager.js","sourceRoot":"","sources":["../../src/ChangeSummaryManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAqI;AACrI,oDAAiH;AACjH,6BAA6B;AAC7B,mEAAgE;AAChE,yDAAsD;AACtD,iCAA4C;AAE5C,yCAA6D;AAC7D,6CAA0D;AAC1D,6CAA0C;AAE1C,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAgE1D;;;;;GAKG;AACH,MAAa,oBAAoB;IAG/B;;;OAGG;I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CAAC,CAAC;YACnK,MAAM,GAAG,MAAM,sBAAW,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAE9D,MAAM,UAAU,GAAG,IAAI,KAAK,EAAc,CAAC;YAC3C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBACtD,kCAAkC;gBAClC,IAAI,KAAK,GAAG,CAAC;oBACX,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;gBAE9E,mEAAmE;gBACnE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBACtE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC5B;YACD,OAAO,UAAU,CAAC;SACnB;gBAAS;YACR,IAAI,MAAM,KAAK,SAAS;gBACtB,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,uBAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SACjC;IACH,CAAC;;AA/euB,sDAAiC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AADjF,oDAAoB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { AccessToken, assert, DbResult, GuidString, Id64String, IModelStatus, Logger, PerfLogger, using } from \"@itwin/core-bentley\";\r\nimport { ChangedValueState, ChangeOpCode, ChangesetRange, IModelError, IModelVersion } from \"@itwin/core-common\";\r\nimport * as path from \"path\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { ECDb, ECDbOpenMode } from \"./ECDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\r\nimport { IModelHost, KnownLocations } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Represents an instance of the `ChangeSummary` ECClass from the `ECDbChange` ECSchema\r\n * combined with the information from the related `Changeset` instance (from the `IModelChange` ECSchema) from\r\n * which the Change Summary was extracted.\r\n *\r\n * See also\r\n * - [ChangeSummaryManager.queryChangeSummary]($backend)\r\n * - [ChangeSummary Overview]($docs/learning/ChangeSummaries)\r\n * @beta\r\n */\r\nexport interface ChangeSummary {\r\n id: Id64String;\r\n changeSet: { wsgId: GuidString, parentWsgId: GuidString, description: string, pushDate: string, userCreated: GuidString };\r\n}\r\n\r\n/** Represents an instance of the `InstanceChange` ECClass from the `ECDbChange` ECSchema\r\n *\r\n * See also\r\n * - [ChangeSummaryManager.queryInstanceChange]($backend)\r\n * - [ChangeSummary Overview]($docs/learning/ChangeSummaries)\r\n * @beta\r\n */\r\nexport interface InstanceChange {\r\n id: Id64String;\r\n summaryId: Id64String;\r\n changedInstance: { id: Id64String, className: string };\r\n opCode: ChangeOpCode;\r\n isIndirect: boolean;\r\n}\r\n\r\n/** Options for [ChangeSummaryManager.extractChangeSummaries]($backend).\r\n * @beta\r\n * @deprecated in 2.x. Use [CreateChangeSummaryArgs]($core-backend) instead\r\n */\r\nexport interface ChangeSummaryExtractOptions {\r\n /** If specified, change summaries are extracted from the start version to the current version as of which the iModel\r\n * was opened. If undefined, the extraction starts at the first version of the iModel.\r\n */\r\n startVersion?: IModelVersion;\r\n /** If specified, the change summary will be extracted only for current version as of which the iModel\r\n * was opened.\r\n */\r\n currentVersionOnly?: boolean;\r\n}\r\n\r\n/** Options for [ChangeSummaryManager.createChangeSummaries]($backend).\r\n * @beta\r\n */\r\nexport interface CreateChangeSummaryArgs extends TokenArg {\r\n /** Id of the iTwin that contains the iModel */\r\n iTwinId: GuidString;\r\n\r\n /** Id of the iModel */\r\n iModelId: GuidString;\r\n\r\n /**\r\n * Range of change sets\r\n * - the Change Summary for the first and last versions are also included\r\n * - if unspecified, all change sets until the latest version are processed\r\n */\r\n range: ChangesetRange;\r\n}\r\n\r\n/** Class to extract Change Summaries for a briefcase.\r\n *\r\n * See also:\r\n * - [ChangeSummary Overview]($docs/learning/ChangeSummaries)\r\n * @beta\r\n */\r\nexport class ChangeSummaryManager {\r\n private static readonly _currentIModelChangeSchemaVersion = { read: 2, write: 0, minor: 0 };\r\n\r\n /** Determines whether the *Change Cache file* is attached to the specified iModel or not\r\n * @param iModel iModel to check whether a *Change Cache file* is attached\r\n * @returns Returns true if the *Change Cache file* is attached to the iModel. false otherwise\r\n */\r\n public static isChangeCacheAttached(iModel: IModelDb): boolean {\r\n if (!iModel || !iModel.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n return iModel.nativeDb.isChangeCacheAttached();\r\n }\r\n\r\n /** Attaches the *Change Cache file* to the specified iModel if it hasn't been attached yet.\r\n * A new *Change Cache file* will be created for the iModel if it hasn't existed before.\r\n * @param iModel iModel to attach the *Change Cache file* file to\r\n * @throws [IModelError]($common)\r\n */\r\n public static attachChangeCache(iModel: IModelDb): void {\r\n if (!iModel || !iModel.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n if (ChangeSummaryManager.isChangeCacheAttached(iModel))\r\n return;\r\n\r\n const changesCacheFilePath: string = BriefcaseManager.getChangeCachePathName(iModel.iModelId);\r\n if (!IModelJsFs.existsSync(changesCacheFilePath)) {\r\n using(new ECDb(), (changeCacheFile: ECDb) => {\r\n ChangeSummaryManager.createChangeCacheFile(iModel, changeCacheFile, changesCacheFilePath);\r\n });\r\n }\r\n\r\n assert(IModelJsFs.existsSync(changesCacheFilePath));\r\n const res: DbResult = iModel.nativeDb.attachChangeCache(changesCacheFilePath);\r\n if (res !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(res, `Failed to attach Change Cache file to ${iModel.pathName}.`);\r\n }\r\n\r\n /** Detaches the *Change Cache file* from the specified iModel.\r\n * - note that this method will cause any pending (currently running or queued) queries to fail\r\n * @param iModel iModel to detach the *Change Cache file* to\r\n * @throws [IModelError]($common) in case of errors, e.g. if no *Change Cache file* was attached before.\r\n */\r\n public static detachChangeCache(iModel: IModelDb): void {\r\n if (!iModel || !iModel.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n iModel.clearCaches();\r\n const res: DbResult = iModel.nativeDb.detachChangeCache();\r\n if (res !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(res, `Failed to detach Change Cache file from ${iModel.pathName}.`);\r\n }\r\n\r\n /** Extracts change summaries from the specified iModel.\r\n * Change summaries are extracted from the version the iModel was opened with up through the specified start version.\r\n * If no start version has been specified, the first version will be used.\r\n * @param accessToken A valid access token string\r\n * @param iModel iModel to extract change summaries for. The iModel must not be a standalone iModel.\r\n * Note: For every version to extract a summary from, the method moves the iModel to that version before extraction. After\r\n * the extraction has completed, the iModel is moved back to the original version.\r\n * @param options Extraction options\r\n * @return the Ids of the extracted change summaries.\r\n * @throws [IModelError]($common) if the iModel is standalone\r\n * @deprecated in 2.x. Use [ChangeSummaryManager.createChangeSummaries]($core-backend) instead\r\n */\r\n public static async extractChangeSummaries(accessToken: AccessToken, iModel: BriefcaseDb, options?: ChangeSummaryExtractOptions): Promise<Id64String[]> { // eslint-disable-line deprecation/deprecation\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n const iModelId = iModel.iModelId;\r\n const endChangeSetId = iModel.changeset.id;\r\n assert(endChangeSetId.length !== 0);\r\n\r\n let startChangeSetId = \"\";\r\n if (options) {\r\n if (options.startVersion) {\r\n startChangeSetId = (await IModelHost.hubAccess.getChangesetFromVersion({ version: options.startVersion, accessToken, iModelId })).id;\r\n } else if (options.currentVersionOnly) {\r\n startChangeSetId = endChangeSetId;\r\n }\r\n }\r\n\r\n Logger.logInfo(loggerCategory, \"Started Change Summary extraction...\", () => ({ iModelId, startChangeSetId, endChangeSetId }));\r\n const totalPerf = new PerfLogger(`ChangeSummaryManager.extractChangeSummaries [ChangeSets: ${startChangeSetId} through ${endChangeSetId}, iModel: ${iModelId}]`);\r\n\r\n // download necessary changesets if they were not downloaded before and retrieve infos about those changesets\r\n let perfLogger = new PerfLogger(\"ChangeSummaryManager.extractChangeSummaries>Retrieve ChangeSetInfos and download Changesets from Hub\");\r\n\r\n const first = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: startChangeSetId }, accessToken })).index;\r\n const end = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: endChangeSetId }, accessToken })).index;\r\n const changeSetInfos = await IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager.getChangeSetsPath(iModelId) });\r\n perfLogger.dispose();\r\n Logger.logTrace(loggerCategory, \"Retrieved changesets to extract from from cache or from hub.\", () => ({ iModelId, startChangeSetId, endChangeSetId, changeSets: changeSetInfos }));\r\n\r\n // Ensure change cache is detached as it's being written to during the extraction\r\n if (this.isChangeCacheAttached(iModel)) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Change cache must be detached before extraction\");\r\n }\r\n\r\n perfLogger = new PerfLogger(\"ChangeSummaryManager.extractChangeSummaries>Open or create local Change Cache file\");\r\n const changesFile = ChangeSummaryManager.openOrCreateChangesFile(iModel);\r\n assert(changesFile.nativeDb !== undefined, \"Should not happen as an exception should have been thrown in that case\");\r\n perfLogger.dispose();\r\n Logger.logTrace(loggerCategory, \"Opened or created Changes Cachefile.\", () => ({ iModelId, startChangeSetId, endChangeSetId }));\r\n\r\n try {\r\n // extract summaries from end changeset through start changeset, so that we only have to go back in history\r\n const changeSetCount: number = changeSetInfos.length;\r\n const endChangeSetIx: number = changeSetCount - 1;\r\n const summaries: Id64String[] = [];\r\n for (let i = endChangeSetIx; i >= 0; i--) {\r\n const currentChangeSetInfo = changeSetInfos[i];\r\n const currentChangeSetId = currentChangeSetInfo.id;\r\n Logger.logInfo(loggerCategory, `Started Change Summary extraction for changeset #${i + 1}...`, () => ({ iModelId, changeSetId: currentChangeSetId }));\r\n\r\n const existingSummaryId: Id64String | undefined = ChangeSummaryManager.isSummaryAlreadyExtracted(changesFile, currentChangeSetId);\r\n if (!!existingSummaryId) {\r\n Logger.logInfo(loggerCategory, `Change Summary for changeset #${i + 1} already exists. It is not extracted again.`, () => ({ iModelId, changeSetId: currentChangeSetId }));\r\n summaries.push(existingSummaryId);\r\n continue;\r\n }\r\n\r\n // iModel is at end changeset, so no need to reverse for it.\r\n if (i !== endChangeSetIx) {\r\n perfLogger = new PerfLogger(\"ChangeSummaryManager.extractChangeSummaries>Roll iModel to previous changeset\");\r\n\r\n await iModel.pullChanges({ accessToken, toIndex: currentChangeSetInfo.index });\r\n perfLogger.dispose();\r\n Logger.logTrace(loggerCategory, `Moved iModel to changeset #${i + 1} to extract summary from.`, () => ({ iModelId, changeSetId: currentChangeSetId }));\r\n }\r\n\r\n const changeSetFilePath = currentChangeSetInfo.pathname;\r\n if (!IModelJsFs.existsSync(changeSetFilePath))\r\n throw new IModelError(IModelStatus.FileNotFound, `Failed to extract change summary: ChangeSet file \"${changeSetFilePath}\" does not exist.`);\r\n\r\n perfLogger = new PerfLogger(\"ChangeSummaryManager.extractChangeSummaries>Extract ChangeSummary\");\r\n const stat = iModel.nativeDb.extractChangeSummary(changesFile.nativeDb, changeSetFilePath);\r\n perfLogger.dispose();\r\n if (stat.error && stat.error.status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat.error.status, stat.error.message);\r\n\r\n Logger.logTrace(loggerCategory, `Actual Change summary extraction done for changeset #${i + 1}.`, () => ({ iModelId, changeSetId: currentChangeSetId }));\r\n\r\n perfLogger = new PerfLogger(\"ChangeSummaryManager.extractChangeSummaries>Add ChangeSet info to ChangeSummary\");\r\n assert(undefined !== stat.result);\r\n const changeSummaryId = stat.result;\r\n summaries.push(changeSummaryId);\r\n ChangeSummaryManager.addExtendedInfos(changesFile, changeSummaryId, currentChangeSetId, currentChangeSetInfo.parentId, currentChangeSetInfo.description, currentChangeSetInfo.pushDate, currentChangeSetInfo.userCreated);\r\n perfLogger.dispose();\r\n Logger.logTrace(loggerCategory, `Added extended infos to Change Summary for changeset #${i + 1}.`, () => ({ iModelId, changeSetId: currentChangeSetId }));\r\n\r\n Logger.logInfo(loggerCategory, `Finished Change Summary extraction for changeset #${i + 1}.`, () => ({ iModelId, changeSetId: currentChangeSetId }));\r\n }\r\n\r\n changesFile.saveChanges();\r\n return summaries;\r\n } finally {\r\n changesFile.dispose();\r\n\r\n perfLogger = new PerfLogger(\"ChangeSummaryManager.extractChangeSummaries>Move iModel to original changeset\");\r\n if (iModel.changeset.id !== endChangeSetId)\r\n await iModel.pullChanges({ accessToken });\r\n perfLogger.dispose();\r\n Logger.logTrace(loggerCategory, \"Moved iModel to initial changeset (the end changeset).\", () => ({ iModelId, startChangeSetId, endChangeSetId }));\r\n\r\n totalPerf.dispose();\r\n Logger.logInfo(loggerCategory, \"Finished Change Summary extraction.\", () => ({ iModelId, startChangeSetId, endChangeSetId }));\r\n }\r\n }\r\n\r\n private static openOrCreateChangesFile(iModel: BriefcaseDb): ECDb {\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid iModel handle. iModel must be open.\");\r\n\r\n const changesFile = new ECDb();\r\n const changeCacheFilePath = BriefcaseManager.getChangeCachePathName(iModel.iModelId);\r\n if (IModelJsFs.existsSync(changeCacheFilePath)) {\r\n ChangeSummaryManager.openChangeCacheFile(changesFile, changeCacheFilePath);\r\n return changesFile;\r\n }\r\n\r\n try {\r\n ChangeSummaryManager.createChangeCacheFile(iModel, changesFile, changeCacheFilePath);\r\n return changesFile;\r\n } catch (e) {\r\n // delete cache file again in case it was created but schema import failed\r\n if (IModelJsFs.existsSync(changeCacheFilePath))\r\n IModelJsFs.removeSync(changeCacheFilePath);\r\n\r\n throw e;\r\n }\r\n }\r\n\r\n private static createChangeCacheFile(iModel: IModelDb, changesFile: ECDb, changeCacheFilePath: string): void {\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid iModel object. iModel must be open.\");\r\n\r\n const stat: DbResult = iModel.nativeDb.createChangeCache(changesFile.nativeDb, changeCacheFilePath);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, `Failed to create Change Cache file at \"${changeCacheFilePath}\".`);\r\n\r\n // Extended information like changeset ids, push dates are persisted in the IModelChange ECSchema\r\n changesFile.importSchema(ChangeSummaryManager.getExtendedSchemaPath());\r\n }\r\n\r\n private static openChangeCacheFile(changesFile: ECDb, changeCacheFilePath: string): void {\r\n changesFile.openDb(changeCacheFilePath, ECDbOpenMode.FileUpgrade);\r\n\r\n const actualSchemaVersion: { read: number, write: number, minor: number } = changesFile.withPreparedStatement(\"SELECT VersionMajor read,VersionWrite write,VersionMinor minor FROM meta.ECSchemaDef WHERE Name='IModelChange'\",\r\n (stmt: ECSqlStatement) => {\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"File is not a valid Change Cache file.\");\r\n\r\n return stmt.getRow();\r\n });\r\n\r\n if (actualSchemaVersion.read === ChangeSummaryManager._currentIModelChangeSchemaVersion.read &&\r\n actualSchemaVersion.write === ChangeSummaryManager._currentIModelChangeSchemaVersion.write &&\r\n actualSchemaVersion.minor === ChangeSummaryManager._currentIModelChangeSchemaVersion.minor)\r\n return;\r\n\r\n changesFile.importSchema(ChangeSummaryManager.getExtendedSchemaPath());\r\n }\r\n\r\n private static getExtendedSchemaPath(): string { return path.join(KnownLocations.packageAssetsDir, \"IModelChange.02.00.00.ecschema.xml\"); }\r\n\r\n private static isSummaryAlreadyExtracted(changesFile: ECDb, changeSetId: GuidString): Id64String | undefined {\r\n return changesFile.withPreparedStatement(\"SELECT Summary.Id summaryid FROM imodelchange.ChangeSet WHERE WsgId=?\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindString(1, changeSetId);\r\n if (DbResult.BE_SQLITE_ROW === stmt.step())\r\n return stmt.getValue(0).getId();\r\n\r\n return undefined;\r\n });\r\n }\r\n\r\n private static addExtendedInfos(changesFile: ECDb, changeSummaryId: Id64String, changesetWsgId: GuidString, changesetParentWsgId?: GuidString, description?: string, changesetPushDate?: string, changeSetUserCreated?: GuidString): void {\r\n changesFile.withPreparedStatement(\"INSERT INTO imodelchange.ChangeSet(Summary.Id,WsgId,ParentWsgId,Description,PushDate,UserCreated) VALUES(?,?,?,?,?,?)\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, changeSummaryId);\r\n stmt.bindString(2, changesetWsgId);\r\n if (changesetParentWsgId)\r\n stmt.bindString(3, changesetParentWsgId);\r\n\r\n if (description)\r\n stmt.bindString(4, description);\r\n\r\n if (changesetPushDate)\r\n stmt.bindDateTime(5, changesetPushDate);\r\n\r\n if (changeSetUserCreated)\r\n stmt.bindString(6, changeSetUserCreated);\r\n\r\n const r: DbResult = stmt.step();\r\n if (r !== DbResult.BE_SQLITE_DONE)\r\n throw new IModelError(r, `Failed to add changeset information to extracted change summary ${changeSummaryId}`);\r\n });\r\n }\r\n\r\n /** Queries the ChangeSummary for the specified change summary id\r\n *\r\n * See also\r\n * - `ECDbChange.ChangeSummary` ECClass in the *ECDbChange* ECSchema\r\n * - [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param changeSummaryId ECInstanceId of the ChangeSummary\r\n * @returns Returns the requested ChangeSummary object\r\n * @throws [IModelError]($common) If change summary does not exist for the specified id, or if the\r\n * change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static queryChangeSummary(iModel: BriefcaseDb, changeSummaryId: Id64String): ChangeSummary {\r\n if (!ChangeSummaryManager.isChangeCacheAttached(iModel))\r\n throw new IModelError(IModelStatus.BadArg, \"Change Cache file must be attached to iModel.\");\r\n\r\n return iModel.withPreparedStatement(\"SELECT WsgId,ParentWsgId,Description,PushDate,UserCreated FROM ecchange.imodelchange.ChangeSet WHERE Summary.Id=?\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, changeSummaryId);\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(IModelStatus.BadArg, `No ChangeSet information found for ChangeSummary ${changeSummaryId}.`);\r\n\r\n const row = stmt.getRow();\r\n return { id: changeSummaryId, changeSet: { wsgId: row.wsgId, parentWsgId: row.parentWsgId, description: row.description, pushDate: row.pushDate, userCreated: row.userCreated } };\r\n });\r\n }\r\n\r\n /** Queries the InstanceChange for the specified instance change id.\r\n *\r\n * See also\r\n * - `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema\r\n * - [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param instanceChangeId ECInstanceId of the InstanceChange (see `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema)\r\n * @returns Returns the requested InstanceChange object (see `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema)\r\n * @throws [IModelError]($common) if instance change does not exist for the specified id, or if the\r\n * change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static queryInstanceChange(iModel: BriefcaseDb, instanceChangeId: Id64String): InstanceChange {\r\n if (!ChangeSummaryManager.isChangeCacheAttached(iModel))\r\n throw new IModelError(IModelStatus.BadArg, \"Change Cache file must be attached to iModel.\");\r\n\r\n // query instance changes\r\n const instanceChange: InstanceChange = iModel.withPreparedStatement(`SELECT ic.Summary.Id summaryId, s.Name changedInstanceSchemaName, c.Name changedInstanceClassName, ic.ChangedInstance.Id changedInstanceId,\r\n ic.OpCode, ic.IsIndirect FROM ecchange.change.InstanceChange ic JOIN main.meta.ECClassDef c ON c.ECInstanceId = ic.ChangedInstance.ClassId\r\n JOIN main.meta.ECSchemaDef s ON c.Schema.Id = s.ECInstanceId WHERE ic.ECInstanceId =? `, (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, instanceChangeId);\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(IModelStatus.BadArg, `No InstanceChange found for id ${instanceChangeId}.`);\r\n\r\n const row = stmt.getRow();\r\n const changedInstanceId: Id64String = row.changedInstanceId;\r\n const changedInstanceClassName: string = `[${row.changedInstanceSchemaName}].[${row.changedInstanceClassName}]`;\r\n const op: ChangeOpCode = row.opCode as ChangeOpCode;\r\n\r\n return {\r\n id: instanceChangeId, summaryId: row.summaryId, changedInstance: { id: changedInstanceId, className: changedInstanceClassName },\r\n opCode: op, isIndirect: row.isIndirect,\r\n };\r\n });\r\n\r\n return instanceChange;\r\n }\r\n\r\n /** Retrieves the names of the properties whose values have changed for the given instance change\r\n *\r\n * See also [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param instanceChangeId Id of the InstanceChange to query the properties whose values have changed\r\n * @returns Returns names of the properties whose values have changed for the given instance change\r\n * @throws [IModelError]($common) if the change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static getChangedPropertyValueNames(iModel: IModelDb, instanceChangeId: Id64String): string[] {\r\n return iModel.withPreparedStatement(\"SELECT AccessString FROM ecchange.change.PropertyValueChange WHERE InstanceChange.Id=?\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, instanceChangeId);\r\n\r\n const selectClauseItems: string[] = [];\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n // access string tokens need to be escaped as they might collide with reserved words in ECSQL or SQLite\r\n const accessString: string = stmt.getValue(0).getString();\r\n const accessStringTokens: string[] = accessString.split(\".\");\r\n assert(accessStringTokens.length > 0);\r\n\r\n let isFirstToken: boolean = true;\r\n let item: string = \"\";\r\n for (const token of accessStringTokens) {\r\n if (!isFirstToken)\r\n item += \".\";\r\n\r\n item += `[${token}]`;\r\n isFirstToken = false;\r\n }\r\n selectClauseItems.push(item);\r\n }\r\n\r\n return selectClauseItems;\r\n });\r\n }\r\n\r\n /** Builds the ECSQL to query the property value changes for the specified instance change and the specified ChangedValueState.\r\n *\r\n * See also [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param instanceChangeInfo InstanceChange to query the property value changes for\r\n * 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]`\r\n * @param changedValueState The Changed State to query the values for. This must correspond to the [InstanceChange.OpCode]($backend) of the InstanceChange.\r\n * @param changedPropertyNames List of the property names for which values have changed for the specified instance change.\r\n * The list can be obtained by calling [ChangeSummaryManager.getChangedPropertyValueNames]($core-backend).\r\n * If omitted, the method will call the above method by itself. The parameter allows for checking first whether\r\n * an instance change has any property value changes at all. If there are no property value changes, this method\r\n * should not be called, as it will throw an error.\r\n * @returns Returns the ECSQL that will retrieve the property value changes\r\n * @throws [IModelError]($common) if instance change does not exist, if there are not property value changes for the instance change,\r\n * if the change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static buildPropertyValueChangesECSql(iModel: IModelDb, instanceChangeInfo: { id: Id64String, summaryId: Id64String, changedInstance: { id: Id64String, className: string } }, changedValueState: ChangedValueState, changedPropertyNames?: string[]): string {\r\n let selectClauseItems: string[];\r\n if (!changedPropertyNames) {\r\n // query property value changes just to build a SELECT statement against the class of the changed instance\r\n selectClauseItems = ChangeSummaryManager.getChangedPropertyValueNames(iModel, instanceChangeInfo.id);\r\n } else\r\n selectClauseItems = changedPropertyNames;\r\n\r\n if (selectClauseItems.length === 0)\r\n throw new IModelError(IModelStatus.BadArg, `No property value changes found for InstanceChange ${instanceChangeInfo.id}.`);\r\n\r\n let ecsql: string = \"SELECT \";\r\n selectClauseItems.map((item: string, index: number) => {\r\n if (index !== 0)\r\n ecsql += \",\";\r\n\r\n ecsql += item;\r\n });\r\n\r\n // Avoiding parameters in the Changes function speeds up performance because ECDb can do optimizations\r\n // if it knows the function args at prepare time\r\n ecsql += ` FROM main.${instanceChangeInfo.changedInstance.className}.Changes(${instanceChangeInfo.summaryId},${changedValueState}) WHERE ECInstanceId=${instanceChangeInfo.changedInstance.id}`;\r\n return ecsql;\r\n }\r\n\r\n /**\r\n * Creates a change summary for the last applied change set to the iModel\r\n * @param accessToken A valid access token string\r\n * @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.\r\n * @returns The id of the extracted change summary.\r\n * @beta\r\n */\r\n public static async createChangeSummary(accessToken: AccessToken, iModel: BriefcaseDb): Promise<Id64String> {\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n const changesetId = iModel.changeset.id;\r\n if (!changesetId)\r\n throw new IModelError(IModelStatus.BadRequest, \"No change set was applied to the iModel\");\r\n if (this.isChangeCacheAttached(iModel))\r\n throw new IModelError(IModelStatus.BadRequest, \"Change cache must be detached before extraction\");\r\n\r\n const iModelId = iModel.iModelId;\r\n const changesetsFolder: string = BriefcaseManager.getChangeSetsPath(iModelId);\r\n const changeset = await IModelHost.hubAccess.downloadChangeset({ accessToken, iModelId, changeset: { id: iModel.changeset.id }, targetDir: changesetsFolder });\r\n\r\n if (!IModelJsFs.existsSync(changeset.pathname))\r\n throw new IModelError(IModelStatus.FileNotFound, `Failed to download change set: ${changeset.pathname}`);\r\n\r\n let changesFile: ECDb | undefined;\r\n try {\r\n changesFile = ChangeSummaryManager.openOrCreateChangesFile(iModel);\r\n assert(changesFile.nativeDb !== undefined, \"Invalid changesFile - should've caused an exception\");\r\n\r\n let changeSummaryId = ChangeSummaryManager.isSummaryAlreadyExtracted(changesFile, changesetId);\r\n if (changeSummaryId !== undefined) {\r\n Logger.logInfo(loggerCategory, `Change Summary for changeset already exists. It is not extracted again.`, () => ({ iModelId, changeSetId: changesetId }));\r\n return changeSummaryId;\r\n }\r\n\r\n const stat = iModel.nativeDb.extractChangeSummary(changesFile.nativeDb, changeset.pathname);\r\n if (stat.error && stat.error.status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat.error.status, stat.error.message);\r\n\r\n assert(undefined !== stat.result);\r\n changeSummaryId = stat.result;\r\n ChangeSummaryManager.addExtendedInfos(changesFile, changeSummaryId, changesetId, changeset.parentId, changeset.description, changeset.pushDate, changeset.userCreated);\r\n\r\n changesFile.saveChanges();\r\n return changeSummaryId;\r\n } finally {\r\n if (changesFile !== undefined)\r\n changesFile.dispose();\r\n IModelJsFs.unlinkSync(changeset.pathname);\r\n }\r\n }\r\n\r\n /**\r\n * Creates change summaries for the specified iModel and a specified range of versions\r\n * @note This may be an expensive operation - downloads the first version and starts applying the change sets, extracting summaries one by one\r\n * @param args Arguments including the range of versions for which Change Summaries are to be created, and other necessary input for creation\r\n */\r\n public static async createChangeSummaries(args: CreateChangeSummaryArgs): Promise<Id64String[]> {\r\n const accessToken = args.accessToken ?? await IModelHost.getAccessToken() ?? \"\";\r\n const { iModelId, iTwinId, range } = args;\r\n range.end = range.end ?? (await IModelHost.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version: IModelVersion.latest() })).index;\r\n if (range.first > range.end)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid range of changesets\");\r\n if (range.first === 0 && range.end === 0)\r\n return []; // no changesets exist, so the inclusive range is empty\r\n\r\n const changesets = await IModelHost.hubAccess.queryChangesets({ accessToken, iModelId, range });\r\n\r\n // Setup a temporary briefcase to help with extracting change summaries\r\n const briefcasePath = BriefcaseManager.getBriefcaseBasePath(iModelId);\r\n const fileName: string = path.join(briefcasePath, `ChangeSummaryBriefcase.bim`);\r\n if (IModelJsFs.existsSync(fileName))\r\n IModelJsFs.removeSync(fileName);\r\n\r\n let iModel: BriefcaseDb | undefined;\r\n try {\r\n // Download a version that has the first change set applied\r\n const props = await BriefcaseManager.downloadBriefcase({ accessToken, iTwinId, iModelId, asOf: { afterChangeSetId: changesets[0].id }, briefcaseId: 0, fileName });\r\n iModel = await BriefcaseDb.open({ fileName: props.fileName });\r\n\r\n const summaryIds = new Array<Id64String>();\r\n for (let index = 0; index < changesets.length; index++) {\r\n // Apply a change set if necessary\r\n if (index > 0)\r\n await iModel.pullChanges({ accessToken, toIndex: changesets[index].index });\r\n\r\n // Create a change summary for the last change set that was applied\r\n const summaryId = await this.createChangeSummary(accessToken, iModel);\r\n summaryIds.push(summaryId);\r\n }\r\n return summaryIds;\r\n } finally {\r\n if (iModel !== undefined)\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ChangeSummaryManager.js","sourceRoot":"","sources":["../../src/ChangeSummaryManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyH;AACzH,oDAAiH;AACjH,6BAA6B;AAC7B,mEAAgE;AAChE,yDAAsD;AACtD,iCAA4C;AAE5C,yCAA6D;AAC7D,6CAA0D;AAC1D,6CAA0C;AAE1C,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAiD1D;;;;;GAKG;AACH,MAAa,oBAAoB;IAG/B;;;OAGG;IACI,MAAM,CAAC,qBAAqB,CAAC,MAAgB;QAClD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM;YAC3B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;QAE3E,OAAO,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAAC,MAAgB;QAC9C,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM;YAC3B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,wBAAwB,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,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;gBAE9E,mEAAmE;gBACnE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBACtE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC5B;YACD,OAAO,UAAU,CAAC;SACnB;gBAAS;YACR,IAAI,MAAM,KAAK,SAAS;gBACtB,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,uBAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SACjC;IACH,CAAC;;AA1XuB,sDAAiC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AADjF,oDAAoB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { AccessToken, assert, DbResult, GuidString, Id64String, IModelStatus, Logger, using } from \"@itwin/core-bentley\";\r\nimport { ChangedValueState, ChangeOpCode, ChangesetRange, IModelError, IModelVersion } from \"@itwin/core-common\";\r\nimport * as path from \"path\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { ECDb, ECDbOpenMode } from \"./ECDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\r\nimport { IModelHost, KnownLocations } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Represents an instance of the `ChangeSummary` ECClass from the `ECDbChange` ECSchema\r\n * combined with the information from the related `Changeset` instance (from the `IModelChange` ECSchema) from\r\n * which the Change Summary was extracted.\r\n *\r\n * See also\r\n * - [ChangeSummaryManager.queryChangeSummary]($backend)\r\n * - [ChangeSummary Overview]($docs/learning/ChangeSummaries)\r\n * @beta\r\n */\r\nexport interface ChangeSummary {\r\n id: Id64String;\r\n changeSet: { wsgId: GuidString, parentWsgId: GuidString, description: string, pushDate: string, userCreated: GuidString };\r\n}\r\n\r\n/** Represents an instance of the `InstanceChange` ECClass from the `ECDbChange` ECSchema\r\n *\r\n * See also\r\n * - [ChangeSummaryManager.queryInstanceChange]($backend)\r\n * - [ChangeSummary Overview]($docs/learning/ChangeSummaries)\r\n * @beta\r\n */\r\nexport interface InstanceChange {\r\n id: Id64String;\r\n summaryId: Id64String;\r\n changedInstance: { id: Id64String, className: string };\r\n opCode: ChangeOpCode;\r\n isIndirect: boolean;\r\n}\r\n\r\n/** Options for [ChangeSummaryManager.createChangeSummaries]($backend).\r\n * @beta\r\n */\r\nexport interface CreateChangeSummaryArgs extends TokenArg {\r\n /** Id of the iTwin that contains the iModel */\r\n iTwinId: GuidString;\r\n\r\n /** Id of the iModel */\r\n iModelId: GuidString;\r\n\r\n /**\r\n * Range of change sets\r\n * - the Change Summary for the first and last versions are also included\r\n * - if unspecified, all change sets until the latest version are processed\r\n */\r\n range: ChangesetRange;\r\n}\r\n\r\n/** Class to extract Change Summaries for a briefcase.\r\n *\r\n * See also:\r\n * - [ChangeSummary Overview]($docs/learning/ChangeSummaries)\r\n * @beta\r\n */\r\nexport class ChangeSummaryManager {\r\n private static readonly _currentIModelChangeSchemaVersion = { read: 2, write: 0, minor: 0 };\r\n\r\n /** Determines whether the *Change Cache file* is attached to the specified iModel or not\r\n * @param iModel iModel to check whether a *Change Cache file* is attached\r\n * @returns Returns true if the *Change Cache file* is attached to the iModel. false otherwise\r\n */\r\n public static isChangeCacheAttached(iModel: IModelDb): boolean {\r\n if (!iModel || !iModel.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n return iModel.nativeDb.isChangeCacheAttached();\r\n }\r\n\r\n /** Attaches the *Change Cache file* to the specified iModel if it hasn't been attached yet.\r\n * A new *Change Cache file* will be created for the iModel if it hasn't existed before.\r\n * @param iModel iModel to attach the *Change Cache file* file to\r\n * @throws [IModelError]($common)\r\n */\r\n public static attachChangeCache(iModel: IModelDb): void {\r\n if (!iModel || !iModel.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n if (ChangeSummaryManager.isChangeCacheAttached(iModel))\r\n return;\r\n\r\n const changesCacheFilePath: string = BriefcaseManager.getChangeCachePathName(iModel.iModelId);\r\n if (!IModelJsFs.existsSync(changesCacheFilePath)) {\r\n using(new ECDb(), (changeCacheFile: ECDb) => {\r\n ChangeSummaryManager.createChangeCacheFile(iModel, changeCacheFile, changesCacheFilePath);\r\n });\r\n }\r\n\r\n assert(IModelJsFs.existsSync(changesCacheFilePath));\r\n const res: DbResult = iModel.nativeDb.attachChangeCache(changesCacheFilePath);\r\n if (res !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(res, `Failed to attach Change Cache file to ${iModel.pathName}.`);\r\n }\r\n\r\n /** Detaches the *Change Cache file* from the specified iModel.\r\n * - note that this method will cause any pending (currently running or queued) queries to fail\r\n * @param iModel iModel to detach the *Change Cache file* to\r\n * @throws [IModelError]($common) in case of errors, e.g. if no *Change Cache file* was attached before.\r\n */\r\n public static detachChangeCache(iModel: IModelDb): void {\r\n if (!iModel || !iModel.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n\r\n iModel.clearCaches();\r\n const res: DbResult = iModel.nativeDb.detachChangeCache();\r\n if (res !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(res, `Failed to detach Change Cache file from ${iModel.pathName}.`);\r\n }\r\n\r\n private static openOrCreateChangesFile(iModel: BriefcaseDb): ECDb {\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid iModel handle. iModel must be open.\");\r\n\r\n const changesFile = new ECDb();\r\n const changeCacheFilePath = BriefcaseManager.getChangeCachePathName(iModel.iModelId);\r\n if (IModelJsFs.existsSync(changeCacheFilePath)) {\r\n ChangeSummaryManager.openChangeCacheFile(changesFile, changeCacheFilePath);\r\n return changesFile;\r\n }\r\n\r\n try {\r\n ChangeSummaryManager.createChangeCacheFile(iModel, changesFile, changeCacheFilePath);\r\n return changesFile;\r\n } catch (e) {\r\n // delete cache file again in case it was created but schema import failed\r\n if (IModelJsFs.existsSync(changeCacheFilePath))\r\n IModelJsFs.removeSync(changeCacheFilePath);\r\n\r\n throw e;\r\n }\r\n }\r\n\r\n private static createChangeCacheFile(iModel: IModelDb, changesFile: ECDb, changeCacheFilePath: string): void {\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid iModel object. iModel must be open.\");\r\n\r\n const stat: DbResult = iModel.nativeDb.createChangeCache(changesFile.nativeDb, changeCacheFilePath);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, `Failed to create Change Cache file at \"${changeCacheFilePath}\".`);\r\n\r\n // Extended information like changeset ids, push dates are persisted in the IModelChange ECSchema\r\n changesFile.importSchema(ChangeSummaryManager.getExtendedSchemaPath());\r\n }\r\n\r\n private static openChangeCacheFile(changesFile: ECDb, changeCacheFilePath: string): void {\r\n changesFile.openDb(changeCacheFilePath, ECDbOpenMode.FileUpgrade);\r\n\r\n const actualSchemaVersion: { read: number, write: number, minor: number } = changesFile.withPreparedStatement(\"SELECT VersionMajor read,VersionWrite write,VersionMinor minor FROM meta.ECSchemaDef WHERE Name='IModelChange'\",\r\n (stmt: ECSqlStatement) => {\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"File is not a valid Change Cache file.\");\r\n\r\n return stmt.getRow();\r\n });\r\n\r\n if (actualSchemaVersion.read === ChangeSummaryManager._currentIModelChangeSchemaVersion.read &&\r\n actualSchemaVersion.write === ChangeSummaryManager._currentIModelChangeSchemaVersion.write &&\r\n actualSchemaVersion.minor === ChangeSummaryManager._currentIModelChangeSchemaVersion.minor)\r\n return;\r\n\r\n changesFile.importSchema(ChangeSummaryManager.getExtendedSchemaPath());\r\n }\r\n\r\n private static getExtendedSchemaPath(): string { return path.join(KnownLocations.packageAssetsDir, \"IModelChange.02.00.00.ecschema.xml\"); }\r\n\r\n private static isSummaryAlreadyExtracted(changesFile: ECDb, changeSetId: GuidString): Id64String | undefined {\r\n return changesFile.withPreparedStatement(\"SELECT Summary.Id summaryid FROM imodelchange.ChangeSet WHERE WsgId=?\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindString(1, changeSetId);\r\n if (DbResult.BE_SQLITE_ROW === stmt.step())\r\n return stmt.getValue(0).getId();\r\n\r\n return undefined;\r\n });\r\n }\r\n\r\n private static addExtendedInfos(changesFile: ECDb, changeSummaryId: Id64String, changesetWsgId: GuidString, changesetParentWsgId?: GuidString, description?: string, changesetPushDate?: string, changeSetUserCreated?: GuidString): void {\r\n changesFile.withPreparedStatement(\"INSERT INTO imodelchange.ChangeSet(Summary.Id,WsgId,ParentWsgId,Description,PushDate,UserCreated) VALUES(?,?,?,?,?,?)\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, changeSummaryId);\r\n stmt.bindString(2, changesetWsgId);\r\n if (changesetParentWsgId)\r\n stmt.bindString(3, changesetParentWsgId);\r\n\r\n if (description)\r\n stmt.bindString(4, description);\r\n\r\n if (changesetPushDate)\r\n stmt.bindDateTime(5, changesetPushDate);\r\n\r\n if (changeSetUserCreated)\r\n stmt.bindString(6, changeSetUserCreated);\r\n\r\n const r: DbResult = stmt.step();\r\n if (r !== DbResult.BE_SQLITE_DONE)\r\n throw new IModelError(r, `Failed to add changeset information to extracted change summary ${changeSummaryId}`);\r\n });\r\n }\r\n\r\n /** Queries the ChangeSummary for the specified change summary id\r\n *\r\n * See also\r\n * - `ECDbChange.ChangeSummary` ECClass in the *ECDbChange* ECSchema\r\n * - [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param changeSummaryId ECInstanceId of the ChangeSummary\r\n * @returns Returns the requested ChangeSummary object\r\n * @throws [IModelError]($common) If change summary does not exist for the specified id, or if the\r\n * change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static queryChangeSummary(iModel: BriefcaseDb, changeSummaryId: Id64String): ChangeSummary {\r\n if (!ChangeSummaryManager.isChangeCacheAttached(iModel))\r\n throw new IModelError(IModelStatus.BadArg, \"Change Cache file must be attached to iModel.\");\r\n\r\n return iModel.withPreparedStatement(\"SELECT WsgId,ParentWsgId,Description,PushDate,UserCreated FROM ecchange.imodelchange.ChangeSet WHERE Summary.Id=?\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, changeSummaryId);\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(IModelStatus.BadArg, `No ChangeSet information found for ChangeSummary ${changeSummaryId}.`);\r\n\r\n const row = stmt.getRow();\r\n return { id: changeSummaryId, changeSet: { wsgId: row.wsgId, parentWsgId: row.parentWsgId, description: row.description, pushDate: row.pushDate, userCreated: row.userCreated } };\r\n });\r\n }\r\n\r\n /** Queries the InstanceChange for the specified instance change id.\r\n *\r\n * See also\r\n * - `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema\r\n * - [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param instanceChangeId ECInstanceId of the InstanceChange (see `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema)\r\n * @returns Returns the requested InstanceChange object (see `ECDbChange.InstanceChange` ECClass in the *ECDbChange* ECSchema)\r\n * @throws [IModelError]($common) if instance change does not exist for the specified id, or if the\r\n * change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static queryInstanceChange(iModel: BriefcaseDb, instanceChangeId: Id64String): InstanceChange {\r\n if (!ChangeSummaryManager.isChangeCacheAttached(iModel))\r\n throw new IModelError(IModelStatus.BadArg, \"Change Cache file must be attached to iModel.\");\r\n\r\n // query instance changes\r\n const instanceChange: InstanceChange = iModel.withPreparedStatement(`SELECT ic.Summary.Id summaryId, s.Name changedInstanceSchemaName, c.Name changedInstanceClassName, ic.ChangedInstance.Id changedInstanceId,\r\n ic.OpCode, ic.IsIndirect FROM ecchange.change.InstanceChange ic JOIN main.meta.ECClassDef c ON c.ECInstanceId = ic.ChangedInstance.ClassId\r\n JOIN main.meta.ECSchemaDef s ON c.Schema.Id = s.ECInstanceId WHERE ic.ECInstanceId =? `, (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, instanceChangeId);\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(IModelStatus.BadArg, `No InstanceChange found for id ${instanceChangeId}.`);\r\n\r\n const row = stmt.getRow();\r\n const changedInstanceId: Id64String = row.changedInstanceId;\r\n const changedInstanceClassName: string = `[${row.changedInstanceSchemaName}].[${row.changedInstanceClassName}]`;\r\n const op: ChangeOpCode = row.opCode as ChangeOpCode;\r\n\r\n return {\r\n id: instanceChangeId, summaryId: row.summaryId, changedInstance: { id: changedInstanceId, className: changedInstanceClassName },\r\n opCode: op, isIndirect: row.isIndirect,\r\n };\r\n });\r\n\r\n return instanceChange;\r\n }\r\n\r\n /** Retrieves the names of the properties whose values have changed for the given instance change\r\n *\r\n * See also [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param instanceChangeId Id of the InstanceChange to query the properties whose values have changed\r\n * @returns Returns names of the properties whose values have changed for the given instance change\r\n * @throws [IModelError]($common) if the change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static getChangedPropertyValueNames(iModel: IModelDb, instanceChangeId: Id64String): string[] {\r\n return iModel.withPreparedStatement(\"SELECT AccessString FROM ecchange.change.PropertyValueChange WHERE InstanceChange.Id=?\",\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, instanceChangeId);\r\n\r\n const selectClauseItems: string[] = [];\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n // access string tokens need to be escaped as they might collide with reserved words in ECSQL or SQLite\r\n const accessString: string = stmt.getValue(0).getString();\r\n const accessStringTokens: string[] = accessString.split(\".\");\r\n assert(accessStringTokens.length > 0);\r\n\r\n let isFirstToken: boolean = true;\r\n let item: string = \"\";\r\n for (const token of accessStringTokens) {\r\n if (!isFirstToken)\r\n item += \".\";\r\n\r\n item += `[${token}]`;\r\n isFirstToken = false;\r\n }\r\n selectClauseItems.push(item);\r\n }\r\n\r\n return selectClauseItems;\r\n });\r\n }\r\n\r\n /** Builds the ECSQL to query the property value changes for the specified instance change and the specified ChangedValueState.\r\n *\r\n * See also [Change Summary Overview]($docs/learning/ChangeSummaries)\r\n * @param iModel iModel\r\n * @param instanceChangeInfo InstanceChange to query the property value changes for\r\n * 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]`\r\n * @param changedValueState The Changed State to query the values for. This must correspond to the [InstanceChange.OpCode]($backend) of the InstanceChange.\r\n * @param changedPropertyNames List of the property names for which values have changed for the specified instance change.\r\n * The list can be obtained by calling [ChangeSummaryManager.getChangedPropertyValueNames]($core-backend).\r\n * If omitted, the method will call the above method by itself. The parameter allows for checking first whether\r\n * an instance change has any property value changes at all. If there are no property value changes, this method\r\n * should not be called, as it will throw an error.\r\n * @returns Returns the ECSQL that will retrieve the property value changes\r\n * @throws [IModelError]($common) if instance change does not exist, if there are not property value changes for the instance change,\r\n * if the change cache file hasn't been attached, or in case of other errors.\r\n */\r\n public static buildPropertyValueChangesECSql(iModel: IModelDb, instanceChangeInfo: { id: Id64String, summaryId: Id64String, changedInstance: { id: Id64String, className: string } }, changedValueState: ChangedValueState, changedPropertyNames?: string[]): string {\r\n let selectClauseItems: string[];\r\n if (!changedPropertyNames) {\r\n // query property value changes just to build a SELECT statement against the class of the changed instance\r\n selectClauseItems = ChangeSummaryManager.getChangedPropertyValueNames(iModel, instanceChangeInfo.id);\r\n } else\r\n selectClauseItems = changedPropertyNames;\r\n\r\n if (selectClauseItems.length === 0)\r\n throw new IModelError(IModelStatus.BadArg, `No property value changes found for InstanceChange ${instanceChangeInfo.id}.`);\r\n\r\n let ecsql: string = \"SELECT \";\r\n selectClauseItems.map((item: string, index: number) => {\r\n if (index !== 0)\r\n ecsql += \",\";\r\n\r\n ecsql += item;\r\n });\r\n\r\n // Avoiding parameters in the Changes function speeds up performance because ECDb can do optimizations\r\n // if it knows the function args at prepare time\r\n ecsql += ` FROM main.${instanceChangeInfo.changedInstance.className}.Changes(${instanceChangeInfo.summaryId},${changedValueState}) WHERE ECInstanceId=${instanceChangeInfo.changedInstance.id}`;\r\n return ecsql;\r\n }\r\n\r\n /**\r\n * Creates a change summary for the last applied change set to the iModel\r\n * @param accessToken A valid access token string\r\n * @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.\r\n * @returns The id of the extracted change summary.\r\n * @beta\r\n */\r\n public static async createChangeSummary(accessToken: AccessToken, iModel: BriefcaseDb): Promise<Id64String> {\r\n if (!iModel?.isOpen)\r\n throw new IModelError(IModelStatus.BadRequest, \"Briefcase must be open\");\r\n const changesetId = iModel.changeset.id;\r\n if (!changesetId)\r\n throw new IModelError(IModelStatus.BadRequest, \"No change set was applied to the iModel\");\r\n if (this.isChangeCacheAttached(iModel))\r\n throw new IModelError(IModelStatus.BadRequest, \"Change cache must be detached before extraction\");\r\n\r\n const iModelId = iModel.iModelId;\r\n const changesetsFolder: string = BriefcaseManager.getChangeSetsPath(iModelId);\r\n const changeset = await IModelHost.hubAccess.downloadChangeset({ accessToken, iModelId, changeset: { id: iModel.changeset.id }, targetDir: changesetsFolder });\r\n\r\n if (!IModelJsFs.existsSync(changeset.pathname))\r\n throw new IModelError(IModelStatus.FileNotFound, `Failed to download change set: ${changeset.pathname}`);\r\n\r\n let changesFile: ECDb | undefined;\r\n try {\r\n changesFile = ChangeSummaryManager.openOrCreateChangesFile(iModel);\r\n assert(changesFile.nativeDb !== undefined, \"Invalid changesFile - should've caused an exception\");\r\n\r\n let changeSummaryId = ChangeSummaryManager.isSummaryAlreadyExtracted(changesFile, changesetId);\r\n if (changeSummaryId !== undefined) {\r\n Logger.logInfo(loggerCategory, `Change Summary for changeset already exists. It is not extracted again.`, () => ({ iModelId, changeSetId: changesetId }));\r\n return changeSummaryId;\r\n }\r\n\r\n const stat = iModel.nativeDb.extractChangeSummary(changesFile.nativeDb, changeset.pathname);\r\n if (stat.error && stat.error.status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat.error.status, stat.error.message);\r\n\r\n assert(undefined !== stat.result);\r\n changeSummaryId = stat.result;\r\n ChangeSummaryManager.addExtendedInfos(changesFile, changeSummaryId, changesetId, changeset.parentId, changeset.description, changeset.pushDate, changeset.userCreated);\r\n\r\n changesFile.saveChanges();\r\n return changeSummaryId;\r\n } finally {\r\n if (changesFile !== undefined)\r\n changesFile.dispose();\r\n IModelJsFs.unlinkSync(changeset.pathname);\r\n }\r\n }\r\n\r\n /**\r\n * Creates change summaries for the specified iModel and a specified range of versions\r\n * @note This may be an expensive operation - downloads the first version and starts applying the change sets, extracting summaries one by one\r\n * @param args Arguments including the range of versions for which Change Summaries are to be created, and other necessary input for creation\r\n */\r\n public static async createChangeSummaries(args: CreateChangeSummaryArgs): Promise<Id64String[]> {\r\n const accessToken = args.accessToken ?? await IModelHost.getAccessToken() ?? \"\";\r\n const { iModelId, iTwinId, range } = args;\r\n range.end = range.end ?? (await IModelHost.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version: IModelVersion.latest() })).index;\r\n if (range.first > range.end)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid range of changesets\");\r\n if (range.first === 0 && range.end === 0)\r\n return []; // no changesets exist, so the inclusive range is empty\r\n\r\n const changesets = await IModelHost.hubAccess.queryChangesets({ accessToken, iModelId, range });\r\n\r\n // Setup a temporary briefcase to help with extracting change summaries\r\n const briefcasePath = BriefcaseManager.getBriefcaseBasePath(iModelId);\r\n const fileName: string = path.join(briefcasePath, `ChangeSummaryBriefcase.bim`);\r\n if (IModelJsFs.existsSync(fileName))\r\n IModelJsFs.removeSync(fileName);\r\n\r\n let iModel: BriefcaseDb | undefined;\r\n try {\r\n // Download a version that has the first change set applied\r\n const props = await BriefcaseManager.downloadBriefcase({ accessToken, iTwinId, iModelId, asOf: { afterChangeSetId: changesets[0].id }, briefcaseId: 0, fileName });\r\n iModel = await BriefcaseDb.open({ fileName: props.fileName });\r\n\r\n const summaryIds = new Array<Id64String>();\r\n for (let index = 0; index < changesets.length; index++) {\r\n // Apply a change set if necessary\r\n if (index > 0)\r\n await iModel.pullChanges({ accessToken, toIndex: changesets[index].index });\r\n\r\n // Create a change summary for the last change set that was applied\r\n const summaryId = await this.createChangeSummary(accessToken, iModel);\r\n summaryIds.push(summaryId);\r\n }\r\n return summaryIds;\r\n } finally {\r\n if (iModel !== undefined)\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n }\r\n }\r\n}\r\n"]}
@@ -69,7 +69,7 @@ class V2CheckpointManager {
69
69
  }
70
70
  return cloudCachePath;
71
71
  }
72
- /* only used by tests that reset the state of the v2checkpointmanager. all dbs should be closed before calling this function. */
72
+ /* only used by tests that reset the state of the v2CheckpointManager. all dbs should be closed before calling this function. */
73
73
  static cleanup() {
74
74
  for (const [_, value] of this.containers.entries()) {
75
75
  if (value.isConnected)
@@ -106,7 +106,7 @@ class V2CheckpointManager {
106
106
  }
107
107
  /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */
108
108
  static toCloudContainerProps(from) {
109
- return { ...from, accessName: from.accountName, accessToken: from.sasToken };
109
+ return { ...from, baseUri: `https://${from.accountName}.blob.core.windows.net`, accessToken: from.sasToken, storageType: "azure" };
110
110
  }
111
111
  static getContainer(v2Props) {
112
112
  let container = this.containers.get(v2Props.containerId);