@itwin/core-backend 5.9.0 → 5.9.2
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 +15 -1
- package/lib/cjs/BriefcaseManager.d.ts +17 -59
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +45 -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/cjs/internal/cross-package.d.ts +1 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +2 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +17 -59
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +46 -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/internal/cross-package.d.ts +1 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js +1 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebase.test.js +2276 -70
- package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 08 May 2026 20:36:41 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.9.2
|
|
6
|
+
Fri, 08 May 2026 20:36:41 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Added batching while writing instance patches to the file during semantic rebase. Also reduced the $meta field in instance patches to include only the necessary properties and skip unnecessary ones.
|
|
11
|
+
|
|
12
|
+
## 5.9.1
|
|
13
|
+
Tue, 05 May 2026 17:43:30 GMT
|
|
14
|
+
|
|
15
|
+
### Updates
|
|
16
|
+
|
|
17
|
+
- Semantic Rebase uses the new ChangesetReader api. Also while doing semantic rebase we now stream the changed instances onto the temp file while writing as well as stream changed instances from the file while reading.
|
|
4
18
|
|
|
5
19
|
## 5.9.0
|
|
6
20
|
Mon, 04 May 2026 16:32:08 GMT
|
|
@@ -1,29 +1,18 @@
|
|
|
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
|
|
10
|
+
import { ChangeInstance, ChangeMeta } from "./ChangesetReaderTypes";
|
|
11
|
+
/** The argument for patch instances during semantic rebase
|
|
13
12
|
* @internal
|
|
14
13
|
*/
|
|
15
|
-
interface
|
|
16
|
-
|
|
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;
|
|
14
|
+
export interface InstancePatch extends Omit<ChangeInstance, "$meta"> {
|
|
15
|
+
$meta: Pick<ChangeMeta, "op" | "stage" | "isIndirectChange">;
|
|
27
16
|
}
|
|
28
17
|
/** The argument for [[BriefcaseManager.downloadBriefcase]]
|
|
29
18
|
* @public
|
|
@@ -294,44 +283,14 @@ export declare class BriefcaseManager {
|
|
|
294
283
|
private static readonly SCHEMAS_FOLDER;
|
|
295
284
|
private static readonly DATA_FOLDER;
|
|
296
285
|
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
286
|
/**
|
|
328
287
|
* Stores changed instances for semantic rebase locally in appropriate json file in a folder structure
|
|
329
|
-
* @param db The
|
|
288
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the changed instances against a txn
|
|
330
289
|
* @param txnId The txn id for which we are storing the changed instances
|
|
331
|
-
* @param instancePatches The
|
|
290
|
+
* @param instancePatches The [ChangeInstance]($backend) IterableIterator instance patches to be stored
|
|
332
291
|
* @internal
|
|
333
292
|
*/
|
|
334
|
-
|
|
293
|
+
static storeChangedInstancesForSemanticRebase(db: BriefcaseDb, txnId: string, instancePatches: IterableIterator<ChangeInstance>): void;
|
|
335
294
|
/**
|
|
336
295
|
* Gets the base path for semantic rebase local files
|
|
337
296
|
* @param db The {@link BriefcaseDb} instance for which to get the base path
|
|
@@ -341,7 +300,7 @@ export declare class BriefcaseManager {
|
|
|
341
300
|
static getBasePathForSemanticRebaseLocalFiles(db: BriefcaseDb): string;
|
|
342
301
|
/**
|
|
343
302
|
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
344
|
-
* @param db The
|
|
303
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the schemas against a txn
|
|
345
304
|
* @param txnId The txn id for which we are storing the schemas
|
|
346
305
|
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
347
306
|
* @internal
|
|
@@ -349,7 +308,7 @@ export declare class BriefcaseManager {
|
|
|
349
308
|
static storeSchemasForSemanticRebase<T extends LocalFileName[] | string[]>(db: BriefcaseDb, txnId: string, schemaFileNames: T): void;
|
|
350
309
|
/**
|
|
351
310
|
* Gets schemas for semantic rebase for a txn
|
|
352
|
-
* @param db The
|
|
311
|
+
* @param db The [BriefcaseDb]($backend) instance for getting the locally stored schemas against a txn
|
|
353
312
|
* @param txnId The txn id for which we are getting the schemas
|
|
354
313
|
* @returns the schema file paths
|
|
355
314
|
* @internal
|
|
@@ -357,15 +316,15 @@ export declare class BriefcaseManager {
|
|
|
357
316
|
static getSchemasForTxn(db: BriefcaseDb, txnId: string): string[];
|
|
358
317
|
/**
|
|
359
318
|
* Get the changed instances data for semantic rebase for a txn
|
|
360
|
-
* @param db - The
|
|
319
|
+
* @param db - The [BriefcaseDb]($backend) instance for getting the locally stored changed instances against a txn
|
|
361
320
|
* @param txnId - The txn id for which we are getting the changed instances
|
|
362
321
|
* @returns Instance patches
|
|
363
322
|
* @internal
|
|
364
323
|
*/
|
|
365
|
-
static getChangedInstancesDataForTxn(db: BriefcaseDb, txnId: string): InstancePatch
|
|
324
|
+
static getChangedInstancesDataForTxn(db: BriefcaseDb, txnId: string): AsyncGenerator<InstancePatch>;
|
|
366
325
|
/**
|
|
367
326
|
* Checks if schema folder exists for semantic rebase for a txn
|
|
368
|
-
* @param db - The
|
|
327
|
+
* @param db - The [BriefcaseDb]($backend) instance for which TO check the schema folder
|
|
369
328
|
* @param txnId - The txn id for which we are check the schema folder
|
|
370
329
|
* @returns true if exists, false otherwise
|
|
371
330
|
* @internal
|
|
@@ -373,7 +332,7 @@ export declare class BriefcaseManager {
|
|
|
373
332
|
static semanticRebaseSchemaFolderExists(db: BriefcaseDb, txnId: string): boolean;
|
|
374
333
|
/**
|
|
375
334
|
* Checks if data folder exists for semantic rebase for a txn
|
|
376
|
-
* @param db The
|
|
335
|
+
* @param db The [BriefcaseDb]($backend) instance for which to check the data folder.
|
|
377
336
|
* @param txnId The txn id for which to check the data folder
|
|
378
337
|
* @returns true if exists, false otherwise
|
|
379
338
|
* @internal
|
|
@@ -381,21 +340,21 @@ export declare class BriefcaseManager {
|
|
|
381
340
|
static semanticRebaseDataFolderExists(db: BriefcaseDb, txnId: string): boolean;
|
|
382
341
|
/**
|
|
383
342
|
* Deletes the schema folder for semantic rebase for a txn
|
|
384
|
-
* @param db The
|
|
343
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the schema folder.
|
|
385
344
|
* @param txnId The txn id for which to delete the schema folder
|
|
386
345
|
* @internal
|
|
387
346
|
*/
|
|
388
347
|
static deleteTxnSchemaFolder(db: BriefcaseDb, txnId: string): void;
|
|
389
348
|
/**
|
|
390
349
|
* Deletes the data folder for semantic rebase for a txn
|
|
391
|
-
* @param db The
|
|
350
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the data folder.
|
|
392
351
|
* @param txnId The txn id for which to delete the data folder
|
|
393
352
|
* @internal
|
|
394
353
|
*/
|
|
395
354
|
static deleteTxnDataFolder(db: BriefcaseDb, txnId: string): void;
|
|
396
355
|
/**
|
|
397
356
|
* Deletes rebase folders for semantic rebase
|
|
398
|
-
* @param db The
|
|
357
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the rebase folders.
|
|
399
358
|
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
400
359
|
* @internal
|
|
401
360
|
*/
|
|
@@ -408,5 +367,4 @@ export declare class BriefcaseManager {
|
|
|
408
367
|
*/
|
|
409
368
|
private static cleanupRebaseFolders;
|
|
410
369
|
}
|
|
411
|
-
export {};
|
|
412
370
|
//# sourceMappingURL=BriefcaseManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BriefcaseManager.d.ts","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAA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,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"}
|
|
@@ -6,58 +6,6 @@
|
|
|
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
|
-
});
|
|
61
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
10
|
exports.BriefcaseManager = void 0;
|
|
63
11
|
// cspell:ignore cset csets ecchanges
|
|
@@ -74,8 +22,6 @@ const SchemaSync_1 = require("./SchemaSync");
|
|
|
74
22
|
const Symbols_1 = require("./internal/Symbols");
|
|
75
23
|
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
76
24
|
const StashManager_1 = require("./StashManager");
|
|
77
|
-
const ChangesetECAdaptor_1 = require("./ChangesetECAdaptor");
|
|
78
|
-
const SqliteChangesetReader_1 = require("./SqliteChangesetReader");
|
|
79
25
|
const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
|
|
80
26
|
/** Manages downloading Briefcases and downloading and uploading changesets.
|
|
81
27
|
* @public
|
|
@@ -531,11 +477,8 @@ class BriefcaseManager {
|
|
|
531
477
|
}
|
|
532
478
|
if (!reverse) {
|
|
533
479
|
if (briefcaseDb) {
|
|
534
|
-
if (useSemanticRebase) {
|
|
535
|
-
this.capturePatchInstances(briefcaseDb);
|
|
536
|
-
}
|
|
537
480
|
briefcaseDb.txns.rebaser.notifyReverseLocalChangesBegin();
|
|
538
|
-
const reversedTxns = nativeDb.pullMergeReverseLocalChanges();
|
|
481
|
+
const reversedTxns = nativeDb.pullMergeReverseLocalChanges(useSemanticRebase);
|
|
539
482
|
if (useSemanticRebase) {
|
|
540
483
|
nativeDb.clearECDbCache(); // Clear the ECDb cache after reversing local changes to ensure consistency during semantic rebase with schema changes.
|
|
541
484
|
}
|
|
@@ -760,101 +703,11 @@ class BriefcaseManager {
|
|
|
760
703
|
static SCHEMAS_FOLDER = "schemas";
|
|
761
704
|
static DATA_FOLDER = "data";
|
|
762
705
|
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
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
796
|
-
const adaptor = new ChangesetECAdaptor_1.ChangesetECAdaptor(reader);
|
|
797
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
798
|
-
const indirectUnifier = __addDisposableResource(env_1, new ChangesetECAdaptor_1.PartialECChangeUnifier(reader.db, ChangesetECAdaptor_1.ECChangeUnifierCache.createInMemoryCache()), false);
|
|
799
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
800
|
-
const directUnifier = __addDisposableResource(env_1, new ChangesetECAdaptor_1.PartialECChangeUnifier(reader.db, ChangesetECAdaptor_1.ECChangeUnifierCache.createInMemoryCache()), false);
|
|
801
|
-
while (adaptor.step()) {
|
|
802
|
-
if (adaptor.reader.isIndirect)
|
|
803
|
-
indirectUnifier.appendFrom(adaptor); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
804
|
-
else
|
|
805
|
-
directUnifier.appendFrom(adaptor); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
806
|
-
}
|
|
807
|
-
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
|
|
808
|
-
}
|
|
809
|
-
catch (e_1) {
|
|
810
|
-
env_1.error = e_1;
|
|
811
|
-
env_1.hasError = true;
|
|
812
|
-
}
|
|
813
|
-
finally {
|
|
814
|
-
__disposeResources(env_1);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* Constructs patch instances from changed instances
|
|
819
|
-
* @param changedInstances The changed instances from which to construct the patch instances
|
|
820
|
-
* @param db The {@link BriefcaseDb} instance for which to construct the patch instances
|
|
821
|
-
* @returns The {@link InstancePatch} instance patches for semantic rebase
|
|
822
|
-
* @internal
|
|
823
|
-
*/
|
|
824
|
-
static constructPatchInstances(db, changedInstances) {
|
|
825
|
-
return changedInstances
|
|
826
|
-
.filter((changedInstance) => !(changedInstance.instance.$meta?.op === "Updated" && changedInstance.instance.$meta.stage === "Old")) // we will not take the old stage of updated instances
|
|
827
|
-
.map((changedInstance) => this.constructPatchInstance(db, changedInstance));
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Constructs a single patch instance from changed instance
|
|
831
|
-
* @param changedInstance The changed instance from which to construct the patch instance
|
|
832
|
-
* @param db The {@link BriefcaseDb} instance for which to construct the single patch instance
|
|
833
|
-
* @returns a single instance patch {@link InstancePatch}
|
|
834
|
-
* @throws IModelError If cannot determine classId or unknown operation encountered
|
|
835
|
-
*/
|
|
836
|
-
static constructPatchInstance(db, changedInstance) {
|
|
837
|
-
const className = (changedInstance.instance.ECClassId && db.getClassNameFromId(changedInstance.instance.ECClassId))
|
|
838
|
-
?? changedInstance.instance.$meta?.classFullName
|
|
839
|
-
?? (changedInstance.instance.$meta?.fallbackClassId && db.getClassNameFromId(changedInstance.instance.$meta.fallbackClassId));
|
|
840
|
-
if (!className)
|
|
841
|
-
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Cannot determine classId of changed instance");
|
|
842
|
-
const instanceKey = { id: changedInstance.instance.ECInstanceId, classFullName: className };
|
|
843
|
-
const op = changedInstance.instance.$meta?.op;
|
|
844
|
-
if (op !== "Inserted" && op !== "Updated" && op !== "Deleted")
|
|
845
|
-
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, `Unknown operation: ${op}`);
|
|
846
|
-
return {
|
|
847
|
-
key: instanceKey,
|
|
848
|
-
op,
|
|
849
|
-
isIndirect: changedInstance.isIndirect,
|
|
850
|
-
props: op !== "Deleted" ? db[Symbols_1._nativeDb].readInstance(instanceKey, { useJsNames: true }) : undefined,
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
706
|
/**
|
|
854
707
|
* Stores changed instances for semantic rebase locally in appropriate json file in a folder structure
|
|
855
|
-
* @param db The
|
|
708
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the changed instances against a txn
|
|
856
709
|
* @param txnId The txn id for which we are storing the changed instances
|
|
857
|
-
* @param instancePatches The
|
|
710
|
+
* @param instancePatches The [ChangeInstance]($backend) IterableIterator instance patches to be stored
|
|
858
711
|
* @internal
|
|
859
712
|
*/
|
|
860
713
|
static storeChangedInstancesForSemanticRebase(db, txnId, instancePatches) {
|
|
@@ -864,7 +717,33 @@ class BriefcaseManager {
|
|
|
864
717
|
if (IModelJsFs_1.IModelJsFs.existsSync(targetDir))
|
|
865
718
|
IModelJsFs_1.IModelJsFs.removeSync(targetDir);
|
|
866
719
|
IModelJsFs_1.IModelJsFs.recursiveMkDirSync(targetDir);
|
|
867
|
-
|
|
720
|
+
const BATCH_SIZE = 100;
|
|
721
|
+
let isFirst = true;
|
|
722
|
+
let batchParts = [];
|
|
723
|
+
const flushBatch = () => {
|
|
724
|
+
if (batchParts.length === 0)
|
|
725
|
+
return;
|
|
726
|
+
IModelJsFs_1.IModelJsFs.appendFileSync(filePath, batchParts.join(""));
|
|
727
|
+
batchParts = [];
|
|
728
|
+
};
|
|
729
|
+
IModelJsFs_1.IModelJsFs.writeFileSync(filePath, "[");
|
|
730
|
+
for (const instancePatch of instancePatches) {
|
|
731
|
+
// 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.
|
|
732
|
+
// Once we have conflict resolution on instance level, we can consider taking old stage of updated instances as well.
|
|
733
|
+
if (instancePatch.$meta.op === "Updated" && instancePatch.$meta.stage === "Old")
|
|
734
|
+
continue;
|
|
735
|
+
const { $meta, ...rest } = instancePatch;
|
|
736
|
+
const transformedInstance = {
|
|
737
|
+
...rest,
|
|
738
|
+
$meta: { op: $meta.op, stage: $meta.stage, isIndirectChange: $meta.isIndirectChange },
|
|
739
|
+
};
|
|
740
|
+
batchParts.push(`${isFirst ? "" : ","}\n${JSON.stringify(transformedInstance, core_common_1.Base64EncodedString.replacer)}`);
|
|
741
|
+
isFirst = false;
|
|
742
|
+
if (batchParts.length >= BATCH_SIZE)
|
|
743
|
+
flushBatch();
|
|
744
|
+
}
|
|
745
|
+
flushBatch();
|
|
746
|
+
IModelJsFs_1.IModelJsFs.appendFileSync(filePath, "\n]");
|
|
868
747
|
}
|
|
869
748
|
/**
|
|
870
749
|
* Gets the base path for semantic rebase local files
|
|
@@ -877,7 +756,7 @@ class BriefcaseManager {
|
|
|
877
756
|
}
|
|
878
757
|
/**
|
|
879
758
|
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
880
|
-
* @param db The
|
|
759
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the schemas against a txn
|
|
881
760
|
* @param txnId The txn id for which we are storing the schemas
|
|
882
761
|
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
883
762
|
* @internal
|
|
@@ -903,7 +782,7 @@ class BriefcaseManager {
|
|
|
903
782
|
}
|
|
904
783
|
/**
|
|
905
784
|
* Gets schemas for semantic rebase for a txn
|
|
906
|
-
* @param db The
|
|
785
|
+
* @param db The [BriefcaseDb]($backend) instance for getting the locally stored schemas against a txn
|
|
907
786
|
* @param txnId The txn id for which we are getting the schemas
|
|
908
787
|
* @returns the schema file paths
|
|
909
788
|
* @internal
|
|
@@ -915,21 +794,25 @@ class BriefcaseManager {
|
|
|
915
794
|
}
|
|
916
795
|
/**
|
|
917
796
|
* Get the changed instances data for semantic rebase for a txn
|
|
918
|
-
* @param db - The
|
|
797
|
+
* @param db - The [BriefcaseDb]($backend) instance for getting the locally stored changed instances against a txn
|
|
919
798
|
* @param txnId - The txn id for which we are getting the changed instances
|
|
920
799
|
* @returns Instance patches
|
|
921
800
|
* @internal
|
|
922
801
|
*/
|
|
923
|
-
static getChangedInstancesDataForTxn(db, txnId) {
|
|
802
|
+
static async *getChangedInstancesDataForTxn(db, txnId) {
|
|
924
803
|
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
925
804
|
const folderPath = path.join(basePath, txnId, BriefcaseManager.DATA_FOLDER);
|
|
926
805
|
const filePath = path.join(folderPath, BriefcaseManager.DATA_FILE_NAME);
|
|
927
|
-
const
|
|
928
|
-
|
|
806
|
+
for await (const line of IModelJsFs_1.IModelJsFs.readLines(filePath)) {
|
|
807
|
+
if (line === "[" || line === "]" || line === "")
|
|
808
|
+
continue;
|
|
809
|
+
const trimmedLine = line.trim().endsWith(",") ? line.trim().slice(0, -1) : line.trim(); // remove trailing comma if exists
|
|
810
|
+
yield JSON.parse(trimmedLine, core_common_1.Base64EncodedString.reviver);
|
|
811
|
+
}
|
|
929
812
|
}
|
|
930
813
|
/**
|
|
931
814
|
* Checks if schema folder exists for semantic rebase for a txn
|
|
932
|
-
* @param db - The
|
|
815
|
+
* @param db - The [BriefcaseDb]($backend) instance for which TO check the schema folder
|
|
933
816
|
* @param txnId - The txn id for which we are check the schema folder
|
|
934
817
|
* @returns true if exists, false otherwise
|
|
935
818
|
* @internal
|
|
@@ -941,7 +824,7 @@ class BriefcaseManager {
|
|
|
941
824
|
}
|
|
942
825
|
/**
|
|
943
826
|
* Checks if data folder exists for semantic rebase for a txn
|
|
944
|
-
* @param db The
|
|
827
|
+
* @param db The [BriefcaseDb]($backend) instance for which to check the data folder.
|
|
945
828
|
* @param txnId The txn id for which to check the data folder
|
|
946
829
|
* @returns true if exists, false otherwise
|
|
947
830
|
* @internal
|
|
@@ -953,7 +836,7 @@ class BriefcaseManager {
|
|
|
953
836
|
}
|
|
954
837
|
/**
|
|
955
838
|
* Deletes the schema folder for semantic rebase for a txn
|
|
956
|
-
* @param db The
|
|
839
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the schema folder.
|
|
957
840
|
* @param txnId The txn id for which to delete the schema folder
|
|
958
841
|
* @internal
|
|
959
842
|
*/
|
|
@@ -969,7 +852,7 @@ class BriefcaseManager {
|
|
|
969
852
|
}
|
|
970
853
|
/**
|
|
971
854
|
* Deletes the data folder for semantic rebase for a txn
|
|
972
|
-
* @param db The
|
|
855
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the data folder.
|
|
973
856
|
* @param txnId The txn id for which to delete the data folder
|
|
974
857
|
* @internal
|
|
975
858
|
*/
|
|
@@ -985,7 +868,7 @@ class BriefcaseManager {
|
|
|
985
868
|
}
|
|
986
869
|
/**
|
|
987
870
|
* Deletes rebase folders for semantic rebase
|
|
988
|
-
* @param db The
|
|
871
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the rebase folders.
|
|
989
872
|
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
990
873
|
* @internal
|
|
991
874
|
*/
|