@itwin/core-backend 5.1.0-dev.9 → 5.2.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/CHANGELOG.md +112 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +1 -1
  3. package/lib/cjs/BackendHubAccess.js +1 -1
  4. package/lib/cjs/BackendHubAccess.js.map +1 -1
  5. package/lib/cjs/BisCoreSchema.d.ts.map +1 -1
  6. package/lib/cjs/BisCoreSchema.js +4 -2
  7. package/lib/cjs/BisCoreSchema.js.map +1 -1
  8. package/lib/cjs/BriefcaseManager.d.ts +10 -2
  9. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  10. package/lib/cjs/BriefcaseManager.js +16 -0
  11. package/lib/cjs/BriefcaseManager.js.map +1 -1
  12. package/lib/cjs/Category.d.ts +4 -4
  13. package/lib/cjs/Category.js +4 -4
  14. package/lib/cjs/Category.js.map +1 -1
  15. package/lib/cjs/ChangesetECAdaptor.d.ts +67 -8
  16. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  17. package/lib/cjs/ChangesetECAdaptor.js +248 -33
  18. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  19. package/lib/cjs/ClassRegistry.d.ts +9 -1
  20. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  21. package/lib/cjs/ClassRegistry.js +9 -1
  22. package/lib/cjs/ClassRegistry.js.map +1 -1
  23. package/lib/cjs/CloudSqlite.js +1 -1
  24. package/lib/cjs/CloudSqlite.js.map +1 -1
  25. package/lib/cjs/CodeSpecs.d.ts +1 -1
  26. package/lib/cjs/CodeSpecs.js +1 -1
  27. package/lib/cjs/CodeSpecs.js.map +1 -1
  28. package/lib/cjs/DisplayStyle.d.ts +4 -4
  29. package/lib/cjs/DisplayStyle.js +3 -3
  30. package/lib/cjs/DisplayStyle.js.map +1 -1
  31. package/lib/cjs/ECDb.d.ts +4 -4
  32. package/lib/cjs/ECDb.d.ts.map +1 -1
  33. package/lib/cjs/ECDb.js +4 -4
  34. package/lib/cjs/ECDb.js.map +1 -1
  35. package/lib/cjs/ECSqlStatement.d.ts +15 -6
  36. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  37. package/lib/cjs/ECSqlStatement.js +19 -4
  38. package/lib/cjs/ECSqlStatement.js.map +1 -1
  39. package/lib/cjs/Element.d.ts +54 -51
  40. package/lib/cjs/Element.d.ts.map +1 -1
  41. package/lib/cjs/Element.js +67 -52
  42. package/lib/cjs/Element.js.map +1 -1
  43. package/lib/cjs/ElementAspect.d.ts +8 -8
  44. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  45. package/lib/cjs/ElementAspect.js +8 -8
  46. package/lib/cjs/ElementAspect.js.map +1 -1
  47. package/lib/cjs/Entity.d.ts +10 -7
  48. package/lib/cjs/Entity.d.ts.map +1 -1
  49. package/lib/cjs/Entity.js +35 -13
  50. package/lib/cjs/Entity.js.map +1 -1
  51. package/lib/cjs/ExportGraphics.d.ts +54 -8
  52. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  53. package/lib/cjs/ExportGraphics.js +158 -59
  54. package/lib/cjs/ExportGraphics.js.map +1 -1
  55. package/lib/cjs/GeographicCRSServices.d.ts +6 -2
  56. package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
  57. package/lib/cjs/GeographicCRSServices.js +1 -1
  58. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  59. package/lib/cjs/IModelDb.d.ts +37 -26
  60. package/lib/cjs/IModelDb.d.ts.map +1 -1
  61. package/lib/cjs/IModelDb.js +124 -47
  62. package/lib/cjs/IModelDb.js.map +1 -1
  63. package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
  64. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  65. package/lib/cjs/IModelElementCloneContext.js +1 -1
  66. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  67. package/lib/cjs/IModelHost.d.ts +2 -3
  68. package/lib/cjs/IModelHost.d.ts.map +1 -1
  69. package/lib/cjs/IModelHost.js +2 -3
  70. package/lib/cjs/IModelHost.js.map +1 -1
  71. package/lib/cjs/IModelIncrementalSchemaLocater.d.ts +36 -0
  72. package/lib/cjs/IModelIncrementalSchemaLocater.d.ts.map +1 -0
  73. package/lib/cjs/IModelIncrementalSchemaLocater.js +69 -0
  74. package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -0
  75. package/lib/cjs/LocalHub.d.ts.map +1 -1
  76. package/lib/cjs/LocalHub.js +6 -4
  77. package/lib/cjs/LocalHub.js.map +1 -1
  78. package/lib/cjs/Material.d.ts +4 -3
  79. package/lib/cjs/Material.d.ts.map +1 -1
  80. package/lib/cjs/Material.js +5 -5
  81. package/lib/cjs/Material.js.map +1 -1
  82. package/lib/cjs/Model.d.ts +22 -22
  83. package/lib/cjs/Model.js +22 -22
  84. package/lib/cjs/Model.js.map +1 -1
  85. package/lib/cjs/Relationship.d.ts +3 -0
  86. package/lib/cjs/Relationship.d.ts.map +1 -1
  87. package/lib/cjs/Relationship.js +15 -0
  88. package/lib/cjs/Relationship.js.map +1 -1
  89. package/lib/cjs/SQLiteDb.d.ts +1 -1
  90. package/lib/cjs/SQLiteDb.js +1 -1
  91. package/lib/cjs/SQLiteDb.js.map +1 -1
  92. package/lib/cjs/Schema.d.ts +25 -0
  93. package/lib/cjs/Schema.d.ts.map +1 -1
  94. package/lib/cjs/Schema.js +25 -0
  95. package/lib/cjs/Schema.js.map +1 -1
  96. package/lib/cjs/SqliteStatement.d.ts +1 -1
  97. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  98. package/lib/cjs/SqliteStatement.js +1 -1
  99. package/lib/cjs/SqliteStatement.js.map +1 -1
  100. package/lib/cjs/Texture.d.ts +1 -1
  101. package/lib/cjs/Texture.js +1 -1
  102. package/lib/cjs/Texture.js.map +1 -1
  103. package/lib/cjs/TxnManager.d.ts +4 -4
  104. package/lib/cjs/TxnManager.js +1 -1
  105. package/lib/cjs/TxnManager.js.map +1 -1
  106. package/lib/cjs/ViewDefinition.d.ts +40 -14
  107. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  108. package/lib/cjs/ViewDefinition.js +42 -14
  109. package/lib/cjs/ViewDefinition.js.map +1 -1
  110. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +61 -0
  111. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -0
  112. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +110 -0
  113. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -0
  114. package/lib/cjs/annotations/FrameGeometry.d.ts +51 -0
  115. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -0
  116. package/lib/cjs/annotations/FrameGeometry.js +249 -0
  117. package/lib/cjs/annotations/FrameGeometry.js.map +1 -0
  118. package/lib/cjs/annotations/LeaderGeometry.d.ts +53 -0
  119. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -0
  120. package/lib/cjs/annotations/LeaderGeometry.js +184 -0
  121. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -0
  122. package/lib/cjs/annotations/TextAnnotationElement.d.ts +204 -0
  123. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -0
  124. package/lib/cjs/annotations/TextAnnotationElement.js +411 -0
  125. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -0
  126. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts +33 -0
  127. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -0
  128. package/lib/cjs/annotations/TextAnnotationGeometry.js +137 -0
  129. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -0
  130. package/lib/cjs/annotations/TextBlockGeometry.d.ts +16 -0
  131. package/lib/cjs/annotations/TextBlockGeometry.d.ts.map +1 -0
  132. package/lib/cjs/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +28 -70
  133. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -0
  134. package/lib/cjs/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +69 -22
  135. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -0
  136. package/lib/cjs/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +174 -49
  137. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -0
  138. package/lib/cjs/core-backend.d.ts +7 -3
  139. package/lib/cjs/core-backend.d.ts.map +1 -1
  140. package/lib/cjs/core-backend.js +27 -6
  141. package/lib/cjs/core-backend.js.map +1 -1
  142. package/lib/cjs/internal/ElementLRUCache.d.ts +23 -0
  143. package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -1
  144. package/lib/cjs/internal/ElementLRUCache.js +167 -3
  145. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  146. package/lib/cjs/internal/Symbols.d.ts +1 -0
  147. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  148. package/lib/cjs/internal/Symbols.js +2 -1
  149. package/lib/cjs/internal/Symbols.js.map +1 -1
  150. package/lib/cjs/internal/annotations/fields.d.ts +22 -0
  151. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -0
  152. package/lib/cjs/internal/annotations/fields.js +237 -0
  153. package/lib/cjs/internal/annotations/fields.js.map +1 -0
  154. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  155. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -1
  156. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  157. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  158. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  159. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  160. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  161. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  162. package/lib/cjs/workspace/Workspace.d.ts +0 -1
  163. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  164. package/lib/cjs/workspace/Workspace.js.map +1 -1
  165. package/lib/esm/BackendHubAccess.d.ts +1 -1
  166. package/lib/esm/BackendHubAccess.js +1 -1
  167. package/lib/esm/BackendHubAccess.js.map +1 -1
  168. package/lib/esm/BisCoreSchema.d.ts.map +1 -1
  169. package/lib/esm/BisCoreSchema.js +4 -2
  170. package/lib/esm/BisCoreSchema.js.map +1 -1
  171. package/lib/esm/BriefcaseManager.d.ts +10 -2
  172. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  173. package/lib/esm/BriefcaseManager.js +17 -1
  174. package/lib/esm/BriefcaseManager.js.map +1 -1
  175. package/lib/esm/Category.d.ts +4 -4
  176. package/lib/esm/Category.js +4 -4
  177. package/lib/esm/Category.js.map +1 -1
  178. package/lib/esm/ChangesetECAdaptor.d.ts +67 -8
  179. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  180. package/lib/esm/ChangesetECAdaptor.js +248 -33
  181. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  182. package/lib/esm/ClassRegistry.d.ts +9 -1
  183. package/lib/esm/ClassRegistry.d.ts.map +1 -1
  184. package/lib/esm/ClassRegistry.js +9 -1
  185. package/lib/esm/ClassRegistry.js.map +1 -1
  186. package/lib/esm/CloudSqlite.js +1 -1
  187. package/lib/esm/CloudSqlite.js.map +1 -1
  188. package/lib/esm/CodeSpecs.d.ts +1 -1
  189. package/lib/esm/CodeSpecs.js +1 -1
  190. package/lib/esm/CodeSpecs.js.map +1 -1
  191. package/lib/esm/DisplayStyle.d.ts +4 -4
  192. package/lib/esm/DisplayStyle.js +3 -3
  193. package/lib/esm/DisplayStyle.js.map +1 -1
  194. package/lib/esm/ECDb.d.ts +4 -4
  195. package/lib/esm/ECDb.d.ts.map +1 -1
  196. package/lib/esm/ECDb.js +4 -4
  197. package/lib/esm/ECDb.js.map +1 -1
  198. package/lib/esm/ECSqlStatement.d.ts +15 -6
  199. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  200. package/lib/esm/ECSqlStatement.js +19 -4
  201. package/lib/esm/ECSqlStatement.js.map +1 -1
  202. package/lib/esm/Element.d.ts +54 -51
  203. package/lib/esm/Element.d.ts.map +1 -1
  204. package/lib/esm/Element.js +67 -52
  205. package/lib/esm/Element.js.map +1 -1
  206. package/lib/esm/ElementAspect.d.ts +8 -8
  207. package/lib/esm/ElementAspect.d.ts.map +1 -1
  208. package/lib/esm/ElementAspect.js +8 -8
  209. package/lib/esm/ElementAspect.js.map +1 -1
  210. package/lib/esm/Entity.d.ts +10 -7
  211. package/lib/esm/Entity.d.ts.map +1 -1
  212. package/lib/esm/Entity.js +36 -14
  213. package/lib/esm/Entity.js.map +1 -1
  214. package/lib/esm/ExportGraphics.d.ts +54 -8
  215. package/lib/esm/ExportGraphics.d.ts.map +1 -1
  216. package/lib/esm/ExportGraphics.js +156 -58
  217. package/lib/esm/ExportGraphics.js.map +1 -1
  218. package/lib/esm/GeographicCRSServices.d.ts +6 -2
  219. package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
  220. package/lib/esm/GeographicCRSServices.js +1 -1
  221. package/lib/esm/GeographicCRSServices.js.map +1 -1
  222. package/lib/esm/IModelDb.d.ts +37 -26
  223. package/lib/esm/IModelDb.d.ts.map +1 -1
  224. package/lib/esm/IModelDb.js +128 -51
  225. package/lib/esm/IModelDb.js.map +1 -1
  226. package/lib/esm/IModelElementCloneContext.d.ts +1 -1
  227. package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
  228. package/lib/esm/IModelElementCloneContext.js +1 -1
  229. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  230. package/lib/esm/IModelHost.d.ts +2 -3
  231. package/lib/esm/IModelHost.d.ts.map +1 -1
  232. package/lib/esm/IModelHost.js +2 -3
  233. package/lib/esm/IModelHost.js.map +1 -1
  234. package/lib/esm/IModelIncrementalSchemaLocater.d.ts +36 -0
  235. package/lib/esm/IModelIncrementalSchemaLocater.d.ts.map +1 -0
  236. package/lib/esm/IModelIncrementalSchemaLocater.js +65 -0
  237. package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -0
  238. package/lib/esm/LocalHub.d.ts.map +1 -1
  239. package/lib/esm/LocalHub.js +6 -4
  240. package/lib/esm/LocalHub.js.map +1 -1
  241. package/lib/esm/Material.d.ts +4 -3
  242. package/lib/esm/Material.d.ts.map +1 -1
  243. package/lib/esm/Material.js +5 -5
  244. package/lib/esm/Material.js.map +1 -1
  245. package/lib/esm/Model.d.ts +22 -22
  246. package/lib/esm/Model.js +22 -22
  247. package/lib/esm/Model.js.map +1 -1
  248. package/lib/esm/Relationship.d.ts +3 -0
  249. package/lib/esm/Relationship.d.ts.map +1 -1
  250. package/lib/esm/Relationship.js +15 -0
  251. package/lib/esm/Relationship.js.map +1 -1
  252. package/lib/esm/SQLiteDb.d.ts +1 -1
  253. package/lib/esm/SQLiteDb.js +1 -1
  254. package/lib/esm/SQLiteDb.js.map +1 -1
  255. package/lib/esm/Schema.d.ts +25 -0
  256. package/lib/esm/Schema.d.ts.map +1 -1
  257. package/lib/esm/Schema.js +25 -0
  258. package/lib/esm/Schema.js.map +1 -1
  259. package/lib/esm/SqliteStatement.d.ts +1 -1
  260. package/lib/esm/SqliteStatement.d.ts.map +1 -1
  261. package/lib/esm/SqliteStatement.js +1 -1
  262. package/lib/esm/SqliteStatement.js.map +1 -1
  263. package/lib/esm/Texture.d.ts +1 -1
  264. package/lib/esm/Texture.js +1 -1
  265. package/lib/esm/Texture.js.map +1 -1
  266. package/lib/esm/TxnManager.d.ts +4 -4
  267. package/lib/esm/TxnManager.js +1 -1
  268. package/lib/esm/TxnManager.js.map +1 -1
  269. package/lib/esm/ViewDefinition.d.ts +40 -14
  270. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  271. package/lib/esm/ViewDefinition.js +42 -14
  272. package/lib/esm/ViewDefinition.js.map +1 -1
  273. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +61 -0
  274. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -0
  275. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +105 -0
  276. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -0
  277. package/lib/esm/annotations/FrameGeometry.d.ts +51 -0
  278. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -0
  279. package/lib/esm/annotations/FrameGeometry.js +244 -0
  280. package/lib/esm/annotations/FrameGeometry.js.map +1 -0
  281. package/lib/esm/annotations/LeaderGeometry.d.ts +53 -0
  282. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -0
  283. package/lib/esm/annotations/LeaderGeometry.js +179 -0
  284. package/lib/esm/annotations/LeaderGeometry.js.map +1 -0
  285. package/lib/esm/annotations/TextAnnotationElement.d.ts +204 -0
  286. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -0
  287. package/lib/esm/annotations/TextAnnotationElement.js +405 -0
  288. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -0
  289. package/lib/esm/annotations/TextAnnotationGeometry.d.ts +33 -0
  290. package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -0
  291. package/lib/esm/annotations/TextAnnotationGeometry.js +134 -0
  292. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -0
  293. package/lib/esm/annotations/TextBlockGeometry.d.ts +16 -0
  294. package/lib/esm/annotations/TextBlockGeometry.d.ts.map +1 -0
  295. package/lib/esm/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +28 -70
  296. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -0
  297. package/lib/esm/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +69 -22
  298. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -0
  299. package/lib/esm/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +172 -48
  300. package/lib/esm/annotations/TextBlockLayout.js.map +1 -0
  301. package/lib/esm/core-backend.d.ts +7 -3
  302. package/lib/esm/core-backend.d.ts.map +1 -1
  303. package/lib/esm/core-backend.js +27 -3
  304. package/lib/esm/core-backend.js.map +1 -1
  305. package/lib/esm/internal/ElementLRUCache.d.ts +23 -0
  306. package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -1
  307. package/lib/esm/internal/ElementLRUCache.js +165 -2
  308. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  309. package/lib/esm/internal/Symbols.d.ts +1 -0
  310. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  311. package/lib/esm/internal/Symbols.js +1 -0
  312. package/lib/esm/internal/Symbols.js.map +1 -1
  313. package/lib/esm/internal/annotations/fields.d.ts +22 -0
  314. package/lib/esm/internal/annotations/fields.d.ts.map +1 -0
  315. package/lib/esm/internal/annotations/fields.js +231 -0
  316. package/lib/esm/internal/annotations/fields.js.map +1 -0
  317. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  318. package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -1
  319. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  320. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  321. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  322. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  323. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  324. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  325. package/lib/esm/test/AnnotationTestUtils.d.ts +15 -0
  326. package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -0
  327. package/lib/esm/test/AnnotationTestUtils.js +41 -0
  328. package/lib/esm/test/AnnotationTestUtils.js.map +1 -0
  329. package/lib/esm/test/ElementLRUCache.test.js +224 -1
  330. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  331. package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
  332. package/lib/esm/test/IModelTestUtils.js +1 -0
  333. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  334. package/lib/esm/test/TestUtils.d.ts +1 -1
  335. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  336. package/lib/esm/test/TestUtils.js +1 -1
  337. package/lib/esm/test/TestUtils.js.map +1 -1
  338. package/lib/esm/test/annotations/Fields.test.d.ts +2 -0
  339. package/lib/esm/test/annotations/Fields.test.d.ts.map +1 -0
  340. package/lib/esm/test/annotations/Fields.test.js +576 -0
  341. package/lib/esm/test/annotations/Fields.test.js.map +1 -0
  342. package/lib/esm/test/annotations/FrameGeometry.test.d.ts +2 -0
  343. package/lib/esm/test/annotations/FrameGeometry.test.d.ts.map +1 -0
  344. package/lib/esm/test/annotations/FrameGeometry.test.js +86 -0
  345. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -0
  346. package/lib/esm/test/annotations/LeaderGeometry.test.d.ts +2 -0
  347. package/lib/esm/test/annotations/LeaderGeometry.test.d.ts.map +1 -0
  348. package/lib/esm/test/annotations/LeaderGeometry.test.js +256 -0
  349. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -0
  350. package/lib/esm/test/annotations/TextAnnotation.test.js +269 -1047
  351. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  352. package/lib/esm/test/annotations/TextBlock.test.d.ts +2 -0
  353. package/lib/esm/test/annotations/TextBlock.test.d.ts.map +1 -0
  354. package/lib/esm/test/annotations/TextBlock.test.js +1199 -0
  355. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -0
  356. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.d.ts +60 -0
  357. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.d.ts.map +1 -0
  358. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js +69 -0
  359. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -0
  360. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.d.ts +1442 -0
  361. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.d.ts.map +1 -0
  362. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +817 -0
  363. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -0
  364. package/lib/esm/test/ecdb/ConcurrentQuery.test.d.ts +2 -0
  365. package/lib/esm/test/ecdb/ConcurrentQuery.test.d.ts.map +1 -0
  366. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +164 -0
  367. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -0
  368. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +22 -32
  369. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
  370. package/lib/esm/test/ecdb/ECDb.test.js +29 -8
  371. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  372. package/lib/esm/test/ecdb/ECSqlQuery.test.js +0 -55
  373. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  374. package/lib/esm/test/ecdb/ECSqlStatement.test.js +192 -0
  375. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  376. package/lib/esm/test/hubaccess/ApplyChangeset.test.d.ts +2 -0
  377. package/lib/esm/test/hubaccess/ApplyChangeset.test.d.ts.map +1 -0
  378. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +86 -0
  379. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -0
  380. package/lib/esm/test/imodel/IModel.test.js +313 -5
  381. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  382. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.d.ts +2 -0
  383. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.d.ts.map +1 -0
  384. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +343 -0
  385. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -0
  386. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.d.ts +2 -0
  387. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.d.ts.map +1 -0
  388. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +207 -0
  389. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -0
  390. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts +11 -0
  391. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts.map +1 -0
  392. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js +36 -0
  393. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +1 -0
  394. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts +17 -0
  395. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts.map +1 -0
  396. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js +116 -0
  397. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +1 -0
  398. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +9 -0
  399. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +1 -0
  400. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +20 -0
  401. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +1 -0
  402. package/lib/esm/test/misc/GeoServices.test.js +36 -10
  403. package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
  404. package/lib/esm/test/schema/ClassRegistry.test.js +104 -2
  405. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  406. package/lib/esm/test/standalone/ChangesetReader.test.js +547 -136
  407. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  408. package/lib/esm/test/standalone/ExportGraphics.test.js +53 -1
  409. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  410. package/lib/esm/test/standalone/GeometryStream.test.js +49 -1
  411. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  412. package/lib/esm/test/standalone/IModelLimits.test.d.ts +2 -0
  413. package/lib/esm/test/standalone/IModelLimits.test.d.ts.map +1 -0
  414. package/lib/esm/test/standalone/IModelLimits.test.js +103 -0
  415. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -0
  416. package/lib/esm/test/standalone/RenderMaterialElement.test.js +24 -1
  417. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  418. package/lib/esm/test/standalone/SnapshotDb.test.js +19 -1
  419. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  420. package/lib/esm/workspace/Workspace.d.ts +0 -1
  421. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  422. package/lib/esm/workspace/Workspace.js.map +1 -1
  423. package/package.json +21 -15
  424. package/lib/cjs/TextAnnotationElement.d.ts +0 -54
  425. package/lib/cjs/TextAnnotationElement.d.ts.map +0 -1
  426. package/lib/cjs/TextAnnotationElement.js +0 -94
  427. package/lib/cjs/TextAnnotationElement.js.map +0 -1
  428. package/lib/cjs/TextAnnotationGeometry.d.ts +0 -32
  429. package/lib/cjs/TextAnnotationGeometry.d.ts.map +0 -1
  430. package/lib/cjs/TextAnnotationGeometry.js.map +0 -1
  431. package/lib/cjs/TextAnnotationLayout.d.ts.map +0 -1
  432. package/lib/cjs/TextAnnotationLayout.js.map +0 -1
  433. package/lib/esm/TextAnnotationElement.d.ts +0 -54
  434. package/lib/esm/TextAnnotationElement.d.ts.map +0 -1
  435. package/lib/esm/TextAnnotationElement.js +0 -89
  436. package/lib/esm/TextAnnotationElement.js.map +0 -1
  437. package/lib/esm/TextAnnotationGeometry.d.ts +0 -32
  438. package/lib/esm/TextAnnotationGeometry.d.ts.map +0 -1
  439. package/lib/esm/TextAnnotationGeometry.js.map +0 -1
  440. package/lib/esm/TextAnnotationLayout.d.ts.map +0 -1
  441. package/lib/esm/TextAnnotationLayout.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Briefc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C,yBAAyB,CAAC;wBAC/C,KAAK,eAAe,CAAC,eAAe;4BAClC,OAAO,IAAI,CAAC;oBAChB,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC;gBAEF,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACnB,EAAE,CAAC,SAAS,CAAC,CAAC,sBAAsB,EAAE,CAAC;oBACvC,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAe,EAAE,GAAoB;QACrE,IAAI,UAAU,GAAG,GAAG,CAAC,eAAe,IAAI,CAAC,CAAC;QAC1C,OAAO,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,MAAM,gBAAgB,CAAC,sBAAsB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;gBACvD,IAAI,CAAC,EAAE,CAAC,4BAA4B;oBAClC,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC5B,OAAO,MAAM,gBAAgB,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,IAAI,UAAU,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,KAAK,eAAe,CAAC,cAAc;oBACzE,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC","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 cset csets ecchanges\n\nimport * as path from \"path\";\nimport {\n AccessToken, BeDuration, ChangeSetStatus, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch,\n} from \"@itwin/core-bentley\";\nimport {\n BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,\n LocalDirName, LocalFileName, RequestNewBriefcaseProps,\n} from \"@itwin/core-common\";\nimport { AcquireNewBriefcaseIdArg, IModelNameArg } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { CheckpointManager, CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SchemaSync } from \"./SchemaSync\";\nimport { _hubAccess, _nativeDb, _releaseAllLocks } from \"./internal/Symbols\";\nimport { IModelNative } from \"./internal/NativePlatform\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/** The argument for [[BriefcaseManager.downloadBriefcase]]\n * @public\n*/\nexport interface RequestNewBriefcaseArg extends TokenArg, RequestNewBriefcaseProps {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n}\n\n/**\n * Parameters for pushing changesets to iModelHub\n * @public\n */\nexport interface PushChangesArgs extends TokenArg {\n /** A description of the changes. This is visible on the iModel's timeline. */\n description: string;\n /** if present, the locks are retained after the operation. Otherwise, *all* locks are released after the changeset is successfully pushed. */\n retainLocks?: true;\n /** number of times to retry pull/merge if other users are pushing at the same time. Default is 5 */\n mergeRetryCount?: number;\n /** delay to wait between pull/merge retry attempts. Default is 3 seconds */\n mergeRetryDelay?: BeDuration;\n /** the number of time to attempt to retry to push the changeset upon failure. Default is 3 */\n pushRetryCount?: number;\n /** The delay to wait between retry attempts on failed pushes. Default is 3 seconds. */\n pushRetryDelay?: BeDuration;\n /**\n * For testing purpose\n * @internal\n */\n noFastForward?: true;\n}\n\n/**\n * Specifies a specific index for pulling changes.\n * @public\n */\nexport interface ToChangesetArgs extends TokenArg {\n /** The last ChangesetIndex to pull. If not present, pull *all* newer changesets. */\n toIndex?: ChangesetIndex;\n}\n\n/** Arguments for [[BriefcaseManager.pullAndApplyChangesets]]\n * @public\n */\nexport type PullChangesArgs = ToChangesetArgs & {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n /**\n * For testing purpose\n * @internal\n */\n noFastForward?: true;\n};\n\n/** Arguments for [[BriefcaseManager.revertTimelineChanges]]\n * @public\n */\nexport type RevertChangesArgs = Optional<PushChangesArgs, \"description\"> & {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n /** The index of the changeset to revert to */\n toIndex: ChangesetIndex;\n /** If present, schema changes are skipped during the revert operation. */\n skipSchemaChanges?: true;\n};\n\n/** Manages downloading Briefcases and downloading and uploading changesets.\n * @public\n */\nexport class BriefcaseManager {\n /** Get the local path of the folder storing files that are associated with an imodel */\n public static getIModelPath(iModelId: GuidString): LocalDirName { return path.join(this._cacheDir, iModelId); }\n\n /** @internal */\n public static getChangeSetsPath(iModelId: GuidString): LocalDirName { return path.join(this.getIModelPath(iModelId), \"changesets\"); }\n\n /** @internal */\n public static getChangeCachePathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.ecchanges\")); }\n\n /** @internal */\n public static getChangedElementsPathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.elems\")); }\n\n private static _briefcaseSubDir = \"briefcases\";\n /** Get the local path of the folder storing briefcases associated with the specified iModel. */\n public static getBriefcaseBasePath(iModelId: GuidString): LocalDirName {\n return path.join(this.getIModelPath(iModelId), this._briefcaseSubDir);\n }\n\n /** Get the name of the local file that holds, or will hold, a local briefcase in the briefcase cache.\n * @note The briefcase cache is a local directory established in the call to [[BriefcaseManager.initialize]].\n * @param briefcase the iModelId and BriefcaseId for the filename\n * @see getIModelPath\n */\n public static getFileName(briefcase: BriefcaseProps): LocalFileName {\n return path.join(this.getBriefcaseBasePath(briefcase.iModelId), `${briefcase.briefcaseId}.bim`);\n }\n\n private static setupCacheDir(cacheRootDir: LocalDirName) {\n this._cacheDir = cacheRootDir;\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\n }\n\n private static _initialized?: boolean;\n /** Initialize BriefcaseManager\n * @param cacheRootDir The root directory for storing a cache of downloaded briefcase files on the local computer.\n * Briefcases are stored relative to this path in sub-folders organized by IModelId.\n * @note It is perfectly valid for applications to store briefcases in locations they manage, outside of `cacheRootDir`.\n */\n public static initialize(cacheRootDir: LocalDirName) {\n if (this._initialized)\n return;\n this.setupCacheDir(cacheRootDir);\n IModelHost.onBeforeShutdown.addOnce(() => this.finalize());\n this._initialized = true;\n }\n\n private static finalize() {\n this._initialized = false;\n }\n\n /** Get a list of the local briefcase held in the briefcase cache, optionally for a single iModelId\n * @param iModelId if present, only briefcases for this iModelId are returned, otherwise all briefcases for all\n * iModels in the briefcase cache are returned.\n * @note usually there should only be one briefcase per iModel.\n */\n public static getCachedBriefcases(iModelId?: GuidString): LocalBriefcaseProps[] {\n const briefcaseList: LocalBriefcaseProps[] = [];\n const iModelDirs = IModelJsFs.readdirSync(this._cacheDir);\n for (const iModelDir of iModelDirs) {\n if (iModelId && iModelId !== iModelDir)\n continue;\n const bcPath = path.join(this._cacheDir, iModelDir, this._briefcaseSubDir);\n try {\n if (!IModelJsFs.lstatSync(bcPath)?.isDirectory)\n continue;\n } catch {\n continue;\n }\n\n const briefcases = IModelJsFs.readdirSync(bcPath);\n for (const briefcaseName of briefcases) {\n if (briefcaseName.endsWith(\".bim\")) {\n try {\n const fileName = path.join(bcPath, briefcaseName);\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\n const db = IModelDb.openDgnDb({ path: fileName }, OpenMode.Readonly);\n briefcaseList.push({ fileName, iTwinId: db.getITwinId(), iModelId: db.getIModelId(), briefcaseId: db.getBriefcaseId(), changeset: db.getCurrentChangeset(), fileSize });\n db.closeFile();\n } catch { }\n }\n }\n }\n return briefcaseList;\n }\n\n private static _cacheDir: LocalDirName;\n /** Get the root directory for the briefcase cache */\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\n\n /** Determine whether the supplied briefcaseId is in the range of assigned BriefcaseIds issued by iModelHub\n * @note this does check whether the id was actually acquired by the caller.\n */\n public static isValidBriefcaseId(id: BriefcaseId) {\n return id >= BriefcaseIdValue.FirstValid && id <= BriefcaseIdValue.LastValid;\n }\n\n /** Acquire a new briefcaseId from iModelHub for the supplied iModelId\n * @note usually there should only be one briefcase per iModel per user. If a single user acquires more than one briefcaseId,\n * it's a good idea to supply different aliases for each of them.\n */\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<BriefcaseId> {\n return IModelHost[_hubAccess].acquireNewBriefcaseId(arg);\n }\n\n /**\n * Download a new briefcase from iModelHub for the supplied iModelId.\n *\n * Briefcases are local files holding a copy of an iModel.\n * Briefcases may either be specific to an individual user (so that it can be modified to create changesets), or it can be readonly so it can accept but not create changesets.\n * Every briefcase internally holds its [[BriefcaseId]]. Writeable briefcases have a `BriefcaseId` \"assigned\" to them by iModelHub. No two users will ever have the same BriefcaseId.\n * Readonly briefcases are \"unassigned\" with the special value [[BriefcaseId.Unassigned]].\n *\n * Typically a given user will have only one briefcase on their machine for a given iModelId. Rarely, it may be necessary to use more than one\n * briefcase to make isolated independent sets of changes, but that is exceedingly complicated and rare.\n *\n * Callers of this method may supply a BriefcaseId, or if none is supplied, a new one is acquired from iModelHub.\n *\n * @param arg The arguments that specify the briefcase file to be downloaded.\n * @returns The properties of the local briefcase in a Promise that is resolved after the briefcase is fully downloaded and the briefcase file is ready for use via [BriefcaseDb.open]($backend).\n * @note The location of the local file to hold the briefcase is arbitrary and may be any valid *local* path on your machine. If you don't supply\n * a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named\n * for the IModelId.\n * @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)\n */\n public static async downloadBriefcase(arg: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {\n const briefcaseId = arg.briefcaseId ?? await this.acquireNewBriefcaseId(arg);\n const fileName = arg.fileName ?? this.getFileName({ ...arg, briefcaseId });\n\n if (IModelJsFs.existsSync(fileName))\n throw new IModelError(IModelStatus.FileAlreadyExists, `Briefcase \"${fileName}\" already exists`);\n\n const asOf = arg.asOf ?? IModelVersion.latest().toJSON();\n const changeset = await IModelHost[_hubAccess].getChangesetFromVersion({ ...arg, version: IModelVersion.fromJSON(asOf) });\n const checkpoint: CheckpointProps = { ...arg, changeset };\n\n try {\n await CheckpointManager.downloadCheckpoint({ localFile: fileName, checkpoint, onProgress: arg.onProgress });\n } catch (error: unknown) {\n const errorMessage = `Failed to download briefcase to ${fileName}, errorMessage: ${(error as Error).message}`;\n if (arg.accessToken && arg.briefcaseId === undefined) {\n Logger.logInfo(loggerCategory, `${errorMessage}, releasing the briefcaseId...`);\n await this.releaseBriefcase(arg.accessToken, { briefcaseId, iModelId: arg.iModelId });\n }\n if (IModelJsFs.existsSync(fileName)) {\n if (arg.accessToken && arg.briefcaseId === undefined)\n Logger.logTrace(loggerCategory, `Deleting the file: ${fileName}...`);\n else\n Logger.logInfo(loggerCategory, `${errorMessage}, deleting the file...`);\n try {\n IModelJsFs.unlinkSync(fileName);\n Logger.logInfo(loggerCategory, `Deleted ${fileName}`);\n } catch (deleteError: unknown) {\n Logger.logWarning(loggerCategory, `Failed to delete ${fileName}. errorMessage: ${(deleteError as Error).message}`);\n }\n }\n throw error;\n }\n\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\n const response: LocalBriefcaseProps = {\n fileName,\n briefcaseId,\n iModelId: arg.iModelId,\n iTwinId: arg.iTwinId,\n changeset: checkpoint.changeset,\n fileSize,\n };\n\n // now open the downloaded checkpoint and reset its BriefcaseId\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.ReadWrite);\n } catch (err: any) {\n throw new IModelError(err.errorNumber, `Could not open downloaded briefcase for write access: ${fileName}, err=${err.message}`);\n }\n try {\n nativeDb.enableWalMode(); // local briefcases should use WAL journal mode\n nativeDb.resetBriefcaseId(briefcaseId);\n if (nativeDb.getCurrentChangeset().id !== checkpoint.changeset.id)\n throw new IModelError(IModelStatus.InvalidId, `Downloaded briefcase has wrong changesetId: ${fileName}`);\n } finally {\n nativeDb.saveChanges();\n nativeDb.closeFile();\n }\n return response;\n }\n\n /** Deletes change sets of an iModel from local disk\n * @internal\n */\n public static deleteChangeSetsFromLocalDisk(iModelId: string) {\n const changesetsPath = BriefcaseManager.getChangeSetsPath(iModelId);\n BriefcaseManager.deleteFolderAndContents(changesetsPath);\n }\n\n /** Releases a briefcaseId from iModelHub. After this call it is illegal to generate changesets for the released briefcaseId.\n * @note generally, this method should not be called directly. Instead use [[deleteBriefcaseFiles]].\n * @see deleteBriefcaseFiles\n */\n public static async releaseBriefcase(accessToken: AccessToken, briefcase: BriefcaseProps): Promise<void> {\n if (this.isValidBriefcaseId(briefcase.briefcaseId))\n return IModelHost[_hubAccess].releaseBriefcase({ accessToken, iModelId: briefcase.iModelId, briefcaseId: briefcase.briefcaseId });\n }\n\n /**\n * Delete and clean up a briefcase and all of its associated files. First, this method opens the supplied filename to determine its briefcaseId.\n * Then, if a requestContext is supplied, it releases a BriefcaseId from iModelHub. Finally it deletes the local briefcase file and\n * associated files (that is, all files in the same directory that start with the briefcase name).\n * @param filePath the full file name of the Briefcase to delete\n * @param accessToken for releasing the briefcaseId\n */\n public static async deleteBriefcaseFiles(filePath: LocalFileName, accessToken?: AccessToken): Promise<void> {\n try {\n const db = IModelDb.openDgnDb({ path: filePath }, OpenMode.Readonly);\n const briefcase: BriefcaseProps = {\n iModelId: db.getIModelId(),\n briefcaseId: db.getBriefcaseId(),\n };\n db.closeFile();\n\n if (accessToken) {\n if (this.isValidBriefcaseId(briefcase.briefcaseId)) {\n await BriefcaseManager.releaseBriefcase(accessToken, briefcase);\n }\n }\n } catch { }\n\n // first try to delete the briefcase file\n try {\n if (IModelJsFs.existsSync(filePath))\n IModelJsFs.unlinkSync(filePath);\n } catch (err) {\n throw new IModelError(IModelStatus.BadRequest, `cannot delete briefcase file ${err}`);\n }\n\n // next, delete all files that start with the briefcase's filePath (e.g. \"a.bim-locks\", \"a.bim-journal\", etc.)\n try {\n const dirName = path.dirname(filePath);\n const fileName = path.basename(filePath);\n const files = IModelJsFs.readdirSync(dirName);\n for (const file of files) {\n if (file.startsWith(fileName))\n this.deleteFile(path.join(dirName, file)); // don't throw on error\n }\n } catch { }\n }\n\n /** Deletes a file\n * - Does not throw any error, but logs it instead\n * - Returns true if the delete was successful\n */\n private static deleteFile(pathname: LocalFileName): boolean {\n try {\n IModelJsFs.unlinkSync(pathname);\n } catch (error) {\n Logger.logError(loggerCategory, `Cannot delete file ${pathname}, ${error}`);\n return false;\n }\n return true;\n }\n\n /** Deletes a folder, checking if it's empty\n * - Does not throw any error, but logs it instead\n * - Returns true if the delete was successful\n */\n private static deleteFolderIfEmpty(folderPathname: LocalDirName): boolean {\n try {\n const files = IModelJsFs.readdirSync(folderPathname);\n if (files.length > 0)\n return false;\n\n IModelJsFs.rmdirSync(folderPathname);\n } catch {\n Logger.logError(loggerCategory, `Cannot delete folder: ${folderPathname}`);\n return false;\n }\n return true;\n }\n\n /** Deletes the contents of a folder, but not the folder itself\n * - Does not throw any errors, but logs them.\n * - returns true if the delete was successful.\n */\n private static deleteFolderContents(folderPathname: LocalDirName): boolean {\n if (!IModelJsFs.existsSync(folderPathname))\n return false;\n\n let status = true;\n const files = IModelJsFs.readdirSync(folderPathname);\n for (const file of files) {\n const curPath = path.join(folderPathname, file);\n const locStatus = (IModelJsFs.lstatSync(curPath)?.isDirectory) ? BriefcaseManager.deleteFolderAndContents(curPath) : BriefcaseManager.deleteFile(curPath);\n if (!locStatus)\n status = false;\n }\n return status;\n }\n\n /** Query the hub for the properties for a ChangesetIndex or ChangesetId */\n public static async queryChangeset(arg: { iModelId: GuidString, changeset: ChangesetIndexOrId }): Promise<ChangesetProps> {\n return IModelHost[_hubAccess].queryChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the hub for an array of changeset properties given a ChangesetRange */\n public static async queryChangesets(arg: { iModelId: GuidString, range: ChangesetRange }): Promise<ChangesetProps[]> {\n return IModelHost[_hubAccess].queryChangesets({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the hub for the ChangesetProps of the most recent changeset */\n public static async getLatestChangeset(arg: { iModelId: GuidString }): Promise<ChangesetProps> {\n return IModelHost[_hubAccess].getLatestChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the Id of an iModel by name.\n * @param arg Identifies the iModel of interest\n * @returns the Id of the corresponding iModel, or `undefined` if no such iModel exists.\n */\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\n return IModelHost[_hubAccess].queryIModelByName(arg);\n }\n\n /** Deletes a folder and all it's contents.\n * - Does not throw any errors, but logs them.\n * - returns true if the delete was successful.\n */\n private static deleteFolderAndContents(folderPathname: LocalDirName): boolean {\n if (!IModelJsFs.existsSync(folderPathname))\n return true;\n\n let status = false;\n status = BriefcaseManager.deleteFolderContents(folderPathname);\n if (!status)\n return false;\n\n status = BriefcaseManager.deleteFolderIfEmpty(folderPathname);\n return status;\n }\n\n private static async applySingleChangeset(db: IModelDb, changesetFile: ChangesetFileProps, fastForward: boolean) {\n if (changesetFile.changesType === ChangesetType.Schema || changesetFile.changesType === ChangesetType.SchemaSync)\n db.clearCaches(); // for schema changesets, statement caches may become invalid. Do this *before* applying, in case db needs to be closed (open statements hold db open.)\n\n db[_nativeDb].applyChangeset(changesetFile, fastForward);\n db.changeset = db[_nativeDb].getCurrentChangeset();\n\n // we're done with this changeset, delete it\n IModelJsFs.removeSync(changesetFile.pathname);\n }\n\n /** @internal */\n public static async revertTimelineChanges(db: IModelDb, arg: RevertChangesArgs): Promise<void> {\n if (!db.isOpen || db[_nativeDb].isReadonly())\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to revert timeline changes\");\n\n let currentIndex = db.changeset.index;\n if (currentIndex === undefined)\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\n\n if (!arg.toIndex) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be specified to revert changesets\");\n }\n if (arg.toIndex > currentIndex) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be less than or equal to the current index\");\n }\n if (!db.holdsSchemaLock) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot revert timeline changesets without holding a schema lock\");\n }\n\n // Download change sets\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\n accessToken: arg.accessToken,\n iModelId: db.iModelId,\n range: { first: arg.toIndex, end: currentIndex },\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\n progressCallback: arg.onProgress,\n });\n\n if (changesets.length === 0)\n return;\n\n changesets.reverse();\n db.clearCaches();\n\n const stopwatch = new StopWatch(`Reverting changes`, true);\n Logger.logInfo(loggerCategory, `Starting reverting timeline changes from ${arg.toIndex} to ${currentIndex}`);\n\n /**\n * Revert timeline changes from the current index to the specified index.\n * It does not change parent of the current changeset.\n * All changes during revert operation are stored in a new changeset.\n * Revert operation require schema lock as we do not acquire individual locks for each element.\n * Optionally schema changes can be skipped (required for schema sync case).\n */\n db[_nativeDb].revertTimelineChanges(changesets, arg.skipSchemaChanges ?? false);\n Logger.logInfo(loggerCategory, `Reverted timeline changes from ${arg.toIndex} to ${currentIndex} (${stopwatch.elapsedSeconds} seconds)`);\n\n changesets.forEach((changeset) => {\n IModelJsFs.removeSync(changeset.pathname);\n });\n db.notifyChangesetApplied();\n }\n\n /** @internal */\n public static async pullAndApplyChangesets(db: IModelDb, arg: PullChangesArgs): Promise<void> {\n if (!db.isOpen || db[_nativeDb].isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to process change sets\");\n\n let currentIndex = db.changeset.index;\n if (currentIndex === undefined)\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\n\n const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;\n\n if (db[_nativeDb].hasPendingTxns() && reverse) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot reverse changesets when there are pending changes\");\n }\n\n // Download change sets\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\n accessToken: arg.accessToken,\n iModelId: db.iModelId,\n range: { first: reverse ? arg.toIndex! + 1 : currentIndex + 1, end: reverse ? currentIndex : arg.toIndex }, // eslint-disable-line @typescript-eslint/no-non-null-assertion\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\n progressCallback: arg.onProgress,\n });\n\n if (changesets.length === 0)\n return; // nothing to apply\n\n if (reverse)\n changesets.reverse();\n\n\n let appliedChangesets = -1;\n if (db[_nativeDb].hasPendingTxns() && !reverse && !arg.noFastForward) {\n // attempt to perform fast forward\n for (const changeset of changesets) {\n // do not waste time on schema changesets. They cannot be fastforwarded.\n if (changeset.changesType === ChangesetType.Schema || changeset.changesType === ChangesetType.SchemaSync)\n break;\n\n try {\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description} using fast forward method`);\n await this.applySingleChangeset(db, changeset, true);\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n appliedChangesets++;\n db.saveChanges();\n } catch {\n db.abandonChanges();\n break;\n }\n }\n }\n\n if (appliedChangesets < changesets.length - 1) {\n db[_nativeDb].pullMergeBegin();\n for (const changeset of changesets.filter((_, index) => index > appliedChangesets)) {\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description}`);\n try {\n await this.applySingleChangeset(db, changeset, false);\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n } catch (err: any) {\n if (err instanceof Error) {\n Logger.logError(loggerCategory, `Error applying changeset with id ${stopwatch.description}: ${err.message}`);\n }\n db.abandonChanges();\n db[_nativeDb].pullMergeEnd();\n throw err;\n }\n }\n db[_nativeDb].pullMergeEnd();\n if (!db.isReadonly) {\n db.saveChanges(\"Merge.\");\n }\n }\n\n // notify listeners\n db.notifyChangesetApplied();\n }\n /** create a changeset from the current changes, and push it to iModelHub */\n private static async pushChanges(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\n const changesetProps = db[_nativeDb].startCreateChangeset() as ChangesetFileProps;\n changesetProps.briefcaseId = db.briefcaseId;\n changesetProps.description = arg.description;\n const fileSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\n if (!fileSize) // either undefined or 0 means error\n throw new IModelError(IModelStatus.NoContent, \"error creating changeset\");\n\n changesetProps.size = fileSize;\n\n let retryCount = arg.pushRetryCount ?? 3;\n while (true) {\n try {\n const accessToken = await IModelHost.getAccessToken();\n const index = await IModelHost[_hubAccess].pushChangeset({ accessToken, iModelId: db.iModelId, changesetProps });\n db[_nativeDb].completeCreateChangeset({ index });\n db.changeset = db[_nativeDb].getCurrentChangeset();\n if (!arg.retainLocks)\n await db.locks[_releaseAllLocks]();\n\n return;\n } catch (err: any) {\n const shouldRetry = () => {\n if (retryCount-- <= 0)\n return false;\n switch (err.errorNumber) {\n case IModelHubStatus.AnotherUserPushing:\n case IModelHubStatus.DatabaseTemporarilyLocked:\n case IModelHubStatus.OperationFailed:\n return true;\n }\n return false;\n };\n\n if (!shouldRetry()) {\n db[_nativeDb].abandonCreateChangeset();\n throw err;\n }\n } finally {\n IModelJsFs.removeSync(changesetProps.pathname);\n }\n }\n }\n\n /** Pull/merge (if necessary), then push all local changes as a changeset. Called by [[BriefcaseDb.pushChanges]]\n * @internal\n */\n public static async pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\n let retryCount = arg.mergeRetryCount ?? 5;\n while (true) {\n try {\n await BriefcaseManager.pullAndApplyChangesets(db, arg);\n if (!db.skipSyncSchemasOnPullAndPush)\n await SchemaSync.pull(db);\n return await BriefcaseManager.pushChanges(db, arg);\n } catch (err: any) {\n if (retryCount-- <= 0 || err.errorNumber !== IModelHubStatus.PullIsRequired)\n throw (err);\n await (arg.mergeRetryDelay ?? BeDuration.fromSeconds(3)).wait();\n }\n }\n }\n\n}\n"]}
