@itwin/core-backend 5.9.0-dev.1 → 5.9.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (551) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +38 -0
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js.map +1 -1
  5. package/lib/cjs/BriefcaseManager.js +3 -3
  6. package/lib/cjs/BriefcaseManager.js.map +1 -1
  7. package/lib/cjs/Category.d.ts +37 -7
  8. package/lib/cjs/Category.d.ts.map +1 -1
  9. package/lib/cjs/Category.js +33 -42
  10. package/lib/cjs/Category.js.map +1 -1
  11. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  12. package/lib/cjs/ChangesetECAdaptor.js +5 -2
  13. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  14. package/lib/cjs/ChannelControl.d.ts +29 -0
  15. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  16. package/lib/cjs/ChannelControl.js.map +1 -1
  17. package/lib/cjs/CheckpointManager.js +1 -1
  18. package/lib/cjs/CheckpointManager.js.map +1 -1
  19. package/lib/cjs/CloudSqlite.d.ts +1 -1
  20. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  21. package/lib/cjs/CloudSqlite.js +68 -13
  22. package/lib/cjs/CloudSqlite.js.map +1 -1
  23. package/lib/cjs/CodeSpecs.d.ts +32 -3
  24. package/lib/cjs/CodeSpecs.d.ts.map +1 -1
  25. package/lib/cjs/CodeSpecs.js +48 -20
  26. package/lib/cjs/CodeSpecs.js.map +1 -1
  27. package/lib/cjs/DisplayStyle.d.ts +18 -3
  28. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  29. package/lib/cjs/DisplayStyle.js +10 -21
  30. package/lib/cjs/DisplayStyle.js.map +1 -1
  31. package/lib/cjs/EditTxn.d.ts +262 -0
  32. package/lib/cjs/EditTxn.d.ts.map +1 -0
  33. package/lib/cjs/EditTxn.js +548 -0
  34. package/lib/cjs/EditTxn.js.map +1 -0
  35. package/lib/cjs/Element.d.ts +74 -5
  36. package/lib/cjs/Element.d.ts.map +1 -1
  37. package/lib/cjs/Element.js +63 -75
  38. package/lib/cjs/Element.js.map +1 -1
  39. package/lib/cjs/ElementAspect.d.ts +10 -0
  40. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  41. package/lib/cjs/ElementAspect.js +21 -12
  42. package/lib/cjs/ElementAspect.js.map +1 -1
  43. package/lib/cjs/ElementTreeWalker.d.ts +56 -3
  44. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  45. package/lib/cjs/ElementTreeWalker.js +53 -40
  46. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  47. package/lib/cjs/ExternalSource.d.ts +11 -2
  48. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  49. package/lib/cjs/ExternalSource.js +10 -8
  50. package/lib/cjs/ExternalSource.js.map +1 -1
  51. package/lib/cjs/IModelDb.d.ts +66 -22
  52. package/lib/cjs/IModelDb.d.ts.map +1 -1
  53. package/lib/cjs/IModelDb.js +175 -289
  54. package/lib/cjs/IModelDb.js.map +1 -1
  55. package/lib/cjs/IModelHost.d.ts +58 -1
  56. package/lib/cjs/IModelHost.d.ts.map +1 -1
  57. package/lib/cjs/IModelHost.js +89 -0
  58. package/lib/cjs/IModelHost.js.map +1 -1
  59. package/lib/cjs/IpcHost.d.ts.map +1 -1
  60. package/lib/cjs/IpcHost.js +35 -15
  61. package/lib/cjs/IpcHost.js.map +1 -1
  62. package/lib/cjs/LineStyle.d.ts +47 -7
  63. package/lib/cjs/LineStyle.d.ts.map +1 -1
  64. package/lib/cjs/LineStyle.js +38 -33
  65. package/lib/cjs/LineStyle.js.map +1 -1
  66. package/lib/cjs/LockControl.d.ts +85 -1
  67. package/lib/cjs/LockControl.d.ts.map +1 -1
  68. package/lib/cjs/LockControl.js.map +1 -1
  69. package/lib/cjs/Material.d.ts +8 -1
  70. package/lib/cjs/Material.d.ts.map +1 -1
  71. package/lib/cjs/Material.js +6 -12
  72. package/lib/cjs/Material.js.map +1 -1
  73. package/lib/cjs/Model.d.ts +59 -20
  74. package/lib/cjs/Model.d.ts.map +1 -1
  75. package/lib/cjs/Model.js +38 -80
  76. package/lib/cjs/Model.js.map +1 -1
  77. package/lib/cjs/Relationship.d.ts +72 -7
  78. package/lib/cjs/Relationship.d.ts.map +1 -1
  79. package/lib/cjs/Relationship.js +39 -21
  80. package/lib/cjs/Relationship.js.map +1 -1
  81. package/lib/cjs/SchemaSync.js +4 -4
  82. package/lib/cjs/SchemaSync.js.map +1 -1
  83. package/lib/cjs/SheetIndex.d.ts +9 -0
  84. package/lib/cjs/SheetIndex.d.ts.map +1 -1
  85. package/lib/cjs/SheetIndex.js +38 -35
  86. package/lib/cjs/SheetIndex.js.map +1 -1
  87. package/lib/cjs/StashManager.js +1 -1
  88. package/lib/cjs/StashManager.js.map +1 -1
  89. package/lib/cjs/Texture.d.ts +6 -0
  90. package/lib/cjs/Texture.d.ts.map +1 -1
  91. package/lib/cjs/Texture.js +6 -14
  92. package/lib/cjs/Texture.js.map +1 -1
  93. package/lib/cjs/TxnManager.d.ts +105 -9
  94. package/lib/cjs/TxnManager.d.ts.map +1 -1
  95. package/lib/cjs/TxnManager.js +194 -15
  96. package/lib/cjs/TxnManager.js.map +1 -1
  97. package/lib/cjs/ViewDefinition.d.ts +21 -1
  98. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  99. package/lib/cjs/ViewDefinition.js +27 -66
  100. package/lib/cjs/ViewDefinition.js.map +1 -1
  101. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
  102. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  103. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +33 -27
  104. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  105. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  106. package/lib/cjs/annotations/TextAnnotationElement.js +6 -5
  107. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  108. package/lib/cjs/core-backend.d.ts +1 -0
  109. package/lib/cjs/core-backend.d.ts.map +1 -1
  110. package/lib/cjs/core-backend.js +1 -0
  111. package/lib/cjs/core-backend.js.map +1 -1
  112. package/lib/cjs/domains/FunctionalElements.d.ts +6 -2
  113. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  114. package/lib/cjs/domains/FunctionalElements.js +8 -13
  115. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  116. package/lib/cjs/domains/GenericElements.d.ts +11 -4
  117. package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
  118. package/lib/cjs/domains/GenericElements.js +13 -24
  119. package/lib/cjs/domains/GenericElements.js.map +1 -1
  120. package/lib/cjs/internal/ChannelAdmin.d.ts +15 -0
  121. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
  122. package/lib/cjs/internal/ChannelAdmin.js +5 -3
  123. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  124. package/lib/cjs/internal/HubMock.d.ts +2 -0
  125. package/lib/cjs/internal/HubMock.d.ts.map +1 -1
  126. package/lib/cjs/internal/HubMock.js +7 -0
  127. package/lib/cjs/internal/HubMock.js.map +1 -1
  128. package/lib/cjs/internal/NoLocks.d.ts.map +1 -1
  129. package/lib/cjs/internal/NoLocks.js +6 -0
  130. package/lib/cjs/internal/NoLocks.js.map +1 -1
  131. package/lib/cjs/internal/ServerBasedLocks.d.ts +12 -0
  132. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
  133. package/lib/cjs/internal/ServerBasedLocks.js +285 -4
  134. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  135. package/lib/cjs/internal/Symbols.d.ts +4 -0
  136. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  137. package/lib/cjs/internal/Symbols.js +5 -1
  138. package/lib/cjs/internal/Symbols.js.map +1 -1
  139. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  140. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  141. package/lib/cjs/internal/annotations/fields.js +7 -6
  142. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  143. package/lib/cjs/internal/workspace/SettingsEditorImpl.d.ts +18 -3
  144. package/lib/cjs/internal/workspace/SettingsEditorImpl.d.ts.map +1 -1
  145. package/lib/cjs/internal/workspace/SettingsEditorImpl.js +49 -242
  146. package/lib/cjs/internal/workspace/SettingsEditorImpl.js.map +1 -1
  147. package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -1
  148. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  149. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +0 -1
  150. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  151. package/lib/cjs/internal/workspace/WorkspaceImpl.js +70 -41
  152. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  153. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  154. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  155. package/lib/cjs/workspace/Settings.d.ts +11 -5
  156. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  157. package/lib/cjs/workspace/Settings.js.map +1 -1
  158. package/lib/cjs/workspace/SettingsDb.d.ts +20 -99
  159. package/lib/cjs/workspace/SettingsDb.d.ts.map +1 -1
  160. package/lib/cjs/workspace/SettingsDb.js +23 -7
  161. package/lib/cjs/workspace/SettingsDb.js.map +1 -1
  162. package/lib/cjs/workspace/SettingsEditor.d.ts +40 -226
  163. package/lib/cjs/workspace/SettingsEditor.d.ts.map +1 -1
  164. package/lib/cjs/workspace/SettingsEditor.js +86 -25
  165. package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
  166. package/lib/cjs/workspace/Workspace.d.ts +7 -11
  167. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  168. package/lib/cjs/workspace/Workspace.js.map +1 -1
  169. package/lib/cjs/workspace/WorkspaceEditor.d.ts +14 -0
  170. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
  171. package/lib/cjs/workspace/WorkspaceEditor.js +1 -1
  172. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  173. package/lib/esm/BackendHubAccess.d.ts +38 -0
  174. package/lib/esm/BackendHubAccess.d.ts.map +1 -1
  175. package/lib/esm/BackendHubAccess.js.map +1 -1
  176. package/lib/esm/BriefcaseManager.js +3 -3
  177. package/lib/esm/BriefcaseManager.js.map +1 -1
  178. package/lib/esm/Category.d.ts +37 -7
  179. package/lib/esm/Category.d.ts.map +1 -1
  180. package/lib/esm/Category.js +33 -42
  181. package/lib/esm/Category.js.map +1 -1
  182. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  183. package/lib/esm/ChangesetECAdaptor.js +5 -2
  184. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  185. package/lib/esm/ChannelControl.d.ts +29 -0
  186. package/lib/esm/ChannelControl.d.ts.map +1 -1
  187. package/lib/esm/ChannelControl.js.map +1 -1
  188. package/lib/esm/CheckpointManager.js +1 -1
  189. package/lib/esm/CheckpointManager.js.map +1 -1
  190. package/lib/esm/CloudSqlite.d.ts +1 -1
  191. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  192. package/lib/esm/CloudSqlite.js +69 -14
  193. package/lib/esm/CloudSqlite.js.map +1 -1
  194. package/lib/esm/CodeSpecs.d.ts +32 -3
  195. package/lib/esm/CodeSpecs.d.ts.map +1 -1
  196. package/lib/esm/CodeSpecs.js +49 -21
  197. package/lib/esm/CodeSpecs.js.map +1 -1
  198. package/lib/esm/DisplayStyle.d.ts +18 -3
  199. package/lib/esm/DisplayStyle.d.ts.map +1 -1
  200. package/lib/esm/DisplayStyle.js +10 -21
  201. package/lib/esm/DisplayStyle.js.map +1 -1
  202. package/lib/esm/EditTxn.d.ts +262 -0
  203. package/lib/esm/EditTxn.d.ts.map +1 -0
  204. package/lib/esm/EditTxn.js +543 -0
  205. package/lib/esm/EditTxn.js.map +1 -0
  206. package/lib/esm/Element.d.ts +74 -5
  207. package/lib/esm/Element.d.ts.map +1 -1
  208. package/lib/esm/Element.js +64 -76
  209. package/lib/esm/Element.js.map +1 -1
  210. package/lib/esm/ElementAspect.d.ts +10 -0
  211. package/lib/esm/ElementAspect.d.ts.map +1 -1
  212. package/lib/esm/ElementAspect.js +22 -13
  213. package/lib/esm/ElementAspect.js.map +1 -1
  214. package/lib/esm/ElementTreeWalker.d.ts +56 -3
  215. package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
  216. package/lib/esm/ElementTreeWalker.js +53 -40
  217. package/lib/esm/ElementTreeWalker.js.map +1 -1
  218. package/lib/esm/ExternalSource.d.ts +11 -2
  219. package/lib/esm/ExternalSource.d.ts.map +1 -1
  220. package/lib/esm/ExternalSource.js +10 -8
  221. package/lib/esm/ExternalSource.js.map +1 -1
  222. package/lib/esm/IModelDb.d.ts +66 -22
  223. package/lib/esm/IModelDb.d.ts.map +1 -1
  224. package/lib/esm/IModelDb.js +177 -291
  225. package/lib/esm/IModelDb.js.map +1 -1
  226. package/lib/esm/IModelHost.d.ts +58 -1
  227. package/lib/esm/IModelHost.d.ts.map +1 -1
  228. package/lib/esm/IModelHost.js +91 -2
  229. package/lib/esm/IModelHost.js.map +1 -1
  230. package/lib/esm/IpcHost.d.ts.map +1 -1
  231. package/lib/esm/IpcHost.js +36 -16
  232. package/lib/esm/IpcHost.js.map +1 -1
  233. package/lib/esm/LineStyle.d.ts +47 -7
  234. package/lib/esm/LineStyle.d.ts.map +1 -1
  235. package/lib/esm/LineStyle.js +38 -33
  236. package/lib/esm/LineStyle.js.map +1 -1
  237. package/lib/esm/LockControl.d.ts +85 -1
  238. package/lib/esm/LockControl.d.ts.map +1 -1
  239. package/lib/esm/LockControl.js.map +1 -1
  240. package/lib/esm/Material.d.ts +8 -1
  241. package/lib/esm/Material.d.ts.map +1 -1
  242. package/lib/esm/Material.js +6 -12
  243. package/lib/esm/Material.js.map +1 -1
  244. package/lib/esm/Model.d.ts +59 -20
  245. package/lib/esm/Model.d.ts.map +1 -1
  246. package/lib/esm/Model.js +39 -81
  247. package/lib/esm/Model.js.map +1 -1
  248. package/lib/esm/Relationship.d.ts +72 -7
  249. package/lib/esm/Relationship.d.ts.map +1 -1
  250. package/lib/esm/Relationship.js +40 -22
  251. package/lib/esm/Relationship.js.map +1 -1
  252. package/lib/esm/SchemaSync.js +5 -5
  253. package/lib/esm/SchemaSync.js.map +1 -1
  254. package/lib/esm/SheetIndex.d.ts +9 -0
  255. package/lib/esm/SheetIndex.d.ts.map +1 -1
  256. package/lib/esm/SheetIndex.js +38 -35
  257. package/lib/esm/SheetIndex.js.map +1 -1
  258. package/lib/esm/StashManager.js +1 -1
  259. package/lib/esm/StashManager.js.map +1 -1
  260. package/lib/esm/Texture.d.ts +6 -0
  261. package/lib/esm/Texture.d.ts.map +1 -1
  262. package/lib/esm/Texture.js +6 -14
  263. package/lib/esm/Texture.js.map +1 -1
  264. package/lib/esm/TxnManager.d.ts +105 -9
  265. package/lib/esm/TxnManager.d.ts.map +1 -1
  266. package/lib/esm/TxnManager.js +194 -15
  267. package/lib/esm/TxnManager.js.map +1 -1
  268. package/lib/esm/ViewDefinition.d.ts +21 -1
  269. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  270. package/lib/esm/ViewDefinition.js +27 -66
  271. package/lib/esm/ViewDefinition.js.map +1 -1
  272. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
  273. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  274. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -27
  275. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  276. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  277. package/lib/esm/annotations/TextAnnotationElement.js +6 -5
  278. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  279. package/lib/esm/core-backend.d.ts +1 -0
  280. package/lib/esm/core-backend.d.ts.map +1 -1
  281. package/lib/esm/core-backend.js +1 -0
  282. package/lib/esm/core-backend.js.map +1 -1
  283. package/lib/esm/domains/FunctionalElements.d.ts +6 -2
  284. package/lib/esm/domains/FunctionalElements.d.ts.map +1 -1
  285. package/lib/esm/domains/FunctionalElements.js +8 -13
  286. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  287. package/lib/esm/domains/GenericElements.d.ts +11 -4
  288. package/lib/esm/domains/GenericElements.d.ts.map +1 -1
  289. package/lib/esm/domains/GenericElements.js +13 -24
  290. package/lib/esm/domains/GenericElements.js.map +1 -1
  291. package/lib/esm/internal/ChannelAdmin.d.ts +15 -0
  292. package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
  293. package/lib/esm/internal/ChannelAdmin.js +6 -4
  294. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  295. package/lib/esm/internal/HubMock.d.ts +2 -0
  296. package/lib/esm/internal/HubMock.d.ts.map +1 -1
  297. package/lib/esm/internal/HubMock.js +7 -0
  298. package/lib/esm/internal/HubMock.js.map +1 -1
  299. package/lib/esm/internal/NoLocks.d.ts.map +1 -1
  300. package/lib/esm/internal/NoLocks.js +6 -0
  301. package/lib/esm/internal/NoLocks.js.map +1 -1
  302. package/lib/esm/internal/ServerBasedLocks.d.ts +12 -0
  303. package/lib/esm/internal/ServerBasedLocks.d.ts.map +1 -1
  304. package/lib/esm/internal/ServerBasedLocks.js +286 -5
  305. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  306. package/lib/esm/internal/Symbols.d.ts +4 -0
  307. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  308. package/lib/esm/internal/Symbols.js +4 -0
  309. package/lib/esm/internal/Symbols.js.map +1 -1
  310. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  311. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  312. package/lib/esm/internal/annotations/fields.js +7 -6
  313. package/lib/esm/internal/annotations/fields.js.map +1 -1
  314. package/lib/esm/internal/workspace/SettingsEditorImpl.d.ts +18 -3
  315. package/lib/esm/internal/workspace/SettingsEditorImpl.d.ts.map +1 -1
  316. package/lib/esm/internal/workspace/SettingsEditorImpl.js +52 -246
  317. package/lib/esm/internal/workspace/SettingsEditorImpl.js.map +1 -1
  318. package/lib/esm/internal/workspace/SettingsImpl.d.ts.map +1 -1
  319. package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
  320. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts +0 -1
  321. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  322. package/lib/esm/internal/workspace/WorkspaceImpl.js +71 -41
  323. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  324. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  325. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  326. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  327. package/lib/esm/test/ElementDrivesElement.test.d.ts +20 -19
  328. package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -1
  329. package/lib/esm/test/ElementDrivesElement.test.js +111 -96
  330. package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
  331. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  332. package/lib/esm/test/IModelHost.test.js +56 -2
  333. package/lib/esm/test/IModelHost.test.js.map +1 -1
  334. package/lib/esm/test/IModelTestUtils.d.ts +23 -23
  335. package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
  336. package/lib/esm/test/IModelTestUtils.js +466 -449
  337. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  338. package/lib/esm/test/IpcHost.test.js +112 -0
  339. package/lib/esm/test/IpcHost.test.js.map +1 -1
  340. package/lib/esm/test/PropertyDb.test.js +2 -2
  341. package/lib/esm/test/PropertyDb.test.js.map +1 -1
  342. package/lib/esm/test/SquashSchemaAndDataChanges.test.js +27 -18
  343. package/lib/esm/test/SquashSchemaAndDataChanges.test.js.map +1 -1
  344. package/lib/esm/test/TestChangeSetUtility.d.ts.map +1 -1
  345. package/lib/esm/test/TestChangeSetUtility.js +11 -7
  346. package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
  347. package/lib/esm/test/TestEditTxn.d.ts +8 -0
  348. package/lib/esm/test/TestEditTxn.d.ts.map +1 -0
  349. package/lib/esm/test/TestEditTxn.js +34 -0
  350. package/lib/esm/test/TestEditTxn.js.map +1 -0
  351. package/lib/esm/test/TestUtils.d.ts +1 -0
  352. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  353. package/lib/esm/test/TestUtils.js +8 -1
  354. package/lib/esm/test/TestUtils.js.map +1 -1
  355. package/lib/esm/test/annotations/Fields.test.js +82 -90
  356. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  357. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  358. package/lib/esm/test/annotations/TextAnnotation.test.js +156 -99
  359. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  360. package/lib/esm/test/annotations/TextBlock.test.js +5 -3
  361. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  362. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
  363. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  364. package/lib/esm/test/categories/Category.test.js +63 -3
  365. package/lib/esm/test/categories/Category.test.js.map +1 -1
  366. package/lib/esm/test/codespec/CodeSpec.test.js +88 -5
  367. package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
  368. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  369. package/lib/esm/test/ecdb/ECSqlAst.test.js +3 -2
  370. package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
  371. package/lib/esm/test/ecdb/ECSqlQuery.test.js +2 -2
  372. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  373. package/lib/esm/test/ecdb/ECSqlStatement.test.js +0 -1
  374. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  375. package/lib/esm/test/ecdb/QueryReaders.test.js +17 -14
  376. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  377. package/lib/esm/test/ecdb/SqliteStatement.test.js +2 -2
  378. package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
  379. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
  380. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +30 -28
  381. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
  382. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
  383. package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
  384. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  385. package/lib/esm/test/element/DeleteDefinitionElements.test.js +159 -143
  386. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  387. package/lib/esm/test/element/ElementAspect.test.js +68 -60
  388. package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
  389. package/lib/esm/test/element/ElementDependencyGraph.test.d.ts.map +1 -1
  390. package/lib/esm/test/element/ElementDependencyGraph.test.js +51 -43
  391. package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
  392. package/lib/esm/test/element/ElementRoundTrip.test.js +37 -38
  393. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  394. package/lib/esm/test/element/ExcludedElements.test.js +2 -2
  395. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  396. package/lib/esm/test/element/ExternalSource.test.js +40 -38
  397. package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
  398. package/lib/esm/test/element/NullStructArray.test.js +10 -9
  399. package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
  400. package/lib/esm/test/element/ProjectInformationRecord.test.js +5 -2
  401. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
  402. package/lib/esm/test/element/SheetInformationAspect.test.js +43 -11
  403. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
  404. package/lib/esm/test/element/UrlLink.test.js +2 -2
  405. package/lib/esm/test/element/UrlLink.test.js.map +1 -1
  406. package/lib/esm/test/font/IModelDbFonts.test.js +87 -73
  407. package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
  408. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +164 -125
  409. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  410. package/lib/esm/test/hubaccess/BriefcaseManager.test.js +2 -4
  411. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  412. package/lib/esm/test/hubaccess/Rebase.test.js +313 -247
  413. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  414. package/lib/esm/test/hubaccess/SemanticRebase.test.js +322 -247
  415. package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
  416. package/lib/esm/test/imodel/Code.test.js +31 -31
  417. package/lib/esm/test/imodel/Code.test.js.map +1 -1
  418. package/lib/esm/test/imodel/ElementTreeWalker.test.js +57 -48
  419. package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
  420. package/lib/esm/test/imodel/IModel.test.js +419 -344
  421. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  422. package/lib/esm/test/imodel/ProjectExtents.test.js +2 -2
  423. package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
  424. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  425. package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -1
  426. package/lib/esm/test/incrementalSchemaLocater/TestContext.js +2 -2
  427. package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -1
  428. package/lib/esm/test/index.d.ts +1 -0
  429. package/lib/esm/test/index.d.ts.map +1 -1
  430. package/lib/esm/test/index.js +1 -0
  431. package/lib/esm/test/index.js.map +1 -1
  432. package/lib/esm/test/schema/ClassRegistry.test.js +23 -22
  433. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  434. package/lib/esm/test/schema/FunctionalDomain.test.js +36 -34
  435. package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
  436. package/lib/esm/test/schema/GenericDomain.test.js +114 -94
  437. package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
  438. package/lib/esm/test/schema/IModelSchemaContext.test.js +2 -1
  439. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  440. package/lib/esm/test/schema/SchemaImportCallbacks.test.js +207 -192
  441. package/lib/esm/test/schema/SchemaImportCallbacks.test.js.map +1 -1
  442. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts +1 -3
  443. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts.map +1 -1
  444. package/lib/esm/test/sheetindex/SheetIndex.test.js +312 -247
  445. package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
  446. package/lib/esm/test/standalone/ChangeMerge.test.js +101 -82
  447. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  448. package/lib/esm/test/standalone/ChangesetReader.test.js +114 -85
  449. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  450. package/lib/esm/test/standalone/DisplayStyle.test.js +43 -40
  451. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
  452. package/lib/esm/test/standalone/Drawing.test.js +4 -3
  453. package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
  454. package/lib/esm/test/standalone/EditTxn.test.d.ts +2 -0
  455. package/lib/esm/test/standalone/EditTxn.test.d.ts.map +1 -0
  456. package/lib/esm/test/standalone/EditTxn.test.js +219 -0
  457. package/lib/esm/test/standalone/EditTxn.test.js.map +1 -0
  458. package/lib/esm/test/standalone/ElementMesh.test.js +16 -13
  459. package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
  460. package/lib/esm/test/standalone/ExportGraphics.test.js +26 -20
  461. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  462. package/lib/esm/test/standalone/GeometryChangeEvents.test.js +11 -15
  463. package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
  464. package/lib/esm/test/standalone/GeometryStream.test.js +212 -165
  465. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  466. package/lib/esm/test/standalone/HubMock.test.js +31 -25
  467. package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
  468. package/lib/esm/test/standalone/IModelLimits.test.js +11 -8
  469. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
  470. package/lib/esm/test/standalone/IModelWrite.test.d.ts +2 -2
  471. package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -1
  472. package/lib/esm/test/standalone/IModelWrite.test.js +184 -142
  473. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  474. package/lib/esm/test/standalone/ITwinWorkspace.test.d.ts +2 -0
  475. package/lib/esm/test/standalone/ITwinWorkspace.test.d.ts.map +1 -0
  476. package/lib/esm/test/standalone/ITwinWorkspace.test.js +236 -0
  477. package/lib/esm/test/standalone/ITwinWorkspace.test.js.map +1 -0
  478. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js +25 -22
  479. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
  480. package/lib/esm/test/standalone/IntegrityCheck.test.js +20 -18
  481. package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
  482. package/lib/esm/test/standalone/MergeConflict.test.d.ts +2 -2
  483. package/lib/esm/test/standalone/MergeConflict.test.d.ts.map +1 -1
  484. package/lib/esm/test/standalone/MergeConflict.test.js +49 -33
  485. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
  486. package/lib/esm/test/standalone/RenderMaterialElement.test.js +5 -5
  487. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  488. package/lib/esm/test/standalone/RenderTimeline.test.js +3 -2
  489. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
  490. package/lib/esm/test/standalone/SectionDrawing.test.js +7 -7
  491. package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
  492. package/lib/esm/test/standalone/ServerBasedLocks.test.js +928 -22
  493. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  494. package/lib/esm/test/standalone/Settings.test.js +26 -4
  495. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  496. package/lib/esm/test/standalone/SettingsSchemas.test.js +2 -1
  497. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  498. package/lib/esm/test/standalone/SnapshotDb.test.js +3 -1
  499. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  500. package/lib/esm/test/standalone/StandaloneDb.test.js +7 -6
  501. package/lib/esm/test/standalone/StandaloneDb.test.js.map +1 -1
  502. package/lib/esm/test/standalone/Texture.test.js +5 -4
  503. package/lib/esm/test/standalone/Texture.test.js.map +1 -1
  504. package/lib/esm/test/standalone/TileCache.test.d.ts.map +1 -1
  505. package/lib/esm/test/standalone/TileCache.test.js +5 -3
  506. package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
  507. package/lib/esm/test/standalone/TileTree.test.js +35 -31
  508. package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
  509. package/lib/esm/test/standalone/TxnManager.test.js +700 -653
  510. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  511. package/lib/esm/test/standalone/ViewDefinition.test.js +295 -229
  512. package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
  513. package/lib/esm/test/standalone/Workspace.test.js +72 -22
  514. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  515. package/lib/esm/test/workspace/SettingsDb.test.js +28 -456
  516. package/lib/esm/test/workspace/SettingsDb.test.js.map +1 -1
  517. package/lib/esm/workspace/Settings.d.ts +11 -5
  518. package/lib/esm/workspace/Settings.d.ts.map +1 -1
  519. package/lib/esm/workspace/Settings.js.map +1 -1
  520. package/lib/esm/workspace/SettingsDb.d.ts +20 -99
  521. package/lib/esm/workspace/SettingsDb.d.ts.map +1 -1
  522. package/lib/esm/workspace/SettingsDb.js +20 -6
  523. package/lib/esm/workspace/SettingsDb.js.map +1 -1
  524. package/lib/esm/workspace/SettingsEditor.d.ts +40 -226
  525. package/lib/esm/workspace/SettingsEditor.d.ts.map +1 -1
  526. package/lib/esm/workspace/SettingsEditor.js +85 -24
  527. package/lib/esm/workspace/SettingsEditor.js.map +1 -1
  528. package/lib/esm/workspace/Workspace.d.ts +7 -11
  529. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  530. package/lib/esm/workspace/Workspace.js.map +1 -1
  531. package/lib/esm/workspace/WorkspaceEditor.d.ts +14 -0
  532. package/lib/esm/workspace/WorkspaceEditor.d.ts.map +1 -1
  533. package/lib/esm/workspace/WorkspaceEditor.js +1 -1
  534. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  535. package/package.json +14 -14
  536. package/lib/cjs/internal/workspace/SettingsDbImpl.d.ts +0 -38
  537. package/lib/cjs/internal/workspace/SettingsDbImpl.d.ts.map +0 -1
  538. package/lib/cjs/internal/workspace/SettingsDbImpl.js +0 -108
  539. package/lib/cjs/internal/workspace/SettingsDbImpl.js.map +0 -1
  540. package/lib/cjs/internal/workspace/SettingsSqliteDb.d.ts +0 -14
  541. package/lib/cjs/internal/workspace/SettingsSqliteDb.d.ts.map +0 -1
  542. package/lib/cjs/internal/workspace/SettingsSqliteDb.js +0 -40
  543. package/lib/cjs/internal/workspace/SettingsSqliteDb.js.map +0 -1
  544. package/lib/esm/internal/workspace/SettingsDbImpl.d.ts +0 -38
  545. package/lib/esm/internal/workspace/SettingsDbImpl.d.ts.map +0 -1
  546. package/lib/esm/internal/workspace/SettingsDbImpl.js +0 -104
  547. package/lib/esm/internal/workspace/SettingsDbImpl.js.map +0 -1
  548. package/lib/esm/internal/workspace/SettingsSqliteDb.d.ts +0 -14
  549. package/lib/esm/internal/workspace/SettingsSqliteDb.d.ts.map +0 -1
  550. package/lib/esm/internal/workspace/SettingsSqliteDb.js +0 -36
  551. package/lib/esm/internal/workspace/SettingsSqliteDb.js.map +0 -1
