@itwin/core-backend 5.9.0-dev.3 → 5.9.0-dev.5

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 (426) hide show
  1. package/lib/cjs/BriefcaseManager.js +3 -3
  2. package/lib/cjs/BriefcaseManager.js.map +1 -1
  3. package/lib/cjs/Category.d.ts +37 -7
  4. package/lib/cjs/Category.d.ts.map +1 -1
  5. package/lib/cjs/Category.js +33 -42
  6. package/lib/cjs/Category.js.map +1 -1
  7. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  8. package/lib/cjs/ChangesetECAdaptor.js +5 -2
  9. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  10. package/lib/cjs/ChannelControl.d.ts +29 -0
  11. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  12. package/lib/cjs/ChannelControl.js.map +1 -1
  13. package/lib/cjs/CheckpointManager.js +1 -1
  14. package/lib/cjs/CheckpointManager.js.map +1 -1
  15. package/lib/cjs/CodeSpecs.d.ts +32 -3
  16. package/lib/cjs/CodeSpecs.d.ts.map +1 -1
  17. package/lib/cjs/CodeSpecs.js +48 -20
  18. package/lib/cjs/CodeSpecs.js.map +1 -1
  19. package/lib/cjs/DisplayStyle.d.ts +18 -3
  20. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  21. package/lib/cjs/DisplayStyle.js +10 -21
  22. package/lib/cjs/DisplayStyle.js.map +1 -1
  23. package/lib/cjs/EditTxn.d.ts +262 -0
  24. package/lib/cjs/EditTxn.d.ts.map +1 -0
  25. package/lib/cjs/EditTxn.js +548 -0
  26. package/lib/cjs/EditTxn.js.map +1 -0
  27. package/lib/cjs/Element.d.ts +74 -5
  28. package/lib/cjs/Element.d.ts.map +1 -1
  29. package/lib/cjs/Element.js +63 -75
  30. package/lib/cjs/Element.js.map +1 -1
  31. package/lib/cjs/ElementAspect.d.ts +10 -0
  32. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  33. package/lib/cjs/ElementAspect.js +21 -12
  34. package/lib/cjs/ElementAspect.js.map +1 -1
  35. package/lib/cjs/ElementTreeWalker.d.ts +56 -3
  36. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  37. package/lib/cjs/ElementTreeWalker.js +53 -40
  38. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  39. package/lib/cjs/ExternalSource.d.ts +11 -2
  40. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  41. package/lib/cjs/ExternalSource.js +10 -8
  42. package/lib/cjs/ExternalSource.js.map +1 -1
  43. package/lib/cjs/IModelDb.d.ts +66 -22
  44. package/lib/cjs/IModelDb.d.ts.map +1 -1
  45. package/lib/cjs/IModelDb.js +174 -288
  46. package/lib/cjs/IModelDb.js.map +1 -1
  47. package/lib/cjs/IModelHost.d.ts +22 -0
  48. package/lib/cjs/IModelHost.d.ts.map +1 -1
  49. package/lib/cjs/IModelHost.js +9 -0
  50. package/lib/cjs/IModelHost.js.map +1 -1
  51. package/lib/cjs/IpcHost.js +2 -2
  52. package/lib/cjs/IpcHost.js.map +1 -1
  53. package/lib/cjs/LineStyle.d.ts +47 -7
  54. package/lib/cjs/LineStyle.d.ts.map +1 -1
  55. package/lib/cjs/LineStyle.js +38 -33
  56. package/lib/cjs/LineStyle.js.map +1 -1
  57. package/lib/cjs/Material.d.ts +8 -1
  58. package/lib/cjs/Material.d.ts.map +1 -1
  59. package/lib/cjs/Material.js +6 -12
  60. package/lib/cjs/Material.js.map +1 -1
  61. package/lib/cjs/Model.d.ts +59 -20
  62. package/lib/cjs/Model.d.ts.map +1 -1
  63. package/lib/cjs/Model.js +38 -80
  64. package/lib/cjs/Model.js.map +1 -1
  65. package/lib/cjs/Relationship.d.ts +72 -7
  66. package/lib/cjs/Relationship.d.ts.map +1 -1
  67. package/lib/cjs/Relationship.js +39 -21
  68. package/lib/cjs/Relationship.js.map +1 -1
  69. package/lib/cjs/SchemaSync.js +4 -4
  70. package/lib/cjs/SchemaSync.js.map +1 -1
  71. package/lib/cjs/SheetIndex.d.ts +9 -0
  72. package/lib/cjs/SheetIndex.d.ts.map +1 -1
  73. package/lib/cjs/SheetIndex.js +38 -35
  74. package/lib/cjs/SheetIndex.js.map +1 -1
  75. package/lib/cjs/StashManager.js +1 -1
  76. package/lib/cjs/StashManager.js.map +1 -1
  77. package/lib/cjs/Texture.d.ts +6 -0
  78. package/lib/cjs/Texture.d.ts.map +1 -1
  79. package/lib/cjs/Texture.js +6 -14
  80. package/lib/cjs/Texture.js.map +1 -1
  81. package/lib/cjs/TxnManager.d.ts +5 -5
  82. package/lib/cjs/TxnManager.d.ts.map +1 -1
  83. package/lib/cjs/TxnManager.js +23 -7
  84. package/lib/cjs/TxnManager.js.map +1 -1
  85. package/lib/cjs/ViewDefinition.d.ts +21 -1
  86. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  87. package/lib/cjs/ViewDefinition.js +27 -66
  88. package/lib/cjs/ViewDefinition.js.map +1 -1
  89. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
  90. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  91. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +33 -27
  92. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  93. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  94. package/lib/cjs/annotations/TextAnnotationElement.js +6 -5
  95. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  96. package/lib/cjs/core-backend.d.ts +1 -0
  97. package/lib/cjs/core-backend.d.ts.map +1 -1
  98. package/lib/cjs/core-backend.js +1 -0
  99. package/lib/cjs/core-backend.js.map +1 -1
  100. package/lib/cjs/domains/FunctionalElements.d.ts +6 -2
  101. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  102. package/lib/cjs/domains/FunctionalElements.js +8 -13
  103. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  104. package/lib/cjs/domains/GenericElements.d.ts +11 -4
  105. package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
  106. package/lib/cjs/domains/GenericElements.js +13 -24
  107. package/lib/cjs/domains/GenericElements.js.map +1 -1
  108. package/lib/cjs/internal/ChannelAdmin.d.ts +15 -0
  109. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
  110. package/lib/cjs/internal/ChannelAdmin.js +5 -3
  111. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  112. package/lib/cjs/internal/Symbols.d.ts +4 -0
  113. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  114. package/lib/cjs/internal/Symbols.js +5 -1
  115. package/lib/cjs/internal/Symbols.js.map +1 -1
  116. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  117. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  118. package/lib/cjs/internal/annotations/fields.js +7 -6
  119. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  120. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  121. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  122. package/lib/esm/BriefcaseManager.js +3 -3
  123. package/lib/esm/BriefcaseManager.js.map +1 -1
  124. package/lib/esm/Category.d.ts +37 -7
  125. package/lib/esm/Category.d.ts.map +1 -1
  126. package/lib/esm/Category.js +33 -42
  127. package/lib/esm/Category.js.map +1 -1
  128. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  129. package/lib/esm/ChangesetECAdaptor.js +5 -2
  130. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  131. package/lib/esm/ChannelControl.d.ts +29 -0
  132. package/lib/esm/ChannelControl.d.ts.map +1 -1
  133. package/lib/esm/ChannelControl.js.map +1 -1
  134. package/lib/esm/CheckpointManager.js +1 -1
  135. package/lib/esm/CheckpointManager.js.map +1 -1
  136. package/lib/esm/CodeSpecs.d.ts +32 -3
  137. package/lib/esm/CodeSpecs.d.ts.map +1 -1
  138. package/lib/esm/CodeSpecs.js +49 -21
  139. package/lib/esm/CodeSpecs.js.map +1 -1
  140. package/lib/esm/DisplayStyle.d.ts +18 -3
  141. package/lib/esm/DisplayStyle.d.ts.map +1 -1
  142. package/lib/esm/DisplayStyle.js +10 -21
  143. package/lib/esm/DisplayStyle.js.map +1 -1
  144. package/lib/esm/EditTxn.d.ts +262 -0
  145. package/lib/esm/EditTxn.d.ts.map +1 -0
  146. package/lib/esm/EditTxn.js +543 -0
  147. package/lib/esm/EditTxn.js.map +1 -0
  148. package/lib/esm/Element.d.ts +74 -5
  149. package/lib/esm/Element.d.ts.map +1 -1
  150. package/lib/esm/Element.js +64 -76
  151. package/lib/esm/Element.js.map +1 -1
  152. package/lib/esm/ElementAspect.d.ts +10 -0
  153. package/lib/esm/ElementAspect.d.ts.map +1 -1
  154. package/lib/esm/ElementAspect.js +22 -13
  155. package/lib/esm/ElementAspect.js.map +1 -1
  156. package/lib/esm/ElementTreeWalker.d.ts +56 -3
  157. package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
  158. package/lib/esm/ElementTreeWalker.js +53 -40
  159. package/lib/esm/ElementTreeWalker.js.map +1 -1
  160. package/lib/esm/ExternalSource.d.ts +11 -2
  161. package/lib/esm/ExternalSource.d.ts.map +1 -1
  162. package/lib/esm/ExternalSource.js +10 -8
  163. package/lib/esm/ExternalSource.js.map +1 -1
  164. package/lib/esm/IModelDb.d.ts +66 -22
  165. package/lib/esm/IModelDb.d.ts.map +1 -1
  166. package/lib/esm/IModelDb.js +176 -290
  167. package/lib/esm/IModelDb.js.map +1 -1
  168. package/lib/esm/IModelHost.d.ts +22 -0
  169. package/lib/esm/IModelHost.d.ts.map +1 -1
  170. package/lib/esm/IModelHost.js +9 -0
  171. package/lib/esm/IModelHost.js.map +1 -1
  172. package/lib/esm/IpcHost.js +3 -3
  173. package/lib/esm/IpcHost.js.map +1 -1
  174. package/lib/esm/LineStyle.d.ts +47 -7
  175. package/lib/esm/LineStyle.d.ts.map +1 -1
  176. package/lib/esm/LineStyle.js +38 -33
  177. package/lib/esm/LineStyle.js.map +1 -1
  178. package/lib/esm/Material.d.ts +8 -1
  179. package/lib/esm/Material.d.ts.map +1 -1
  180. package/lib/esm/Material.js +6 -12
  181. package/lib/esm/Material.js.map +1 -1
  182. package/lib/esm/Model.d.ts +59 -20
  183. package/lib/esm/Model.d.ts.map +1 -1
  184. package/lib/esm/Model.js +39 -81
  185. package/lib/esm/Model.js.map +1 -1
  186. package/lib/esm/Relationship.d.ts +72 -7
  187. package/lib/esm/Relationship.d.ts.map +1 -1
  188. package/lib/esm/Relationship.js +40 -22
  189. package/lib/esm/Relationship.js.map +1 -1
  190. package/lib/esm/SchemaSync.js +5 -5
  191. package/lib/esm/SchemaSync.js.map +1 -1
  192. package/lib/esm/SheetIndex.d.ts +9 -0
  193. package/lib/esm/SheetIndex.d.ts.map +1 -1
  194. package/lib/esm/SheetIndex.js +38 -35
  195. package/lib/esm/SheetIndex.js.map +1 -1
  196. package/lib/esm/StashManager.js +1 -1
  197. package/lib/esm/StashManager.js.map +1 -1
  198. package/lib/esm/Texture.d.ts +6 -0
  199. package/lib/esm/Texture.d.ts.map +1 -1
  200. package/lib/esm/Texture.js +6 -14
  201. package/lib/esm/Texture.js.map +1 -1
  202. package/lib/esm/TxnManager.d.ts +5 -5
  203. package/lib/esm/TxnManager.d.ts.map +1 -1
  204. package/lib/esm/TxnManager.js +23 -7
  205. package/lib/esm/TxnManager.js.map +1 -1
  206. package/lib/esm/ViewDefinition.d.ts +21 -1
  207. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  208. package/lib/esm/ViewDefinition.js +27 -66
  209. package/lib/esm/ViewDefinition.js.map +1 -1
  210. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
  211. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  212. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -27
  213. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  214. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  215. package/lib/esm/annotations/TextAnnotationElement.js +6 -5
  216. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  217. package/lib/esm/core-backend.d.ts +1 -0
  218. package/lib/esm/core-backend.d.ts.map +1 -1
  219. package/lib/esm/core-backend.js +1 -0
  220. package/lib/esm/core-backend.js.map +1 -1
  221. package/lib/esm/domains/FunctionalElements.d.ts +6 -2
  222. package/lib/esm/domains/FunctionalElements.d.ts.map +1 -1
  223. package/lib/esm/domains/FunctionalElements.js +8 -13
  224. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  225. package/lib/esm/domains/GenericElements.d.ts +11 -4
  226. package/lib/esm/domains/GenericElements.d.ts.map +1 -1
  227. package/lib/esm/domains/GenericElements.js +13 -24
  228. package/lib/esm/domains/GenericElements.js.map +1 -1
  229. package/lib/esm/internal/ChannelAdmin.d.ts +15 -0
  230. package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
  231. package/lib/esm/internal/ChannelAdmin.js +6 -4
  232. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  233. package/lib/esm/internal/Symbols.d.ts +4 -0
  234. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  235. package/lib/esm/internal/Symbols.js +4 -0
  236. package/lib/esm/internal/Symbols.js.map +1 -1
  237. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  238. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  239. package/lib/esm/internal/annotations/fields.js +7 -6
  240. package/lib/esm/internal/annotations/fields.js.map +1 -1
  241. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  242. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  243. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  244. package/lib/esm/test/ElementDrivesElement.test.d.ts +20 -19
  245. package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -1
  246. package/lib/esm/test/ElementDrivesElement.test.js +111 -96
  247. package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
  248. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  249. package/lib/esm/test/IModelHost.test.js +56 -2
  250. package/lib/esm/test/IModelHost.test.js.map +1 -1
  251. package/lib/esm/test/IModelTestUtils.d.ts +23 -23
  252. package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
  253. package/lib/esm/test/IModelTestUtils.js +466 -449
  254. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  255. package/lib/esm/test/PropertyDb.test.js +2 -2
  256. package/lib/esm/test/PropertyDb.test.js.map +1 -1
  257. package/lib/esm/test/SquashSchemaAndDataChanges.test.js +27 -18
  258. package/lib/esm/test/SquashSchemaAndDataChanges.test.js.map +1 -1
  259. package/lib/esm/test/TestChangeSetUtility.d.ts.map +1 -1
  260. package/lib/esm/test/TestChangeSetUtility.js +11 -7
  261. package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
  262. package/lib/esm/test/TestEditTxn.d.ts +8 -0
  263. package/lib/esm/test/TestEditTxn.d.ts.map +1 -0
  264. package/lib/esm/test/TestEditTxn.js +34 -0
  265. package/lib/esm/test/TestEditTxn.js.map +1 -0
  266. package/lib/esm/test/TestUtils.d.ts +1 -0
  267. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  268. package/lib/esm/test/TestUtils.js +8 -1
  269. package/lib/esm/test/TestUtils.js.map +1 -1
  270. package/lib/esm/test/annotations/Fields.test.js +82 -90
  271. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  272. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  273. package/lib/esm/test/annotations/TextAnnotation.test.js +156 -99
  274. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  275. package/lib/esm/test/annotations/TextBlock.test.js +5 -3
  276. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  277. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
  278. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  279. package/lib/esm/test/categories/Category.test.js +63 -3
  280. package/lib/esm/test/categories/Category.test.js.map +1 -1
  281. package/lib/esm/test/codespec/CodeSpec.test.js +88 -5
  282. package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
  283. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  284. package/lib/esm/test/ecdb/ECSqlAst.test.js +3 -2
  285. package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
  286. package/lib/esm/test/ecdb/ECSqlQuery.test.js +2 -2
  287. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  288. package/lib/esm/test/ecdb/ECSqlStatement.test.js +0 -1
  289. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  290. package/lib/esm/test/ecdb/QueryReaders.test.js +17 -14
  291. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  292. package/lib/esm/test/ecdb/SqliteStatement.test.js +2 -2
  293. package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
  294. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
  295. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +30 -28
  296. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
  297. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
  298. package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
  299. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  300. package/lib/esm/test/element/DeleteDefinitionElements.test.js +159 -143
  301. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  302. package/lib/esm/test/element/ElementAspect.test.js +68 -60
  303. package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
  304. package/lib/esm/test/element/ElementDependencyGraph.test.d.ts.map +1 -1
  305. package/lib/esm/test/element/ElementDependencyGraph.test.js +51 -43
  306. package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
  307. package/lib/esm/test/element/ElementRoundTrip.test.js +37 -38
  308. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  309. package/lib/esm/test/element/ExcludedElements.test.js +2 -2
  310. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  311. package/lib/esm/test/element/ExternalSource.test.js +40 -38
  312. package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
  313. package/lib/esm/test/element/NullStructArray.test.js +10 -9
  314. package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
  315. package/lib/esm/test/element/ProjectInformationRecord.test.js +5 -2
  316. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
  317. package/lib/esm/test/element/SheetInformationAspect.test.js +43 -11
  318. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
  319. package/lib/esm/test/element/UrlLink.test.js +2 -2
  320. package/lib/esm/test/element/UrlLink.test.js.map +1 -1
  321. package/lib/esm/test/font/IModelDbFonts.test.js +87 -73
  322. package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
  323. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +164 -125
  324. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  325. package/lib/esm/test/hubaccess/BriefcaseManager.test.js +2 -4
  326. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  327. package/lib/esm/test/hubaccess/Rebase.test.js +313 -247
  328. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  329. package/lib/esm/test/hubaccess/SemanticRebase.test.js +322 -247
  330. package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
  331. package/lib/esm/test/imodel/Code.test.js +31 -31
  332. package/lib/esm/test/imodel/Code.test.js.map +1 -1
  333. package/lib/esm/test/imodel/ElementTreeWalker.test.js +57 -48
  334. package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
  335. package/lib/esm/test/imodel/IModel.test.js +419 -344
  336. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  337. package/lib/esm/test/imodel/ProjectExtents.test.js +2 -2
  338. package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
  339. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  340. package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -1
  341. package/lib/esm/test/incrementalSchemaLocater/TestContext.js +2 -2
  342. package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -1
  343. package/lib/esm/test/index.d.ts +1 -0
  344. package/lib/esm/test/index.d.ts.map +1 -1
  345. package/lib/esm/test/index.js +1 -0
  346. package/lib/esm/test/index.js.map +1 -1
  347. package/lib/esm/test/schema/ClassRegistry.test.js +23 -22
  348. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  349. package/lib/esm/test/schema/FunctionalDomain.test.js +36 -34
  350. package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
  351. package/lib/esm/test/schema/GenericDomain.test.js +114 -94
  352. package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
  353. package/lib/esm/test/schema/IModelSchemaContext.test.js +2 -1
  354. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  355. package/lib/esm/test/schema/SchemaImportCallbacks.test.js +207 -192
  356. package/lib/esm/test/schema/SchemaImportCallbacks.test.js.map +1 -1
  357. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts +1 -3
  358. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts.map +1 -1
  359. package/lib/esm/test/sheetindex/SheetIndex.test.js +312 -247
  360. package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
  361. package/lib/esm/test/standalone/ChangeMerge.test.js +101 -82
  362. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  363. package/lib/esm/test/standalone/ChangesetReader.test.js +114 -85
  364. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  365. package/lib/esm/test/standalone/DisplayStyle.test.js +43 -40
  366. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
  367. package/lib/esm/test/standalone/Drawing.test.js +4 -3
  368. package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
  369. package/lib/esm/test/standalone/EditTxn.test.d.ts +2 -0
  370. package/lib/esm/test/standalone/EditTxn.test.d.ts.map +1 -0
  371. package/lib/esm/test/standalone/EditTxn.test.js +219 -0
  372. package/lib/esm/test/standalone/EditTxn.test.js.map +1 -0
  373. package/lib/esm/test/standalone/ElementMesh.test.js +16 -13
  374. package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
  375. package/lib/esm/test/standalone/ExportGraphics.test.js +26 -20
  376. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  377. package/lib/esm/test/standalone/GeometryChangeEvents.test.js +11 -15
  378. package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
  379. package/lib/esm/test/standalone/GeometryStream.test.js +212 -165
  380. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  381. package/lib/esm/test/standalone/HubMock.test.js +31 -25
  382. package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
  383. package/lib/esm/test/standalone/IModelLimits.test.js +11 -8
  384. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
  385. package/lib/esm/test/standalone/IModelWrite.test.d.ts +2 -2
  386. package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -1
  387. package/lib/esm/test/standalone/IModelWrite.test.js +184 -142
  388. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  389. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js +25 -22
  390. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
  391. package/lib/esm/test/standalone/IntegrityCheck.test.js +20 -18
  392. package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
  393. package/lib/esm/test/standalone/MergeConflict.test.d.ts +2 -2
  394. package/lib/esm/test/standalone/MergeConflict.test.d.ts.map +1 -1
  395. package/lib/esm/test/standalone/MergeConflict.test.js +49 -33
  396. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
  397. package/lib/esm/test/standalone/RenderMaterialElement.test.js +5 -5
  398. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  399. package/lib/esm/test/standalone/RenderTimeline.test.js +3 -2
  400. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
  401. package/lib/esm/test/standalone/SectionDrawing.test.js +7 -7
  402. package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
  403. package/lib/esm/test/standalone/ServerBasedLocks.test.js +21 -19
  404. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  405. package/lib/esm/test/standalone/Settings.test.js +7 -4
  406. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  407. package/lib/esm/test/standalone/SettingsSchemas.test.js +2 -1
  408. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  409. package/lib/esm/test/standalone/SnapshotDb.test.js +3 -1
  410. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  411. package/lib/esm/test/standalone/StandaloneDb.test.js +7 -6
  412. package/lib/esm/test/standalone/StandaloneDb.test.js.map +1 -1
  413. package/lib/esm/test/standalone/Texture.test.js +5 -4
  414. package/lib/esm/test/standalone/Texture.test.js.map +1 -1
  415. package/lib/esm/test/standalone/TileCache.test.d.ts.map +1 -1
  416. package/lib/esm/test/standalone/TileCache.test.js +5 -3
  417. package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
  418. package/lib/esm/test/standalone/TileTree.test.js +35 -31
  419. package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
  420. package/lib/esm/test/standalone/TxnManager.test.js +700 -653
  421. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  422. package/lib/esm/test/standalone/ViewDefinition.test.js +295 -229
  423. package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
  424. package/lib/esm/test/standalone/Workspace.test.js +25 -23
  425. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  426. package/package.json +12 -12
