@itwin/core-backend 5.9.0-dev.4 → 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
@@ -4,6 +4,7 @@
4
4
  import { Id64String } from "@itwin/core-bentley";
5
5
  import { _implementationProhibited, _verifyChannel } from "./internal/Symbols";
6
6
  import { IModelDb } from "./IModelDb";
7
+ import type { EditTxn } from "./EditTxn";
7
8
  /** The key for a channel. Used for "allowed channels" in [[ChannelControl]]
8
9
  * @beta
9
10
  */
@@ -59,10 +60,38 @@ export interface ChannelControl {
59
60
  makeChannelRoot(args: {
60
61
  elementId: Id64String;
61
62
  channelKey: ChannelKey;
63
+ /** The transaction to use for the operation. */
64
+ txn: EditTxn;
62
65
  }): void;
66
+ /** Make an existing element a new Channel root.
67
+ * @throws if the element is already in a channel different than the shared channel, or if
68
+ * there is already another channelRoot element for the specified channelKey
69
+ * @deprecated Use [[makeChannelRoot]] and supply `txn`.
70
+ */
71
+ makeChannelRoot(args: {
72
+ elementId: Id64String;
73
+ channelKey: ChannelKey;
74
+ }): void;
75
+ /** Insert a new Subject element that is a Channel Root in this iModel.
76
+ * @returns the ElementId of the new Subject element.
77
+ * @note if the parentSubject element is already in a channel, this will add the Subject element and then throw an error without making it a Channel root.
78
+ */
79
+ insertChannelSubject(args: {
80
+ /** The name of the new Subject element */
81
+ subjectName: string;
82
+ /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/
83
+ channelKey: ChannelKey;
84
+ /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */
85
+ parentSubjectId?: Id64String;
86
+ /** Optional description for new Subject. */
87
+ description?: string;
88
+ /** The EditTxn to use for the operation. */
89
+ txn: EditTxn;
90
+ }): Id64String;
63
91
  /** Insert a new Subject element that is a Channel Root in this iModel.
64
92
  * @returns the ElementId of the new Subject element.
65
93
  * @note if the parentSubject element is already in a channel, this will add the Subject element and then throw an error without making it a Channel root.
94
+ * @deprecated Use [[insertChannelSubject]] and supply `txn`.
66
95
  */
67
96
  insertChannelSubject(args: {
68
97
  /** The name of the new Subject element */
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelControl.d.ts","sourceRoot":"","sources":["../../src/ChannelControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG;IAC5C,MAAM,EAAE,QAAQ,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,IAAI,CAAC,EAAE,CAAC,CAAC;CACV;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,gBAAgB;IAChB,QAAQ,CAAC,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAE9C;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD;;OAEG;IACH,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IACnD;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC;IACjD;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,UAAU,CAAC;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ACrB,4CAA4C;QAC5C,GAAG,EAAE,OAAO,CAAC;KACd,GAAG,UAAU,CAAC;IACf;;;;OAIG;IACH,oBAAoB,CAAC,IAAI,EAAE;QACzB,0CAA0C;QAC1C,WAAW,EAAE,MAAM,CAAC;QACpB,kGAAkG;QAClG,UAAU,EAAE,UAAU,CAAC;QACvB,oFAAoF;QACpF,eAAe,CAAC,EAAE,UAAU,CAAC;QAC7B,4CAA4C;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,UAAU,CAAC;IACf;;;;;OAKG;IACH,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAEjE,gBAAgB;IAChB,CAAC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IAEhD;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7F;AAED,YAAY;AACZ,yBAAiB,cAAc,CAAC;IAC9B,wGAAwG;IACjG,MAAM,iBAAiB,WAAW,CAAC;CAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelControl.js","sourceRoot":"","sources":["../../src/ChannelControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,gDAA+E;AA4F/E,YAAY;AACZ,IAAiB,cAAc,CAG9B;AAHD,WAAiB,cAAc;IAC7B,wGAAwG;IAC3F,gCAAiB,GAAG,QAAQ,CAAC;AAC5C,CAAC,EAHgB,cAAc,8BAAd,cAAc,QAG9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { _implementationProhibited, _verifyChannel } from \"./internal/Symbols\";\nimport { IModelDb } from \"./IModelDb\";\n\n/** The key for a channel. Used for \"allowed channels\" in [[ChannelControl]]\n * @beta\n */\nexport type ChannelKey = string;\n\n/**\n * Context provided to the channel upgrade callback.\n * @beta\n */\nexport interface ChannelUpgradeContext<T = any> {\n iModel: IModelDb;\n channelKey: string;\n fromVersion: string;\n toVersion: string;\n /** Optional data to be used during the upgrade */\n data?: T;\n}\n\n/**\n * Options for upgrading a channel before schema import.\n * The framework will automatically populate the context with iModel and data.\n * @beta\n */\nexport interface ChannelUpgradeOptions<T = any> {\n channelKey: string;\n fromVersion: string;\n toVersion: string;\n callback: (context: ChannelUpgradeContext<T>) => Promise<void>;\n}\n\n/**\n * Controls which channels of an iModel are permitted for write operations. An implementation of this interface is\n * available via [[IModelDb.channels]].\n * @see [Working With Channels]($docs/learning/backend/Channel.md) for details\n * @beta\n */\nexport interface ChannelControl {\n /** @internal */\n readonly [_implementationProhibited]: unknown;\n\n /** Add a new channel to the list of allowed channels of the [[IModelDb]] for this session.\n * @param channelKey The key for the channel to become editable in this session.\n */\n addAllowedChannel(channelKey: ChannelKey): void;\n /** Remove a channel from the list of allowed channels of the [[IModelDb]] for this session.\n * @param channelKey The key of the channel that should no longer be editable in this session.\n */\n removeAllowedChannel(channelKey: ChannelKey): void;\n /** Get the channelKey of the channel for an element by ElementId.\n * @throws if the element does not exist\n */\n getChannelKey(elementId: Id64String): ChannelKey;\n /** Make an existing element a new Channel root.\n * @throws if the element is already in a channel different than the shared channel, or if\n * there is already another channelRoot element for the specified channelKey\n */\n makeChannelRoot(args: { elementId: Id64String, channelKey: ChannelKey }): void;\n /** Insert a new Subject element that is a Channel Root in this iModel.\n * @returns the ElementId of the new Subject element.\n * @note if the parentSubject element is already in a channel, this will add the Subject element and then throw an error without making it a Channel root.\n */\n insertChannelSubject(args: {\n /** The name of the new Subject element */\n subjectName: string;\n /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/\n channelKey: ChannelKey;\n /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */\n parentSubjectId?: Id64String;\n /** Optional description for new Subject. */\n description?: string;\n }): Id64String;\n /**\n * Queries for the element Id acting as the ChannelRoot for a given channelKey, if any\n * @param channelKey The key for the channel to query for\n * @returns The element Id of the ChannelRoot element of the specified Channel key, or undefined if\n * there is no ChannelRoot for it\n */\n queryChannelRoot(channelKey: ChannelKey): Id64String | undefined;\n\n /** @internal */\n [_verifyChannel]: (modelId: Id64String) => void;\n\n /**\n * Upgrade a channel to a new version.\n * @beta\n */\n upgradeChannel(options: ChannelUpgradeOptions, iModel: IModelDb, data?: any): Promise<void>;\n}\n\n/** @beta */\nexport namespace ChannelControl {\n /** the name of the special \"shared\" channel holding information that is editable by any application. */\n export const sharedChannelName = \"shared\";\n}\n\n"]}
1
+ {"version":3,"file":"ChannelControl.js","sourceRoot":"","sources":["../../src/ChannelControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,gDAA+E;AAyH/E,YAAY;AACZ,IAAiB,cAAc,CAG9B;AAHD,WAAiB,cAAc;IAC7B,wGAAwG;IAC3F,gCAAiB,GAAG,QAAQ,CAAC;AAC5C,CAAC,EAHgB,cAAc,8BAAd,cAAc,QAG9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { _implementationProhibited, _verifyChannel } from \"./internal/Symbols\";\nimport { IModelDb } from \"./IModelDb\";\nimport type { EditTxn } from \"./EditTxn\";\n\n/** The key for a channel. Used for \"allowed channels\" in [[ChannelControl]]\n * @beta\n */\nexport type ChannelKey = string;\n\n/**\n * Context provided to the channel upgrade callback.\n * @beta\n */\nexport interface ChannelUpgradeContext<T = any> {\n iModel: IModelDb;\n channelKey: string;\n fromVersion: string;\n toVersion: string;\n /** Optional data to be used during the upgrade */\n data?: T;\n}\n\n/**\n * Options for upgrading a channel before schema import.\n * The framework will automatically populate the context with iModel and data.\n * @beta\n */\nexport interface ChannelUpgradeOptions<T = any> {\n channelKey: string;\n fromVersion: string;\n toVersion: string;\n callback: (context: ChannelUpgradeContext<T>) => Promise<void>;\n}\n\n/**\n * Controls which channels of an iModel are permitted for write operations. An implementation of this interface is\n * available via [[IModelDb.channels]].\n * @see [Working With Channels]($docs/learning/backend/Channel.md) for details\n * @beta\n */\nexport interface ChannelControl {\n /** @internal */\n readonly [_implementationProhibited]: unknown;\n\n /** Add a new channel to the list of allowed channels of the [[IModelDb]] for this session.\n * @param channelKey The key for the channel to become editable in this session.\n */\n addAllowedChannel(channelKey: ChannelKey): void;\n /** Remove a channel from the list of allowed channels of the [[IModelDb]] for this session.\n * @param channelKey The key of the channel that should no longer be editable in this session.\n */\n removeAllowedChannel(channelKey: ChannelKey): void;\n /** Get the channelKey of the channel for an element by ElementId.\n * @throws if the element does not exist\n */\n getChannelKey(elementId: Id64String): ChannelKey;\n /** Make an existing element a new Channel root.\n * @throws if the element is already in a channel different than the shared channel, or if\n * there is already another channelRoot element for the specified channelKey\n */\n makeChannelRoot(args: {\n elementId: Id64String;\n channelKey: ChannelKey;\n /** The transaction to use for the operation. */\n txn: EditTxn;\n }): void;\n /** Make an existing element a new Channel root.\n * @throws if the element is already in a channel different than the shared channel, or if\n * there is already another channelRoot element for the specified channelKey\n * @deprecated Use [[makeChannelRoot]] and supply `txn`.\n */\n makeChannelRoot(args: { elementId: Id64String, channelKey: ChannelKey }): void;\n /** Insert a new Subject element that is a Channel Root in this iModel.\n * @returns the ElementId of the new Subject element.\n * @note if the parentSubject element is already in a channel, this will add the Subject element and then throw an error without making it a Channel root.\n */\n insertChannelSubject(args: {\n /** The name of the new Subject element */\n subjectName: string;\n /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/\n channelKey: ChannelKey;\n /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */\n parentSubjectId?: Id64String;\n /** Optional description for new Subject. */\n description?: string;\n /** The EditTxn to use for the operation. */\n txn: EditTxn;\n }): Id64String;\n /** Insert a new Subject element that is a Channel Root in this iModel.\n * @returns the ElementId of the new Subject element.\n * @note if the parentSubject element is already in a channel, this will add the Subject element and then throw an error without making it a Channel root.\n * @deprecated Use [[insertChannelSubject]] and supply `txn`.\n */\n insertChannelSubject(args: {\n /** The name of the new Subject element */\n subjectName: string;\n /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/\n channelKey: ChannelKey;\n /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */\n parentSubjectId?: Id64String;\n /** Optional description for new Subject. */\n description?: string;\n }): Id64String;\n /**\n * Queries for the element Id acting as the ChannelRoot for a given channelKey, if any\n * @param channelKey The key for the channel to query for\n * @returns The element Id of the ChannelRoot element of the specified Channel key, or undefined if\n * there is no ChannelRoot for it\n */\n queryChannelRoot(channelKey: ChannelKey): Id64String | undefined;\n\n /** @internal */\n [_verifyChannel]: (modelId: Id64String) => void;\n\n /**\n * Upgrade a channel to a new version.\n * @beta\n */\n upgradeChannel(options: ChannelUpgradeOptions, iModel: IModelDb, data?: any): Promise<void>;\n}\n\n/** @beta */\nexport namespace ChannelControl {\n /** the name of the special \"shared\" channel holding information that is editable by any application. */\n export const sharedChannelName = \"shared\";\n}\n\n"]}
@@ -243,7 +243,7 @@ class CheckpointManager {
243
243
  }
244
244
  finally {
245
245
  core_bentley_1.Logger.setLevel(imodeljs_native_1.NativeLoggerCategory.SQLite, prevLogLevel); // Set logging to what it was before we started applying changesets.
246
- db.saveChanges();
246
+ db[Symbols_1._nativeDb].saveChanges();
247
247
  db.close();
248
248
  }
249
249
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CheckpointManager.js","sourceRoot":"","sources":["../../src/CheckpointManager.ts"],"names":[],"mappings":";AAAA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E,CAAC,EAAE,CAAC;QAChI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO;YACV,uBAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAElC,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAwB;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,uBAAU,CAAC,oBAAU,CAAC,CAAC,kBAAkB,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEjJ,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE;gBACT,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,MAAM,uBAAU,CAAC,oBAAU,CAAC,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;aAC7I;SACF,CAAC;IACJ,CAAC;;AA/IH,8CAgJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\n// cspell:ignore BLOCKCACHE\n\nimport * as path from \"path\";\nimport { NativeLoggerCategory } from \"@bentley/imodeljs-native\";\nimport { AccessToken, BeEvent, ChangeSetStatus, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, OpenMode, StopWatch } from \"@itwin/core-bentley\";\nimport {\n BriefcaseIdValue, ChangesetId, ChangesetIdWithIndex, ChangesetIndexAndId, IModelError, IModelVersion, LocalDirName, LocalFileName, OpenCheckpointArgs,\n} from \"@itwin/core-common\";\nimport { V2CheckpointAccessProps } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SnapshotDb, TokenArg } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _hubAccess, _mockCheckpoint, _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/** @internal */\nexport interface MockCheckpoint {\n mockAttach(checkpoint: CheckpointProps): string;\n mockDownload(_request: DownloadRequest): void;\n}\n\n/**\n * Properties of a checkpoint\n * @public\n */\nexport interface CheckpointProps extends TokenArg {\n readonly expectV2?: boolean;\n\n /** iTwin that the iModel belongs to */\n readonly iTwinId: GuidString;\n\n /** Id of the iModel */\n readonly iModelId: GuidString;\n\n /** changeset for the checkpoint */\n readonly changeset: ChangesetIdWithIndex;\n\n /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */\n readonly allowPreceding?: boolean;\n\n /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */\n readonly reattachSafetySeconds?: number;\n}\n\n/** Return value from [[ProgressFunction]].\n * @public\n */\nexport enum ProgressStatus {\n /** Continue download. */\n Continue = 0,\n /** Abort download. */\n Abort = 1,\n}\n\n/** Called to show progress during a download. If this function returns non-zero, the download is aborted.\n * @public\n */\nexport type ProgressFunction = (loaded: number, total: number) => ProgressStatus;\n\n/** The parameters that specify a request to download a checkpoint file from iModelHub.\n * @internal\n */\nexport interface DownloadRequest {\n /** name of local file to hold the downloaded data. */\n localFile: LocalFileName;\n\n /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names,\n * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name.\n * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes.\n */\n readonly aliasFiles?: ReadonlyArray<string>;\n\n /** Properties of the checkpoint to be downloaded */\n readonly checkpoint: CheckpointProps;\n\n /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this\n * function returns a non-zero value, the download is aborted.\n */\n readonly onProgress?: ProgressFunction;\n}\n\n/** @internal */\nexport interface DownloadJob {\n request: DownloadRequest;\n promise?: Promise<any>;\n}\n\n/** @internal */\nexport class Downloads {\n private static _active = new Map<string, DownloadJob>();\n\n private static async process<T>(job: DownloadJob, fn: (job: DownloadJob) => Promise<T>) {\n const jobName = job.request.localFile; // save this, it can change inside call to `fn`!\n this._active.set(jobName, job);\n try {\n return await fn(job);\n } finally {\n this._active.delete(jobName);\n }\n }\n\n public static isInProgress(pathName: LocalFileName): DownloadJob | undefined {\n return this._active.get(pathName);\n }\n\n public static async download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>) {\n const pathName = request.localFile;\n let job = this.isInProgress(pathName);\n if (undefined !== job)\n return job.promise;\n\n IModelJsFs.recursiveMkDirSync(path.dirname(pathName));\n job = { request };\n return job.promise = this.process(job, downloadFn);\n }\n}\n\n/**\n * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them.\n * @internal\n*/\nexport class V2CheckpointManager {\n public static readonly cloudCacheName = \"Checkpoints\";\n private static _cloudCache?: CloudSqlite.CloudCache;\n private static containers = new Map<string, CloudSqlite.CloudContainer>();\n\n /** used by HubMock\n * @internal\n */\n public static [_mockCheckpoint]?: MockCheckpoint;\n\n\n public static getFolder(): LocalDirName {\n const cloudCachePath = path.join(BriefcaseManager.cacheDir, V2CheckpointManager.cloudCacheName);\n if (!(IModelJsFs.existsSync(cloudCachePath))) {\n IModelJsFs.recursiveMkDirSync(cloudCachePath);\n }\n return cloudCachePath;\n }\n\n /* only used by tests that reset the state of the v2CheckpointManager. all dbs should be closed before calling this function. */\n public static cleanup(): void {\n for (const [_, value] of this.containers.entries()) {\n if (value.isConnected)\n value.disconnect({ detach: true });\n }\n\n CloudSqlite.CloudCaches.dropCache(this.cloudCacheName)?.destroy();\n this._cloudCache = undefined;\n this.containers.clear();\n }\n\n private static get cloudCache(): CloudSqlite.CloudCache {\n if (!this._cloudCache) {\n let cacheDir: string | undefined = process.env.CHECKPOINT_CACHE_DIR ?? this.getFolder();\n // See if there is a daemon running, otherwise use profile directory for cloudCache\n if (!(IModelJsFs.existsSync(path.join(cacheDir, \"portnumber.bcv\"))))\n cacheDir = undefined; // no daemon running, use profile directory\n\n this._cloudCache = CloudSqlite.CloudCaches.getCache({ cacheName: this.cloudCacheName, cacheDir, cacheSize: \"50G\" });\n }\n return this._cloudCache;\n }\n\n /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */\n private static toCloudContainerProps(from: V2CheckpointAccessProps): CloudSqlite.ContainerAccessProps {\n return { ...from, baseUri: `https://${from.accountName}.blob.core.windows.net`, accessToken: from.sasToken, storageType: \"azure\" };\n }\n\n private static getContainer(v2Props: V2CheckpointAccessProps, checkpoint: CheckpointProps) {\n let container = this.containers.get(v2Props.containerId);\n if (undefined === container) {\n let tokenFn: ((args: CloudSqlite.RequestTokenArgs) => Promise<AccessToken>) | undefined;\n let tokenRefreshSeconds: number | undefined = -1;\n // from Rpc, the accessToken in the checkpoint request is from the current user. It is used to request the sasToken for the container and\n // the sasToken is checked for refresh (before it expires) on every Rpc request using that user's accessToken. For Ipc, the\n // accessToken in the checkpoint request is undefined, and the sasToken is requested by IModelHost.getAccessToken(). It is refreshed on a timer.\n if (undefined === checkpoint.accessToken) {\n tokenFn = async () => (await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint))?.sasToken ?? \"\";\n tokenRefreshSeconds = undefined;\n }\n container = CloudSqlite.createCloudContainer({ ...this.toCloudContainerProps(v2Props), tokenRefreshSeconds, logId: process.env.POD_NAME, tokenFn });\n this.containers.set(v2Props.containerId, container);\n }\n return container;\n }\n\n public static async attach(checkpoint: CheckpointProps): Promise<{ dbName: string, container: CloudSqlite.CloudContainer | undefined }> {\n if (this[_mockCheckpoint]) // used by HubMock\n return { dbName: this[_mockCheckpoint].mockAttach(checkpoint), container: undefined };\n\n let v2props: V2CheckpointAccessProps | undefined;\n try {\n v2props = await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint);\n if (!v2props)\n throw new Error(\"no checkpoint\");\n } catch (err: any) {\n throw new IModelError(IModelStatus.NotFound, `V2 checkpoint not found: err: ${err.message}`);\n }\n\n try {\n const container = this.getContainer(v2props, checkpoint);\n const dbName = v2props.dbName;\n // Use the new token from the recently queried v2 checkpoint just incase the one we currently have is expired.\n container.accessToken = v2props.sasToken;\n if (!container.isConnected)\n container.connect(this.cloudCache);\n container.checkForChanges();\n const dbStats = container.queryDatabase(dbName);\n if (IModelHost.appWorkspace.settings.getBoolean(\"Checkpoints/prefetch\", false)) {\n const getPrefetchConfig = (name: string, defaultVal: number) => IModelHost.appWorkspace.settings.getNumber(`Checkpoints/prefetch/${name}`, defaultVal);\n const minRequests = getPrefetchConfig(\"minRequests\", 3);\n const maxRequests = getPrefetchConfig(\"maxRequests\", 6);\n const timeout = getPrefetchConfig(\"timeout\", 100);\n const maxBlocks = getPrefetchConfig(\"maxBlocks\", 500); // default size of 2GB. Assumes a checkpoint block size of 4MB.\n if (dbStats?.totalBlocks !== undefined && dbStats.totalBlocks <= maxBlocks && dbStats.nPrefetch === 0) {\n const logPrefetch = async (prefetch: CloudSqlite.CloudPrefetch) => {\n const stopwatch = new StopWatch(`[${container.containerId}/${dbName}]`, true);\n Logger.logInfo(loggerCategory, `Starting prefetch of ${stopwatch.description}`, { minRequests, maxRequests, timeout });\n const done = await prefetch.promise;\n Logger.logInfo(loggerCategory, `Prefetch of ${stopwatch.description} complete=${done} (${stopwatch.elapsedSeconds} seconds)`, { minRequests, maxRequests, timeout });\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n logPrefetch(CloudSqlite.startCloudPrefetch(container, dbName, { minRequests, nRequests: maxRequests, timeout }));\n } else {\n Logger.logInfo(loggerCategory, `Skipping prefetch due to size limits or ongoing prefetch.`, { maxBlocks, numPrefetches: dbStats?.nPrefetch, totalBlocksInDb: dbStats?.totalBlocks, v2props });\n }\n }\n return { dbName, container };\n } catch (e: any) {\n const error = `Cloud cache connect failed: ${e.message}`;\n if (checkpoint.expectV2)\n Logger.logError(loggerCategory, error);\n\n throw new IModelError(e.errorNumber, error);\n }\n }\n\n /** @internal */\n private static async performDownload(job: DownloadJob): Promise<ChangesetId> {\n const request = job.request;\n if (this[_mockCheckpoint])\n this[_mockCheckpoint].mockDownload(request);\n else {\n const v2props: V2CheckpointAccessProps | undefined = await IModelHost[_hubAccess].queryV2Checkpoint({ ...request.checkpoint, allowPreceding: true });\n if (!v2props)\n throw new IModelError(IModelStatus.NotFound, \"V2 checkpoint not found\");\n\n CheckpointManager.onDownloadV2.raiseEvent(job);\n const container = CloudSqlite.createCloudContainer(this.toCloudContainerProps(v2props));\n await CloudSqlite.transferDb(\"download\", container, { dbName: v2props.dbName, localFileName: request.localFile, onProgress: request.onProgress });\n }\n return request.checkpoint.changeset.id;\n }\n\n /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline.\n * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will\n * be the same as the requested changesetId or the most recent checkpoint before it.)\n */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId> {\n return Downloads.download(request, async (job: DownloadJob) => this.performDownload(job));\n }\n}\n\n/** @internal */\nexport class CheckpointManager {\n public static readonly onDownloadV2 = new BeEvent<(job: DownloadJob) => void>();\n public static getKey(checkpoint: CheckpointProps) { return `${checkpoint.iModelId}:${checkpoint.changeset.id}`; }\n\n private static async doDownload(request: DownloadRequest): Promise<ChangesetId> {\n // first see if there's a V2 checkpoint available.\n const stopwatch = new StopWatch(`[${request.checkpoint.changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting download of V2 checkpoint with id ${stopwatch.description}`);\n const changesetId = await V2CheckpointManager.downloadCheckpoint(request);\n Logger.logInfo(loggerCategory, `Downloaded V2 checkpoint with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n if (changesetId !== request.checkpoint.changeset.id)\n Logger.logInfo(loggerCategory, `Downloaded previous v2 checkpoint because requested checkpoint not found.`, { requestedChangesetId: request.checkpoint.changeset.id, iModelId: request.checkpoint.iModelId, changesetId, iTwinId: request.checkpoint.iTwinId });\n else\n Logger.logInfo(loggerCategory, `Downloaded v2 checkpoint.`, { iModelId: request.checkpoint.iModelId, changesetId: request.checkpoint.changeset.id, iTwinId: request.checkpoint.iTwinId });\n return changesetId;\n }\n\n public static async updateToRequestedVersion(request: DownloadRequest) {\n const checkpoint = request.checkpoint;\n const targetFile = request.localFile;\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId, changeset: checkpoint.changeset };\n try {\n // Open checkpoint for write\n const prevLogLevel = Logger.getLevel(NativeLoggerCategory.SQLite) ?? LogLevel.Error; // Get log level before we set it to None.\n Logger.setLevel(NativeLoggerCategory.SQLite, LogLevel.None); // Ignores noisy error messages when applying changesets.\n const db = SnapshotDb.openForApplyChangesets(targetFile);\n const nativeDb = db[_nativeDb];\n try {\n\n if (nativeDb.hasPendingTxns()) {\n Logger.logWarning(loggerCategory, \"Checkpoint with Txns found - deleting them\", () => traceInfo);\n nativeDb.deleteAllTxns();\n }\n\n if (nativeDb.getBriefcaseId() !== BriefcaseIdValue.Unassigned)\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);\n\n CheckpointManager.validateCheckpointGuids(checkpoint, db);\n // Apply change sets if necessary\n const currentChangeset: Mutable<ChangesetIndexAndId> = nativeDb.getCurrentChangeset();\n if (currentChangeset.id !== checkpoint.changeset.id) {\n const accessToken = checkpoint.accessToken;\n const toIndex = checkpoint.changeset.index ??\n (await IModelHost[_hubAccess].getChangesetFromVersion({ accessToken, iModelId: checkpoint.iModelId, version: IModelVersion.asOfChangeSet(checkpoint.changeset.id) })).index;\n await BriefcaseManager.pullAndApplyChangesets(db, { accessToken, toIndex });\n } else {\n // make sure the parent changeset index is saved in the file - old versions didn't have it.\n currentChangeset.index = checkpoint.changeset.index!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(currentChangeset));\n }\n } finally {\n Logger.setLevel(NativeLoggerCategory.SQLite, prevLogLevel); // Set logging to what it was before we started applying changesets.\n db.saveChanges();\n db.close();\n }\n } catch (error: any) {\n\n Logger.logError(loggerCategory, \"Error downloading checkpoint - deleting it\", () => traceInfo);\n IModelJsFs.removeSync(targetFile);\n\n if (error.errorNumber === ChangeSetStatus.CorruptedChangeStream || error.errorNumber === ChangeSetStatus.InvalidId || error.errorNumber === ChangeSetStatus.InvalidVersion) {\n Logger.logError(loggerCategory, \"Detected potential corruption of change sets. Deleting them to enable retries\", () => traceInfo);\n BriefcaseManager.deleteChangeSetsFromLocalDisk(checkpoint.iModelId);\n }\n throw error;\n }\n }\n\n /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<void> {\n if (this.verifyCheckpoint(request.checkpoint, request.localFile))\n return;\n\n if (request.aliasFiles) {\n for (const alias of request.aliasFiles) {\n if (this.verifyCheckpoint(request.checkpoint, alias)) {\n request.localFile = alias;\n return;\n }\n }\n }\n\n await this.doDownload(request);\n return this.updateToRequestedVersion(request);\n }\n\n /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */\n public static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb) {\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId };\n\n const nativeDb = snapshotDb[_nativeDb];\n const dbChangeset = nativeDb.getCurrentChangeset();\n const iModelId = Guid.normalize(nativeDb.getIModelId());\n if (iModelId !== Guid.normalize(checkpoint.iModelId)) {\n if (nativeDb.isReadonly())\n throw new IModelError(IModelStatus.ValidationFailed, \"iModelId is not properly set up in the checkpoint\");\n\n Logger.logWarning(loggerCategory, \"iModelId is not properly set up in the checkpoint. Updated checkpoint to the correct iModelId.\", () => ({ ...traceInfo, dbGuid: iModelId }));\n const iModelIdNormalized = Guid.normalize(checkpoint.iModelId);\n nativeDb.setIModelId(iModelIdNormalized);\n (snapshotDb as any)._iModelId = iModelIdNormalized;\n // Required to reset the ChangeSetId because setDbGuid clears the value.\n nativeDb.saveLocalValue(\"ParentChangeSetId\", dbChangeset.id);\n if (undefined !== dbChangeset.index)\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(dbChangeset));\n }\n\n const iTwinId = Guid.normalize(nativeDb.getITwinId());\n if (iTwinId !== Guid.normalize(checkpoint.iTwinId))\n throw new IModelError(IModelStatus.ValidationFailed, \"iTwinId was not properly set up in the checkpoint\");\n }\n\n /** @returns true if the file is the checkpoint requested */\n public static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean {\n if (!IModelJsFs.existsSync(fileName))\n return false;\n\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.Readonly);\n } catch {\n return false;\n }\n\n const isValid = checkpoint.iModelId === nativeDb.getIModelId() && checkpoint.changeset.id === nativeDb.getCurrentChangeset().id;\n nativeDb.closeFile();\n if (!isValid)\n IModelJsFs.removeSync(fileName);\n\n return isValid;\n }\n\n public static async toCheckpointProps(args: OpenCheckpointArgs): Promise<CheckpointProps> {\n const changeset = args.changeset ?? await IModelHost[_hubAccess].getLatestChangeset({ ...args, accessToken: await IModelHost.getAccessToken() });\n\n return {\n iModelId: args.iModelId,\n iTwinId: args.iTwinId,\n changeset: {\n index: changeset.index,\n id: changeset.id ?? (await IModelHost[_hubAccess].queryChangeset({ ...args, changeset, accessToken: await IModelHost.getAccessToken() })).id,\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"CheckpointManager.js","sourceRoot":"","sources":["../../src/CheckpointManager.ts"],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,EAAE,KAAK,QAAQ,CAAC,mBAAmB,EAAE,CAAC,EAAE,CAAC;QAChI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO;YACV,uBAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAElC,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAwB;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,uBAAU,CAAC,oBAAU,CAAC,CAAC,kBAAkB,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEjJ,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE;gBACT,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,MAAM,uBAAU,CAAC,oBAAU,CAAC,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;aAC7I;SACF,CAAC;IACJ,CAAC;;AA/IH,8CAgJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\n// cspell:ignore BLOCKCACHE\n\nimport * as path from \"path\";\nimport { NativeLoggerCategory } from \"@bentley/imodeljs-native\";\nimport { AccessToken, BeEvent, ChangeSetStatus, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, OpenMode, StopWatch } from \"@itwin/core-bentley\";\nimport {\n BriefcaseIdValue, ChangesetId, ChangesetIdWithIndex, ChangesetIndexAndId, IModelError, IModelVersion, LocalDirName, LocalFileName, OpenCheckpointArgs,\n} from \"@itwin/core-common\";\nimport { V2CheckpointAccessProps } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SnapshotDb, TokenArg } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _hubAccess, _mockCheckpoint, _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/** @internal */\nexport interface MockCheckpoint {\n mockAttach(checkpoint: CheckpointProps): string;\n mockDownload(_request: DownloadRequest): void;\n}\n\n/**\n * Properties of a checkpoint\n * @public\n */\nexport interface CheckpointProps extends TokenArg {\n readonly expectV2?: boolean;\n\n /** iTwin that the iModel belongs to */\n readonly iTwinId: GuidString;\n\n /** Id of the iModel */\n readonly iModelId: GuidString;\n\n /** changeset for the checkpoint */\n readonly changeset: ChangesetIdWithIndex;\n\n /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */\n readonly allowPreceding?: boolean;\n\n /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */\n readonly reattachSafetySeconds?: number;\n}\n\n/** Return value from [[ProgressFunction]].\n * @public\n */\nexport enum ProgressStatus {\n /** Continue download. */\n Continue = 0,\n /** Abort download. */\n Abort = 1,\n}\n\n/** Called to show progress during a download. If this function returns non-zero, the download is aborted.\n * @public\n */\nexport type ProgressFunction = (loaded: number, total: number) => ProgressStatus;\n\n/** The parameters that specify a request to download a checkpoint file from iModelHub.\n * @internal\n */\nexport interface DownloadRequest {\n /** name of local file to hold the downloaded data. */\n localFile: LocalFileName;\n\n /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names,\n * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name.\n * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes.\n */\n readonly aliasFiles?: ReadonlyArray<string>;\n\n /** Properties of the checkpoint to be downloaded */\n readonly checkpoint: CheckpointProps;\n\n /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this\n * function returns a non-zero value, the download is aborted.\n */\n readonly onProgress?: ProgressFunction;\n}\n\n/** @internal */\nexport interface DownloadJob {\n request: DownloadRequest;\n promise?: Promise<any>;\n}\n\n/** @internal */\nexport class Downloads {\n private static _active = new Map<string, DownloadJob>();\n\n private static async process<T>(job: DownloadJob, fn: (job: DownloadJob) => Promise<T>) {\n const jobName = job.request.localFile; // save this, it can change inside call to `fn`!\n this._active.set(jobName, job);\n try {\n return await fn(job);\n } finally {\n this._active.delete(jobName);\n }\n }\n\n public static isInProgress(pathName: LocalFileName): DownloadJob | undefined {\n return this._active.get(pathName);\n }\n\n public static async download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>) {\n const pathName = request.localFile;\n let job = this.isInProgress(pathName);\n if (undefined !== job)\n return job.promise;\n\n IModelJsFs.recursiveMkDirSync(path.dirname(pathName));\n job = { request };\n return job.promise = this.process(job, downloadFn);\n }\n}\n\n/**\n * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them.\n * @internal\n*/\nexport class V2CheckpointManager {\n public static readonly cloudCacheName = \"Checkpoints\";\n private static _cloudCache?: CloudSqlite.CloudCache;\n private static containers = new Map<string, CloudSqlite.CloudContainer>();\n\n /** used by HubMock\n * @internal\n */\n public static [_mockCheckpoint]?: MockCheckpoint;\n\n\n public static getFolder(): LocalDirName {\n const cloudCachePath = path.join(BriefcaseManager.cacheDir, V2CheckpointManager.cloudCacheName);\n if (!(IModelJsFs.existsSync(cloudCachePath))) {\n IModelJsFs.recursiveMkDirSync(cloudCachePath);\n }\n return cloudCachePath;\n }\n\n /* only used by tests that reset the state of the v2CheckpointManager. all dbs should be closed before calling this function. */\n public static cleanup(): void {\n for (const [_, value] of this.containers.entries()) {\n if (value.isConnected)\n value.disconnect({ detach: true });\n }\n\n CloudSqlite.CloudCaches.dropCache(this.cloudCacheName)?.destroy();\n this._cloudCache = undefined;\n this.containers.clear();\n }\n\n private static get cloudCache(): CloudSqlite.CloudCache {\n if (!this._cloudCache) {\n let cacheDir: string | undefined = process.env.CHECKPOINT_CACHE_DIR ?? this.getFolder();\n // See if there is a daemon running, otherwise use profile directory for cloudCache\n if (!(IModelJsFs.existsSync(path.join(cacheDir, \"portnumber.bcv\"))))\n cacheDir = undefined; // no daemon running, use profile directory\n\n this._cloudCache = CloudSqlite.CloudCaches.getCache({ cacheName: this.cloudCacheName, cacheDir, cacheSize: \"50G\" });\n }\n return this._cloudCache;\n }\n\n /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */\n private static toCloudContainerProps(from: V2CheckpointAccessProps): CloudSqlite.ContainerAccessProps {\n return { ...from, baseUri: `https://${from.accountName}.blob.core.windows.net`, accessToken: from.sasToken, storageType: \"azure\" };\n }\n\n private static getContainer(v2Props: V2CheckpointAccessProps, checkpoint: CheckpointProps) {\n let container = this.containers.get(v2Props.containerId);\n if (undefined === container) {\n let tokenFn: ((args: CloudSqlite.RequestTokenArgs) => Promise<AccessToken>) | undefined;\n let tokenRefreshSeconds: number | undefined = -1;\n // from Rpc, the accessToken in the checkpoint request is from the current user. It is used to request the sasToken for the container and\n // the sasToken is checked for refresh (before it expires) on every Rpc request using that user's accessToken. For Ipc, the\n // accessToken in the checkpoint request is undefined, and the sasToken is requested by IModelHost.getAccessToken(). It is refreshed on a timer.\n if (undefined === checkpoint.accessToken) {\n tokenFn = async () => (await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint))?.sasToken ?? \"\";\n tokenRefreshSeconds = undefined;\n }\n container = CloudSqlite.createCloudContainer({ ...this.toCloudContainerProps(v2Props), tokenRefreshSeconds, logId: process.env.POD_NAME, tokenFn });\n this.containers.set(v2Props.containerId, container);\n }\n return container;\n }\n\n public static async attach(checkpoint: CheckpointProps): Promise<{ dbName: string, container: CloudSqlite.CloudContainer | undefined }> {\n if (this[_mockCheckpoint]) // used by HubMock\n return { dbName: this[_mockCheckpoint].mockAttach(checkpoint), container: undefined };\n\n let v2props: V2CheckpointAccessProps | undefined;\n try {\n v2props = await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint);\n if (!v2props)\n throw new Error(\"no checkpoint\");\n } catch (err: any) {\n throw new IModelError(IModelStatus.NotFound, `V2 checkpoint not found: err: ${err.message}`);\n }\n\n try {\n const container = this.getContainer(v2props, checkpoint);\n const dbName = v2props.dbName;\n // Use the new token from the recently queried v2 checkpoint just incase the one we currently have is expired.\n container.accessToken = v2props.sasToken;\n if (!container.isConnected)\n container.connect(this.cloudCache);\n container.checkForChanges();\n const dbStats = container.queryDatabase(dbName);\n if (IModelHost.appWorkspace.settings.getBoolean(\"Checkpoints/prefetch\", false)) {\n const getPrefetchConfig = (name: string, defaultVal: number) => IModelHost.appWorkspace.settings.getNumber(`Checkpoints/prefetch/${name}`, defaultVal);\n const minRequests = getPrefetchConfig(\"minRequests\", 3);\n const maxRequests = getPrefetchConfig(\"maxRequests\", 6);\n const timeout = getPrefetchConfig(\"timeout\", 100);\n const maxBlocks = getPrefetchConfig(\"maxBlocks\", 500); // default size of 2GB. Assumes a checkpoint block size of 4MB.\n if (dbStats?.totalBlocks !== undefined && dbStats.totalBlocks <= maxBlocks && dbStats.nPrefetch === 0) {\n const logPrefetch = async (prefetch: CloudSqlite.CloudPrefetch) => {\n const stopwatch = new StopWatch(`[${container.containerId}/${dbName}]`, true);\n Logger.logInfo(loggerCategory, `Starting prefetch of ${stopwatch.description}`, { minRequests, maxRequests, timeout });\n const done = await prefetch.promise;\n Logger.logInfo(loggerCategory, `Prefetch of ${stopwatch.description} complete=${done} (${stopwatch.elapsedSeconds} seconds)`, { minRequests, maxRequests, timeout });\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n logPrefetch(CloudSqlite.startCloudPrefetch(container, dbName, { minRequests, nRequests: maxRequests, timeout }));\n } else {\n Logger.logInfo(loggerCategory, `Skipping prefetch due to size limits or ongoing prefetch.`, { maxBlocks, numPrefetches: dbStats?.nPrefetch, totalBlocksInDb: dbStats?.totalBlocks, v2props });\n }\n }\n return { dbName, container };\n } catch (e: any) {\n const error = `Cloud cache connect failed: ${e.message}`;\n if (checkpoint.expectV2)\n Logger.logError(loggerCategory, error);\n\n throw new IModelError(e.errorNumber, error);\n }\n }\n\n /** @internal */\n private static async performDownload(job: DownloadJob): Promise<ChangesetId> {\n const request = job.request;\n if (this[_mockCheckpoint])\n this[_mockCheckpoint].mockDownload(request);\n else {\n const v2props: V2CheckpointAccessProps | undefined = await IModelHost[_hubAccess].queryV2Checkpoint({ ...request.checkpoint, allowPreceding: true });\n if (!v2props)\n throw new IModelError(IModelStatus.NotFound, \"V2 checkpoint not found\");\n\n CheckpointManager.onDownloadV2.raiseEvent(job);\n const container = CloudSqlite.createCloudContainer(this.toCloudContainerProps(v2props));\n await CloudSqlite.transferDb(\"download\", container, { dbName: v2props.dbName, localFileName: request.localFile, onProgress: request.onProgress });\n }\n return request.checkpoint.changeset.id;\n }\n\n /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline.\n * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will\n * be the same as the requested changesetId or the most recent checkpoint before it.)\n */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId> {\n return Downloads.download(request, async (job: DownloadJob) => this.performDownload(job));\n }\n}\n\n/** @internal */\nexport class CheckpointManager {\n public static readonly onDownloadV2 = new BeEvent<(job: DownloadJob) => void>();\n public static getKey(checkpoint: CheckpointProps) { return `${checkpoint.iModelId}:${checkpoint.changeset.id}`; }\n\n private static async doDownload(request: DownloadRequest): Promise<ChangesetId> {\n // first see if there's a V2 checkpoint available.\n const stopwatch = new StopWatch(`[${request.checkpoint.changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting download of V2 checkpoint with id ${stopwatch.description}`);\n const changesetId = await V2CheckpointManager.downloadCheckpoint(request);\n Logger.logInfo(loggerCategory, `Downloaded V2 checkpoint with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n if (changesetId !== request.checkpoint.changeset.id)\n Logger.logInfo(loggerCategory, `Downloaded previous v2 checkpoint because requested checkpoint not found.`, { requestedChangesetId: request.checkpoint.changeset.id, iModelId: request.checkpoint.iModelId, changesetId, iTwinId: request.checkpoint.iTwinId });\n else\n Logger.logInfo(loggerCategory, `Downloaded v2 checkpoint.`, { iModelId: request.checkpoint.iModelId, changesetId: request.checkpoint.changeset.id, iTwinId: request.checkpoint.iTwinId });\n return changesetId;\n }\n\n public static async updateToRequestedVersion(request: DownloadRequest) {\n const checkpoint = request.checkpoint;\n const targetFile = request.localFile;\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId, changeset: checkpoint.changeset };\n try {\n // Open checkpoint for write\n const prevLogLevel = Logger.getLevel(NativeLoggerCategory.SQLite) ?? LogLevel.Error; // Get log level before we set it to None.\n Logger.setLevel(NativeLoggerCategory.SQLite, LogLevel.None); // Ignores noisy error messages when applying changesets.\n const db = SnapshotDb.openForApplyChangesets(targetFile);\n const nativeDb = db[_nativeDb];\n try {\n\n if (nativeDb.hasPendingTxns()) {\n Logger.logWarning(loggerCategory, \"Checkpoint with Txns found - deleting them\", () => traceInfo);\n nativeDb.deleteAllTxns();\n }\n\n if (nativeDb.getBriefcaseId() !== BriefcaseIdValue.Unassigned)\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);\n\n CheckpointManager.validateCheckpointGuids(checkpoint, db);\n // Apply change sets if necessary\n const currentChangeset: Mutable<ChangesetIndexAndId> = nativeDb.getCurrentChangeset();\n if (currentChangeset.id !== checkpoint.changeset.id) {\n const accessToken = checkpoint.accessToken;\n const toIndex = checkpoint.changeset.index ??\n (await IModelHost[_hubAccess].getChangesetFromVersion({ accessToken, iModelId: checkpoint.iModelId, version: IModelVersion.asOfChangeSet(checkpoint.changeset.id) })).index;\n await BriefcaseManager.pullAndApplyChangesets(db, { accessToken, toIndex });\n } else {\n // make sure the parent changeset index is saved in the file - old versions didn't have it.\n currentChangeset.index = checkpoint.changeset.index!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(currentChangeset));\n }\n } finally {\n Logger.setLevel(NativeLoggerCategory.SQLite, prevLogLevel); // Set logging to what it was before we started applying changesets.\n db[_nativeDb].saveChanges();\n db.close();\n }\n } catch (error: any) {\n\n Logger.logError(loggerCategory, \"Error downloading checkpoint - deleting it\", () => traceInfo);\n IModelJsFs.removeSync(targetFile);\n\n if (error.errorNumber === ChangeSetStatus.CorruptedChangeStream || error.errorNumber === ChangeSetStatus.InvalidId || error.errorNumber === ChangeSetStatus.InvalidVersion) {\n Logger.logError(loggerCategory, \"Detected potential corruption of change sets. Deleting them to enable retries\", () => traceInfo);\n BriefcaseManager.deleteChangeSetsFromLocalDisk(checkpoint.iModelId);\n }\n throw error;\n }\n }\n\n /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<void> {\n if (this.verifyCheckpoint(request.checkpoint, request.localFile))\n return;\n\n if (request.aliasFiles) {\n for (const alias of request.aliasFiles) {\n if (this.verifyCheckpoint(request.checkpoint, alias)) {\n request.localFile = alias;\n return;\n }\n }\n }\n\n await this.doDownload(request);\n return this.updateToRequestedVersion(request);\n }\n\n /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */\n public static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb) {\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId };\n\n const nativeDb = snapshotDb[_nativeDb];\n const dbChangeset = nativeDb.getCurrentChangeset();\n const iModelId = Guid.normalize(nativeDb.getIModelId());\n if (iModelId !== Guid.normalize(checkpoint.iModelId)) {\n if (nativeDb.isReadonly())\n throw new IModelError(IModelStatus.ValidationFailed, \"iModelId is not properly set up in the checkpoint\");\n\n Logger.logWarning(loggerCategory, \"iModelId is not properly set up in the checkpoint. Updated checkpoint to the correct iModelId.\", () => ({ ...traceInfo, dbGuid: iModelId }));\n const iModelIdNormalized = Guid.normalize(checkpoint.iModelId);\n nativeDb.setIModelId(iModelIdNormalized);\n (snapshotDb as any)._iModelId = iModelIdNormalized;\n // Required to reset the ChangeSetId because setDbGuid clears the value.\n nativeDb.saveLocalValue(\"ParentChangeSetId\", dbChangeset.id);\n if (undefined !== dbChangeset.index)\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(dbChangeset));\n }\n\n const iTwinId = Guid.normalize(nativeDb.getITwinId());\n if (iTwinId !== Guid.normalize(checkpoint.iTwinId))\n throw new IModelError(IModelStatus.ValidationFailed, \"iTwinId was not properly set up in the checkpoint\");\n }\n\n /** @returns true if the file is the checkpoint requested */\n public static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean {\n if (!IModelJsFs.existsSync(fileName))\n return false;\n\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.Readonly);\n } catch {\n return false;\n }\n\n const isValid = checkpoint.iModelId === nativeDb.getIModelId() && checkpoint.changeset.id === nativeDb.getCurrentChangeset().id;\n nativeDb.closeFile();\n if (!isValid)\n IModelJsFs.removeSync(fileName);\n\n return isValid;\n }\n\n public static async toCheckpointProps(args: OpenCheckpointArgs): Promise<CheckpointProps> {\n const changeset = args.changeset ?? await IModelHost[_hubAccess].getLatestChangeset({ ...args, accessToken: await IModelHost.getAccessToken() });\n\n return {\n iModelId: args.iModelId,\n iTwinId: args.iTwinId,\n changeset: {\n index: changeset.index,\n id: changeset.id ?? (await IModelHost[_hubAccess].queryChangeset({ ...args, changeset, accessToken: await IModelHost.getAccessToken() })).id,\n },\n };\n }\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { Id64String } from "@itwin/core-bentley";
5
5
  import { CodeScopeSpec, CodeSpec, CodeSpecProperties } from "@itwin/core-common";
6
+ import { EditTxn } from "./EditTxn";
6
7
  import { IModelDb } from "./IModelDb";
7
8
  /** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]
8
9
  * @public @preview
@@ -33,10 +34,29 @@ export declare class CodeSpecs {
33
34
  hasName(name: string): boolean;
34
35
  private insertCodeSpec;
35
36
  /** Add a new CodeSpec to the iModel.
37
+ * @param txn The active EditTxn.
36
38
  * @param codeSpec The CodeSpec to insert
37
39
  * @returns The Id of the persistent CodeSpec.
38
40
  * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec
39
41
  * @throws IModelError if the insertion fails
42
+ * @beta
43
+ */
44
+ insert(txn: EditTxn, codeSpec: CodeSpec): Id64String;
45
+ /** Add a new CodeSpec to the iModel.
46
+ * @param txn The active EditTxn.
47
+ * @param name The name for the new CodeSpec.
48
+ * @param properties The properties of the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.
49
+ * @returns The Id of the persistent CodeSpec.
50
+ * @throws IModelError if the insertion fails
51
+ * @beta
52
+ */
53
+ insert(txn: EditTxn, name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;
54
+ /** Add a new CodeSpec to the iModel.
55
+ * @param codeSpec The CodeSpec to insert
56
+ * @returns The Id of the persistent CodeSpec.
57
+ * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec
58
+ * @throws IModelError if the insertion fails
59
+ * @deprecated Use CodeSpecs.insert(txn, codeSpec) instead.
40
60
  */
41
61
  insert(codeSpec: CodeSpec): Id64String;
42
62
  /** Add a new CodeSpec to the IModelDb.
@@ -44,12 +64,21 @@ export declare class CodeSpecs {
44
64
  * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.
45
65
  * @returns The Id of the persistent CodeSpec.
46
66
  * @throws IModelError if the insertion fails
67
+ * @deprecated Use CodeSpecs.insert(txn, ...) instead.
47
68
  */
48
69
  insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;
49
70
  /** Update the Json properties of an existing CodeSpec.
50
- * @param codeSpec The codeSpec holding Json properties values to update
51
- * @throws if unable to update the codeSpec.
52
- */
71
+ * @param txn The active EditTxn.
72
+ * @param codeSpec The codeSpec holding Json properties values to update.
73
+ * @throws if unable to update the codeSpec.
74
+ * @beta
75
+ */
76
+ updateProperties(txn: EditTxn, codeSpec: CodeSpec): void;
77
+ /** Update the Json properties of an existing CodeSpec.
78
+ * @param codeSpec The codeSpec holding Json properties values to update.
79
+ * @throws if unable to update the codeSpec.
80
+ * @deprecated Use CodeSpecs.updateProperties(txn, codeSpec) instead.
81
+ */
53
82
  updateProperties(codeSpec: CodeSpec): void;
54
83
  /** Load a CodeSpec from the iModel
55
84
  * @param id The persistent Id of the CodeSpec to load
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.d.ts","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAgC,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,kBAAkB,EAAe,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkB;IAC1C,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAkB;gBAE9B,MAAM,EAAE,QAAQ;IAO5B,OAAO,CAAC,UAAU;IAOlB,8DAA8D;IACvD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAOxC;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ;IAYhD,uEAAuE;IAChE,KAAK,CAA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;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAWxC,yEAAyE;IAClE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQrC,OAAO,CAAC,cAAc;IAgCtB;;;;;;;OAOG;IACI,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU;IAE3D;;;;;;;OAOG;IACI,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAAC,IAAI,GAAG,UAAU;IAE1G;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU;IAE7C;;;;;;OAMG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAAC,IAAI,GAAG,UAAU;IAwC5F;;;;;OAKG;IACI,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAE/D;;;;OAIG;IACI,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA4BjD;;OAEG;IACI,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,QAAQ;CAYtC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  /** @packageDocumentation
7
7
  * @module Codes
8
8
  */
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.CodeSpecs = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_common_1 = require("@itwin/core-common");
13
+ const EditTxn_1 = require("./EditTxn");
14
+ const Symbols_1 = require("./internal/Symbols");
13
15
  /** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]
14
16
  * @public @preview
15
17
  */
@@ -113,27 +115,53 @@ class CodeSpecs {
113
115
  });
114
116
  return core_bentley_1.Id64.fromLocalAndBriefcaseIds(id, 0);
115
117
  }
