@itwin/core-backend 5.5.0-dev.1 → 5.5.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  3. package/lib/cjs/ChangesetECAdaptor.js +0 -2
  4. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  5. package/lib/cjs/IModelDb.d.ts +11 -2
  6. package/lib/cjs/IModelDb.d.ts.map +1 -1
  7. package/lib/cjs/IModelDb.js +20 -15
  8. package/lib/cjs/IModelDb.js.map +1 -1
  9. package/lib/cjs/TxnManager.d.ts.map +1 -1
  10. package/lib/cjs/TxnManager.js +2 -1
  11. package/lib/cjs/TxnManager.js.map +1 -1
  12. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  13. package/lib/esm/ChangesetECAdaptor.js +0 -2
  14. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  15. package/lib/esm/IModelDb.d.ts +11 -2
  16. package/lib/esm/IModelDb.d.ts.map +1 -1
  17. package/lib/esm/IModelDb.js +20 -15
  18. package/lib/esm/IModelDb.js.map +1 -1
  19. package/lib/esm/TxnManager.d.ts.map +1 -1
  20. package/lib/esm/TxnManager.js +2 -1
  21. package/lib/esm/TxnManager.js.map +1 -1
  22. package/lib/esm/test/annotations/Fields.test.js +2 -2
  23. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  24. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +5 -5
  25. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  26. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +39 -0
  27. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  28. package/lib/esm/test/imodel/IModel.test.js +31 -2
  29. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  30. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +432 -198
  31. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  32. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +272 -190
  33. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
  34. package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts +27 -0
  35. package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -0
  36. package/lib/esm/test/incrementalSchemaLocater/TestContext.js +136 -0
  37. package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -0
  38. package/lib/esm/test/standalone/ChangesetReader.test.js +222 -3
  39. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  40. package/lib/esm/test/standalone/RenderTimeline.test.js +1 -1
  41. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
  42. package/lib/esm/test/standalone/StandaloneDb.test.d.ts +2 -0
  43. package/lib/esm/test/standalone/StandaloneDb.test.d.ts.map +1 -0
  44. package/lib/esm/test/standalone/StandaloneDb.test.js +103 -0
  45. package/lib/esm/test/standalone/StandaloneDb.test.js.map +1 -0
  46. package/lib/esm/test/standalone/TxnManager.test.js +43 -0
  47. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  48. package/package.json +13 -13
  49. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts +0 -11
  50. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts.map +0 -1
  51. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js +0 -36
  52. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +0 -1
  53. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts +0 -20
  54. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts.map +0 -1
  55. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js +0 -126
  56. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +0 -1
  57. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +0 -24
  58. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +0 -1
  59. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +0 -67
  60. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TxnManager.d.ts","sourceRoot":"","sources":["../../src/TxnManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACG,OAAO,EAAmD,oBAAoB,EAAE,QAAQ,EAAa,UAAU,EAAE,YAAY,EACtI,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAe,yBAAyB,EAAE,sBAAsB,EAA4D,MAAM,oBAAoB,CAAC;AAE/M,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAExE,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAG9G;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,0BAA0B,CAAC;IAC7C,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,0BAA0B,CAAC;IAC7C,4IAA4I;IAC5I,QAAQ,CAAC,OAAO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539
539
  }
540
540
  /** @internal */
