@itwin/core-backend 5.10.0-dev.9 → 5.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +8 -1
  3. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  4. package/lib/cjs/BriefcaseManager.js.map +1 -1
  5. package/lib/cjs/Category.d.ts +4 -4
  6. package/lib/cjs/Category.js.map +1 -1
  7. package/lib/cjs/ChangesetECAdaptor.d.ts +6 -6
  8. package/lib/cjs/ChangesetECAdaptor.js +4 -4
  9. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  10. package/lib/cjs/ChangesetReader.d.ts +84 -1
  11. package/lib/cjs/ChangesetReader.d.ts.map +1 -1
  12. package/lib/cjs/ChangesetReader.js +108 -12
  13. package/lib/cjs/ChangesetReader.js.map +1 -1
  14. package/lib/cjs/ClassRegistry.d.ts +3 -3
  15. package/lib/cjs/ClassRegistry.js +3 -3
  16. package/lib/cjs/ClassRegistry.js.map +1 -1
  17. package/lib/cjs/CodeSpecs.d.ts +3 -3
  18. package/lib/cjs/CodeSpecs.js.map +1 -1
  19. package/lib/cjs/DisplayStyle.d.ts +2 -2
  20. package/lib/cjs/DisplayStyle.js.map +1 -1
  21. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  22. package/lib/cjs/ECSqlStatement.js +4 -0
  23. package/lib/cjs/ECSqlStatement.js.map +1 -1
  24. package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -1
  25. package/lib/cjs/ECSqlSyncReader.js +1 -0
  26. package/lib/cjs/ECSqlSyncReader.js.map +1 -1
  27. package/lib/cjs/Element.d.ts +16 -13
  28. package/lib/cjs/Element.d.ts.map +1 -1
  29. package/lib/cjs/Element.js +8 -5
  30. package/lib/cjs/Element.js.map +1 -1
  31. package/lib/cjs/ElementAspect.d.ts +1 -1
  32. package/lib/cjs/ElementAspect.js.map +1 -1
  33. package/lib/cjs/ElementTreeWalker.d.ts +5 -5
  34. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  35. package/lib/cjs/Entity.d.ts +13 -5
  36. package/lib/cjs/Entity.d.ts.map +1 -1
  37. package/lib/cjs/Entity.js +13 -5
  38. package/lib/cjs/Entity.js.map +1 -1
  39. package/lib/cjs/ExternalSource.d.ts +2 -2
  40. package/lib/cjs/ExternalSource.js.map +1 -1
  41. package/lib/cjs/IModelDb.d.ts +112 -40
  42. package/lib/cjs/IModelDb.d.ts.map +1 -1
  43. package/lib/cjs/IModelDb.js +215 -42
  44. package/lib/cjs/IModelDb.js.map +1 -1
  45. package/lib/cjs/LineStyle.d.ts +6 -6
  46. package/lib/cjs/LineStyle.js.map +1 -1
  47. package/lib/cjs/LocalHub.d.ts +6 -0
  48. package/lib/cjs/LocalHub.d.ts.map +1 -1
  49. package/lib/cjs/LocalHub.js +23 -0
  50. package/lib/cjs/LocalHub.js.map +1 -1
  51. package/lib/cjs/Material.d.ts +1 -1
  52. package/lib/cjs/Material.js.map +1 -1
  53. package/lib/cjs/Model.d.ts +6 -6
  54. package/lib/cjs/Model.js.map +1 -1
  55. package/lib/cjs/Relationship.d.ts +13 -11
  56. package/lib/cjs/Relationship.d.ts.map +1 -1
  57. package/lib/cjs/Relationship.js +9 -7
  58. package/lib/cjs/Relationship.js.map +1 -1
  59. package/lib/cjs/SheetIndex.d.ts +4 -4
  60. package/lib/cjs/SheetIndex.js.map +1 -1
  61. package/lib/cjs/Texture.d.ts +1 -1
  62. package/lib/cjs/Texture.js.map +1 -1
  63. package/lib/cjs/TxnManager.d.ts.map +1 -1
  64. package/lib/cjs/TxnManager.js +7 -0
  65. package/lib/cjs/TxnManager.js.map +1 -1
  66. package/lib/cjs/ViewDefinition.d.ts +6 -6
  67. package/lib/cjs/ViewDefinition.js.map +1 -1
  68. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  69. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  70. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -1
  71. package/lib/cjs/annotations/FrameGeometry.js +2 -3
  72. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  73. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +6 -2
  74. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +1 -0
  75. package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
  76. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  77. package/lib/cjs/domains/GenericElements.d.ts +2 -2
  78. package/lib/cjs/domains/GenericElements.js.map +1 -1
  79. package/lib/cjs/internal/ChannelAdmin.d.ts +2 -2
  80. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  81. package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -1
  82. package/lib/cjs/internal/ElementLRUCache.js +23 -4
  83. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  84. package/lib/cjs/internal/HubMock.d.ts +24 -1
  85. package/lib/cjs/internal/HubMock.d.ts.map +1 -1
  86. package/lib/cjs/internal/HubMock.js +60 -39
  87. package/lib/cjs/internal/HubMock.js.map +1 -1
  88. package/lib/cjs/internal/ServerBasedLocks.d.ts +19 -1
  89. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
  90. package/lib/cjs/internal/ServerBasedLocks.js +55 -1
  91. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  92. package/lib/cjs/internal/cross-package.d.ts +1 -1
  93. package/lib/cjs/internal/cross-package.d.ts.map +1 -1
  94. package/lib/cjs/internal/cross-package.js +1 -2
  95. package/lib/cjs/internal/cross-package.js.map +1 -1
  96. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
  97. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +55 -9
  98. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  99. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  100. package/lib/cjs/internal/workspace/WorkspaceImpl.js +7 -11
  101. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  102. package/lib/cjs/workspace/SettingsSchemas.d.ts +20 -3
  103. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  104. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  105. package/lib/cjs/workspace/Workspace.d.ts +3 -1
  106. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  107. package/lib/cjs/workspace/Workspace.js.map +1 -1
  108. package/lib/esm/BriefcaseManager.d.ts +8 -1
  109. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  110. package/lib/esm/BriefcaseManager.js.map +1 -1
  111. package/lib/esm/Category.d.ts +4 -4
  112. package/lib/esm/Category.js.map +1 -1
  113. package/lib/esm/ChangesetECAdaptor.d.ts +6 -6
  114. package/lib/esm/ChangesetECAdaptor.js +4 -4
  115. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  116. package/lib/esm/ChangesetReader.d.ts +84 -1
  117. package/lib/esm/ChangesetReader.d.ts.map +1 -1
  118. package/lib/esm/ChangesetReader.js +108 -12
  119. package/lib/esm/ChangesetReader.js.map +1 -1
  120. package/lib/esm/ClassRegistry.d.ts +3 -3
  121. package/lib/esm/ClassRegistry.js +3 -3
  122. package/lib/esm/ClassRegistry.js.map +1 -1
  123. package/lib/esm/CodeSpecs.d.ts +3 -3
  124. package/lib/esm/CodeSpecs.js.map +1 -1
  125. package/lib/esm/DisplayStyle.d.ts +2 -2
  126. package/lib/esm/DisplayStyle.js.map +1 -1
  127. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  128. package/lib/esm/ECSqlStatement.js +4 -0
  129. package/lib/esm/ECSqlStatement.js.map +1 -1
  130. package/lib/esm/ECSqlSyncReader.d.ts.map +1 -1
  131. package/lib/esm/ECSqlSyncReader.js +1 -0
  132. package/lib/esm/ECSqlSyncReader.js.map +1 -1
  133. package/lib/esm/Element.d.ts +16 -13
  134. package/lib/esm/Element.d.ts.map +1 -1
  135. package/lib/esm/Element.js +8 -5
  136. package/lib/esm/Element.js.map +1 -1
  137. package/lib/esm/ElementAspect.d.ts +1 -1
  138. package/lib/esm/ElementAspect.js.map +1 -1
  139. package/lib/esm/ElementTreeWalker.d.ts +5 -5
  140. package/lib/esm/ElementTreeWalker.js.map +1 -1
  141. package/lib/esm/Entity.d.ts +13 -5
  142. package/lib/esm/Entity.d.ts.map +1 -1
  143. package/lib/esm/Entity.js +13 -5
  144. package/lib/esm/Entity.js.map +1 -1
  145. package/lib/esm/ExternalSource.d.ts +2 -2
  146. package/lib/esm/ExternalSource.js.map +1 -1
  147. package/lib/esm/IModelDb.d.ts +112 -40
  148. package/lib/esm/IModelDb.d.ts.map +1 -1
  149. package/lib/esm/IModelDb.js +216 -43
  150. package/lib/esm/IModelDb.js.map +1 -1
  151. package/lib/esm/LineStyle.d.ts +6 -6
  152. package/lib/esm/LineStyle.js.map +1 -1
  153. package/lib/esm/LocalHub.d.ts +6 -0
  154. package/lib/esm/LocalHub.d.ts.map +1 -1
  155. package/lib/esm/LocalHub.js +23 -0
  156. package/lib/esm/LocalHub.js.map +1 -1
  157. package/lib/esm/Material.d.ts +1 -1
  158. package/lib/esm/Material.js.map +1 -1
  159. package/lib/esm/Model.d.ts +6 -6
  160. package/lib/esm/Model.js.map +1 -1
  161. package/lib/esm/Relationship.d.ts +13 -11
  162. package/lib/esm/Relationship.d.ts.map +1 -1
  163. package/lib/esm/Relationship.js +9 -7
  164. package/lib/esm/Relationship.js.map +1 -1
  165. package/lib/esm/SheetIndex.d.ts +4 -4
  166. package/lib/esm/SheetIndex.js.map +1 -1
  167. package/lib/esm/Texture.d.ts +1 -1
  168. package/lib/esm/Texture.js.map +1 -1
  169. package/lib/esm/TxnManager.d.ts.map +1 -1
  170. package/lib/esm/TxnManager.js +7 -0
  171. package/lib/esm/TxnManager.js.map +1 -1
  172. package/lib/esm/ViewDefinition.d.ts +6 -6
  173. package/lib/esm/ViewDefinition.js.map +1 -1
  174. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  175. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  176. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -1
  177. package/lib/esm/annotations/FrameGeometry.js +2 -3
  178. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  179. package/lib/esm/domains/FunctionalElements.d.ts +1 -1
  180. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  181. package/lib/esm/domains/GenericElements.d.ts +2 -2
  182. package/lib/esm/domains/GenericElements.js.map +1 -1
  183. package/lib/esm/internal/ChannelAdmin.d.ts +2 -2
  184. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  185. package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -1
  186. package/lib/esm/internal/ElementLRUCache.js +23 -4
  187. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  188. package/lib/esm/internal/HubMock.d.ts +24 -1
  189. package/lib/esm/internal/HubMock.d.ts.map +1 -1
  190. package/lib/esm/internal/HubMock.js +61 -40
  191. package/lib/esm/internal/HubMock.js.map +1 -1
  192. package/lib/esm/internal/ServerBasedLocks.d.ts +19 -1
  193. package/lib/esm/internal/ServerBasedLocks.d.ts.map +1 -1
  194. package/lib/esm/internal/ServerBasedLocks.js +55 -1
  195. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  196. package/lib/esm/internal/cross-package.d.ts +1 -1
  197. package/lib/esm/internal/cross-package.d.ts.map +1 -1
  198. package/lib/esm/internal/cross-package.js +1 -1
  199. package/lib/esm/internal/cross-package.js.map +1 -1
  200. package/lib/esm/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
  201. package/lib/esm/internal/workspace/SettingsSchemasImpl.js +55 -9
  202. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  203. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  204. package/lib/esm/internal/workspace/WorkspaceImpl.js +7 -11
  205. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  206. package/lib/esm/test/ElementLRUCache.test.js +60 -0
  207. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  208. package/lib/esm/test/SchemaChangesetCanBeReversed.test.d.ts +2 -0
  209. package/lib/esm/test/SchemaChangesetCanBeReversed.test.d.ts.map +1 -0
  210. package/lib/esm/test/SchemaChangesetCanBeReversed.test.js +239 -0
  211. package/lib/esm/test/SchemaChangesetCanBeReversed.test.js.map +1 -0
  212. package/lib/esm/test/annotations/FrameGeometry.test.js +2 -1
  213. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  214. package/lib/esm/test/ecdb/CTE.test.js +1 -0
  215. package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
  216. package/lib/esm/test/ecdb/ECSqlQuery.test.js +10 -2
  217. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  218. package/lib/esm/test/ecdb/ECSqlStatement.test.js +10 -0
  219. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  220. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +1 -0
  221. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
  222. package/lib/esm/test/ecdb/QueryReaders.test.js +13 -0
  223. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  224. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +1 -0
  225. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  226. package/lib/esm/test/element/DeleteDefinitionElements.test.js +6 -2
  227. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  228. package/lib/esm/test/element/ElementRoundTrip.test.js +5 -0
  229. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  230. package/lib/esm/test/element/ExcludedElements.test.js +1 -0
  231. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  232. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +10 -0
  233. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  234. package/lib/esm/test/hubaccess/SemanticRebase.test.js +1 -0
  235. package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
  236. package/lib/esm/test/imodel/IModel.test.js +31 -0
  237. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  238. package/lib/esm/test/schema/ClassRegistry.test.js +3 -0
  239. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  240. package/lib/esm/test/schema/IModelSchemaContext.test.js +2 -0
  241. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  242. package/lib/esm/test/schema/SchemaViewHidden.test.d.ts +2 -0
  243. package/lib/esm/test/schema/SchemaViewHidden.test.d.ts.map +1 -0
  244. package/lib/esm/test/schema/SchemaViewHidden.test.js +275 -0
  245. package/lib/esm/test/schema/SchemaViewHidden.test.js.map +1 -0
  246. package/lib/esm/test/schema/SchemaViewKoQ.test.d.ts +2 -0
  247. package/lib/esm/test/schema/SchemaViewKoQ.test.d.ts.map +1 -0
  248. package/lib/esm/test/schema/SchemaViewKoQ.test.js +184 -0
  249. package/lib/esm/test/schema/SchemaViewKoQ.test.js.map +1 -0
  250. package/lib/esm/test/schema/SchemaViewLifecycle.test.d.ts +2 -0
  251. package/lib/esm/test/schema/SchemaViewLifecycle.test.d.ts.map +1 -0
  252. package/lib/esm/test/schema/SchemaViewLifecycle.test.js +141 -0
  253. package/lib/esm/test/schema/SchemaViewLifecycle.test.js.map +1 -0
  254. package/lib/esm/test/schema/SchemaViewValidation.test.d.ts +2 -0
  255. package/lib/esm/test/schema/SchemaViewValidation.test.d.ts.map +1 -0
  256. package/lib/esm/test/schema/SchemaViewValidation.test.js +475 -0
  257. package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -0
  258. package/lib/esm/test/standalone/ChangesetReader.test.js +945 -337
  259. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  260. package/lib/esm/test/standalone/DeleteElements.test.js +45 -0
  261. package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
  262. package/lib/esm/test/standalone/IModelWrite.test.js +6 -0
  263. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  264. package/lib/esm/test/standalone/ServerBasedLocks.test.js +62 -0
  265. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  266. package/lib/esm/test/standalone/Settings.test.js +2 -0
  267. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  268. package/lib/esm/test/standalone/SettingsSchemas.test.js +397 -0
  269. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  270. package/lib/esm/test/standalone/Workspace.test.js +23 -0
  271. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  272. package/lib/esm/workspace/SettingsSchemas.d.ts +20 -3
  273. package/lib/esm/workspace/SettingsSchemas.d.ts.map +1 -1
  274. package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
  275. package/lib/esm/workspace/Workspace.d.ts +3 -1
  276. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  277. package/lib/esm/workspace/Workspace.js.map +1 -1
  278. package/package.json +15 -15