1
+ {"version":3,"file":"BriefcaseManager.js","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,qCAAqC;AAErC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACQ,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAc,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAY,SAAS,EACrI,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACQ,gBAAgB,EAA0G,aAAa,EAAE,WAAW,EAAE,aAAa,GAEjL,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAqC,MAAM,qBAAqB,CAAC;AAC3F,O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------------------------------------------------------------------------------------------\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 cset csets ecchanges\n\nimport * as path from \"path\";\nimport {\n AccessToken, BeDuration, ChangeSetStatus, DbResult, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch\n} from \"@itwin/core-bentley\";\nimport {\n BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,\n LocalDirName, LocalFileName, RequestNewBriefcaseProps,\n} from \"@itwin/core-common\";\nimport { AcquireNewBriefcaseIdArg, DownloadChangesetArg, DownloadChangesetRangeArg, IModelNameArg } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { CheckpointManager, CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SchemaSync } from \"./SchemaSync\";\nimport { _hubAccess, _nativeDb, _releaseAllLocks } from \"./internal/Symbols\";\nimport { IModelNative } from \"./internal/NativePlatform\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/** The argument for [[BriefcaseManager.downloadBriefcase]]\n * @public\n*/\nexport interface RequestNewBriefcaseArg extends TokenArg, RequestNewBriefcaseProps {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n}\n\n/**\n * Parameters for pushing changesets to iModelHub\n * @public\n */\nexport interface PushChangesArgs extends TokenArg {\n /** A description of the changes. This is visible on the iModel's timeline. */\n description: string;\n /** if present, the locks are retained after the operation. Otherwise, *all* locks are released after the changeset is successfully pushed. */\n retainLocks?: true;\n /** number of times to retry pull/merge if other users are pushing at the same time. Default is 5 */\n mergeRetryCount?: number;\n /** delay to wait between pull/merge retry attempts. Default is 3 seconds */\n mergeRetryDelay?: BeDuration;\n /** the number of time to attempt to retry to push the changeset upon failure. Default is 3 */\n pushRetryCount?: number;\n /** The delay to wait between retry attempts on failed pushes. Default is 3 seconds. */\n pushRetryDelay?: BeDuration;\n /**\n * For testing purpose\n * @internal\n */\n noFastForward?: true;\n}\n\n/**\n * Specifies a specific index for pulling changes.\n * @public\n */\nexport interface ToChangesetArgs extends TokenArg {\n /** The last ChangesetIndex to pull. If not present, pull *all* newer changesets. */\n toIndex?: ChangesetIndex;\n}\n\n/** Arguments for [[BriefcaseManager.pullAndApplyChangesets]]\n * @public\n */\nexport type PullChangesArgs = ToChangesetArgs & {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n /**\n * For testing purpose\n * @internal\n */\n noFastForward?: true;\n};\n\n/** Arguments for [[BriefcaseManager.revertTimelineChanges]]\n * @public\n */\nexport type RevertChangesArgs = Optional<PushChangesArgs, \"description\"> & {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n /** The index of the changeset to revert to */\n toIndex: ChangesetIndex;\n /** If present, schema changes are skipped during the revert operation. */\n skipSchemaChanges?: true;\n};\n\n/** Manages downloading Briefcases and downloading and uploading changesets.\n * @public\n */\nexport class BriefcaseManager {\n /** Get the local path of the folder storing files that are associated with an imodel */\n public static getIModelPath(iModelId: GuidString): LocalDirName { return path.join(this._cacheDir, iModelId); }\n\n /** @internal */\n public static getChangeSetsPath(iModelId: GuidString): LocalDirName { return path.join(this.getIModelPath(iModelId), \"changesets\"); }\n\n /** @internal */\n public static getChangeCachePathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.ecchanges\")); }\n\n /** @internal */\n public static getChangedElementsPathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.elems\")); }\n\n private static _briefcaseSubDir = \"briefcases\";\n /** Get the local path of the folder storing briefcases associated with the specified iModel. */\n public static getBriefcaseBasePath(iModelId: GuidString): LocalDirName {\n return path.join(this.getIModelPath(iModelId), this._briefcaseSubDir);\n }\n\n /** Get the name of the local file that holds, or will hold, a local briefcase in the briefcase cache.\n * @note The briefcase cache is a local directory established in the call to [[BriefcaseManager.initialize]].\n * @param briefcase the iModelId and BriefcaseId for the filename\n * @see getIModelPath\n */\n public static getFileName(briefcase: BriefcaseProps): LocalFileName {\n return path.join(this.getBriefcaseBasePath(briefcase.iModelId), `${briefcase.briefcaseId}.bim`);\n }\n\n private static setupCacheDir(cacheRootDir: LocalDirName) {\n this._cacheDir = cacheRootDir;\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\n }\n\n private static _initialized?: boolean;\n /** Initialize BriefcaseManager\n * @param cacheRootDir The root directory for storing a cache of downloaded briefcase files on the local computer.\n * Briefcases are stored relative to this path in sub-folders organized by IModelId.\n * @note It is perfectly valid for applications to store briefcases in locations they manage, outside of `cacheRootDir`.\n */\n public static initialize(cacheRootDir: LocalDirName) {\n if (this._initialized)\n return;\n this.setupCacheDir(cacheRootDir);\n IModelHost.onBeforeShutdown.addOnce(() => this.finalize());\n this._initialized = true;\n }\n\n private static finalize() {\n this._initialized = false;\n }\n\n /** Get a list of the local briefcase held in the briefcase cache, optionally for a single iModelId\n * @param iModelId if present, only briefcases for this iModelId are returned, otherwise all briefcases for all\n * iModels in the briefcase cache are returned.\n * @note usually there should only be one briefcase per iModel.\n */\n public static getCachedBriefcases(iModelId?: GuidString): LocalBriefcaseProps[] {\n const briefcaseList: LocalBriefcaseProps[] = [];\n const iModelDirs = IModelJsFs.readdirSync(this._cacheDir);\n for (const iModelDir of iModelDirs) {\n if (iModelId && iModelId !== iModelDir)\n continue;\n const bcPath = path.join(this._cacheDir, iModelDir, this._briefcaseSubDir);\n try {\n if (!IModelJsFs.lstatSync(bcPath)?.isDirectory)\n continue;\n } catch {\n continue;\n }\n\n const briefcases = IModelJsFs.readdirSync(bcPath);\n for (const briefcaseName of briefcases) {\n if (briefcaseName.endsWith(\".bim\")) {\n try {\n const fileName = path.join(bcPath, briefcaseName);\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\n const db = IModelDb.openDgnDb({ path: fileName }, OpenMode.Readonly);\n briefcaseList.push({ fileName, iTwinId: db.getITwinId(), iModelId: db.getIModelId(), briefcaseId: db.getBriefcaseId(), changeset: db.getCurrentChangeset(), fileSize });\n db.closeFile();\n } catch { }\n }\n }\n }\n return briefcaseList;\n }\n\n private static _cacheDir: LocalDirName;\n /** Get the root directory for the briefcase cache */\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\n\n /** Determine whether the supplied briefcaseId is in the range of assigned BriefcaseIds issued by iModelHub\n * @note this does check whether the id was actually acquired by the caller.\n */\n public static isValidBriefcaseId(id: BriefcaseId) {\n return id >= BriefcaseIdValue.FirstValid && id <= BriefcaseIdValue.LastValid;\n }\n\n /** Acquire a new briefcaseId from iModelHub for the supplied iModelId\n * @note usually there should only be one briefcase per iModel per user. If a single user acquires more than one briefcaseId,\n * it's a good idea to supply different aliases for each of them.\n */\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<BriefcaseId> {\n return IModelHost[_hubAccess].acquireNewBriefcaseId(arg);\n }\n\n /**\n * Download a new briefcase from iModelHub for the supplied iModelId.\n *\n * Briefcases are local files holding a copy of an iModel.\n * Briefcases may either be specific to an individual user (so that it can be modified to create changesets), or it can be readonly so it can accept but not create changesets.\n * Every briefcase internally holds its [[BriefcaseId]]. Writeable briefcases have a `BriefcaseId` \"assigned\" to them by iModelHub. No two users will ever have the same BriefcaseId.\n * Readonly briefcases are \"unassigned\" with the special value [[BriefcaseId.Unassigned]].\n *\n * Typically a given user will have only one briefcase on their machine for a given iModelId. Rarely, it may be necessary to use more than one\n * briefcase to make isolated independent sets of changes, but that is exceedingly complicated and rare.\n *\n * Callers of this method may supply a BriefcaseId, or if none is supplied, a new one is acquired from iModelHub.\n *\n * @param arg The arguments that specify the briefcase file to be downloaded.\n * @returns The properties of the local briefcase in a Promise that is resolved after the briefcase is fully downloaded and the briefcase file is ready for use via [BriefcaseDb.open]($backend).\n * @note The location of the local file to hold the briefcase is arbitrary and may be any valid *local* path on your machine. If you don't supply\n * a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named\n * for the IModelId.\n * @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)\n */\n public static async downloadBriefcase(arg: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {\n const briefcaseId = arg.briefcaseId ?? await this.acquireNewBriefcaseId(arg);\n const fileName = arg.fileName ?? this.getFileName({ ...arg, briefcaseId });\n\n if (IModelJsFs.existsSync(fileName))\n throw new IModelError(IModelStatus.FileAlreadyExists, `Briefcase \"${fileName}\" already exists`);\n\n const asOf = arg.asOf ?? IModelVersion.latest().toJSON();\n const changeset = await IModelHost[_hubAccess].getChangesetFromVersion({ ...arg, version: IModelVersion.fromJSON(asOf) });\n const checkpoint: CheckpointProps = { ...arg, changeset };\n\n try {\n await CheckpointManager.downloadCheckpoint({ localFile: fileName, checkpoint, onProgress: arg.onProgress });\n } catch (error: unknown) {\n const errorMessage = `Failed to download briefcase to ${fileName}, errorMessage: ${(error as Error).message}`;\n if (arg.accessToken && arg.briefcaseId === undefined) {\n Logger.logInfo(loggerCategory, `${errorMessage}, releasing the briefcaseId...`);\n await this.releaseBriefcase(arg.accessToken, { briefcaseId, iModelId: arg.iModelId });\n }\n if (IModelJsFs.existsSync(fileName)) {\n if (arg.accessToken && arg.briefcaseId === undefined)\n Logger.logTrace(loggerCategory, `Deleting the file: ${fileName}...`);\n else\n Logger.logInfo(loggerCategory, `${errorMessage}, deleting the file...`);\n try {\n IModelJsFs.unlinkSync(fileName);\n Logger.logInfo(loggerCategory, `Deleted ${fileName}`);\n } catch (deleteError: unknown) {\n Logger.logWarning(loggerCategory, `Failed to delete ${fileName}. errorMessage: ${(deleteError as Error).message}`);\n }\n }\n throw error;\n }\n\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\n const response: LocalBriefcaseProps = {\n fileName,\n briefcaseId,\n iModelId: arg.iModelId,\n iTwinId: arg.iTwinId,\n changeset: checkpoint.changeset,\n fileSize,\n };\n\n // now open the downloaded checkpoint and reset its BriefcaseId\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.ReadWrite);\n } catch (err: any) {\n throw new IModelError(err.errorNumber, `Could not open downloaded briefcase for write access: ${fileName}, err=${err.message}`);\n }\n try {\n nativeDb.enableWalMode(); // local briefcases should use WAL journal mode\n nativeDb.resetBriefcaseId(briefcaseId);\n if (nativeDb.getCurrentChangeset().id !== checkpoint.changeset.id)\n throw new IModelError(IModelStatus.InvalidId, `Downloaded briefcase has wrong changesetId: ${fileName}`);\n } finally {\n nativeDb.saveChanges();\n nativeDb.closeFile();\n }\n return response;\n }\n\n /** Deletes change sets of an iModel from local disk\n * @internal\n */\n public static deleteChangeSetsFromLocalDisk(iModelId: string) {\n const changesetsPath = BriefcaseManager.getChangeSetsPath(iModelId);\n BriefcaseManager.deleteFolderAndContents(changesetsPath);\n }\n\n /** Releases a briefcaseId from iModelHub. After this call it is illegal to generate changesets for the released briefcaseId.\n * @note generally, this method should not be called directly. Instead use [[deleteBriefcaseFiles]].\n * @see deleteBriefcaseFiles\n */\n public static async releaseBriefcase(accessToken: AccessToken, briefcase: BriefcaseProps): Promise<void> {\n if (this.isValidBriefcaseId(briefcase.briefcaseId))\n return IModelHost[_hubAccess].releaseBriefcase({ accessToken, iModelId: briefcase.iModelId, briefcaseId: briefcase.briefcaseId });\n }\n\n /**\n * Delete and clean up a briefcase and all of its associated files. First, this method opens the supplied filename to determine its briefcaseId.\n * Then, if a requestContext is supplied, it releases a BriefcaseId from iModelHub. Finally it deletes the local briefcase file and\n * associated files (that is, all files in the same directory that start with the briefcase name).\n * @param filePath the full file name of the Briefcase to delete\n * @param accessToken for releasing the briefcaseId\n */\n public static async deleteBriefcaseFiles(filePath: LocalFileName, accessToken?: AccessToken): Promise<void> {\n try {\n const db = IModelDb.openDgnDb({ path: filePath }, OpenMode.Readonly);\n const briefcase: BriefcaseProps = {\n iModelId: db.getIModelId(),\n briefcaseId: db.getBriefcaseId(),\n };\n db.closeFile();\n\n if (accessToken) {\n if (this.isValidBriefcaseId(briefcase.briefcaseId)) {\n await BriefcaseManager.releaseBriefcase(accessToken, briefcase);\n }\n }\n } catch { }\n\n // first try to delete the briefcase file\n try {\n if (IModelJsFs.existsSync(filePath))\n IModelJsFs.unlinkSync(filePath);\n } catch (err) {\n throw new IModelError(IModelStatus.BadRequest, `cannot delete briefcase file ${err}`);\n }\n\n // next, delete all files that start with the briefcase's filePath (e.g. \"a.bim-locks\", \"a.bim-journal\", etc.)\n try {\n const dirName = path.dirname(filePath);\n const fileName = path.basename(filePath);\n const files = IModelJsFs.readdirSync(dirName);\n for (const file of files) {\n if (file.startsWith(fileName))\n this.deleteFile(path.join(dirName, file)); // don't throw on error\n }\n } catch { }\n }\n\n /** Deletes a file\n * - Does not throw any error, but logs it instead\n * - Returns true if the delete was successful\n */\n private static deleteFile(pathname: LocalFileName): boolean {\n try {\n IModelJsFs.unlinkSync(pathname);\n } catch (error) {\n Logger.logError(loggerCategory, `Cannot delete file ${pathname}, ${error}`);\n return false;\n }\n return true;\n }\n\n /** Deletes a folder, checking if it's empty\n * - Does not throw any error, but logs it instead\n * - Returns true if the delete was successful\n */\n private static deleteFolderIfEmpty(folderPathname: LocalDirName): boolean {\n try {\n const files = IModelJsFs.readdirSync(folderPathname);\n if (files.length > 0)\n return false;\n\n IModelJsFs.rmdirSync(folderPathname);\n } catch {\n Logger.logError(loggerCategory, `Cannot delete folder: ${folderPathname}`);\n return false;\n }\n return true;\n }\n\n /** Deletes the contents of a folder, but not the folder itself\n * - Does not throw any errors, but logs them.\n * - returns true if the delete was successful.\n */\n private static deleteFolderContents(folderPathname: LocalDirName): boolean {\n if (!IModelJsFs.existsSync(folderPathname))\n return false;\n\n let status = true;\n const files = IModelJsFs.readdirSync(folderPathname);\n for (const file of files) {\n const curPath = path.join(folderPathname, file);\n const locStatus = (IModelJsFs.lstatSync(curPath)?.isDirectory) ? BriefcaseManager.deleteFolderAndContents(curPath) : BriefcaseManager.deleteFile(curPath);\n if (!locStatus)\n status = false;\n }\n return status;\n }\n\n /** Download all the changesets in the specified range.\n * @beta\n */\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\n return IModelHost[_hubAccess].downloadChangesets(arg);\n }\n\n /** Download a single changeset.\n * @beta\n */\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\n return IModelHost[_hubAccess].downloadChangeset(arg);\n }\n\n /** Query the hub for the properties for a ChangesetIndex or ChangesetId */\n public static async queryChangeset(arg: { iModelId: GuidString, changeset: ChangesetIndexOrId }): Promise<ChangesetProps> {\n return IModelHost[_hubAccess].queryChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the hub for an array of changeset properties given a ChangesetRange */\n public static async queryChangesets(arg: { iModelId: GuidString, range: ChangesetRange }): Promise<ChangesetProps[]> {\n return IModelHost[_hubAccess].queryChangesets({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the hub for the ChangesetProps of the most recent changeset */\n public static async getLatestChangeset(arg: { iModelId: GuidString }): Promise<ChangesetProps> {\n return IModelHost[_hubAccess].getLatestChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the Id of an iModel by name.\n * @param arg Identifies the iModel of interest\n * @returns the Id of the corresponding iModel, or `undefined` if no such iModel exists.\n */\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\n return IModelHost[_hubAccess].queryIModelByName(arg);\n }\n\n /** Deletes a folder and all it's contents.\n * - Does not throw any errors, but logs them.\n * - returns true if the delete was successful.\n */\n private static deleteFolderAndContents(folderPathname: LocalDirName): boolean {\n if (!IModelJsFs.existsSync(folderPathname))\n return true;\n\n let status = false;\n status = BriefcaseManager.deleteFolderContents(folderPathname);\n if (!status)\n return false;\n\n status = BriefcaseManager.deleteFolderIfEmpty(folderPathname);\n return status;\n }\n\n private static async applySingleChangeset(db: IModelDb, changesetFile: ChangesetFileProps, fastForward: boolean) {\n if (changesetFile.changesType === ChangesetType.Schema || changesetFile.changesType === ChangesetType.SchemaSync)\n db.clearCaches(); // for schema changesets, statement caches may become invalid. Do this *before* applying, in case db needs to be closed (open statements hold db open.)\n\n db[_nativeDb].applyChangeset(changesetFile, fastForward);\n db.changeset = db[_nativeDb].getCurrentChangeset();\n\n // we're done with this changeset, delete it\n IModelJsFs.removeSync(changesetFile.pathname);\n }\n\n /** @internal */\n public static async revertTimelineChanges(db: IModelDb, arg: RevertChangesArgs): Promise<void> {\n if (!db.isOpen || db[_nativeDb].isReadonly())\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to revert timeline changes\");\n\n let currentIndex = db.changeset.index;\n if (currentIndex === undefined)\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\n\n if (!arg.toIndex) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be specified to revert changesets\");\n }\n if (arg.toIndex > currentIndex) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be less than or equal to the current index\");\n }\n if (!db.holdsSchemaLock) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot revert timeline changesets without holding a schema lock\");\n }\n\n // Download change sets\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\n accessToken: arg.accessToken,\n iModelId: db.iModelId,\n range: { first: arg.toIndex, end: currentIndex },\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\n progressCallback: arg.onProgress,\n });\n\n if (changesets.length === 0)\n return;\n\n changesets.reverse();\n db.clearCaches();\n\n const stopwatch = new StopWatch(`Reverting changes`, true);\n Logger.logInfo(loggerCategory, `Starting reverting timeline changes from ${arg.toIndex} to ${currentIndex}`);\n\n /**\n * Revert timeline changes from the current index to the specified index.\n * It does not change parent of the current changeset.\n * All changes during revert operation are stored in a new changeset.\n * Revert operation require schema lock as we do not acquire individual locks for each element.\n * Optionally schema changes can be skipped (required for schema sync case).\n */\n db[_nativeDb].revertTimelineChanges(changesets, arg.skipSchemaChanges ?? false);\n Logger.logInfo(loggerCategory, `Reverted timeline changes from ${arg.toIndex} to ${currentIndex} (${stopwatch.elapsedSeconds} seconds)`);\n\n changesets.forEach((changeset) => {\n IModelJsFs.removeSync(changeset.pathname);\n });\n db.notifyChangesetApplied();\n }\n\n /** @internal */\n public static async pullAndApplyChangesets(db: IModelDb, arg: PullChangesArgs): Promise<void> {\n if (!db.isOpen || db[_nativeDb].isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to process change sets\");\n\n let currentIndex = db.changeset.index;\n if (currentIndex === undefined)\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\n\n const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;\n\n if (db[_nativeDb].hasPendingTxns() && reverse) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot reverse changesets when there are pending changes\");\n }\n\n // Download change sets\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\n accessToken: arg.accessToken,\n iModelId: db.iModelId,\n range: { first: reverse ? arg.toIndex! + 1 : currentIndex + 1, end: reverse ? currentIndex : arg.toIndex }, // eslint-disable-line @typescript-eslint/no-non-null-assertion\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\n progressCallback: arg.onProgress,\n });\n\n if (changesets.length === 0)\n return; // nothing to apply\n\n if (reverse)\n changesets.reverse();\n\n\n let appliedChangesets = -1;\n if (db[_nativeDb].hasPendingTxns() && !reverse && !arg.noFastForward) {\n // attempt to perform fast forward\n for (const changeset of changesets) {\n // do not waste time on schema changesets. They cannot be fastforwarded.\n if (changeset.changesType === ChangesetType.Schema || changeset.changesType === ChangesetType.SchemaSync)\n break;\n\n try {\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description} using fast forward method`);\n await this.applySingleChangeset(db, changeset, true);\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n appliedChangesets++;\n db.saveChanges();\n } catch {\n db.abandonChanges();\n break;\n }\n }\n }\n\n if (appliedChangesets < changesets.length - 1) {\n db[_nativeDb].pullMergeBegin();\n for (const changeset of changesets.filter((_, index) => index > appliedChangesets)) {\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description}`);\n try {\n await this.applySingleChangeset(db, changeset, false);\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n } catch (err: any) {\n if (err instanceof Error) {\n Logger.logError(loggerCategory, `Error applying changeset with id ${stopwatch.description}: ${err.message}`);\n }\n db.abandonChanges();\n db[_nativeDb].pullMergeEnd();\n throw err;\n }\n }\n db[_nativeDb].pullMergeEnd();\n if (!db.isReadonly) {\n db.saveChanges(\"Merge.\");\n }\n }\n\n // notify listeners\n db.notifyChangesetApplied();\n }\n /** create a changeset from the current changes, and push it to iModelHub */\n private static async pushChanges(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\n const changesetProps = db[_nativeDb].startCreateChangeset() as ChangesetFileProps;\n changesetProps.briefcaseId = db.briefcaseId;\n changesetProps.description = arg.description;\n const fileSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\n if (!fileSize) // either undefined or 0 means error\n throw new IModelError(IModelStatus.NoContent, \"error creating changeset\");\n\n changesetProps.size = fileSize;\n const id = IModelNative.platform.DgnDb.computeChangesetId(changesetProps);\n if (id !== changesetProps.id) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR_InvalidChangeSetVersion, `Changeset id ${changesetProps.id} does not match computed id ${id}.`);\n }\n\n let retryCount = arg.pushRetryCount ?? 3;\n while (true) {\n try {\n const accessToken = await IModelHost.getAccessToken();\n const index = await IModelHost[_hubAccess].pushChangeset({ accessToken, iModelId: db.iModelId, changesetProps });\n db[_nativeDb].completeCreateChangeset({ index });\n db.changeset = db[_nativeDb].getCurrentChangeset();\n if (!arg.retainLocks)\n await db.locks[_releaseAllLocks]();\n\n return;\n } catch (err: any) {\n const shouldRetry = () => {\n if (retryCount-- <= 0)\n return false;\n switch (err.errorNumber) {\n case IModelHubStatus.AnotherUserPushing:\n case IModelHubStatus.DatabaseTemporarilyLocked:\n case IModelHubStatus.OperationFailed:\n return true;\n }\n return false;\n };\n\n if (!shouldRetry()) {\n db[_nativeDb].abandonCreateChangeset();\n throw err;\n }\n } finally {\n IModelJsFs.removeSync(changesetProps.pathname);\n }\n }\n }\n\n /** Pull/merge (if necessary), then push all local changes as a changeset. Called by [[BriefcaseDb.pushChanges]]\n * @internal\n */\n public static async pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\n let retryCount = arg.mergeRetryCount ?? 5;\n while (true) {\n try {\n await BriefcaseManager.pullAndApplyChangesets(db, arg);\n if (!db.skipSyncSchemasOnPullAndPush)\n await SchemaSync.pull(db);\n return await BriefcaseManager.pushChanges(db, arg);\n } catch (err: any) {\n if (retryCount-- <= 0 || err.errorNumber !== IModelHubStatus.PullIsRequired)\n throw (err);\n await (arg.mergeRetryDelay ?? BeDuration.fromSeconds(3)).wait();\n }\n }\n }\n\n}\n"]}
@@ -7,7 +7,7 @@ import { DefinitionElement } from "./Element";
7
7
  import { IModelDb } from "./IModelDb";