@@ -38,6 +38,7 @@ const SchemaSync_1 = require("./SchemaSync");
38
38
  const ServerBasedLocks_1 = require("./internal/ServerBasedLocks");
39
39
  const SqliteStatement_1 = require("./SqliteStatement");
40
40
  const TxnManager_1 = require("./TxnManager");
41
+ const EditTxn_1 = require("./EditTxn");
41
42
  const ViewDefinition_1 = require("./ViewDefinition");
42
43
  const ViewStore_1 = require("./ViewStore");
43
44
  const Settings_1 = require("./workspace/Settings");
@@ -57,6 +58,38 @@ const IntegrityCheck_1 = require("./internal/IntegrityCheck");
57
58
  const ECSqlSyncReader_1 = require("./ECSqlSyncReader");
58
59
  // spell:ignore fontid fontmap
59
60
  const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
61
+ /**
62
+ * Internal write surface used to preserve legacy implicit-transaction mutators while callers migrate to explicit [[EditTxn]] scopes.
63
+ *
64
+ * Unlike an explicit [[EditTxn]], this transaction is always available for writable iModels and cannot be manually started or ended.
65
+ * When implicit-write enforcement is enabled, attempts to write through this transaction are logged or rejected.
66
+ */
67
+ class ImplicitWriteTxn extends EditTxn_1.EditTxn {
68
+ constructor(iModel) {
69
+ super(iModel, "implicit");
70
+ }
71
+ start() {
72
+ throw new Error("ImplicitWriteTxn cannot be started");
73
+ }
74
+ end(_mode = "save", _args) {
75
+ throw new Error("ImplicitWriteTxn cannot be ended");
76
+ }
77
+ verifyWriteable() {
78
+ const enforcement = EditTxn_1.EditTxn.implicitWriteEnforcement;
79
+ if (enforcement === "allow")
80
+ return;
81
+ try {
82
+ core_common_1.EditTxnError.throwError("implicit-txn-write-disallowed", "Implicit transaction write is disallowed. Use an explicit EditTxn instead", this.iModel.key);
83
+ }
84
+ catch (err) {
85
+ if (enforcement === "log") {
86
+ core_bentley_1.Logger.logError(loggerCategory, err);
87
+ return;
88
+ }
89
+ throw err;
90
+ }
91
+ }
92
+ }
60
93
  /** @internal */