116
- insert(codeSpecOrName, props) {
117
- if (codeSpecOrName instanceof core_common_1.CodeSpec) {
118
- const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);
119
- codeSpecOrName.id = id;
120
- return id;
118
+ insert(txnOrCodeSpec, codeSpecOrNameOrProps, props) {
119
+ if (txnOrCodeSpec instanceof EditTxn_1.EditTxn) {
120
+ const txn = txnOrCodeSpec;
121
+ if (txn.iModel !== this._imodel)
122
+ core_common_1.EditTxnError.throwError("wrong-imodel", "EditTxn does not belong to this iModel", txn.iModel.key);
123
+ // CodeSpec insertion writes directly to SQLite, so enforce txn writability explicitly.
124
+ txn.verifyWriteable();
125
+ if (codeSpecOrNameOrProps instanceof core_common_1.CodeSpec) {
126
+ const id = this.insertCodeSpec(codeSpecOrNameOrProps.name, codeSpecOrNameOrProps.properties);
127
+ codeSpecOrNameOrProps.id = id;
128
+ return id;
129
+ }
130
+ if (typeof codeSpecOrNameOrProps !== "string" || props === undefined)
131
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
132
+ if (typeof props === "object")
133
+ return this.insertCodeSpec(codeSpecOrNameOrProps, props);
134
+ const spec = core_common_1.CodeSpec.create(this._imodel, codeSpecOrNameOrProps, props);
135
+ return this.insertCodeSpec(spec.name, spec.properties);
121
136
  }
122
- if (props === undefined)
137
+ // Deprecated overloads - use implicit transaction.
138
+ if (txnOrCodeSpec instanceof core_common_1.CodeSpec)
139
+ return this.insert(this._imodel[Symbols_1._implicitTxn], txnOrCodeSpec);
140
+ if (codeSpecOrNameOrProps === undefined)
123
141
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
124
- if (typeof props === "object")
125
- return this.insertCodeSpec(codeSpecOrName, props);
126
- const spec = core_common_1.CodeSpec.create(this._imodel, codeSpecOrName, props);
127
- return this.insertCodeSpec(spec.name, spec.properties);
142
+ if (typeof codeSpecOrNameOrProps === "string" || codeSpecOrNameOrProps instanceof core_common_1.CodeSpec)
143
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
144
+ return this.insert(this._imodel[Symbols_1._implicitTxn], txnOrCodeSpec, codeSpecOrNameOrProps);
128
145
  }
129
- /** Update the Json properties of an existing CodeSpec.
130
- * @param codeSpec The codeSpec holding Json properties values to update
131
- * @throws if unable to update the codeSpec.
132
- */
133
- updateProperties(codeSpec) {
146
+ updateProperties(txnOrCodeSpec, codeSpec) {
147
+ let effectiveTxn;
148
+ let effectiveCodeSpec;
149
+ if (txnOrCodeSpec instanceof EditTxn_1.EditTxn) {
150
+ effectiveTxn = txnOrCodeSpec;
151
+ if (effectiveTxn.iModel !== this._imodel)
152
+ core_common_1.EditTxnError.throwError("wrong-imodel", "EditTxn does not belong to this iModel", effectiveTxn.iModel.key);
153
+ if (undefined === codeSpec)
154
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
155
+ effectiveCodeSpec = codeSpec;
156
+ }
157
+ else {
158
+ effectiveTxn = this._imodel[Symbols_1._implicitTxn];
159
+ effectiveCodeSpec = txnOrCodeSpec;
160
+ }
161
+ effectiveTxn.verifyWriteable();
134
162
  this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {
135
- stmt.bindString(1, JSON.stringify(codeSpec.properties));
136
- stmt.bindId(2, codeSpec.id);
163
+ stmt.bindString(1, JSON.stringify(effectiveCodeSpec.properties));
164
+ stmt.bindId(2, effectiveCodeSpec.id);
137
165
  if (core_bentley_1.DbResult.BE_SQLITE_DONE !== stmt.step())
138
166
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "error updating CodeSpec properties");
139
167
  });
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA8F;AAI9F;;GAEG;AACH,MAAa,SAAS;IACZ,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;IAClC,OAAO,CAAW;IAClB,gBAAgB,GAAe,EAAE,CAAC;IAE1C,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC;YAC3B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACrG,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YACzB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,IAAY;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE;YACL,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CA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U,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YACxD,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,uBAAQ,CAAC,cAAc,KAAK,IAAI,CAAC,IAAI,EAAE;gBACzC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,EAAc;QACxB,IAAI,mBAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,mCAAmC,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;YACpH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAxKH,8BAyKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Codes\n */\n\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\n\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public @preview\n */\nexport class CodeSpecs {\n private static tableName = \"bis_CodeSpec\";\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n private findByName(name: string): Id64String | undefined {\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\n stmt.bindString(1, name);\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\n });\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n const id = this.findByName(name);\n if (!id)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return id;\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch {\n return false;\n }\n }\n\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\n const iModel = this._imodel;\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\n if (this.findByName(spec.name))\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\n\n const internalCodes = iModel.codeService?.internalCodes;\n if (internalCodes) {\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\n internalCodes.reader.verifyBisCodeSpec(spec);\n } else {\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\n }\n\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\n stmt.bindInteger(1, id);\n stmt.bindString(2, spec.name);\n stmt.bindString(3, spec.props);\n const rc = stmt.step();\n if (rc !== DbResult.BE_SQLITE_DONE)\n throw new BentleyError(rc, \"Error inserting codeSpec\");\n });\n\n return Id64.fromLocalAndBriefcaseIds(id, 0);\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n */\n public insert(codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\n if (codeSpecOrName instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\n codeSpecOrName.id = id;\n return id;\n }\n if (props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrName, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param codeSpec The codeSpec holding Json properties values to update\n * @throws if unable to update the codeSpec.\n */\n public updateProperties(codeSpec: CodeSpec): void {\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\n stmt.bindId(2, codeSpec.id);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\n });\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\n stmt.bindId(1, id);\n if (!stmt.nextRow())\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\n\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\n });\n }\n}\n"]}
1
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA4G;AAC5G,uCAAoC;AAGpC,gDAAkD;AAElD;;GAEG;AACH,MAAa,SAAS;IACZ,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;IAClC,OAAO,CAAW;IAClB,gBAAgB,GAAe,EAAE,CAAC;IAE1C,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC;YAC3B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACrG,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YACzB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,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AY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAjPH,8BAkPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Codes\n */\n\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, EditTxnError, IModelError } from \"@itwin/core-common\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\nimport { _implicitTxn } from \"./internal/Symbols\";\n\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public @preview\n */\nexport class CodeSpecs {\n private static tableName = \"bis_CodeSpec\";\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n private findByName(name: string): Id64String | undefined {\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\n stmt.bindString(1, name);\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\n });\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n const id = this.findByName(name);\n if (!id)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return id;\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch {\n return false;\n }\n }\n\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\n const iModel = this._imodel;\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\n if (this.findByName(spec.name))\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\n\n const internalCodes = iModel.codeService?.internalCodes;\n if (internalCodes) {\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\n internalCodes.reader.verifyBisCodeSpec(spec);\n } else {\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\n }\n\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\n stmt.bindInteger(1, id);\n stmt.bindString(2, spec.name);\n stmt.bindString(3, spec.props);\n const rc = stmt.step();\n if (rc !== DbResult.BE_SQLITE_DONE)\n throw new BentleyError(rc, \"Error inserting codeSpec\");\n });\n\n return Id64.fromLocalAndBriefcaseIds(id, 0);\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param txn The active EditTxn.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n * @beta\n */\n public insert(txn: EditTxn, codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the iModel.\n * @param txn The active EditTxn.\n * @param name The name for the new CodeSpec.\n * @param properties The properties of the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n * @beta\n */\n public insert(txn: EditTxn, name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n * @deprecated Use CodeSpecs.insert(txn, codeSpec) instead.\n */\n public insert(codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n * @deprecated Use CodeSpecs.insert(txn, ...) instead.\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(\n txnOrCodeSpec: EditTxn | CodeSpec | string,\n codeSpecOrNameOrProps?: CodeSpec | string | CodeSpecProperties | CodeScopeSpec.Type,\n props?: CodeSpecProperties | CodeScopeSpec.Type,\n ): Id64String {\n if (txnOrCodeSpec instanceof EditTxn) {\n const txn = txnOrCodeSpec;\n if (txn.iModel !== this._imodel)\n EditTxnError.throwError(\"wrong-imodel\", \"EditTxn does not belong to this iModel\", txn.iModel.key);\n // CodeSpec insertion writes directly to SQLite, so enforce txn writability explicitly.\n txn.verifyWriteable();\n if (codeSpecOrNameOrProps instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrNameOrProps.name, codeSpecOrNameOrProps.properties);\n codeSpecOrNameOrProps.id = id;\n return id;\n }\n if (typeof codeSpecOrNameOrProps !== \"string\" || props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrNameOrProps, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrNameOrProps, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n // Deprecated overloads - use implicit transaction.\n if (txnOrCodeSpec instanceof CodeSpec)\n return this.insert(this._imodel[_implicitTxn], txnOrCodeSpec);\n\n if (codeSpecOrNameOrProps === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof codeSpecOrNameOrProps === \"string\" || codeSpecOrNameOrProps instanceof CodeSpec)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n return this.insert(this._imodel[_implicitTxn], txnOrCodeSpec, codeSpecOrNameOrProps);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param txn The active EditTxn.\n * @param codeSpec The codeSpec holding Json properties values to update.\n * @throws if unable to update the codeSpec.\n * @beta\n */\n public updateProperties(txn: EditTxn, codeSpec: CodeSpec): void;\n\n /** Update the Json properties of an existing CodeSpec.\n * @param codeSpec The codeSpec holding Json properties values to update.\n * @throws if unable to update the codeSpec.\n * @deprecated Use CodeSpecs.updateProperties(txn, codeSpec) instead.\n */\n public updateProperties(codeSpec: CodeSpec): void;\n public updateProperties(txnOrCodeSpec: EditTxn | CodeSpec, codeSpec?: CodeSpec): void {\n let effectiveTxn: EditTxn;\n let effectiveCodeSpec: CodeSpec;\n\n if (txnOrCodeSpec instanceof EditTxn) {\n effectiveTxn = txnOrCodeSpec;\n if (effectiveTxn.iModel !== this._imodel)\n EditTxnError.throwError(\"wrong-imodel\", \"EditTxn does not belong to this iModel\", effectiveTxn.iModel.key);\n\n if (undefined === codeSpec)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n effectiveCodeSpec = codeSpec;\n } else {\n effectiveTxn = this._imodel[_implicitTxn];\n effectiveCodeSpec = txnOrCodeSpec;\n }\n\n effectiveTxn.verifyWriteable();\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(effectiveCodeSpec.properties));\n stmt.bindId(2, effectiveCodeSpec.id);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\n });\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\n stmt.bindId(1, id);\n if (!stmt.nextRow())\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\n\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\n });\n }\n}\n"]}
@@ -4,6 +4,7 @@
4
4
  import { Id64String } from "@itwin/core-bentley";