@@ -9,7 +9,7 @@ import * as fs from "fs";
9
9
  import { join } from "path";
10
10
  import * as touch from "touch";
11
11
  import { assert, BeEvent, BentleyStatus, ChangeSetStatus, DbChangeStage, DbConflictCause, DbConflictResolution, DbResult, Guid, Id64, IModelStatus, JsonUtils, Logger, LogLevel, LRUMap, OpenMode } from "@itwin/core-bentley";
12
- import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryRowFormat, SchemaState, ViewStoreError, ViewStoreRpc } from "@itwin/core-common";
12
+ import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EditTxnError, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryRowFormat, SchemaState, ViewStoreError, ViewStoreRpc } from "@itwin/core-common";
13
13
  import { Range2d, Range3d } from "@itwin/core-geometry";
14
14
  import { BackendLoggerCategory } from "./BackendLoggerCategory";
15
15
  import { BriefcaseManager } from "./BriefcaseManager";
@@ -35,6 +35,7 @@ import { SchemaSync } from "./SchemaSync";
35
35
  import { createServerBasedLocks } from "./internal/ServerBasedLocks";
36
36
  import { SqliteStatement, StatementCache } from "./SqliteStatement";
37
37
  import { TxnManager } from "./TxnManager";
38
+ import { EditTxn } from "./EditTxn";
38
39
  import { DrawingViewDefinition, SheetViewDefinition, ViewDefinition } from "./ViewDefinition";