61
94
  var BriefcaseLocalValue;
62
95
  (function (BriefcaseLocalValue) {
@@ -142,6 +175,25 @@ class IModelDb extends core_common_1.IModel {
142
175
  _locks = (0, NoLocks_1.createNoOpLockControl)();
143
176
  /** @internal */
144
177
  _codeService;
178
+ /**
179
+ * The always-available implicit transaction for this iModel.
180
+ *
181
+ * Legacy mutating APIs route through this transaction for backwards compatibility until they are fully migrated to explicit [[EditTxn]] usage.
182
+ * @internal
183
+ */
184
+ [Symbols_1._implicitTxn];
185
+ /** @internal */
186
+ [Symbols_1._activeTxn];
187
+ /** Returns the active [[EditTxn]] if one is current, otherwise the implicit transaction.
188
+ * Use this inside element and relationship callbacks that may be invoked either during an explicit transaction or
189
+ * during indirect change processing.
190
+ * @note This method is a temporary workaround until [[OnElementArg]] (and related callback arg types) are updated
191
+ * to carry the transaction directly in a future PR.
192
+ * @internal
193
+ */
194
+ getIndirectTxn() {
195
+ return this[Symbols_1._activeTxn] ?? this[Symbols_1._implicitTxn];
196
+ }
145
197
  /** @alpha */
146
198
  get codeService() { return this._codeService; }
147
199
  /** The [[LockControl]] that orchestrates [concurrent editing]($docs/learning/backend/ConcurrencyControl.md) of this iModel. */
@@ -230,17 +282,20 @@ class IModelDb extends core_common_1.IModel {
230
282
  // Make closeIModel available so their code doesn't break.
231
283
  this[Symbols_1._nativeDb].closeIModel = () => {
232
284
  if (!this.isReadonly)
233
- this.saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
285
+ this[Symbols_1._nativeDb].saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
286
+ this[Symbols_1._activeTxn] = undefined;
234
287
  this[Symbols_1._nativeDb].closeFile();
235
288
  };
236
289
  this[Symbols_1._nativeDb].setIModelDb(this);
237
290
  this[Symbols_1._resetIModelDb]();
238
291
  IModelDb._openDbs.set(this._fileKey, this);
292
+ this[Symbols_1._implicitTxn] = new ImplicitWriteTxn(this);
293
+ this[Symbols_1._activeTxn] = undefined;
239
294
  if (undefined === IModelDb._shutdownListener) { // the first time we create an IModelDb, add a listener to close any orphan files at shutdown.
240
295
  IModelDb._shutdownListener = IModelHost_1.IModelHost.onBeforeShutdown.addListener(() => {
241
296
  IModelDb._openDbs.forEach((db) => {
242
297
  try {
243
- db.abandonChanges();
298
+ db[Symbols_1._nativeDb].abandonChanges();
244
299
  db.close();
245
300
  }
246
301
  catch { }
@@ -270,8 +325,8 @@ class IModelDb extends core_common_1.IModel {
270
325
  }
271
326
  /**
272
327
  * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.
273
- * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'
274
- * @param alias identifer that was used in the call to [[attachDb]]
328
+ * @note There are some reserved table names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'
329
+ * @param alias identifier that was used in the call to [[attachDb]]
275
330
  *
276
331
  * @example [[include:IModelDb_attachDb.code]]
277
332
  *
@@ -289,7 +344,13 @@ class IModelDb extends core_common_1.IModel {
289
344
  close(options) {
290
345
  if (!this.isOpen)
291
346
  return; // don't continue if already closed
347
+ // Give the active txn a chance to save or abandon before beforeClose() cleanup runs.
348
+ // StandaloneDb.beforeClose() saves any unsaved changes, so onClose() must run first so
349
+ // subclasses that override onClose() to abandon changes can do so before that save.
350
+ if (!this.isReadonly)
351
+ (this[Symbols_1._activeTxn] ?? this[Symbols_1._implicitTxn]).onClose();
292
352
  this.beforeClose();
353
+ this[Symbols_1._activeTxn] = undefined;
293
354
  if (options?.optimize)
294
355
  this.optimize();
295
356
  IModelDb._openDbs.delete(this._fileKey);
@@ -298,10 +359,20 @@ class IModelDb extends core_common_1.IModel {
298
359
  this._locks = undefined;
299
360
  this._codeService?.close();
300
361
  this._codeService = undefined;
301
- if (!this.isReadonly)
302
- this.saveChanges();
303
362
  this[Symbols_1._nativeDb].closeFile();
304
363
  }
364
+ saveSchemaChanges(args) {
365
+ if (!this[Symbols_1._nativeDb].hasUnsavedChanges())
366
+ return;
367
+ const saveArgs = typeof args === "string" ? { description: args } : args;
368
+ saveArgs === undefined ? this[Symbols_1._nativeDb].saveChanges() : this[Symbols_1._nativeDb].saveChanges(JSON.stringify(saveArgs));
369
+ }
370
+ abandonSchemaChanges() {
371
+ if (!this[Symbols_1._nativeDb].hasUnsavedChanges())
372
+ return;
373
+ this.clearCaches({ instanceCachesOnly: true });
374
+ this[Symbols_1._nativeDb].abandonChanges();
375
+ }
305
376
  /** Optimize this iModel by vacuuming, and analyzing.
306
377
  *
307
378
  * @note This operation requires exclusive access to the database and may take some time on large files.
@@ -738,10 +809,10 @@ class IModelDb extends core_common_1.IModel {
738
809
  * ``` ts
739
810
  * [[include:IModelDb.updateProjectExtents]]
740
811
  * ```
812
+ * @deprecated Use EditTxn.updateProjectExtents instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
741
813
  */
742
814
  updateProjectExtents(newExtents) {
743
- this.projectExtents = newExtents;
744
- this.updateIModelProps();
815
+ this[Symbols_1._implicitTxn].updateProjectExtents(newExtents);
745
816
  }
746
817
  /** Compute an appropriate project extents for this iModel based on the ranges of all spatial elements.
747
818
  * Typically, the result is simply the union of the ranges of all spatial elements. However, the algorithm also detects "outlier elements",
@@ -761,45 +832,26 @@ class IModelDb extends core_common_1.IModel {
761
832
  outliers: result.outliers,
762
833
  };
763
834
  }
764
- /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel. */
835
+ /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel.
836
+ * @deprecated Use EditTxn.updateEcefLocation instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
837
+ */
765
838
  updateEcefLocation(ecef) {
766
- this.setEcefLocation(ecef);
767
- this.updateIModelProps();
839
+ this[Symbols_1._implicitTxn].updateEcefLocation(ecef);
768
840
  }
769
- /** Update the IModelProps of this iModel in the database. */
841
+ /** Update the IModelProps of this iModel in the database.
842
+ * @deprecated Use EditTxn.updateIModelProps instead, within an explicit EditTxn scope (or via withEditTxn).
843
+ */
770
844
  updateIModelProps() {
771
- this[Symbols_1._nativeDb].updateIModelProps(this.toJSON());
845
+ this[Symbols_1._implicitTxn].updateIModelProps();
772
846
  }
773
- /** Commit unsaved changes in memory as a Txn to this iModelDb.
774
- * @internal
775
- * @param descriptionOrArgs Optionally provide description or [[SaveChangesArgs]] args for the changes.
776
- * @throws [[IModelError]] if there is a problem saving changes or if there are pending, un-processed lock or code requests.
777
- * @note This will not push changes to the iModelHub.
778
- * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync}, {TxnManager.withIndirectTxnMode} or {RebaseHandler.recompute}.
779
- * @see [[IModelDb.pushChanges]] to push changes to the iModelHub.
780
- */
781
847
  saveChanges(descriptionOrArgs) {
782
- if (this.openMode === core_bentley_1.OpenMode.Readonly)
783
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.ReadOnly, "IModelDb was opened read-only");
784
- if (this.isBriefcaseDb()) {
785
- if (this.txns.isIndirectChanges) {
786
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Cannot save changes while in an indirect change scope");
787
- }
788
- }
789
- const args = typeof descriptionOrArgs === "string" ? { description: descriptionOrArgs } : descriptionOrArgs;
790
- const stat = this[Symbols_1._nativeDb].saveChanges(args ? JSON.stringify(args) : undefined);
791
- if (core_bentley_1.DbResult.BE_SQLITE_ERROR_PropagateChangesFailed === stat)
792
- throw new core_common_1.IModelError(stat, `Could not save changes due to propagation failure.`);
793
- if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat)
794
- throw new core_common_1.IModelError(stat, `Could not save changes (${args?.description})`);
848
+ this[Symbols_1._implicitTxn].saveChanges(descriptionOrArgs);
795
849
  }
796
850
  /** Abandon changes in memory that have not been saved as a Txn to this iModelDb.
797
- * @note This will not delete Txns that have already been saved, even if they have not yet been pushed.
851
+ * @deprecated Use EditTxn.abandonChanges instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
798
852
  */
799
853
  abandonChanges() {
800
- // Clears instanceKey caches only, instead of all of the backend caches, since the changes are not saved yet
801
- this.clearCaches({ instanceCachesOnly: true });
802
- this[Symbols_1._nativeDb].abandonChanges();
854
+ this[Symbols_1._implicitTxn].abandonChanges();
803
855
  }
804
856
  /**
805
857
  * Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
@@ -811,7 +863,7 @@ class IModelDb extends core_common_1.IModel {
811
863
  */
812
864
  performCheckpoint() {
813
865
  if (!this.isReadonly) {
814
- this.saveChanges();
866
+ this[Symbols_1._nativeDb].saveChanges();
815
867
  this.clearCaches();
816
868
  this[Symbols_1._nativeDb].concurrentQueryShutdown();
817
869
  this[Symbols_1._nativeDb].performCheckpoint();
@@ -850,7 +902,7 @@ class IModelDb extends core_common_1.IModel {
850
902
  *
851
903
  * If the removal was successful, the database is automatically saved to disk.
852
904
  * @param schemaNames Array of schema names to drop
853
- * @throws [IModelError]($common) if the database if the operation failed.
905
+ * @throws [[IModelError]] if the operation fails.
854
906
  * @alpha
855
907
  */
856
908
  async dropSchemas(schemaNames) {
@@ -864,11 +916,11 @@ class IModelDb extends core_common_1.IModel {
864
916
  await this.acquireSchemaLock();
865
917
  try {
866
918
  this[Symbols_1._nativeDb].dropSchemas(schemaNames);
867
- this.saveChanges(`dropped unused schemas`);
919
+ this.saveSchemaChanges("dropped unused schemas");
868
920
  }
869
921
  catch (error) {
870
922
  core_bentley_1.Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);
871
- this.abandonChanges();
923
+ this.abandonSchemaChanges();
872
924
  throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);
873
925
  }
874
926
  finally {
@@ -893,8 +945,9 @@ class IModelDb extends core_common_1.IModel {
893
945
  transformStrategy: DataTransformationStrategy.None,
894
946
  };
895
947
  try {
896
- if (callback?.preSchemaImportCallback) {
897
- const callbackResult = await callback.preSchemaImportCallback(context);
948
+ const preSchemaImportCallback = callback?.preSchemaImportCallback;
949
+ if (preSchemaImportCallback) {
950
+ const callbackResult = await preSchemaImportCallback(context);
898
951
  callbackResources.transformStrategy = callbackResult.transformStrategy;
899
952
  if (callbackResult.transformStrategy === DataTransformationStrategy.Snapshot) {
900
953
  // Create temporary snapshot file
@@ -907,13 +960,12 @@ class IModelDb extends core_common_1.IModel {
907
960
  }
908
961
  callbackResources.cachedData = callbackResult.cachedData;
909
962
  }
910
- if (this.isBriefcaseDb() && IModelHost_1.IModelHost.useSemanticRebase) {
911
- this.saveChanges("Save changes from schema import pre callback");
912
- }
963
+ if (this.isBriefcaseDb() && IModelHost_1.IModelHost.useSemanticRebase)
964
+ this.saveSchemaChanges("Save changes from schema import pre callback");
913
965
  }
914
966
  }
915
967
  catch (callbackError) {
916
- this.abandonChanges();
968
+ this.abandonSchemaChanges();
917
969
  this.cleanupSnapshot(callbackResources);
918
970
  throw new core_common_1.IModelError(callbackError.errorNumber ?? core_bentley_1.IModelStatus.BadRequest, `Failed to execute preSchemaImportCallback: ${callbackError.message}`);
919
971
  }
@@ -927,14 +979,14 @@ class IModelDb extends core_common_1.IModel {
927
979
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "InMemory transform strategy requires cachedData to be provided.");
928
980
  }
929
981
  try {
930
- if (callback?.postSchemaImportCallback)
931
- await callback.postSchemaImportCallback(context);
932
- if (this.isBriefcaseDb() && IModelHost_1.IModelHost.useSemanticRebase) {
933
- this.saveChanges("Save changes from schema import post callback");
934
- }
982
+ const postSchemaImportCallback = callback?.postSchemaImportCallback;
983
+ if (postSchemaImportCallback)
984
+ await postSchemaImportCallback(context);
985
+ if (this.isBriefcaseDb() && IModelHost_1.IModelHost.useSemanticRebase)
986
+ this.saveSchemaChanges("Save changes from schema import post callback");
935
987
  }
936
988
  catch (callbackError) {
937
- this.abandonChanges();
989
+ this.abandonSchemaChanges();
938
990
  throw new core_common_1.IModelError(callbackError.errorNumber ?? core_bentley_1.IModelStatus.BadRequest, `Failed to execute postSchemaImportCallback: ${callbackError.message}`);
939
991
  }
940
992
  finally {
@@ -963,15 +1015,15 @@ class IModelDb extends core_common_1.IModel {
963
1015
  }
964
1016
  }
965
1017
  if (options?.channelUpgrade) {
1018
+ const channelUpgrade = options.channelUpgrade;
966
1019
  try {
967
- await this.channels.upgradeChannel(options.channelUpgrade, this, options.data);
1020
+ await this.channels.upgradeChannel(channelUpgrade, this, options.data);
968
1021
  // If semantic rebase is enabled and channel upgrade made changes, save them
969
- if (this.isBriefcaseDb() && IModelHost_1.IModelHost.useSemanticRebase) {
970
- this.saveChanges();
971
- }
1022
+ if (this.isBriefcaseDb() && IModelHost_1.IModelHost.useSemanticRebase)
1023
+ this.saveSchemaChanges();
972
1024
  }
973
1025
  catch (error) {
974
- this.abandonChanges();
1026
+ this.abandonSchemaChanges();
975
1027
  throw error;
976
1028
  }
977
1029
  }
@@ -982,13 +1034,13 @@ class IModelDb extends core_common_1.IModel {
982
1034
  if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
983
1035
  await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
984
1036
  const schemaSyncDbUri = syncAccess.getUri();
985
- this.saveChanges();
1037
+ this.saveSchemaChanges();
986
1038
  try {
987
1039
  nativeImportOp(schemas, { schemaLockHeld: false, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
988
1040
  }
989
1041
  catch (outerErr) {
990
1042
  if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
991
- this.abandonChanges();
1043
+ this.abandonSchemaChanges();
992
1044
  if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
993
1045
  await this.acquireSchemaLock();
994
1046
  try {
@@ -1041,13 +1093,16 @@ class IModelDb extends core_common_1.IModel {
1041
1093
  if (options?.schemaImportCallbacks?.postSchemaImportCallback)
1042
1094
  await this.postSchemaImportCallback(options.schemaImportCallbacks, { iModel: this, resources: preSchemaImportCallbackResult, data: options.data });
1043
1095
  }
1044
- /** Import an ECSchema. On success, the schema definition is stored in the iModel.
1096
+ /** Import ECSchema(s). On success, the schema definition is stored in the iModel.
1045
1097
  * 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.
1046
1098
  * You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
1047
- * @param schemaFileName array of Full paths to ECSchema.xml files to be imported.
1099
+ * @param schemaFileNames Files containing serialized ECSchemas.
1048
1100
  * @param {SchemaImportOptions} options - options during schema import.
1049
1101
  * @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
1050
1102
  * @note Changes are saved if importSchemas is successful and abandoned if not successful.
1103
+ * @note To turn on native logging, use NativeLoggerCategory and a console appender.
1104
+ * - For metadata differences between existing and imported schemas, turn on "ECDb" category.
1105
+ * - For import details, turn on "SchemaImport" category.
1051
1106
  * - 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).
1052
1107
  * - See [Schema Versioning]($docs/bis/guide/schema-evolution/schema-versioning-and-generations.md) for more information on acceptable changes to schemas.
1053
1108
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {RebaseHandler.recompute}.
@@ -1209,7 +1264,7 @@ class IModelDb extends core_common_1.IModel {
1209
1264
  return this._jsClassMap;
1210
1265
  }
1211
1266
  /**
1212
- * Allows locally registering a schema for this imodel, in constrast to [Schemas.registerSchema] which is a global operation
1267
+ * Allows locally registering a schema for this imodel, in contrast to [Schemas.registerSchema] which is a global operation
1213
1268
  */
1214
1269
  get schemaMap() {
1215
1270
  if (this._schemaMap === undefined)
@@ -1521,26 +1576,18 @@ class IModelDb extends core_common_1.IModel {
1521
1576
  * @param prop the FilePropertyProps that describes the new property
1522
1577
  * @param value either a string or a blob to save as the file property
1523
1578
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {TxnManager.withIndirectTxnMode}.
1579
+ * @deprecated Use EditTxn.saveFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1524
1580
  */
1525
1581
  saveFileProperty(prop, strValue, blobVal) {
1526
- if (this.isBriefcaseDb()) {
1527
- if (this.txns.isIndirectChanges) {
1528
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Cannot save file property while in an indirect change scope");
1529
- }
1530
- }
1531
- this[Symbols_1._nativeDb].saveFileProperty(prop, strValue, blobVal);
1582
+ this[Symbols_1._implicitTxn].saveFileProperty(prop, strValue, blobVal);
1532
1583
  }
1533
1584
  /** delete a "file property" from this iModel
1534
1585
  * @param prop the FilePropertyProps that describes the property
1535
1586
  * @note This method should not be called from {TxnManager.withIndirectTxnModeAsync} or {TxnManager.withIndirectTxnMode}.
1587
+ * @deprecated Use EditTxn.deleteFileProperty instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1536
1588
  */
1537
1589
  deleteFileProperty(prop) {
1538
- if (this.isBriefcaseDb()) {
1539
- if (this.txns.isIndirectChanges) {
1540
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Cannot delete file property while in an indirect change scope");
1541
- }
1542
- }
1543
- this[Symbols_1._nativeDb].saveFileProperty(prop, undefined, undefined);
1590
+ this[Symbols_1._implicitTxn].deleteFileProperty(prop);
1544
1591
  }
1545
1592
  /** Query for the next available major id for a "file property" from this iModel.
1546
1593
  * @param prop the FilePropertyProps that describes the property
@@ -1744,28 +1791,17 @@ class IModelDb extends core_common_1.IModel {
1744
1791
  * @param name The name for the SettingDictionary. If a dictionary by that name already exists in the iModel, its value is replaced.
1745
1792
  * @param dict The SettingDictionary object to stringify and save.
1746
1793
  * @note All saved `SettingDictionary`s are loaded into [[workspace.settings]] every time an iModel is opened.
1747
- * @beta
1794
+ * @beta @deprecated Use EditTxn.saveSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1748
1795
  */
1749
1796
  saveSettingDictionary(name, dict) {
1750
- this.withSqliteStatement("REPLACE INTO be_Prop(id,SubId,TxnMode,Namespace,Name,strData) VALUES(0,0,0,?,?,?)", (stmt) => {
1751
- stmt.bindString(1, IModelDb._settingPropNamespace);
1752
- stmt.bindString(2, name);
1753
- stmt.bindString(3, JSON.stringify(dict));
1754
- stmt.stepForWrite();
1755
- });
1756
- this.saveChanges("add settings");
1797
+ this[Symbols_1._implicitTxn].saveSettingDictionary(name, dict);
1757
1798
  }
1758
1799
  /** Delete a SettingDictionary, previously added with [[saveSettingDictionary]], from this iModel.
1759
1800
  * @param name The name of the dictionary to delete.
1760
- * @beta
1801
+ * @beta @deprecated Use EditTxn.deleteSettingDictionary instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
1761
1802
  */
1762
1803
  deleteSettingDictionary(name) {
1763
- this.withSqliteStatement("DELETE FROM be_Prop WHERE Namespace=? AND Name=?", (stmt) => {
1764
- stmt.bindString(1, IModelDb._settingPropNamespace);
1765
- stmt.bindString(2, name);
1766
- stmt.stepForWrite();
1767
- });
1768
- this.saveChanges("delete settings");
1804
+ this[Symbols_1._implicitTxn].deleteSettingDictionary(name);
1769
1805
  }
1770
1806
  /** Load all setting dictionaries in this iModel into `this.workspace.settings` */
1771
1807
  loadIModelSettings() {
@@ -2041,33 +2077,19 @@ function processSchemaWriteStatus(status) {
2041
2077
  /** Insert a new model.
2042
2078
  * @param props The data for the new model.
2043
2079
  * @returns The newly inserted model's Id.
2044
- * @throws [[IModelError]] if unable to insert the model.
2080
+ * @throws [[IModelError]] if insertion fails.
2081
+ * @deprecated Use EditTxn.insertModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2045
2082
  */
2046
2083
  insertModel(props) {
2047
- try {
2048
- return props.id = this._iModel[Symbols_1._nativeDb].insertModel(props);
2049
- }
2050
- catch (err) {
2051
- const error = new core_common_1.IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
2052
- error.cause = err;
2053
- throw error;
2054
- }
2084
+ return this._iModel[Symbols_1._implicitTxn].insertModel(props);
2055
2085
  }
2056
2086
  /** Update an existing model.
2057
2087
  * @param props the properties of the model to change
2058
- * @throws [[IModelError]] if unable to update the model.
2088
+ * @throws [[IModelError]] if update fails.
2089
+ * @deprecated Use EditTxn.updateModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2059
2090
  */
2060
2091
  updateModel(props) {
2061
- try {
2062
- if (props.id)
2063
- this[Symbols_1._cache].delete(props.id);
2064
- this._iModel[Symbols_1._nativeDb].updateModel(props);
2065
- }
2066
- catch (err) {
2067
- const error = new core_common_1.IModelError(err.errorNumber, `Error updating model [${err.message}], id: ${props.id}`);
2068
- error.cause = err;
2069
- throw error;
2070
- }
2092
+ this._iModel[Symbols_1._implicitTxn].updateModel(props);
2071
2093
  }
2072
2094
  /** Mark the geometry of [[GeometricModel]] as having changed, by recording an indirect change to its GeometryGuid property.
2073
2095
  * Typically the GeometryGuid changes automatically when [[GeometricElement]]s within the model are modified, but
@@ -2075,32 +2097,20 @@ function processSchemaWriteStatus(status) {
2075
2097
  * [[GeometricElement]]s that reference those definition elements in their geometry streams.
2076
2098
  * Cached [Tile]($frontend)s are only invalidated after the geometry guid of the model changes.
2077
2099
  * @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.
2078
- * @throws IModelError if unable to update the geometry guid.
2100
+ * @throws [[IModelError]] if the update fails.
2101
+ * @deprecated Use EditTxn.updateGeometryGuid instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2079
2102
  * @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
2080
2103
  */
2081
2104
  updateGeometryGuid(modelId) {
2082
- this._iModel.models[Symbols_1._cache].delete(modelId);
2083
- const error = this._iModel[Symbols_1._nativeDb].updateModelGeometryGuid(modelId);
2084
- if (error !== core_bentley_1.IModelStatus.Success)
2085
- throw new core_common_1.IModelError(error, `Error updating geometry guid for model ${modelId}`);
2105
+ this._iModel[Symbols_1._implicitTxn].updateGeometryGuid(modelId);
2086
2106
  }
2087
2107
  /** Delete one or more existing models.
2088
2108
  * @param ids The Ids of the models to be deleted
2089
- * @throws [[IModelError]]
2109
+ * @throws [[IModelError]] if deletion fails.
2110
+ * @deprecated Use EditTxn.deleteModel instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2090
2111
  */
2091
2112
  deleteModel(ids) {
2092
- core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
2093
- try {
2094
- this[Symbols_1._cache].delete(id);
2095
- this[Symbols_1._instanceKeyCache].deleteById(id);
2096
- this._iModel[Symbols_1._nativeDb].deleteModel(id);
2097
- }
2098
- catch (err) {
2099
- const error = new core_common_1.IModelError(err.errorNumber, `Error deleting model [${err.message}], id: ${id}`);
2100
- error.cause = err;
2101
- throw error;
2102
- }
2103
- });
2113
+ this._iModel[Symbols_1._implicitTxn].deleteModel(ids);
2104
2114
  }
2105
2115
  /** For each specified [[GeometricModel]], attempts to obtain the union of the volumes of all geometric elements within that model.
2106
2116
  * @param ids The Id or Ids of the [[GeometricModel]]s for which to obtain the extents.
@@ -2318,26 +2328,15 @@ function processSchemaWriteStatus(status) {
2318
2328
  /** Insert a new element into the iModel.
2319
2329
  * @param elProps The properties of the new element.
2320
2330
  * @returns The newly inserted element's Id.
2321
- * @throws [[ITwinError]] if unable to insert the element.
2331
+ * @throws [[ITwinError]] if insertion fails.
2322
2332
  * @note For convenience, the value of `elProps.id` is updated to reflect the resultant element's id.
2323
2333
  * However when `elProps.federationGuid` is not present or undefined, a new Guid will be generated and stored on the resultant element. But
2324
2334
  * the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
2325
2335
  * if you intend to continue working with it. That will ensure its values reflect the persistent state.
2336
+ * @deprecated Use EditTxn.insertElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2326
2337
  */
2327
2338
  insertElement(elProps, options) {
2328
- try {
2329
- this[Symbols_1._cache].delete({
2330
- id: elProps.id,
2331
- federationGuid: elProps.federationGuid,
2332
- code: elProps.code,
2333
- });
2334
- return elProps.id = this._iModel[Symbols_1._nativeDb].insertElement(elProps, options);
2335
- }
2336
- catch (err) {
2337
- err.message = `Error inserting element [${err.message}]`;
2338
- err.metadata = { elProps };
2339
- throw err;
2340
- }
2339
+ return this._iModel[Symbols_1._implicitTxn].insertElement(elProps, options);
2341
2340
  }
2342
2341
  /**
2343
2342
  * Update some properties of an existing element.
@@ -2348,126 +2347,33 @@ function processSchemaWriteStatus(status) {
2348
2347
  * @param elProps the properties of the element to update.
2349
2348
  * @note The values of `classFullName` and `model` *may not be changed* by this method. Further, it will permute the `elProps` object by adding or
2350
2349
  * overwriting their values to the correct values.
2351
- * @throws [[ITwinError]] if unable to update the element.
2350
+ * @throws [[ITwinError]] if update fails.
2351
+ * @deprecated Use EditTxn.updateElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2352
2352
  */
2353
2353
  updateElement(elProps) {
2354
- try {
2355
- if (elProps.id) {
2356
- this[Symbols_1._instanceKeyCache].deleteById(elProps.id);
2357
- }
2358
- else {
2359
- this[Symbols_1._instanceKeyCache].delete({
2360
- federationGuid: elProps.federationGuid,
2361
- code: elProps.code,
2362
- });
2363
- }
2364
- this[Symbols_1._cache].delete({
2365
- id: elProps.id,
2366
- federationGuid: elProps.federationGuid,
2367
- code: elProps.code,
2368
- });
2369
- this._iModel[Symbols_1._nativeDb].updateElement(elProps);
2370
- }
2371
- catch (err) {
2372
- err.message = `Error updating element [${err.message}], id: ${elProps.id}`;
2373
- err.metadata = { elProps };
2374
- throw err;
2375
- }
2354
+ this._iModel[Symbols_1._implicitTxn].updateElement(elProps);
2376
2355
  }
2377
2356
  /** Delete one or more elements from this iModel.
2378
2357
  * @param ids The set of Ids of the element(s) to be deleted
2379
2358
  * @throws [[ITwinError]]
2380
2359
  * @see deleteDefinitionElements
2360
+ * @deprecated Use EditTxn.deleteElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2381
2361
  */
2382
2362
  deleteElement(ids) {
2383
- const iModel = this._iModel;
2384
- core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
2385
- try {
2386
- this[Symbols_1._cache].delete({ id });
2387
- this[Symbols_1._instanceKeyCache].deleteById(id);
2388
- iModel[Symbols_1._nativeDb].deleteElement(id);
2389
- }
2390
- catch (err) {
2391
- err.message = `Error deleting element [${err.message}], id: ${id}`;
2392
- err.metadata = { elementId: id };
2393
- throw err;
2394
- }
2395
- });
2363
+ this._iModel[Symbols_1._implicitTxn].deleteElement(ids);
2396
2364
  }
2397
2365
  /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
2398
2366
  * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
2399
2367
  * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
2400
2368
  * This method performs those expensive checks and then calls *delete* if not referenced.
2401
- * @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
2369
+ * @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
2402
2370
  * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
2403
2371
  * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
2404
2372
  * @see deleteElement
2405
- * @beta
2373
+ * @deprecated Use EditTxn.deleteDefinitionElements instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2406
2374
  */
2407
2375
  deleteDefinitionElements(definitionElementIds) {
2408
- const usageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(definitionElementIds);
2409
- if (!usageInfo) {
2410
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Error querying for DefinitionElement usage");
2411
- }
2412
- const usedIdSet = usageInfo.usedIds ? core_bentley_1.Id64.toIdSet(usageInfo.usedIds) : new Set();
2413
- const deleteIfUnused = (ids, used) => {
2414
- if (ids) {
2415
- ids.forEach((id) => {
2416
- if (!used.has(id))
2417
- this._iModel.elements.deleteElement(id);
2418
- });
2419
- }
2420
- };
2421
- try {
2422
- this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
2423
- deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);
2424
- deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);
2425
- deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);
2426
- deleteIfUnused(usageInfo.geometryPartIds, usedIdSet);
2427
- deleteIfUnused(usageInfo.lineStyleIds, usedIdSet);
2428
- deleteIfUnused(usageInfo.renderMaterialIds, usedIdSet);
2429
- deleteIfUnused(usageInfo.subCategoryIds, usedIdSet);
2430
- deleteIfUnused(usageInfo.textureIds, usedIdSet);
2431
- deleteIfUnused(usageInfo.displayStyleIds, usedIdSet);
2432
- deleteIfUnused(usageInfo.categorySelectorIds, usedIdSet);
2433
- deleteIfUnused(usageInfo.modelSelectorIds, usedIdSet);
2434
- if (usageInfo.otherDefinitionElementIds) {
2435
- this._iModel.elements.deleteElement(usageInfo.otherDefinitionElementIds);
2436
- }
2437
- }
2438
- finally {
2439
- this._iModel[Symbols_1._nativeDb].endPurgeOperation();
2440
- }
2441
- if (usageInfo.viewDefinitionIds) {
2442
- // take another pass in case a deleted ViewDefinition was the only usage of these view-related DefinitionElements
2443
- let viewRelatedIds = [];
2444
- if (usageInfo.displayStyleIds)
2445
- viewRelatedIds = viewRelatedIds.concat(usageInfo.displayStyleIds.filter((id) => usedIdSet.has(id)));
2446
- if (usageInfo.categorySelectorIds)
2447
- viewRelatedIds = viewRelatedIds.concat(usageInfo.categorySelectorIds.filter((id) => usedIdSet.has(id)));
2448
- if (usageInfo.modelSelectorIds)
2449
- viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));
2450
- if (viewRelatedIds.length > 0) {
2451
- const viewRelatedUsageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(viewRelatedIds);
2452
- if (viewRelatedUsageInfo) {
2453
- const usedViewRelatedIdSet = viewRelatedUsageInfo.usedIds ? core_bentley_1.Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set();
2454
- try {
2455
- this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
2456
- deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);
2457
- deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);
2458
- deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);
2459
- }
2460
- finally {
2461
- this._iModel[Symbols_1._nativeDb].endPurgeOperation();
2462
- }
2463
- viewRelatedIds.forEach((id) => {
2464
- if (!usedViewRelatedIdSet.has(id))
2465
- usedIdSet.delete(id);
2466
- });
2467
- }
2468
- }
2469
- }
2470
- return usedIdSet;
2376
+ return this._iModel[Symbols_1._implicitTxn].deleteDefinitionElements(definitionElementIds);
2471
2377
  }
2472
2378
  /** Query for the child elements of the specified element.
2473
2379
  * @returns Returns an array of child element identifiers.
@@ -2658,47 +2564,26 @@ function processSchemaWriteStatus(status) {
2658
2564
  * @returns the id of the newly inserted aspect.
2659
2565
  * @note Aspect Ids may collide with element Ids, so don't put both in a container like Set or Map
2660
2566
  * use [EntityReference]($common) for that instead.
2567
+ * @deprecated Use EditTxn.insertAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2661
2568
  */
2662
2569
  insertAspect(aspectProps) {
2663
- try {
2664
- return this._iModel[Symbols_1._nativeDb].insertElementAspect(aspectProps);
2665
- }
2666
- catch (err) {
2667
- const error = new core_common_1.IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`, aspectProps);
2668
- error.cause = err;
2669
- throw error;
2670
- }
2570
+ return this._iModel[Symbols_1._implicitTxn].insertAspect(aspectProps);
2671
2571
  }
2672
2572
  /** Update an exist ElementAspect within the iModel.
2673
2573
  * @param aspectProps The properties to use to update the ElementAspect.
2674
2574
  * @throws [[IModelError]] if unable to update the ElementAspect.
2575
+ * @deprecated Use EditTxn.updateAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2675
2576
  */
2676
2577
  updateAspect(aspectProps) {
2677
- try {
2678
- this._iModel[Symbols_1._nativeDb].updateElementAspect(aspectProps);
2679
- }
2680
- catch (err) {
2681
- const error = new core_common_1.IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`, aspectProps);
2682
- error.cause = err;
2683
- throw error;
2684
- }
2578
+ this._iModel[Symbols_1._implicitTxn].updateAspect(aspectProps);
2685
2579
  }
2686
2580
  /** Delete one or more ElementAspects from this iModel.
2687
2581
  * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
2688
2582
  * @throws [[IModelError]] if unable to delete the ElementAspect.
2583
+ * @deprecated Use EditTxn.deleteAspect instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2689
2584
  */
2690
2585
  deleteAspect(aspectInstanceIds) {
2691
- const iModel = this._iModel;
2692
- core_bentley_1.Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {
2693
- try {
2694
- iModel[Symbols_1._nativeDb].deleteElementAspect(aspectInstanceId);
2695
- }
2696
- catch (err) {
2697
- const error = new core_common_1.IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
2698
- error.cause = err;
2699
- throw error;
2700
- }
2701
- });
2586
+ this._iModel[Symbols_1._implicitTxn].deleteAspect(aspectInstanceIds);
2702
2587
  }
2703
2588
  }
2704
2589
  IModelDb.Elements = Elements;
@@ -2741,11 +2626,11 @@ function processSchemaWriteStatus(status) {
2741
2626
  this._viewStore.container.accessToken = accessToken;
2742
2627
  return this._viewStore;
2743
2628
  }
2744
- /** @beta */
2629
+ /**
2630
+ * @beta @deprecated Use EditTxn.saveDefaultViewStore instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
2631
+ */
2745
2632
  saveDefaultViewStore(arg) {
2746
- const props = { baseUri: arg.baseUri, containerId: arg.containerId, storageType: arg.storageType }; // sanitize to only known properties
2747
- this._iModel.saveFileProperty(Views.viewStoreProperty, JSON.stringify(props));
2748
- this._iModel.saveChanges("update default ViewStore");
2633
+ this._iModel[Symbols_1._implicitTxn].saveDefaultViewStore(arg);
2749
2634
  }
2750
2635
  /** Query for the array of ViewDefinitionProps of the specified class and matching the specified IsPrivate setting.
2751
2636
  * @param className Query for view definitions of this class.
@@ -2888,7 +2773,7 @@ function processSchemaWriteStatus(status) {
2888
2773
  blob32[0] = core_bentley_1.Id64.getLowerUint32(viewId);
2889
2774
  blob32[1] = core_bentley_1.Id64.getUpperUint32(viewId);
2890
2775
  const blob8 = new Uint8Array(blob32.buffer);
2891
- this._iModel.saveFileProperty(spec, undefined, blob8);
2776
+ this._iModel[Symbols_1._implicitTxn].saveFileProperty(spec, undefined, blob8);
2892
2777
  }
2893
2778
  }
2894
2779
  IModelDb.Views = Views;
@@ -3046,7 +2931,7 @@ class BriefcaseDb extends IModelDb {
3046
2931
  }
3047
2932
  // attempt to release locks must happen after changes are undone successfully
3048
2933
  core_bentley_1.Logger.logInfo(loggerCategory, "Releasing locks after discarding changes");
3049
- await this.locks.releaseAllLocks();
2934
+ await this.locks.abandonAllLocks();
3050
2935
  }
3051
2936
  /**
3052
2937
  * The Guid that identifies the *context* that owns this iModel.
@@ -3092,7 +2977,7 @@ class BriefcaseDb extends IModelDb {
3092
2977
  executeUpgrade();
3093
2978
  await withBriefcaseDb(briefcase, async (db) => {
3094
2979
  db[Symbols_1._nativeDb].schemaSyncPush(schemaSyncDbUri);
3095
- db.saveChanges();
2980
+ db[Symbols_1._nativeDb].saveChanges();
3096
2981
  });
3097
2982
  syncAccess.synchronizeWithCloud();
3098
2983
  });
@@ -3457,7 +3342,7 @@ class BriefcaseDb extends IModelDb {
3457
3342
  }
3458
3343
  try {
3459
3344
  await BriefcaseManager_1.BriefcaseManager.revertTimelineChanges(this, arg);
3460
- this.saveChanges("Revert changes");
3345
+ this[Symbols_1._nativeDb].saveChanges("Revert changes");
3461
3346
  if (!arg.description) {
3462
3347
  arg.description = `Reverted changes from ${this.changeset.index} to ${arg.toIndex}${arg.skipSchemaChanges ? " (schema changes skipped)" : ""}`;
3463
3348
  }
@@ -3480,7 +3365,7 @@ class BriefcaseDb extends IModelDb {
3480
3365
  }
3481
3366
  }
3482
3367
  finally {
3483
- this.abandonChanges();
3368
+ this[Symbols_1._nativeDb].abandonChanges();
3484
3369
  }
3485
3370
  }
3486
3371
  /**
@@ -3510,7 +3395,7 @@ class BriefcaseDb extends IModelDb {
3510
3395
  }
3511
3396
  close(options) {
3512
3397
  if (this.isBriefcase && this.isOpen && !this.isReadonly && this.txns.rebaser.inProgress()) {
3513
- this.abandonChanges();
3398
+ this[Symbols_1._nativeDb].abandonChanges();
3514
3399
  }
3515
3400
  super.close(options);
3516
3401
  this.onClosed.raiseEvent();
@@ -3728,7 +3613,7 @@ class SnapshotDb extends IModelDb {
3728
3613
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.SQLiteError, "Error creating class views");
3729
3614
  }
3730
3615
  else {
3731
- this.saveChanges();
3616
+ this[Symbols_1._nativeDb].saveChanges();
3732
3617
  }
3733
3618
  }
3734
3619
  }
@@ -3759,15 +3644,16 @@ class StandaloneDb extends BriefcaseDb {
3759
3644
  }
3760
3645
  /**
3761
3646
  * @internal
3762
- * Called during close of the iModel. It will delete any pending txns, analyze and vacuum the iModel.
3647
+ * Called during close of the StandaloneDb. It will delete any pending txns.
3763
3648
  */
3764
3649
  beforeClose() {
3765
3650
  super.beforeClose();
3766
- if (!this.isReadonly && this.txns.hasLocalChanges) {
3767
- this.saveChanges();
3768
- this.txns.deleteAllTxns();
3769
- this.saveChanges();
3770
- }
3651
+ if (this.isReadonly || !this.txns.hasLocalChanges)
3652
+ return;
3653
+ const nativeDb = this[Symbols_1._nativeDb];
3654
+ nativeDb.saveChanges();
3655
+ nativeDb.deleteAllTxns();
3656
+ nativeDb.saveChanges();
3771
3657
  }
3772
3658
  static tryFindByKey(key) {
3773
3659
  const db = super.tryFindByKey(key);
@@ -3823,7 +3709,7 @@ class StandaloneDb extends BriefcaseDb {
3823
3709
  if (core_bentley_1.BentleyStatus.SUCCESS !== result)
3824
3710
  throw new core_common_1.IModelError(result, "Error creating class views");
3825
3711
  else
3826
- this.saveChanges();
3712
+ this[Symbols_1._nativeDb].saveChanges();
3827
3713
  }
3828
3714
  /** Open a standalone iModel file.
3829
3715
  * @param filePath The path of the standalone iModel file.