@itwin/core-backend 5.7.0-dev.8 → 5.8.0-dev.1
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.
- package/CHANGELOG.md +8 -1
- package/lib/cjs/BriefcaseManager.d.ts +138 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +336 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CloudSqlite.js +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +71 -0
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +122 -6
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +15 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +12 -0
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts +2 -0
- package/lib/cjs/IModelJsFs.d.ts.map +1 -1
- package/lib/cjs/IModelJsFs.js +2 -0
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/TileStorage.js +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +41 -3
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +151 -3
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +2 -0
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/internal/IModelDbFontsImpl.js +1 -1
- package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.d.ts +240 -0
- package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -0
- package/lib/cjs/internal/IntegrityCheck.js +193 -0
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -0
- package/lib/cjs/internal/annotations/fields.js +2 -2
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/cjs/rpc/tracing.js +2 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +138 -1
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +336 -1
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/CloudSqlite.js +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +71 -0
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +122 -6
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelHost.d.ts +15 -0
- package/lib/esm/IModelHost.d.ts.map +1 -1
- package/lib/esm/IModelHost.js +12 -0
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/IModelJsFs.d.ts +2 -0
- package/lib/esm/IModelJsFs.d.ts.map +1 -1
- package/lib/esm/IModelJsFs.js +2 -0
- package/lib/esm/IModelJsFs.js.map +1 -1
- package/lib/esm/TileStorage.js +1 -1
- package/lib/esm/TileStorage.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +41 -3
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +152 -4
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +2 -0
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/internal/IModelDbFontsImpl.js +1 -1
- package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/esm/internal/IntegrityCheck.d.ts +240 -0
- package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -0
- package/lib/esm/internal/IntegrityCheck.js +187 -0
- package/lib/esm/internal/IntegrityCheck.js.map +1 -0
- package/lib/esm/internal/annotations/fields.js +2 -2
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/rpc/tracing.js +2 -2
- package/lib/esm/rpc/tracing.js.map +1 -1
- package/lib/esm/test/SquashSchemaAndDataChanges.test.d.ts +2 -0
- package/lib/esm/test/SquashSchemaAndDataChanges.test.d.ts.map +1 -0
- package/lib/esm/test/SquashSchemaAndDataChanges.test.js +241 -0
- package/lib/esm/test/SquashSchemaAndDataChanges.test.js.map +1 -0
- package/lib/esm/test/hubaccess/Rebase.test.js +1575 -1568
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebase.test.d.ts +2 -0
- package/lib/esm/test/hubaccess/SemanticRebase.test.d.ts.map +1 -0
- package/lib/esm/test/hubaccess/SemanticRebase.test.js +1206 -0
- package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -0
- package/lib/esm/test/imodel/IModel.test.js +1 -1
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +173 -2
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.d.ts +2 -0
- package/lib/esm/test/standalone/IntegrityCheck.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/IntegrityCheck.test.js +385 -0
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -0
- package/lib/esm/test/standalone/ViewDefinition.test.js +14 -2
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js +5 -0
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/lib/esm/workspace/Workspace.js +1 -1
- package/lib/esm/workspace/Workspace.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 13 Feb 2026 17:13:15 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.6.1
|
|
6
|
+
Fri, 13 Feb 2026 17:11:47 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Add iModelDb.integrityCheck function that checks imodel database for corruption and reports results
|
|
4
11
|
|
|
5
12
|
## 5.6.0
|
|
6
13
|
Thu, 05 Feb 2026 16:12:37 GMT
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
|
-
import { AccessToken, BeDuration, GuidString, Optional } from "@itwin/core-bentley";
|
|
4
|
+
import { AccessToken, BeDuration, GuidString, Id64String, Optional } from "@itwin/core-bentley";
|
|
5
5
|
import { BriefcaseId, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, LocalBriefcaseProps, LocalDirName, LocalFileName, RequestNewBriefcaseProps } from "@itwin/core-common";
|
|
6
6
|
import { AcquireNewBriefcaseIdArg, DownloadChangesetArg, DownloadChangesetRangeArg, IModelNameArg } from "./BackendHubAccess";
|
|
7
7
|
import { ProgressFunction } from "./CheckpointManager";
|
|
8
8
|
import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb";
|
|
9
9
|
import { StashProps } from "./StashManager";
|
|
10
|
+
import { ECSqlRow } from "./Entity";
|
|
11
|
+
/**
|
|
12
|
+
* The argument for identifying an Patch Instance Key
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
interface PatchInstanceKey {
|
|
16
|
+
id: Id64String;
|
|
17
|
+
classFullName: string;
|
|
18
|
+
}
|
|
19
|
+
/** The argument for patch instances during high level rebase application
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export interface InstancePatch {
|
|
23
|
+
key: PatchInstanceKey;
|
|
24
|
+
op: "Inserted" | "Updated" | "Deleted";
|
|
25
|
+
isIndirect: boolean;
|
|
26
|
+
props?: ECSqlRow;
|
|
27
|
+
}
|
|
10
28
|
/** The argument for [[BriefcaseManager.downloadBriefcase]]
|
|
11
29
|
* @public
|
|
12
30
|
*/
|
|
@@ -271,5 +289,124 @@ export declare class BriefcaseManager {
|
|
|
271
289
|
* @internal
|
|
272
290
|
*/
|
|
273
291
|
static pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void>;
|
|
292
|
+
private static readonly REBASING_FOLDER;
|
|
293
|
+
private static readonly EC_FOLDER;
|
|
294
|
+
private static readonly SCHEMAS_FOLDER;
|
|
295
|
+
private static readonly DATA_FOLDER;
|
|
296
|
+
private static readonly DATA_FILE_NAME;
|
|
297
|
+
/**
|
|
298
|
+
* Captures the changed instances as patch instances from each data txn in the briefcase db for semantic rebase
|
|
299
|
+
* @param db The {@link BriefcaseDb} instance for which to capture the changed instances as patch instances for all data txns
|
|
300
|
+
* @internal
|
|
301
|
+
*/
|
|
302
|
+
private static capturePatchInstances;
|
|
303
|
+
/**
|
|
304
|
+
* Captures changed instances from a txn as JSON
|
|
305
|
+
* @param txnId The txn id for which to capture changed instances
|
|
306
|
+
* @param db The {@link BriefcaseDb} instance from which to capture changed instances as json
|
|
307
|
+
* @returns changed instances for semantic rebase
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
private static captureChangedInstancesAsJSON;
|
|
311
|
+
/**
|
|
312
|
+
* Constructs patch instances from changed instances
|
|
313
|
+
* @param changedInstances The changed instances from which to construct the patch instances
|
|
314
|
+
* @param db The {@link BriefcaseDb} instance for which to construct the patch instances
|
|
315
|
+
* @returns The {@link InstancePatch} instance patches for semantic rebase
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
private static constructPatchInstances;
|
|
319
|
+
/**
|
|
320
|
+
* Constructs a single patch instance from changed instance
|
|
321
|
+
* @param changedInstance The changed instance from which to construct the patch instance
|
|
322
|
+
* @param db The {@link BriefcaseDb} instance for which to construct the single patch instance
|
|
323
|
+
* @returns a single instance patch {@link InstancePatch}
|
|
324
|
+
* @throws IModelError If cannot determine classId or unknown operation encountered
|
|
325
|
+
*/
|
|
326
|
+
private static constructPatchInstance;
|
|
327
|
+
/**
|
|
328
|
+
* Stores changed instances for semantic rebase locally in appropriate json file in a folder structure
|
|
329
|
+
* @param db The {@link BriefcaseDb} instance for storing the changed instances against a txn
|
|
330
|
+
* @param txnId The txn id for which we are storing the changed instances
|
|
331
|
+
* @param instancePatches The {@link InstancePatch} instance patches to be stored
|
|
332
|
+
* @internal
|
|
333
|
+
*/
|
|
334
|
+
private static storeChangedInstancesForSemanticRebase;
|
|
335
|
+
/**
|
|
336
|
+
* Gets the base path for semantic rebase local files
|
|
337
|
+
* @param db The {@link BriefcaseDb} instance for which to get the base path
|
|
338
|
+
* @returns base path for semantic rebase local files
|
|
339
|
+
* @internal
|
|
340
|
+
*/
|
|
341
|
+
static getBasePathForSemanticRebaseLocalFiles(db: BriefcaseDb): string;
|
|
342
|
+
/**
|
|
343
|
+
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
344
|
+
* @param db The {@link BriefcaseDb} instance for storing the schemas against a txn
|
|
345
|
+
* @param txnId The txn id for which we are storing the schemas
|
|
346
|
+
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
347
|
+
* @internal
|
|
348
|
+
*/
|
|
349
|
+
static storeSchemasForSemanticRebase<T extends LocalFileName[] | string[]>(db: BriefcaseDb, txnId: string, schemaFileNames: T): void;
|
|
350
|
+
/**
|
|
351
|
+
* Gets schemas for semantic rebase for a txn
|
|
352
|
+
* @param db The {@link BriefcaseDb} instance for getting the locally stored schemas against a txn
|
|
353
|
+
* @param txnId The txn id for which we are getting the schemas
|
|
354
|
+
* @returns the schema file paths
|
|
355
|
+
* @internal
|
|
356
|
+
*/
|
|
357
|
+
static getSchemasForTxn(db: BriefcaseDb, txnId: string): string[];
|
|
358
|
+
/**
|
|
359
|
+
* Get the changed instances data for semantic rebase for a txn
|
|
360
|
+
* @param db - The {@link BriefcaseDb} instance for getting the locally stored changed instances against a txn
|
|
361
|
+
* @param txnId - The txn id for which we are getting the changed instances
|
|
362
|
+
* @returns Instance patches
|
|
363
|
+
* @internal
|
|
364
|
+
*/
|
|
365
|
+
static getChangedInstancesDataForTxn(db: BriefcaseDb, txnId: string): InstancePatch[];
|
|
366
|
+
/**
|
|
367
|
+
* Checks if schema folder exists for semantic rebase for a txn
|
|
368
|
+
* @param db - The {@link BriefcaseDb} instance for which TO check the schema folder
|
|
369
|
+
* @param txnId - The txn id for which we are check the schema folder
|
|
370
|
+
* @returns true if exists, false otherwise
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
static semanticRebaseSchemaFolderExists(db: BriefcaseDb, txnId: string): boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Checks if data folder exists for semantic rebase for a txn
|
|
376
|
+
* @param db The {@link BriefcaseDb} instance for which to check the data folder.
|
|
377
|
+
* @param txnId The txn id for which to check the data folder
|
|
378
|
+
* @returns true if exists, false otherwise
|
|
379
|
+
* @internal
|
|
380
|
+
*/
|
|
381
|
+
static semanticRebaseDataFolderExists(db: BriefcaseDb, txnId: string): boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Deletes the schema folder for semantic rebase for a txn
|
|
384
|
+
* @param db The {@link BriefcaseDb} instance for which to delete the schema folder.
|
|
385
|
+
* @param txnId The txn id for which to delete the schema folder
|
|
386
|
+
* @internal
|
|
387
|
+
*/
|
|
388
|
+
static deleteTxnSchemaFolder(db: BriefcaseDb, txnId: string): void;
|
|
389
|
+
/**
|
|
390
|
+
* Deletes the data folder for semantic rebase for a txn
|
|
391
|
+
* @param db The {@link BriefcaseDb} instance for which to delete the data folder.
|
|
392
|
+
* @param txnId The txn id for which to delete the data folder
|
|
393
|
+
* @internal
|
|
394
|
+
*/
|
|
395
|
+
static deleteTxnDataFolder(db: BriefcaseDb, txnId: string): void;
|
|
396
|
+
/**
|
|
397
|
+
* Deletes rebase folders for semantic rebase
|
|
398
|
+
* @param db The {@link BriefcaseDb} instance for which to delete the rebase folders.
|
|
399
|
+
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
static deleteRebaseFolders(db: BriefcaseDb, checkIfEmpty?: boolean): void;
|
|
403
|
+
/**
|
|
404
|
+
* Cleans up rebase folders for semantic rebase given briefcase file path and briefcase id
|
|
405
|
+
* @param briefcaseFilePath The briefcase file path
|
|
406
|
+
* @param briefcaseId The briefcase id
|
|
407
|
+
* @internal
|
|
408
|
+
*/
|
|
409
|
+
private static cleanupRebaseFolders;
|
|
274
410
|
}
|
|
411
|
+
export {};
|
|
275
412
|
//# sourceMappingURL=BriefcaseManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BriefcaseManager.d.ts","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EACL,WAAW,EAAE,UAAU,EAA6B,UAAU,EAAmD,QAAQ,
|
|
1
|
+
{"version":3,"file":"BriefcaseManager.d.ts","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EACL,WAAW,EAAE,UAAU,EAA6B,UAAU,EAAE,UAAU,EAAmD,QAAQ,EACtI,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAAoB,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAA6C,mBAAmB,EACrM,YAAY,EAAE,aAAa,EAAE,wBAAwB,EAEtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE9H,OAAO,EAAsC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,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AC,oBAAoB;CAapC"}
|
|
@@ -6,6 +6,58 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module iModels
|
|
8
8
|
*/
|
|
9
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
10
|
+
if (value !== null && value !== void 0) {
|
|
11
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
12
|
+
var dispose, inner;
|
|
13
|
+
if (async) {
|
|
14
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
15
|
+
dispose = value[Symbol.asyncDispose];
|
|
16
|
+
}
|
|
17
|
+
if (dispose === void 0) {
|
|
18
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
19
|
+
dispose = value[Symbol.dispose];
|
|
20
|
+
if (async) inner = dispose;
|
|
21
|
+
}
|
|
22
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
23
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
24
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
25
|
+
}
|
|
26
|
+
else if (async) {
|
|
27
|
+
env.stack.push({ async: true });
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
32
|
+
return function (env) {
|
|
33
|
+
function fail(e) {
|
|
34
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
35
|
+
env.hasError = true;
|
|
36
|
+
}
|
|
37
|
+
var r, s = 0;
|
|
38
|
+
function next() {
|
|
39
|
+
while (r = env.stack.pop()) {
|
|
40
|
+
try {
|
|
41
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
42
|
+
if (r.dispose) {
|
|
43
|
+
var result = r.dispose.call(r.value);
|
|
44
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
45
|
+
}
|
|
46
|
+
else s |= 1;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
fail(e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
53
|
+
if (env.hasError) throw env.error;
|
|
54
|
+
}
|
|
55
|
+
return next();
|
|
56
|
+
};
|
|
57
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
58
|
+
var e = new Error(message);
|
|
59
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
60
|
+
});
|
|
9
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
62
|
exports.BriefcaseManager = void 0;
|
|
11
63
|
// cspell:ignore cset csets ecchanges
|
|
@@ -22,6 +74,8 @@ const SchemaSync_1 = require("./SchemaSync");
|
|
|
22
74
|
const Symbols_1 = require("./internal/Symbols");
|
|
23
75
|
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
24
76
|
const StashManager_1 = require("./StashManager");
|
|
77
|
+
const ChangesetECAdaptor_1 = require("./ChangesetECAdaptor");
|
|
78
|
+
const SqliteChangesetReader_1 = require("./SqliteChangesetReader");
|
|
25
79
|
const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
|
|
26
80
|
/** Manages downloading Briefcases and downloading and uploading changesets.
|
|
27
81
|
* @public
|
|
@@ -232,6 +286,8 @@ class BriefcaseManager {
|
|
|
232
286
|
briefcaseId: db.getBriefcaseId(),
|
|
233
287
|
};
|
|
234
288
|
db.closeFile();
|
|
289
|
+
if (this.isValidBriefcaseId(briefcase.briefcaseId))
|
|
290
|
+
this.cleanupRebaseFolders(filePath, briefcase.briefcaseId); // cleanup rebase folders
|
|
235
291
|
if (accessToken) {
|
|
236
292
|
if (this.isValidBriefcaseId(briefcase.briefcaseId)) {
|
|
237
293
|
await BriefcaseManager.releaseBriefcase(accessToken, briefcase);
|
|
@@ -465,10 +521,24 @@ class BriefcaseManager {
|
|
|
465
521
|
core_bentley_1.Logger.logInfo(loggerCategory, `Creating restore point ${this.PULL_MERGE_RESTORE_POINT_NAME}`);
|
|
466
522
|
await this.createRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME);
|
|
467
523
|
}
|
|
524
|
+
const hasIncomingSchemaChange = changesets.some((changeset) => changeset.changesType === core_common_1.ChangesetType.Schema);
|
|
525
|
+
const hasLocalSchemaTxn = briefcaseDb?.checkIfSchemaTxnExists() ?? false;
|
|
526
|
+
const useSemanticRebase = briefcaseDb !== undefined &&
|
|
527
|
+
IModelHost_1.IModelHost.useSemanticRebase &&
|
|
528
|
+
(hasIncomingSchemaChange || hasLocalSchemaTxn);
|
|
529
|
+
if (useSemanticRebase) {
|
|
530
|
+
core_bentley_1.Logger.logInfo(loggerCategory, `Using semantic rebase (incoming schema change: ${hasIncomingSchemaChange}, local schema txn: ${hasLocalSchemaTxn})`);
|
|
531
|
+
}
|
|
468
532
|
if (!reverse) {
|
|
469
533
|
if (briefcaseDb) {
|
|
534
|
+
if (useSemanticRebase) {
|
|
535
|
+
this.capturePatchInstances(briefcaseDb);
|
|
536
|
+
}
|
|
470
537
|
briefcaseDb.txns.rebaser.notifyReverseLocalChangesBegin();
|
|
471
538
|
const reversedTxns = nativeDb.pullMergeReverseLocalChanges();
|
|
539
|
+
if (useSemanticRebase) {
|
|
540
|
+
nativeDb.clearECDbCache(); // Clear the ECDb cache after reversing local changes to ensure consistency during semantic rebase with schema changes.
|
|
541
|
+
}
|
|
472
542
|
const reversedTxnProps = reversedTxns.map((txn) => briefcaseDb.txns.getTxnProps(txn)).filter((props) => props !== undefined);
|
|
473
543
|
briefcaseDb.txns.rebaser.notifyReverseLocalChangesEnd(reversedTxnProps);
|
|
474
544
|
core_bentley_1.Logger.logInfo(loggerCategory, `Reversed ${reversedTxns.length} local changes`);
|
|
@@ -501,7 +571,10 @@ class BriefcaseManager {
|
|
|
501
571
|
}
|
|
502
572
|
if (!reverse) {
|
|
503
573
|
if (briefcaseDb) {
|
|
504
|
-
|
|
574
|
+
if (useSemanticRebase)
|
|
575
|
+
await briefcaseDb.txns.rebaser.resumeSemantic();
|
|
576
|
+
else
|
|
577
|
+
await briefcaseDb.txns.rebaser.resume();
|
|
505
578
|
}
|
|
506
579
|
else {
|
|
507
580
|
// Only Briefcase has change management. Following is
|
|
@@ -681,6 +754,268 @@ class BriefcaseManager {
|
|
|
681
754
|
}
|
|
682
755
|
}
|
|
683
756
|
}
|
|
757
|
+
// #region Semantic Rebase Interop Helper
|
|
758
|
+
static REBASING_FOLDER = ".rebasing";
|
|
759
|
+
static EC_FOLDER = "ec";
|
|
760
|
+
static SCHEMAS_FOLDER = "schemas";
|
|
761
|
+
static DATA_FOLDER = "data";
|
|
762
|
+
static DATA_FILE_NAME = "data.json";
|
|
763
|
+
/**
|
|
764
|
+
* Captures the changed instances as patch instances from each data txn in the briefcase db for semantic rebase
|
|
765
|
+
* @param db The {@link BriefcaseDb} instance for which to capture the changed instances as patch instances for all data txns
|
|
766
|
+
* @internal
|
|
767
|
+
*/
|
|
768
|
+
static capturePatchInstances(db) {
|
|
769
|
+
const txns = Array.from(db.txns.queryTxns());
|
|
770
|
+
txns.forEach((txn) => {
|
|
771
|
+
if (txn.type !== "Data")
|
|
772
|
+
return;
|
|
773
|
+
// already captured(This actually shows that first rebase operation is already done but during that while reinstating this txns,
|
|
774
|
+
// some error happened so the folder still exists so we don't want to capture again)
|
|
775
|
+
if (this.semanticRebaseDataFolderExists(db, txn.id))
|
|
776
|
+
return;
|
|
777
|
+
const changedInstances = this.captureChangedInstancesAsJSON(db, txn.id);
|
|
778
|
+
const instancePatches = this.constructPatchInstances(db, changedInstances);
|
|
779
|
+
this.storeChangedInstancesForSemanticRebase(db, txn.id, instancePatches);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Captures changed instances from a txn as JSON
|
|
784
|
+
* @param txnId The txn id for which to capture changed instances
|
|
785
|
+
* @param db The {@link BriefcaseDb} instance from which to capture changed instances as json
|
|
786
|
+
* @returns changed instances for semantic rebase
|
|
787
|
+
* @internal
|
|
788
|
+
*/
|
|
789
|
+
static captureChangedInstancesAsJSON(db, txnId) {
|
|
790
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
791
|
+
try {
|
|
792
|
+
const reader = SqliteChangesetReader_1.SqliteChangesetReader.openTxn({
|
|
793
|
+
txnId, db, disableSchemaCheck: true
|
|
794
|
+
});
|
|
795
|
+
const adaptor = new ChangesetECAdaptor_1.ChangesetECAdaptor(reader);
|
|
796
|
+
const indirectUnifier = __addDisposableResource(env_1, new ChangesetECAdaptor_1.PartialECChangeUnifier(reader.db, ChangesetECAdaptor_1.ECChangeUnifierCache.createInMemoryCache()), false);
|
|
797
|
+
const directUnifier = __addDisposableResource(env_1, new ChangesetECAdaptor_1.PartialECChangeUnifier(reader.db, ChangesetECAdaptor_1.ECChangeUnifierCache.createInMemoryCache()), false);
|
|
798
|
+
while (adaptor.step()) {
|
|
799
|
+
if (adaptor.reader.isIndirect)
|
|
800
|
+
indirectUnifier.appendFrom(adaptor);
|
|
801
|
+
else
|
|
802
|
+
directUnifier.appendFrom(adaptor);
|
|
803
|
+
}
|
|
804
|
+
return [...Array.from(directUnifier.instances).map((instance) => ({ isIndirect: false, instance })), ...Array.from(indirectUnifier.instances).map((instance) => ({ isIndirect: true, instance }))];
|
|
805
|
+
}
|
|
806
|
+
catch (e_1) {
|
|
807
|
+
env_1.error = e_1;
|
|
808
|
+
env_1.hasError = true;
|
|
809
|
+
}
|
|
810
|
+
finally {
|
|
811
|
+
__disposeResources(env_1);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Constructs patch instances from changed instances
|
|
816
|
+
* @param changedInstances The changed instances from which to construct the patch instances
|
|
817
|
+
* @param db The {@link BriefcaseDb} instance for which to construct the patch instances
|
|
818
|
+
* @returns The {@link InstancePatch} instance patches for semantic rebase
|
|
819
|
+
* @internal
|
|
820
|
+
*/
|
|
821
|
+
static constructPatchInstances(db, changedInstances) {
|
|
822
|
+
return changedInstances
|
|
823
|
+
.filter((changedInstance) => !(changedInstance.instance.$meta?.op === "Updated" && changedInstance.instance.$meta.stage === "Old")) // we will not take the old stage of updated instances
|
|
824
|
+
.map((changedInstance) => this.constructPatchInstance(db, changedInstance));
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Constructs a single patch instance from changed instance
|
|
828
|
+
* @param changedInstance The changed instance from which to construct the patch instance
|
|
829
|
+
* @param db The {@link BriefcaseDb} instance for which to construct the single patch instance
|
|
830
|
+
* @returns a single instance patch {@link InstancePatch}
|
|
831
|
+
* @throws IModelError If cannot determine classId or unknown operation encountered
|
|
832
|
+
*/
|
|
833
|
+
static constructPatchInstance(db, changedInstance) {
|
|
834
|
+
const className = (changedInstance.instance.ECClassId && db.getClassNameFromId(changedInstance.instance.ECClassId))
|
|
835
|
+
?? changedInstance.instance.$meta?.classFullName
|
|
836
|
+
?? (changedInstance.instance.$meta?.fallbackClassId && db.getClassNameFromId(changedInstance.instance.$meta.fallbackClassId));
|
|
837
|
+
if (!className)
|
|
838
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Cannot determine classId of changed instance");
|
|
839
|
+
const instanceKey = { id: changedInstance.instance.ECInstanceId, classFullName: className };
|
|
840
|
+
const op = changedInstance.instance.$meta?.op;
|
|
841
|
+
if (op !== "Inserted" && op !== "Updated" && op !== "Deleted")
|
|
842
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, `Unknown operation: ${op}`);
|
|
843
|
+
return {
|
|
844
|
+
key: instanceKey,
|
|
845
|
+
op,
|
|
846
|
+
isIndirect: changedInstance.isIndirect,
|
|
847
|
+
props: op !== "Deleted" ? db[Symbols_1._nativeDb].readInstance(instanceKey, { useJsNames: true }) : undefined,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Stores changed instances for semantic rebase locally in appropriate json file in a folder structure
|
|
852
|
+
* @param db The {@link BriefcaseDb} instance for storing the changed instances against a txn
|
|
853
|
+
* @param txnId The txn id for which we are storing the changed instances
|
|
854
|
+
* @param instancePatches The {@link InstancePatch} instance patches to be stored
|
|
855
|
+
* @internal
|
|
856
|
+
*/
|
|
857
|
+
static storeChangedInstancesForSemanticRebase(db, txnId, instancePatches) {
|
|
858
|
+
const basePath = this.getBasePathForSemanticRebaseLocalFiles(db);
|
|
859
|
+
const targetDir = path.join(basePath, txnId, this.DATA_FOLDER);
|
|
860
|
+
const filePath = path.join(targetDir, this.DATA_FILE_NAME);
|
|
861
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(targetDir))
|
|
862
|
+
IModelJsFs_1.IModelJsFs.removeSync(targetDir);
|
|
863
|
+
IModelJsFs_1.IModelJsFs.recursiveMkDirSync(targetDir);
|
|
864
|
+
IModelJsFs_1.IModelJsFs.writeFileSync(filePath, JSON.stringify(instancePatches, undefined, 2));
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Gets the base path for semantic rebase local files
|
|
868
|
+
* @param db The {@link BriefcaseDb} instance for which to get the base path
|
|
869
|
+
* @returns base path for semantic rebase local files
|
|
870
|
+
* @internal
|
|
871
|
+
*/
|
|
872
|
+
static getBasePathForSemanticRebaseLocalFiles(db) {
|
|
873
|
+
return path.join(path.dirname(db.pathName), this.REBASING_FOLDER, db.briefcaseId.toString(), this.EC_FOLDER);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
877
|
+
* @param db The {@link BriefcaseDb} instance for storing the schemas against a txn
|
|
878
|
+
* @param txnId The txn id for which we are storing the schemas
|
|
879
|
+
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
880
|
+
* @internal
|
|
881
|
+
*/
|
|
882
|
+
static storeSchemasForSemanticRebase(db, txnId, schemaFileNames) {
|
|
883
|
+
const basePath = this.getBasePathForSemanticRebaseLocalFiles(db);
|
|
884
|
+
const targetDir = path.join(basePath, txnId, this.SCHEMAS_FOLDER);
|
|
885
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(targetDir))
|
|
886
|
+
IModelJsFs_1.IModelJsFs.removeSync(targetDir);
|
|
887
|
+
IModelJsFs_1.IModelJsFs.recursiveMkDirSync(targetDir);
|
|
888
|
+
schemaFileNames.forEach((schemaFileOrXml, index) => {
|
|
889
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(schemaFileOrXml)) { // This means it is a file
|
|
890
|
+
const fileName = path.basename(schemaFileOrXml);
|
|
891
|
+
const filePath = path.join(targetDir, fileName);
|
|
892
|
+
IModelJsFs_1.IModelJsFs.copySync(schemaFileOrXml, filePath);
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
const fileName = `${"Schema"}_${index}.ecschema.xml`;
|
|
896
|
+
const filePath = path.join(targetDir, fileName);
|
|
897
|
+
IModelJsFs_1.IModelJsFs.writeFileSync(filePath, schemaFileOrXml);
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Gets schemas for semantic rebase for a txn
|
|
903
|
+
* @param db The {@link BriefcaseDb} instance for getting the locally stored schemas against a txn
|
|
904
|
+
* @param txnId The txn id for which we are getting the schemas
|
|
905
|
+
* @returns the schema file paths
|
|
906
|
+
* @internal
|
|
907
|
+
*/
|
|
908
|
+
static getSchemasForTxn(db, txnId) {
|
|
909
|
+
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
910
|
+
const folderPath = path.join(basePath, txnId, BriefcaseManager.SCHEMAS_FOLDER);
|
|
911
|
+
return IModelJsFs_1.IModelJsFs.readdirSync(folderPath).map((file) => path.join(folderPath, file));
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Get the changed instances data for semantic rebase for a txn
|
|
915
|
+
* @param db - The {@link BriefcaseDb} instance for getting the locally stored changed instances against a txn
|
|
916
|
+
* @param txnId - The txn id for which we are getting the changed instances
|
|
917
|
+
* @returns Instance patches
|
|
918
|
+
* @internal
|
|
919
|
+
*/
|
|
920
|
+
static getChangedInstancesDataForTxn(db, txnId) {
|
|
921
|
+
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
922
|
+
const folderPath = path.join(basePath, txnId, BriefcaseManager.DATA_FOLDER);
|
|
923
|
+
const filePath = path.join(folderPath, BriefcaseManager.DATA_FILE_NAME);
|
|
924
|
+
const fileContents = IModelJsFs_1.IModelJsFs.readFileWithEncodingSync(filePath, "utf-8");
|
|
925
|
+
return JSON.parse(fileContents);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Checks if schema folder exists for semantic rebase for a txn
|
|
929
|
+
* @param db - The {@link BriefcaseDb} instance for which TO check the schema folder
|
|
930
|
+
* @param txnId - The txn id for which we are check the schema folder
|
|
931
|
+
* @returns true if exists, false otherwise
|
|
932
|
+
* @internal
|
|
933
|
+
*/
|
|
934
|
+
static semanticRebaseSchemaFolderExists(db, txnId) {
|
|
935
|
+
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
936
|
+
const folderPath = path.join(basePath, txnId, BriefcaseManager.SCHEMAS_FOLDER);
|
|
937
|
+
return IModelJsFs_1.IModelJsFs.existsSync(folderPath);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Checks if data folder exists for semantic rebase for a txn
|
|
941
|
+
* @param db The {@link BriefcaseDb} instance for which to check the data folder.
|
|
942
|
+
* @param txnId The txn id for which to check the data folder
|
|
943
|
+
* @returns true if exists, false otherwise
|
|
944
|
+
* @internal
|
|
945
|
+
*/
|
|
946
|
+
static semanticRebaseDataFolderExists(db, txnId) {
|
|
947
|
+
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
948
|
+
const folderPath = path.join(basePath, txnId, BriefcaseManager.DATA_FOLDER);
|
|
949
|
+
return IModelJsFs_1.IModelJsFs.existsSync(folderPath);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Deletes the schema folder for semantic rebase for a txn
|
|
953
|
+
* @param db The {@link BriefcaseDb} instance for which to delete the schema folder.
|
|
954
|
+
* @param txnId The txn id for which to delete the schema folder
|
|
955
|
+
* @internal
|
|
956
|
+
*/
|
|
957
|
+
static deleteTxnSchemaFolder(db, txnId) {
|
|
958
|
+
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
959
|
+
const txnFolderPath = path.join(basePath, txnId);
|
|
960
|
+
const folderPath = path.join(txnFolderPath, BriefcaseManager.SCHEMAS_FOLDER);
|
|
961
|
+
if (!IModelJsFs_1.IModelJsFs.existsSync(folderPath))
|
|
962
|
+
return;
|
|
963
|
+
IModelJsFs_1.IModelJsFs.removeSync(folderPath);
|
|
964
|
+
if (IModelJsFs_1.IModelJsFs.readdirSync(txnFolderPath).length === 0) // Also delete the txn folder if empty
|
|
965
|
+
IModelJsFs_1.IModelJsFs.removeSync(txnFolderPath);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Deletes the data folder for semantic rebase for a txn
|
|
969
|
+
* @param db The {@link BriefcaseDb} instance for which to delete the data folder.
|
|
970
|
+
* @param txnId The txn id for which to delete the data folder
|
|
971
|
+
* @internal
|
|
972
|
+
*/
|
|
973
|
+
static deleteTxnDataFolder(db, txnId) {
|
|
974
|
+
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
975
|
+
const txnFolderPath = path.join(basePath, txnId);
|
|
976
|
+
const folderPath = path.join(txnFolderPath, BriefcaseManager.DATA_FOLDER);
|
|
977
|
+
if (!IModelJsFs_1.IModelJsFs.existsSync(folderPath))
|
|
978
|
+
return;
|
|
979
|
+
IModelJsFs_1.IModelJsFs.removeSync(folderPath);
|
|
980
|
+
if (IModelJsFs_1.IModelJsFs.readdirSync(txnFolderPath).length === 0) // Also delete the txn folder if empty
|
|
981
|
+
IModelJsFs_1.IModelJsFs.removeSync(txnFolderPath);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Deletes rebase folders for semantic rebase
|
|
985
|
+
* @param db The {@link BriefcaseDb} instance for which to delete the rebase folders.
|
|
986
|
+
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
987
|
+
* @internal
|
|
988
|
+
*/
|
|
989
|
+
static deleteRebaseFolders(db, checkIfEmpty = false) {
|
|
990
|
+
const briefcaseRebasingRoot = path.join(path.dirname(db.pathName), this.REBASING_FOLDER, db.briefcaseId.toString());
|
|
991
|
+
if (!IModelJsFs_1.IModelJsFs.existsSync(briefcaseRebasingRoot))
|
|
992
|
+
return;
|
|
993
|
+
if (checkIfEmpty) {
|
|
994
|
+
const basePath = this.getBasePathForSemanticRebaseLocalFiles(db);
|
|
995
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(basePath) && IModelJsFs_1.IModelJsFs.readdirSync(basePath).length > 0)
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
IModelJsFs_1.IModelJsFs.removeSync(briefcaseRebasingRoot);
|
|
999
|
+
// remove .rebasing root if it's now empty
|
|
1000
|
+
const rebasingRoot = path.join(path.dirname(db.pathName), this.REBASING_FOLDER);
|
|
1001
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(rebasingRoot) && IModelJsFs_1.IModelJsFs.readdirSync(rebasingRoot).length === 0)
|
|
1002
|
+
IModelJsFs_1.IModelJsFs.removeSync(rebasingRoot);
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Cleans up rebase folders for semantic rebase given briefcase file path and briefcase id
|
|
1006
|
+
* @param briefcaseFilePath The briefcase file path
|
|
1007
|
+
* @param briefcaseId The briefcase id
|
|
1008
|
+
* @internal
|
|
1009
|
+
*/
|
|
1010
|
+
static cleanupRebaseFolders(briefcaseFilePath, briefcaseId) {
|
|
1011
|
+
const briefcaseRebasingRoot = path.join(path.dirname(briefcaseFilePath), this.REBASING_FOLDER, briefcaseId.toString());
|
|
1012
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(briefcaseRebasingRoot))
|
|
1013
|
+
IModelJsFs_1.IModelJsFs.removeSync(briefcaseRebasingRoot);
|
|
1014
|
+
// remove .rebasing root if it's now empty
|
|
1015
|
+
const rebasingRoot = path.join(path.dirname(briefcaseFilePath), this.REBASING_FOLDER);
|
|
1016
|
+
if (IModelJsFs_1.IModelJsFs.existsSync(rebasingRoot) && IModelJsFs_1.IModelJsFs.readdirSync(rebasingRoot).length === 0)
|
|
1017
|
+
IModelJsFs_1.IModelJsFs.removeSync(rebasingRoot);
|
|
1018
|
+
}
|
|
684
1019
|
}
|
|
685
1020
|
exports.BriefcaseManager = BriefcaseManager;
|
|
686
1021
|
//# sourceMappingURL=BriefcaseManager.js.map
|