39
40
  import { ViewStore } from "./ViewStore";
40
41
  import { SettingsPriority } from "./workspace/Settings";
@@ -44,7 +45,7 @@ import { SettingsImpl } from "./internal/workspace/SettingsImpl";
44
45
  import { IModelNative } from "./internal/NativePlatform";
45
46
  import { createNoOpLockControl } from "./internal/NoLocks";
46
47
  import { createIModelDbFonts } from "./internal/IModelDbFontsImpl";
47
- import { _cache, _close, _hubAccess, _instanceKeyCache, _nativeDb, _releaseAllLocks, _resetIModelDb } from "./internal/Symbols";
48
+ import { _activeTxn, _cache, _close, _hubAccess, _implicitTxn, _instanceKeyCache, _nativeDb, _releaseAllLocks, _resetIModelDb } from "./internal/Symbols";
48
49
  import { ECVersion, SchemaContext, SchemaJsonLocater } from "@itwin/ecschema-metadata";
49
50
  import { SchemaMap } from "./Schema";
50
51
  import { ElementLRUCache, InstanceKeyLRUCache } from "./internal/ElementLRUCache";
@@ -54,6 +55,38 @@ import { integrityCheckTypeMap, performQuickIntegrityCheck, performSpecificInteg
54
55
  import { ECSqlSyncReader } from "./ECSqlSyncReader";
55
56
  // spell:ignore fontid fontmap
56
57
  const loggerCategory = BackendLoggerCategory.IModelDb;
58
+ /**
59
+ * Internal write surface used to preserve legacy implicit-transaction mutators while callers migrate to explicit [[EditTxn]] scopes.
60
+ *
61
+ * Unlike an explicit [[EditTxn]], this transaction is always available for writable iModels and cannot be manually started or ended.
62
+ * When implicit-write enforcement is enabled, attempts to write through this transaction are logged or rejected.
63
+ */
64
+ class ImplicitWriteTxn extends EditTxn {
65
+ constructor(iModel) {
66
+ super(iModel, "implicit");
67
+ }
68
+ start() {
69
+ throw new Error("ImplicitWriteTxn cannot be started");
70
+ }
71
+ end(_mode = "save", _args) {
72
+ throw new Error("ImplicitWriteTxn cannot be ended");
73
+ }
74
+ verifyWriteable() {
75
+ const enforcement = EditTxn.implicitWriteEnforcement;
76
+ if (enforcement === "allow")
77
+ return;
78
+ try {
79
+ EditTxnError.throwError("implicit-txn-write-disallowed", "Implicit transaction write is disallowed. Use an explicit EditTxn instead", this.iModel.key);
80
+ }
81
+ catch (err) {
82
+ if (enforcement === "log") {
83
+ Logger.logError(loggerCategory, err);
84
+ return;
85
+ }
86
+ throw err;
87
+ }
88
+ }
89
+ }
57
90
  /** @internal */
58
91
  export var BriefcaseLocalValue;
59
92
  (function (BriefcaseLocalValue) {
@@ -139,6 +172,25 @@ export class IModelDb extends IModel {
139
172
  _locks = createNoOpLockControl();
140
173
  /** @internal */
141
174
  _codeService;
175
+ /**
176
+ * The always-available implicit transaction for this iModel.
177
+ *
178
+ * Legacy mutating APIs route through this transaction for backwards compatibility until they are fully migrated to explicit [[EditTxn]] usage.
179
+ * @internal
180
+ */
181
+ [_implicitTxn];
182
+ /** @internal */
183
+ [_activeTxn];
184
+ /** Returns the active [[EditTxn]] if one is current, otherwise the implicit transaction.
185
+ * Use this inside element and relationship callbacks that may be invoked either during an explicit transaction or
186
+ * during indirect change processing.
187
+ * @note This method is a temporary workaround until [[OnElementArg]] (and related callback arg types) are updated
188
+ * to carry the transaction directly in a future PR.
189
+ * @internal
190
+ */
191
+ getIndirectTxn() {
192
+ return this[_activeTxn] ?? this[_implicitTxn];
193
+ }
142
194
  /** @alpha */
143
195
  get codeService() { return this._codeService; }
144
196
  /** The [[LockControl]] that orchestrates [concurrent editing]($docs/learning/backend/ConcurrencyControl.md) of this iModel. */
@@ -227,17 +279,20 @@ export class IModelDb extends IModel {
227
279
  // Make closeIModel available so their code doesn't break.
228
280
  this[_nativeDb].closeIModel = () => {
229
281
  if (!this.isReadonly)
230
- this.saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
282
+ this[_nativeDb].saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
283
+ this[_activeTxn] = undefined;
231
284
  this[_nativeDb].closeFile();
232
285
  };
233
286
  this[_nativeDb].setIModelDb(this);
234
287
  this[_resetIModelDb]();
235
288
  IModelDb._openDbs.set(this._fileKey, this);
289
+ this[_implicitTxn] = new ImplicitWriteTxn(this);
290
+ this[_activeTxn] = undefined;
236
291
  if (undefined === IModelDb._shutdownListener) { // the first time we create an IModelDb, add a listener to close any orphan files at shutdown.
237
292
  IModelDb._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => {
238
293
  IModelDb._openDbs.forEach((db) => {
239
294
  try {
240
- db.abandonChanges();
295
+ db[_nativeDb].abandonChanges();
241
296
  db.close();
242
297
  }
243
298
  catch { }
@@ -267,8 +322,8 @@ export class IModelDb extends IModel {
267
322
  }
268
323
  /**
269
324
  * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.
270
- * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'
271
- * @param alias identifer that was used in the call to [[attachDb]]
325
+ * @note There are some reserved table names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'
326
+ * @param alias identifier that was used in the call to [[attachDb]]
272
327
  *
273
328
  * @example [[include:IModelDb_attachDb.code]]
274
329
  *
@@ -286,7 +341,13 @@ export class IModelDb extends IModel {
286
341
  close(options) {
287
342
  if (!this.isOpen)
288
343
  return; // don't continue if already closed
344
+ // Give the active txn a chance to save or abandon before beforeClose() cleanup runs.
345
+ // StandaloneDb.beforeClose() saves any unsaved changes, so onClose() must run first so
346
+ // subclasses that override onClose() to abandon changes can do so before that save.
347
+ if (!this.isReadonly)
348
+ (this[_activeTxn] ?? this[_implicitTxn]).onClose();
289
349
  this.beforeClose();
350
+ this[_activeTxn] = undefined;
290
351
  if (options?.optimize)
291
352
  this.optimize();
292
353
  IModelDb._openDbs.delete(this._fileKey);
@@ -295,10 +356,20 @@ export class IModelDb extends IModel {
295
356
  this._locks = undefined;
296
357
  this._codeService?.close();
297
358
  this._codeService = undefined;
298
- if (!this.isReadonly)
299
- this.saveChanges();
300
359
  this[_nativeDb].closeFile();
301
360
  }
361
+ saveSchemaChanges(args) {
362
+ if (!this[_nativeDb].hasUnsavedChanges())
363
+ return;
364
+ const saveArgs = typeof args === "string" ? { description: args } : args;
365
+ saveArgs === undefined ? this[_nativeDb].saveChanges() : this[_nativeDb].saveChanges(JSON.stringify(saveArgs));
366
+ }
367
+ abandonSchemaChanges() {
368
+ if (!this[_nativeDb].hasUnsavedChanges())
369
+ return;
370
+ this.clearCaches({ instanceCachesOnly: true });
371
+ this[_nativeDb].abandonChanges();
372
+ }
302
373
  /** Optimize this iModel by vacuuming, and analyzing.
303
374
  *
304
375
  * @note This operation requires exclusive access to the database and may take some time on large files.
@@ -735,10 +806,10 @@ export class IModelDb extends IModel {
735
806
  * ``` ts
736
807
  * [[include:IModelDb.updateProjectExtents]]
737
808
  * ```
809
+ * @deprecated Use EditTxn.updateProjectExtents instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
738
810
  */
739
811
  updateProjectExtents(newExtents) {
740
- this.projectExtents = newExtents;
741
- this.updateIModelProps();
812
+ this[_implicitTxn].updateProjectExtents(newExtents);
742
813
  }
743
814
  /** Compute an appropriate project extents for this iModel based on the ranges of all spatial elements.
744
815
  * Typically, the result is simply the union of the ranges of all spatial elements. However, the algorithm also detects "outlier elements",
@@ -758,45 +829,26 @@ export class IModelDb extends IModel {
758
829
  outliers: result.outliers,
759
830
  };
760
831
  }
761
- /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel. */
832
+ /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel.
833
+ * @deprecated Use EditTxn.updateEcefLocation instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
834
+ */
762
835
  updateEcefLocation(ecef) {
763
- this.setEcefLocation(ecef);
764
- this.updateIModelProps();
836
+ this[_implicitTxn].updateEcefLocation(ecef);
765
837
  }
766
- /** Update the IModelProps of this iModel in the database. */
838
+ /** Update the IModelProps of this iModel in the database.
839
+ * @deprecated Use EditTxn.updateIModelProps instead, within an explicit EditTxn scope (or via withEditTxn).
840
+ */
767
841
  updateIModelProps() {
768
- this[_nativeDb].updateIModelProps(this.toJSON());
842
+ this[_implicitTxn].updateIModelProps();
769
843
  }
770
- /** Commit unsaved changes in memory as a Txn to this iModelDb.
771
- * @internal
772
- * @param descriptionOrArgs Optionally provide description or [[SaveChangesArgs]] args for the changes.
773
- * @throws [[IModelError]] if there is a problem saving changes or if there are pending, un-processed lock or code requests.
774
- * @note This will not push changes to the iModelHub.
775
- * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync}, {TxnManager.withIndirectTxnMode} or {RebaseHandler.recompute}.
776
- * @see [[IModelDb.pushChanges]] to push changes to the iModelHub.
777
- */
778
844
  saveChanges(descriptionOrArgs) {
779
- if (this.openMode === OpenMode.Readonly)
780
- throw new IModelError(IModelStatus.ReadOnly, "IModelDb was opened read-only");
781
- if (this.isBriefcaseDb()) {
782
- if (this.txns.isIndirectChanges) {
783
- throw new IModelError(IModelStatus.BadRequest, "Cannot save changes while in an indirect change scope");
784
- }
785
- }
786
- const args = typeof descriptionOrArgs === "string" ? { description: descriptionOrArgs } : descriptionOrArgs;
787
- const stat = this[_nativeDb].saveChanges(args ? JSON.stringify(args) : undefined);
788
- if (DbResult.BE_SQLITE_ERROR_PropagateChangesFailed === stat)
789
- throw new IModelError(stat, `Could not save changes due to propagation failure.`);
790
- if (DbResult.BE_SQLITE_OK !== stat)
791
- throw new IModelError(stat, `Could not save changes (${args?.description})`);
845
+ this[_implicitTxn].saveChanges(descriptionOrArgs);
792
846
  }
793
847
  /** Abandon changes in memory that have not been saved as a Txn to this iModelDb.
794
- * @note This will not delete Txns that have already been saved, even if they have not yet been pushed.
848
+ * @deprecated Use EditTxn.abandonChanges instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
795
849
  */
796
850
  abandonChanges() {
797
- // Clears instanceKey caches only, instead of all of the backend caches, since the changes are not saved yet
798
- this.clearCaches({ instanceCachesOnly: true });
799
- this[_nativeDb].abandonChanges();
851
+ this[_implicitTxn].abandonChanges();
800
852
  }
801
853
  /**
802
854
  * Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
@@ -808,7 +860,7 @@ export class IModelDb extends IModel {
808
860
  */
809
861
  performCheckpoint() {
810
862
  if (!this.isReadonly) {
811
- this.saveChanges();
863
+ this[_nativeDb].saveChanges();
812
864
  this.clearCaches();
813
865
  this[_nativeDb].concurrentQueryShutdown();
814
866
  this[_nativeDb].performCheckpoint();
@@ -847,7 +899,7 @@ export class IModelDb extends IModel {
847
899
  *
848
900
  * If the removal was successful, the database is automatically saved to disk.
849
901
  * @param schemaNames Array of schema names to drop
850
- * @throws [IModelError]($common) if the database if the operation failed.
902
+ * @throws [[IModelError]] if the operation fails.
851
903
  * @alpha
852
904
  */
853
905
  async dropSchemas(schemaNames) {
@@ -861,11 +913,11 @@ export class IModelDb extends IModel {
861
913
  await this.acquireSchemaLock();
862
914
  try {
863
915
  this[_nativeDb].dropSchemas(schemaNames);
864
- this.saveChanges(`dropped unused schemas`);
916
+ this.saveSchemaChanges("dropped unused schemas");
865
917
  }
866
918
  catch (error) {
867
919
  Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);
868
- this.abandonChanges();
920
+ this.abandonSchemaChanges();
869
921
  throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);
870
922
  }
871
923
  finally {
@@ -890,8 +942,9 @@ export class IModelDb extends IModel {
890
942
  transformStrategy: DataTransformationStrategy.None,
891
943
  };
892
944
  try {
893
- if (callback?.preSchemaImportCallback) {
894
- const callbackResult = await callback.preSchemaImportCallback(context);
945
+ const preSchemaImportCallback = callback?.preSchemaImportCallback;
946
+ if (preSchemaImportCallback) {
947
+ const callbackResult = await preSchemaImportCallback(context);
895
948
  callbackResources.transformStrategy = callbackResult.transformStrategy;
896
949
  if (callbackResult.transformStrategy === DataTransformationStrategy.Snapshot) {
897
950
  // Create temporary snapshot file
@@ -904,13 +957,12 @@ export class IModelDb extends IModel {
904
957
  }
905
958
  callbackResources.cachedData = callbackResult.cachedData;
906
959
  }
907
- if (this.isBriefcaseDb() && IModelHost.useSemanticRebase) {
908
- this.saveChanges("Save changes from schema import pre callback");
909
- }
960
+ if (this.isBriefcaseDb() && IModelHost.useSemanticRebase)
961
+ this.saveSchemaChanges("Save changes from schema import pre callback");
910
962
  }
911
963
  }
912
964
  catch (callbackError) {
913
- this.abandonChanges();
965
+ this.abandonSchemaChanges();
914
966
  this.cleanupSnapshot(callbackResources);
915
967
  throw new IModelError(callbackError.errorNumber ?? IModelStatus.BadRequest, `Failed to execute preSchemaImportCallback: ${callbackError.message}`);
916
968
  }
@@ -924,14 +976,14 @@ export class IModelDb extends IModel {
924
976
  throw new IModelError(IModelStatus.BadRequest, "InMemory transform strategy requires cachedData to be provided.");
925
977
  }
926
978
  try {
927
- if (callback?.postSchemaImportCallback)
928
- await callback.postSchemaImportCallback(context);
929
- if (this.isBriefcaseDb() && IModelHost.useSemanticRebase) {
930
- this.saveChanges("Save changes from schema import post callback");
931
- }
979
+ const postSchemaImportCallback = callback?.postSchemaImportCallback;
980
+ if (postSchemaImportCallback)
981
+ await postSchemaImportCallback(context);
982
+ if (this.isBriefcaseDb() && IModelHost.useSemanticRebase)
983
+ this.saveSchemaChanges("Save changes from schema import post callback");
932
984
  }
933
985
  catch (callbackError) {
934
- this.abandonChanges();
986
+ this.abandonSchemaChanges();
935
987
  throw new IModelError(callbackError.errorNumber ?? IModelStatus.BadRequest, `Failed to execute postSchemaImportCallback: ${callbackError.message}`);
936
988
  }
937
989
  finally {
@@ -960,15 +1012,15 @@ export class IModelDb extends IModel {
960
1012
  }
961
1013
  }
962
1014
  if (options?.channelUpgrade) {
1015
+ const channelUpgrade = options.channelUpgrade;
963
1016
  try {
964
- await this.channels.upgradeChannel(options.channelUpgrade, this, options.data);
1017
+ await this.channels.upgradeChannel(channelUpgrade, this, options.data);
965
1018
  // If semantic rebase is enabled and channel upgrade made changes, save them
966
- if (this.isBriefcaseDb() && IModelHost.useSemanticRebase) {
967
- this.saveChanges();
968
- }
1019
+ if (this.isBriefcaseDb() && IModelHost.useSemanticRebase)
1020
+ this.saveSchemaChanges();
969
1021
  }
970
1022
  catch (error) {
971
- this.abandonChanges();
1023
+ this.abandonSchemaChanges();
972
1024
  throw error;
973
1025
  }
974
1026
  }
@@ -979,13 +1031,13 @@ export class IModelDb extends IModel {
979
1031
  if (this[_nativeDb].schemaSyncEnabled()) {
980
1032
  await SchemaSync.withLockedAccess(this, { openMode: OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
981
1033
  const schemaSyncDbUri = syncAccess.getUri();
982
- this.saveChanges();
1034
+ this.saveSchemaChanges();
983
1035
  try {
984
1036
  nativeImportOp(schemas, { schemaLockHeld: false, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
985
1037
  }
986
1038
  catch (outerErr) {
987
1039
  if (DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
988
- this.abandonChanges();
1040
+ this.abandonSchemaChanges();
989
1041
  if (this[_nativeDb].getITwinId() !== Guid.empty)
990
1042
  await this.acquireSchemaLock();
991
1043
  try {
@@ -1038,13 +1090,16 @@ export class IModelDb extends IModel {
1038
1090
  if (options?.schemaImportCallbacks?.postSchemaImportCallback)
1039
1091
  await this.postSchemaImportCallback(options.schemaImportCallbacks, { iModel: this, resources: preSchemaImportCallbackResult, data: options.data });
1040
1092
  }
1041
- /** Import an ECSchema. On success, the schema definition is stored in the iModel.
1093
+ /** Import ECSchema(s). On success, the schema definition is stored in the iModel.
1042
1094
  * This method is asynchronous (must be awaited) because, in the case where this IModelDb is a briefcase, this method first obtains the schema lock from the iModel server.
1043
1095
  * You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
1044
- * @param schemaFileName array of Full paths to ECSchema.xml files to be imported.
1096
+ * @param schemaFileNames Files containing serialized ECSchemas.
1045
1097
  * @param {SchemaImportOptions} options - options during schema import.
1046
1098
  * @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
1047
1099
  * @note Changes are saved if importSchemas is successful and abandoned if not successful.
1100
+ * @note To turn on native logging, use NativeLoggerCategory and a console appender.
1101
+ * - For metadata differences between existing and imported schemas, turn on "ECDb" category.
1102
+ * - For import details, turn on "SchemaImport" category.
1048
1103
  * - You can use NativeLoggerCategory to turn on the native logs. You can also control [what exactly is logged by the loggers](https://www.itwinjs.org/learning/common/logging/#controlling-what-is-logged).
1049
1104
  * - See [Schema Versioning]($docs/bis/guide/schema-evolution/schema-versioning-and-generations.md) for more information on acceptable changes to schemas.
1050
1105
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {RebaseHandler.recompute}.
@@ -1206,7 +1261,7 @@ export class IModelDb extends IModel {
1206
1261
  return this._jsClassMap;
1207
1262
  }
1208
1263
  /**
1209
- * Allows locally registering a schema for this imodel, in constrast to [Schemas.registerSchema] which is a global operation
1264
+ * Allows locally registering a schema for this imodel, in contrast to [Schemas.registerSchema] which is a global operation
1210
1265
  */
1211
1266
  get schemaMap() {
1212
1267
  if (this._schemaMap === undefined)
@@ -1518,26 +1573,18 @@ export class IModelDb extends IModel {
1518
1573
  * @param prop the FilePropertyProps that describes the new property
1519
1574
  * @param value either a string or a blob to save as the file property
1520
1575
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {TxnManager.withIndirectTxnMode}.
1576
+ * @deprecated Use EditTxn.saveFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1521
1577
  */
1522
1578
  saveFileProperty(prop, strValue, blobVal) {
1523
- if (this.isBriefcaseDb()) {
1524
- if (this.txns.isIndirectChanges) {
1525
- throw new IModelError(IModelStatus.BadRequest, "Cannot save file property while in an indirect change scope");
1526
- }
1527
- }
1528
- this[_nativeDb].saveFileProperty(prop, strValue, blobVal);
1579
+ this[_implicitTxn].saveFileProperty(prop, strValue, blobVal);
1529
1580
  }
1530
1581
  /** delete a "file property" from this iModel
1531
1582
  * @param prop the FilePropertyProps that describes the property
1532
1583
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {TxnManager.withIndirectTxnMode}.
1584
+ * @deprecated Use EditTxn.deleteFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1533
1585
  */
1534
1586
  deleteFileProperty(prop) {
1535
- if (this.isBriefcaseDb()) {
1536
- if (this.txns.isIndirectChanges) {
1537
- throw new IModelError(IModelStatus.BadRequest, "Cannot delete file property while in an indirect change scope");
1538
- }
1539
- }
1540
- this[_nativeDb].saveFileProperty(prop, undefined, undefined);
1587
+ this[_implicitTxn].deleteFileProperty(prop);
1541
1588
  }
1542
1589
  /** Query for the next available major id for a "file property" from this iModel.
1543
1590
  * @param prop the FilePropertyProps that describes the property
@@ -1741,28 +1788,17 @@ export class IModelDb extends IModel {
1741
1788
  * @param name The name for the SettingDictionary. If a dictionary by that name already exists in the iModel, its value is replaced.
1742
1789
  * @param dict The SettingDictionary object to stringify and save.
1743
1790
  * @note All saved `SettingDictionary`s are loaded into [[workspace.settings]] every time an iModel is opened.
1744
- * @beta
1791
+ * @beta @deprecated Use EditTxn.saveSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1745
1792
  */
1746
1793
  saveSettingDictionary(name, dict) {
1747
- this.withSqliteStatement("REPLACE INTO be_Prop(id,SubId,TxnMode,Namespace,Name,strData) VALUES(0,0,0,?,?,?)", (stmt) => {
1748
- stmt.bindString(1, IModelDb._settingPropNamespace);
1749
- stmt.bindString(2, name);
1750
- stmt.bindString(3, JSON.stringify(dict));
1751
- stmt.stepForWrite();
1752
- });
1753
- this.saveChanges("add settings");
1794
+ this[_implicitTxn].saveSettingDictionary(name, dict);
1754
1795
  }
1755
1796
  /** Delete a SettingDictionary, previously added with [[saveSettingDictionary]], from this iModel.
1756
1797
  * @param name The name of the dictionary to delete.
1757
- * @beta
1798
+ * @beta @deprecated Use EditTxn.deleteSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1758
1799
  */
1759
1800
  deleteSettingDictionary(name) {
1760
- this.withSqliteStatement("DELETE FROM be_Prop WHERE Namespace=? AND Name=?", (stmt) => {
1761
- stmt.bindString(1, IModelDb._settingPropNamespace);
1762
- stmt.bindString(2, name);
1763
- stmt.stepForWrite();
1764
- });
1765
- this.saveChanges("delete settings");
1801
+ this[_implicitTxn].deleteSettingDictionary(name);
1766
1802
  }
1767
1803
  /** Load all setting dictionaries in this iModel into `this.workspace.settings` */
1768
1804
  loadIModelSettings() {
@@ -2037,33 +2073,19 @@ function processSchemaWriteStatus(status) {
2037
2073
  /** Insert a new model.
2038
2074
  * @param props The data for the new model.
2039
2075
  * @returns The newly inserted model's Id.
2040
- * @throws [[IModelError]] if unable to insert the model.
2076
+ * @throws [[IModelError]] if insertion fails.
2077
+ * @deprecated Use EditTxn.insertModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2041
2078
  */
2042
2079
  insertModel(props) {
2043
- try {
2044
- return props.id = this._iModel[_nativeDb].insertModel(props);
2045
- }
2046
- catch (err) {
2047
- const error = new IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
2048
- error.cause = err;
2049
- throw error;
2050
- }
2080
+ return this._iModel[_implicitTxn].insertModel(props);
2051
2081
  }
2052
2082
  /** Update an existing model.
2053
2083
  * @param props the properties of the model to change
2054
- * @throws [[IModelError]] if unable to update the model.
2084
+ * @throws [[IModelError]] if update fails.
2085
+ * @deprecated Use EditTxn.updateModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2055
2086
  */
2056
2087
  updateModel(props) {
2057
- try {
2058
- if (props.id)
2059
- this[_cache].delete(props.id);
2060
- this._iModel[_nativeDb].updateModel(props);
2061
- }
2062
- catch (err) {
2063
- const error = new IModelError(err.errorNumber, `Error updating model [${err.message}], id: ${props.id}`);
2064
- error.cause = err;
2065
- throw error;
2066
- }
2088
+ this._iModel[_implicitTxn].updateModel(props);
2067
2089
  }
2068
2090
  /** Mark the geometry of [[GeometricModel]] as having changed, by recording an indirect change to its GeometryGuid property.
2069
2091
  * Typically the GeometryGuid changes automatically when [[GeometricElement]]s within the model are modified, but
@@ -2071,32 +2093,20 @@ function processSchemaWriteStatus(status) {
2071
2093
  * [[GeometricElement]]s that reference those definition elements in their geometry streams.
2072
2094
  * Cached [Tile]($frontend)s are only invalidated after the geometry guid of the model changes.
2073
2095
  * @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.
2074
- * @throws IModelError if unable to update the geometry guid.
2096
+ * @throws [[IModelError]] if the update fails.
2097
+ * @deprecated Use EditTxn.updateGeometryGuid instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2075
2098
  * @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
2076
2099
  */
2077
2100
  updateGeometryGuid(modelId) {
2078
- this._iModel.models[_cache].delete(modelId);
2079
- const error = this._iModel[_nativeDb].updateModelGeometryGuid(modelId);
2080
- if (error !== IModelStatus.Success)
2081
- throw new IModelError(error, `Error updating geometry guid for model ${modelId}`);
2101
+ this._iModel[_implicitTxn].updateGeometryGuid(modelId);
2082
2102
  }
2083
2103
  /** Delete one or more existing models.
2084
2104
  * @param ids The Ids of the models to be deleted
2085
- * @throws [[IModelError]]
2105
+ * @throws [[IModelError]] if deletion fails.
2106
+ * @deprecated Use EditTxn.deleteModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2086
2107
  */
2087
2108
  deleteModel(ids) {
2088
- Id64.toIdSet(ids).forEach((id) => {
2089
- try {
2090
- this[_cache].delete(id);
2091
- this[_instanceKeyCache].deleteById(id);
2092
- this._iModel[_nativeDb].deleteModel(id);
2093
- }
2094
- catch (err) {
2095
- const error = new IModelError(err.errorNumber, `Error deleting model [${err.message}], id: ${id}`);
2096
- error.cause = err;
2097
- throw error;
2098
- }
2099
- });
2109
+ this._iModel[_implicitTxn].deleteModel(ids);
2100
2110
  }
2101
2111
  /** For each specified [[GeometricModel]], attempts to obtain the union of the volumes of all geometric elements within that model.
2102
2112
  * @param ids The Id or Ids of the [[GeometricModel]]s for which to obtain the extents.
@@ -2314,26 +2324,15 @@ function processSchemaWriteStatus(status) {
2314
2324
  /** Insert a new element into the iModel.
2315
2325
  * @param elProps The properties of the new element.
2316
2326
  * @returns The newly inserted element's Id.
2317
- * @throws [[ITwinError]] if unable to insert the element.
2327
+ * @throws [[ITwinError]] if insertion fails.
2318
2328
  * @note For convenience, the value of `elProps.id` is updated to reflect the resultant element's id.
2319
2329
  * However when `elProps.federationGuid` is not present or undefined, a new Guid will be generated and stored on the resultant element. But
2320
2330
  * the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
2321
2331
  * if you intend to continue working with it. That will ensure its values reflect the persistent state.
2332
+ * @deprecated Use EditTxn.insertElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2322
2333
  */
2323
2334
  insertElement(elProps, options) {
2324
- try {
2325
- this[_cache].delete({
2326
- id: elProps.id,
2327
- federationGuid: elProps.federationGuid,
2328
- code: elProps.code,
2329
- });
2330
- return elProps.id = this._iModel[_nativeDb].insertElement(elProps, options);
2331
- }
2332
- catch (err) {
2333
- err.message = `Error inserting element [${err.message}]`;
2334
- err.metadata = { elProps };
2335
- throw err;
2336
- }
2335
+ return this._iModel[_implicitTxn].insertElement(elProps, options);
2337
2336
  }
2338
2337
  /**
2339
2338
  * Update some properties of an existing element.
@@ -2344,126 +2343,33 @@ function processSchemaWriteStatus(status) {
2344
2343
  * @param elProps the properties of the element to update.
2345
2344
  * @note The values of `classFullName` and `model` *may not be changed* by this method. Further, it will permute the `elProps` object by adding or
2346
2345
  * overwriting their values to the correct values.
2347
- * @throws [[ITwinError]] if unable to update the element.
2346
+ * @throws [[ITwinError]] if update fails.
2347
+ * @deprecated Use EditTxn.updateElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2348
2348
  */
2349
2349
  updateElement(elProps) {
2350
- try {
2351
- if (elProps.id) {
2352
- this[_instanceKeyCache].deleteById(elProps.id);
2353
- }
2354
- else {
2355
- this[_instanceKeyCache].delete({
2356
- federationGuid: elProps.federationGuid,
2357
- code: elProps.code,
2358
- });
2359
- }
2360
- this[_cache].delete({
2361
- id: elProps.id,
2362
- federationGuid: elProps.federationGuid,
2363
- code: elProps.code,
2364
- });
2365
- this._iModel[_nativeDb].updateElement(elProps);
2366
- }
2367
- catch (err) {
2368
- err.message = `Error updating element [${err.message}], id: ${elProps.id}`;
2369
- err.metadata = { elProps };
2370
- throw err;
2371
- }
2350
+ this._iModel[_implicitTxn].updateElement(elProps);
2372
2351
  }
2373
2352
  /** Delete one or more elements from this iModel.
2374
2353
  * @param ids The set of Ids of the element(s) to be deleted
2375
2354
  * @throws [[ITwinError]]
2376
2355
  * @see deleteDefinitionElements
2356
+ * @deprecated Use EditTxn.deleteElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2377
2357
  */
2378
2358
  deleteElement(ids) {
2379
- const iModel = this._iModel;
2380
- Id64.toIdSet(ids).forEach((id) => {
2381
- try {
2382
- this[_cache].delete({ id });
2383
- this[_instanceKeyCache].deleteById(id);
2384
- iModel[_nativeDb].deleteElement(id);
2385
- }
2386
- catch (err) {
2387
- err.message = `Error deleting element [${err.message}], id: ${id}`;
2388
- err.metadata = { elementId: id };
2389
- throw err;
2390
- }
2391
- });
2359
+ this._iModel[_implicitTxn].deleteElement(ids);
2392
2360
  }
2393
2361
  /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
2394
2362
  * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
2395
2363
  * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
2396
2364
  * This method performs those expensive checks and then calls *delete* if not referenced.
2397
- * @param ids The Ids of the DefinitionElements to attempt to delete. To prevent multiple passes over the same GeometricElements, it is best to pass in the entire array of
2365
+ * @param definitionElementIds The Ids of the DefinitionElements to attempt to delete. To prevent multiple passes over the same GeometricElements, it is best to pass in the entire array of
2398
2366
  * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
2399
2367
  * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
2400
2368
  * @see deleteElement
2401
- * @beta
2369
+ * @deprecated Use EditTxn.deleteDefinitionElements instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2402
2370
  */
2403
2371
  deleteDefinitionElements(definitionElementIds) {
2404
- const usageInfo = this._iModel[_nativeDb].queryDefinitionElementUsage(definitionElementIds);
2405
- if (!usageInfo) {
2406
- throw new IModelError(IModelStatus.BadRequest, "Error querying for DefinitionElement usage");
2407
- }
2408
- const usedIdSet = usageInfo.usedIds ? Id64.toIdSet(usageInfo.usedIds) : new Set();
2409
- const deleteIfUnused = (ids, used) => {
2410
- if (ids) {
2411
- ids.forEach((id) => {
2412
- if (!used.has(id))
2413
- this._iModel.elements.deleteElement(id);
2414
- });
2415
- }
2416
- };
2417
- try {
2418
- this._iModel[_nativeDb].beginPurgeOperation();
2419
- deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);
2420
- deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);
2421
- deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);
2422
- deleteIfUnused(usageInfo.geometryPartIds, usedIdSet);
2423
- deleteIfUnused(usageInfo.lineStyleIds, usedIdSet);
2424
- deleteIfUnused(usageInfo.renderMaterialIds, usedIdSet);
2425
- deleteIfUnused(usageInfo.subCategoryIds, usedIdSet);
2426
- deleteIfUnused(usageInfo.textureIds, usedIdSet);
2427
- deleteIfUnused(usageInfo.displayStyleIds, usedIdSet);
2428
- deleteIfUnused(usageInfo.categorySelectorIds, usedIdSet);
2429
- deleteIfUnused(usageInfo.modelSelectorIds, usedIdSet);
2430
- if (usageInfo.otherDefinitionElementIds) {
2431
- this._iModel.elements.deleteElement(usageInfo.otherDefinitionElementIds);
2432
- }
2433
- }
2434
- finally {
2435
- this._iModel[_nativeDb].endPurgeOperation();
2436
- }
2437
- if (usageInfo.viewDefinitionIds) {
2438
- // take another pass in case a deleted ViewDefinition was the only usage of these view-related DefinitionElements
2439
- let viewRelatedIds = [];
2440
- if (usageInfo.displayStyleIds)
2441
- viewRelatedIds = viewRelatedIds.concat(usageInfo.displayStyleIds.filter((id) => usedIdSet.has(id)));
2442
- if (usageInfo.categorySelectorIds)
2443
- viewRelatedIds = viewRelatedIds.concat(usageInfo.categorySelectorIds.filter((id) => usedIdSet.has(id)));
2444
- if (usageInfo.modelSelectorIds)
2445
- viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));
2446
- if (viewRelatedIds.length > 0) {
2447
- const viewRelatedUsageInfo = this._iModel[_nativeDb].queryDefinitionElementUsage(viewRelatedIds);
2448
- if (viewRelatedUsageInfo) {
2449
- const usedViewRelatedIdSet = viewRelatedUsageInfo.usedIds ? Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set();
2450
- try {
2451
- this._iModel[_nativeDb].beginPurgeOperation();
2452
- deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);
2453
- deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);
2454
- deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);
2455
- }
2456
- finally {
2457
- this._iModel[_nativeDb].endPurgeOperation();
2458
- }
2459
- viewRelatedIds.forEach((id) => {
2460
- if (!usedViewRelatedIdSet.has(id))
2461
- usedIdSet.delete(id);
2462
- });
2463
- }
2464
- }
2465
- }
2466
- return usedIdSet;
2372
+ return this._iModel[_implicitTxn].deleteDefinitionElements(definitionElementIds);
2467
2373
  }
2468
2374
  /** Query for the child elements of the specified element.
2469
2375
  * @returns Returns an array of child element identifiers.
@@ -2654,47 +2560,26 @@ function processSchemaWriteStatus(status) {
2654
2560
  * @returns the id of the newly inserted aspect.
2655
2561
  * @note Aspect Ids may collide with element Ids, so don't put both in a container like Set or Map
2656
2562
  * use [EntityReference]($common) for that instead.
2563
+ * @deprecated Use EditTxn.insertAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2657
2564
  */
2658
2565
  insertAspect(aspectProps) {
2659
- try {
2660
- return this._iModel[_nativeDb].insertElementAspect(aspectProps);
2661
- }
2662
- catch (err) {
2663
- const error = new IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`, aspectProps);
2664
- error.cause = err;
2665
- throw error;
2666
- }
2566
+ return this._iModel[_implicitTxn].insertAspect(aspectProps);
2667
2567
  }
2668
2568
  /** Update an exist ElementAspect within the iModel.
2669
2569
  * @param aspectProps The properties to use to update the ElementAspect.
2670
2570
  * @throws [[IModelError]] if unable to update the ElementAspect.
2571
+ * @deprecated Use EditTxn.updateAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2671
2572
  */
2672
2573
  updateAspect(aspectProps) {
2673
- try {
2674
- this._iModel[_nativeDb].updateElementAspect(aspectProps);
2675
- }
2676
- catch (err) {
2677
- const error = new IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`, aspectProps);
2678
- error.cause = err;
2679
- throw error;
2680
- }
2574
+ this._iModel[_implicitTxn].updateAspect(aspectProps);
2681
2575
  }
2682
2576
  /** Delete one or more ElementAspects from this iModel.
2683
2577
  * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
2684
2578
  * @throws [[IModelError]] if unable to delete the ElementAspect.
2579
+ * @deprecated Use EditTxn.deleteAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2685
2580
  */
2686
2581
  deleteAspect(aspectInstanceIds) {
2687
- const iModel = this._iModel;
2688
- Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {
2689
- try {
2690
- iModel[_nativeDb].deleteElementAspect(aspectInstanceId);
2691
- }
2692
- catch (err) {
2693
- const error = new IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
2694
- error.cause = err;
2695
- throw error;
2696
- }
2697
- });
2582
+ this._iModel[_implicitTxn].deleteAspect(aspectInstanceIds);
2698
2583
  }
2699
2584
  }
2700
2585
  IModelDb.Elements = Elements;
@@ -2737,11 +2622,11 @@ function processSchemaWriteStatus(status) {
2737
2622
  this._viewStore.container.accessToken = accessToken;
2738
2623
  return this._viewStore;
2739
2624
  }
2740
- /** @beta */
2625
+ /**
2626
+ * @beta @deprecated Use EditTxn.saveDefaultViewStore instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2627
+ */
2741
2628
  saveDefaultViewStore(arg) {
2742
- const props = { baseUri: arg.baseUri, containerId: arg.containerId, storageType: arg.storageType }; // sanitize to only known properties
2743
- this._iModel.saveFileProperty(Views.viewStoreProperty, JSON.stringify(props));
2744
- this._iModel.saveChanges("update default ViewStore");
2629
+ this._iModel[_implicitTxn].saveDefaultViewStore(arg);
2745
2630
  }
2746
2631
  /** Query for the array of ViewDefinitionProps of the specified class and matching the specified IsPrivate setting.
2747
2632
  * @param className Query for view definitions of this class.
@@ -2884,7 +2769,7 @@ function processSchemaWriteStatus(status) {
2884
2769
  blob32[0] = Id64.getLowerUint32(viewId);
2885
2770
  blob32[1] = Id64.getUpperUint32(viewId);
2886
2771
  const blob8 = new Uint8Array(blob32.buffer);
2887
- this._iModel.saveFileProperty(spec, undefined, blob8);
2772
+ this._iModel[_implicitTxn].saveFileProperty(spec, undefined, blob8);
2888
2773
  }
2889
2774
  }
2890
2775
  IModelDb.Views = Views;
@@ -3088,7 +2973,7 @@ export class BriefcaseDb extends IModelDb {
3088
2973
  executeUpgrade();
3089
2974
  await withBriefcaseDb(briefcase, async (db) => {
3090
2975
  db[_nativeDb].schemaSyncPush(schemaSyncDbUri);
3091
- db.saveChanges();
2976
+ db[_nativeDb].saveChanges();
3092
2977
  });
3093
2978
  syncAccess.synchronizeWithCloud();
3094
2979
  });
@@ -3453,7 +3338,7 @@ export class BriefcaseDb extends IModelDb {
3453
3338
  }
3454
3339
  try {
3455
3340
  await BriefcaseManager.revertTimelineChanges(this, arg);
3456
- this.saveChanges("Revert changes");
3341
+ this[_nativeDb].saveChanges("Revert changes");
3457
3342
  if (!arg.description) {
3458
3343
  arg.description = `Reverted changes from ${this.changeset.index} to ${arg.toIndex}${arg.skipSchemaChanges ? " (schema changes skipped)" : ""}`;
3459
3344
  }
@@ -3476,7 +3361,7 @@ export class BriefcaseDb extends IModelDb {
3476
3361
  }
3477
3362
  }
3478
3363
  finally {
3479
- this.abandonChanges();
3364
+ this[_nativeDb].abandonChanges();
3480
3365
  }
3481
3366
  }
3482
3367
  /**
@@ -3506,7 +3391,7 @@ export class BriefcaseDb extends IModelDb {
3506
3391
  }
3507
3392
  close(options) {
3508
3393
  if (this.isBriefcase && this.isOpen && !this.isReadonly && this.txns.rebaser.inProgress()) {
3509
- this.abandonChanges();
3394
+ this[_nativeDb].abandonChanges();
3510
3395
  }
3511
3396
  super.close(options);
3512
3397
  this.onClosed.raiseEvent();
@@ -3723,7 +3608,7 @@ export class SnapshotDb extends IModelDb {
3723
3608
  throw new IModelError(IModelStatus.SQLiteError, "Error creating class views");
3724
3609
  }
3725
3610
  else {
3726
- this.saveChanges();
3611
+ this[_nativeDb].saveChanges();
3727
3612
  }
3728
3613
  }
3729
3614
  }
@@ -3753,15 +3638,16 @@ export class StandaloneDb extends BriefcaseDb {
3753
3638
  }
3754
3639
  /**
3755
3640
  * @internal
3756
- * Called during close of the iModel. It will delete any pending txns, analyze and vacuum the iModel.
3641
+ * Called during close of the StandaloneDb. It will delete any pending txns.
3757
3642
  */
3758
3643
  beforeClose() {
3759
3644
  super.beforeClose();
3760
- if (!this.isReadonly && this.txns.hasLocalChanges) {
3761
- this.saveChanges();
3762
- this.txns.deleteAllTxns();
3763
- this.saveChanges();
3764
- }
3645
+ if (this.isReadonly || !this.txns.hasLocalChanges)
3646
+ return;
3647
+ const nativeDb = this[_nativeDb];
3648
+ nativeDb.saveChanges();
3649
+ nativeDb.deleteAllTxns();
3650
+ nativeDb.saveChanges();
3765
3651
  }
3766
3652
  static tryFindByKey(key) {
3767
3653
  const db = super.tryFindByKey(key);
@@ -3817,7 +3703,7 @@ export class StandaloneDb extends BriefcaseDb {
3817
3703
  if (BentleyStatus.SUCCESS !== result)
3818
3704
  throw new IModelError(result, "Error creating class views");
3819
3705
  else
3820
- this.saveChanges();
3706
+ this[_nativeDb].saveChanges();
3821
3707
  }
3822
3708
  /** Open a standalone iModel file.
3823
3709
  * @param filePath The path of the standalone iModel file.