@@ -46,7 +46,7 @@ import { IModelNative } from "./internal/NativePlatform";
46
46
  import { createNoOpLockControl } from "./internal/NoLocks";
47
47
  import { createIModelDbFonts } from "./internal/IModelDbFontsImpl";
48
48
  import { _activeTxn, _cache, _close, _hubAccess, _implicitTxn, _instanceKeyCache, _nativeDb, _releaseAllLocks, _resetIModelDb } from "./internal/Symbols";
49
- import { ECVersion, SchemaContext, SchemaJsonLocater } from "@itwin/ecschema-metadata";
49
+ import { ECVersion, SchemaContext, SchemaJsonLocater, SchemaView } from "@itwin/ecschema-metadata";
50
50
  import { SchemaMap } from "./Schema";
51
51
  import { ElementLRUCache, InstanceKeyLRUCache } from "./internal/ElementLRUCache";
52
52
  import { IModelIncrementalSchemaLocater } from "./IModelIncrementalSchemaLocater";
@@ -162,6 +162,7 @@ export class IModelDb extends IModel {
162
162
  _jsClassMap;
163
163
  _schemaMap;
164
164
  _schemaContext;
165
+ _schemasPromise;
165
166
  /** @deprecated in 5.0.0 - will not be removed until after 2026-06-13. Use [[fonts]]. */
166
167
  _fontMap; // eslint-disable-line @typescript-eslint/no-deprecated
167
168
  _fonts = createIModelDbFonts(this);
@@ -718,6 +719,7 @@ export class IModelDb extends IModel {
718
719
  const where = [...parentCategories].join(",");
719
720
  const query = `SELECT ECInstanceId as id, Parent.Id as parentId, Properties as appearance FROM BisCore.SubCategory WHERE Parent.Id IN (${where})`;
720
721
  try {
722
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
721
723
  for await (const row of this.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames })) {
722
724
  result.push(row.toRow());
723
725
  }
@@ -738,6 +740,7 @@ export class IModelDb extends IModel {
738
740
  const where = [...categoryIds].join(",");
739
741
  const query = `SELECT ECInstanceId as id, Parent.Id as parentId, Properties as appearance FROM BisCore.SubCategory WHERE Parent.Id IN (${where})`;
740
742
  try {
743
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
741
744
  for await (const row of this.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames })) {
742
745
  result.push(row.toRow());
743
746
  }
@@ -794,6 +797,11 @@ export class IModelDb extends IModel {
794
797
  this._jsClassMap = undefined;
795
798
  this._schemaMap = undefined;
796
799
  this._schemaContext = undefined;
800
+ if (this._schemasPromise) {
801
+ const old = this._schemasPromise;
802
+ this._schemasPromise = undefined;
803
+ old.then((view) => view.markOutdated()).catch(() => { });
804
+ }
797
805
  this[_nativeDb].clearECDbCache();
798
806
  }
799
807
  this.elements[_cache].clear();
@@ -806,7 +814,7 @@ export class IModelDb extends IModel {
806
814
  * ``` ts
807
815
  * [[include:IModelDb.updateProjectExtents]]
808
816
  * ```
809
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.updateProjectExtents instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
817
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.updateProjectExtents instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
810
818
  */
811
819
  updateProjectExtents(newExtents) {
812
820
  this[_implicitTxn].updateProjectExtents(newExtents);
@@ -830,13 +838,13 @@ export class IModelDb extends IModel {
830
838
  };
831
839
  }
832
840
  /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel.
833
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.updateEcefLocation instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
841
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.updateEcefLocation instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
834
842
  */
835
843
  updateEcefLocation(ecef) {
836
844
  this[_implicitTxn].updateEcefLocation(ecef);
837
845
  }
838
846
  /** Update the IModelProps of this iModel in the database.
839
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.updateIModelProps instead, within an explicit EditTxn scope (or via withEditTxn).
847
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.updateIModelProps instead, within an explicit EditTxn scope (or via withEditTxn).
840
848
  */
841
849
  updateIModelProps() {
842
850
  this[_implicitTxn].updateIModelProps();
@@ -845,7 +853,7 @@ export class IModelDb extends IModel {
845
853
  this[_implicitTxn].saveChanges(descriptionOrArgs);
846
854
  }
847
855
  /** Abandon changes in memory that have not been saved as a Txn to this iModelDb.
848
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.abandonChanges instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
856
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.abandonChanges instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
849
857
  */
850
858
  abandonChanges() {
851
859
  this[_implicitTxn].abandonChanges();
@@ -1234,7 +1242,7 @@ export class IModelDb extends IModel {
1234
1242
  }
1235
1243
  /** The registry of entity metadata for this iModel.
1236
1244
  * @internal
1237
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.
1245
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` from the `iModel` instead.
1238
1246
  *
1239
1247
  * @example
1240
1248
  * ```typescript
@@ -1242,7 +1250,8 @@ export class IModelDb extends IModel {
1242
1250
  * const classMetaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find("SchemaName:ClassName");
1243
1251
  *
1244
1252
  * // Replacement:
1245
- * const metaData: EntityClass | undefined = imodel.schemaContext.getSchemaItemSync("SchemaName.ClassName", EntityClass);
1253
+ * const view = await imodel.getSchemaView();
1254
+ * const cls = view.findClass("SchemaName:ClassName");
1246
1255
  * ```
1247
1256
  */
1248
1257
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -1269,7 +1278,11 @@ export class IModelDb extends IModel {
1269
1278
  return this._schemaMap;
1270
1279
  }
1271
1280
  /**
1272
- * Gets the context that allows accessing the metadata (ecschema-metadata package) of this iModel
1281
+ * Gets the context that allows accessing the metadata (`@itwin/ecschema-metadata` package) of this iModel.
1282
+ *
1283
+ * For runtime read-only access - class/property iteration, IS-A checks, navigating relationships, KOQ lookups -
1284
+ * prefer [[getSchemaView]]. `schemaContext` remains the right choice when you need schema authoring
1285
+ * (via `@itwin/ecschema-editing`), custom-attribute deserialization, or the full ecschema-metadata object graph.
1273
1286
  * @public @preview
1274
1287
  */
1275
1288
  get schemaContext() {
@@ -1283,6 +1296,55 @@ export class IModelDb extends IModel {
1283
1296
  }
1284
1297
  return this._schemaContext;
1285
1298
  }
1299
+ /** Get the schema view for this iModel. The view is built lazily on
1300
+ * first call by fetching compact binary schema data via `PRAGMA schema_view` through
1301
+ * the ConcurrentQuery thread pool. Subsequent calls return the cached view. Multiple
1302
+ * concurrent callers share a single in-flight build.
1303
+ *
1304
+ * The returned `SchemaView` is a lightweight, read-only, synchronous API for
1305
+ * navigating schema metadata - classes, properties, relationships, enumerations, etc.
1306
+ * It is the recommended default for runtime read-only metadata access and is significantly
1307
+ * faster and lower-memory than [[schemaContext]]. Use [[schemaContext]] for schema authoring,
1308
+ * custom-attribute deserialization, or anywhere you need the full ecschema-metadata object graph.
1309
+ * @beta
1310
+ */
1311
+ async getSchemaView() {
1312
+ if (this._schemasPromise) {
1313
+ const ctx = await this._schemasPromise;
1314
+ if (!ctx.isOutdated)
1315
+ return ctx;
1316
+ }
1317
+ // Capture the in-flight promise locally so the rejection handler only clears
1318
+ // `_schemasPromise` if it still points at this build. A concurrent invalidation +
1319
+ // re-fetch could otherwise replace the field before our hydrate fails, and a naive
1320
+ // `_schemasPromise = undefined` would clobber that newer reference.
1321
+ const inflight = this._hydrateSchemas();
1322
+ this._schemasPromise = inflight;
1323
+ inflight.catch(() => {
1324
+ if (this._schemasPromise === inflight)
1325
+ this._schemasPromise = undefined;
1326
+ });
1327
+ return inflight;
1328
+ }
1329
+ async _hydrateSchemas() {
1330
+ // PRAGMA returns exactly one row with format, formatVersion, data (binary), schemaToken.
1331
+ // Important: only call reader.next() once - do NOT use `for await` on PRAGMA results.
1332
+ // ConcurrentQuery wraps regular ECSQL in LIMIT/OFFSET for pagination but skips this for
1333
+ // PRAGMAs. If the serialized result exceeds the memory threshold, the response is marked
1334
+ // "Partial", and a `for await` loop would re-issue the same PRAGMA forever since PRAGMAs
1335
+ // don't support OFFSET-based pagination.
1336
+ // This implementation uses the non-pinned version of the pragma other than frontend - because backend
1337
+ // is always strictly coupled with the native code.
1338
+ const reader = this.createQueryReader("PRAGMA schema_view");
1339
+ const result = await reader.next();
1340
+ if (result.done)
1341
+ throw new IModelError(DbResult.BE_SQLITE_ERROR, "PRAGMA schema_view returned no rows");
1342
+ const data = result.value.data;
1343
+ const token = result.value.schemaToken;
1344
+ if (data === undefined || data === null)
1345
+ throw new IModelError(DbResult.BE_SQLITE_ERROR, "PRAGMA schema_view returned null data column");
1346
+ return SchemaView.fromBinary(data, token ?? "");
1347
+ }
1286
1348
  /** Get the linkTableRelationships for this IModel */
1287
1349
  get relationships() {
1288
1350
  return this._relationships || (this._relationships = new Relationships(this));
@@ -1357,7 +1419,7 @@ export class IModelDb extends IModel {
1357
1419
  }
1358
1420
  /** Get metadata for a class. This method will load the metadata from the iModel into the cache as a side-effect, if necessary.
1359
1421
  * @throws [[IModelError]] if the metadata cannot be found nor loaded.
1360
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `getSchemaItem` from `SchemaContext` class instead.
1422
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` on the iModel and call `view.findClass(...)` instead.
1361
1423
  *
1362
1424
  * @example
1363
1425
  * * ```typescript
@@ -1365,7 +1427,8 @@ export class IModelDb extends IModel {
1365
1427
  * const metaData: EntityMetaData = imodel.getMetaData("SchemaName:ClassName");
1366
1428
  *
1367
1429
  * // Replacement:
1368
- * const metaData: EntityClass | undefined = imodel.schemaContext.getSchemaItemSync("SchemaName", "ClassName", EntityClass);
1430
+ * const view = await imodel.getSchemaView();
1431
+ * const cls = view.findClass("SchemaName:ClassName");
1369
1432
  * ```
1370
1433
  */
1371
1434
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -1383,7 +1446,7 @@ export class IModelDb extends IModel {
1383
1446
  return metadata;
1384
1447
  }
1385
1448
  /** Identical to [[getMetaData]], except it returns `undefined` instead of throwing an error if the metadata cannot be found nor loaded.
1386
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `getSchemaItem` from `SchemaContext` class instead.
1449
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` on the iModel and call `view.findClass(...)` instead.
1387
1450
  *
1388
1451
  * @example
1389
1452
  * * ```typescript
@@ -1391,7 +1454,8 @@ export class IModelDb extends IModel {
1391
1454
  * const metaData: EntityMetaData | undefined = imodel.tryGetMetaData("SchemaName:ClassName");
1392
1455
  *
1393
1456
  * // Replacement:
1394
- * const metaData: EntityClass | undefined = imodel.schemaContext.getSchemaItemSync("SchemaName.ClassName", EntityClass);
1457
+ * const view = await imodel.getSchemaView();
1458
+ * const cls = view.findClass("SchemaName:ClassName");
1395
1459
  * ```
1396
1460
  */
1397
1461
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -1411,7 +1475,7 @@ export class IModelDb extends IModel {
1411
1475
  * @param func The callback to be invoked on each property
1412
1476
  * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
1413
1477
  * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
1414
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `forEachProperty` instead.
1478
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` on the iModel and iterate `view.findClass(classFullName)?.getProperties()` instead.
1415
1479
  *
1416
1480
  * @example
1417
1481
  * ```typescript
@@ -1421,9 +1485,10 @@ export class IModelDb extends IModel {
1421
1485
  * }, false);
1422
1486
  *
1423
1487
  * // Replacement:
1424
- * await IModelDb.forEachProperty(imodel, "TestDomain.TestDomainClass", true, (propName: string, property: Property) => {
1425
- * console.log(`Property name: ${propName}, Property type: ${property.propertyType}`);
1426
- * }, false);
1488
+ * const view = await imodel.getSchemaView();
1489
+ * for (const property of view.findClass("BisCore:Element")?.getProperties() ?? []) {
1490
+ * console.log(`Property name: ${property.name}, Kind: ${property.kind}`);
1491
+ * }
1427
1492
  * ```
1428
1493
  */
1429
1494
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -1437,7 +1502,7 @@ export class IModelDb extends IModel {
1437
1502
  * @param func The callback to be invoked on each property
1438
1503
  * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
1439
1504
  * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
1440
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `forEachProperty` from `SchemaContext` class instead.
1505
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` on the iModel and iterate `view.findClass(classFullName)?.getProperties()` instead.
1441
1506
  *
1442
1507
  * @example
1443
1508
  * ```typescript
@@ -1447,9 +1512,10 @@ export class IModelDb extends IModel {
1447
1512
  * });
1448
1513
  *
1449
1514
  * // Replacement:
1450
- * imodel.schemaContext.forEachProperty("BisCore:Element", true, (propName: string, property: Property) => {
1451
- * console.log(`Property name: ${propName}, Property type: ${property.propertyType}`);
1452
- * });
1515
+ * const view = await imodel.getSchemaView();
1516
+ * for (const property of view.findClass("BisCore:Element")?.getProperties() ?? []) {
1517
+ * console.log(`Property name: ${property.name}, Kind: ${property.kind}`);
1518
+ * }
1453
1519
  * ```
1454
1520
  */
1455
1521
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -1573,7 +1639,7 @@ export class IModelDb extends IModel {
1573
1639
  * @param prop the FilePropertyProps that describes the new property
1574
1640
  * @param value either a string or a blob to save as the file property
1575
1641
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {TxnManager.withIndirectTxnMode}.
1576
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.saveFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1642
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.saveFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1577
1643
  */
1578
1644
  saveFileProperty(prop, strValue, blobVal) {
1579
1645
  this[_implicitTxn].saveFileProperty(prop, strValue, blobVal);
@@ -1581,7 +1647,7 @@ export class IModelDb extends IModel {
1581
1647
  /** delete a "file property" from this iModel
1582
1648
  * @param prop the FilePropertyProps that describes the property
1583
1649
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {TxnManager.withIndirectTxnMode}.
1584
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.deleteFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1650
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.deleteFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1585
1651
  */
1586
1652
  deleteFileProperty(prop) {
1587
1653
  this[_implicitTxn].deleteFileProperty(prop);
@@ -1789,14 +1855,14 @@ export class IModelDb extends IModel {
1789
1855
  * @param dict The SettingDictionary object to stringify and save.
1790
1856
  * @note All saved `SettingDictionary`s are loaded into [[workspace.settings]] every time an iModel is opened.
1791
1857
  * @see [[Settings.addDictionary]] to register a dictionary for the current session only without persisting it.
1792
- * @beta @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.saveSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1858
+ * @beta @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.saveSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1793
1859
  */
1794
1860
  saveSettingDictionary(name, dict) {
1795
1861
  this[_implicitTxn].saveSettingDictionary(name, dict);
1796
1862
  }
1797
1863
  /** Delete a SettingDictionary, previously added with [[saveSettingDictionary]], from this iModel.
1798
1864
  * @param name The name of the dictionary to delete.
1799
- * @beta @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use EditTxn.deleteSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1865
+ * @beta @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.deleteSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1800
1866
  */
1801
1867
  deleteSettingDictionary(name) {
1802
1868
  this[_implicitTxn].deleteSettingDictionary(name);
@@ -2085,7 +2151,7 @@ function processSchemaWriteStatus(status) {
2085
2151
  * @param props The data for the new model.
2086
2152
  * @returns The newly inserted model's Id.
2087
2153
  * @throws [[IModelError]] if insertion fails.
2088
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.insertModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2154
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.insertModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2089
2155
  */
2090
2156
  insertModel(props) {
2091
2157
  return this._iModel[_implicitTxn].insertModel(props);
@@ -2093,7 +2159,7 @@ function processSchemaWriteStatus(status) {
2093
2159
  /** Update an existing model.
2094
2160
  * @param props the properties of the model to change
2095
2161
  * @throws [[IModelError]] if update fails.
2096
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.updateModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2162
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.updateModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2097
2163
  */
2098
2164
  updateModel(props) {
2099
2165
  this._iModel[_implicitTxn].updateModel(props);
@@ -2105,7 +2171,7 @@ function processSchemaWriteStatus(status) {
2105
2171
  * Cached [Tile]($frontend)s are only invalidated after the geometry guid of the model changes.
2106
2172
  * @note This will throw IModelError with [IModelStatus.VersionTooOld]($core-bentley) if a version of the BisCore schema older than 1.0.11 is present in the iModel.
2107
2173
  * @throws [[IModelError]] if the update fails.
2108
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.updateGeometryGuid instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2174
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.updateGeometryGuid instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2109
2175
  * @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
2110
2176
  */
2111
2177
  updateGeometryGuid(modelId) {
@@ -2114,7 +2180,7 @@ function processSchemaWriteStatus(status) {
2114
2180
  /** Delete one or more existing models.
2115
2181
  * @param ids The Ids of the models to be deleted
2116
2182
  * @throws [[IModelError]] if deletion fails.
2117
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.deleteModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2183
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.deleteModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2118
2184
  */
2119
2185
  deleteModel(ids) {
2120
2186
  this._iModel[_implicitTxn].deleteModel(ids);
@@ -2340,7 +2406,7 @@ function processSchemaWriteStatus(status) {
2340
2406
  * However when `elProps.federationGuid` is not present or undefined, a new Guid will be generated and stored on the resultant element. But
2341
2407
  * the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
2342
2408
  * if you intend to continue working with it. That will ensure its values reflect the persistent state.
2343
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.insertElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2409
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.insertElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2344
2410
  */
2345
2411
  insertElement(elProps, options) {
2346
2412
  return this._iModel[_implicitTxn].insertElement(elProps, options);
@@ -2355,7 +2421,7 @@ function processSchemaWriteStatus(status) {
2355
2421
  * @note The values of `classFullName` and `model` *may not be changed* by this method. Further, it will permute the `elProps` object by adding or
2356
2422
  * overwriting their values to the correct values.
2357
2423
  * @throws [[ITwinError]] if update fails.
2358
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.updateElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2424
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.updateElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2359
2425
  */
2360
2426
  updateElement(elProps) {
2361
2427
  this._iModel[_implicitTxn].updateElement(elProps);
@@ -2364,11 +2430,23 @@ function processSchemaWriteStatus(status) {
2364
2430
  * @param ids The set of Ids of the element(s) to be deleted
2365
2431
  * @throws [[ITwinError]]
2366
2432
  * @see deleteDefinitionElements
2367
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.deleteElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2433
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.deleteElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2368
2434
  */
2369
2435
  deleteElement(ids) {
2370
2436
  this._iModel[_implicitTxn].deleteElement(ids);
2371
2437
  }
2438
+ /**
2439
+ * Delete multiple elements from the iModel.
2440
+ * @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
2441
+ * @param deleteOptions Options for the delete operation.
2442
+ * @returns A result object containing information about the deletion operation success and the element ids that failed to delete (if any).
2443
+ * @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
2444
+ * @deprecated in 5.1.9 - will not be removed until after 2026-08-15. Use EditTxn.deleteElements instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2445
+ * @beta
2446
+ */
2447
+ deleteElements(ids, deleteOptions) {
2448
+ return this._iModel[_implicitTxn].deleteElements(ids, deleteOptions);
2449
+ }
2372
2450
  /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
2373
2451
  * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
2374
2452
  * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
@@ -2377,7 +2455,7 @@ function processSchemaWriteStatus(status) {
2377
2455
  * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
2378
2456
  * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
2379
2457
  * @see deleteElement
2380
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.deleteDefinitionElements instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2458
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.deleteDefinitionElements instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2381
2459
  */
2382
2460
  deleteDefinitionElements(definitionElementIds) {
2383
2461
  return this._iModel[_implicitTxn].deleteDefinitionElements(definitionElementIds);
@@ -2571,7 +2649,7 @@ function processSchemaWriteStatus(status) {
2571
2649
  * @returns the id of the newly inserted aspect.
2572
2650
  * @note Aspect Ids may collide with element Ids, so don't put both in a container like Set or Map
2573
2651
  * use [EntityReference]($common) for that instead.
2574
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.insertAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2652
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.insertAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2575
2653
  */
2576
2654
  insertAspect(aspectProps) {
2577
2655
  return this._iModel[_implicitTxn].insertAspect(aspectProps);
@@ -2579,7 +2657,7 @@ function processSchemaWriteStatus(status) {
2579
2657
  /** Update an exist ElementAspect within the iModel.
2580
2658
  * @param aspectProps The properties to use to update the ElementAspect.
2581
2659
  * @throws [[IModelError]] if unable to update the ElementAspect.
2582
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.updateAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2660
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.updateAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2583
2661
  */
2584
2662
  updateAspect(aspectProps) {
2585
2663
  this._iModel[_implicitTxn].updateAspect(aspectProps);
@@ -2587,7 +2665,7 @@ function processSchemaWriteStatus(status) {
2587
2665
  /** Delete one or more ElementAspects from this iModel.
2588
2666
  * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
2589
2667
  * @throws [[IModelError]] if unable to delete the ElementAspect.
2590
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.deleteAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2668
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.deleteAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2591
2669
  */
2592
2670
  deleteAspect(aspectInstanceIds) {
2593
2671
  this._iModel[_implicitTxn].deleteAspect(aspectInstanceIds);
@@ -2634,7 +2712,7 @@ function processSchemaWriteStatus(status) {
2634
2712
  return this._viewStore;
2635
2713
  }
2636
2714
  /**
2637
- * @beta @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.saveDefaultViewStore instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2715
+ * @beta @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use EditTxn.saveDefaultViewStore instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2638
2716
  */
2639
2717
  saveDefaultViewStore(arg) {
2640
2718
  this._iModel[_implicitTxn].saveDefaultViewStore(arg);
@@ -3323,7 +3401,63 @@ export class BriefcaseDb extends IModelDb {
3323
3401
  async getAllChangesetHealthData() {
3324
3402
  return this[_nativeDb].getAllChangesetHealthData();
3325
3403
  }
3326
- /** Revert timeline changes and then push resulting changeset */
3404
+ /**
3405
+ * Whether file-based transactions are enabled for this briefcase.
3406
+ *
3407
+ * When enabled, transaction data is stored in separate temporary `.txn` files rather than in the
3408
+ * briefcase's internal transaction table. This avoids SQLite blob size limits and reduces memory
3409
+ * pressure for very large changesets, at the cost of additional disk I/O.
3410
+ * @see [[enableFileBasedTxns]] to enable, [[disableFileBasedTxns]] to disable.
3411
+ * @internal
3412
+ */
3413
+ get isFileBasedTxnsEnabled() {
3414
+ return this[_nativeDb].queryLocalValue("fileBasedTxns") === "1";
3415
+ }
3416
+ /**
3417
+ * Enable file-based transactions for this briefcase.
3418
+ * @throws IModelError with [[ChangeSetStatus.HasUncommittedChanges]] if there are unsaved changes.
3419
+ * @throws IModelError with [[ChangeSetStatus.HasLocalChanges]] if there are pending transactions.
3420
+ * @internal
3421
+ */
3422
+ enableFileBasedTxns() {
3423
+ this._setFileBasedTxnsSetting(true);
3424
+ }
3425
+ /**
3426
+ * Disable file-based transactions for this briefcase, reverting to the default storage mode
3427
+ * (transactions stored within the briefcase's internal transaction table).
3428
+ * @throws IModelError with [[ChangeSetStatus.HasUncommittedChanges]] if there are unsaved changes.
3429
+ * @throws IModelError with [[ChangeSetStatus.HasLocalChanges]] if there are pending transactions.
3430
+ * @internal
3431
+ */
3432
+ disableFileBasedTxns() {
3433
+ this._setFileBasedTxnsSetting(false);
3434
+ }
3435
+ _setFileBasedTxnsSetting(enabled) {
3436
+ if (this.isFileBasedTxnsEnabled === enabled)
3437
+ return;
3438
+ const nativeDb = this[_nativeDb];
3439
+ if (nativeDb.hasUnsavedChanges())
3440
+ throw new IModelError(ChangeSetStatus.HasUncommittedChanges, "Cannot change file-based transactions setting while there are unsaved changes");
3441
+ if (nativeDb.hasPendingTxns())
3442
+ throw new IModelError(ChangeSetStatus.HasLocalChanges, "Cannot change file-based transactions setting while there are pending transactions");
3443
+ if (enabled)
3444
+ nativeDb.saveLocalValue("fileBasedTxns", "1");
3445
+ else
3446
+ nativeDb.deleteLocalValue("fileBasedTxns");
3447
+ }
3448
+ /**
3449
+ * Revert timeline changes and push the resulting changeset.
3450
+ *
3451
+ * Pulls the latest changes, acquires the schema lock, reverts the inclusive range of
3452
+ * changesets `[toIndex..current]`, and pushes the revert as a new changeset. On failure,
3453
+ * follow the behavior specified by `arg.inCaseOfFailure`, which may discard local changes,
3454
+ * retain local changes, or delete the briefcase.
3455
+ *
3456
+ * @param arg - Arguments specifying the target changeset index, push options, access token, and failure handling behavior.
3457
+ * @throws IModelError with [[ChangeSetStatus.ApplyError]] if `toIndex` is not specified.
3458
+ * @throws IModelError with [[ChangeSetStatus.HasUncommittedChanges]] if there are unsaved changes.
3459
+ * @throws IModelError with [[ChangeSetStatus.HasLocalChanges]] if there are pending transactions.
3460
+ */
3327
3461
  async revertAndPushChanges(arg) {
3328
3462
  const nativeDb = this[_nativeDb];
3329
3463
  if (arg.toIndex === undefined) {
@@ -3355,11 +3489,14 @@ export class BriefcaseDb extends IModelDb {
3355
3489
  if (nativeDb.schemaSyncEnabled()) {
3356
3490
  arg.skipSchemaChanges = true;
3357
3491
  }
3492
+ // The native side enables file-based txns during revert. Restore the original setting afterward.
3493
+ const wasFileBasedTxnsEnabled = this.isFileBasedTxnsEnabled;
3494
+ const preRevertIndex = this.changeset.index;
3358
3495
  try {
3359
3496
  await BriefcaseManager.revertTimelineChanges(this, arg);
3360
- this[_nativeDb].saveChanges("Revert changes");
3497
+ nativeDb.saveChanges("Revert changes");
3361
3498
  if (!arg.description) {
3362
- arg.description = `Reverted changes from ${this.changeset.index} to ${arg.toIndex}${arg.skipSchemaChanges ? " (schema changes skipped)" : ""}`;
3499
+ arg.description = `Reverted changes from ${preRevertIndex} to ${arg.toIndex}${arg.skipSchemaChanges ? " (schema changes skipped)" : ""}`;
3363
3500
  }
3364
3501
  const pushArgs = {
3365
3502
  description: arg.description,
@@ -3374,13 +3511,49 @@ export class BriefcaseDb extends IModelDb {
3374
3511
  this.clearCaches();
3375
3512
  }
3376
3513
  catch (err) {
3377
- if (!arg.retainLocks) {
3378
- await this.locks.releaseAllLocks();
3379
- throw err;
3514
+ const failureAction = arg.inCaseOfFailure ?? "revert";
3515
+ try {
3516
+ switch (failureAction) {
3517
+ case "revert":
3518
+ // Restore the briefcase to its pre-revert state: save any unsaved changes into txns,
3519
+ // reverse all txns, then delete them.
3520
+ nativeDb.saveChanges();
3521
+ if (nativeDb.hasPendingTxns())
3522
+ nativeDb.reverseAll();
3523
+ nativeDb.deleteAllTxns();
3524
+ break;
3525
+ case "delete":
3526
+ // Clear local changes first so lock release can succeed.
3527
+ nativeDb.abandonChanges();
3528
+ nativeDb.deleteAllTxns();
3529
+ if (!arg.retainLocks)
3530
+ await this.locks.releaseAllLocks();
3531
+ const filePath = this.pathName;
3532
+ this.close();
3533
+ await BriefcaseManager.deleteBriefcaseFiles(filePath, arg.accessToken);
3534
+ break;
3535
+ case "retain":
3536
+ // Keep local changes as-is for caller inspection/recovery.
3537
+ nativeDb.saveChanges();
3538
+ break;
3539
+ }
3540
+ }
3541
+ catch (cleanupErr) {
3542
+ Logger.logError(loggerCategory, `Failed to clean up after revert error (action=${failureAction}): ${String(cleanupErr)}`);
3380
3543
  }
3544
+ if (!arg.retainLocks && this.isOpen) {
3545
+ try {
3546
+ await this.locks.releaseAllLocks();
3547
+ }
3548
+ catch (lockErr) {
3549
+ Logger.logError(loggerCategory, `Failed to release locks after revert failure (action=${failureAction}): ${String(lockErr)}`);
3550
+ }
3551
+ }
3552
+ throw err;
3381
3553
  }
3382
3554
  finally {
3383
- this[_nativeDb].abandonChanges();
3555
+ if (this.isOpen && !wasFileBasedTxnsEnabled && !nativeDb.hasPendingTxns() && !nativeDb.hasUnsavedChanges())
3556
+ this.disableFileBasedTxns();
3384
3557
  }
3385
3558
  }
3386
3559
  /**