8
8
  import { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from "./Entity";
9
9
  /** Defines the appearance for graphics in Geometric elements
10
- * @public
10
+ * @public @preview
11
11
  */
12
12
  export declare class SubCategory extends DefinitionElement {
13
13
  static get className(): string;
@@ -69,7 +69,7 @@ export declare class SubCategory extends DefinitionElement {
69
69
  static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
70
70
  }
71
71
  /** A Category element is the target of the `category` member of [[GeometricElement]].
72
- * @public
72
+ * @public @preview
73
73
  */
74
74
  export declare class Category extends DefinitionElement {
75
75
  static get className(): string;
@@ -101,7 +101,7 @@ export declare class Category extends DefinitionElement {
101
101
  setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void;
102
102
  }
103
103
  /** Categorizes 2d GeometricElements.
104
- * @public
104
+ * @public @preview
105
105
  */
106
106
  export declare class DrawingCategory extends Category {
107
107
  static get className(): string;
@@ -136,7 +136,7 @@ export declare class DrawingCategory extends Category {
136
136
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
137
137
  }
138
138
  /** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).
139
- * @public
139
+ * @public @preview
140
140
  */
141
141
  export declare class SpatialCategory extends Category {
142
142
  static get className(): string;
@@ -11,7 +11,7 @@ import { DefinitionElement } from "./Element";
11
11
  import { IModelDb } from "./IModelDb";
12
12
  import { CategoryOwnsSubCategories } from "./NavigationRelationship";
13
13
  /** Defines the appearance for graphics in Geometric elements
14
- * @public
14
+ * @public @preview
15
15
  */
16
16
  export class SubCategory extends DefinitionElement {
17
17
  static get className() { return "SubCategory"; }
@@ -123,7 +123,7 @@ export class SubCategory extends DefinitionElement {
123
123
  }
124
124
  }
125
125
  /** A Category element is the target of the `category` member of [[GeometricElement]].
126
- * @public
126
+ * @public @preview
127
127
  */
128
128
  export class Category extends DefinitionElement {
129
129
  static get className() { return "Category"; }
@@ -186,7 +186,7 @@ export class Category extends DefinitionElement {
186
186
  }
187
187
  }
188
188
  /** Categorizes 2d GeometricElements.
189
- * @public
189
+ * @public @preview
190
190
  */
191
191
  export class DrawingCategory extends Category {
192
192
  static get className() { return "DrawingCategory"; }
@@ -241,7 +241,7 @@ export class DrawingCategory extends Category {
241
241
  }
242
242
  }
243
243
  /** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).
244
- * @public
244
+ * @public @preview
245
245
  */
246
246
  export class SpatialCategory extends Category {
247
247
  static get className() { return "SpatialCategory"; }
@@ -1 +1 @@
1
- {"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,WAAW,EAAiB,IAAI,EAA0C,IAAI,EAAE,qBAAqB,GACtG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IACxE,qDAAqD;IAC9C,UAAU,CAAwB;IACzC,gDAAgD;IACzC,WAAW,CAAU;IAE5B,YAAsB,KAAuB,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAqB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Q,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF","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\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\n\n/** Defines the appearance for graphics in Geometric elements\n * @public\n */\nexport class SubCategory extends DefinitionElement {\n public static override get className(): string { return \"SubCategory\"; }\n /** The Appearance parameters for this SubCategory */\n public appearance: SubCategoryAppearance;\n /** Optional description of this SubCategory. */\n public description?: string;\n\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.appearance = new SubCategoryAppearance(props.appearance);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * SubCategory custom HandledProps include 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"description\", source: \"Class\" },\n { propertyName: \"properties\", source: \"Class\" },\n ];\n\n /**\n * SubCategory deserializes 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\n const elProps = super.deserialize(props) as SubCategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n if (props.row.properties !== '') {\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\n } else {\n elProps.appearance = undefined;\n }\n return elProps;\n }\n\n /**\n * SubCategory serialize 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.description !== undefined) {\n inst.description = props.description;\n }\n if (props.appearance !== undefined) {\n inst.properties = JSON.stringify(props.appearance);\n }\n return inst;\n }\n\n public override toJSON(): SubCategoryProps {\n const val = super.toJSON() as SubCategoryProps;\n val.appearance = this.appearance.toJSON();\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the SubCategory's name (its Code value). */\n public getSubCategoryName(): string { return this.code.value; }\n /** Get the Id of the SubCategory. */\n public getSubCategoryId(): Id64String { return this.id; }\n /** Get the Id of this SubCategory's parent Category. */\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\n /** Check if this is the default SubCategory of its parent Category. */\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\n\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\n * @param iModel The IModel\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\n * @param codeValue The name of the SubCategory\n */\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\n }\n\n /** Create a new SubCategory\n * @param iModelDb The iModel\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The newly constructed SubCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\n if (appearance instanceof SubCategoryAppearance)\n appearance = appearance.toJSON();\n\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\n const subCategoryProps: SubCategoryProps = {\n classFullName: this.classFullName,\n model: parentCategory.model,\n parent: new CategoryOwnsSubCategories(parentCategoryId),\n code: this.createCode(iModelDb, parentCategoryId, name),\n appearance,\n };\n return new SubCategory(subCategoryProps, iModelDb);\n }\n\n /** Insert a new SubCategory\n * @param iModelDb Insert into this iModel\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The Id of the newly inserted SubCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\n return iModelDb.elements.insertElement(subCategory.toJSON());\n }\n}\n\n/** A Category element is the target of the `category` member of [[GeometricElement]].\n * @public\n */\nexport class Category extends DefinitionElement {\n public static override get className(): string { return \"Category\"; }\n public rank: Rank = Rank.User;\n public description?: string;\n\n protected constructor(props: CategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.rank = JsonUtils.asInt(props.rank);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * Category custom HandledProps include 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"rank\", source: \"Class\" },\n { propertyName: \"description\", source: \"Class\" },\n ];\n\n /**\n * Category deserializes 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\n const elProps = super.deserialize(props) as CategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n elProps.rank = JsonUtils.asInt(props.row.rank);\n return elProps;\n }\n\n /**\n * Category serialize 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (undefined !== props.description) {\n inst.description = props.description;\n }\n inst.rank = props.rank;\n return inst;\n }\n public override toJSON(): CategoryProps {\n const val = super.toJSON() as CategoryProps;\n val.rank = this.rank;\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the Id of the default SubCategory for this Category. */\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\n\n /** Set the appearance of the default SubCategory for this Category */\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\n if (props instanceof SubCategoryAppearance)\n props = props.toJSON();\n\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\n subCat.appearance = new SubCategoryAppearance(props);\n this.iModel.elements.updateElement(subCat.toJSON());\n }\n}\n\n/** Categorizes 2d GeometricElements.\n * @public\n */\nexport class DrawingCategory extends Category {\n public static override get className(): string { return \"DrawingCategory\"; }\n\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\n\n /** Looks up the CategoryId of a DrawingCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A drawing category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new DrawingCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @returns The newly constructed DrawingCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new DrawingCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new DrawingCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\n * @returns The Id of the newly inserted DrawingCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const elements = iModelDb.elements;\n category.id = elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\n * @public\n */\nexport class SpatialCategory extends Category {\n public static override get className(): string { return \"SpatialCategory\"; }\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\n\n /** Looks up the CategoryId of a SpatialCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A spatial category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new SpatialCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the SpatialCategory\n * @returns The newly constructed SpatialCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new SpatialCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new SpatialCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\n * @param name The name of the SpatialCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\n * @returns The Id of the newly inserted SpatialCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n category.id = iModelDb.elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n"]}
1
+ {"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,WAAW,EAAiB,IAAI,EAA0C,IAAI,EAAE,qBAAqB,GACtG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,W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CAAC;YACxD,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QAC1J,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF","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\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\n\n/** Defines the appearance for graphics in Geometric elements\n * @public @preview\n */\nexport class SubCategory extends DefinitionElement {\n public static override get className(): string { return \"SubCategory\"; }\n /** The Appearance parameters for this SubCategory */\n public appearance: SubCategoryAppearance;\n /** Optional description of this SubCategory. */\n public description?: string;\n\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.appearance = new SubCategoryAppearance(props.appearance);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * SubCategory custom HandledProps include 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"description\", source: \"Class\" },\n { propertyName: \"properties\", source: \"Class\" },\n ];\n\n /**\n * SubCategory deserializes 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\n const elProps = super.deserialize(props) as SubCategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n if (props.row.properties !== '') {\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\n } else {\n elProps.appearance = undefined;\n }\n return elProps;\n }\n\n /**\n * SubCategory serialize 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.description !== undefined) {\n inst.description = props.description;\n }\n if (props.appearance !== undefined) {\n inst.properties = JSON.stringify(props.appearance);\n }\n return inst;\n }\n\n public override toJSON(): SubCategoryProps {\n const val = super.toJSON() as SubCategoryProps;\n val.appearance = this.appearance.toJSON();\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the SubCategory's name (its Code value). */\n public getSubCategoryName(): string { return this.code.value; }\n /** Get the Id of the SubCategory. */\n public getSubCategoryId(): Id64String { return this.id; }\n /** Get the Id of this SubCategory's parent Category. */\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\n /** Check if this is the default SubCategory of its parent Category. */\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\n\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\n * @param iModel The IModel\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\n * @param codeValue The name of the SubCategory\n */\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\n }\n\n /** Create a new SubCategory\n * @param iModelDb The iModel\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The newly constructed SubCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\n if (appearance instanceof SubCategoryAppearance)\n appearance = appearance.toJSON();\n\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\n const subCategoryProps: SubCategoryProps = {\n classFullName: this.classFullName,\n model: parentCategory.model,\n parent: new CategoryOwnsSubCategories(parentCategoryId),\n code: this.createCode(iModelDb, parentCategoryId, name),\n appearance,\n };\n return new SubCategory(subCategoryProps, iModelDb);\n }\n\n /** Insert a new SubCategory\n * @param iModelDb Insert into this iModel\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The Id of the newly inserted SubCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\n return iModelDb.elements.insertElement(subCategory.toJSON());\n }\n}\n\n/** A Category element is the target of the `category` member of [[GeometricElement]].\n * @public @preview\n */\nexport class Category extends DefinitionElement {\n public static override get className(): string { return \"Category\"; }\n public rank: Rank = Rank.User;\n public description?: string;\n\n protected constructor(props: CategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.rank = JsonUtils.asInt(props.rank);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * Category custom HandledProps include 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"rank\", source: \"Class\" },\n { propertyName: \"description\", source: \"Class\" },\n ];\n\n /**\n * Category deserializes 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\n const elProps = super.deserialize(props) as CategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n elProps.rank = JsonUtils.asInt(props.row.rank);\n return elProps;\n }\n\n /**\n * Category serialize 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (undefined !== props.description) {\n inst.description = props.description;\n }\n inst.rank = props.rank;\n return inst;\n }\n public override toJSON(): CategoryProps {\n const val = super.toJSON() as CategoryProps;\n val.rank = this.rank;\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the Id of the default SubCategory for this Category. */\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\n\n /** Set the appearance of the default SubCategory for this Category */\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\n if (props instanceof SubCategoryAppearance)\n props = props.toJSON();\n\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\n subCat.appearance = new SubCategoryAppearance(props);\n this.iModel.elements.updateElement(subCat.toJSON());\n }\n}\n\n/** Categorizes 2d GeometricElements.\n * @public @preview\n */\nexport class DrawingCategory extends Category {\n public static override get className(): string { return \"DrawingCategory\"; }\n\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\n\n /** Looks up the CategoryId of a DrawingCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A drawing category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new DrawingCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @returns The newly constructed DrawingCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new DrawingCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new DrawingCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\n * @returns The Id of the newly inserted DrawingCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const elements = iModelDb.elements;\n category.id = elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\n * @public @preview\n */\nexport class SpatialCategory extends Category {\n public static override get className(): string { return \"SpatialCategory\"; }\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\n\n /** Looks up the CategoryId of a SpatialCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A spatial category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new SpatialCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the SpatialCategory\n * @returns The newly constructed SpatialCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new SpatialCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new SpatialCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\n * @param name The name of the SpatialCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\n * @returns The Id of the newly inserted SpatialCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n category.id = iModelDb.elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module ECDb
3
3
  */
4
4
  import { Id64String } from "@itwin/core-bentley";
5
- import { SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "./SqliteChangesetReader";
5
+ import { AnyDb, SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "./SqliteChangesetReader";
6
6
  /**
7
7
  * Record meta data for the change.
8
8
  * @beta
@@ -31,33 +31,96 @@ export interface ChangedECInstance {
31
31
  $meta?: ChangeMetaData;
32
32
  [key: string]: any;
33
33
  }
34
+ /**
35
+ * Represents a cache for unifying EC changes.
36
+ * @beta
37
+ */
38
+ export interface ECChangeUnifierCache extends Disposable {
39
+ /**
40
+ * Retrieves the value associated with the specified key from the cache.
41
+ * @param key - The key to retrieve the value for.
42
+ * @returns The value associated with the key, or undefined if the key is not found.
43
+ */
44
+ get(key: string): ChangedECInstance | undefined;
45
+ /**
46
+ * Sets the value associated with the specified key in the cache.
47
+ * @param key - The key to set the value for.
48
+ * @param value - The value to be associated with the key.
49
+ */
50
+ set(key: string, value: ChangedECInstance): void;
51
+ /**
52
+ * Returns an iterator for all the values in the cache.
53
+ * @returns An iterator for all the values in the cache.
54
+ */
55
+ all(): IterableIterator<ChangedECInstance>;
56
+ /**
57
+ * Returns the number of entries in the cache.
58
+ * @returns The number of entries in the cache.
59
+ */
60
+ count(): number;
61
+ }
62
+ /** @beta */
63
+ export declare namespace ECChangeUnifierCache {
64
+ /**
65
+ * Creates and returns a new in-memory cache for EC change unification.
66
+ * @note This cache is fast but recommended for small to medium size changesets. As it store changes in memory using a hash map, it may run out of memory for larger changesets.
67
+ * @returns {ECChangeUnifierCache} An instance of cache that store changes in memory using a hash map.
68
+ */
69
+ function createInMemoryCache(): ECChangeUnifierCache;
70
+ /**
71
+ * Creates an ECChangeUnifierCache that is backed by a database.
72
+ * @note This cache is suitable for larger changesets and uses SQLite to store changes. It is slower than the in-memory cache but can handle larger datasets without running out of memory.
73
+ * @param db - The database instance to use for caching.
74
+ * @param bufferedReadInstanceSizeInBytes - The size in bytes for buffered read instances. Defaults to 10 MB.
75
+ * @returns An instance of ECChangeUnifierCache backed by SQLite temp db.
76
+ */
77
+ function createSqliteBackedCache(db: AnyDb, bufferedReadInstanceSizeInBytes?: number): ECChangeUnifierCache;
78
+ }
34
79
  /**
35
80
  * Combine partial changed instance into single instance.
36
81
  * Partial changes is per table and a single instance can
37
82
  * span multiple tables.
38
83
  * @beta
39
84
  */
40
- export declare class PartialECChangeUnifier {
85
+ export declare class PartialECChangeUnifier implements Disposable {
86
+ private _db;
41
87
  private _cache;
42
88
  private _readonly;
89
+ constructor(_db: AnyDb, _cache?: ECChangeUnifierCache);
90
+ /**
91
+ * Dispose the instance.
92
+ */
93
+ [Symbol.dispose](): void;
43
94
  /**
44
95
  * Get root class id for a given class
45
96
  * @param classId given class id
46
97
  * @param db use to find root class
47
98
  * @returns return root class id
48
99
  */
49
- private static getRootClassId;
100
+ private getRootClassId;
101
+ /**
102
+ * Checks if the given `rhsClassId` is an instance of the `lhsClassId`.
103
+ * @param rhsClassId The ID of the right-hand side class.
104
+ * @param lhsClassId The ID of the left-hand side class.
105
+ * @returns `true` if `rhsClassId` is an instance of `lhsClassId`, `false` otherwise.
106
+ */
107
+ private instanceOf;
50
108
  /**
51
109
  * Combine partial instance with instance with same key if already exists.
52
110
  * @param rhs partial instance
53
111
  */
54
112
  private combine;
113
+ /**
114
+ * Returns the number of instances in the cache.
115
+ * @returns The number of instances in the cache.
116
+ */
117
+ getInstanceCount(): number;
55
118
  /**
56
119
  * Build key from EC change.
57
120
  * @param change EC change
58
121
  * @returns key created from EC change.
59
122
  */
60
- private static buildKey;
123
+ private buildKey;
61
124
  /**
62
125
  * Append partial changes which will be combine using there instance key.
63
126
  * @note $meta property must be present on partial change as information
@@ -66,10 +129,6 @@ export declare class PartialECChangeUnifier {
66
129
  * @beta
67
130
  */
68
131
  appendFrom(adaptor: ChangesetECAdaptor): void;
69
- /**
70
- * Delete $meta from all the instances.
71
- */
72
- stripMetaData(): void;
73
132
  /**
74
133
  * Returns complete EC change instances.
75
134
  * @beta
@@ -1 +1 @@
1
- {"version":3,"file":"ChangesetECAdaptor.d.ts","sourceRoot":"","sources":["../../src/ChangesetECAdaptor.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAwB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAuB,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAoVvH;;;KAGK;AACL,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,EAAE,EAAE,cAAc,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,gBAAgB,CAAC;IACxB,sFAAsF;IACtF,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,iEAAiE;IACjE,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEhC,YAAY,EAAE,UAAU,CAAC;IAEzB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AA4BD;;;;;GAKG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAwC;IACtD,OAAO,CAAC,SAAS,CAAS;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAgC7B;;;OAGG;IACH,OAAO,CAAC,OAAO;IAkCf;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,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