541
541
  _onChangesApplied() {
542
- this._iModel.clearCaches();
542
+ // Should only clear instance caches, not all caches
543
+ this._iModel.clearCaches({ instanceCachesOnly: true });
543
544
  ChangedEntitiesProc.process(this._iModel, this);
544
545
  this.onChangesApplied.raiseEvent();
545
546
  IpcHost_1.IpcHost.notifyTxns(this._iModel, "notifyChangesApplied");
@@ -1 +1 @@
1
- {"version":3,"file":"TxnManager.js","sourceRoot":"","sources":["../../src/TxnManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAyEH,wDAIC;AA3ED,+BAA+B;AAC/B,sDAE6B;AAC7B,oDAA+M;AAC/M,mEAAgE;AAEhE,uCAAoC;AAGpC,gDAA+C;AAC/C,4EAA8G;AAC9G,yDAAsD;AA0DtD,oCAAoC;AACpC,SAAgB,sBAAsB,CAAC,GAAW;IAChD,MAAM,OAAO,GAAG,mBAAmB,CAAC,WAAW,CAAC;IAChD,mBAAmB,CAAC,WAAW,GAAG,GAAG,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iIAAiI;AACjI,MAAM,oBAAoB;IACR,SAAS,GAAG,IAAI,+BAAgB,EAAE,CAAC;IAClC,aAAa,GAAa,EAAE,CAAC;IAC7B,SAAS,CAAuB;IAEjD,YAAmB,QAA8B;QAC/C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,QAAoB,EAAE,OAAmB;QACrD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,IAAA,qBAAM,EAAC,UAAU,IAAI,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YACxD,u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I,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,mBAAmB,CAAC,QAAoB;QAC7C,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,QAAQ,EAAE,CAAC;QACb,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,6BAA6B,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,wBAAwB,CAAC,QAA6B;QACjE,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,QAAQ,EAAE,CAAC;QACnB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,6BAA6B,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA9iBD,gCA8iBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport * as touch from \"touch\";\r\nimport {\r\n assert, BeEvent, BentleyError, compareStrings, CompressedId64Set, DbConflictResolution, DbResult, Id64Array, Id64String, IModelStatus, IndexMap, Logger, OrderedId64Array\r\n} from \"@itwin/core-bentley\";\r\nimport { ChangesetIndexAndId, EntityIdAndClassIdIterable, IModelError, ModelGeometryChangesProps, ModelIdAndGeometryGuid, NotifyEntitiesChangedArgs, NotifyEntitiesChangedMetadata } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BriefcaseDb, SaveChangesArgs, StandaloneDb } from \"./IModelDb\";\r\nimport { IpcHost } from \"./IpcHost\";\r\nimport { Relationship, RelationshipProps } from \"./Relationship\";\r\nimport { SqliteStatement } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { DbRebaseChangesetConflictArgs, RebaseChangesetConflictArgs } from \"./internal/ChangesetConflictArgs\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\n\r\n/** A string that identifies a Txn.\r\n * @public @preview\r\n */\r\nexport type TxnIdString = string;\r\n\r\n/** An error generated during dependency validation.\r\n * @see [[TxnManager.validationErrors]].\r\n * @public @preview\r\n */\r\nexport interface ValidationError {\r\n /** If true, txn is aborted. */\r\n fatal: boolean;\r\n /** The type of error. */\r\n errorType: string;\r\n /** Optional description of what went wrong. */\r\n message?: string;\r\n}\r\n\r\n/** Describes a set of [[Element]]s or [[Model]]s that changed as part of a transaction.\r\n * @see [[TxnManager.onElementsChanged]] and [[TxnManager.onModelsChanged]].\r\n * @public @preview\r\n */\r\nexport interface TxnChangedEntities {\r\n /** The entities that were inserted by the transaction. */\r\n readonly inserts: EntityIdAndClassIdIterable;\r\n /** The entities that were deleted by the transaction. */\r\n readonly deletes: EntityIdAndClassIdIterable;\r\n /** The entities that were modified by the transaction, including any [[Element]]s for which one of their [[ElementAspect]]s was changed. */\r\n readonly updates: EntityIdAndClassIdIterable;\r\n}\r\n\r\n/** Arguments supplied to [[TxnManager.queryLocalChanges]].\r\n * @beta\r\n */\r\nexport interface QueryLocalChangesArgs {\r\n /** If supplied and non-empty, restricts the results to include only EC instances belonging to the specified classes or subclasses thereof. */\r\n readonly includedClasses?: string[];\r\n /** If `true`, include changes that have not yet been saved. */\r\n readonly includeUnsavedChanges?: boolean;\r\n}\r\n\r\n/** Represents a change (insertion, deletion, or modification) to a single EC instance made in a local [[BriefcaseDb]].\r\n * @see [[TxnManager.queryLocalChanges]] to iterate all of the changed instances.\r\n* @beta\r\n*/\r\nexport interface ChangeInstanceKey {\r\n /** ECInstanceId of the instance. */\r\n id: Id64String;\r\n /** Fully-qualified class name of the instance. */\r\n classFullName: string;\r\n /** The type of change. */\r\n changeType: \"inserted\" | \"updated\" | \"deleted\";\r\n}\r\n\r\ntype EntitiesChangedEvent = BeEvent<(changes: TxnChangedEntities) => void>;\r\n\r\n/** Strictly for tests. @internal */\r\nexport function setMaxEntitiesPerEvent(max: number): number {\r\n const prevMax = ChangedEntitiesProc.maxPerEvent;\r\n ChangedEntitiesProc.maxPerEvent = max;\r\n return prevMax;\r\n}\r\n\r\n/** Maintains an ordered array of entity Ids and a parallel array containing the index of the corresponding entity's class Id. */\r\nclass ChangedEntitiesArray {\r\n public readonly entityIds = new OrderedId64Array();\r\n private readonly _classIndices: number[] = [];\r\n private readonly _classIds: IndexMap<Id64String>;\r\n\r\n public constructor(classIds: IndexMap<Id64String>) {\r\n this._classIds = classIds;\r\n }\r\n\r\n public insert(entityId: Id64String, classId: Id64String): void {\r\n const entityIndex = this.entityIds.insert(entityId);\r\n const classIndex = this._classIds.insert(classId);\r\n assert(classIndex >= 0);\r\n if (this.entityIds.length !== this._classIndices.length) {\r\n // New entity - insert corresponding class index entry.\r\n this._classIndices.splice(entityIndex, 0, classIndex);\r\n } else {\r\n // Existing entity - update corresponding class index.\r\n // (We do this because apparently connectors can (very rarely) change the class Id of an existing element).\r\n this._classIndices[entityIndex] = classIndex;\r\n }\r\n\r\n assert(this.entityIds.length === this._classIndices.length);\r\n }\r\n\r\n public clear(): void {\r\n this.entityIds.clear();\r\n this._classIndices.length = 0;\r\n }\r\n\r\n public addToChangedEntities(entities: NotifyEntitiesChangedArgs, type: \"deleted\" | \"inserted\" | \"updated\"): void {\r\n if (this.entityIds.length > 0)\r\n entities[type] = CompressedId64Set.compressIds(this.entityIds);\r\n\r\n entities[`${type}Meta`] = this._classIndices;\r\n }\r\n\r\n public iterable(classIds: Id64Array): EntityIdAndClassIdIterable {\r\n function* iterator(entityIds: ReadonlyArray<Id64String>, classIndices: number[]) {\r\n const entity = { id: \"\", classId: \"\" };\r\n for (let i = 0; i < entityIds.length; i++) {\r\n entity.id = entityIds[i];\r\n entity.classId = classIds[classIndices[i]];\r\n yield entity;\r\n }\r\n }\r\n\r\n return {\r\n [Symbol.iterator]: () => iterator(this.entityIds.array, this._classIndices),\r\n };\r\n }\r\n}\r\n\r\nclass ChangedEntitiesProc {\r\n private readonly _classIds = new IndexMap<Id64String>((lhs, rhs) => compareStrings(lhs, rhs));\r\n private readonly _inserted = new ChangedEntitiesArray(this._classIds);\r\n private readonly _deleted = new ChangedEntitiesArray(this._classIds);\r\n private readonly _updated = new ChangedEntitiesArray(this._classIds);\r\n private _currSize = 0;\r\n\r\n public static maxPerEvent = 1000;\r\n\r\n public static process(iModel: BriefcaseDb | StandaloneDb, mgr: TxnManager): void {\r\n if (mgr.isDisposed) {\r\n // The iModel is being closed. Do not prepare new sqlite statements.\r\n return;\r\n }\r\n\r\n this.processChanges(iModel, mgr.onElementsChanged, \"notifyElementsChanged\");\r\n this.processChanges(iModel, mgr.onModelsChanged, \"notifyModelsChanged\");\r\n }\r\n\r\n private populateMetadata(db: BriefcaseDb | StandaloneDb, classIds: Id64Array): NotifyEntitiesChangedMetadata[] {\r\n // Ensure metadata for all class Ids is loaded. Loading metadata for a derived class loads metadata for all of its superclasses.\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const classIdsToLoad = classIds.filter((x) => undefined === db.classMetaDataRegistry.findByClassId(x));\r\n if (classIdsToLoad.length > 0) {\r\n const classIdsStr = classIdsToLoad.join(\",\");\r\n const sql = `SELECT ec_class.Name, ec_class.Id, ec_schema.Name FROM ec_class JOIN ec_schema WHERE ec_schema.Id = ec_class.SchemaId AND ec_class.Id IN (${classIdsStr})`;\r\n db.withPreparedSqliteStatement(sql, (stmt) => {\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const classFullName = `${stmt.getValueString(2)}:${stmt.getValueString(0)}`;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n db.tryGetMetaData(classFullName);\r\n }\r\n });\r\n }\r\n\r\n // Define array indices for the metadata array entries correlating to the class Ids in the input list.\r\n const nameToIndex = new Map<string, number>();\r\n for (const classId of classIds) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const meta = db.classMetaDataRegistry.findByClassId(classId);\r\n nameToIndex.set(meta?.ecclass ?? \"\", nameToIndex.size);\r\n }\r\n\r\n const result: NotifyEntitiesChangedMetadata[] = [];\r\n\r\n function addMetadata(name: string, index: number): void {\r\n const bases: number[] = [];\r\n result[index] = { name, bases };\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const meta = db.tryGetMetaData(name);\r\n if (!meta) {\r\n return;\r\n }\r\n\r\n for (const baseClassName of meta.baseClasses) {\r\n let baseClassIndex = nameToIndex.get(baseClassName);\r\n if (undefined === baseClassIndex) {\r\n baseClassIndex = nameToIndex.size;\r\n nameToIndex.set(baseClassName, baseClassIndex);\r\n addMetadata(baseClassName, baseClassIndex);\r\n }\r\n\r\n bases.push(baseClassIndex);\r\n }\r\n }\r\n\r\n for (const [name, index] of nameToIndex) {\r\n if (index >= classIds.length) {\r\n // Entries beyond this are base classes for the classes in `classIds` - don't reprocess them.\r\n break;\r\n }\r\n\r\n addMetadata(name, index);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private sendEvent(iModel: BriefcaseDb | StandaloneDb, evt: EntitiesChangedEvent, evtName: \"notifyElementsChanged\" | \"notifyModelsChanged\") {\r\n if (this._currSize === 0)\r\n return;\r\n\r\n const classIds = this._classIds.toArray();\r\n\r\n // Notify backend listeners.\r\n const txnEntities: TxnChangedEntities = {\r\n inserts: this._inserted.iterable(classIds),\r\n deletes: this._deleted.iterable(classIds),\r\n updates: this._updated.iterable(classIds),\r\n };\r\n evt.raiseEvent(txnEntities);\r\n\r\n // Notify frontend listeners.\r\n const entities: NotifyEntitiesChangedArgs = {\r\n insertedMeta: [],\r\n updatedMeta: [],\r\n deletedMeta: [],\r\n meta: this.populateMetadata(iModel, classIds),\r\n };\r\n\r\n this._inserted.addToChangedEntities(entities, \"inserted\");\r\n this._deleted.addToChangedEntities(entities, \"deleted\");\r\n this._updated.addToChangedEntities(entities, \"updated\");\r\n\r\n IpcHost.notifyTxns(iModel, evtName, entities);\r\n\r\n // Reset state.\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n this._updated.clear();\r\n this._classIds.clear();\r\n this._currSize = 0;\r\n }\r\n\r\n private static processChanges(iModel: BriefcaseDb | StandaloneDb, changedEvent: EntitiesChangedEvent, evtName: \"notifyElementsChanged\" | \"notifyModelsChanged\") {\r\n try {\r\n const maxSize = this.maxPerEvent;\r\n const changes = new ChangedEntitiesProc();\r\n const select = \"notifyElementsChanged\" === evtName\r\n ? \"SELECT ElementId, ChangeType, ECClassId FROM temp.txn_Elements\"\r\n : \"SELECT ModelId, ChangeType, ECClassId FROM temp.txn_Models\";\r\n iModel.withPreparedSqliteStatement(select, (sql: SqliteStatement) => {\r\n const stmt = sql.stmt;\r\n while (sql.step() === DbResult.BE_SQLITE_ROW) {\r\n const id = stmt.getValueId(0);\r\n const classId = stmt.getValueId(2);\r\n switch (stmt.getValueInteger(1)) {\r\n case 0:\r\n changes._inserted.insert(id, classId);\r\n break;\r\n case 1:\r\n changes._updated.insert(id, classId);\r\n break;\r\n case 2:\r\n changes._deleted.insert(id, classId);\r\n break;\r\n }\r\n\r\n if (++changes._currSize >= maxSize)\r\n changes.sendEvent(iModel, changedEvent, evtName);\r\n }\r\n });\r\n\r\n changes.sendEvent(iModel, changedEvent, evtName);\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelDb, BentleyError.getErrorMessage(err));\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\ninterface IConflictHandler {\r\n handler: (arg: RebaseChangesetConflictArgs) => DbConflictResolution | undefined;\r\n next: IConflictHandler | undefined;\r\n id: string;\r\n}\r\n\r\n/**\r\n * @alpha\r\n * Transaction types\r\n */\r\nexport type TxnType = \"Data\" | \"ECSchema\" | \"Ddl\";\r\n\r\n/**\r\n * @alpha\r\n * Transaction modes\r\n */\r\nexport type TxnMode = \"direct\" | \"indirect\";\r\n\r\n/**\r\n * @alpha\r\n * Represents the properties of a transaction within the transaction manager.\r\n *\r\n * @property id - The unique identifier for the transaction.\r\n * @property sessionId - The identifier of the session to which the transaction belongs.\r\n * @property nextId - (Optional) The identifier of the next transaction in the sequence.\r\n * @property prevId - (Optional) The identifier of the previous transaction in the sequence.\r\n * @property props - The arguments or properties associated with the save changes operation.\r\n * @property type - The type of transaction, which can be \"Data\", \"ECSchema\", or \"Ddl\".\r\n * @property reversed - Indicates whether the transaction has been reversed.\r\n * @property grouped - Indicates whether the transaction is grouped with others.\r\n * @property timestamp - The timestamp when the transaction was created.\r\n */\r\nexport interface TxnProps {\r\n id: TxnIdString;\r\n sessionId: number;\r\n nextId?: TxnIdString;\r\n prevId?: TxnIdString;\r\n props: SaveChangesArgs;\r\n type: TxnType;\r\n reversed: boolean;\r\n grouped: boolean;\r\n timestamp: string;\r\n}\r\n\r\n/**\r\n * Manages the process of merging and rebasing local changes (transactions) in a [[BriefcaseDb]] or [[StandaloneDb]].\r\n *\r\n * The `RebaseManager` coordinates the rebase of local transactions when pulling and merging changes from other sources,\r\n * such as remote repositories or other users. It provides mechanisms to handle transaction conflicts, register custom conflict\r\n * handlers, and manage the rebase workflow. This includes resuming rebases, invoking user-defined handlers for conflict resolution,\r\n * and tracking the current merge/rebase state.\r\n *\r\n * Key responsibilities:\r\n * - Orchestrates the rebase of local transactions after a pull/merge operation.\r\n * - Allows registration and removal of custom conflict handlers to resolve changeset conflicts during rebase.\r\n * - Provides methods to check the current merge/rebase state.\r\n * - Raises events before and after each transaction is rebased.\r\n * - Ensures changes are saved or aborted appropriately based on the outcome of the rebase process.\r\n *\r\n * @alpha\r\n */\r\nexport class RebaseManager {\r\n private _conflictHandlers?: IConflictHandler;\r\n private _customHandler?: RebaseHandler;\r\n private _aborting: boolean = false;\r\n public constructor(private _iModel: BriefcaseDb | StandaloneDb) { }\r\n\r\n /**\r\n * Resumes the rebase process for the current iModel, applying any pending local changes\r\n * on top of the latest pulled changes from the remote source.\r\n *\r\n * This method performs the following steps:\r\n * 1. Begins the rebase process using the native database.\r\n * 2. Iterates through each transaction that needs to be rebased:\r\n * - Retrieves transaction properties.\r\n * - Raises events before and after rebasing each transaction.\r\n * - Optionally reinstates local changes based on the rebase handler.\r\n * - Optionally recomputes transaction data using the rebase handler.\r\n * - Updates the transaction in the native database.\r\n * 3. Ends the rebase process and saves changes if the database is not read-only.\r\n * 4. Drops any restore point associated with the pull-merge operation.\r\n *\r\n * If an error occurs during the process, the rebase is aborted and the error is rethrown.\r\n *\r\n * @throws {Error} If a transaction cannot be found or if any step in the rebase process fails.\r\n */\r\n public async resume() {\r\n const nativeDb = this._iModel[_nativeDb];\r\n const txns = this._iModel.txns;\r\n try {\r\n const reversedTxns = nativeDb.pullMergeRebaseBegin();\r\n txns.onRebaseBegin.raiseEvent(reversedTxns);\r\n let txnId = nativeDb.pullMergeRebaseNext();\r\n while (txnId) {\r\n const txnProps = txns.getTxnProps(txnId);\r\n if (!txnProps) {\r\n throw new Error(`Transaction ${txnId} not found`);\r\n }\r\n\r\n txns.onRebaseTxnBegin.raiseEvent(txnProps);\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, `Rebasing local changes for transaction ${txnId}`);\r\n const shouldReinstate = this._customHandler?.shouldReinstate(txnProps) ?? true;\r\n if (shouldReinstate) {\r\n nativeDb.pullMergeRebaseReinstateTxn();\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, `Reinstated local changes for transaction ${txnId}`);\r\n }\r\n\r\n if (this._customHandler) {\r\n await this._customHandler.recompute(txnProps);\r\n }\r\n\r\n nativeDb.pullMergeRebaseUpdateTxn();\r\n txns.onRebaseTxnEnd.raiseEvent(txnProps);\r\n\r\n txnId = nativeDb.pullMergeRebaseNext();\r\n }\r\n\r\n nativeDb.pullMergeRebaseEnd();\r\n if (!nativeDb.isReadonly) {\r\n nativeDb.saveChanges(\"Merge.\");\r\n }\r\n if (BriefcaseManager.containsRestorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME)) {\r\n BriefcaseManager.dropRestorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME);\r\n }\r\n } catch (err) {\r\n nativeDb.pullMergeRebaseAbortTxn();\r\n throw err;\r\n }\r\n finally {\r\n txns.onRebaseEnd.raiseEvent();\r\n }\r\n }\r\n\r\n /**\r\n * Determines whether the current transaction can be aborted.\r\n *\r\n * This method checks if a transaction is currently in progress and if a specific restore point,\r\n * identified by `BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME`, exists in the briefcase manager.\r\n *\r\n * @returns {boolean} Returns `true` if a transaction is in progress and the required restore point exists; otherwise, returns `false`.\r\n */\r\n public canAbort() {\r\n return this.inProgress() && BriefcaseManager.containsRestorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME);\r\n }\r\n\r\n /**\r\n * Aborts the current transaction by restoring the iModel to a predefined restore point.\r\n *\r\n * If a restore point is available (as determined by `canAbort()`), this method restores the iModel\r\n * to the state saved at the restore point named by `BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME`.\r\n * If no restore point is available, an error is thrown.\r\n *\r\n * @returns A promise that resolves when the restore operation is complete.\r\n * @throws {Error} If there is no restore point to abort to.\r\n */\r\n public async abort(): Promise<void> {\r\n if (this.canAbort()) {\r\n this._aborting = true;\r\n try {\r\n await BriefcaseManager.restorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME);\r\n } finally {\r\n this._aborting = false;\r\n }\r\n } else {\r\n throw new Error(\"No restore point to abort to\");\r\n }\r\n }\r\n\r\n /**\r\n * Sets the handler to be invoked for rebase operations.\r\n *\r\n * @param handler - The {@link RebaseHandler} to handle rebase events.\r\n */\r\n public setCustomHandler(handler: RebaseHandler) {\r\n if (this._customHandler) {\r\n Logger.logWarning(BackendLoggerCategory.IModelDb, \"Rebase handler already set\");\r\n }\r\n this._customHandler = handler;\r\n }\r\n\r\n /**\r\n * Determines whether a transaction is currently in progress.\r\n *\r\n * @returns {boolean} Returns `true` if there is an active transaction stage, otherwise `false`.\r\n */\r\n public inProgress() {\r\n return this._iModel[_nativeDb].pullMergeGetStage() !== \"None\";\r\n }\r\n\r\n /**\r\n * Indicates whether the current transaction manager is in the process of aborting a transaction.\r\n *\r\n * @returns `true` if the transaction manager is currently aborting; otherwise, `false`.\r\n */\r\n public get isAborting(): boolean {\r\n return this._aborting;\r\n }\r\n\r\n /**\r\n * Indicates whether the current transaction manager is in the \"Rebasing\" stage.\r\n *\r\n * This property checks the internal native database's merge stage to determine if a rebase operation is in progress.\r\n *\r\n * @returns `true` if the transaction manager is currently rebasing; otherwise, `false`.\r\n */\r\n public get isRebasing() {\r\n return this._iModel[_nativeDb].pullMergeGetStage() === \"Rebasing\";\r\n }\r\n\r\n /**\r\n * Indicates whether the current iModel is in the process of merging changes from a pull operation.\r\n *\r\n * @returns `true` if the iModel is currently merging changes; otherwise, `false`.\r\n */\r\n public get isMerging() {\r\n return this._iModel[_nativeDb].pullMergeGetStage() === \"Merging\";\r\n }\r\n\r\n /**\r\n * Attempts to resolve a changeset conflict by invoking registered conflict handlers in sequence.\r\n *\r\n * Iterates through the linked list of conflict handlers, passing the provided conflict arguments to each handler.\r\n * If a handler returns a defined resolution, logs the resolution and returns it immediately.\r\n * If no handler resolves the conflict, returns `undefined`.\r\n *\r\n * @param args - The arguments describing the changeset conflict to resolve.\r\n * @returns The conflict resolution provided by a handler, or `undefined` if no handler resolves the conflict.\r\n */\r\n public onConflict(args: RebaseChangesetConflictArgs): DbConflictResolution | undefined {\r\n let curr = this._conflictHandlers;\r\n while (curr) {\r\n const resolution = curr.handler(args);\r\n if (resolution !== undefined) {\r\n Logger.logTrace(BackendLoggerCategory.IModelDb, `Conflict handler ${curr.id} resolved conflict`);\r\n return resolution;\r\n }\r\n curr = curr.next;\r\n }\r\n return undefined\r\n }\r\n\r\n /**\r\n * Registers a new conflict handler for rebase changeset conflicts.\r\n *\r\n * @param args - An object containing:\r\n * - `id`: A unique identifier for the conflict handler.\r\n * - `handler`: A function that handles rebase changeset conflicts and returns a `DbConflictResolution` or `undefined`.\r\n * @throws IModelError if a conflict handler with the same `id` already exists.\r\n *\r\n * @remarks\r\n * Conflict handlers are used during changeset rebase operations to resolve conflicts.\r\n * Each handler must have a unique `id`. Attempting to register a handler with a duplicate `id` will result in an error.\r\n */\r\n public addConflictHandler(args: { id: string, handler: (args: RebaseChangesetConflictArgs) => DbConflictResolution | undefined }) {\r\n const idExists = (id: string) => {\r\n let curr = this._conflictHandlers;\r\n while (curr) {\r\n if (curr.id === id)\r\n return true;\r\n curr = curr.next;\r\n }\r\n return false;\r\n }\r\n if (idExists(args.id))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Conflict handler with id ${args.id} already exists`);\r\n this._conflictHandlers = { ...args, next: this._conflictHandlers };\r\n }\r\n\r\n /**\r\n * Removes a conflict handler from the internal linked list by its identifier.\r\n *\r\n * @param id - The unique identifier of the conflict handler to remove.\r\n *\r\n * If the handler with the specified `id` exists in the list, it will be removed.\r\n * If no handler with the given `id` is found, the method does nothing.\r\n */\r\n public removeConflictHandler(id: string) {\r\n if (!this._conflictHandlers)\r\n return;\r\n\r\n if (this._conflictHandlers?.id === id) {\r\n this._conflictHandlers = this._conflictHandlers.next;\r\n return;\r\n }\r\n\r\n let prev = this._conflictHandlers;\r\n let curr = this._conflictHandlers?.next;\r\n while (curr) {\r\n if (curr.id === id) {\r\n prev.next = curr.next;\r\n return;\r\n }\r\n prev = curr;\r\n curr = curr.next;\r\n }\r\n }\r\n}\r\n\r\n/** Manages local changes to a [[BriefcaseDb]] or [[StandaloneDb]] via [Txns]($docs/learning/InteractiveEditing.md)\r\n * @public @preview\r\n */\r\nexport class TxnManager {\r\n /** @internal */\r\n private _isDisposed = false;\r\n /** @internal */\r\n private _withIndirectChangeRefCounter = 0;\r\n /** @internal */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /** @internal */\r\n public readonly rebaser: RebaseManager;\r\n\r\n /** @internal */\r\n constructor(private _iModel: BriefcaseDb | StandaloneDb) {\r\n this.rebaser = new RebaseManager(_iModel);\r\n _iModel.onBeforeClose.addOnce(() => {\r\n this._isDisposed = true;\r\n });\r\n }\r\n\r\n /** Array of errors from dependency propagation */\r\n public readonly validationErrors: ValidationError[] = [];\r\n\r\n private get _nativeDb() { return this._iModel[_nativeDb]; }\r\n private _getElementClass(elClassName: string): typeof Element {\r\n return this._iModel.getJsClass(elClassName) as unknown as typeof Element;\r\n }\r\n private _getRelationshipClass(relClassName: string): typeof Relationship {\r\n return this._iModel.getJsClass<typeof Relationship>(relClassName);\r\n }\r\n\r\n /** If a -watch file exists for this iModel, update its timestamp so watching processes can be\r\n * notified that we've modified the briefcase.\r\n * @internal Used by IModelDb on push/pull.\r\n */\r\n public touchWatchFile(): void {\r\n // This is an async call. We don't have any reason to await it.\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n touch(this._iModel.watchFilePathName, { nocreate: true });\r\n }\r\n\r\n /** @internal */\r\n protected _onBeforeOutputsHandled(elClassName: string, elId: Id64String): void {\r\n (this._getElementClass(elClassName) as any).onBeforeOutputsHandled(elId, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onAllInputsHandled(elClassName: string, elId: Id64String): void {\r\n (this._getElementClass(elClassName) as any).onAllInputsHandled(elId, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onRootChanged(props: RelationshipProps): void {\r\n this._getRelationshipClass(props.classFullName).onRootChanged(props, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onDeletedDependency(props: RelationshipProps): void {\r\n this._getRelationshipClass(props.classFullName).onDeletedDependency(props, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onBeginValidate() { this.validationErrors.length = 0; }\r\n\r\n /** called from native code after validation of a Txn, either from saveChanges or apply changeset.\r\n * @internal\r\n */\r\n protected _onEndValidate() {\r\n ChangedEntitiesProc.process(this._iModel, this);\r\n this.onEndValidation.raiseEvent();\r\n // TODO: if (this.validationErrors.length !== 0) throw new IModelError(validation ...)\r\n }\r\n\r\n /** @internal */\r\n protected _onGeometryChanged(modelProps: ModelGeometryChangesProps[]) {\r\n this.onGeometryChanged.raiseEvent(modelProps);\r\n IpcHost.notifyEditingScope(this._iModel, \"notifyGeometryChanged\", modelProps); // send to frontend\r\n }\r\n\r\n /** @internal */\r\n protected _onGeometryGuidsChanged(changes: ModelIdAndGeometryGuid[]): void {\r\n this.onModelGeometryChanged.raiseEvent(changes);\r\n IpcHost.notifyTxns(this._iModel, \"notifyGeometryGuidsChanged\", changes);\r\n }\r\n\r\n /** @internal */\r\n protected _onCommit() {\r\n this.onCommit.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyCommit\");\r\n }\r\n\r\n /** @internal */\r\n protected _onCommitted() {\r\n this.touchWatchFile();\r\n this.onCommitted.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyCommitted\", this.hasPendingTxns, Date.now());\r\n }\r\n\r\n /** @internal */\r\n protected _onReplayExternalTxns() {\r\n this.onReplayExternalTxns.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyReplayExternalTxns\");\r\n }\r\n\r\n /** @internal */\r\n protected _onReplayedExternalTxns() {\r\n this.onReplayedExternalTxns.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyReplayedExternalTxns\");\r\n }\r\n\r\n /** @internal */\r\n protected _onChangesApplied() {\r\n this._iModel.clearCaches();\r\n ChangedEntitiesProc.process(this._iModel, this);\r\n this.onChangesApplied.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyChangesApplied\");\r\n }\r\n\r\n /** @internal */\r\n protected _onBeforeUndoRedo(isUndo: boolean) {\r\n this.onBeforeUndoRedo.raiseEvent(isUndo);\r\n IpcHost.notifyTxns(this._iModel, \"notifyBeforeUndoRedo\", isUndo);\r\n }\r\n\r\n /** @internal */\r\n protected _onAfterUndoRedo(isUndo: boolean) {\r\n this.touchWatchFile();\r\n this.onAfterUndoRedo.raiseEvent(isUndo);\r\n IpcHost.notifyTxns(this._iModel, \"notifyAfterUndoRedo\", isUndo);\r\n }\r\n\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _onChangesPushed(changeset: ChangesetIndexAndId) {\r\n this.touchWatchFile();\r\n this.onChangesPushed.raiseEvent(changeset);\r\n IpcHost.notifyTxns(this._iModel, \"notifyPushedChanges\", changeset);\r\n }\r\n\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _onChangesPulled(changeset: ChangesetIndexAndId) {\r\n this.touchWatchFile();\r\n this.onChangesPulled.raiseEvent(changeset);\r\n IpcHost.notifyTxns(this._iModel, \"notifyPulledChanges\", changeset);\r\n }\r\n\r\n private _onRebaseLocalTxnConflict(internalArg: DbRebaseChangesetConflictArgs): DbConflictResolution {\r\n const args = new RebaseChangesetConflictArgs(internalArg, this._iModel);\r\n\r\n const getChangeMetaData = () => {\r\n return {\r\n parent: this._iModel.changeset,\r\n txn: args.txn,\r\n table: args.tableName,\r\n op: args.opcode,\r\n cause: args.cause,\r\n indirect: args.indirect,\r\n primarykey: args.getPrimaryKeyValues(),\r\n fkConflictCount: args.cause === \"ForeignKey\" ? args.getForeignKeyConflicts() : undefined,\r\n };\r\n }\r\n\r\n // Default conflict resolution for which custom handler is never called.\r\n if (args.cause === \"Data\" && !args.indirect) {\r\n if (args.tableName === \"be_Prop\") {\r\n if (args.getValueText(0, \"Old\") === \"ec_Db\" && args.getValueText(1, \"Old\") === \"localDbInfo\") {\r\n return DbConflictResolution.Skip;\r\n }\r\n }\r\n if (args.tableName.startsWith(\"ec_\")) {\r\n return DbConflictResolution.Skip;\r\n }\r\n }\r\n\r\n if (args.cause === \"Conflict\") {\r\n if (args.tableName.startsWith(\"ec_\")) {\r\n return DbConflictResolution.Skip;\r\n }\r\n }\r\n\r\n try {\r\n const resolution = this.rebaser.onConflict(args);\r\n if (resolution !== undefined)\r\n return resolution;\r\n } catch (err) {\r\n const msg = `Rebase failed. Custom conflict handler should not throw exception. Aborting txn. ${BentleyError.getErrorMessage(err)}`;\r\n Logger.logError(BackendLoggerCategory.IModelDb, msg, getChangeMetaData());\r\n args.setLastError(msg);\r\n return DbConflictResolution.Abort;\r\n }\r\n\r\n if (args.cause === \"Data\" && !args.indirect) {\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, \"UPDATE/DELETE before value do not match with one in db or CASCADE action was triggered. Local change will replace existing.\", getChangeMetaData());\r\n return DbConflictResolution.Replace;\r\n }\r\n\r\n if (args.cause === \"Conflict\") {\r\n const msg = \"PRIMARY KEY insert conflict. Aborting rebase.\";\r\n Logger.logError(BackendLoggerCategory.IModelDb, msg, getChangeMetaData());\r\n args.setLastError(msg);\r\n return DbConflictResolution.Abort;\r\n }\r\n\r\n if (args.cause === \"ForeignKey\") {\r\n const msg = `Foreign key conflicts in ChangeSet. Aborting rebase.`;\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, msg, getChangeMetaData());\r\n args.setLastError(msg);\r\n return DbConflictResolution.Abort;\r\n }\r\n\r\n if (args.cause === \"NotFound\") {\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, \"PRIMARY KEY not found. Skipping local change.\", getChangeMetaData());\r\n return DbConflictResolution.Skip;\r\n }\r\n\r\n if (args.cause === \"Constraint\") {\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, \"Constraint violation detected. Generally caused by db constraints like UNIQUE index. Skipping local change.\", getChangeMetaData());\r\n return DbConflictResolution.Skip;\r\n }\r\n\r\n return DbConflictResolution.Replace;\r\n }\r\n\r\n\r\n /**\r\n * @alpha\r\n * Retrieves the txn properties for a given txn ID.\r\n *\r\n * @param id - The unique identifier of the transaction.\r\n * @returns The properties of the transaction if found; otherwise, `undefined`.\r\n */\r\n public getTxnProps(id: TxnIdString): TxnProps | undefined {\r\n return this._iModel[_nativeDb].getTxnProps(id);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Iterates over all transactions in the sequence, yielding each transaction's properties.\r\n *\r\n * @yields {TxnProps} The properties of each transaction in the sequence.\r\n */\r\n public *queryTxns(): Generator<TxnProps> {\r\n let txn = this.getTxnProps(this.queryFirstTxnId());\r\n while (txn) {\r\n yield txn;\r\n txn = txn.nextId ? this.getTxnProps(txn.nextId) : undefined;\r\n }\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Retrieves the properties of the last saved txn via `IModelDb.saveChanges()`, if available.\r\n *\r\n * @returns The properties of the last saved txn, or `undefined` if none exist.\r\n */\r\n public getLastSavedTxnProps(): TxnProps | undefined {\r\n return this.getTxnProps(this.queryPreviousTxnId(this.getCurrentTxnId()));\r\n }\r\n\r\n /** Dependency handlers may call method this to report a validation error.\r\n * @param error The error. If error.fatal === true, the transaction will cancel rather than commit.\r\n */\r\n public reportError(error: ValidationError) {\r\n this.validationErrors.push(error);\r\n this._nativeDb.logTxnError(error.fatal);\r\n }\r\n\r\n /** Determine whether any fatal validation errors have occurred during dependency propagation. */\r\n public get hasFatalError(): boolean { return this._nativeDb.hasFatalTxnError(); }\r\n\r\n /** @internal */\r\n public readonly onEndValidation = new BeEvent<() => void>();\r\n\r\n /** Called after validation completes from [[IModelDb.saveChanges]].\r\n * The argument to the event holds the list of elements that were inserted, updated, and deleted.\r\n * @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onElementsChanged = new BeEvent<(changes: TxnChangedEntities) => void>();\r\n\r\n /** Called after validation completes from [[IModelDb.saveChanges]].\r\n * The argument to the event holds the list of models that were inserted, updated, and deleted.\r\n * @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onModelsChanged = new BeEvent<(changes: TxnChangedEntities) => void>();\r\n\r\n /** Event raised after the geometry within one or more [[GeometricModel]]s is modified by applying a changeset or validation of a transaction.\r\n * A model's geometry can change as a result of:\r\n * - Insertion or deletion of a geometric element within the model; or\r\n * - Modification of an existing element's geometric properties; or\r\n * - An explicit request to flag it as changed via [[IModelDb.Models.updateModel]].\r\n */\r\n public readonly onModelGeometryChanged = new BeEvent<(changes: ReadonlyArray<ModelIdAndGeometryGuid>) => void>();\r\n\r\n public readonly onGeometryChanged = new BeEvent<(models: ModelGeometryChangesProps[]) => void>();\r\n /** Event raised before a commit operation is performed. Initiated by a call to [[IModelDb.saveChanges]], unless there are no changes to save. */\r\n public readonly onCommit = new BeEvent<() => void>();\r\n /** Event raised after a commit operation has been performed. Initiated by a call to [[IModelDb.saveChanges]], even if there were no changes to save. */\r\n public readonly onCommitted = new BeEvent<() => void>();\r\n /** Event raised after a ChangeSet has been applied to this briefcase */\r\n public readonly onChangesApplied = new BeEvent<() => void>();\r\n /** Event raised before an undo/redo operation is performed. */\r\n public readonly onBeforeUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n /** Event raised after an undo/redo operation has been performed.\r\n * @param _action The action that was performed.\r\n */\r\n public readonly onAfterUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n /** Event raised for a read-only briefcase that was opened with the `watchForChanges` flag enabled when changes made by another connection are applied to the briefcase.\r\n * @see [[onReplayedExternalTxns]] for the event raised after all such changes have been applied.\r\n */\r\n public readonly onReplayExternalTxns = new BeEvent<() => void>();\r\n /** Event raised for a read-only briefcase that was opened with the `watchForChanges` flag enabled when changes made by another connection are applied to the briefcase.\r\n * @see [[onReplayExternalTxns]] for the event raised before the changes are applied.\r\n */\r\n public readonly onReplayedExternalTxns = new BeEvent<() => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase transaction begins.\r\n */\r\n public readonly onRebaseTxnBegin = new BeEvent<(txn: TxnProps) => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase transaction ends.\r\n */\r\n public readonly onRebaseTxnEnd = new BeEvent<(txn: TxnProps) => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase begins.\r\n */\r\n public readonly onRebaseBegin = new BeEvent<(txns: TxnIdString[]) => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase ends.\r\n */\r\n public readonly onRebaseEnd = new BeEvent<() => void>();\r\n\r\n /** Event raised after changes are pulled from iModelHub.\r\n * @see [[BriefcaseDb.pullChanges]].\r\n */\r\n public readonly onChangesPulled = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /** Event raised after changes are pushed to iModelHub.\r\n * @see [[BriefcaseDb.pushChanges]].\r\n */\r\n public readonly onChangesPushed = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /**\r\n * if handler is set and it does not return undefined then default handler will not be called\r\n * @internal\r\n * */\r\n public appCustomConflictHandler?: (args: DbRebaseChangesetConflictArgs) => DbConflictResolution | undefined;\r\n\r\n /**\r\n * Restart the current TxnManager session. This causes all Txns in the current session to no longer be undoable (as if the file was closed\r\n * and reopened.)\r\n * @note This can be quite disconcerting to the user expecting to be able to undo previously made changes. It should only be used\r\n * under extreme circumstances where damage to the file or session could happen if the currently committed are reversed. Use sparingly and with care.\r\n * Probably a good idea to alert the user it happened.\r\n */\r\n public restartSession() {\r\n this._nativeDb.restartTxnSession();\r\n }\r\n\r\n /** Determine whether current txn is propagating indirect changes or not. */\r\n public get isIndirectChanges(): boolean { return this.getMode() === \"indirect\" }\r\n\r\n /** Determine if there are currently any reversible (undoable) changes from this editing session. */\r\n public get isUndoPossible(): boolean { return this._nativeDb.isUndoPossible(); }\r\n\r\n /** Determine if there are currently any reinstatable (redoable) changes */\r\n public get isRedoPossible(): boolean { return this._nativeDb.isRedoPossible(); }\r\n\r\n /** Get the description of the operation that would be reversed by calling reverseTxns(1).\r\n * This is useful for showing the operation that would be undone, for example in a menu.\r\n */\r\n public getUndoString(): string { return this._nativeDb.getUndoString(); }\r\n\r\n /** Get a description of the operation that would be reinstated by calling reinstateTxn.\r\n * This is useful for showing the operation that would be redone, in a pull-down menu for example.\r\n */\r\n public getRedoString(): string { return this._nativeDb.getRedoString(); }\r\n\r\n /** Begin a new multi-Txn operation. This can be used to cause a series of Txns that would normally\r\n * be considered separate actions for undo to be grouped into a single undoable operation. This means that when reverseTxns(1) is called,\r\n * the entire group of changes are undone together. Multi-Txn operations can be nested and until the outermost operation is closed\r\n * all changes constitute a single operation.\r\n * @note This method must always be paired with a call to endMultiTxnAction.\r\n */\r\n public beginMultiTxnOperation(): DbResult { return this._nativeDb.beginMultiTxnOperation(); }\r\n\r\n /** End a multi-Txn operation */\r\n public endMultiTxnOperation(): DbResult { return this._nativeDb.endMultiTxnOperation(); }\r\n\r\n /** Return the depth of the multi-Txn stack. Generally for diagnostic use only. */\r\n public getMultiTxnOperationDepth(): number { return this._nativeDb.getMultiTxnOperationDepth(); }\r\n\r\n /** Reverse (undo) the most recent operation(s) to this IModelDb.\r\n * @param numOperations the number of operations to reverse. If this is greater than 1, the entire set of operations will\r\n * be reinstated together when/if ReinstateTxn is called.\r\n * @note If there are any outstanding uncommitted changes, they are reversed.\r\n * @note The term \"operation\" is used rather than Txn, since multiple Txns can be grouped together via [[beginMultiTxnOperation]]. So,\r\n * even if numOperations is 1, multiple Txns may be reversed if they were grouped together when they were made.\r\n * @note If numOperations is too large only the operations are reversible are reversed.\r\n */\r\n public reverseTxns(numOperations: number): IModelStatus {\r\n return this._nativeDb.reverseTxns(numOperations);\r\n }\r\n\r\n /** Reverse the most recent operation. */\r\n public reverseSingleTxn(): IModelStatus { return this.reverseTxns(1); }\r\n\r\n /** Reverse all changes back to the beginning of the session. */\r\n public reverseAll(): IModelStatus { return this._nativeDb.reverseAll(); }\r\n\r\n /** Reverse all changes back to a previously saved TxnId.\r\n * @param txnId a TxnId obtained from a previous call to GetCurrentTxnId.\r\n * @returns Success if the transactions were reversed, error status otherwise.\r\n * @see [[getCurrentTxnId]] [[cancelTo]]\r\n */\r\n public reverseTo(txnId: TxnIdString): IModelStatus { return this._nativeDb.reverseTo(txnId); }\r\n\r\n /** Reverse and then cancel (make non-reinstatable) all changes back to a previous TxnId.\r\n * @param txnId a TxnId obtained from a previous call to [[getCurrentTxnId]]\r\n * @returns Success if the transactions were reversed and cleared, error status otherwise.\r\n */\r\n public cancelTo(txnId: TxnIdString): IModelStatus { return this._nativeDb.cancelTo(txnId); }\r\n\r\n /** Reinstate the most recently reversed transaction. Since at any time multiple transactions can be reversed, it\r\n * may take multiple calls to this method to reinstate all reversed operations.\r\n * @returns Success if a reversed transaction was reinstated, error status otherwise.\r\n * @note If there are any outstanding uncommitted changes, they are canceled before the Txn is reinstated.\r\n */\r\n public reinstateTxn(): IModelStatus { return this._iModel.reinstateTxn(); }\r\n\r\n /** Get the Id of the first transaction, if any.\r\n */\r\n public queryFirstTxnId(): TxnIdString { return this._nativeDb.queryFirstTxnId(); }\r\n\r\n /** Get the successor of the specified TxnId */\r\n public queryNextTxnId(txnId: TxnIdString): TxnIdString { return this._nativeDb.queryNextTxnId(txnId); }\r\n\r\n /** Get the predecessor of the specified TxnId */\r\n public queryPreviousTxnId(txnId: TxnIdString): TxnIdString { return this._nativeDb.queryPreviousTxnId(txnId); }\r\n\r\n /** Get the Id of the current (tip) transaction. */\r\n public getCurrentTxnId(): TxnIdString { return this._nativeDb.getCurrentTxnId(); }\r\n\r\n /**\r\n * @alpha\r\n * Get the Id of the current session.\r\n */\r\n public getCurrentSessionId(): number { return this._nativeDb.currentTxnSessionId(); }\r\n\r\n /** Get the description that was supplied when the specified transaction was saved. */\r\n public getTxnDescription(txnId: TxnIdString): string { return this._nativeDb.getTxnDescription(txnId); }\r\n\r\n /** Test if a TxnId is valid */\r\n public isTxnIdValid(txnId: TxnIdString): boolean { return this._nativeDb.isTxnIdValid(txnId); }\r\n\r\n /** Query if there are any pending Txns in this IModelDb that are waiting to be pushed.\r\n * @see [[IModelDb.pushChanges]]\r\n */\r\n public get hasPendingTxns(): boolean { return this._nativeDb.hasPendingTxns(); }\r\n\r\n /**\r\n * Query if there are any changes in memory that have yet to be saved to the IModelDb.\r\n * @see [[IModelDb.saveChanges]]\r\n */\r\n public get hasUnsavedChanges(): boolean { return this._nativeDb.hasUnsavedChanges(); }\r\n\r\n /**\r\n * @alpha\r\n * Query if there are any pending schema changes in this IModelDb.\r\n */\r\n public get hasPendingSchemaChanges(): boolean { return this._nativeDb.hasPendingSchemaChanges(); }\r\n\r\n /**\r\n * Query if there are changes in memory that have not been saved to the iModelDb or if there are Txns that are waiting to be pushed.\r\n * @see [[IModelDb.saveChanges]]\r\n * @see [[IModelDb.pushChanges]]\r\n */\r\n public get hasLocalChanges(): boolean { return this.hasUnsavedChanges || this.hasPendingTxns; }\r\n\r\n /** Destroy the record of all local changes that have yet to be saved and/or pushed.\r\n * This permanently eradicates your changes - use with caution!\r\n * Typically, callers will want to subsequently use [[LockControl.releaseAllLocks]].\r\n * After calling this function, [[hasLocalChanges]], [[hasPendingTxns]], and [[hasUnsavedChanges]] will all be `false`.\r\n */\r\n public deleteAllTxns(): void {\r\n this._nativeDb.deleteAllTxns();\r\n }\r\n\r\n /** Obtain a list of the EC instances that have been changed locally by the [[BriefcaseDb]] associated with this `TxnManager` and have not yet been pushed to the iModel.\r\n * @beta\r\n */\r\n public queryLocalChanges(args?: QueryLocalChangesArgs): Iterable<ChangeInstanceKey> {\r\n if (!args) {\r\n args = { includedClasses: [], includeUnsavedChanges: false };\r\n }\r\n return this._nativeDb.getLocalChanges(args.includedClasses ?? [], args.includeUnsavedChanges ?? false);\r\n }\r\n\r\n /** Query the number of bytes of memory currently allocated by SQLite to keep track of\r\n * changes to the iModel, for debugging/diagnostic purposes, as reported by [sqlite3session_memory_used](https://www.sqlite.org/session/sqlite3session_memory_used.html).\r\n */\r\n public getChangeTrackingMemoryUsed(): number {\r\n return this._iModel[_nativeDb].getChangeTrackingMemoryUsed();\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Get the current transaction mode.\r\n * @returns The current transaction mode, either \"direct\" or \"indirect\".\r\n */\r\n public getMode(): TxnMode {\r\n return this._nativeDb.getTxnMode();\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Execute a series of changes in an indirect transaction.\r\n * @param callback The function containing the changes to make.\r\n */\r\n public withIndirectTxnMode(callback: () => void): void {\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"indirect\");\r\n }\r\n this._withIndirectChangeRefCounter++;\r\n try {\r\n callback();\r\n } finally {\r\n this._withIndirectChangeRefCounter--;\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"direct\");\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Execute a series of changes in an indirect transaction.\r\n * @param callback The function containing the changes to make.\r\n */\r\n public async withIndirectTxnModeAsync(callback: () => Promise<void>): Promise<void> {\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"indirect\");\r\n }\r\n this._withIndirectChangeRefCounter++;\r\n try {\r\n await callback();\r\n } finally {\r\n this._withIndirectChangeRefCounter--;\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"direct\");\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Interface for handling rebase operations on transactions.\r\n * @alpha\r\n */\r\nexport interface RebaseHandler {\r\n /**\r\n * Determine whether a transaction should be reinstated during a rebase operation.\r\n * @param txn The transaction to check.\r\n *\r\n * @alpha\r\n */\r\n shouldReinstate(txn: TxnProps): boolean;\r\n /**\r\n * Recompute the changes for a given transaction.\r\n * @param txn The transaction to recompute.\r\n *\r\n * @alpha\r\n */\r\n recompute(txn: TxnProps): Promise<void>;\r\n}"]}
1
+ {"version":3,"file":"TxnManager.js","sourceRoot":"","sources":["../../src/TxnManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAyEH,wDAIC;AA3ED,+BAA+B;AAC/B,sDAE6B;AAC7B,oDAA+M;AAC/M,mEAAgE;AAEhE,uCAAoC;AAGpC,gDAA0E;AAC1E,4EAA8G;AAC9G,yDAAsD;AA0DtD,oCAAoC;AACpC,SAAgB,sBAAsB,CAAC,GAAW;IAChD,MAAM,OAAO,GAAG,mBAAmB,CAAC,WAAW,CAAC;IAChD,mBAAmB,CAAC,WAAW,GAAG,GAAG,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iIAAiI;AACjI,MAAM,oBAAoB;IACR,SAAS,GAAG,IAAI,+BAAgB,EAAE,CAAC;IAClC,aAAa,GAAa,EAAE,CAAC;IAC7B,SAAS,CAAuB;IAEjD,YAAmB,QAA8B;QAC/C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,QAAoB,EAAE,OAAmB;QACrD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,IAAA,qBAAM,EAAC,UAAU,IAAI,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YACxD,uDAAuD;YACvD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;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;IACI,mBAAmB,CAAC,QAAoB;QAC7C,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,QAAQ,EAAE,CAAC;QACb,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,6BAA6B,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,wBAAwB,CAAC,QAA6B;QACjE,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,QAAQ,EAAE,CAAC;QACnB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,6BAA6B,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,6BAA6B,KAAK,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/iBD,gCA+iBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport * as touch from \"touch\";\r\nimport {\r\n assert, BeEvent, BentleyError, compareStrings, CompressedId64Set, DbConflictResolution, DbResult, Id64Array, Id64String, IModelStatus, IndexMap, Logger, OrderedId64Array\r\n} from \"@itwin/core-bentley\";\r\nimport { ChangesetIndexAndId, EntityIdAndClassIdIterable, IModelError, ModelGeometryChangesProps, ModelIdAndGeometryGuid, NotifyEntitiesChangedArgs, NotifyEntitiesChangedMetadata } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BriefcaseDb, SaveChangesArgs, StandaloneDb } from \"./IModelDb\";\r\nimport { IpcHost } from \"./IpcHost\";\r\nimport { Relationship, RelationshipProps } from \"./Relationship\";\r\nimport { SqliteStatement } from \"./SqliteStatement\";\r\nimport { _cache, _instanceKeyCache, _nativeDb } from \"./internal/Symbols\";\r\nimport { DbRebaseChangesetConflictArgs, RebaseChangesetConflictArgs } from \"./internal/ChangesetConflictArgs\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\n\r\n/** A string that identifies a Txn.\r\n * @public @preview\r\n */\r\nexport type TxnIdString = string;\r\n\r\n/** An error generated during dependency validation.\r\n * @see [[TxnManager.validationErrors]].\r\n * @public @preview\r\n */\r\nexport interface ValidationError {\r\n /** If true, txn is aborted. */\r\n fatal: boolean;\r\n /** The type of error. */\r\n errorType: string;\r\n /** Optional description of what went wrong. */\r\n message?: string;\r\n}\r\n\r\n/** Describes a set of [[Element]]s or [[Model]]s that changed as part of a transaction.\r\n * @see [[TxnManager.onElementsChanged]] and [[TxnManager.onModelsChanged]].\r\n * @public @preview\r\n */\r\nexport interface TxnChangedEntities {\r\n /** The entities that were inserted by the transaction. */\r\n readonly inserts: EntityIdAndClassIdIterable;\r\n /** The entities that were deleted by the transaction. */\r\n readonly deletes: EntityIdAndClassIdIterable;\r\n /** The entities that were modified by the transaction, including any [[Element]]s for which one of their [[ElementAspect]]s was changed. */\r\n readonly updates: EntityIdAndClassIdIterable;\r\n}\r\n\r\n/** Arguments supplied to [[TxnManager.queryLocalChanges]].\r\n * @beta\r\n */\r\nexport interface QueryLocalChangesArgs {\r\n /** If supplied and non-empty, restricts the results to include only EC instances belonging to the specified classes or subclasses thereof. */\r\n readonly includedClasses?: string[];\r\n /** If `true`, include changes that have not yet been saved. */\r\n readonly includeUnsavedChanges?: boolean;\r\n}\r\n\r\n/** Represents a change (insertion, deletion, or modification) to a single EC instance made in a local [[BriefcaseDb]].\r\n * @see [[TxnManager.queryLocalChanges]] to iterate all of the changed instances.\r\n* @beta\r\n*/\r\nexport interface ChangeInstanceKey {\r\n /** ECInstanceId of the instance. */\r\n id: Id64String;\r\n /** Fully-qualified class name of the instance. */\r\n classFullName: string;\r\n /** The type of change. */\r\n changeType: \"inserted\" | \"updated\" | \"deleted\";\r\n}\r\n\r\ntype EntitiesChangedEvent = BeEvent<(changes: TxnChangedEntities) => void>;\r\n\r\n/** Strictly for tests. @internal */\r\nexport function setMaxEntitiesPerEvent(max: number): number {\r\n const prevMax = ChangedEntitiesProc.maxPerEvent;\r\n ChangedEntitiesProc.maxPerEvent = max;\r\n return prevMax;\r\n}\r\n\r\n/** Maintains an ordered array of entity Ids and a parallel array containing the index of the corresponding entity's class Id. */\r\nclass ChangedEntitiesArray {\r\n public readonly entityIds = new OrderedId64Array();\r\n private readonly _classIndices: number[] = [];\r\n private readonly _classIds: IndexMap<Id64String>;\r\n\r\n public constructor(classIds: IndexMap<Id64String>) {\r\n this._classIds = classIds;\r\n }\r\n\r\n public insert(entityId: Id64String, classId: Id64String): void {\r\n const entityIndex = this.entityIds.insert(entityId);\r\n const classIndex = this._classIds.insert(classId);\r\n assert(classIndex >= 0);\r\n if (this.entityIds.length !== this._classIndices.length) {\r\n // New entity - insert corresponding class index entry.\r\n this._classIndices.splice(entityIndex, 0, classIndex);\r\n } else {\r\n // Existing entity - update corresponding class index.\r\n // (We do this because apparently connectors can (very rarely) change the class Id of an existing element).\r\n this._classIndices[entityIndex] = classIndex;\r\n }\r\n\r\n assert(this.entityIds.length === this._classIndices.length);\r\n }\r\n\r\n public clear(): void {\r\n this.entityIds.clear();\r\n this._classIndices.length = 0;\r\n }\r\n\r\n public addToChangedEntities(entities: NotifyEntitiesChangedArgs, type: \"deleted\" | \"inserted\" | \"updated\"): void {\r\n if (this.entityIds.length > 0)\r\n entities[type] = CompressedId64Set.compressIds(this.entityIds);\r\n\r\n entities[`${type}Meta`] = this._classIndices;\r\n }\r\n\r\n public iterable(classIds: Id64Array): EntityIdAndClassIdIterable {\r\n function* iterator(entityIds: ReadonlyArray<Id64String>, classIndices: number[]) {\r\n const entity = { id: \"\", classId: \"\" };\r\n for (let i = 0; i < entityIds.length; i++) {\r\n entity.id = entityIds[i];\r\n entity.classId = classIds[classIndices[i]];\r\n yield entity;\r\n }\r\n }\r\n\r\n return {\r\n [Symbol.iterator]: () => iterator(this.entityIds.array, this._classIndices),\r\n };\r\n }\r\n}\r\n\r\nclass ChangedEntitiesProc {\r\n private readonly _classIds = new IndexMap<Id64String>((lhs, rhs) => compareStrings(lhs, rhs));\r\n private readonly _inserted = new ChangedEntitiesArray(this._classIds);\r\n private readonly _deleted = new ChangedEntitiesArray(this._classIds);\r\n private readonly _updated = new ChangedEntitiesArray(this._classIds);\r\n private _currSize = 0;\r\n\r\n public static maxPerEvent = 1000;\r\n\r\n public static process(iModel: BriefcaseDb | StandaloneDb, mgr: TxnManager): void {\r\n if (mgr.isDisposed) {\r\n // The iModel is being closed. Do not prepare new sqlite statements.\r\n return;\r\n }\r\n\r\n this.processChanges(iModel, mgr.onElementsChanged, \"notifyElementsChanged\");\r\n this.processChanges(iModel, mgr.onModelsChanged, \"notifyModelsChanged\");\r\n }\r\n\r\n private populateMetadata(db: BriefcaseDb | StandaloneDb, classIds: Id64Array): NotifyEntitiesChangedMetadata[] {\r\n // Ensure metadata for all class Ids is loaded. Loading metadata for a derived class loads metadata for all of its superclasses.\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const classIdsToLoad = classIds.filter((x) => undefined === db.classMetaDataRegistry.findByClassId(x));\r\n if (classIdsToLoad.length > 0) {\r\n const classIdsStr = classIdsToLoad.join(\",\");\r\n const sql = `SELECT ec_class.Name, ec_class.Id, ec_schema.Name FROM ec_class JOIN ec_schema WHERE ec_schema.Id = ec_class.SchemaId AND ec_class.Id IN (${classIdsStr})`;\r\n db.withPreparedSqliteStatement(sql, (stmt) => {\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const classFullName = `${stmt.getValueString(2)}:${stmt.getValueString(0)}`;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n db.tryGetMetaData(classFullName);\r\n }\r\n });\r\n }\r\n\r\n // Define array indices for the metadata array entries correlating to the class Ids in the input list.\r\n const nameToIndex = new Map<string, number>();\r\n for (const classId of classIds) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const meta = db.classMetaDataRegistry.findByClassId(classId);\r\n nameToIndex.set(meta?.ecclass ?? \"\", nameToIndex.size);\r\n }\r\n\r\n const result: NotifyEntitiesChangedMetadata[] = [];\r\n\r\n function addMetadata(name: string, index: number): void {\r\n const bases: number[] = [];\r\n result[index] = { name, bases };\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const meta = db.tryGetMetaData(name);\r\n if (!meta) {\r\n return;\r\n }\r\n\r\n for (const baseClassName of meta.baseClasses) {\r\n let baseClassIndex = nameToIndex.get(baseClassName);\r\n if (undefined === baseClassIndex) {\r\n baseClassIndex = nameToIndex.size;\r\n nameToIndex.set(baseClassName, baseClassIndex);\r\n addMetadata(baseClassName, baseClassIndex);\r\n }\r\n\r\n bases.push(baseClassIndex);\r\n }\r\n }\r\n\r\n for (const [name, index] of nameToIndex) {\r\n if (index >= classIds.length) {\r\n // Entries beyond this are base classes for the classes in `classIds` - don't reprocess them.\r\n break;\r\n }\r\n\r\n addMetadata(name, index);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private sendEvent(iModel: BriefcaseDb | StandaloneDb, evt: EntitiesChangedEvent, evtName: \"notifyElementsChanged\" | \"notifyModelsChanged\") {\r\n if (this._currSize === 0)\r\n return;\r\n\r\n const classIds = this._classIds.toArray();\r\n\r\n // Notify backend listeners.\r\n const txnEntities: TxnChangedEntities = {\r\n inserts: this._inserted.iterable(classIds),\r\n deletes: this._deleted.iterable(classIds),\r\n updates: this._updated.iterable(classIds),\r\n };\r\n evt.raiseEvent(txnEntities);\r\n\r\n // Notify frontend listeners.\r\n const entities: NotifyEntitiesChangedArgs = {\r\n insertedMeta: [],\r\n updatedMeta: [],\r\n deletedMeta: [],\r\n meta: this.populateMetadata(iModel, classIds),\r\n };\r\n\r\n this._inserted.addToChangedEntities(entities, \"inserted\");\r\n this._deleted.addToChangedEntities(entities, \"deleted\");\r\n this._updated.addToChangedEntities(entities, \"updated\");\r\n\r\n IpcHost.notifyTxns(iModel, evtName, entities);\r\n\r\n // Reset state.\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n this._updated.clear();\r\n this._classIds.clear();\r\n this._currSize = 0;\r\n }\r\n\r\n private static processChanges(iModel: BriefcaseDb | StandaloneDb, changedEvent: EntitiesChangedEvent, evtName: \"notifyElementsChanged\" | \"notifyModelsChanged\") {\r\n try {\r\n const maxSize = this.maxPerEvent;\r\n const changes = new ChangedEntitiesProc();\r\n const select = \"notifyElementsChanged\" === evtName\r\n ? \"SELECT ElementId, ChangeType, ECClassId FROM temp.txn_Elements\"\r\n : \"SELECT ModelId, ChangeType, ECClassId FROM temp.txn_Models\";\r\n iModel.withPreparedSqliteStatement(select, (sql: SqliteStatement) => {\r\n const stmt = sql.stmt;\r\n while (sql.step() === DbResult.BE_SQLITE_ROW) {\r\n const id = stmt.getValueId(0);\r\n const classId = stmt.getValueId(2);\r\n switch (stmt.getValueInteger(1)) {\r\n case 0:\r\n changes._inserted.insert(id, classId);\r\n break;\r\n case 1:\r\n changes._updated.insert(id, classId);\r\n break;\r\n case 2:\r\n changes._deleted.insert(id, classId);\r\n break;\r\n }\r\n\r\n if (++changes._currSize >= maxSize)\r\n changes.sendEvent(iModel, changedEvent, evtName);\r\n }\r\n });\r\n\r\n changes.sendEvent(iModel, changedEvent, evtName);\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelDb, BentleyError.getErrorMessage(err));\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\ninterface IConflictHandler {\r\n handler: (arg: RebaseChangesetConflictArgs) => DbConflictResolution | undefined;\r\n next: IConflictHandler | undefined;\r\n id: string;\r\n}\r\n\r\n/**\r\n * @alpha\r\n * Transaction types\r\n */\r\nexport type TxnType = \"Data\" | \"ECSchema\" | \"Ddl\";\r\n\r\n/**\r\n * @alpha\r\n * Transaction modes\r\n */\r\nexport type TxnMode = \"direct\" | \"indirect\";\r\n\r\n/**\r\n * @alpha\r\n * Represents the properties of a transaction within the transaction manager.\r\n *\r\n * @property id - The unique identifier for the transaction.\r\n * @property sessionId - The identifier of the session to which the transaction belongs.\r\n * @property nextId - (Optional) The identifier of the next transaction in the sequence.\r\n * @property prevId - (Optional) The identifier of the previous transaction in the sequence.\r\n * @property props - The arguments or properties associated with the save changes operation.\r\n * @property type - The type of transaction, which can be \"Data\", \"ECSchema\", or \"Ddl\".\r\n * @property reversed - Indicates whether the transaction has been reversed.\r\n * @property grouped - Indicates whether the transaction is grouped with others.\r\n * @property timestamp - The timestamp when the transaction was created.\r\n */\r\nexport interface TxnProps {\r\n id: TxnIdString;\r\n sessionId: number;\r\n nextId?: TxnIdString;\r\n prevId?: TxnIdString;\r\n props: SaveChangesArgs;\r\n type: TxnType;\r\n reversed: boolean;\r\n grouped: boolean;\r\n timestamp: string;\r\n}\r\n\r\n/**\r\n * Manages the process of merging and rebasing local changes (transactions) in a [[BriefcaseDb]] or [[StandaloneDb]].\r\n *\r\n * The `RebaseManager` coordinates the rebase of local transactions when pulling and merging changes from other sources,\r\n * such as remote repositories or other users. It provides mechanisms to handle transaction conflicts, register custom conflict\r\n * handlers, and manage the rebase workflow. This includes resuming rebases, invoking user-defined handlers for conflict resolution,\r\n * and tracking the current merge/rebase state.\r\n *\r\n * Key responsibilities:\r\n * - Orchestrates the rebase of local transactions after a pull/merge operation.\r\n * - Allows registration and removal of custom conflict handlers to resolve changeset conflicts during rebase.\r\n * - Provides methods to check the current merge/rebase state.\r\n * - Raises events before and after each transaction is rebased.\r\n * - Ensures changes are saved or aborted appropriately based on the outcome of the rebase process.\r\n *\r\n * @alpha\r\n */\r\nexport class RebaseManager {\r\n private _conflictHandlers?: IConflictHandler;\r\n private _customHandler?: RebaseHandler;\r\n private _aborting: boolean = false;\r\n public constructor(private _iModel: BriefcaseDb | StandaloneDb) { }\r\n\r\n /**\r\n * Resumes the rebase process for the current iModel, applying any pending local changes\r\n * on top of the latest pulled changes from the remote source.\r\n *\r\n * This method performs the following steps:\r\n * 1. Begins the rebase process using the native database.\r\n * 2. Iterates through each transaction that needs to be rebased:\r\n * - Retrieves transaction properties.\r\n * - Raises events before and after rebasing each transaction.\r\n * - Optionally reinstates local changes based on the rebase handler.\r\n * - Optionally recomputes transaction data using the rebase handler.\r\n * - Updates the transaction in the native database.\r\n * 3. Ends the rebase process and saves changes if the database is not read-only.\r\n * 4. Drops any restore point associated with the pull-merge operation.\r\n *\r\n * If an error occurs during the process, the rebase is aborted and the error is rethrown.\r\n *\r\n * @throws {Error} If a transaction cannot be found or if any step in the rebase process fails.\r\n */\r\n public async resume() {\r\n const nativeDb = this._iModel[_nativeDb];\r\n const txns = this._iModel.txns;\r\n try {\r\n const reversedTxns = nativeDb.pullMergeRebaseBegin();\r\n txns.onRebaseBegin.raiseEvent(reversedTxns);\r\n let txnId = nativeDb.pullMergeRebaseNext();\r\n while (txnId) {\r\n const txnProps = txns.getTxnProps(txnId);\r\n if (!txnProps) {\r\n throw new Error(`Transaction ${txnId} not found`);\r\n }\r\n\r\n txns.onRebaseTxnBegin.raiseEvent(txnProps);\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, `Rebasing local changes for transaction ${txnId}`);\r\n const shouldReinstate = this._customHandler?.shouldReinstate(txnProps) ?? true;\r\n if (shouldReinstate) {\r\n nativeDb.pullMergeRebaseReinstateTxn();\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, `Reinstated local changes for transaction ${txnId}`);\r\n }\r\n\r\n if (this._customHandler) {\r\n await this._customHandler.recompute(txnProps);\r\n }\r\n\r\n nativeDb.pullMergeRebaseUpdateTxn();\r\n txns.onRebaseTxnEnd.raiseEvent(txnProps);\r\n\r\n txnId = nativeDb.pullMergeRebaseNext();\r\n }\r\n\r\n nativeDb.pullMergeRebaseEnd();\r\n if (!nativeDb.isReadonly) {\r\n nativeDb.saveChanges(\"Merge.\");\r\n }\r\n if (BriefcaseManager.containsRestorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME)) {\r\n BriefcaseManager.dropRestorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME);\r\n }\r\n } catch (err) {\r\n nativeDb.pullMergeRebaseAbortTxn();\r\n throw err;\r\n }\r\n finally {\r\n txns.onRebaseEnd.raiseEvent();\r\n }\r\n }\r\n\r\n /**\r\n * Determines whether the current transaction can be aborted.\r\n *\r\n * This method checks if a transaction is currently in progress and if a specific restore point,\r\n * identified by `BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME`, exists in the briefcase manager.\r\n *\r\n * @returns {boolean} Returns `true` if a transaction is in progress and the required restore point exists; otherwise, returns `false`.\r\n */\r\n public canAbort() {\r\n return this.inProgress() && BriefcaseManager.containsRestorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME);\r\n }\r\n\r\n /**\r\n * Aborts the current transaction by restoring the iModel to a predefined restore point.\r\n *\r\n * If a restore point is available (as determined by `canAbort()`), this method restores the iModel\r\n * to the state saved at the restore point named by `BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME`.\r\n * If no restore point is available, an error is thrown.\r\n *\r\n * @returns A promise that resolves when the restore operation is complete.\r\n * @throws {Error} If there is no restore point to abort to.\r\n */\r\n public async abort(): Promise<void> {\r\n if (this.canAbort()) {\r\n this._aborting = true;\r\n try {\r\n await BriefcaseManager.restorePoint(this._iModel, BriefcaseManager.PULL_MERGE_RESTORE_POINT_NAME);\r\n } finally {\r\n this._aborting = false;\r\n }\r\n } else {\r\n throw new Error(\"No restore point to abort to\");\r\n }\r\n }\r\n\r\n /**\r\n * Sets the handler to be invoked for rebase operations.\r\n *\r\n * @param handler - The {@link RebaseHandler} to handle rebase events.\r\n */\r\n public setCustomHandler(handler: RebaseHandler) {\r\n if (this._customHandler) {\r\n Logger.logWarning(BackendLoggerCategory.IModelDb, \"Rebase handler already set\");\r\n }\r\n this._customHandler = handler;\r\n }\r\n\r\n /**\r\n * Determines whether a transaction is currently in progress.\r\n *\r\n * @returns {boolean} Returns `true` if there is an active transaction stage, otherwise `false`.\r\n */\r\n public inProgress() {\r\n return this._iModel[_nativeDb].pullMergeGetStage() !== \"None\";\r\n }\r\n\r\n /**\r\n * Indicates whether the current transaction manager is in the process of aborting a transaction.\r\n *\r\n * @returns `true` if the transaction manager is currently aborting; otherwise, `false`.\r\n */\r\n public get isAborting(): boolean {\r\n return this._aborting;\r\n }\r\n\r\n /**\r\n * Indicates whether the current transaction manager is in the \"Rebasing\" stage.\r\n *\r\n * This property checks the internal native database's merge stage to determine if a rebase operation is in progress.\r\n *\r\n * @returns `true` if the transaction manager is currently rebasing; otherwise, `false`.\r\n */\r\n public get isRebasing() {\r\n return this._iModel[_nativeDb].pullMergeGetStage() === \"Rebasing\";\r\n }\r\n\r\n /**\r\n * Indicates whether the current iModel is in the process of merging changes from a pull operation.\r\n *\r\n * @returns `true` if the iModel is currently merging changes; otherwise, `false`.\r\n */\r\n public get isMerging() {\r\n return this._iModel[_nativeDb].pullMergeGetStage() === \"Merging\";\r\n }\r\n\r\n /**\r\n * Attempts to resolve a changeset conflict by invoking registered conflict handlers in sequence.\r\n *\r\n * Iterates through the linked list of conflict handlers, passing the provided conflict arguments to each handler.\r\n * If a handler returns a defined resolution, logs the resolution and returns it immediately.\r\n * If no handler resolves the conflict, returns `undefined`.\r\n *\r\n * @param args - The arguments describing the changeset conflict to resolve.\r\n * @returns The conflict resolution provided by a handler, or `undefined` if no handler resolves the conflict.\r\n */\r\n public onConflict(args: RebaseChangesetConflictArgs): DbConflictResolution | undefined {\r\n let curr = this._conflictHandlers;\r\n while (curr) {\r\n const resolution = curr.handler(args);\r\n if (resolution !== undefined) {\r\n Logger.logTrace(BackendLoggerCategory.IModelDb, `Conflict handler ${curr.id} resolved conflict`);\r\n return resolution;\r\n }\r\n curr = curr.next;\r\n }\r\n return undefined\r\n }\r\n\r\n /**\r\n * Registers a new conflict handler for rebase changeset conflicts.\r\n *\r\n * @param args - An object containing:\r\n * - `id`: A unique identifier for the conflict handler.\r\n * - `handler`: A function that handles rebase changeset conflicts and returns a `DbConflictResolution` or `undefined`.\r\n * @throws IModelError if a conflict handler with the same `id` already exists.\r\n *\r\n * @remarks\r\n * Conflict handlers are used during changeset rebase operations to resolve conflicts.\r\n * Each handler must have a unique `id`. Attempting to register a handler with a duplicate `id` will result in an error.\r\n */\r\n public addConflictHandler(args: { id: string, handler: (args: RebaseChangesetConflictArgs) => DbConflictResolution | undefined }) {\r\n const idExists = (id: string) => {\r\n let curr = this._conflictHandlers;\r\n while (curr) {\r\n if (curr.id === id)\r\n return true;\r\n curr = curr.next;\r\n }\r\n return false;\r\n }\r\n if (idExists(args.id))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Conflict handler with id ${args.id} already exists`);\r\n this._conflictHandlers = { ...args, next: this._conflictHandlers };\r\n }\r\n\r\n /**\r\n * Removes a conflict handler from the internal linked list by its identifier.\r\n *\r\n * @param id - The unique identifier of the conflict handler to remove.\r\n *\r\n * If the handler with the specified `id` exists in the list, it will be removed.\r\n * If no handler with the given `id` is found, the method does nothing.\r\n */\r\n public removeConflictHandler(id: string) {\r\n if (!this._conflictHandlers)\r\n return;\r\n\r\n if (this._conflictHandlers?.id === id) {\r\n this._conflictHandlers = this._conflictHandlers.next;\r\n return;\r\n }\r\n\r\n let prev = this._conflictHandlers;\r\n let curr = this._conflictHandlers?.next;\r\n while (curr) {\r\n if (curr.id === id) {\r\n prev.next = curr.next;\r\n return;\r\n }\r\n prev = curr;\r\n curr = curr.next;\r\n }\r\n }\r\n}\r\n\r\n/** Manages local changes to a [[BriefcaseDb]] or [[StandaloneDb]] via [Txns]($docs/learning/InteractiveEditing.md)\r\n * @public @preview\r\n */\r\nexport class TxnManager {\r\n /** @internal */\r\n private _isDisposed = false;\r\n /** @internal */\r\n private _withIndirectChangeRefCounter = 0;\r\n /** @internal */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /** @internal */\r\n public readonly rebaser: RebaseManager;\r\n\r\n /** @internal */\r\n constructor(private _iModel: BriefcaseDb | StandaloneDb) {\r\n this.rebaser = new RebaseManager(_iModel);\r\n _iModel.onBeforeClose.addOnce(() => {\r\n this._isDisposed = true;\r\n });\r\n }\r\n\r\n /** Array of errors from dependency propagation */\r\n public readonly validationErrors: ValidationError[] = [];\r\n\r\n private get _nativeDb() { return this._iModel[_nativeDb]; }\r\n private _getElementClass(elClassName: string): typeof Element {\r\n return this._iModel.getJsClass(elClassName) as unknown as typeof Element;\r\n }\r\n private _getRelationshipClass(relClassName: string): typeof Relationship {\r\n return this._iModel.getJsClass<typeof Relationship>(relClassName);\r\n }\r\n\r\n /** If a -watch file exists for this iModel, update its timestamp so watching processes can be\r\n * notified that we've modified the briefcase.\r\n * @internal Used by IModelDb on push/pull.\r\n */\r\n public touchWatchFile(): void {\r\n // This is an async call. We don't have any reason to await it.\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n touch(this._iModel.watchFilePathName, { nocreate: true });\r\n }\r\n\r\n /** @internal */\r\n protected _onBeforeOutputsHandled(elClassName: string, elId: Id64String): void {\r\n (this._getElementClass(elClassName) as any).onBeforeOutputsHandled(elId, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onAllInputsHandled(elClassName: string, elId: Id64String): void {\r\n (this._getElementClass(elClassName) as any).onAllInputsHandled(elId, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onRootChanged(props: RelationshipProps): void {\r\n this._getRelationshipClass(props.classFullName).onRootChanged(props, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onDeletedDependency(props: RelationshipProps): void {\r\n this._getRelationshipClass(props.classFullName).onDeletedDependency(props, this._iModel);\r\n }\r\n /** @internal */\r\n protected _onBeginValidate() { this.validationErrors.length = 0; }\r\n\r\n /** called from native code after validation of a Txn, either from saveChanges or apply changeset.\r\n * @internal\r\n */\r\n protected _onEndValidate() {\r\n ChangedEntitiesProc.process(this._iModel, this);\r\n this.onEndValidation.raiseEvent();\r\n // TODO: if (this.validationErrors.length !== 0) throw new IModelError(validation ...)\r\n }\r\n\r\n /** @internal */\r\n protected _onGeometryChanged(modelProps: ModelGeometryChangesProps[]) {\r\n this.onGeometryChanged.raiseEvent(modelProps);\r\n IpcHost.notifyEditingScope(this._iModel, \"notifyGeometryChanged\", modelProps); // send to frontend\r\n }\r\n\r\n /** @internal */\r\n protected _onGeometryGuidsChanged(changes: ModelIdAndGeometryGuid[]): void {\r\n this.onModelGeometryChanged.raiseEvent(changes);\r\n IpcHost.notifyTxns(this._iModel, \"notifyGeometryGuidsChanged\", changes);\r\n }\r\n\r\n /** @internal */\r\n protected _onCommit() {\r\n this.onCommit.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyCommit\");\r\n }\r\n\r\n /** @internal */\r\n protected _onCommitted() {\r\n this.touchWatchFile();\r\n this.onCommitted.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyCommitted\", this.hasPendingTxns, Date.now());\r\n }\r\n\r\n /** @internal */\r\n protected _onReplayExternalTxns() {\r\n this.onReplayExternalTxns.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyReplayExternalTxns\");\r\n }\r\n\r\n /** @internal */\r\n protected _onReplayedExternalTxns() {\r\n this.onReplayedExternalTxns.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyReplayedExternalTxns\");\r\n }\r\n\r\n /** @internal */\r\n protected _onChangesApplied() {\r\n // Should only clear instance caches, not all caches\r\n this._iModel.clearCaches({ instanceCachesOnly: true });\r\n ChangedEntitiesProc.process(this._iModel, this);\r\n this.onChangesApplied.raiseEvent();\r\n IpcHost.notifyTxns(this._iModel, \"notifyChangesApplied\");\r\n }\r\n\r\n /** @internal */\r\n protected _onBeforeUndoRedo(isUndo: boolean) {\r\n this.onBeforeUndoRedo.raiseEvent(isUndo);\r\n IpcHost.notifyTxns(this._iModel, \"notifyBeforeUndoRedo\", isUndo);\r\n }\r\n\r\n /** @internal */\r\n protected _onAfterUndoRedo(isUndo: boolean) {\r\n this.touchWatchFile();\r\n this.onAfterUndoRedo.raiseEvent(isUndo);\r\n IpcHost.notifyTxns(this._iModel, \"notifyAfterUndoRedo\", isUndo);\r\n }\r\n\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _onChangesPushed(changeset: ChangesetIndexAndId) {\r\n this.touchWatchFile();\r\n this.onChangesPushed.raiseEvent(changeset);\r\n IpcHost.notifyTxns(this._iModel, \"notifyPushedChanges\", changeset);\r\n }\r\n\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _onChangesPulled(changeset: ChangesetIndexAndId) {\r\n this.touchWatchFile();\r\n this.onChangesPulled.raiseEvent(changeset);\r\n IpcHost.notifyTxns(this._iModel, \"notifyPulledChanges\", changeset);\r\n }\r\n\r\n private _onRebaseLocalTxnConflict(internalArg: DbRebaseChangesetConflictArgs): DbConflictResolution {\r\n const args = new RebaseChangesetConflictArgs(internalArg, this._iModel);\r\n\r\n const getChangeMetaData = () => {\r\n return {\r\n parent: this._iModel.changeset,\r\n txn: args.txn,\r\n table: args.tableName,\r\n op: args.opcode,\r\n cause: args.cause,\r\n indirect: args.indirect,\r\n primarykey: args.getPrimaryKeyValues(),\r\n fkConflictCount: args.cause === \"ForeignKey\" ? args.getForeignKeyConflicts() : undefined,\r\n };\r\n }\r\n\r\n // Default conflict resolution for which custom handler is never called.\r\n if (args.cause === \"Data\" && !args.indirect) {\r\n if (args.tableName === \"be_Prop\") {\r\n if (args.getValueText(0, \"Old\") === \"ec_Db\" && args.getValueText(1, \"Old\") === \"localDbInfo\") {\r\n return DbConflictResolution.Skip;\r\n }\r\n }\r\n if (args.tableName.startsWith(\"ec_\")) {\r\n return DbConflictResolution.Skip;\r\n }\r\n }\r\n\r\n if (args.cause === \"Conflict\") {\r\n if (args.tableName.startsWith(\"ec_\")) {\r\n return DbConflictResolution.Skip;\r\n }\r\n }\r\n\r\n try {\r\n const resolution = this.rebaser.onConflict(args);\r\n if (resolution !== undefined)\r\n return resolution;\r\n } catch (err) {\r\n const msg = `Rebase failed. Custom conflict handler should not throw exception. Aborting txn. ${BentleyError.getErrorMessage(err)}`;\r\n Logger.logError(BackendLoggerCategory.IModelDb, msg, getChangeMetaData());\r\n args.setLastError(msg);\r\n return DbConflictResolution.Abort;\r\n }\r\n\r\n if (args.cause === \"Data\" && !args.indirect) {\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, \"UPDATE/DELETE before value do not match with one in db or CASCADE action was triggered. Local change will replace existing.\", getChangeMetaData());\r\n return DbConflictResolution.Replace;\r\n }\r\n\r\n if (args.cause === \"Conflict\") {\r\n const msg = \"PRIMARY KEY insert conflict. Aborting rebase.\";\r\n Logger.logError(BackendLoggerCategory.IModelDb, msg, getChangeMetaData());\r\n args.setLastError(msg);\r\n return DbConflictResolution.Abort;\r\n }\r\n\r\n if (args.cause === \"ForeignKey\") {\r\n const msg = `Foreign key conflicts in ChangeSet. Aborting rebase.`;\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, msg, getChangeMetaData());\r\n args.setLastError(msg);\r\n return DbConflictResolution.Abort;\r\n }\r\n\r\n if (args.cause === \"NotFound\") {\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, \"PRIMARY KEY not found. Skipping local change.\", getChangeMetaData());\r\n return DbConflictResolution.Skip;\r\n }\r\n\r\n if (args.cause === \"Constraint\") {\r\n Logger.logInfo(BackendLoggerCategory.IModelDb, \"Constraint violation detected. Generally caused by db constraints like UNIQUE index. Skipping local change.\", getChangeMetaData());\r\n return DbConflictResolution.Skip;\r\n }\r\n\r\n return DbConflictResolution.Replace;\r\n }\r\n\r\n\r\n /**\r\n * @alpha\r\n * Retrieves the txn properties for a given txn ID.\r\n *\r\n * @param id - The unique identifier of the transaction.\r\n * @returns The properties of the transaction if found; otherwise, `undefined`.\r\n */\r\n public getTxnProps(id: TxnIdString): TxnProps | undefined {\r\n return this._iModel[_nativeDb].getTxnProps(id);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Iterates over all transactions in the sequence, yielding each transaction's properties.\r\n *\r\n * @yields {TxnProps} The properties of each transaction in the sequence.\r\n */\r\n public *queryTxns(): Generator<TxnProps> {\r\n let txn = this.getTxnProps(this.queryFirstTxnId());\r\n while (txn) {\r\n yield txn;\r\n txn = txn.nextId ? this.getTxnProps(txn.nextId) : undefined;\r\n }\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Retrieves the properties of the last saved txn via `IModelDb.saveChanges()`, if available.\r\n *\r\n * @returns The properties of the last saved txn, or `undefined` if none exist.\r\n */\r\n public getLastSavedTxnProps(): TxnProps | undefined {\r\n return this.getTxnProps(this.queryPreviousTxnId(this.getCurrentTxnId()));\r\n }\r\n\r\n /** Dependency handlers may call method this to report a validation error.\r\n * @param error The error. If error.fatal === true, the transaction will cancel rather than commit.\r\n */\r\n public reportError(error: ValidationError) {\r\n this.validationErrors.push(error);\r\n this._nativeDb.logTxnError(error.fatal);\r\n }\r\n\r\n /** Determine whether any fatal validation errors have occurred during dependency propagation. */\r\n public get hasFatalError(): boolean { return this._nativeDb.hasFatalTxnError(); }\r\n\r\n /** @internal */\r\n public readonly onEndValidation = new BeEvent<() => void>();\r\n\r\n /** Called after validation completes from [[IModelDb.saveChanges]].\r\n * The argument to the event holds the list of elements that were inserted, updated, and deleted.\r\n * @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onElementsChanged = new BeEvent<(changes: TxnChangedEntities) => void>();\r\n\r\n /** Called after validation completes from [[IModelDb.saveChanges]].\r\n * The argument to the event holds the list of models that were inserted, updated, and deleted.\r\n * @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onModelsChanged = new BeEvent<(changes: TxnChangedEntities) => void>();\r\n\r\n /** Event raised after the geometry within one or more [[GeometricModel]]s is modified by applying a changeset or validation of a transaction.\r\n * A model's geometry can change as a result of:\r\n * - Insertion or deletion of a geometric element within the model; or\r\n * - Modification of an existing element's geometric properties; or\r\n * - An explicit request to flag it as changed via [[IModelDb.Models.updateModel]].\r\n */\r\n public readonly onModelGeometryChanged = new BeEvent<(changes: ReadonlyArray<ModelIdAndGeometryGuid>) => void>();\r\n\r\n public readonly onGeometryChanged = new BeEvent<(models: ModelGeometryChangesProps[]) => void>();\r\n /** Event raised before a commit operation is performed. Initiated by a call to [[IModelDb.saveChanges]], unless there are no changes to save. */\r\n public readonly onCommit = new BeEvent<() => void>();\r\n /** Event raised after a commit operation has been performed. Initiated by a call to [[IModelDb.saveChanges]], even if there were no changes to save. */\r\n public readonly onCommitted = new BeEvent<() => void>();\r\n /** Event raised after a ChangeSet has been applied to this briefcase */\r\n public readonly onChangesApplied = new BeEvent<() => void>();\r\n /** Event raised before an undo/redo operation is performed. */\r\n public readonly onBeforeUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n /** Event raised after an undo/redo operation has been performed.\r\n * @param _action The action that was performed.\r\n */\r\n public readonly onAfterUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n /** Event raised for a read-only briefcase that was opened with the `watchForChanges` flag enabled when changes made by another connection are applied to the briefcase.\r\n * @see [[onReplayedExternalTxns]] for the event raised after all such changes have been applied.\r\n */\r\n public readonly onReplayExternalTxns = new BeEvent<() => void>();\r\n /** Event raised for a read-only briefcase that was opened with the `watchForChanges` flag enabled when changes made by another connection are applied to the briefcase.\r\n * @see [[onReplayExternalTxns]] for the event raised before the changes are applied.\r\n */\r\n public readonly onReplayedExternalTxns = new BeEvent<() => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase transaction begins.\r\n */\r\n public readonly onRebaseTxnBegin = new BeEvent<(txn: TxnProps) => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase transaction ends.\r\n */\r\n public readonly onRebaseTxnEnd = new BeEvent<(txn: TxnProps) => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase begins.\r\n */\r\n public readonly onRebaseBegin = new BeEvent<(txns: TxnIdString[]) => void>();\r\n\r\n /**\r\n * @alpha\r\n * Event raised when a rebase ends.\r\n */\r\n public readonly onRebaseEnd = new BeEvent<() => void>();\r\n\r\n /** Event raised after changes are pulled from iModelHub.\r\n * @see [[BriefcaseDb.pullChanges]].\r\n */\r\n public readonly onChangesPulled = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /** Event raised after changes are pushed to iModelHub.\r\n * @see [[BriefcaseDb.pushChanges]].\r\n */\r\n public readonly onChangesPushed = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /**\r\n * if handler is set and it does not return undefined then default handler will not be called\r\n * @internal\r\n * */\r\n public appCustomConflictHandler?: (args: DbRebaseChangesetConflictArgs) => DbConflictResolution | undefined;\r\n\r\n /**\r\n * Restart the current TxnManager session. This causes all Txns in the current session to no longer be undoable (as if the file was closed\r\n * and reopened.)\r\n * @note This can be quite disconcerting to the user expecting to be able to undo previously made changes. It should only be used\r\n * under extreme circumstances where damage to the file or session could happen if the currently committed are reversed. Use sparingly and with care.\r\n * Probably a good idea to alert the user it happened.\r\n */\r\n public restartSession() {\r\n this._nativeDb.restartTxnSession();\r\n }\r\n\r\n /** Determine whether current txn is propagating indirect changes or not. */\r\n public get isIndirectChanges(): boolean { return this.getMode() === \"indirect\" }\r\n\r\n /** Determine if there are currently any reversible (undoable) changes from this editing session. */\r\n public get isUndoPossible(): boolean { return this._nativeDb.isUndoPossible(); }\r\n\r\n /** Determine if there are currently any reinstatable (redoable) changes */\r\n public get isRedoPossible(): boolean { return this._nativeDb.isRedoPossible(); }\r\n\r\n /** Get the description of the operation that would be reversed by calling reverseTxns(1).\r\n * This is useful for showing the operation that would be undone, for example in a menu.\r\n */\r\n public getUndoString(): string { return this._nativeDb.getUndoString(); }\r\n\r\n /** Get a description of the operation that would be reinstated by calling reinstateTxn.\r\n * This is useful for showing the operation that would be redone, in a pull-down menu for example.\r\n */\r\n public getRedoString(): string { return this._nativeDb.getRedoString(); }\r\n\r\n /** Begin a new multi-Txn operation. This can be used to cause a series of Txns that would normally\r\n * be considered separate actions for undo to be grouped into a single undoable operation. This means that when reverseTxns(1) is called,\r\n * the entire group of changes are undone together. Multi-Txn operations can be nested and until the outermost operation is closed\r\n * all changes constitute a single operation.\r\n * @note This method must always be paired with a call to endMultiTxnAction.\r\n */\r\n public beginMultiTxnOperation(): DbResult { return this._nativeDb.beginMultiTxnOperation(); }\r\n\r\n /** End a multi-Txn operation */\r\n public endMultiTxnOperation(): DbResult { return this._nativeDb.endMultiTxnOperation(); }\r\n\r\n /** Return the depth of the multi-Txn stack. Generally for diagnostic use only. */\r\n public getMultiTxnOperationDepth(): number { return this._nativeDb.getMultiTxnOperationDepth(); }\r\n\r\n /** Reverse (undo) the most recent operation(s) to this IModelDb.\r\n * @param numOperations the number of operations to reverse. If this is greater than 1, the entire set of operations will\r\n * be reinstated together when/if ReinstateTxn is called.\r\n * @note If there are any outstanding uncommitted changes, they are reversed.\r\n * @note The term \"operation\" is used rather than Txn, since multiple Txns can be grouped together via [[beginMultiTxnOperation]]. So,\r\n * even if numOperations is 1, multiple Txns may be reversed if they were grouped together when they were made.\r\n * @note If numOperations is too large only the operations are reversible are reversed.\r\n */\r\n public reverseTxns(numOperations: number): IModelStatus {\r\n return this._nativeDb.reverseTxns(numOperations);\r\n }\r\n\r\n /** Reverse the most recent operation. */\r\n public reverseSingleTxn(): IModelStatus { return this.reverseTxns(1); }\r\n\r\n /** Reverse all changes back to the beginning of the session. */\r\n public reverseAll(): IModelStatus { return this._nativeDb.reverseAll(); }\r\n\r\n /** Reverse all changes back to a previously saved TxnId.\r\n * @param txnId a TxnId obtained from a previous call to GetCurrentTxnId.\r\n * @returns Success if the transactions were reversed, error status otherwise.\r\n * @see [[getCurrentTxnId]] [[cancelTo]]\r\n */\r\n public reverseTo(txnId: TxnIdString): IModelStatus { return this._nativeDb.reverseTo(txnId); }\r\n\r\n /** Reverse and then cancel (make non-reinstatable) all changes back to a previous TxnId.\r\n * @param txnId a TxnId obtained from a previous call to [[getCurrentTxnId]]\r\n * @returns Success if the transactions were reversed and cleared, error status otherwise.\r\n */\r\n public cancelTo(txnId: TxnIdString): IModelStatus { return this._nativeDb.cancelTo(txnId); }\r\n\r\n /** Reinstate the most recently reversed transaction. Since at any time multiple transactions can be reversed, it\r\n * may take multiple calls to this method to reinstate all reversed operations.\r\n * @returns Success if a reversed transaction was reinstated, error status otherwise.\r\n * @note If there are any outstanding uncommitted changes, they are canceled before the Txn is reinstated.\r\n */\r\n public reinstateTxn(): IModelStatus { return this._iModel.reinstateTxn(); }\r\n\r\n /** Get the Id of the first transaction, if any.\r\n */\r\n public queryFirstTxnId(): TxnIdString { return this._nativeDb.queryFirstTxnId(); }\r\n\r\n /** Get the successor of the specified TxnId */\r\n public queryNextTxnId(txnId: TxnIdString): TxnIdString { return this._nativeDb.queryNextTxnId(txnId); }\r\n\r\n /** Get the predecessor of the specified TxnId */\r\n public queryPreviousTxnId(txnId: TxnIdString): TxnIdString { return this._nativeDb.queryPreviousTxnId(txnId); }\r\n\r\n /** Get the Id of the current (tip) transaction. */\r\n public getCurrentTxnId(): TxnIdString { return this._nativeDb.getCurrentTxnId(); }\r\n\r\n /**\r\n * @alpha\r\n * Get the Id of the current session.\r\n */\r\n public getCurrentSessionId(): number { return this._nativeDb.currentTxnSessionId(); }\r\n\r\n /** Get the description that was supplied when the specified transaction was saved. */\r\n public getTxnDescription(txnId: TxnIdString): string { return this._nativeDb.getTxnDescription(txnId); }\r\n\r\n /** Test if a TxnId is valid */\r\n public isTxnIdValid(txnId: TxnIdString): boolean { return this._nativeDb.isTxnIdValid(txnId); }\r\n\r\n /** Query if there are any pending Txns in this IModelDb that are waiting to be pushed.\r\n * @see [[IModelDb.pushChanges]]\r\n */\r\n public get hasPendingTxns(): boolean { return this._nativeDb.hasPendingTxns(); }\r\n\r\n /**\r\n * Query if there are any changes in memory that have yet to be saved to the IModelDb.\r\n * @see [[IModelDb.saveChanges]]\r\n */\r\n public get hasUnsavedChanges(): boolean { return this._nativeDb.hasUnsavedChanges(); }\r\n\r\n /**\r\n * @alpha\r\n * Query if there are any pending schema changes in this IModelDb.\r\n */\r\n public get hasPendingSchemaChanges(): boolean { return this._nativeDb.hasPendingSchemaChanges(); }\r\n\r\n /**\r\n * Query if there are changes in memory that have not been saved to the iModelDb or if there are Txns that are waiting to be pushed.\r\n * @see [[IModelDb.saveChanges]]\r\n * @see [[IModelDb.pushChanges]]\r\n */\r\n public get hasLocalChanges(): boolean { return this.hasUnsavedChanges || this.hasPendingTxns; }\r\n\r\n /** Destroy the record of all local changes that have yet to be saved and/or pushed.\r\n * This permanently eradicates your changes - use with caution!\r\n * Typically, callers will want to subsequently use [[LockControl.releaseAllLocks]].\r\n * After calling this function, [[hasLocalChanges]], [[hasPendingTxns]], and [[hasUnsavedChanges]] will all be `false`.\r\n */\r\n public deleteAllTxns(): void {\r\n this._nativeDb.deleteAllTxns();\r\n }\r\n\r\n /** Obtain a list of the EC instances that have been changed locally by the [[BriefcaseDb]] associated with this `TxnManager` and have not yet been pushed to the iModel.\r\n * @beta\r\n */\r\n public queryLocalChanges(args?: QueryLocalChangesArgs): Iterable<ChangeInstanceKey> {\r\n if (!args) {\r\n args = { includedClasses: [], includeUnsavedChanges: false };\r\n }\r\n return this._nativeDb.getLocalChanges(args.includedClasses ?? [], args.includeUnsavedChanges ?? false);\r\n }\r\n\r\n /** Query the number of bytes of memory currently allocated by SQLite to keep track of\r\n * changes to the iModel, for debugging/diagnostic purposes, as reported by [sqlite3session_memory_used](https://www.sqlite.org/session/sqlite3session_memory_used.html).\r\n */\r\n public getChangeTrackingMemoryUsed(): number {\r\n return this._iModel[_nativeDb].getChangeTrackingMemoryUsed();\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Get the current transaction mode.\r\n * @returns The current transaction mode, either \"direct\" or \"indirect\".\r\n */\r\n public getMode(): TxnMode {\r\n return this._nativeDb.getTxnMode();\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Execute a series of changes in an indirect transaction.\r\n * @param callback The function containing the changes to make.\r\n */\r\n public withIndirectTxnMode(callback: () => void): void {\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"indirect\");\r\n }\r\n this._withIndirectChangeRefCounter++;\r\n try {\r\n callback();\r\n } finally {\r\n this._withIndirectChangeRefCounter--;\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"direct\");\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Execute a series of changes in an indirect transaction.\r\n * @param callback The function containing the changes to make.\r\n */\r\n public async withIndirectTxnModeAsync(callback: () => Promise<void>): Promise<void> {\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"indirect\");\r\n }\r\n this._withIndirectChangeRefCounter++;\r\n try {\r\n await callback();\r\n } finally {\r\n this._withIndirectChangeRefCounter--;\r\n if (this._withIndirectChangeRefCounter === 0) {\r\n this._nativeDb.setTxnMode(\"direct\");\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Interface for handling rebase operations on transactions.\r\n * @alpha\r\n */\r\nexport interface RebaseHandler {\r\n /**\r\n * Determine whether a transaction should be reinstated during a rebase operation.\r\n * @param txn The transaction to check.\r\n *\r\n * @alpha\r\n */\r\n shouldReinstate(txn: TxnProps): boolean;\r\n /**\r\n * Recompute the changes for a given transaction.\r\n * @param txn The transaction to recompute.\r\n *\r\n * @alpha\r\n */\r\n recompute(txn: TxnProps): Promise<void>;\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ChangesetECAdaptor.d.ts","sourceRoot":"","sources":["../../src/ChangesetECAdaptor.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAA8B,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAgB,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAuVvH;;;KAGK;AACL,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,EAAE,EAAE,cAAc,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,gBAAgB,CAAC;IACxB,sFAAsF;IACtF,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,iEAAiE;IACjE,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEhC,YAAY,EAAE,UAAU,CAAC;IAEzB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AA6BD;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAC;IAEhD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,GAAG,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IA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O,CAAC,IAAI,IAAI;IAI/B;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAYlC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;IAoBvB;;;;OAIG;IACI,SAAS,CAAC,SAAS,EAAE,MAAM;IAIlC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAWxB,qCAAqC;IACrC,IAAW,EAAE,mBAA6B;IAC1C,0DAA0D;IAC1D,IAAW,UAAU,YAAqC;IAC1D,yDAAyD;IACzD,IAAW,SAAS,YAAoC;IACxD,yDAAyD;IACzD,IAAW,SAAS,YAAoC;IAExD;;;OAGG;IACI,IAAI,IAAI,OAAO;IA4GtB;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAwBnC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;CA6ClB"}
@@ -8,7 +8,6 @@
8
8
  import { DbResult, Guid } from "@itwin/core-bentley";
9
9
  import { Base64EncodedString } from "@itwin/core-common";
10
10
  import { ECDb } from "./ECDb";
11
- import { _nativeDb } from "./internal/Symbols";
12
11
  class ECDbMap {
13
12
  db;
14
13
  _cachedClassMaps = new Map();
@@ -438,7 +437,6 @@ class SqliteBackedInstanceCache {
438
437
  this._db.clearStatementCache();
439
438
  else {
440
439
  this._db.clearCaches();
441
- this._db[_nativeDb].clearECDbCache();
442
440
  }
443
441
  this._db.withSqliteStatement(`DROP TABLE IF EXISTS ${this._cacheTable}`, (stmt) => {
444
442
  if (DbResult.BE_SQLITE_DONE !== stmt.step())