@itwin/core-backend 5.10.0-dev.11 → 5.10.0-dev.13

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 (114) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/Category.d.ts +4 -4
  3. package/lib/cjs/Category.js.map +1 -1
  4. package/lib/cjs/ChangesetECAdaptor.d.ts +6 -6
  5. package/lib/cjs/ChangesetECAdaptor.js +4 -4
  6. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  7. package/lib/cjs/CodeSpecs.d.ts +3 -3
  8. package/lib/cjs/CodeSpecs.js.map +1 -1
  9. package/lib/cjs/DisplayStyle.d.ts +2 -2
  10. package/lib/cjs/DisplayStyle.js.map +1 -1
  11. package/lib/cjs/Element.d.ts +10 -10
  12. package/lib/cjs/Element.js +2 -2
  13. package/lib/cjs/Element.js.map +1 -1
  14. package/lib/cjs/ElementAspect.d.ts +1 -1
  15. package/lib/cjs/ElementAspect.js.map +1 -1
  16. package/lib/cjs/ElementTreeWalker.d.ts +5 -5
  17. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  18. package/lib/cjs/ExternalSource.d.ts +2 -2
  19. package/lib/cjs/ExternalSource.js.map +1 -1
  20. package/lib/cjs/IModelDb.d.ts +33 -23
  21. package/lib/cjs/IModelDb.d.ts.map +1 -1
  22. package/lib/cjs/IModelDb.js +32 -20
  23. package/lib/cjs/IModelDb.js.map +1 -1
  24. package/lib/cjs/LineStyle.d.ts +6 -6
  25. package/lib/cjs/LineStyle.js.map +1 -1
  26. package/lib/cjs/Material.d.ts +1 -1
  27. package/lib/cjs/Material.js.map +1 -1
  28. package/lib/cjs/Model.d.ts +6 -6
  29. package/lib/cjs/Model.js.map +1 -1
  30. package/lib/cjs/Relationship.d.ts +10 -10
  31. package/lib/cjs/Relationship.js +6 -6
  32. package/lib/cjs/Relationship.js.map +1 -1
  33. package/lib/cjs/SheetIndex.d.ts +4 -4
  34. package/lib/cjs/SheetIndex.js.map +1 -1
  35. package/lib/cjs/Texture.d.ts +1 -1
  36. package/lib/cjs/Texture.js.map +1 -1
  37. package/lib/cjs/ViewDefinition.d.ts +6 -6
  38. package/lib/cjs/ViewDefinition.js.map +1 -1
  39. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  40. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  41. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -1
  42. package/lib/cjs/annotations/FrameGeometry.js +2 -3
  43. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  44. package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
  45. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  46. package/lib/cjs/domains/GenericElements.d.ts +2 -2
  47. package/lib/cjs/domains/GenericElements.js.map +1 -1
  48. package/lib/cjs/internal/ChannelAdmin.d.ts +2 -2
  49. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  50. package/lib/cjs/internal/ServerBasedLocks.d.ts +19 -1
  51. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
  52. package/lib/cjs/internal/ServerBasedLocks.js +55 -1
  53. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  54. package/lib/esm/Category.d.ts +4 -4
  55. package/lib/esm/Category.js.map +1 -1
  56. package/lib/esm/ChangesetECAdaptor.d.ts +6 -6
  57. package/lib/esm/ChangesetECAdaptor.js +4 -4
  58. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  59. package/lib/esm/CodeSpecs.d.ts +3 -3
  60. package/lib/esm/CodeSpecs.js.map +1 -1
  61. package/lib/esm/DisplayStyle.d.ts +2 -2
  62. package/lib/esm/DisplayStyle.js.map +1 -1
  63. package/lib/esm/Element.d.ts +10 -10
  64. package/lib/esm/Element.js +2 -2
  65. package/lib/esm/Element.js.map +1 -1
  66. package/lib/esm/ElementAspect.d.ts +1 -1
  67. package/lib/esm/ElementAspect.js.map +1 -1
  68. package/lib/esm/ElementTreeWalker.d.ts +5 -5
  69. package/lib/esm/ElementTreeWalker.js.map +1 -1
  70. package/lib/esm/ExternalSource.d.ts +2 -2
  71. package/lib/esm/ExternalSource.js.map +1 -1
  72. package/lib/esm/IModelDb.d.ts +33 -23
  73. package/lib/esm/IModelDb.d.ts.map +1 -1
  74. package/lib/esm/IModelDb.js +32 -20
  75. package/lib/esm/IModelDb.js.map +1 -1
  76. package/lib/esm/LineStyle.d.ts +6 -6
  77. package/lib/esm/LineStyle.js.map +1 -1
  78. package/lib/esm/Material.d.ts +1 -1
  79. package/lib/esm/Material.js.map +1 -1
  80. package/lib/esm/Model.d.ts +6 -6
  81. package/lib/esm/Model.js.map +1 -1
  82. package/lib/esm/Relationship.d.ts +10 -10
  83. package/lib/esm/Relationship.js +6 -6
  84. package/lib/esm/Relationship.js.map +1 -1
  85. package/lib/esm/SheetIndex.d.ts +4 -4
  86. package/lib/esm/SheetIndex.js.map +1 -1
  87. package/lib/esm/Texture.d.ts +1 -1
  88. package/lib/esm/Texture.js.map +1 -1
  89. package/lib/esm/ViewDefinition.d.ts +6 -6
  90. package/lib/esm/ViewDefinition.js.map +1 -1
  91. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  92. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  93. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -1
  94. package/lib/esm/annotations/FrameGeometry.js +2 -3
  95. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  96. package/lib/esm/domains/FunctionalElements.d.ts +1 -1
  97. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  98. package/lib/esm/domains/GenericElements.d.ts +2 -2
  99. package/lib/esm/domains/GenericElements.js.map +1 -1
  100. package/lib/esm/internal/ChannelAdmin.d.ts +2 -2
  101. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  102. package/lib/esm/internal/ServerBasedLocks.d.ts +19 -1
  103. package/lib/esm/internal/ServerBasedLocks.d.ts.map +1 -1
  104. package/lib/esm/internal/ServerBasedLocks.js +55 -1
  105. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  106. package/lib/esm/test/annotations/FrameGeometry.test.js +2 -1
  107. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  108. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +10 -0
  109. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  110. package/lib/esm/test/standalone/DeleteElements.test.js +45 -0
  111. package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
  112. package/lib/esm/test/standalone/ServerBasedLocks.test.js +62 -0
  113. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  114. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"ServerBasedLocks.js","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAqiB/F,wDAEC;AAriBD;;GAEG;AAEH,sDAAkG;AAClG,oDAA2F;AAI3F,8CAA2C;AAC3C,0CAAuC;AACvC,uCAA2H;AAmB3H,MAAa,gBAAgB;IACX,CAAC,mCAAyB,CAAC,GAAG,SAAS,CAAC;IAExD,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IACxB,MAAM,GAAG,IAAI,mBAAQ,EAAE,CAAC;IACxB,SAAS,CAAc;IAClC,uBAAuB,CAAa;IAC3B,oBAAoB,GAAG,oBAAoB,CAAC,CAAC,qEAAqE;IAEnI,YAAmB,MAAmB;QACpC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAS,CAAC,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QAElE,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAQ,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAA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,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAElF,uGAAuG;IAChG,kBAAkB,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACvE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,8BAA8B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtH,CAAC;IAED,kGAAkG;IAC3F,eAAe,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACpE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,2BAA2B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnH,CAAC;CAEF;AAngBD,4CAmgBC;AAED,SAAgB,sBAAsB,CAAC,MAAmB;IACxD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC","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\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModel, IModelError, LockState, ServerBasedLocksError } from \"@itwin/core-common\";\r\nimport { LockMap } from \"../BackendHubAccess\";\r\nimport { BriefcaseDb } from \"../IModelDb\";\r\nimport { LockControl } from \"../LockControl\";\r\nimport { IModelHost } from \"../IModelHost\";\r\nimport { SQLiteDb } from \"../SQLiteDb\";\r\nimport { _close, _elementWasCreated, _hubAccess, _implementationProhibited, _nativeDb, _releaseAllLocks } from \"./Symbols\";\r\n\r\n/**\r\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\r\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\r\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\r\n */\r\ninterface ElementOwners {\r\n readonly modelId: Id64String;\r\n readonly parentId: Id64String | undefined;\r\n}\r\n\r\n// eslint-disable-next-line no-restricted-syntax\r\nconst enum LockOrigin {\r\n Acquired = 0,\r\n NewElement = 1,\r\n Discovered = 2,\r\n}\r\n\r\nexport class ServerBasedLocks implements LockControl {\r\n public readonly [_implementationProhibited] = undefined;\r\n\r\n public get isServerBased() { return true; }\r\n protected readonly lockDb = new SQLiteDb();\r\n protected readonly briefcase: BriefcaseDb;\r\n private _removeOnCommitListener: () => void;\r\n private readonly _unsavedChangesTxnId = \"0x7FFFFFFFFFFFFFFF\"; // a placeholder txn id for locks acquired in the current unsaved Txn\r\n\r\n public constructor(iModel: BriefcaseDb) {\r\n this.briefcase = iModel;\r\n const dbName = `${iModel[_nativeDb].getTempFileBaseName()}-locks`;\r\n\r\n try {\r\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\r\n } catch {\r\n this.lockDb.createDb(dbName);\r\n }\r\n\r\n // Tracks the locks that are actively held.\r\n this.lockDb.executeSQL(\"CREATE TABLE IF NOT EXISTS locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\r\n // Tracks the locks that are required by each Txn. They may or may not currently be held.\r\n this.lockDb.executeSQL(`\r\n CREATE TABLE IF NOT EXISTS txn_locks(\r\n txnId INTEGER NOT NULL,\r\n elementId INTEGER NOT NULL,\r\n state INTEGER NOT NULL,\r\n origin INTEGER NOT NULL,\r\n abandoned BOOLEAN NOT NULL,\r\n PRIMARY KEY (txnId, elementId))`);\r\n this.lockDb.saveChanges();\r\n\r\n this._removeOnCommitListener = this.briefcase.txns.onCommit.addListener(() => {\r\n const committedTxnId = this.briefcase.txns.queryPreviousTxnId(this.briefcase.txns.getCurrentTxnId())\r\n\r\n // With this commit, any reversed txns with the committed txn's ID or greater are no longer reinstatable,\r\n // so clear out the record of their locks. If the locks are still held, sorry, it's too late!\r\n this.clearTxnLockRecords(committedTxnId);\r\n\r\n // All of the \"current\" changes are now part of a real txn, so update the txn id accordingly.\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE txn_locks SET txnId=? WHERE txnId=?\", (stmt) => {\r\n stmt.bindId(1, committedTxnId);\r\n stmt.bindId(2, this._unsavedChangesTxnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't update locks database with txn ID of unsaved changes txn upon saving (error code ${rc})`);\r\n });\r\n\r\n this.lockDb.saveChanges();\r\n });\r\n }\r\n\r\n public [_close]() {\r\n this._removeOnCommitListener();\r\n\r\n if (this.lockDb.isOpen)\r\n this.lockDb.closeDb();\r\n }\r\n\r\n private getOwners(id: Id64String): ElementOwners {\r\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_ROW !== rc)\r\n throw new IModelError(rc, `element ${id} not found`);\r\n\r\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\r\n });\r\n }\r\n\r\n private getLockState(id?: Id64String): LockState | undefined {\r\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\r\n });\r\n }\r\n\r\n /** Clear the cache of locally held locks.\r\n * Note: does *not* release locks from server.\r\n */\r\n private clearAllLocks() {\r\n this.lockDb.executeSQL(\"DELETE FROM locks\");\r\n this.lockDb.executeSQL(\"DELETE FROM txn_locks\");\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** only for tests */\r\n public getLockCount(state: LockState): number {\r\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\r\n stmt.bindInteger(1, state);\r\n stmt.step();\r\n return stmt.getValueInteger(0);\r\n });\r\n }\r\n\r\n public async [_releaseAllLocks](): Promise<void> {\r\n await IModelHost[_hubAccess].releaseAllLocks(this.briefcase); // throws if unsuccessful\r\n this.clearAllLocks();\r\n }\r\n\r\n public async releaseAllLocks(): Promise<void> {\r\n if (this.briefcase.txns.hasLocalChanges) {\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", \"Locks cannot be released while the briefcase contains local changes\");\r\n }\r\n\r\n return this[_releaseAllLocks]();\r\n }\r\n\r\n public async abandonAllLocks(): Promise<void> {\r\n if (this.briefcase.txns.hasLocalChanges) {\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", \"Locks cannot be abandoned while the briefcase contains local changes\");\r\n }\r\n\r\n if (IModelHost[_hubAccess].abandonAllLocks === undefined) {\r\n // If the IModelHub doesn't support an explicit abandon, call release with a blank changeset to indicate\r\n // that locks should be released without updating the changeset associated with the locks.\r\n await IModelHost[_hubAccess].releaseAllLocks({\r\n iModelId: this.briefcase.iModelId,\r\n briefcaseId: this.briefcase.briefcaseId,\r\n changeset: { id: \"\", index: 0 }\r\n });\r\n } else {\r\n await IModelHost[_hubAccess].abandonAllLocks(this.briefcase);\r\n }\r\n\r\n this.clearAllLocks();\r\n }\r\n\r\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\r\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\r\n stmt.bindId(1, id);\r\n stmt.bindInteger(2, state);\r\n stmt.bindInteger(3, origin);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n throw new IModelError(rc, \"can't insert lock into database\");\r\n });\r\n\r\n return true;\r\n }\r\n\r\n private insertTxnLockRecord(id: Id64String, state: LockState, origin: LockOrigin): void {\r\n // Locks are always acquired in the current txn, which isn't a real txn until it's committed.\r\n // So use a placeholder txn id for now, and we'll update to the real txn id on commit.\r\n // This is important to distinguish new locks acquired in the current txn from locks acquired in previous reversed txns, which will only\r\n // be cleared (no longer reinstateable) on commit.\r\n this.lockDb.withPreparedSqliteStatement(`\r\n INSERT INTO txn_locks(txnId,elementId,state,origin,abandoned)\r\n VALUES (?,?,?,?,FALSE)\r\n ON CONFLICT(txnId,elementId)\r\n DO UPDATE SET\r\n state=excluded.state,\r\n origin=excluded.origin,\r\n abandoned=excluded.abandoned`, (stmt) => {\r\n stmt.bindId(1, this._unsavedChangesTxnId);\r\n stmt.bindId(2, id);\r\n stmt.bindInteger(3, state);\r\n stmt.bindInteger(4, origin);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't insert txn lock record into database (error code ${rc})`);\r\n });\r\n }\r\n\r\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\r\n if (id === undefined || id === IModel.rootSubjectId)\r\n return false; // has no owners\r\n\r\n const { modelId, parentId } = this.getOwners(id);\r\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\r\n return true;\r\n\r\n // see if this model is exclusively locked by one of its owners. If so, save that fact on modelId so future tests won't have to descend.\r\n if (this.ownerHoldsExclusiveLock(modelId))\r\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\r\n\r\n // see if the parent is exclusively locked by one of its owners. If so, save that fact on parentId so future tests won't have to descend.\r\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\r\n public holdsExclusiveLock(id: Id64String): boolean {\r\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\r\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n public holdsSharedLock(id: Id64String): boolean {\r\n const state = this.getLockState(id);\r\n // see if we hold shared or exclusive lock, or if an owner has exclusive lock. If so we implicitly have shared lock, but owner holding shared lock doesn't help.\r\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */\r\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\r\n // if the id is not valid, or of the lock is already in the set, or if we already hold a shared lock, we're done\r\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\r\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\r\n return;\r\n\r\n locks.add(id); // add to set of needed shared locks\r\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\r\n }\r\n\r\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\r\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\r\n const el = this.getOwners(id);\r\n this.addSharedLock(el.parentId, locks); // if this element is in a group\r\n this.addSharedLock(el.modelId, locks); // check its model\r\n }\r\n\r\n /** attempt to acquire all necessary locks for a set of elements */\r\n private async acquireAllLocks(locks: LockMap) {\r\n if (locks.size === 0) // no locks are required.\r\n return;\r\n\r\n const sharedLocks = new Set<Id64String>();\r\n for (const lock of locks)\r\n this.addOwnerSharedLocks(lock[0], sharedLocks);\r\n\r\n for (const shared of sharedLocks) {\r\n if (!locks.has(shared)) // we may already be asking for exclusive lock\r\n locks.set(shared, LockState.Shared);\r\n }\r\n\r\n await IModelHost[_hubAccess].acquireLocks(this.briefcase, locks); // throws if unsuccessful\r\n for (const lock of locks) {\r\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\r\n this.insertTxnLockRecord(lock[0], lock[1], LockOrigin.Acquired);\r\n }\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\r\n const locks = new Map<Id64String, LockState>();\r\n if (arg.shared) {\r\n for (const id of Id64.iterable(arg.shared)) {\r\n if (!this.holdsSharedLock(id))\r\n locks.set(id, LockState.Shared);\r\n }\r\n }\r\n if (arg.exclusive) {\r\n for (const id of Id64.iterable(arg.exclusive)) {\r\n if (!this.holdsExclusiveLock(id))\r\n locks.set(id, LockState.Exclusive);\r\n }\r\n }\r\n return this.acquireAllLocks(locks);\r\n }\r\n\r\n private async abandonLocks(locks: LockMap): Promise<void> {\r\n if (IModelHost[_hubAccess].abandonLocks === undefined) {\r\n // If the IModelHub doesn't support an explicit abandon, call acquireLocks with a blank changeset to indicate\r\n // that locks should be released without updating the changeset associated with the locks.\r\n await IModelHost[_hubAccess].acquireLocks({\r\n iModelId: this.briefcase.iModelId,\r\n briefcaseId: this.briefcase.briefcaseId,\r\n changeset: { id: \"\", index: 0 }\r\n }, locks);\r\n } else {\r\n await IModelHost[_hubAccess].abandonLocks(this.briefcase, locks);\r\n }\r\n }\r\n\r\n public async abandonLocksForCurrentUnsavedTxn(): Promise<boolean> {\r\n return this.abandonLocksForReversedTxn(this._unsavedChangesTxnId);\r\n }\r\n\r\n public async abandonLocksForReversedTxn(txnId: Id64String): Promise<boolean> {\r\n if (this.briefcase.txns.hasUnsavedChanges)\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", `cannot abandon locks for txn ${txnId} because the current txn has unsaved changes`);\r\n\r\n const txnProps = this.briefcase.txns.getTxnProps(txnId);\r\n if (txnProps === undefined) {\r\n // The current txn commonly won't exist on the TxnManager yet. It's often just a placeholder for not-yet-saved changes.\r\n // (Sometimes it will exist and refer to a reversed Txn).\r\n // The unsavedChangesTxnId won't exist on the TxnManager either, of course.\r\n // But all other txn ids must be known to the TxnManager or it is an error.\r\n if (txnId !== this.briefcase.txns.getCurrentTxnId() && txnId !== this._unsavedChangesTxnId)\r\n ServerBasedLocksError.throwError(\"txn-id-not-found\", `cannot abandon locks for txn ${txnId} because it does not exist`);\r\n } else {\r\n // If the txn id is known to the TxnManager, then we require that it has already been reversed.\r\n if (!txnProps.reversed)\r\n ServerBasedLocksError.throwError(\"txn-not-reversed\", `cannot abandon locks for txn ${txnId} because it has not been reversed`);\r\n }\r\n\r\n let locksReleased = false;\r\n\r\n // Abandon locks for unsaved (and now abandoned) changes.\r\n if (txnId !== this._unsavedChangesTxnId) {\r\n locksReleased = await this.abandonLocksForCurrentUnsavedTxn();\r\n }\r\n\r\n // At this point, we know:\r\n // 1. There are no unsaved changes, and the associated locks have been abandoned.\r\n // 2. The given txn ID has been reversed, which means any later txns are sure to have been reversed, too.\r\n\r\n // So we simply have to find all non-abandoned locks associated with the given txn or later, abandon them (or restore\r\n // them to their previous state), and mark them as abandoned in txn_locks.\r\n\r\n // Find all locks associated with the given txnId or later.\r\n // For each elementId, find the previous state of the lock before this Txn (if any), or None otherwise.\r\n // This is the state that we will restore the element's lock to. The reason we do this is to account for\r\n // lock upgrades. If an earlier Txn acquired a Shared lock on this element, and this Txn acquired an\r\n // Exclusive lock, we should restore the Shared lock.\r\n const allTxnLocks = new Map<Id64String, LockState>();\r\n const locksToRelease = new Map<Id64String, LockState>();\r\n this.lockDb.withPreparedSqliteStatement(\r\n `\r\n SELECT\r\n current.elementId,\r\n current.origin,\r\n IFNULL(\r\n (SELECT previous.state\r\n FROM txn_locks previous\r\n WHERE previous.elementId = current.elementId\r\n AND previous.txnId < ?2\r\n AND previous.abandoned=FALSE\r\n ORDER BY previous.txnId DESC\r\n LIMIT 1\r\n ),\r\n ?1\r\n ) AS previousState\r\n FROM txn_locks current\r\n WHERE current.txnId>=?2\r\n AND current.abandoned=FALSE\r\n ORDER BY current.txnId DESC\r\n `,\r\n (stmt) => {\r\n stmt.bindInteger(1, LockState.None);\r\n stmt.bindId(2, txnId);\r\n\r\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const elementId = stmt.getValueId(0);\r\n const origin = stmt.getValueInteger(1);\r\n const previousState = stmt.getValueInteger(2);\r\n allTxnLocks.set(elementId, previousState);\r\n if (origin !== LockOrigin.NewElement)\r\n locksToRelease.set(elementId, previousState);\r\n }\r\n });\r\n\r\n // Release the locks on the server.\r\n if (locksToRelease.size > 0)\r\n await this.abandonLocks(locksToRelease);\r\n\r\n // Mark the txn locks as abandoned.\r\n if (txnId === this._unsavedChangesTxnId) {\r\n // After abandoning locks held for the \"unsaved\" txn, we clear them completely because they are not reinstateable.\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM txn_locks WHERE txnId=?\", (stmt) => {\r\n stmt.bindId(1, this._unsavedChangesTxnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete txn locks for unsaved changes in database (error code ${rc})`);\r\n });\r\n } else {\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE txn_locks SET abandoned=TRUE WHERE txnId>=?\", (stmt) => {\r\n stmt.bindId(1, txnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't mark txn locks as abandoned in database (error code ${rc})`);\r\n });\r\n }\r\n\r\n // Restore each lock to its previous state (if any) in the local cache. Usually this means deleting it.\r\n for (const [elementId, previousState] of allTxnLocks) {\r\n if (previousState === LockState.None) {\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM locks WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, elementId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete lock from database (error code ${rc})`);\r\n });\r\n } else {\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE locks SET state=? WHERE id=?\", (stmt) => {\r\n stmt.bindInteger(1, previousState);\r\n stmt.bindId(2, elementId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't update lock in database (error code ${rc})`);\r\n });\r\n }\r\n }\r\n\r\n // Ideally we'd only invalidate \"Discovered\" locks that are related to this Txn's Shared and\r\n // Exclusive locks. But that is a lot of added complexity for little benefit.\r\n // Clearing them all will have no impact on correctness and a minimal impact on performance.\r\n this.clearDiscoveredLocks();\r\n\r\n this.lockDb.saveChanges();\r\n\r\n return locksReleased || allTxnLocks.size > 0;\r\n }\r\n\r\n private getAbandonedLocksForTxn(txnId: Id64String): {\r\n newElementLocks: Map<Id64String, LockState>,\r\n locksToAcquire: Map<Id64String, LockState>\r\n } {\r\n const newElementLocks = new Map<Id64String, LockState>();\r\n const locksToAcquire = new Map<Id64String, LockState>();\r\n this.lockDb.withPreparedSqliteStatement(\r\n \"SELECT elementId, state, origin FROM txn_locks WHERE txnId<=? AND abandoned=TRUE\",\r\n (stmt) => {\r\n stmt.bindId(1, txnId);\r\n\r\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const elementId = stmt.getValueId(0);\r\n const state = stmt.getValueInteger(1);\r\n const origin = stmt.getValueInteger(2);\r\n if (origin === LockOrigin.NewElement)\r\n newElementLocks.set(elementId, state);\r\n else\r\n locksToAcquire.set(elementId, state);\r\n }\r\n });\r\n\r\n return { newElementLocks, locksToAcquire };\r\n }\r\n\r\n public async acquireLocksForReinstatingTxn(txnId: Id64String): Promise<boolean> {\r\n if (this.briefcase.txns.hasUnsavedChanges)\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", `cannot acquire locks for reinstating txn ${txnId} because the current txn has unsaved changes`);\r\n\r\n // If the Txn is known to the TxnManager, we can proceed. We don't need to check if it is currently\r\n // reversed, because if it isn't, then abandonLocksForReversedTxn couldn't have been called, and so the\r\n // locks are still held. Proceeding with this method will be a no-op, but it will be harmless.\r\n // However, if the Txn Id is unknown, it may have been canceled or refer to the current Txn\r\n // whose unsaved changes were just abandoned. Or it's just plain-old invalid. In any case, we can't\r\n // re-acquire the associated locks.\r\n const txnProps = this.briefcase.txns.getTxnProps(txnId);\r\n if (txnProps === undefined) {\r\n ServerBasedLocksError.throwError(\"txn-id-not-found\", `cannot acquire locks for txn ${txnId} because it does not exist or has not been saved`);\r\n }\r\n\r\n // Find all locks associated with the given txnId.\r\n const { newElementLocks, locksToAcquire } = this.getAbandonedLocksForTxn(txnId);\r\n\r\n // Attempt to acquire the locks on the server. This may fail if the locks are no longer available!\r\n if (locksToAcquire.size > 0)\r\n await IModelHost[_hubAccess].acquireLocks(this.briefcase, locksToAcquire); // throws if unsuccessful\r\n\r\n // Mark the txn locks as no longer abandoned.\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE txn_locks SET abandoned=FALSE WHERE txnId<=?\", (stmt) => {\r\n stmt.bindId(1, txnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't mark txn locks as no longer abandoned in database (error code ${rc})`);\r\n });\r\n\r\n // Insert the newly-acquired locks in the local cache. Note that we don't need to insert entries in the txn_locks table,\r\n // because these locks are already associated with the Txn.\r\n for (const [elementId, state] of locksToAcquire) {\r\n this.insertLock(elementId, state, LockOrigin.Acquired);\r\n }\r\n for (const [elementId, state] of newElementLocks) {\r\n this.insertLock(elementId, state, LockOrigin.NewElement);\r\n }\r\n\r\n // Ideally we'd only invalidate \"Discovered\" locks that are related to this Txn's Shared and\r\n // Exclusive locks. But that is a lot of added complexity for little benefit.\r\n // Clearing them all will have no impact on correctness and a minimal impact on performance.\r\n this.clearDiscoveredLocks();\r\n\r\n this.lockDb.saveChanges();\r\n\r\n return locksToAcquire.size > 0 || newElementLocks.size > 0;\r\n }\r\n\r\n public holdsNecessaryLocksForReinstatingTxn(txnId: Id64String): boolean {\r\n const locks = this.getAbandonedLocksForTxn(txnId);\r\n return locks.locksToAcquire.size === 0 && locks.newElementLocks.size === 0;\r\n }\r\n\r\n public clearTxnLockRecords(txnId: Id64String) {\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM txn_locks WHERE txnId!=? AND txnId>=?\", (stmt) => {\r\n stmt.bindId(1, this._unsavedChangesTxnId);\r\n stmt.bindId(2, txnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete txn lock records from database (error code ${rc})`);\r\n });\r\n\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** When an element is newly created in a session, we hold the lock on it implicitly. Save that fact. */\r\n public [_elementWasCreated](id: Id64String) {\r\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\r\n this.insertTxnLockRecord(id, LockState.Exclusive, LockOrigin.NewElement);\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n private clearDiscoveredLocks() {\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM locks WHERE origin=?\", (stmt) => {\r\n stmt.bindInteger(1, LockOrigin.Discovered);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete discovered locks from database (error code ${rc})`);\r\n });\r\n }\r\n\r\n /** locks are not necessary during change propagation. */\r\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\r\n\r\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\r\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\r\n public checkSharedLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsSharedLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n}\r\n\r\nexport function createServerBasedLocks(iModel: BriefcaseDb): LockControl {\r\n return new ServerBasedLocks(iModel);\r\n}\r\n"]}
1
+ {"version":3,"file":"ServerBasedLocks.js","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAwmB/F,wDAEC;AAxmBD;;GAEG;AAEH,sDAAkG;AAClG,oDAA2F;AAI3F,8CAA2C;AAC3C,0CAAuC;AACvC,uCAA2H;AAmB3H,MAAa,gBAAgB;IACX,CAAC,mCAAyB,CAAC,GAAG,SAAS,CAAC;IAExD,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IACxB,MAAM,GAAG,IAAI,mBAAQ,EAAE,CAAC;IACxB,SAAS,CAAc;IAClC,uBAAuB,CAAa;IACpC,uBAAuB,CAAa;IAC5C;mHAC+G;IACvG,iBAAiB,GAAW,CAAC,CAAC;IACrB,oBAAoB,GAAG,oBAAoB,CAAC,CAAC,qEAAqE;IAEnI,YAAmB,MAAmB;QACpC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAS,CAAC,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QAElE,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAQ,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,mBAAS,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAE3C,2CAA2C;QAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,yGAAyG,CAAC,CAAC;QA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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\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModel, IModelError, LockState, ServerBasedLocksError } from \"@itwin/core-common\";\r\nimport { LockMap } from \"../BackendHubAccess\";\r\nimport { BriefcaseDb } from \"../IModelDb\";\r\nimport { LockControl } from \"../LockControl\";\r\nimport { IModelHost } from \"../IModelHost\";\r\nimport { SQLiteDb } from \"../SQLiteDb\";\r\nimport { _close, _elementWasCreated, _hubAccess, _implementationProhibited, _nativeDb, _releaseAllLocks } from \"./Symbols\";\r\n\r\n/**\r\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\r\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\r\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\r\n */\r\ninterface ElementOwners {\r\n readonly modelId: Id64String;\r\n readonly parentId: Id64String | undefined;\r\n}\r\n\r\n// eslint-disable-next-line no-restricted-syntax\r\nconst enum LockOrigin {\r\n Acquired = 0,\r\n NewElement = 1,\r\n Discovered = 2,\r\n}\r\n\r\nexport class ServerBasedLocks implements LockControl {\r\n public readonly [_implementationProhibited] = undefined;\r\n\r\n public get isServerBased() { return true; }\r\n protected readonly lockDb = new SQLiteDb();\r\n protected readonly briefcase: BriefcaseDb;\r\n private _removeOnCommitListener: () => void;\r\n private _removeOnPushedListener: () => void;\r\n /** The local ID portion of the highest element ID pushed to the server. Elements with this briefcase's ID\r\n * and a local ID greater than this value are implicitly exclusively locked by us (no server lock required). */\r\n private _highWaterLocalId: number = 0;\r\n private readonly _unsavedChangesTxnId = \"0x7FFFFFFFFFFFFFFF\"; // a placeholder txn id for locks acquired in the current unsaved Txn\r\n\r\n public constructor(iModel: BriefcaseDb) {\r\n this.briefcase = iModel;\r\n const dbName = `${iModel[_nativeDb].getTempFileBaseName()}-locks`;\r\n\r\n try {\r\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\r\n } catch {\r\n this.lockDb.createDb(dbName);\r\n }\r\n\r\n this.lockDb[_nativeDb].enableWalMode(true);\r\n\r\n // Tracks the locks that are actively held.\r\n this.lockDb.executeSQL(\"CREATE TABLE IF NOT EXISTS locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\r\n // Tracks the locks that are required by each Txn. They may or may not currently be held.\r\n this.lockDb.executeSQL(`\r\n CREATE TABLE IF NOT EXISTS txn_locks(\r\n txnId INTEGER NOT NULL,\r\n elementId INTEGER NOT NULL,\r\n state INTEGER NOT NULL,\r\n origin INTEGER NOT NULL,\r\n abandoned BOOLEAN NOT NULL,\r\n PRIMARY KEY (txnId, elementId))`);\r\n\r\n // Stores persistent metadata, including the high-water mark for new-element lock tracking.\r\n this.lockDb.executeSQL(\"CREATE TABLE IF NOT EXISTS metadata(key TEXT PRIMARY KEY NOT NULL,value INTEGER NOT NULL)\");\r\n\r\n // Initialize the high-water mark. If an existing value is stored, use it. Otherwise derive it from\r\n // the iModel's current element ID sequence — any element with this briefcase's ID and a local ID at\r\n // or below the sequence was either already pushed or was created-then-abandoned in a previous session.\r\n const storedHwm = this.lockDb.withSqliteStatement(\r\n \"SELECT value FROM metadata WHERE key='highWaterLocalId'\",\r\n (stmt) => (DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValueInteger(0) : undefined)\r\n );\r\n if (storedHwm !== undefined) {\r\n this._highWaterLocalId = storedHwm;\r\n } else {\r\n this.updateHighWaterMark();\r\n }\r\n\r\n this.lockDb.saveChanges();\r\n\r\n this._removeOnCommitListener = this.briefcase.txns.onCommit.addListener(() => {\r\n const committedTxnId = this.briefcase.txns.queryPreviousTxnId(this.briefcase.txns.getCurrentTxnId())\r\n\r\n // With this commit, any reversed txns with the committed txn's ID or greater are no longer reinstatable,\r\n // so clear out the record of their locks. If the locks are still held, sorry, it's too late!\r\n this.clearTxnLockRecords(committedTxnId);\r\n\r\n // All of the \"current\" changes are now part of a real txn, so update the txn id accordingly.\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE txn_locks SET txnId=? WHERE txnId=?\", (stmt) => {\r\n stmt.bindId(1, committedTxnId);\r\n stmt.bindId(2, this._unsavedChangesTxnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't update locks database with txn ID of unsaved changes txn upon saving (error code ${rc})`);\r\n });\r\n\r\n this.lockDb.saveChanges();\r\n });\r\n\r\n this._removeOnPushedListener = this.briefcase.txns.onChangesPushed.addListener(() => {\r\n this.updateHighWaterMark();\r\n this.lockDb.saveChanges();\r\n });\r\n }\r\n\r\n public [_close]() {\r\n this._removeOnCommitListener();\r\n this._removeOnPushedListener();\r\n\r\n if (this.lockDb.isOpen)\r\n this.lockDb.closeDb();\r\n }\r\n\r\n private getOwners(id: Id64String): ElementOwners {\r\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_ROW !== rc)\r\n throw new IModelError(rc, `element ${id} not found`);\r\n\r\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\r\n });\r\n }\r\n\r\n private getLockState(id?: Id64String): LockState | undefined {\r\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\r\n });\r\n }\r\n\r\n /** Read the local ID portion of the iModel's current element ID sequence counter.\r\n * The native layer writes this value with BeInt64Id::ToString() (decimal by default) but\r\n * BeInt64Id::FromString() accepts both decimal and \"0x\"-prefixed hex. BigInt() has the same\r\n * dual-format behavior, so it is the canonical JS equivalent. Mask to the lower 40 bits. */\r\n private readCurrentLocalIdSequence(): number {\r\n const seqStr = this.briefcase[_nativeDb].queryLocalValue(\"bis_elementidsequence\");\r\n if (!seqStr)\r\n return 0;\r\n return Number(BigInt(seqStr) & 0xFFFFFFFFFFn);\r\n }\r\n\r\n /** Persist the current element ID sequence as the new high-water mark. Called after a successful push. */\r\n private updateHighWaterMark(): void {\r\n this._highWaterLocalId = this.readCurrentLocalIdSequence();\r\n this.lockDb.withPreparedSqliteStatement(\r\n \"INSERT INTO metadata(key,value) VALUES('highWaterLocalId',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value\",\r\n (stmt) => { stmt.bindInteger(1, this._highWaterLocalId); stmt.step(); }\r\n );\r\n }\r\n\r\n /** Returns true if this element was created by this briefcase after the last push and therefore does not\r\n * require a server lock. */\r\n private isNewElement(id: Id64String): boolean {\r\n return Id64.getBriefcaseId(id) === this.briefcase.briefcaseId && Id64.getLocalId(id) > this._highWaterLocalId;\r\n }\r\n\r\n /** Clear the cache of locally held locks.\r\n * Note: does *not* release locks from server.\r\n */\r\n private clearAllLocks() {\r\n this.lockDb.executeSQL(\"DELETE FROM locks\");\r\n this.lockDb.executeSQL(\"DELETE FROM txn_locks\");\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** only for tests */\r\n public getLockCount(state: LockState): number {\r\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\r\n stmt.bindInteger(1, state);\r\n stmt.step();\r\n return stmt.getValueInteger(0);\r\n });\r\n }\r\n\r\n public async [_releaseAllLocks](): Promise<void> {\r\n await IModelHost[_hubAccess].releaseAllLocks(this.briefcase); // throws if unsuccessful\r\n this.clearAllLocks();\r\n }\r\n\r\n public async releaseAllLocks(): Promise<void> {\r\n if (this.briefcase.txns.hasLocalChanges) {\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", \"Locks cannot be released while the briefcase contains local changes\");\r\n }\r\n\r\n return this[_releaseAllLocks]();\r\n }\r\n\r\n public async abandonAllLocks(): Promise<void> {\r\n if (this.briefcase.txns.hasLocalChanges) {\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", \"Locks cannot be abandoned while the briefcase contains local changes\");\r\n }\r\n\r\n if (IModelHost[_hubAccess].abandonAllLocks === undefined) {\r\n // If the IModelHub doesn't support an explicit abandon, call release with a blank changeset to indicate\r\n // that locks should be released without updating the changeset associated with the locks.\r\n await IModelHost[_hubAccess].releaseAllLocks({\r\n iModelId: this.briefcase.iModelId,\r\n briefcaseId: this.briefcase.briefcaseId,\r\n changeset: { id: \"\", index: 0 }\r\n });\r\n } else {\r\n await IModelHost[_hubAccess].abandonAllLocks(this.briefcase);\r\n }\r\n\r\n this.clearAllLocks();\r\n }\r\n\r\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\r\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\r\n stmt.bindId(1, id);\r\n stmt.bindInteger(2, state);\r\n stmt.bindInteger(3, origin);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n throw new IModelError(rc, \"can't insert lock into database\");\r\n });\r\n\r\n return true;\r\n }\r\n\r\n private insertTxnLockRecord(id: Id64String, state: LockState, origin: LockOrigin): void {\r\n // Locks are always acquired in the current txn, which isn't a real txn until it's committed.\r\n // So use a placeholder txn id for now, and we'll update to the real txn id on commit.\r\n // This is important to distinguish new locks acquired in the current txn from locks acquired in previous reversed txns, which will only\r\n // be cleared (no longer reinstateable) on commit.\r\n this.lockDb.withPreparedSqliteStatement(`\r\n INSERT INTO txn_locks(txnId,elementId,state,origin,abandoned)\r\n VALUES (?,?,?,?,FALSE)\r\n ON CONFLICT(txnId,elementId)\r\n DO UPDATE SET\r\n state=excluded.state,\r\n origin=excluded.origin,\r\n abandoned=excluded.abandoned`, (stmt) => {\r\n stmt.bindId(1, this._unsavedChangesTxnId);\r\n stmt.bindId(2, id);\r\n stmt.bindInteger(3, state);\r\n stmt.bindInteger(4, origin);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't insert txn lock record into database (error code ${rc})`);\r\n });\r\n }\r\n\r\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\r\n if (id === undefined || id === IModel.rootSubjectId)\r\n return false; // has no owners\r\n\r\n const { modelId, parentId } = this.getOwners(id);\r\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\r\n return true;\r\n\r\n // see if this model is exclusively locked by one of its owners. If so, save that fact on modelId so future tests won't have to descend.\r\n if (this.ownerHoldsExclusiveLock(modelId))\r\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\r\n\r\n // see if the parent is exclusively locked by one of its owners. If so, save that fact on parentId so future tests won't have to descend.\r\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\r\n public holdsExclusiveLock(id: Id64String): boolean {\r\n // New elements (created by this briefcase since the last push) are implicitly exclusively locked.\r\n if (this.isNewElement(id))\r\n return true;\r\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\r\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n public holdsSharedLock(id: Id64String): boolean {\r\n // New elements are implicitly exclusively locked, which implies shared lock too.\r\n if (this.isNewElement(id))\r\n return true;\r\n const state = this.getLockState(id);\r\n // see if we hold shared or exclusive lock, or if an owner has exclusive lock. If so we implicitly have shared lock, but owner holding shared lock doesn't help.\r\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */\r\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\r\n // if the id is not valid, or of the lock is already in the set, or if we already hold a shared lock, we're done\r\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\r\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\r\n return;\r\n\r\n locks.add(id); // add to set of needed shared locks\r\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\r\n }\r\n\r\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\r\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\r\n const el = this.getOwners(id);\r\n this.addSharedLock(el.parentId, locks); // if this element is in a group\r\n this.addSharedLock(el.modelId, locks); // check its model\r\n }\r\n\r\n /** attempt to acquire all necessary locks for a set of elements */\r\n private async acquireAllLocks(locks: LockMap) {\r\n if (locks.size === 0) // no locks are required.\r\n return;\r\n\r\n const sharedLocks = new Set<Id64String>();\r\n for (const lock of locks)\r\n this.addOwnerSharedLocks(lock[0], sharedLocks);\r\n\r\n for (const shared of sharedLocks) {\r\n if (!locks.has(shared)) // we may already be asking for exclusive lock\r\n locks.set(shared, LockState.Shared);\r\n }\r\n\r\n await IModelHost[_hubAccess].acquireLocks(this.briefcase, locks); // throws if unsuccessful\r\n for (const lock of locks) {\r\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\r\n this.insertTxnLockRecord(lock[0], lock[1], LockOrigin.Acquired);\r\n }\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\r\n const locks = new Map<Id64String, LockState>();\r\n if (arg.shared) {\r\n for (const id of Id64.iterable(arg.shared)) {\r\n if (!this.holdsSharedLock(id))\r\n locks.set(id, LockState.Shared);\r\n }\r\n }\r\n if (arg.exclusive) {\r\n for (const id of Id64.iterable(arg.exclusive)) {\r\n if (!this.holdsExclusiveLock(id))\r\n locks.set(id, LockState.Exclusive);\r\n }\r\n }\r\n return this.acquireAllLocks(locks);\r\n }\r\n\r\n private async abandonLocks(locks: LockMap): Promise<void> {\r\n if (IModelHost[_hubAccess].abandonLocks === undefined) {\r\n // If the IModelHub doesn't support an explicit abandon, call acquireLocks with a blank changeset to indicate\r\n // that locks should be released without updating the changeset associated with the locks.\r\n await IModelHost[_hubAccess].acquireLocks({\r\n iModelId: this.briefcase.iModelId,\r\n briefcaseId: this.briefcase.briefcaseId,\r\n changeset: { id: \"\", index: 0 }\r\n }, locks);\r\n } else {\r\n await IModelHost[_hubAccess].abandonLocks(this.briefcase, locks);\r\n }\r\n }\r\n\r\n public async abandonLocksForCurrentUnsavedTxn(): Promise<boolean> {\r\n return this.abandonLocksForReversedTxn(this._unsavedChangesTxnId);\r\n }\r\n\r\n public async abandonLocksForReversedTxn(txnId: Id64String): Promise<boolean> {\r\n if (this.briefcase.txns.hasUnsavedChanges)\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", `cannot abandon locks for txn ${txnId} because the current txn has unsaved changes`);\r\n\r\n const txnProps = this.briefcase.txns.getTxnProps(txnId);\r\n if (txnProps === undefined) {\r\n // The current txn commonly won't exist on the TxnManager yet. It's often just a placeholder for not-yet-saved changes.\r\n // (Sometimes it will exist and refer to a reversed Txn).\r\n // The unsavedChangesTxnId won't exist on the TxnManager either, of course.\r\n // But all other txn ids must be known to the TxnManager or it is an error.\r\n if (txnId !== this.briefcase.txns.getCurrentTxnId() && txnId !== this._unsavedChangesTxnId)\r\n ServerBasedLocksError.throwError(\"txn-id-not-found\", `cannot abandon locks for txn ${txnId} because it does not exist`);\r\n } else {\r\n // If the txn id is known to the TxnManager, then we require that it has already been reversed.\r\n if (!txnProps.reversed)\r\n ServerBasedLocksError.throwError(\"txn-not-reversed\", `cannot abandon locks for txn ${txnId} because it has not been reversed`);\r\n }\r\n\r\n let locksReleased = false;\r\n\r\n // Abandon locks for unsaved (and now abandoned) changes.\r\n if (txnId !== this._unsavedChangesTxnId) {\r\n locksReleased = await this.abandonLocksForCurrentUnsavedTxn();\r\n }\r\n\r\n // At this point, we know:\r\n // 1. There are no unsaved changes, and the associated locks have been abandoned.\r\n // 2. The given txn ID has been reversed, which means any later txns are sure to have been reversed, too.\r\n\r\n // So we simply have to find all non-abandoned locks associated with the given txn or later, abandon them (or restore\r\n // them to their previous state), and mark them as abandoned in txn_locks.\r\n\r\n // Find all locks associated with the given txnId or later.\r\n // For each elementId, find the previous state of the lock before this Txn (if any), or None otherwise.\r\n // This is the state that we will restore the element's lock to. The reason we do this is to account for\r\n // lock upgrades. If an earlier Txn acquired a Shared lock on this element, and this Txn acquired an\r\n // Exclusive lock, we should restore the Shared lock.\r\n const allTxnLocks = new Map<Id64String, LockState>();\r\n const locksToRelease = new Map<Id64String, LockState>();\r\n this.lockDb.withPreparedSqliteStatement(\r\n `\r\n SELECT\r\n current.elementId,\r\n current.origin,\r\n IFNULL(\r\n (SELECT previous.state\r\n FROM txn_locks previous\r\n WHERE previous.elementId = current.elementId\r\n AND previous.txnId < ?2\r\n AND previous.abandoned=FALSE\r\n ORDER BY previous.txnId DESC\r\n LIMIT 1\r\n ),\r\n ?1\r\n ) AS previousState\r\n FROM txn_locks current\r\n WHERE current.txnId>=?2\r\n AND current.abandoned=FALSE\r\n ORDER BY current.txnId DESC\r\n `,\r\n (stmt) => {\r\n stmt.bindInteger(1, LockState.None);\r\n stmt.bindId(2, txnId);\r\n\r\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const elementId = stmt.getValueId(0);\r\n const origin = stmt.getValueInteger(1);\r\n const previousState = stmt.getValueInteger(2);\r\n allTxnLocks.set(elementId, previousState);\r\n if (origin !== LockOrigin.NewElement)\r\n locksToRelease.set(elementId, previousState);\r\n }\r\n });\r\n\r\n // Release the locks on the server.\r\n if (locksToRelease.size > 0)\r\n await this.abandonLocks(locksToRelease);\r\n\r\n // Mark the txn locks as abandoned.\r\n if (txnId === this._unsavedChangesTxnId) {\r\n // After abandoning locks held for the \"unsaved\" txn, we clear them completely because they are not reinstateable.\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM txn_locks WHERE txnId=?\", (stmt) => {\r\n stmt.bindId(1, this._unsavedChangesTxnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete txn locks for unsaved changes in database (error code ${rc})`);\r\n });\r\n } else {\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE txn_locks SET abandoned=TRUE WHERE txnId>=?\", (stmt) => {\r\n stmt.bindId(1, txnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't mark txn locks as abandoned in database (error code ${rc})`);\r\n });\r\n }\r\n\r\n // Restore each lock to its previous state (if any) in the local cache. Usually this means deleting it.\r\n for (const [elementId, previousState] of allTxnLocks) {\r\n if (previousState === LockState.None) {\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM locks WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, elementId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete lock from database (error code ${rc})`);\r\n });\r\n } else {\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE locks SET state=? WHERE id=?\", (stmt) => {\r\n stmt.bindInteger(1, previousState);\r\n stmt.bindId(2, elementId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't update lock in database (error code ${rc})`);\r\n });\r\n }\r\n }\r\n\r\n // Ideally we'd only invalidate \"Discovered\" locks that are related to this Txn's Shared and\r\n // Exclusive locks. But that is a lot of added complexity for little benefit.\r\n // Clearing them all will have no impact on correctness and a minimal impact on performance.\r\n this.clearDiscoveredLocks();\r\n\r\n this.lockDb.saveChanges();\r\n\r\n return locksReleased || allTxnLocks.size > 0;\r\n }\r\n\r\n private getAbandonedLocksForTxn(txnId: Id64String): {\r\n newElementLocks: Map<Id64String, LockState>,\r\n locksToAcquire: Map<Id64String, LockState>\r\n } {\r\n const newElementLocks = new Map<Id64String, LockState>();\r\n const locksToAcquire = new Map<Id64String, LockState>();\r\n this.lockDb.withPreparedSqliteStatement(\r\n \"SELECT elementId, state, origin FROM txn_locks WHERE txnId<=? AND abandoned=TRUE\",\r\n (stmt) => {\r\n stmt.bindId(1, txnId);\r\n\r\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const elementId = stmt.getValueId(0);\r\n const state = stmt.getValueInteger(1);\r\n const origin = stmt.getValueInteger(2);\r\n if (origin === LockOrigin.NewElement)\r\n newElementLocks.set(elementId, state);\r\n else\r\n locksToAcquire.set(elementId, state);\r\n }\r\n });\r\n\r\n return { newElementLocks, locksToAcquire };\r\n }\r\n\r\n public async acquireLocksForReinstatingTxn(txnId: Id64String): Promise<boolean> {\r\n if (this.briefcase.txns.hasUnsavedChanges)\r\n ServerBasedLocksError.throwError(\"has-unsaved-changes\", `cannot acquire locks for reinstating txn ${txnId} because the current txn has unsaved changes`);\r\n\r\n // If the Txn is known to the TxnManager, we can proceed. We don't need to check if it is currently\r\n // reversed, because if it isn't, then abandonLocksForReversedTxn couldn't have been called, and so the\r\n // locks are still held. Proceeding with this method will be a no-op, but it will be harmless.\r\n // However, if the Txn Id is unknown, it may have been canceled or refer to the current Txn\r\n // whose unsaved changes were just abandoned. Or it's just plain-old invalid. In any case, we can't\r\n // re-acquire the associated locks.\r\n const txnProps = this.briefcase.txns.getTxnProps(txnId);\r\n if (txnProps === undefined) {\r\n ServerBasedLocksError.throwError(\"txn-id-not-found\", `cannot acquire locks for txn ${txnId} because it does not exist or has not been saved`);\r\n }\r\n\r\n // Find all locks associated with the given txnId.\r\n const { newElementLocks, locksToAcquire } = this.getAbandonedLocksForTxn(txnId);\r\n\r\n // Attempt to acquire the locks on the server. This may fail if the locks are no longer available!\r\n if (locksToAcquire.size > 0)\r\n await IModelHost[_hubAccess].acquireLocks(this.briefcase, locksToAcquire); // throws if unsuccessful\r\n\r\n // Mark the txn locks as no longer abandoned.\r\n this.lockDb.withPreparedSqliteStatement(\"UPDATE txn_locks SET abandoned=FALSE WHERE txnId<=?\", (stmt) => {\r\n stmt.bindId(1, txnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't mark txn locks as no longer abandoned in database (error code ${rc})`);\r\n });\r\n\r\n // Insert the newly-acquired locks in the local cache. Note that we don't need to insert entries in the txn_locks table,\r\n // because these locks are already associated with the Txn.\r\n for (const [elementId, state] of locksToAcquire) {\r\n this.insertLock(elementId, state, LockOrigin.Acquired);\r\n }\r\n for (const [elementId, state] of newElementLocks) {\r\n this.insertLock(elementId, state, LockOrigin.NewElement);\r\n }\r\n\r\n // Ideally we'd only invalidate \"Discovered\" locks that are related to this Txn's Shared and\r\n // Exclusive locks. But that is a lot of added complexity for little benefit.\r\n // Clearing them all will have no impact on correctness and a minimal impact on performance.\r\n this.clearDiscoveredLocks();\r\n\r\n this.lockDb.saveChanges();\r\n\r\n return locksToAcquire.size > 0 || newElementLocks.size > 0;\r\n }\r\n\r\n public holdsNecessaryLocksForReinstatingTxn(txnId: Id64String): boolean {\r\n const locks = this.getAbandonedLocksForTxn(txnId);\r\n return locks.locksToAcquire.size === 0 && locks.newElementLocks.size === 0;\r\n }\r\n\r\n public clearTxnLockRecords(txnId: Id64String) {\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM txn_locks WHERE txnId!=? AND txnId>=?\", (stmt) => {\r\n stmt.bindId(1, this._unsavedChangesTxnId);\r\n stmt.bindId(2, txnId);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete txn lock records from database (error code ${rc})`);\r\n });\r\n\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** When an element is newly created in a session, we hold the lock on it implicitly.\r\n * For elements whose local ID is above the high-water mark this is already handled by [[isNewElement]],\r\n * so no database write is needed. The only case that does require a write is when the element's ID is\r\n * at or below the high-water mark (e.g. when re-applying a stash whose elements were created before\r\n * the last push). */\r\n public [_elementWasCreated](id: Id64String) {\r\n if (this.isNewElement(id))\r\n return; // already covered implicitly; no database write needed\r\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\r\n this.insertTxnLockRecord(id, LockState.Exclusive, LockOrigin.NewElement);\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n private clearDiscoveredLocks() {\r\n this.lockDb.withPreparedSqliteStatement(\"DELETE FROM locks WHERE origin=?\", (stmt) => {\r\n stmt.bindInteger(1, LockOrigin.Discovered);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n ServerBasedLocksError.throwError(\"lock-database-problem\", `can't delete discovered locks from database (error code ${rc})`);\r\n });\r\n }\r\n\r\n /** locks are not necessary during change propagation. */\r\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\r\n\r\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\r\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\r\n public checkSharedLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsSharedLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n}\r\n\r\nexport function createServerBasedLocks(iModel: BriefcaseDb): LockControl {\r\n return new ServerBasedLocks(iModel);\r\n}\r\n"]}
@@ -72,7 +72,7 @@ export declare class SubCategory extends DefinitionElement {
72
72
  static insert(txn: EditTxn, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
73
73
  /**
74
74
  * Insert a new SubCategory
75
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use SubCategory.insert(txn, ...) instead.
75
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use SubCategory.insert(txn, ...) instead.
76
76
  */
77
77
  static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
78
78
  }
@@ -112,7 +112,7 @@ export declare class Category extends DefinitionElement {
112
112
  setDefaultAppearance(txn: EditTxn, props: SubCategoryAppearance.Props | SubCategoryAppearance): void;
113
113
  /**
114
114
  * Set the appearance of the default SubCategory for this Category
115
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use Category.setDefaultAppearance(txn, ...) instead.
115
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use Category.setDefaultAppearance(txn, ...) instead.
116
116
  */
117
117
  setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void;
118
118
  }
@@ -154,7 +154,7 @@ export declare class DrawingCategory extends Category {
154
154
  static insert(txn: EditTxn, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
155
155
  /**
156
156
  * Insert a new DrawingCategory
157
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use DrawingCategory.insert(txn, ...) instead.
157
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use DrawingCategory.insert(txn, ...) instead.
158
158
  */
159
159
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
160
160
  }
@@ -196,7 +196,7 @@ export declare class SpatialCategory extends Category {
196
196
  static insert(txn: EditTxn, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
197
197
  /**
198
198
  * Insert a new SpatialCategory
199
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use SpatialCategory.insert(txn, ...) instead.
199
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use SpatialCategory.insert(txn, ...) instead.
200
200
  */
201
201
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
202
202
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,WAAW,EAAiB,IAAI,EAA0C,IAAI,EAAE,qBAAqB,GACtG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IACxE,qDAAqD;IAC9C,UAAU,CAAwB;IACzC,gDAAgD;IACzC,WAAW,CAAU;IAE5B,YAAsB,KAAuB,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,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AS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAkBM,MAAM,CAAC,MAAM,CAAC,OAA2B,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QACnK,MAAM,GAAG,GAAG,OAAO,YAAY,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAClE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,QAAQ,CAAC,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF","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 { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\r\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\r\nimport { _implicitTxn } from \"./internal/Symbols\";\r\n\r\n/** Defines the appearance for graphics in Geometric elements\r\n * @public @preview\r\n */\r\nexport class SubCategory extends DefinitionElement {\r\n public static override get className(): string { return \"SubCategory\"; }\r\n /** The Appearance parameters for this SubCategory */\r\n public appearance: SubCategoryAppearance;\r\n /** Optional description of this SubCategory. */\r\n public description?: string;\r\n\r\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.appearance = new SubCategoryAppearance(props.appearance);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /**\r\n * SubCategory custom HandledProps include 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"description\", source: \"Class\" },\r\n { propertyName: \"properties\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * SubCategory deserializes 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\r\n const elProps = super.deserialize(props) as SubCategoryProps;\r\n elProps.description = JsonUtils.asString(props.row.description);\r\n if (props.row.properties !== '') {\r\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\r\n } else {\r\n elProps.appearance = undefined;\r\n }\r\n return elProps;\r\n }\r\n\r\n /**\r\n * SubCategory serialize 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (props.description !== undefined) {\r\n inst.description = props.description;\r\n }\r\n if (props.appearance !== undefined) {\r\n inst.properties = JSON.stringify(props.appearance);\r\n }\r\n return inst;\r\n }\r\n\r\n public override toJSON(): SubCategoryProps {\r\n const val = super.toJSON() as SubCategoryProps;\r\n val.appearance = this.appearance.toJSON();\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the SubCategory's name (its Code value). */\r\n public getSubCategoryName(): string { return this.code.value; }\r\n /** Get the Id of the SubCategory. */\r\n public getSubCategoryId(): Id64String { return this.id; }\r\n /** Get the Id of this SubCategory's parent Category. */\r\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\r\n /** Check if this is the default SubCategory of its parent Category. */\r\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\r\n\r\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\r\n * @param iModel The IModel\r\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\r\n * @param codeValue The name of the SubCategory\r\n */\r\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\r\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\r\n }\r\n\r\n /** Create a new SubCategory\r\n * @param iModelDb The iModel\r\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The newly constructed SubCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\r\n if (appearance instanceof SubCategoryAppearance)\r\n appearance = appearance.toJSON();\r\n\r\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\r\n const subCategoryProps: SubCategoryProps = {\r\n classFullName: this.classFullName,\r\n model: parentCategory.model,\r\n parent: new CategoryOwnsSubCategories(parentCategoryId),\r\n code: this.createCode(iModelDb, parentCategoryId, name),\r\n appearance,\r\n };\r\n return new SubCategory(subCategoryProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new SubCategory\r\n * @param txn The EditTxn to use\r\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The Id of the newly inserted SubCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n /**\r\n * Insert a new SubCategory\r\n * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use SubCategory.insert(txn, ...) instead.\r\n */\r\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const subCategory = this.create(txn.iModel, parentCategoryId, name, appearance);\r\n return subCategory.insert(txn);\r\n }\r\n}\r\n\r\n/** A Category element is the target of the `category` member of [[GeometricElement]].\r\n * @public @preview\r\n */\r\nexport class Category extends DefinitionElement {\r\n public static override get className(): string { return \"Category\"; }\r\n public rank: Rank = Rank.User;\r\n public description?: string;\r\n\r\n protected constructor(props: CategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.rank = JsonUtils.asInt(props.rank);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /**\r\n * Category custom HandledProps include 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"rank\", source: \"Class\" },\r\n { propertyName: \"description\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * Category deserializes 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\r\n const elProps = super.deserialize(props) as CategoryProps;\r\n elProps.description = JsonUtils.asString(props.row.description);\r\n elProps.rank = JsonUtils.asInt(props.row.rank);\r\n return elProps;\r\n }\r\n\r\n /**\r\n * Category serialize 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (undefined !== props.description) {\r\n inst.description = props.description;\r\n }\r\n inst.rank = props.rank;\r\n return inst;\r\n }\r\n public override toJSON(): CategoryProps {\r\n const val = super.toJSON() as CategoryProps;\r\n val.rank = this.rank;\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the Id of the default SubCategory for this Category. */\r\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\r\n\r\n /**\r\n * Set the appearance of the default SubCategory for this Category\r\n * @beta\r\n */\r\n public setDefaultAppearance(txn: EditTxn, props: SubCategoryAppearance.Props | SubCategoryAppearance): void;\r\n /**\r\n * Set the appearance of the default SubCategory for this Category\r\n * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use Category.setDefaultAppearance(txn, ...) instead.\r\n */\r\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void;\r\n public setDefaultAppearance(txnOrProps: EditTxn | SubCategoryAppearance.Props | SubCategoryAppearance, props?: SubCategoryAppearance.Props | SubCategoryAppearance): void {\r\n let txn: EditTxn;\r\n let appearance: SubCategoryAppearance.Props | SubCategoryAppearance;\r\n if (txnOrProps instanceof EditTxn) {\r\n txn = txnOrProps;\r\n if (props === undefined)\r\n throw new Error(\"Invalid argument\");\r\n appearance = props;\r\n } else {\r\n txn = this.iModel[_implicitTxn];\r\n appearance = txnOrProps;\r\n }\r\n if (appearance instanceof SubCategoryAppearance)\r\n appearance = appearance.toJSON();\r\n\r\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\r\n subCat.appearance = new SubCategoryAppearance(appearance);\r\n subCat.update(txn);\r\n }\r\n}\r\n\r\n/** Categorizes 2d GeometricElements.\r\n * @public @preview\r\n */\r\nexport class DrawingCategory extends Category {\r\n public static override get className(): string { return \"DrawingCategory\"; }\r\n\r\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\r\n\r\n /** Looks up the CategoryId of a DrawingCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A drawing category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new DrawingCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @returns The newly constructed DrawingCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new DrawingCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new DrawingCategory\r\n * @param txn The EditTxn to use\r\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\r\n * @returns The Id of the newly inserted DrawingCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n /**\r\n * Insert a new DrawingCategory\r\n * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use DrawingCategory.insert(txn, ...) instead.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const category = this.create(txn.iModel, definitionModelId, name);\r\n category.id = category.insert(txn);\r\n category.setDefaultAppearance(txn, defaultAppearance);\r\n return category.id;\r\n }\r\n}\r\n\r\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\r\n * @public @preview\r\n */\r\nexport class SpatialCategory extends Category {\r\n public static override get className(): string { return \"SpatialCategory\"; }\r\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\r\n\r\n /** Looks up the CategoryId of a SpatialCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A spatial category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new SpatialCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the SpatialCategory\r\n * @returns The newly constructed SpatialCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new SpatialCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new SpatialCategory\r\n * @param txn The EditTxn to use\r\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\r\n * @param name The name of the SpatialCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\r\n * @returns The Id of the newly inserted SpatialCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n /**\r\n * Insert a new SpatialCategory\r\n * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use SpatialCategory.insert(txn, ...) instead.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const category = this.create(txn.iModel, definitionModelId, name);\r\n category.id = category.insert(txn);\r\n category.setDefaultAppearance(txn, defaultAppearance);\r\n return category.id;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,WAAW,EAAiB,IAAI,EAA0C,IAAI,EAAE,qBAAqB,GACtG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IACxE,qDAAqD;IAC9C,UAAU,CAAwB;IACzC,gDAAgD;IACzC,WAAW,CAAU;IAE5B,YAAsB,KAAuB,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAmB,mBAAmB,GAA4B;QAChF,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE;QAChD,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE;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,YAAY,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAClE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,QAAQ,CAAC,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF","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 { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\r\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\r\nimport { _implicitTxn } from \"./internal/Symbols\";\r\n\r\n/** Defines the appearance for graphics in Geometric elements\r\n * @public @preview\r\n */\r\nexport class SubCategory extends DefinitionElement {\r\n public static override get className(): string { return \"SubCategory\"; }\r\n /** The Appearance parameters for this SubCategory */\r\n public appearance: SubCategoryAppearance;\r\n /** Optional description of this SubCategory. */\r\n public description?: string;\r\n\r\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.appearance = new SubCategoryAppearance(props.appearance);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /**\r\n * SubCategory custom HandledProps include 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"description\", source: \"Class\" },\r\n { propertyName: \"properties\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * SubCategory deserializes 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\r\n const elProps = super.deserialize(props) as SubCategoryProps;\r\n elProps.description = JsonUtils.asString(props.row.description);\r\n if (props.row.properties !== '') {\r\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\r\n } else {\r\n elProps.appearance = undefined;\r\n }\r\n return elProps;\r\n }\r\n\r\n /**\r\n * SubCategory serialize 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (props.description !== undefined) {\r\n inst.description = props.description;\r\n }\r\n if (props.appearance !== undefined) {\r\n inst.properties = JSON.stringify(props.appearance);\r\n }\r\n return inst;\r\n }\r\n\r\n public override toJSON(): SubCategoryProps {\r\n const val = super.toJSON() as SubCategoryProps;\r\n val.appearance = this.appearance.toJSON();\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the SubCategory's name (its Code value). */\r\n public getSubCategoryName(): string { return this.code.value; }\r\n /** Get the Id of the SubCategory. */\r\n public getSubCategoryId(): Id64String { return this.id; }\r\n /** Get the Id of this SubCategory's parent Category. */\r\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\r\n /** Check if this is the default SubCategory of its parent Category. */\r\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\r\n\r\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\r\n * @param iModel The IModel\r\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\r\n * @param codeValue The name of the SubCategory\r\n */\r\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\r\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\r\n }\r\n\r\n /** Create a new SubCategory\r\n * @param iModelDb The iModel\r\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The newly constructed SubCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\r\n if (appearance instanceof SubCategoryAppearance)\r\n appearance = appearance.toJSON();\r\n\r\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\r\n const subCategoryProps: SubCategoryProps = {\r\n classFullName: this.classFullName,\r\n model: parentCategory.model,\r\n parent: new CategoryOwnsSubCategories(parentCategoryId),\r\n code: this.createCode(iModelDb, parentCategoryId, name),\r\n appearance,\r\n };\r\n return new SubCategory(subCategoryProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new SubCategory\r\n * @param txn The EditTxn to use\r\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The Id of the newly inserted SubCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n /**\r\n * Insert a new SubCategory\r\n * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use SubCategory.insert(txn, ...) instead.\r\n */\r\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const subCategory = this.create(txn.iModel, parentCategoryId, name, appearance);\r\n return subCategory.insert(txn);\r\n }\r\n}\r\n\r\n/** A Category element is the target of the `category` member of [[GeometricElement]].\r\n * @public @preview\r\n */\r\nexport class Category extends DefinitionElement {\r\n public static override get className(): string { return \"Category\"; }\r\n public rank: Rank = Rank.User;\r\n public description?: string;\r\n\r\n protected constructor(props: CategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.rank = JsonUtils.asInt(props.rank);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /**\r\n * Category custom HandledProps include 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"rank\", source: \"Class\" },\r\n { propertyName: \"description\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * Category deserializes 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\r\n const elProps = super.deserialize(props) as CategoryProps;\r\n elProps.description = JsonUtils.asString(props.row.description);\r\n elProps.rank = JsonUtils.asInt(props.row.rank);\r\n return elProps;\r\n }\r\n\r\n /**\r\n * Category serialize 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (undefined !== props.description) {\r\n inst.description = props.description;\r\n }\r\n inst.rank = props.rank;\r\n return inst;\r\n }\r\n public override toJSON(): CategoryProps {\r\n const val = super.toJSON() as CategoryProps;\r\n val.rank = this.rank;\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the Id of the default SubCategory for this Category. */\r\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\r\n\r\n /**\r\n * Set the appearance of the default SubCategory for this Category\r\n * @beta\r\n */\r\n public setDefaultAppearance(txn: EditTxn, props: SubCategoryAppearance.Props | SubCategoryAppearance): void;\r\n /**\r\n * Set the appearance of the default SubCategory for this Category\r\n * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use Category.setDefaultAppearance(txn, ...) instead.\r\n */\r\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void;\r\n public setDefaultAppearance(txnOrProps: EditTxn | SubCategoryAppearance.Props | SubCategoryAppearance, props?: SubCategoryAppearance.Props | SubCategoryAppearance): void {\r\n let txn: EditTxn;\r\n let appearance: SubCategoryAppearance.Props | SubCategoryAppearance;\r\n if (txnOrProps instanceof EditTxn) {\r\n txn = txnOrProps;\r\n if (props === undefined)\r\n throw new Error(\"Invalid argument\");\r\n appearance = props;\r\n } else {\r\n txn = this.iModel[_implicitTxn];\r\n appearance = txnOrProps;\r\n }\r\n if (appearance instanceof SubCategoryAppearance)\r\n appearance = appearance.toJSON();\r\n\r\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\r\n subCat.appearance = new SubCategoryAppearance(appearance);\r\n subCat.update(txn);\r\n }\r\n}\r\n\r\n/** Categorizes 2d GeometricElements.\r\n * @public @preview\r\n */\r\nexport class DrawingCategory extends Category {\r\n public static override get className(): string { return \"DrawingCategory\"; }\r\n\r\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\r\n\r\n /** Looks up the CategoryId of a DrawingCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A drawing category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new DrawingCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @returns The newly constructed DrawingCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new DrawingCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new DrawingCategory\r\n * @param txn The EditTxn to use\r\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\r\n * @returns The Id of the newly inserted DrawingCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n /**\r\n * Insert a new DrawingCategory\r\n * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use DrawingCategory.insert(txn, ...) instead.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const category = this.create(txn.iModel, definitionModelId, name);\r\n category.id = category.insert(txn);\r\n category.setDefaultAppearance(txn, defaultAppearance);\r\n return category.id;\r\n }\r\n}\r\n\r\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\r\n * @public @preview\r\n */\r\nexport class SpatialCategory extends Category {\r\n public static override get className(): string { return \"SpatialCategory\"; }\r\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\r\n\r\n /** Looks up the CategoryId of a SpatialCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A spatial category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new SpatialCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the SpatialCategory\r\n * @returns The newly constructed SpatialCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new SpatialCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new SpatialCategory\r\n * @param txn The EditTxn to use\r\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\r\n * @param name The name of the SpatialCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\r\n * @returns The Id of the newly inserted SpatialCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n /**\r\n * Insert a new SpatialCategory\r\n * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use SpatialCategory.insert(txn, ...) instead.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const category = this.create(txn.iModel, definitionModelId, name);\r\n category.id = category.insert(txn);\r\n category.setDefaultAppearance(txn, defaultAppearance);\r\n return category.id;\r\n }\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import { AnyDb, SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "
6
6
  /**
7
7
  * Record meta data for the change.
8
8
  * @beta
9
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangeMeta]($backend) with [ChangesetReader]($backend) instead.
9
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangeMeta]($backend) with [ChangesetReader]($backend) instead.
10
10
  * */
11
11
  export interface ChangeMetaData {
12
12
  /** list of tables making up this EC change */
@@ -25,7 +25,7 @@ export interface ChangeMetaData {
25
25
  /**
26
26
  * Represent EC change derived from low level sqlite change
27
27
  * @beta
28
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangeInstance]($backend) with [ChangesetReader]($backend) instead.
28
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangeInstance]($backend) with [ChangesetReader]($backend) instead.
29
29
  */
30
30
  export interface ChangedECInstance {
31
31
  ECInstanceId: Id64String;
@@ -36,7 +36,7 @@ export interface ChangedECInstance {
36
36
  /**
37
37
  * Represents a cache for unifying EC changes.
38
38
  * @beta
39
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangeCache]($backend) with [ChangesetReader]($backend) instead.
39
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangeCache]($backend) with [ChangesetReader]($backend) instead.
40
40
  */
41
41
  export interface ECChangeUnifierCache extends Disposable {
42
42
  /**
@@ -64,7 +64,7 @@ export interface ECChangeUnifierCache extends Disposable {
64
64
  }
65
65
  /**
66
66
  * @beta
67
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangeUnifierCache.createInMemoryCache]($backend) / [ChangeUnifierCache.createSqliteBackedCache]($backend) instead.
67
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangeUnifierCache.createInMemoryCache]($backend) / [ChangeUnifierCache.createSqliteBackedCache]($backend) instead.
68
68
  */
69
69
  export declare namespace ECChangeUnifierCache {
70
70
  /**
@@ -87,7 +87,7 @@ export declare namespace ECChangeUnifierCache {
87
87
  * Partial changes is per table and a single instance can
88
88
  * span multiple tables.
89
89
  * @beta
90
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [PartialChangeUnifier]($backend) with [ChangesetReader]($backend) instead.
90
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [PartialChangeUnifier]($backend) with [ChangesetReader]($backend) instead.
91
91
  */
92
92
  export declare class PartialECChangeUnifier implements Disposable {
93
93
  private _db;
@@ -147,7 +147,7 @@ export declare class PartialECChangeUnifier implements Disposable {
147
147
  * it is per table while a single instance can span multiple table.
148
148
  * @note PrimitiveArray and StructArray are not supported types.
149
149
  * @beta
150
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangesetReader]($backend) instead.
150
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangesetReader]($backend) instead.
151
151
  *
152
152
  */
153
153
  export declare class ChangesetECAdaptor implements Disposable {
@@ -295,7 +295,7 @@ class ECDbMap {
295
295
  /**
296
296
  * Helper function to convert between JS DateTime & SQLite JulianDay values.
297
297
  * @beta
298
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. The DateTime namespace is deprecated and will be removed in a future release.
298
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. The DateTime namespace is deprecated and will be removed in a future release.
299
299
  * */
300
300
  var DateTime;
301
301
  (function (DateTime) {
@@ -324,7 +324,7 @@ var DateTime;
324
324
  })(DateTime || (DateTime = {}));
325
325
  /**
326
326
  * @beta
327
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangeUnifierCache.createInMemoryCache]($backend) / [ChangeUnifierCache.createSqliteBackedCache]($backend) instead.
327
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangeUnifierCache.createInMemoryCache]($backend) / [ChangeUnifierCache.createSqliteBackedCache]($backend) instead.
328
328
  */
329
329
  export var ECChangeUnifierCache;
330
330
  (function (ECChangeUnifierCache) {
@@ -524,7 +524,7 @@ class SqliteBackedInstanceCache {
524
524
  * Partial changes is per table and a single instance can
525
525
  * span multiple tables.
526
526
  * @beta
527
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [PartialChangeUnifier]($backend) with [ChangesetReader]($backend) instead.
527
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [PartialChangeUnifier]($backend) with [ChangesetReader]($backend) instead.
528
528
  */
529
529
  export class PartialECChangeUnifier {
530
530
  _db;
@@ -687,7 +687,7 @@ export class PartialECChangeUnifier {
687
687
  * it is per table while a single instance can span multiple table.
688
688
  * @note PrimitiveArray and StructArray are not supported types.
689
689
  * @beta
690
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use [ChangesetReader]($backend) instead.
690
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use [ChangesetReader]($backend) instead.
691
691
  *
692
692
  */
693
693
  export class ChangesetECAdaptor {