5
5
  import { Code, CodeScopeProps, ColorDef, DisplayStyle3dProps, DisplayStyle3dSettings, DisplayStyle3dSettingsProps, DisplayStyleProps, DisplayStyleSettings, EntityReferenceSet, RenderSchedule, ViewFlags } from "@itwin/core-common";
6
6
  import { DefinitionElement } from "./Element";
7
+ import { EditTxn } from "./EditTxn";
7
8
  import { IModelDb } from "./IModelDb";
8
9
  import { IModelElementCloneContext } from "./IModelElementCloneContext";
9
10
  import { DeserializeEntityArgs, ECSqlRow } from "./Entity";
@@ -47,12 +48,19 @@ export declare class DisplayStyle2d extends DisplayStyle {
47
48
  * @throws [[IModelError]] if unable to create the element.
48
49
  */
49
50
  static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DisplayStyle2d;
50
- /** Insert a DisplayStyle2d for use by a ViewDefinition.
51
- * @param iModelDb Insert into this iModel
51
+ /**
52
+ * Insert a DisplayStyle2d for use by a ViewDefinition.
53
+ * @param txn The EditTxn to use
52
54
  * @param definitionModelId Insert the new DisplayStyle2d into this DefinitionModel
53
55
  * @param name The name of the DisplayStyle2d
54
56
  * @returns The Id of the newly inserted DisplayStyle2d element.
55
57
  * @throws [[IModelError]] if unable to insert the element.
58
+ * @beta
59
+ */
60
+ static insert(txn: EditTxn, definitionModelId: Id64String, name: string): Id64String;
61
+ /**
62
+ * Insert a DisplayStyle2d for use by a ViewDefinition.
63
+ * @deprecated Use DisplayStyle2d.insert(txn, ...) instead.
56
64
  */
57
65
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String;
58
66
  }
