@itwin/core-backend 5.9.0 → 5.9.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 +14 -62
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +29 -162
- package/lib/cjs/BriefcaseManager.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 +14 -0
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +3 -0
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +95 -13
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +14 -62
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +30 -163
- package/lib/esm/BriefcaseManager.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 +14 -0
- package/lib/esm/IModelJsFs.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +3 -0
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +96 -14
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebase.test.js +2242 -68
- package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
|
-
import { AccessToken, BeDuration, GuidString,
|
|
4
|
+
import { AccessToken, BeDuration, GuidString, 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 {
|
|
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
|
+
import { ChangeInstance } from "./ChangesetReaderTypes";
|
|
28
11
|
/** The argument for [[BriefcaseManager.downloadBriefcase]]
|
|
29
12
|
* @public
|
|
30
13
|
*/
|
|
@@ -294,44 +277,14 @@ export declare class BriefcaseManager {
|
|
|
294
277
|
private static readonly SCHEMAS_FOLDER;
|
|
295
278
|
private static readonly DATA_FOLDER;
|
|
296
279
|
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
280
|
/**
|
|
328
281
|
* Stores changed instances for semantic rebase locally in appropriate json file in a folder structure
|
|
329
|
-
* @param db The
|
|
282
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the changed instances against a txn
|
|
330
283
|
* @param txnId The txn id for which we are storing the changed instances
|
|
331
|
-
* @param instancePatches The
|
|
284
|
+
* @param instancePatches The [ChangeInstance]($backend) instance patches to be stored
|
|
332
285
|
* @internal
|
|
333
286
|
*/
|
|
334
|
-
|
|
287
|
+
static storeChangedInstancesForSemanticRebase(db: BriefcaseDb, txnId: string, instancePatches: IterableIterator<ChangeInstance>): void;
|
|
335
288
|
/**
|
|
336
289
|
* Gets the base path for semantic rebase local files
|
|
337
290
|
* @param db The {@link BriefcaseDb} instance for which to get the base path
|
|
@@ -341,7 +294,7 @@ export declare class BriefcaseManager {
|
|
|
341
294
|
static getBasePathForSemanticRebaseLocalFiles(db: BriefcaseDb): string;
|
|
342
295
|
/**
|
|
343
296
|
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
344
|
-
* @param db The
|
|
297
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the schemas against a txn
|
|
345
298
|
* @param txnId The txn id for which we are storing the schemas
|
|
346
299
|
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
347
300
|
* @internal
|
|
@@ -349,7 +302,7 @@ export declare class BriefcaseManager {
|
|
|
349
302
|
static storeSchemasForSemanticRebase<T extends LocalFileName[] | string[]>(db: BriefcaseDb, txnId: string, schemaFileNames: T): void;
|
|
350
303
|
/**
|
|
351
304
|
* Gets schemas for semantic rebase for a txn
|
|
352
|
-
* @param db The
|
|
305
|
+
* @param db The [BriefcaseDb]($backend) instance for getting the locally stored schemas against a txn
|
|
353
306
|
* @param txnId The txn id for which we are getting the schemas
|
|
354
307
|
* @returns the schema file paths
|
|
355
308
|
* @internal
|
|
@@ -357,15 +310,15 @@ export declare class BriefcaseManager {
|
|
|
357
310
|
static getSchemasForTxn(db: BriefcaseDb, txnId: string): string[];
|
|
358
311
|
/**
|
|
359
312
|
* Get the changed instances data for semantic rebase for a txn
|
|
360
|
-
* @param db - The
|
|
313
|
+
* @param db - The [BriefcaseDb]($backend) instance for getting the locally stored changed instances against a txn
|
|
361
314
|
* @param txnId - The txn id for which we are getting the changed instances
|
|
362
315
|
* @returns Instance patches
|
|
363
316
|
* @internal
|
|
364
317
|
*/
|
|
365
|
-
static getChangedInstancesDataForTxn(db: BriefcaseDb, txnId: string):
|
|
318
|
+
static getChangedInstancesDataForTxn(db: BriefcaseDb, txnId: string): AsyncGenerator<ChangeInstance>;
|
|
366
319
|
/**
|
|
367
320
|
* Checks if schema folder exists for semantic rebase for a txn
|
|
368
|
-
* @param db - The
|
|
321
|
+
* @param db - The [BriefcaseDb]($backend) instance for which TO check the schema folder
|
|
369
322
|
* @param txnId - The txn id for which we are check the schema folder
|
|
370
323
|
* @returns true if exists, false otherwise
|
|
371
324
|
* @internal
|
|
@@ -373,7 +326,7 @@ export declare class BriefcaseManager {
|
|
|
373
326
|
static semanticRebaseSchemaFolderExists(db: BriefcaseDb, txnId: string): boolean;
|
|
374
327
|
/**
|
|
375
328
|
* Checks if data folder exists for semantic rebase for a txn
|
|
376
|
-
* @param db The
|
|
329
|
+
* @param db The [BriefcaseDb]($backend) instance for which to check the data folder.
|
|
377
330
|
* @param txnId The txn id for which to check the data folder
|
|
378
331
|
* @returns true if exists, false otherwise
|
|
379
332
|
* @internal
|
|
@@ -381,21 +334,21 @@ export declare class BriefcaseManager {
|
|
|
381
334
|
static semanticRebaseDataFolderExists(db: BriefcaseDb, txnId: string): boolean;
|
|
382
335
|
/**
|
|
383
336
|
* Deletes the schema folder for semantic rebase for a txn
|
|
384
|
-
* @param db The
|
|
337
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the schema folder.
|
|
385
338
|
* @param txnId The txn id for which to delete the schema folder
|
|
386
339
|
* @internal
|
|
387
340
|
*/
|
|
388
341
|
static deleteTxnSchemaFolder(db: BriefcaseDb, txnId: string): void;
|
|
389
342
|
/**
|
|
390
343
|
* Deletes the data folder for semantic rebase for a txn
|
|
391
|
-
* @param db The
|
|
344
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the data folder.
|
|
392
345
|
* @param txnId The txn id for which to delete the data folder
|
|
393
346
|
* @internal
|
|
394
347
|
*/
|
|
395
348
|
static deleteTxnDataFolder(db: BriefcaseDb, txnId: string): void;
|
|
396
349
|
/**
|
|
397
350
|
* Deletes rebase folders for semantic rebase
|
|
398
|
-
* @param db The
|
|
351
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the rebase folders.
|
|
399
352
|
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
400
353
|
* @internal
|
|
401
354
|
*/
|
|
@@ -408,5 +361,4 @@ export declare class BriefcaseManager {
|
|
|
408
361
|
*/
|
|
409
362
|
private static cleanupRebaseFolders;
|
|
410
363
|
}
|
|
411
|
-
export {};
|
|
412
364
|
//# 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,
|
|
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,EAC1H,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,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,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM7D,OAAO,EAAgB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;EAEE;AACF,MAAM,WAAW,sBAAuB,SAAQ,QAAQ,EAAE,wBAAwB;IAChF;;OAEG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,8IAA8I;IAC9I,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,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AAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAMrF;;;;;OAKG;WACW,qBAAqB,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAazE;;;;;MAKE;WACY,mBAAmB,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAavE;;;;;OAKG;WACW,mBAAmB,CAAC,EAAE,EAAE,WAAW,EAAE,YAAY,GAAE,OAAe,GAAG,IAAI;IAiBvF;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAapC"}
|
|
@@ -5,63 +5,11 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module iModels
|
|
7
7
|
*/
|
|
8
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
9
|
-
if (value !== null && value !== void 0) {
|
|
10
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
11
|
-
var dispose, inner;
|
|
12
|
-
if (async) {
|
|
13
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
14
|
-
dispose = value[Symbol.asyncDispose];
|
|
15
|
-
}
|
|
16
|
-
if (dispose === void 0) {
|
|
17
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
18
|
-
dispose = value[Symbol.dispose];
|
|
19
|
-
if (async) inner = dispose;
|
|
20
|
-
}
|
|
21
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
22
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
23
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
24
|
-
}
|
|
25
|
-
else if (async) {
|
|
26
|
-
env.stack.push({ async: true });
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
};
|
|
30
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
31
|
-
return function (env) {
|
|
32
|
-
function fail(e) {
|
|
33
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
34
|
-
env.hasError = true;
|
|
35
|
-
}
|
|
36
|
-
var r, s = 0;
|
|
37
|
-
function next() {
|
|
38
|
-
while (r = env.stack.pop()) {
|
|
39
|
-
try {
|
|
40
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
41
|
-
if (r.dispose) {
|
|
42
|
-
var result = r.dispose.call(r.value);
|
|
43
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
44
|
-
}
|
|
45
|
-
else s |= 1;
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
fail(e);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
52
|
-
if (env.hasError) throw env.error;
|
|
53
|
-
}
|
|
54
|
-
return next();
|
|
55
|
-
};
|
|
56
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
57
|
-
var e = new Error(message);
|
|
58
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
59
|
-
});
|
|
60
8
|
// cspell:ignore cset csets ecchanges
|
|
61
9
|
import * as path from "node:path";
|
|
62
10
|
import * as os from "node:os";
|
|
63
11
|
import { BeDuration, ChangeSetStatus, DbResult, IModelHubStatus, IModelStatus, Logger, OpenMode, StopWatch } from "@itwin/core-bentley";
|
|
64
|
-
import { BriefcaseIdValue, ChangesetType, IModelError, IModelVersion, } from "@itwin/core-common";
|
|
12
|
+
import { Base64EncodedString, BriefcaseIdValue, ChangesetType, IModelError, IModelVersion, } from "@itwin/core-common";
|
|
65
13
|
import { BackendLoggerCategory } from "./BackendLoggerCategory";
|
|
66
14
|
import { CheckpointManager } from "./CheckpointManager";
|
|
67
15
|
import { BriefcaseDb, IModelDb } from "./IModelDb";
|
|
@@ -71,8 +19,6 @@ import { SchemaSync } from "./SchemaSync";
|
|
|
71
19
|
import { _hubAccess, _nativeDb, _releaseAllLocks } from "./internal/Symbols";
|
|
72
20
|
import { IModelNative } from "./internal/NativePlatform";
|
|
73
21
|
import { StashManager } from "./StashManager";
|
|
74
|
-
import { ChangesetECAdaptor, ECChangeUnifierCache, PartialECChangeUnifier } from "./ChangesetECAdaptor";
|
|
75
|
-
import { SqliteChangesetReader } from "./SqliteChangesetReader";
|
|
76
22
|
const loggerCategory = BackendLoggerCategory.IModelDb;
|
|
77
23
|
/** Manages downloading Briefcases and downloading and uploading changesets.
|
|
78
24
|
* @public
|
|
@@ -528,11 +474,8 @@ export class BriefcaseManager {
|
|
|
528
474
|
}
|
|
529
475
|
if (!reverse) {
|
|
530
476
|
if (briefcaseDb) {
|
|
531
|
-
if (useSemanticRebase) {
|
|
532
|
-
this.capturePatchInstances(briefcaseDb);
|
|
533
|
-
}
|
|
534
477
|
briefcaseDb.txns.rebaser.notifyReverseLocalChangesBegin();
|
|
535
|
-
const reversedTxns = nativeDb.pullMergeReverseLocalChanges();
|
|
478
|
+
const reversedTxns = nativeDb.pullMergeReverseLocalChanges(useSemanticRebase);
|
|
536
479
|
if (useSemanticRebase) {
|
|
537
480
|
nativeDb.clearECDbCache(); // Clear the ECDb cache after reversing local changes to ensure consistency during semantic rebase with schema changes.
|
|
538
481
|
}
|
|
@@ -757,101 +700,11 @@ export class BriefcaseManager {
|
|
|
757
700
|
static SCHEMAS_FOLDER = "schemas";
|
|
758
701
|
static DATA_FOLDER = "data";
|
|
759
702
|
static DATA_FILE_NAME = "data.json";
|
|
760
|
-
/**
|
|
761
|
-
* Captures the changed instances as patch instances from each data txn in the briefcase db for semantic rebase
|
|
762
|
-
* @param db The {@link BriefcaseDb} instance for which to capture the changed instances as patch instances for all data txns
|
|
763
|
-
* @internal
|
|
764
|
-
*/
|
|
765
|
-
static capturePatchInstances(db) {
|
|
766
|
-
const txns = Array.from(db.txns.queryTxns());
|
|
767
|
-
txns.forEach((txn) => {
|
|
768
|
-
if (txn.type !== "Data")
|
|
769
|
-
return;
|
|
770
|
-
// already captured(This actually shows that first rebase operation is already done but during that while reinstating this txns,
|
|
771
|
-
// some error happened so the folder still exists so we don't want to capture again)
|
|
772
|
-
if (this.semanticRebaseDataFolderExists(db, txn.id))
|
|
773
|
-
return;
|
|
774
|
-
const changedInstances = this.captureChangedInstancesAsJSON(db, txn.id);
|
|
775
|
-
const instancePatches = this.constructPatchInstances(db, changedInstances);
|
|
776
|
-
this.storeChangedInstancesForSemanticRebase(db, txn.id, instancePatches);
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Captures changed instances from a txn as JSON
|
|
781
|
-
* @param txnId The txn id for which to capture changed instances
|
|
782
|
-
* @param db The {@link BriefcaseDb} instance from which to capture changed instances as json
|
|
783
|
-
* @returns changed instances for semantic rebase
|
|
784
|
-
* @internal
|
|
785
|
-
*/
|
|
786
|
-
static captureChangedInstancesAsJSON(db, txnId) {
|
|
787
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
788
|
-
try {
|
|
789
|
-
const reader = SqliteChangesetReader.openTxn({
|
|
790
|
-
txnId, db, disableSchemaCheck: true
|
|
791
|
-
});
|
|
792
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
793
|
-
const adaptor = new ChangesetECAdaptor(reader);
|
|
794
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
795
|
-
const indirectUnifier = __addDisposableResource(env_1, new PartialECChangeUnifier(reader.db, ECChangeUnifierCache.createInMemoryCache()), false);
|
|
796
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
797
|
-
const directUnifier = __addDisposableResource(env_1, new PartialECChangeUnifier(reader.db, ECChangeUnifierCache.createInMemoryCache()), false);
|
|
798
|
-
while (adaptor.step()) {
|
|
799
|
-
if (adaptor.reader.isIndirect)
|
|
800
|
-
indirectUnifier.appendFrom(adaptor); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
801
|
-
else
|
|
802
|
-
directUnifier.appendFrom(adaptor); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
803
|
-
}
|
|
804
|
-
return [...Array.from(directUnifier.instances).map((instance) => ({ isIndirect: false, instance })), ...Array.from(indirectUnifier.instances).map((instance) => ({ isIndirect: true, instance }))]; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
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 IModelError(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 IModelError(IModelStatus.BadArg, `Unknown operation: ${op}`);
|
|
843
|
-
return {
|
|
844
|
-
key: instanceKey,
|
|
845
|
-
op,
|
|
846
|
-
isIndirect: changedInstance.isIndirect,
|
|
847
|
-
props: op !== "Deleted" ? db[_nativeDb].readInstance(instanceKey, { useJsNames: true }) : undefined,
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
703
|
/**
|
|
851
704
|
* Stores changed instances for semantic rebase locally in appropriate json file in a folder structure
|
|
852
|
-
* @param db The
|
|
705
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the changed instances against a txn
|
|
853
706
|
* @param txnId The txn id for which we are storing the changed instances
|
|
854
|
-
* @param instancePatches The
|
|
707
|
+
* @param instancePatches The [ChangeInstance]($backend) instance patches to be stored
|
|
855
708
|
* @internal
|
|
856
709
|
*/
|
|
857
710
|
static storeChangedInstancesForSemanticRebase(db, txnId, instancePatches) {
|
|
@@ -861,7 +714,17 @@ export class BriefcaseManager {
|
|
|
861
714
|
if (IModelJsFs.existsSync(targetDir))
|
|
862
715
|
IModelJsFs.removeSync(targetDir);
|
|
863
716
|
IModelJsFs.recursiveMkDirSync(targetDir);
|
|
864
|
-
IModelJsFs.writeFileSync(filePath,
|
|
717
|
+
IModelJsFs.writeFileSync(filePath, "[");
|
|
718
|
+
let isFirst = true;
|
|
719
|
+
for (const instancePatch of instancePatches) {
|
|
720
|
+
// we will not take the old stage of updated instances for now, because we still don't have conflict resolution on instance level while using semantic rebase.
|
|
721
|
+
// Once we have conflict resolution on instance level, we can consider taking old stage of updated instances as well.
|
|
722
|
+
if (instancePatch.$meta.op === "Updated" && instancePatch.$meta.stage === "Old")
|
|
723
|
+
continue;
|
|
724
|
+
IModelJsFs.appendFileSync(filePath, `${isFirst ? "" : ","}\n${JSON.stringify(instancePatch, Base64EncodedString.replacer)}`);
|
|
725
|
+
isFirst = false;
|
|
726
|
+
}
|
|
727
|
+
IModelJsFs.appendFileSync(filePath, "\n]");
|
|
865
728
|
}
|
|
866
729
|
/**
|
|
867
730
|
* Gets the base path for semantic rebase local files
|
|
@@ -874,7 +737,7 @@ export class BriefcaseManager {
|
|
|
874
737
|
}
|
|
875
738
|
/**
|
|
876
739
|
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
877
|
-
* @param db The
|
|
740
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the schemas against a txn
|
|
878
741
|
* @param txnId The txn id for which we are storing the schemas
|
|
879
742
|
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
880
743
|
* @internal
|
|
@@ -900,7 +763,7 @@ export class BriefcaseManager {
|
|
|
900
763
|
}
|
|
901
764
|
/**
|
|
902
765
|
* Gets schemas for semantic rebase for a txn
|
|
903
|
-
* @param db The
|
|
766
|
+
* @param db The [BriefcaseDb]($backend) instance for getting the locally stored schemas against a txn
|
|
904
767
|
* @param txnId The txn id for which we are getting the schemas
|
|
905
768
|
* @returns the schema file paths
|
|
906
769
|
* @internal
|
|
@@ -912,21 +775,25 @@ export class BriefcaseManager {
|
|
|
912
775
|
}
|
|
913
776
|
/**
|
|
914
777
|
* Get the changed instances data for semantic rebase for a txn
|
|
915
|
-
* @param db - The
|
|
778
|
+
* @param db - The [BriefcaseDb]($backend) instance for getting the locally stored changed instances against a txn
|
|
916
779
|
* @param txnId - The txn id for which we are getting the changed instances
|
|
917
780
|
* @returns Instance patches
|
|
918
781
|
* @internal
|
|
919
782
|
*/
|
|
920
|
-
static getChangedInstancesDataForTxn(db, txnId) {
|
|
783
|
+
static async *getChangedInstancesDataForTxn(db, txnId) {
|
|
921
784
|
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
922
785
|
const folderPath = path.join(basePath, txnId, BriefcaseManager.DATA_FOLDER);
|
|
923
786
|
const filePath = path.join(folderPath, BriefcaseManager.DATA_FILE_NAME);
|
|
924
|
-
const
|
|
925
|
-
|
|
787
|
+
for await (const line of IModelJsFs.readLines(filePath)) {
|
|
788
|
+
if (line === "[" || line === "]" || line === "")
|
|
789
|
+
continue;
|
|
790
|
+
const trimmedLine = line.trim().endsWith(",") ? line.trim().slice(0, -1) : line.trim(); // remove trailing comma if exists
|
|
791
|
+
yield JSON.parse(trimmedLine, Base64EncodedString.reviver);
|
|
792
|
+
}
|
|
926
793
|
}
|
|
927
794
|
/**
|
|
928
795
|
* Checks if schema folder exists for semantic rebase for a txn
|
|
929
|
-
* @param db - The
|
|
796
|
+
* @param db - The [BriefcaseDb]($backend) instance for which TO check the schema folder
|
|
930
797
|
* @param txnId - The txn id for which we are check the schema folder
|
|
931
798
|
* @returns true if exists, false otherwise
|
|
932
799
|
* @internal
|
|
@@ -938,7 +805,7 @@ export class BriefcaseManager {
|
|
|
938
805
|
}
|
|
939
806
|
/**
|
|
940
807
|
* Checks if data folder exists for semantic rebase for a txn
|
|
941
|
-
* @param db The
|
|
808
|
+
* @param db The [BriefcaseDb]($backend) instance for which to check the data folder.
|
|
942
809
|
* @param txnId The txn id for which to check the data folder
|
|
943
810
|
* @returns true if exists, false otherwise
|
|
944
811
|
* @internal
|
|
@@ -950,7 +817,7 @@ export class BriefcaseManager {
|
|
|
950
817
|
}
|
|
951
818
|
/**
|
|
952
819
|
* Deletes the schema folder for semantic rebase for a txn
|
|
953
|
-
* @param db The
|
|
820
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the schema folder.
|
|
954
821
|
* @param txnId The txn id for which to delete the schema folder
|
|
955
822
|
* @internal
|
|
956
823
|
*/
|
|
@@ -966,7 +833,7 @@ export class BriefcaseManager {
|
|
|
966
833
|
}
|
|
967
834
|
/**
|
|
968
835
|
* Deletes the data folder for semantic rebase for a txn
|
|
969
|
-
* @param db The
|
|
836
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the data folder.
|
|
970
837
|
* @param txnId The txn id for which to delete the data folder
|
|
971
838
|
* @internal
|
|
972
839
|
*/
|
|
@@ -982,7 +849,7 @@ export class BriefcaseManager {
|
|
|
982
849
|
}
|
|
983
850
|
/**
|
|
984
851
|
* Deletes rebase folders for semantic rebase
|
|
985
|
-
* @param db The
|
|
852
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the rebase folders.
|
|
986
853
|
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
987
854
|
* @internal
|
|
988
855
|
*/
|