@itwin/core-backend 5.10.0-dev.1 → 5.10.0-dev.10
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 +35 -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/Category.d.ts +4 -4
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +6 -6
- package/lib/cjs/ChangesetECAdaptor.js +4 -4
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +3 -3
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/Element.d.ts +10 -10
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +2 -2
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +5 -5
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts +2 -2
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +22 -22
- package/lib/cjs/IModelDb.js +20 -20
- package/lib/cjs/IModelDb.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/LineStyle.d.ts +6 -6
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/Material.d.ts +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +6 -6
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +10 -10
- package/lib/cjs/Relationship.js +6 -6
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SheetIndex.d.ts +4 -4
- package/lib/cjs/SheetIndex.d.ts.map +1 -1
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/Texture.d.ts +1 -1
- package/lib/cjs/Texture.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/ViewDefinition.d.ts +6 -6
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +2 -2
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts +2 -2
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.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/Category.d.ts +4 -4
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts +6 -6
- package/lib/esm/ChangesetECAdaptor.js +4 -4
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/CodeSpecs.d.ts +3 -3
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +2 -2
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/Element.d.ts +10 -10
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +2 -2
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts +1 -1
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementTreeWalker.d.ts +5 -5
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/ExternalSource.d.ts +2 -2
- package/lib/esm/ExternalSource.d.ts.map +1 -1
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +22 -22
- package/lib/esm/IModelDb.js +20 -20
- package/lib/esm/IModelDb.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/LineStyle.d.ts +6 -6
- package/lib/esm/LineStyle.js.map +1 -1
- package/lib/esm/Material.d.ts +1 -1
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.d.ts +6 -6
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/Relationship.d.ts +10 -10
- package/lib/esm/Relationship.js +6 -6
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/SheetIndex.d.ts +4 -4
- package/lib/esm/SheetIndex.d.ts.map +1 -1
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/Texture.d.ts +1 -1
- package/lib/esm/Texture.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/ViewDefinition.d.ts +6 -6
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/domains/FunctionalElements.d.ts +1 -1
- package/lib/esm/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/esm/domains/FunctionalElements.js.map +1 -1
- package/lib/esm/domains/GenericElements.d.ts +2 -2
- package/lib/esm/domains/GenericElements.d.ts.map +1 -1
- package/lib/esm/domains/GenericElements.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.d.ts +2 -2
- package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/esm/internal/ChannelAdmin.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 +13 -13
|
@@ -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) IterableIterator instance patches to be stored
|
|
855
708
|
* @internal
|
|
856
709
|
*/
|
|
857
710
|
static storeChangedInstancesForSemanticRebase(db, txnId, instancePatches) {
|
|
@@ -861,7 +714,33 @@ export class BriefcaseManager {
|
|
|
861
714
|
if (IModelJsFs.existsSync(targetDir))
|
|
862
715
|
IModelJsFs.removeSync(targetDir);
|
|
863
716
|
IModelJsFs.recursiveMkDirSync(targetDir);
|
|
864
|
-
|
|
717
|
+
const BATCH_SIZE = 100;
|
|
718
|
+
let isFirst = true;
|
|
719
|
+
let batchParts = [];
|
|
720
|
+
const flushBatch = () => {
|
|
721
|
+
if (batchParts.length === 0)
|
|
722
|
+
return;
|
|
723
|
+
IModelJsFs.appendFileSync(filePath, batchParts.join(""));
|
|
724
|
+
batchParts = [];
|
|
725
|
+
};
|
|
726
|
+
IModelJsFs.writeFileSync(filePath, "[");
|
|
727
|
+
for (const instancePatch of instancePatches) {
|
|
728
|
+
// 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.
|
|
729
|
+
// Once we have conflict resolution on instance level, we can consider taking old stage of updated instances as well.
|
|
730
|
+
if (instancePatch.$meta.op === "Updated" && instancePatch.$meta.stage === "Old")
|
|
731
|
+
continue;
|
|
732
|
+
const { $meta, ...rest } = instancePatch;
|
|
733
|
+
const transformedInstance = {
|
|
734
|
+
...rest,
|
|
735
|
+
$meta: { op: $meta.op, stage: $meta.stage, isIndirectChange: $meta.isIndirectChange },
|
|
736
|
+
};
|
|
737
|
+
batchParts.push(`${isFirst ? "" : ","}\n${JSON.stringify(transformedInstance, Base64EncodedString.replacer)}`);
|
|
738
|
+
isFirst = false;
|
|
739
|
+
if (batchParts.length >= BATCH_SIZE)
|
|
740
|
+
flushBatch();
|
|
741
|
+
}
|
|
742
|
+
flushBatch();
|
|
743
|
+
IModelJsFs.appendFileSync(filePath, "\n]");
|
|
865
744
|
}
|
|
866
745
|
/**
|
|
867
746
|
* Gets the base path for semantic rebase local files
|
|
@@ -874,7 +753,7 @@ export class BriefcaseManager {
|
|
|
874
753
|
}
|
|
875
754
|
/**
|
|
876
755
|
* Stores schemas for semantic rebase locally in appropriate folder structure
|
|
877
|
-
* @param db The
|
|
756
|
+
* @param db The [BriefcaseDb]($backend) instance for storing the schemas against a txn
|
|
878
757
|
* @param txnId The txn id for which we are storing the schemas
|
|
879
758
|
* @param schemaFileNames The schema file paths or schema xml strings to be stored
|
|
880
759
|
* @internal
|
|
@@ -900,7 +779,7 @@ export class BriefcaseManager {
|
|
|
900
779
|
}
|
|
901
780
|
/**
|
|
902
781
|
* Gets schemas for semantic rebase for a txn
|
|
903
|
-
* @param db The
|
|
782
|
+
* @param db The [BriefcaseDb]($backend) instance for getting the locally stored schemas against a txn
|
|
904
783
|
* @param txnId The txn id for which we are getting the schemas
|
|
905
784
|
* @returns the schema file paths
|
|
906
785
|
* @internal
|
|
@@ -912,21 +791,25 @@ export class BriefcaseManager {
|
|
|
912
791
|
}
|
|
913
792
|
/**
|
|
914
793
|
* Get the changed instances data for semantic rebase for a txn
|
|
915
|
-
* @param db - The
|
|
794
|
+
* @param db - The [BriefcaseDb]($backend) instance for getting the locally stored changed instances against a txn
|
|
916
795
|
* @param txnId - The txn id for which we are getting the changed instances
|
|
917
796
|
* @returns Instance patches
|
|
918
797
|
* @internal
|
|
919
798
|
*/
|
|
920
|
-
static getChangedInstancesDataForTxn(db, txnId) {
|
|
799
|
+
static async *getChangedInstancesDataForTxn(db, txnId) {
|
|
921
800
|
const basePath = BriefcaseManager.getBasePathForSemanticRebaseLocalFiles(db);
|
|
922
801
|
const folderPath = path.join(basePath, txnId, BriefcaseManager.DATA_FOLDER);
|
|
923
802
|
const filePath = path.join(folderPath, BriefcaseManager.DATA_FILE_NAME);
|
|
924
|
-
const
|
|
925
|
-
|
|
803
|
+
for await (const line of IModelJsFs.readLines(filePath)) {
|
|
804
|
+
if (line === "[" || line === "]" || line === "")
|
|
805
|
+
continue;
|
|
806
|
+
const trimmedLine = line.trim().endsWith(",") ? line.trim().slice(0, -1) : line.trim(); // remove trailing comma if exists
|
|
807
|
+
yield JSON.parse(trimmedLine, Base64EncodedString.reviver);
|
|
808
|
+
}
|
|
926
809
|
}
|
|
927
810
|
/**
|
|
928
811
|
* Checks if schema folder exists for semantic rebase for a txn
|
|
929
|
-
* @param db - The
|
|
812
|
+
* @param db - The [BriefcaseDb]($backend) instance for which TO check the schema folder
|
|
930
813
|
* @param txnId - The txn id for which we are check the schema folder
|
|
931
814
|
* @returns true if exists, false otherwise
|
|
932
815
|
* @internal
|
|
@@ -938,7 +821,7 @@ export class BriefcaseManager {
|
|
|
938
821
|
}
|
|
939
822
|
/**
|
|
940
823
|
* Checks if data folder exists for semantic rebase for a txn
|
|
941
|
-
* @param db The
|
|
824
|
+
* @param db The [BriefcaseDb]($backend) instance for which to check the data folder.
|
|
942
825
|
* @param txnId The txn id for which to check the data folder
|
|
943
826
|
* @returns true if exists, false otherwise
|
|
944
827
|
* @internal
|
|
@@ -950,7 +833,7 @@ export class BriefcaseManager {
|
|
|
950
833
|
}
|
|
951
834
|
/**
|
|
952
835
|
* Deletes the schema folder for semantic rebase for a txn
|
|
953
|
-
* @param db The
|
|
836
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the schema folder.
|
|
954
837
|
* @param txnId The txn id for which to delete the schema folder
|
|
955
838
|
* @internal
|
|
956
839
|
*/
|
|
@@ -966,7 +849,7 @@ export class BriefcaseManager {
|
|
|
966
849
|
}
|
|
967
850
|
/**
|
|
968
851
|
* Deletes the data folder for semantic rebase for a txn
|
|
969
|
-
* @param db The
|
|
852
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the data folder.
|
|
970
853
|
* @param txnId The txn id for which to delete the data folder
|
|
971
854
|
* @internal
|
|
972
855
|
*/
|
|
@@ -982,7 +865,7 @@ export class BriefcaseManager {
|
|
|
982
865
|
}
|
|
983
866
|
/**
|
|
984
867
|
* Deletes rebase folders for semantic rebase
|
|
985
|
-
* @param db The
|
|
868
|
+
* @param db The [BriefcaseDb]($backend) instance for which to delete the rebase folders.
|
|
986
869
|
* @param checkIfEmpty If true, only deletes the base folder if it is empty, default is false
|
|
987
870
|
* @internal
|
|
988
871
|
*/
|