@@ -93,11 +101,18 @@ export declare class DisplayStyle3d extends DisplayStyle {
93
101
  static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): DisplayStyle3d;
94
102
  /**
95
103
  * Insert a DisplayStyle3d for use by a ViewDefinition.
96
- * @param iModelDb Insert into this iModel
104
+ * @param txn The EditTxn to use
97
105
  * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]
98
106
  * @param name The name of the DisplayStyle3d
107
+ * @param options Creation options
99
108
  * @returns The Id of the newly inserted DisplayStyle3d element.
100
109
  * @throws [[IModelError]] if unable to insert the element.
110
+ * @beta
111
+ */
112
+ static insert(txn: EditTxn, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;
113
+ /**
114
+ * Insert a DisplayStyle3d for use by a ViewDefinition.
115
+ * @deprecated Use DisplayStyle3d.insert(txn, ...) instead.
101
116
  */
102
117
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;
103
118
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayStyle.d.ts","sourceRoot":"","sources":["../../src/DisplayStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAsC,UAAU,EAAuB,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EACQ,IAAI,EAAE,cAAc,EAAY,QAAQ,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,2BAA2B,EAC/H,iBAAiB,EAAE,oBAAoB,EAAgC,kBAAkB,EAA+B,cAAc,EAAoB,SAAS,EACpK,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAkB,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE3D;;;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