@itwin/core-backend 5.0.0-dev.11 → 5.0.0-dev.110

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 (1057) hide show
  1. package/CHANGELOG.md +70 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +15 -35
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js +2 -0
  5. package/lib/cjs/BackendHubAccess.js.map +1 -1
  6. package/lib/cjs/BisCoreSchema.d.ts.map +1 -1
  7. package/lib/cjs/BisCoreSchema.js +2 -0
  8. package/lib/cjs/BisCoreSchema.js.map +1 -1
  9. package/lib/cjs/BlobContainerService.d.ts +4 -4
  10. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  11. package/lib/cjs/BlobContainerService.js.map +1 -1
  12. package/lib/cjs/BriefcaseManager.d.ts +10 -0
  13. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  14. package/lib/cjs/BriefcaseManager.js +63 -20
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/CatalogDb.d.ts +103 -0
  17. package/lib/cjs/CatalogDb.d.ts.map +1 -0
  18. package/lib/cjs/CatalogDb.js +271 -0
  19. package/lib/cjs/CatalogDb.js.map +1 -0
  20. package/lib/cjs/Category.js +6 -1
  21. package/lib/cjs/Category.js.map +1 -1
  22. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  23. package/lib/cjs/ChangeSummaryManager.js +102 -27
  24. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  25. package/lib/cjs/ChangedElementsDb.d.ts +3 -3
  26. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
  27. package/lib/cjs/ChangedElementsDb.js +8 -7
  28. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  29. package/lib/cjs/ChangesetECAdaptor.d.ts +3 -3
  30. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  31. package/lib/cjs/ChangesetECAdaptor.js +32 -19
  32. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  33. package/lib/cjs/CheckpointManager.d.ts +12 -17
  34. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  35. package/lib/cjs/CheckpointManager.js +40 -92
  36. package/lib/cjs/CheckpointManager.js.map +1 -1
  37. package/lib/cjs/ClassRegistry.d.ts +46 -2
  38. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  39. package/lib/cjs/ClassRegistry.js +93 -37
  40. package/lib/cjs/ClassRegistry.js.map +1 -1
  41. package/lib/cjs/CloudSqlite.d.ts +104 -20
  42. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  43. package/lib/cjs/CloudSqlite.js +172 -54
  44. package/lib/cjs/CloudSqlite.js.map +1 -1
  45. package/lib/cjs/CodeService.d.ts +2 -0
  46. package/lib/cjs/CodeService.d.ts.map +1 -1
  47. package/lib/cjs/CodeService.js +4 -0
  48. package/lib/cjs/CodeService.js.map +1 -1
  49. package/lib/cjs/CodeSpecs.js +3 -2
  50. package/lib/cjs/CodeSpecs.js.map +1 -1
  51. package/lib/cjs/CustomViewState3dCreator.js +7 -6
  52. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  53. package/lib/cjs/DevTools.js +16 -16
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.js +2 -0
  56. package/lib/cjs/DisplayStyle.js.map +1 -1
  57. package/lib/cjs/ECDb.d.ts +53 -60
  58. package/lib/cjs/ECDb.d.ts.map +1 -1
  59. package/lib/cjs/ECDb.js +115 -73
  60. package/lib/cjs/ECDb.js.map +1 -1
  61. package/lib/cjs/ECSchemaXmlContext.d.ts +1 -1
  62. package/lib/cjs/ECSchemaXmlContext.js +2 -1
  63. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  64. package/lib/cjs/ECSqlStatement.d.ts +185 -4
  65. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  66. package/lib/cjs/ECSqlStatement.js +237 -9
  67. package/lib/cjs/ECSqlStatement.js.map +1 -1
  68. package/lib/cjs/Element.d.ts +29 -26
  69. package/lib/cjs/Element.d.ts.map +1 -1
  70. package/lib/cjs/Element.js +173 -48
  71. package/lib/cjs/Element.js.map +1 -1
  72. package/lib/cjs/ElementAspect.d.ts +0 -5
  73. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  74. package/lib/cjs/ElementAspect.js +25 -16
  75. package/lib/cjs/ElementAspect.js.map +1 -1
  76. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  77. package/lib/cjs/ElementTreeWalker.js +17 -12
  78. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  79. package/lib/cjs/Entity.d.ts +50 -10
  80. package/lib/cjs/Entity.d.ts.map +1 -1
  81. package/lib/cjs/Entity.js +79 -16
  82. package/lib/cjs/Entity.js.map +1 -1
  83. package/lib/cjs/ExportGraphics.js +4 -0
  84. package/lib/cjs/ExportGraphics.js.map +1 -1
  85. package/lib/cjs/ExternalSource.js +22 -0
  86. package/lib/cjs/ExternalSource.js.map +1 -1
  87. package/lib/cjs/FontFile.d.ts +68 -0
  88. package/lib/cjs/FontFile.d.ts.map +1 -0
  89. package/lib/cjs/FontFile.js +36 -0
  90. package/lib/cjs/FontFile.js.map +1 -0
  91. package/lib/cjs/GeoCoordConfig.js +8 -8
  92. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  93. package/lib/cjs/GeometrySummary.js +6 -3
  94. package/lib/cjs/GeometrySummary.js.map +1 -1
  95. package/lib/cjs/IModelDb.d.ts +213 -73
  96. package/lib/cjs/IModelDb.d.ts.map +1 -1
  97. package/lib/cjs/IModelDb.js +379 -172
  98. package/lib/cjs/IModelDb.js.map +1 -1
  99. package/lib/cjs/IModelDbFonts.d.ts +54 -0
  100. package/lib/cjs/IModelDbFonts.d.ts.map +1 -0
  101. package/lib/cjs/{IModelCloneContext.js → IModelDbFonts.js} +2 -7
  102. package/lib/cjs/IModelDbFonts.js.map +1 -0
  103. package/lib/cjs/IModelElementCloneContext.d.ts +2 -0
  104. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  105. package/lib/cjs/IModelElementCloneContext.js +12 -1
  106. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  107. package/lib/cjs/IModelHost.d.ts +15 -15
  108. package/lib/cjs/IModelHost.d.ts.map +1 -1
  109. package/lib/cjs/IModelHost.js +76 -43
  110. package/lib/cjs/IModelHost.js.map +1 -1
  111. package/lib/cjs/IModelJsFs.d.ts.map +1 -1
  112. package/lib/cjs/IModelJsFs.js +17 -1
  113. package/lib/cjs/IModelJsFs.js.map +1 -1
  114. package/lib/cjs/ImageSourceConversion.d.ts +49 -0
  115. package/lib/cjs/ImageSourceConversion.d.ts.map +1 -0
  116. package/lib/cjs/ImageSourceConversion.js +37 -0
  117. package/lib/cjs/ImageSourceConversion.js.map +1 -0
  118. package/lib/cjs/IpcHost.d.ts.map +1 -1
  119. package/lib/cjs/IpcHost.js +19 -33
  120. package/lib/cjs/IpcHost.js.map +1 -1
  121. package/lib/cjs/LocalHub.js +8 -2
  122. package/lib/cjs/LocalHub.js.map +1 -1
  123. package/lib/cjs/LocalhostIpcHost.js +5 -6
  124. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  125. package/lib/cjs/Material.js +40 -0
  126. package/lib/cjs/Material.js.map +1 -1
  127. package/lib/cjs/Model.d.ts +1 -1
  128. package/lib/cjs/Model.d.ts.map +1 -1
  129. package/lib/cjs/Model.js +27 -2
  130. package/lib/cjs/Model.js.map +1 -1
  131. package/lib/cjs/NativeAppStorage.js +5 -3
  132. package/lib/cjs/NativeAppStorage.js.map +1 -1
  133. package/lib/cjs/NativeHost.d.ts.map +1 -1
  134. package/lib/cjs/NativeHost.js +10 -4
  135. package/lib/cjs/NativeHost.js.map +1 -1
  136. package/lib/cjs/NavigationRelationship.js +25 -25
  137. package/lib/cjs/NavigationRelationship.js.map +1 -1
  138. package/lib/cjs/PromiseMemoizer.d.ts +2 -3
  139. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  140. package/lib/cjs/PromiseMemoizer.js +12 -5
  141. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  142. package/lib/cjs/PropertyStore.js +1 -4
  143. package/lib/cjs/PropertyStore.js.map +1 -1
  144. package/lib/cjs/Relationship.d.ts.map +1 -1
  145. package/lib/cjs/Relationship.js +15 -1
  146. package/lib/cjs/Relationship.js.map +1 -1
  147. package/lib/cjs/SQLiteDb.d.ts +6 -4
  148. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  149. package/lib/cjs/SQLiteDb.js +79 -19
  150. package/lib/cjs/SQLiteDb.js.map +1 -1
  151. package/lib/cjs/Schema.d.ts +25 -1
  152. package/lib/cjs/Schema.d.ts.map +1 -1
  153. package/lib/cjs/Schema.js +44 -8
  154. package/lib/cjs/Schema.js.map +1 -1
  155. package/lib/cjs/SchemaSync.js +1 -4
  156. package/lib/cjs/SchemaSync.js.map +1 -1
  157. package/lib/cjs/SheetIndex.js +6 -0
  158. package/lib/cjs/SheetIndex.js.map +1 -1
  159. package/lib/cjs/SqliteChangesetReader.d.ts +11 -3
  160. package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
  161. package/lib/cjs/SqliteChangesetReader.js +21 -5
  162. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  163. package/lib/cjs/SqliteStatement.d.ts +4 -2
  164. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  165. package/lib/cjs/SqliteStatement.js +13 -1
  166. package/lib/cjs/SqliteStatement.js.map +1 -1
  167. package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
  168. package/lib/cjs/TextAnnotationGeometry.js +38 -11
  169. package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
  170. package/lib/cjs/TextAnnotationLayout.d.ts +10 -3
  171. package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
  172. package/lib/cjs/TextAnnotationLayout.js +56 -18
  173. package/lib/cjs/TextAnnotationLayout.js.map +1 -1
  174. package/lib/cjs/Texture.js +3 -0
  175. package/lib/cjs/Texture.js.map +1 -1
  176. package/lib/cjs/TileStorage.js +6 -1
  177. package/lib/cjs/TileStorage.js.map +1 -1
  178. package/lib/cjs/TxnManager.d.ts +55 -4
  179. package/lib/cjs/TxnManager.d.ts.map +1 -1
  180. package/lib/cjs/TxnManager.js +234 -58
  181. package/lib/cjs/TxnManager.js.map +1 -1
  182. package/lib/cjs/ViewDefinition.d.ts +6 -6
  183. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  184. package/lib/cjs/ViewDefinition.js +81 -26
  185. package/lib/cjs/ViewDefinition.js.map +1 -1
  186. package/lib/cjs/ViewStateHydrator.d.ts +0 -1
  187. package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
  188. package/lib/cjs/ViewStateHydrator.js +1 -11
  189. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  190. package/lib/cjs/ViewStore.d.ts.map +1 -1
  191. package/lib/cjs/ViewStore.js +32 -29
  192. package/lib/cjs/ViewStore.js.map +1 -1
  193. package/lib/cjs/core-backend.d.ts +8 -2
  194. package/lib/cjs/core-backend.d.ts.map +1 -1
  195. package/lib/cjs/core-backend.js +8 -2
  196. package/lib/cjs/core-backend.js.map +1 -1
  197. package/lib/cjs/domains/FunctionalElements.js +1 -1
  198. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  199. package/lib/cjs/internal/ChangesetConflictArgs.d.ts +40 -2
  200. package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -1
  201. package/lib/cjs/internal/ChangesetConflictArgs.js +101 -0
  202. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
  203. package/lib/cjs/internal/ChannelAdmin.d.ts +1 -1
  204. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
  205. package/lib/cjs/internal/ChannelAdmin.js +16 -13
  206. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  207. package/lib/cjs/internal/FontFileImpl.d.ts +34 -0
  208. package/lib/cjs/internal/FontFileImpl.d.ts.map +1 -0
  209. package/lib/cjs/internal/FontFileImpl.js +143 -0
  210. package/lib/cjs/internal/FontFileImpl.js.map +1 -0
  211. package/lib/cjs/{HubMock.d.ts → internal/HubMock.d.ts} +6 -7
  212. package/lib/cjs/internal/HubMock.d.ts.map +1 -0
  213. package/lib/cjs/{HubMock.js → internal/HubMock.js} +40 -15
  214. package/lib/cjs/internal/HubMock.js.map +1 -0
  215. package/lib/cjs/internal/IModelDbFontsImpl.d.ts +7 -0
  216. package/lib/cjs/internal/IModelDbFontsImpl.d.ts.map +1 -0
  217. package/lib/cjs/internal/IModelDbFontsImpl.js +186 -0
  218. package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -0
  219. package/lib/cjs/internal/NoLocks.js +2 -5
  220. package/lib/cjs/internal/NoLocks.js.map +1 -1
  221. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
  222. package/lib/cjs/internal/ServerBasedLocks.js +6 -6
  223. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  224. package/lib/cjs/internal/Symbols.d.ts +8 -0
  225. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  226. package/lib/cjs/internal/Symbols.js +9 -1
  227. package/lib/cjs/internal/Symbols.js.map +1 -1
  228. package/lib/cjs/internal/workspace/SettingsImpl.js +6 -9
  229. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  230. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +8 -12
  231. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  232. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +2 -16
  233. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  234. package/lib/cjs/internal/workspace/WorkspaceImpl.js +57 -121
  235. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  236. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +1 -4
  237. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  238. package/lib/cjs/rpc/multipart.d.ts.map +1 -1
  239. package/lib/cjs/rpc/multipart.js +2 -1
  240. package/lib/cjs/rpc/multipart.js.map +1 -1
  241. package/lib/cjs/rpc/tracing.js +2 -2
  242. package/lib/cjs/rpc/tracing.js.map +1 -1
  243. package/lib/cjs/rpc/web/request.d.ts.map +1 -1
  244. package/lib/cjs/rpc/web/request.js +2 -1
  245. package/lib/cjs/rpc/web/request.js.map +1 -1
  246. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  247. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +6 -2
  248. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  249. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -3
  250. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  251. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  252. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +15 -25
  253. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  254. package/lib/cjs/workspace/Workspace.d.ts +6 -13
  255. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  256. package/lib/cjs/workspace/Workspace.js.map +1 -1
  257. package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -7
  258. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
  259. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  260. package/lib/esm/BackendHubAccess.d.ts +209 -0
  261. package/lib/esm/BackendHubAccess.d.ts.map +1 -0
  262. package/lib/esm/BackendHubAccess.js +41 -0
  263. package/lib/esm/BackendHubAccess.js.map +1 -0
  264. package/lib/esm/BackendLoggerCategory.d.ts +88 -0
  265. package/lib/esm/BackendLoggerCategory.d.ts.map +1 -0
  266. package/lib/esm/BackendLoggerCategory.js +93 -0
  267. package/lib/esm/BackendLoggerCategory.js.map +1 -0
  268. package/lib/esm/BisCoreSchema.d.ts +22 -0
  269. package/lib/esm/BisCoreSchema.d.ts.map +1 -0
  270. package/lib/esm/BisCoreSchema.js +61 -0
  271. package/lib/esm/BisCoreSchema.js.map +1 -0
  272. package/lib/esm/BlobContainerService.d.ts +159 -0
  273. package/lib/esm/BlobContainerService.d.ts.map +1 -0
  274. package/lib/esm/BlobContainerService.js +15 -0
  275. package/lib/esm/BlobContainerService.js.map +1 -0
  276. package/lib/esm/BriefcaseManager.d.ts +213 -0
  277. package/lib/esm/BriefcaseManager.d.ts.map +1 -0
  278. package/lib/esm/BriefcaseManager.js +520 -0
  279. package/lib/esm/BriefcaseManager.js.map +1 -0
  280. package/lib/esm/CatalogDb.d.ts +103 -0
  281. package/lib/esm/CatalogDb.d.ts.map +1 -0
  282. package/lib/esm/CatalogDb.js +267 -0
  283. package/lib/esm/CatalogDb.js.map +1 -0
  284. package/lib/esm/Category.d.ts +136 -0
  285. package/lib/esm/Category.d.ts.map +1 -0
  286. package/lib/esm/Category.js +224 -0
  287. package/lib/esm/Category.js.map +1 -0
  288. package/lib/esm/ChangeSummaryManager.d.ts +161 -0
  289. package/lib/esm/ChangeSummaryManager.d.ts.map +1 -0
  290. package/lib/esm/ChangeSummaryManager.js +421 -0
  291. package/lib/esm/ChangeSummaryManager.js.map +1 -0
  292. package/lib/esm/ChangedElementsDb.d.ts +101 -0
  293. package/lib/esm/ChangedElementsDb.d.ts.map +1 -0
  294. package/lib/esm/ChangedElementsDb.js +165 -0
  295. package/lib/esm/ChangedElementsDb.js.map +1 -0
  296. package/lib/esm/ChangesetECAdaptor.d.ts +203 -0
  297. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -0
  298. package/lib/esm/ChangesetECAdaptor.js +815 -0
  299. package/lib/esm/ChangesetECAdaptor.js.map +1 -0
  300. package/lib/esm/ChannelControl.d.ts +68 -0
  301. package/lib/esm/ChannelControl.d.ts.map +1 -0
  302. package/lib/esm/ChannelControl.js +15 -0
  303. package/lib/esm/ChannelControl.js.map +1 -0
  304. package/lib/esm/CheckpointManager.d.ts +118 -0
  305. package/lib/esm/CheckpointManager.d.ts.map +1 -0
  306. package/lib/esm/CheckpointManager.js +321 -0
  307. package/lib/esm/CheckpointManager.js.map +1 -0
  308. package/lib/esm/ClassRegistry.d.ts +134 -0
  309. package/lib/esm/ClassRegistry.d.ts.map +1 -0
  310. package/lib/esm/ClassRegistry.js +324 -0
  311. package/lib/esm/ClassRegistry.js.map +1 -0
  312. package/lib/esm/CloudSqlite.d.ts +766 -0
  313. package/lib/esm/CloudSqlite.d.ts.map +1 -0
  314. package/lib/esm/CloudSqlite.js +622 -0
  315. package/lib/esm/CloudSqlite.js.map +1 -0
  316. package/lib/esm/CodeService.d.ts +402 -0
  317. package/lib/esm/CodeService.d.ts.map +1 -0
  318. package/lib/esm/CodeService.js +65 -0
  319. package/lib/esm/CodeService.js.map +1 -0
  320. package/lib/esm/CodeSpecs.d.ts +59 -0
  321. package/lib/esm/CodeSpecs.d.ts.map +1 -0
  322. package/lib/esm/CodeSpecs.js +152 -0
  323. package/lib/esm/CodeSpecs.js.map +1 -0
  324. package/lib/esm/ConcurrentQuery.d.ts +14 -0
  325. package/lib/esm/ConcurrentQuery.d.ts.map +1 -0
  326. package/lib/esm/ConcurrentQuery.js +33 -0
  327. package/lib/esm/ConcurrentQuery.js.map +1 -0
  328. package/lib/esm/CustomViewState3dCreator.d.ts +22 -0
  329. package/lib/esm/CustomViewState3dCreator.d.ts.map +1 -0
  330. package/lib/esm/CustomViewState3dCreator.js +78 -0
  331. package/lib/esm/CustomViewState3dCreator.js.map +1 -0
  332. package/lib/esm/DevTools.d.ts +73 -0
  333. package/lib/esm/DevTools.d.ts.map +1 -0
  334. package/lib/esm/DevTools.js +153 -0
  335. package/lib/esm/DevTools.js.map +1 -0
  336. package/lib/esm/DisplayStyle.d.ts +99 -0
  337. package/lib/esm/DisplayStyle.d.ts.map +1 -0
  338. package/lib/esm/DisplayStyle.js +264 -0
  339. package/lib/esm/DisplayStyle.js.map +1 -0
  340. package/lib/esm/ECDb.d.ts +206 -0
  341. package/lib/esm/ECDb.d.ts.map +1 -0
  342. package/lib/esm/ECDb.js +410 -0
  343. package/lib/esm/ECDb.js.map +1 -0
  344. package/lib/esm/ECSchemaXmlContext.d.ts +46 -0
  345. package/lib/esm/ECSchemaXmlContext.d.ts.map +1 -0
  346. package/lib/esm/ECSchemaXmlContext.js +66 -0
  347. package/lib/esm/ECSchemaXmlContext.js.map +1 -0
  348. package/lib/esm/ECSqlStatement.d.ts +671 -0
  349. package/lib/esm/ECSqlStatement.d.ts.map +1 -0
  350. package/lib/esm/ECSqlStatement.js +1028 -0
  351. package/lib/esm/ECSqlStatement.js.map +1 -0
  352. package/lib/esm/Element.d.ts +999 -0
  353. package/lib/esm/Element.d.ts.map +1 -0
  354. package/lib/esm/Element.js +1375 -0
  355. package/lib/esm/Element.js.map +1 -0
  356. package/lib/esm/ElementAspect.d.ts +164 -0
  357. package/lib/esm/ElementAspect.d.ts.map +1 -0
  358. package/lib/esm/ElementAspect.js +205 -0
  359. package/lib/esm/ElementAspect.js.map +1 -0
  360. package/lib/esm/ElementGraphics.d.ts +7 -0
  361. package/lib/esm/ElementGraphics.d.ts.map +1 -0
  362. package/lib/esm/ElementGraphics.js +36 -0
  363. package/lib/esm/ElementGraphics.js.map +1 -0
  364. package/lib/esm/ElementTreeWalker.d.ts +182 -0
  365. package/lib/esm/ElementTreeWalker.d.ts.map +1 -0
  366. package/lib/esm/ElementTreeWalker.js +425 -0
  367. package/lib/esm/ElementTreeWalker.js.map +1 -0
  368. package/lib/esm/Entity.d.ts +146 -0
  369. package/lib/esm/Entity.d.ts.map +1 -0
  370. package/lib/esm/Entity.js +186 -0
  371. package/lib/esm/Entity.js.map +1 -0
  372. package/lib/esm/EntityReferences.d.ts +50 -0
  373. package/lib/esm/EntityReferences.d.ts.map +1 -0
  374. package/lib/esm/EntityReferences.js +92 -0
  375. package/lib/esm/EntityReferences.js.map +1 -0
  376. package/lib/esm/ExportGraphics.d.ts +318 -0
  377. package/lib/esm/ExportGraphics.d.ts.map +1 -0
  378. package/lib/esm/ExportGraphics.js +209 -0
  379. package/lib/esm/ExportGraphics.js.map +1 -0
  380. package/lib/esm/ExternalSource.d.ts +89 -0
  381. package/lib/esm/ExternalSource.d.ts.map +1 -0
  382. package/lib/esm/ExternalSource.js +139 -0
  383. package/lib/esm/ExternalSource.js.map +1 -0
  384. package/lib/esm/FontFile.d.ts +68 -0
  385. package/lib/esm/FontFile.d.ts.map +1 -0
  386. package/lib/esm/FontFile.js +33 -0
  387. package/lib/esm/FontFile.js.map +1 -0
  388. package/lib/esm/GeoCoordConfig.d.ts +30 -0
  389. package/lib/esm/GeoCoordConfig.d.ts.map +1 -0
  390. package/lib/esm/GeoCoordConfig.js +78 -0
  391. package/lib/esm/GeoCoordConfig.js.map +1 -0
  392. package/lib/esm/GeographicCRSServices.d.ts +40 -0
  393. package/lib/esm/GeographicCRSServices.d.ts.map +1 -0
  394. package/lib/esm/GeographicCRSServices.js +17 -0
  395. package/lib/esm/GeographicCRSServices.js.map +1 -0
  396. package/lib/esm/GeometrySummary.d.ts +5 -0
  397. package/lib/esm/GeometrySummary.d.ts.map +1 -0
  398. package/lib/esm/GeometrySummary.js +381 -0
  399. package/lib/esm/GeometrySummary.js.map +1 -0
  400. package/lib/esm/IModelDb.d.ts +1407 -0
  401. package/lib/esm/IModelDb.d.ts.map +1 -0
  402. package/lib/esm/IModelDb.js +3267 -0
  403. package/lib/esm/IModelDb.js.map +1 -0
  404. package/lib/esm/IModelDbFonts.d.ts +54 -0
  405. package/lib/esm/IModelDbFonts.d.ts.map +1 -0
  406. package/lib/esm/IModelDbFonts.js +9 -0
  407. package/lib/esm/IModelDbFonts.js.map +1 -0
  408. package/lib/esm/IModelElementCloneContext.d.ts +92 -0
  409. package/lib/esm/IModelElementCloneContext.d.ts.map +1 -0
  410. package/lib/esm/IModelElementCloneContext.js +168 -0
  411. package/lib/esm/IModelElementCloneContext.js.map +1 -0
  412. package/lib/esm/IModelHost.d.ts +387 -0
  413. package/lib/esm/IModelHost.d.ts.map +1 -0
  414. package/lib/esm/IModelHost.js +502 -0
  415. package/lib/esm/IModelHost.js.map +1 -0
  416. package/lib/esm/IModelJsFs.d.ts +62 -0
  417. package/lib/esm/IModelJsFs.d.ts.map +1 -0
  418. package/lib/esm/IModelJsFs.js +151 -0
  419. package/lib/esm/IModelJsFs.js.map +1 -0
  420. package/lib/esm/ImageSourceConversion.d.ts +49 -0
  421. package/lib/esm/ImageSourceConversion.d.ts.map +1 -0
  422. package/lib/esm/ImageSourceConversion.js +33 -0
  423. package/lib/esm/ImageSourceConversion.js.map +1 -0
  424. package/lib/esm/IpcHost.d.ts +111 -0
  425. package/lib/esm/IpcHost.d.ts.map +1 -0
  426. package/lib/esm/IpcHost.js +292 -0
  427. package/lib/esm/IpcHost.js.map +1 -0
  428. package/lib/esm/LineStyle.d.ts +312 -0
  429. package/lib/esm/LineStyle.d.ts.map +1 -0
  430. package/lib/esm/LineStyle.js +293 -0
  431. package/lib/esm/LineStyle.js.map +1 -0
  432. package/lib/esm/LocalHub.d.ts +163 -0
  433. package/lib/esm/LocalHub.d.ts.map +1 -0
  434. package/lib/esm/LocalHub.js +583 -0
  435. package/lib/esm/LocalHub.js.map +1 -0
  436. package/lib/esm/LocalhostIpcHost.d.ts +22 -0
  437. package/lib/esm/LocalhostIpcHost.d.ts.map +1 -0
  438. package/lib/esm/LocalhostIpcHost.js +74 -0
  439. package/lib/esm/LocalhostIpcHost.js.map +1 -0
  440. package/lib/esm/LockControl.d.ts +73 -0
  441. package/lib/esm/LockControl.d.ts.map +1 -0
  442. package/lib/esm/LockControl.js +9 -0
  443. package/lib/esm/LockControl.js.map +1 -0
  444. package/lib/esm/Material.d.ts +131 -0
  445. package/lib/esm/Material.d.ts.map +1 -0
  446. package/lib/esm/Material.js +235 -0
  447. package/lib/esm/Material.js.map +1 -0
  448. package/lib/esm/Model.d.ts +375 -0
  449. package/lib/esm/Model.d.ts.map +1 -0
  450. package/lib/esm/Model.js +484 -0
  451. package/lib/esm/Model.js.map +1 -0
  452. package/lib/esm/NativeAppStorage.d.ts +52 -0
  453. package/lib/esm/NativeAppStorage.d.ts.map +1 -0
  454. package/lib/esm/NativeAppStorage.js +205 -0
  455. package/lib/esm/NativeAppStorage.js.map +1 -0
  456. package/lib/esm/NativeHost.d.ts +53 -0
  457. package/lib/esm/NativeHost.d.ts.map +1 -0
  458. package/lib/esm/NativeHost.js +161 -0
  459. package/lib/esm/NativeHost.js.map +1 -0
  460. package/lib/esm/NavigationRelationship.d.ts +185 -0
  461. package/lib/esm/NavigationRelationship.d.ts.map +1 -0
  462. package/lib/esm/NavigationRelationship.js +238 -0
  463. package/lib/esm/NavigationRelationship.js.map +1 -0
  464. package/lib/esm/PromiseMemoizer.d.ts +48 -0
  465. package/lib/esm/PromiseMemoizer.d.ts.map +1 -0
  466. package/lib/esm/PromiseMemoizer.js +101 -0
  467. package/lib/esm/PromiseMemoizer.js.map +1 -0
  468. package/lib/esm/PropertyStore.d.ts +134 -0
  469. package/lib/esm/PropertyStore.d.ts.map +1 -0
  470. package/lib/esm/PropertyStore.js +177 -0
  471. package/lib/esm/PropertyStore.js.map +1 -0
  472. package/lib/esm/Relationship.d.ts +399 -0
  473. package/lib/esm/Relationship.d.ts.map +1 -0
  474. package/lib/esm/Relationship.js +476 -0
  475. package/lib/esm/Relationship.js.map +1 -0
  476. package/lib/esm/RpcBackend.d.ts +6 -0
  477. package/lib/esm/RpcBackend.d.ts.map +1 -0
  478. package/lib/esm/RpcBackend.js +28 -0
  479. package/lib/esm/RpcBackend.js.map +1 -0
  480. package/lib/esm/SQLiteDb.d.ts +324 -0
  481. package/lib/esm/SQLiteDb.d.ts.map +1 -0
  482. package/lib/esm/SQLiteDb.js +380 -0
  483. package/lib/esm/SQLiteDb.js.map +1 -0
  484. package/lib/esm/Schema.d.ts +79 -0
  485. package/lib/esm/Schema.d.ts.map +1 -0
  486. package/lib/esm/Schema.js +113 -0
  487. package/lib/esm/Schema.js.map +1 -0
  488. package/lib/esm/SchemaSync.d.ts +47 -0
  489. package/lib/esm/SchemaSync.d.ts.map +1 -0
  490. package/lib/esm/SchemaSync.js +148 -0
  491. package/lib/esm/SchemaSync.js.map +1 -0
  492. package/lib/esm/SchemaUtils.d.ts +19 -0
  493. package/lib/esm/SchemaUtils.d.ts.map +1 -0
  494. package/lib/esm/SchemaUtils.js +37 -0
  495. package/lib/esm/SchemaUtils.js.map +1 -0
  496. package/lib/esm/SheetIndex.d.ts +148 -0
  497. package/lib/esm/SheetIndex.d.ts.map +1 -0
  498. package/lib/esm/SheetIndex.js +228 -0
  499. package/lib/esm/SheetIndex.js.map +1 -0
  500. package/lib/esm/SqliteChangesetReader.d.ts +278 -0
  501. package/lib/esm/SqliteChangesetReader.d.ts.map +1 -0
  502. package/lib/esm/SqliteChangesetReader.js +337 -0
  503. package/lib/esm/SqliteChangesetReader.js.map +1 -0
  504. package/lib/esm/SqliteStatement.d.ts +375 -0
  505. package/lib/esm/SqliteStatement.d.ts.map +1 -0
  506. package/lib/esm/SqliteStatement.js +615 -0
  507. package/lib/esm/SqliteStatement.js.map +1 -0
  508. package/lib/esm/TextAnnotationElement.d.ts +54 -0
  509. package/lib/esm/TextAnnotationElement.d.ts.map +1 -0
  510. package/lib/esm/TextAnnotationElement.js +89 -0
  511. package/lib/esm/TextAnnotationElement.js.map +1 -0
  512. package/lib/esm/TextAnnotationGeometry.d.ts +32 -0
  513. package/lib/esm/TextAnnotationGeometry.d.ts.map +1 -0
  514. package/lib/esm/TextAnnotationGeometry.js +181 -0
  515. package/lib/esm/TextAnnotationGeometry.js.map +1 -0
  516. package/lib/esm/TextAnnotationLayout.d.ts +177 -0
  517. package/lib/esm/TextAnnotationLayout.d.ts.map +1 -0
  518. package/lib/esm/TextAnnotationLayout.js +513 -0
  519. package/lib/esm/TextAnnotationLayout.js.map +1 -0
  520. package/lib/esm/Texture.d.ts +58 -0
  521. package/lib/esm/Texture.d.ts.map +1 -0
  522. package/lib/esm/Texture.js +81 -0
  523. package/lib/esm/Texture.js.map +1 -0
  524. package/lib/esm/TileStorage.d.ts +59 -0
  525. package/lib/esm/TileStorage.d.ts.map +1 -0
  526. package/lib/esm/TileStorage.js +158 -0
  527. package/lib/esm/TileStorage.js.map +1 -0
  528. package/lib/esm/TxnManager.d.ts +296 -0
  529. package/lib/esm/TxnManager.d.ts.map +1 -0
  530. package/lib/esm/TxnManager.js +619 -0
  531. package/lib/esm/TxnManager.js.map +1 -0
  532. package/lib/esm/ViewDefinition.d.ts +392 -0
  533. package/lib/esm/ViewDefinition.d.ts.map +1 -0
  534. package/lib/esm/ViewDefinition.js +638 -0
  535. package/lib/esm/ViewDefinition.js.map +1 -0
  536. package/lib/esm/ViewStateHydrator.d.ts +14 -0
  537. package/lib/esm/ViewStateHydrator.d.ts.map +1 -0
  538. package/lib/esm/ViewStateHydrator.js +89 -0
  539. package/lib/esm/ViewStateHydrator.js.map +1 -0
  540. package/lib/esm/ViewStore.d.ts +502 -0
  541. package/lib/esm/ViewStore.d.ts.map +1 -0
  542. package/lib/esm/ViewStore.js +1260 -0
  543. package/lib/esm/ViewStore.js.map +1 -0
  544. package/lib/esm/core-backend.d.ts +183 -0
  545. package/lib/esm/core-backend.d.ts.map +1 -0
  546. package/lib/esm/core-backend.js +187 -0
  547. package/lib/esm/core-backend.js.map +1 -0
  548. package/lib/esm/domains/FunctionalElements.d.ts +86 -0
  549. package/lib/esm/domains/FunctionalElements.d.ts.map +1 -0
  550. package/lib/esm/domains/FunctionalElements.js +117 -0
  551. package/lib/esm/domains/FunctionalElements.js.map +1 -0
  552. package/lib/esm/domains/FunctionalSchema.d.ts +14 -0
  553. package/lib/esm/domains/FunctionalSchema.d.ts.map +1 -0
  554. package/lib/esm/domains/FunctionalSchema.js +37 -0
  555. package/lib/esm/domains/FunctionalSchema.js.map +1 -0
  556. package/lib/esm/domains/GenericElements.d.ts +160 -0
  557. package/lib/esm/domains/GenericElements.d.ts.map +1 -0
  558. package/lib/esm/domains/GenericElements.js +225 -0
  559. package/lib/esm/domains/GenericElements.js.map +1 -0
  560. package/lib/esm/domains/GenericSchema.d.ts +11 -0
  561. package/lib/esm/domains/GenericSchema.d.ts.map +1 -0
  562. package/lib/esm/domains/GenericSchema.js +25 -0
  563. package/lib/esm/domains/GenericSchema.js.map +1 -0
  564. package/lib/esm/internal/ChangesetConflictArgs.d.ts +62 -0
  565. package/lib/esm/internal/ChangesetConflictArgs.d.ts.map +1 -0
  566. package/lib/esm/internal/ChangesetConflictArgs.js +104 -0
  567. package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -0
  568. package/lib/esm/internal/ChannelAdmin.d.ts +34 -0
  569. package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -0
  570. package/lib/esm/internal/ChannelAdmin.js +116 -0
  571. package/lib/esm/internal/ChannelAdmin.js.map +1 -0
  572. package/lib/esm/internal/FontFileImpl.d.ts +34 -0
  573. package/lib/esm/internal/FontFileImpl.d.ts.map +1 -0
  574. package/lib/esm/internal/FontFileImpl.js +135 -0
  575. package/lib/esm/internal/FontFileImpl.js.map +1 -0
  576. package/lib/esm/internal/HubMock.d.ts +94 -0
  577. package/lib/esm/internal/HubMock.d.ts.map +1 -0
  578. package/lib/esm/internal/HubMock.js +242 -0
  579. package/lib/esm/internal/HubMock.js.map +1 -0
  580. package/lib/esm/internal/IModelDbFontsImpl.d.ts +7 -0
  581. package/lib/esm/internal/IModelDbFontsImpl.d.ts.map +1 -0
  582. package/lib/esm/internal/IModelDbFontsImpl.js +183 -0
  583. package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -0
  584. package/lib/esm/internal/NativePlatform.d.ts +15 -0
  585. package/lib/esm/internal/NativePlatform.d.ts.map +1 -0
  586. package/lib/esm/internal/NativePlatform.js +43 -0
  587. package/lib/esm/internal/NativePlatform.js.map +1 -0
  588. package/lib/esm/internal/NoLocks.d.ts +6 -0
  589. package/lib/esm/internal/NoLocks.d.ts.map +1 -0
  590. package/lib/esm/internal/NoLocks.js +24 -0
  591. package/lib/esm/internal/NoLocks.js.map +1 -0
  592. package/lib/esm/internal/ServerBasedLocks.d.ts +52 -0
  593. package/lib/esm/internal/ServerBasedLocks.d.ts.map +1 -0
  594. package/lib/esm/internal/ServerBasedLocks.js +175 -0
  595. package/lib/esm/internal/ServerBasedLocks.js.map +1 -0
  596. package/lib/esm/internal/Symbols.d.ts +19 -0
  597. package/lib/esm/internal/Symbols.d.ts.map +1 -0
  598. package/lib/esm/internal/Symbols.js +26 -0
  599. package/lib/esm/internal/Symbols.js.map +1 -0
  600. package/lib/esm/internal/cross-package.d.ts +4 -0
  601. package/lib/esm/internal/cross-package.d.ts.map +1 -0
  602. package/lib/esm/internal/cross-package.js +8 -0
  603. package/lib/esm/internal/cross-package.js.map +1 -0
  604. package/lib/esm/internal/workspace/SettingsImpl.d.ts +43 -0
  605. package/lib/esm/internal/workspace/SettingsImpl.d.ts.map +1 -0
  606. package/lib/esm/internal/workspace/SettingsImpl.js +154 -0
  607. package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -0
  608. package/lib/esm/internal/workspace/SettingsSchemasImpl.d.ts +6 -0
  609. package/lib/esm/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -0
  610. package/lib/esm/internal/workspace/SettingsSchemasImpl.js +268 -0
  611. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -0
  612. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts +27 -0
  613. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -0
  614. package/lib/esm/internal/workspace/WorkspaceImpl.js +627 -0
  615. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -0
  616. package/lib/esm/internal/workspace/WorkspaceSqliteDb.d.ts +10 -0
  617. package/lib/esm/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -0
  618. package/lib/esm/internal/workspace/WorkspaceSqliteDb.js +35 -0
  619. package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -0
  620. package/lib/esm/rpc/multipart.d.ts +12 -0
  621. package/lib/esm/rpc/multipart.d.ts.map +1 -0
  622. package/lib/esm/rpc/multipart.js +67 -0
  623. package/lib/esm/rpc/multipart.js.map +1 -0
  624. package/lib/esm/rpc/tracing.d.ts +29 -0
  625. package/lib/esm/rpc/tracing.d.ts.map +1 -0
  626. package/lib/esm/rpc/tracing.js +71 -0
  627. package/lib/esm/rpc/tracing.js.map +1 -0
  628. package/lib/esm/rpc/web/logging.d.ts +10 -0
  629. package/lib/esm/rpc/web/logging.d.ts.map +1 -0
  630. package/lib/esm/rpc/web/logging.js +41 -0
  631. package/lib/esm/rpc/web/logging.js.map +1 -0
  632. package/lib/esm/rpc/web/request.d.ts +7 -0
  633. package/lib/esm/rpc/web/request.d.ts.map +1 -0
  634. package/lib/esm/rpc/web/request.js +71 -0
  635. package/lib/esm/rpc/web/request.js.map +1 -0
  636. package/lib/esm/rpc/web/response.d.ts +7 -0
  637. package/lib/esm/rpc/web/response.d.ts.map +1 -0
  638. package/lib/esm/rpc/web/response.js +136 -0
  639. package/lib/esm/rpc/web/response.js.map +1 -0
  640. package/lib/esm/rpc-impl/DevToolsRpcImpl.d.ts +16 -0
  641. package/lib/esm/rpc-impl/DevToolsRpcImpl.d.ts.map +1 -0
  642. package/lib/esm/rpc-impl/DevToolsRpcImpl.js +29 -0
  643. package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -0
  644. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +51 -0
  645. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -0
  646. package/lib/esm/rpc-impl/IModelReadRpcImpl.js +314 -0
  647. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -0
  648. package/lib/esm/rpc-impl/IModelTileRpcImpl.d.ts +21 -0
  649. package/lib/esm/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -0
  650. package/lib/esm/rpc-impl/IModelTileRpcImpl.js +193 -0
  651. package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -0
  652. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts +45 -0
  653. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -0
  654. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js +155 -0
  655. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -0
  656. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts +18 -0
  657. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts.map +1 -0
  658. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js +41 -0
  659. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -0
  660. package/lib/esm/test/AdvancedEqual.d.ts +38 -0
  661. package/lib/esm/test/AdvancedEqual.d.ts.map +1 -0
  662. package/lib/esm/test/AdvancedEqual.js +67 -0
  663. package/lib/esm/test/AdvancedEqual.js.map +1 -0
  664. package/lib/esm/test/AttachDb.test.d.ts +2 -0
  665. package/lib/esm/test/AttachDb.test.d.ts.map +1 -0
  666. package/lib/esm/test/AttachDb.test.js +157 -0
  667. package/lib/esm/test/AttachDb.test.js.map +1 -0
  668. package/lib/esm/test/GeometryTestUtil.d.ts +7 -0
  669. package/lib/esm/test/GeometryTestUtil.d.ts.map +1 -0
  670. package/lib/esm/test/GeometryTestUtil.js +25 -0
  671. package/lib/esm/test/GeometryTestUtil.js.map +1 -0
  672. package/lib/esm/test/IModelHost.test.d.ts +2 -0
  673. package/lib/esm/test/IModelHost.test.d.ts.map +1 -0
  674. package/lib/esm/test/IModelHost.test.js +187 -0
  675. package/lib/esm/test/IModelHost.test.js.map +1 -0
  676. package/lib/esm/test/IModelTestUtils.d.ts +177 -0
  677. package/lib/esm/test/IModelTestUtils.d.ts.map +1 -0
  678. package/lib/esm/test/IModelTestUtils.js +1146 -0
  679. package/lib/esm/test/IModelTestUtils.js.map +1 -0
  680. package/lib/esm/test/ImageSourceConversion.test.d.ts +2 -0
  681. package/lib/esm/test/ImageSourceConversion.test.d.ts.map +1 -0
  682. package/lib/esm/test/ImageSourceConversion.test.js +171 -0
  683. package/lib/esm/test/ImageSourceConversion.test.js.map +1 -0
  684. package/lib/esm/test/IpcHost.test.d.ts +2 -0
  685. package/lib/esm/test/IpcHost.test.d.ts.map +1 -0
  686. package/lib/esm/test/IpcHost.test.js +55 -0
  687. package/lib/esm/test/IpcHost.test.js.map +1 -0
  688. package/lib/esm/test/KnownTestLocations.d.ts +7 -0
  689. package/lib/esm/test/KnownTestLocations.d.ts.map +1 -0
  690. package/lib/esm/test/KnownTestLocations.js +27 -0
  691. package/lib/esm/test/KnownTestLocations.js.map +1 -0
  692. package/lib/esm/test/PrintElementTree.d.ts +7 -0
  693. package/lib/esm/test/PrintElementTree.d.ts.map +1 -0
  694. package/lib/esm/test/PrintElementTree.js +36 -0
  695. package/lib/esm/test/PrintElementTree.js.map +1 -0
  696. package/lib/esm/test/PropertyDb.test.d.ts +2 -0
  697. package/lib/esm/test/PropertyDb.test.d.ts.map +1 -0
  698. package/lib/esm/test/PropertyDb.test.js +71 -0
  699. package/lib/esm/test/PropertyDb.test.js.map +1 -0
  700. package/lib/esm/test/RevisionUtility.d.ts +33 -0
  701. package/lib/esm/test/RevisionUtility.d.ts.map +1 -0
  702. package/lib/esm/test/RevisionUtility.js +52 -0
  703. package/lib/esm/test/RevisionUtility.js.map +1 -0
  704. package/lib/esm/test/SchemaUtils.test.d.ts +2 -0
  705. package/lib/esm/test/SchemaUtils.test.d.ts.map +1 -0
  706. package/lib/esm/test/SchemaUtils.test.js +99 -0
  707. package/lib/esm/test/SchemaUtils.test.js.map +1 -0
  708. package/lib/esm/test/SequentialLogMatcher.d.ts +35 -0
  709. package/lib/esm/test/SequentialLogMatcher.d.ts.map +1 -0
  710. package/lib/esm/test/SequentialLogMatcher.js +130 -0
  711. package/lib/esm/test/SequentialLogMatcher.js.map +1 -0
  712. package/lib/esm/test/TestChangeSetUtility.d.ts +23 -0
  713. package/lib/esm/test/TestChangeSetUtility.d.ts.map +1 -0
  714. package/lib/esm/test/TestChangeSetUtility.js +65 -0
  715. package/lib/esm/test/TestChangeSetUtility.js.map +1 -0
  716. package/lib/esm/test/TestUtils.d.ts +38 -0
  717. package/lib/esm/test/TestUtils.d.ts.map +1 -0
  718. package/lib/esm/test/TestUtils.js +99 -0
  719. package/lib/esm/test/TestUtils.js.map +1 -0
  720. package/lib/esm/test/annotations/TextAnnotation.test.d.ts +2 -0
  721. package/lib/esm/test/annotations/TextAnnotation.test.d.ts.map +1 -0
  722. package/lib/esm/test/annotations/TextAnnotation.test.js +1135 -0
  723. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -0
  724. package/lib/esm/test/categories/Category.test.d.ts +2 -0
  725. package/lib/esm/test/categories/Category.test.d.ts.map +1 -0
  726. package/lib/esm/test/categories/Category.test.js +51 -0
  727. package/lib/esm/test/categories/Category.test.js.map +1 -0
  728. package/lib/esm/test/codespec/CodeSpec.test.d.ts +2 -0
  729. package/lib/esm/test/codespec/CodeSpec.test.d.ts.map +1 -0
  730. package/lib/esm/test/codespec/CodeSpec.test.js +51 -0
  731. package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -0
  732. package/lib/esm/test/ecdb/CTE.test.d.ts +2 -0
  733. package/lib/esm/test/ecdb/CTE.test.d.ts.map +1 -0
  734. package/lib/esm/test/ecdb/CTE.test.js +177 -0
  735. package/lib/esm/test/ecdb/CTE.test.js.map +1 -0
  736. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.d.ts +2 -0
  737. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.d.ts.map +1 -0
  738. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +167 -0
  739. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -0
  740. package/lib/esm/test/ecdb/ECDb.test.d.ts +2 -0
  741. package/lib/esm/test/ecdb/ECDb.test.d.ts.map +1 -0
  742. package/lib/esm/test/ecdb/ECDb.test.js +653 -0
  743. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -0
  744. package/lib/esm/test/ecdb/ECDbTestHelper.d.ts +5 -0
  745. package/lib/esm/test/ecdb/ECDbTestHelper.d.ts.map +1 -0
  746. package/lib/esm/test/ecdb/ECDbTestHelper.js +28 -0
  747. package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -0
  748. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.d.ts +2 -0
  749. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.d.ts.map +1 -0
  750. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js +63 -0
  751. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -0
  752. package/lib/esm/test/ecdb/ECSqlAst.test.d.ts +5 -0
  753. package/lib/esm/test/ecdb/ECSqlAst.test.d.ts.map +1 -0
  754. package/lib/esm/test/ecdb/ECSqlAst.test.js +972 -0
  755. package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -0
  756. package/lib/esm/test/ecdb/ECSqlQuery.test.d.ts +2 -0
  757. package/lib/esm/test/ecdb/ECSqlQuery.test.d.ts.map +1 -0
  758. package/lib/esm/test/ecdb/ECSqlQuery.test.js +776 -0
  759. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -0
  760. package/lib/esm/test/ecdb/ECSqlReader.test.d.ts +2 -0
  761. package/lib/esm/test/ecdb/ECSqlReader.test.d.ts.map +1 -0
  762. package/lib/esm/test/ecdb/ECSqlReader.test.js +669 -0
  763. package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -0
  764. package/lib/esm/test/ecdb/ECSqlStatement.test.d.ts +2 -0
  765. package/lib/esm/test/ecdb/ECSqlStatement.test.d.ts.map +1 -0
  766. package/lib/esm/test/ecdb/ECSqlStatement.test.js +3329 -0
  767. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -0
  768. package/lib/esm/test/ecdb/SqliteStatement.test.d.ts +2 -0
  769. package/lib/esm/test/ecdb/SqliteStatement.test.d.ts.map +1 -0
  770. package/lib/esm/test/ecdb/SqliteStatement.test.js +510 -0
  771. package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -0
  772. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts +4 -0
  773. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -0
  774. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +127 -0
  775. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -0
  776. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.d.ts +2 -0
  777. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.d.ts.map +1 -0
  778. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +197 -0
  779. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -0
  780. package/lib/esm/test/ecsql/src/ECSqlTestParser.d.ts +66 -0
  781. package/lib/esm/test/ecsql/src/ECSqlTestParser.d.ts.map +1 -0
  782. package/lib/esm/test/ecsql/src/ECSqlTestParser.js +420 -0
  783. package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -0
  784. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.d.ts +2 -0
  785. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.d.ts.map +1 -0
  786. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +369 -0
  787. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -0
  788. package/lib/esm/test/element/DeleteDefinitionElements.test.d.ts +2 -0
  789. package/lib/esm/test/element/DeleteDefinitionElements.test.d.ts.map +1 -0
  790. package/lib/esm/test/element/DeleteDefinitionElements.test.js +208 -0
  791. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -0
  792. package/lib/esm/test/element/ElementAspect.test.d.ts +2 -0
  793. package/lib/esm/test/element/ElementAspect.test.d.ts.map +1 -0
  794. package/lib/esm/test/element/ElementAspect.test.js +363 -0
  795. package/lib/esm/test/element/ElementAspect.test.js.map +1 -0
  796. package/lib/esm/test/element/ElementDependencyGraph.test.d.ts +2 -0
  797. package/lib/esm/test/element/ElementDependencyGraph.test.d.ts.map +1 -0
  798. package/lib/esm/test/element/ElementDependencyGraph.test.js +383 -0
  799. package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -0
  800. package/lib/esm/test/element/ElementRoundTrip.test.d.ts +2 -0
  801. package/lib/esm/test/element/ElementRoundTrip.test.d.ts.map +1 -0
  802. package/lib/esm/test/element/ElementRoundTrip.test.js +926 -0
  803. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -0
  804. package/lib/esm/test/element/ExcludedElements.test.d.ts +2 -0
  805. package/lib/esm/test/element/ExcludedElements.test.d.ts.map +1 -0
  806. package/lib/esm/test/element/ExcludedElements.test.js +57 -0
  807. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -0
  808. package/lib/esm/test/element/ExternalSource.test.d.ts +2 -0
  809. package/lib/esm/test/element/ExternalSource.test.d.ts.map +1 -0
  810. package/lib/esm/test/element/ExternalSource.test.js +107 -0
  811. package/lib/esm/test/element/ExternalSource.test.js.map +1 -0
  812. package/lib/esm/test/element/NullStructArray.test.d.ts +2 -0
  813. package/lib/esm/test/element/NullStructArray.test.d.ts.map +1 -0
  814. package/lib/esm/test/element/NullStructArray.test.js +77 -0
  815. package/lib/esm/test/element/NullStructArray.test.js.map +1 -0
  816. package/lib/esm/test/element/UrlLink.test.d.ts +2 -0
  817. package/lib/esm/test/element/UrlLink.test.d.ts.map +1 -0
  818. package/lib/esm/test/element/UrlLink.test.js +36 -0
  819. package/lib/esm/test/element/UrlLink.test.js.map +1 -0
  820. package/lib/esm/test/font/FontFile.test.d.ts +2 -0
  821. package/lib/esm/test/font/FontFile.test.d.ts.map +1 -0
  822. package/lib/esm/test/font/FontFile.test.js +139 -0
  823. package/lib/esm/test/font/FontFile.test.js.map +1 -0
  824. package/lib/esm/test/font/IModelDbFonts.test.d.ts +2 -0
  825. package/lib/esm/test/font/IModelDbFonts.test.d.ts.map +1 -0
  826. package/lib/esm/test/font/IModelDbFonts.test.js +266 -0
  827. package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -0
  828. package/lib/esm/test/hubaccess/BriefcaseManager.test.d.ts +2 -0
  829. package/lib/esm/test/hubaccess/BriefcaseManager.test.d.ts.map +1 -0
  830. package/lib/esm/test/hubaccess/BriefcaseManager.test.js +176 -0
  831. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -0
  832. package/lib/esm/test/hubaccess/CheckpointManager.test.d.ts +2 -0
  833. package/lib/esm/test/hubaccess/CheckpointManager.test.d.ts.map +1 -0
  834. package/lib/esm/test/hubaccess/CheckpointManager.test.js +52 -0
  835. package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -0
  836. package/lib/esm/test/imageData.d.ts +9 -0
  837. package/lib/esm/test/imageData.d.ts.map +1 -0
  838. package/lib/esm/test/imageData.js +16 -0
  839. package/lib/esm/test/imageData.js.map +1 -0
  840. package/lib/esm/test/imodel/ElementTreeWalker.test.d.ts +2 -0
  841. package/lib/esm/test/imodel/ElementTreeWalker.test.d.ts.map +1 -0
  842. package/lib/esm/test/imodel/ElementTreeWalker.test.js +383 -0
  843. package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -0
  844. package/lib/esm/test/imodel/GetTextureImage.test.d.ts +2 -0
  845. package/lib/esm/test/imodel/GetTextureImage.test.d.ts.map +1 -0
  846. package/lib/esm/test/imodel/GetTextureImage.test.js +29 -0
  847. package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -0
  848. package/lib/esm/test/imodel/IModel.test.d.ts +2 -0
  849. package/lib/esm/test/imodel/IModel.test.d.ts.map +1 -0
  850. package/lib/esm/test/imodel/IModel.test.js +2615 -0
  851. package/lib/esm/test/imodel/IModel.test.js.map +1 -0
  852. package/lib/esm/test/imodel/ProjectExtents.test.d.ts +2 -0
  853. package/lib/esm/test/imodel/ProjectExtents.test.d.ts.map +1 -0
  854. package/lib/esm/test/imodel/ProjectExtents.test.js +66 -0
  855. package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -0
  856. package/lib/esm/test/imodel/SchemaXmlImport.test.d.ts +2 -0
  857. package/lib/esm/test/imodel/SchemaXmlImport.test.d.ts.map +1 -0
  858. package/lib/esm/test/imodel/SchemaXmlImport.test.js +74 -0
  859. package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -0
  860. package/lib/esm/test/index.d.ts +7 -0
  861. package/lib/esm/test/index.d.ts.map +1 -0
  862. package/lib/esm/test/index.js +11 -0
  863. package/lib/esm/test/index.js.map +1 -0
  864. package/lib/esm/test/misc/DevTools.test.d.ts +2 -0
  865. package/lib/esm/test/misc/DevTools.test.d.ts.map +1 -0
  866. package/lib/esm/test/misc/DevTools.test.js +72 -0
  867. package/lib/esm/test/misc/DevTools.test.js.map +1 -0
  868. package/lib/esm/test/misc/EntitySubClasses.test.d.ts +2 -0
  869. package/lib/esm/test/misc/EntitySubClasses.test.d.ts.map +1 -0
  870. package/lib/esm/test/misc/EntitySubClasses.test.js +106 -0
  871. package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -0
  872. package/lib/esm/test/misc/GeoServices.test.d.ts +2 -0
  873. package/lib/esm/test/misc/GeoServices.test.d.ts.map +1 -0
  874. package/lib/esm/test/misc/GeoServices.test.js +850 -0
  875. package/lib/esm/test/misc/GeoServices.test.js.map +1 -0
  876. package/lib/esm/test/misc/PromiseMemoizer.test.d.ts +2 -0
  877. package/lib/esm/test/misc/PromiseMemoizer.test.d.ts.map +1 -0
  878. package/lib/esm/test/misc/PromiseMemoizer.test.js +111 -0
  879. package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -0
  880. package/lib/esm/test/native/DgnDbWorker.test.d.ts +2 -0
  881. package/lib/esm/test/native/DgnDbWorker.test.d.ts.map +1 -0
  882. package/lib/esm/test/native/DgnDbWorker.test.js +159 -0
  883. package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -0
  884. package/lib/esm/test/rpc/response.test.d.ts +2 -0
  885. package/lib/esm/test/rpc/response.test.d.ts.map +1 -0
  886. package/lib/esm/test/rpc/response.test.js +112 -0
  887. package/lib/esm/test/rpc/response.test.js.map +1 -0
  888. package/lib/esm/test/schema/ClassRegistry.test.d.ts +2 -0
  889. package/lib/esm/test/schema/ClassRegistry.test.d.ts.map +1 -0
  890. package/lib/esm/test/schema/ClassRegistry.test.js +679 -0
  891. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -0
  892. package/lib/esm/test/schema/FunctionalDomain.test.d.ts +2 -0
  893. package/lib/esm/test/schema/FunctionalDomain.test.d.ts.map +1 -0
  894. package/lib/esm/test/schema/FunctionalDomain.test.js +490 -0
  895. package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -0
  896. package/lib/esm/test/schema/GenericDomain.test.d.ts +2 -0
  897. package/lib/esm/test/schema/GenericDomain.test.d.ts.map +1 -0
  898. package/lib/esm/test/schema/GenericDomain.test.js +133 -0
  899. package/lib/esm/test/schema/GenericDomain.test.js.map +1 -0
  900. package/lib/esm/test/schema/IModelSchemaContext.test.d.ts +2 -0
  901. package/lib/esm/test/schema/IModelSchemaContext.test.d.ts.map +1 -0
  902. package/lib/esm/test/schema/IModelSchemaContext.test.js +95 -0
  903. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -0
  904. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts +4 -0
  905. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts.map +1 -0
  906. package/lib/esm/test/sheetindex/SheetIndex.test.js +312 -0
  907. package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -0
  908. package/lib/esm/test/standalone/ChangeMerge.test.d.ts +2 -0
  909. package/lib/esm/test/standalone/ChangeMerge.test.d.ts.map +1 -0
  910. package/lib/esm/test/standalone/ChangeMerge.test.js +409 -0
  911. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -0
  912. package/lib/esm/test/standalone/ChangesetReader.test.d.ts +2 -0
  913. package/lib/esm/test/standalone/ChangesetReader.test.d.ts.map +1 -0
  914. package/lib/esm/test/standalone/ChangesetReader.test.js +891 -0
  915. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -0
  916. package/lib/esm/test/standalone/CustomViewState3dCreator.test.d.ts +2 -0
  917. package/lib/esm/test/standalone/CustomViewState3dCreator.test.d.ts.map +1 -0
  918. package/lib/esm/test/standalone/CustomViewState3dCreator.test.js +49 -0
  919. package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -0
  920. package/lib/esm/test/standalone/DisplayStyle.test.d.ts +2 -0
  921. package/lib/esm/test/standalone/DisplayStyle.test.d.ts.map +1 -0
  922. package/lib/esm/test/standalone/DisplayStyle.test.js +136 -0
  923. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -0
  924. package/lib/esm/test/standalone/Drawing.test.d.ts +2 -0
  925. package/lib/esm/test/standalone/Drawing.test.d.ts.map +1 -0
  926. package/lib/esm/test/standalone/Drawing.test.js +120 -0
  927. package/lib/esm/test/standalone/Drawing.test.js.map +1 -0
  928. package/lib/esm/test/standalone/ElementGraphics.test.d.ts +2 -0
  929. package/lib/esm/test/standalone/ElementGraphics.test.d.ts.map +1 -0
  930. package/lib/esm/test/standalone/ElementGraphics.test.js +127 -0
  931. package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -0
  932. package/lib/esm/test/standalone/ElementMesh.test.d.ts +2 -0
  933. package/lib/esm/test/standalone/ElementMesh.test.d.ts.map +1 -0
  934. package/lib/esm/test/standalone/ElementMesh.test.js +142 -0
  935. package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -0
  936. package/lib/esm/test/standalone/ExportGraphics.test.d.ts +2 -0
  937. package/lib/esm/test/standalone/ExportGraphics.test.d.ts.map +1 -0
  938. package/lib/esm/test/standalone/ExportGraphics.test.js +1005 -0
  939. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -0
  940. package/lib/esm/test/standalone/GeometryChangeEvents.test.d.ts +2 -0
  941. package/lib/esm/test/standalone/GeometryChangeEvents.test.d.ts.map +1 -0
  942. package/lib/esm/test/standalone/GeometryChangeEvents.test.js +139 -0
  943. package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -0
  944. package/lib/esm/test/standalone/GeometryStream.test.d.ts +2 -0
  945. package/lib/esm/test/standalone/GeometryStream.test.d.ts.map +1 -0
  946. package/lib/esm/test/standalone/GeometryStream.test.js +2869 -0
  947. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -0
  948. package/lib/esm/test/standalone/HubMock.test.d.ts +2 -0
  949. package/lib/esm/test/standalone/HubMock.test.d.ts.map +1 -0
  950. package/lib/esm/test/standalone/HubMock.test.js +343 -0
  951. package/lib/esm/test/standalone/HubMock.test.js.map +1 -0
  952. package/lib/esm/test/standalone/IModelWrite.test.d.ts +7 -0
  953. package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -0
  954. package/lib/esm/test/standalone/IModelWrite.test.js +907 -0
  955. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -0
  956. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.d.ts +2 -0
  957. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.d.ts.map +1 -0
  958. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js +417 -0
  959. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -0
  960. package/lib/esm/test/standalone/MergeConflict.test.d.ts +7 -0
  961. package/lib/esm/test/standalone/MergeConflict.test.d.ts.map +1 -0
  962. package/lib/esm/test/standalone/MergeConflict.test.js +345 -0
  963. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -0
  964. package/lib/esm/test/standalone/NativeAppStorage.test.d.ts +2 -0
  965. package/lib/esm/test/standalone/NativeAppStorage.test.d.ts.map +1 -0
  966. package/lib/esm/test/standalone/NativeAppStorage.test.js +121 -0
  967. package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -0
  968. package/lib/esm/test/standalone/RenderMaterialElement.test.d.ts +2 -0
  969. package/lib/esm/test/standalone/RenderMaterialElement.test.d.ts.map +1 -0
  970. package/lib/esm/test/standalone/RenderMaterialElement.test.js +399 -0
  971. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -0
  972. package/lib/esm/test/standalone/RenderTimeline.test.d.ts +2 -0
  973. package/lib/esm/test/standalone/RenderTimeline.test.d.ts.map +1 -0
  974. package/lib/esm/test/standalone/RenderTimeline.test.js +71 -0
  975. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -0
  976. package/lib/esm/test/standalone/SQLiteDb.test.d.ts +2 -0
  977. package/lib/esm/test/standalone/SQLiteDb.test.d.ts.map +1 -0
  978. package/lib/esm/test/standalone/SQLiteDb.test.js +63 -0
  979. package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -0
  980. package/lib/esm/test/standalone/SchemaUtils.test.d.ts +2 -0
  981. package/lib/esm/test/standalone/SchemaUtils.test.d.ts.map +1 -0
  982. package/lib/esm/test/standalone/SchemaUtils.test.js +25 -0
  983. package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -0
  984. package/lib/esm/test/standalone/SectionDrawing.test.d.ts +2 -0
  985. package/lib/esm/test/standalone/SectionDrawing.test.d.ts.map +1 -0
  986. package/lib/esm/test/standalone/SectionDrawing.test.js +83 -0
  987. package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -0
  988. package/lib/esm/test/standalone/ServerBasedLocks.test.d.ts +2 -0
  989. package/lib/esm/test/standalone/ServerBasedLocks.test.d.ts.map +1 -0
  990. package/lib/esm/test/standalone/ServerBasedLocks.test.js +279 -0
  991. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -0
  992. package/lib/esm/test/standalone/Setting.test.d.ts +2 -0
  993. package/lib/esm/test/standalone/Setting.test.d.ts.map +1 -0
  994. package/lib/esm/test/standalone/Setting.test.js +76 -0
  995. package/lib/esm/test/standalone/Setting.test.js.map +1 -0
  996. package/lib/esm/test/standalone/Settings.test.d.ts +2 -0
  997. package/lib/esm/test/standalone/Settings.test.d.ts.map +1 -0
  998. package/lib/esm/test/standalone/Settings.test.js +349 -0
  999. package/lib/esm/test/standalone/Settings.test.js.map +1 -0
  1000. package/lib/esm/test/standalone/SettingsSchemas.test.d.ts +2 -0
  1001. package/lib/esm/test/standalone/SettingsSchemas.test.d.ts.map +1 -0
  1002. package/lib/esm/test/standalone/SettingsSchemas.test.js +31 -0
  1003. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -0
  1004. package/lib/esm/test/standalone/SnapshotDb.test.d.ts +2 -0
  1005. package/lib/esm/test/standalone/SnapshotDb.test.d.ts.map +1 -0
  1006. package/lib/esm/test/standalone/SnapshotDb.test.js +155 -0
  1007. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -0
  1008. package/lib/esm/test/standalone/Texture.test.d.ts +2 -0
  1009. package/lib/esm/test/standalone/Texture.test.d.ts.map +1 -0
  1010. package/lib/esm/test/standalone/Texture.test.js +90 -0
  1011. package/lib/esm/test/standalone/Texture.test.js.map +1 -0
  1012. package/lib/esm/test/standalone/TileCache.test.d.ts +9 -0
  1013. package/lib/esm/test/standalone/TileCache.test.d.ts.map +1 -0
  1014. package/lib/esm/test/standalone/TileCache.test.js +127 -0
  1015. package/lib/esm/test/standalone/TileCache.test.js.map +1 -0
  1016. package/lib/esm/test/standalone/TileTree.test.d.ts +2 -0
  1017. package/lib/esm/test/standalone/TileTree.test.d.ts.map +1 -0
  1018. package/lib/esm/test/standalone/TileTree.test.js +241 -0
  1019. package/lib/esm/test/standalone/TileTree.test.js.map +1 -0
  1020. package/lib/esm/test/standalone/TxnManager.test.d.ts +2 -0
  1021. package/lib/esm/test/standalone/TxnManager.test.d.ts.map +1 -0
  1022. package/lib/esm/test/standalone/TxnManager.test.js +878 -0
  1023. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -0
  1024. package/lib/esm/test/standalone/ViewDefinition.test.d.ts +2 -0
  1025. package/lib/esm/test/standalone/ViewDefinition.test.d.ts.map +1 -0
  1026. package/lib/esm/test/standalone/ViewDefinition.test.js +279 -0
  1027. package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -0
  1028. package/lib/esm/test/standalone/ViewStoreDb.test.d.ts +2 -0
  1029. package/lib/esm/test/standalone/ViewStoreDb.test.d.ts.map +1 -0
  1030. package/lib/esm/test/standalone/ViewStoreDb.test.js +288 -0
  1031. package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -0
  1032. package/lib/esm/test/standalone/Workspace.test.d.ts +2 -0
  1033. package/lib/esm/test/standalone/Workspace.test.d.ts.map +1 -0
  1034. package/lib/esm/test/standalone/Workspace.test.js +162 -0
  1035. package/lib/esm/test/standalone/Workspace.test.js.map +1 -0
  1036. package/lib/esm/workspace/Settings.d.ts +216 -0
  1037. package/lib/esm/workspace/Settings.d.ts.map +1 -0
  1038. package/lib/esm/workspace/Settings.js +83 -0
  1039. package/lib/esm/workspace/Settings.js.map +1 -0
  1040. package/lib/esm/workspace/SettingsSchemas.d.ts +135 -0
  1041. package/lib/esm/workspace/SettingsSchemas.d.ts.map +1 -0
  1042. package/lib/esm/workspace/SettingsSchemas.js +9 -0
  1043. package/lib/esm/workspace/SettingsSchemas.js.map +1 -0
  1044. package/lib/esm/workspace/Workspace.d.ts +500 -0
  1045. package/lib/esm/workspace/Workspace.d.ts.map +1 -0
  1046. package/lib/esm/workspace/Workspace.js +97 -0
  1047. package/lib/esm/workspace/Workspace.js.map +1 -0
  1048. package/lib/esm/workspace/WorkspaceEditor.d.ts +240 -0
  1049. package/lib/esm/workspace/WorkspaceEditor.d.ts.map +1 -0
  1050. package/lib/esm/workspace/WorkspaceEditor.js +31 -0
  1051. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -0
  1052. package/package.json +36 -28
  1053. package/lib/cjs/HubMock.d.ts.map +0 -1
  1054. package/lib/cjs/HubMock.js.map +0 -1
  1055. package/lib/cjs/IModelCloneContext.d.ts +0 -9
  1056. package/lib/cjs/IModelCloneContext.d.ts.map +0 -1
  1057. package/lib/cjs/IModelCloneContext.js.map +0 -1
@@ -0,0 +1,2615 @@
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
53
+ /*---------------------------------------------------------------------------------------------
54
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
55
+ * See LICENSE.md in the project root for license terms and full copyright notice.
56
+ *--------------------------------------------------------------------------------------------*/
57
+ import { assert, expect } from "chai";
58
+ import * as path from "path";
59
+ import * as semver from "semver";
60
+ import * as sinon from "sinon";
61
+ import { DbResult, Guid, Id64, IModelStatus, Logger, OpenMode, ProcessDetector } from "@itwin/core-bentley";
62
+ import { BisCodeSpec, BriefcaseIdValue, Code, CodeScopeSpec, CodeSpec, ColorByName, ColorDef, DisplayStyleSettings, EcefLocation, FontMap, FontType, GeoCoordStatus, GeographicCRS, GeometryParams, GeometryStreamBuilder, ImageSourceFormat, IModel, IModelError, RelatedElement, RenderMode, SchemaState, SubCategoryAppearance, TextureMapping, TextureMapUnits, ViewFlags, } from "@itwin/core-common";
63
+ import { Geometry, LineString3d, Loop, Matrix4d, Point3d, PolyfaceBuilder, Range3d, StrokeOptions, Transform, YawPitchRollAngles, } from "@itwin/core-geometry";
64
+ import { V2CheckpointManager } from "../../CheckpointManager";
65
+ import { _nativeDb, BisCoreSchema, Category, ClassRegistry, DefinitionContainer, DefinitionGroup, DefinitionGroupGroupsDefinitions, DefinitionModel, DefinitionPartition, DictionaryModel, DisplayStyle3d, DocumentPartition, DrawingGraphic, Element, ElementDrivesElement, ElementGroupsMembers, ElementOwnsChildElements, GeometricElement2d, GeometricElement3d, GeometricModel, GroupInformationPartition, IModelDb, IModelHost, IModelJsFs, InformationPartitionElement, InformationRecordElement, LinkPartition, Model, PhysicalElement, PhysicalModel, PhysicalObject, PhysicalPartition, RenderMaterialElement, SnapshotDb, SpatialCategory, SqliteValueType, StandaloneDb, SubCategory, Subject, Texture, } from "../../core-backend";
66
+ import { BriefcaseDb } from "../../IModelDb";
67
+ import { HubMock } from "../../internal/HubMock";
68
+ import { KnownTestLocations } from "../KnownTestLocations";
69
+ import { IModelTestUtils } from "../IModelTestUtils";
70
+ import { DisableNativeAssertions } from "../TestUtils";
71
+ import { samplePngTexture } from "../imageData";
72
+ import { performance } from "perf_hooks";
73
+ import { _hubAccess } from "../../internal/Symbols";
74
+ import { CustomAttributeClass, EntityClass, PropertyType, propertyTypeToString, SchemaItemType } from "@itwin/ecschema-metadata";
75
+ // spell-checker: disable
76
+ async function getIModelError(promise) {
77
+ try {
78
+ await promise;
79
+ return undefined;
80
+ }
81
+ catch (err) {
82
+ return err instanceof IModelError ? err : undefined;
83
+ }
84
+ }
85
+ function expectIModelError(expectedErrorNumber, error) {
86
+ expect(error).not.to.be.undefined;
87
+ expect(error).instanceof(IModelError);
88
+ expect(error.errorNumber).to.equal(expectedErrorNumber);
89
+ }
90
+ describe("iModel", () => {
91
+ let imodel1;
92
+ let imodel2;
93
+ let imodel3;
94
+ let imodel4;
95
+ let imodel5;
96
+ let originalEnv;
97
+ before(async () => {
98
+ originalEnv = { ...process.env };
99
+ IModelTestUtils.registerTestBimSchema();
100
+ imodel1 = IModelTestUtils.createSnapshotFromSeed(IModelTestUtils.prepareOutputFile("IModel", "test.bim"), IModelTestUtils.resolveAssetFile("test.bim"));
101
+ imodel2 = IModelTestUtils.createSnapshotFromSeed(IModelTestUtils.prepareOutputFile("IModel", "CompatibilityTestSeed.bim"), IModelTestUtils.resolveAssetFile("CompatibilityTestSeed.bim"));
102
+ imodel3 = SnapshotDb.openFile(IModelTestUtils.resolveAssetFile("GetSetAutoHandledStructProperties.bim"));
103
+ imodel4 = IModelTestUtils.createSnapshotFromSeed(IModelTestUtils.prepareOutputFile("IModel", "GetSetAutoHandledArrayProperties.bim"), IModelTestUtils.resolveAssetFile("GetSetAutoHandledArrayProperties.bim"));
104
+ imodel5 = IModelTestUtils.createSnapshotFromSeed(IModelTestUtils.prepareOutputFile("IModel", "mirukuru.ibim"), IModelTestUtils.resolveAssetFile("mirukuru.ibim"));
105
+ const schemaPathname = path.join(KnownTestLocations.assetsDir, "TestBim.ecschema.xml");
106
+ await imodel1.importSchemas([schemaPathname]); // will throw an exception if import fails
107
+ });
108
+ after(() => {
109
+ process.env = originalEnv;
110
+ imodel1.close();
111
+ imodel2.close();
112
+ imodel3.close();
113
+ imodel4.close();
114
+ imodel5.close();
115
+ });
116
+ afterEach(() => {
117
+ sinon.restore();
118
+ });
119
+ /** Roundtrip the entity through a json string and back to a new entity. */
120
+ const roundtripThroughJson = (entity1) => {
121
+ const string1 = JSON.stringify(entity1);
122
+ const props1 = JSON.parse(string1);
123
+ const entity2 = new entity1.constructor(props1, entity1.iModel); // create a new entity from the EntityProps
124
+ const string2 = JSON.stringify(entity2);
125
+ assert.equal(string1, string2);
126
+ return entity2;
127
+ };
128
+ it("should be able to get properties of an iIModel", () => {
129
+ expect(imodel1.name).equals("TBD"); // That's the name of the root subject!
130
+ const extents = imodel1.projectExtents;
131
+ assert(!extents.isNull);
132
+ // make sure we can construct a new element even if we haven't loaded its metadata (will be loaded in ctor)
133
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
134
+ assert.isUndefined(imodel1.classMetaDataRegistry.find("biscore:lightlocation"));
135
+ const e1 = imodel1.constructEntity({ category: "0x11", classFullName: "BisCore:LightLocation", model: "0x01", code: Code.createEmpty() });
136
+ assert.isDefined(e1);
137
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
138
+ assert.isDefined(imodel1.classMetaDataRegistry.find("biscore:lightlocation")); // should have been loaded in ctor
139
+ });
140
+ it("should use schema to look up classes by name", () => {
141
+ const elementClass = ClassRegistry.findRegisteredClass(Element.classFullName);
142
+ const categoryClass = ClassRegistry.findRegisteredClass(Category.classFullName);
143
+ assert.isDefined(elementClass);
144
+ assert.isDefined(categoryClass);
145
+ assert.equal(elementClass.schema, BisCoreSchema);
146
+ assert.equal(categoryClass.schema, BisCoreSchema);
147
+ assert.equal(elementClass.className, "Element");
148
+ assert.equal(categoryClass.className, "Category");
149
+ });
150
+ it("Fonts", () => {
151
+ const dbFonts = imodel1.fonts;
152
+ expect(Array.from(dbFonts.queryMappedFamilies({ includeNonEmbedded: true })).length).to.equal(4);
153
+ expect(dbFonts.findDescriptor(1)).to.deep.equal({ name: "Arial", type: FontType.TrueType });
154
+ expect(dbFonts.findId({ name: "Arial" })).to.equal(1);
155
+ expect(dbFonts.findId({ name: "arial" })).to.equal(1);
156
+ expect(dbFonts.findDescriptor(2)).to.deep.equal({ name: "Font0", type: FontType.Rsc });
157
+ expect(dbFonts.findId({ name: "Font0" })).to.equal(2);
158
+ expect(dbFonts.findId({ name: "fOnt0" })).to.equal(2);
159
+ expect(dbFonts.findDescriptor(3)).to.deep.equal({ name: "ShxFont0", type: FontType.Shx });
160
+ expect(dbFonts.findId({ name: "ShxFont0" })).to.equal(3);
161
+ expect(dbFonts.findId({ name: "shxfont0" })).to.equal(3);
162
+ expect(dbFonts.findDescriptor(4)).to.deep.equal({ name: "Calibri", type: FontType.TrueType });
163
+ expect(dbFonts.findId({ name: "Calibri" })).to.equal(4);
164
+ expect(dbFonts.findId({ name: "cAlIbRi" })).to.equal(4);
165
+ expect(dbFonts.findId({ name: "notfound" })).to.be.undefined;
166
+ const fonts1 = imodel1.fontMap; // eslint-disable-line @typescript-eslint/no-deprecated
167
+ assert.equal(fonts1.fonts.size, 4, "font map size should be 4");
168
+ assert.equal(FontType.TrueType, fonts1.getFont(1).type, "get font 1 type is TrueType");
169
+ assert.equal("Arial", fonts1.getFont(1).name, "get Font 1 name");
170
+ assert.equal(1, fonts1.getFont("Arial").id, "get Font 1, by name");
171
+ assert.equal(1, fonts1.getFont("arial").id, "get Font 1, by name case insensitive");
172
+ assert.equal(FontType.Rsc, fonts1.getFont(2).type, "get font 2 type is Rsc");
173
+ assert.equal("Font0", fonts1.getFont(2).name, "get Font 2 name");
174
+ assert.equal(2, fonts1.getFont("Font0").id, "get Font 2, by name");
175
+ assert.equal(2, fonts1.getFont("fOnt0").id, "get Font 2, by name case insensitive");
176
+ assert.equal(FontType.Shx, fonts1.getFont(3).type, "get font 1 type is Shx");
177
+ assert.equal("ShxFont0", fonts1.getFont(3).name, "get Font 3 name");
178
+ assert.equal(3, fonts1.getFont("ShxFont0").id, "get Font 3, by name");
179
+ assert.equal(3, fonts1.getFont("shxfont0").id, "get Font 3, by name case insensitive");
180
+ assert.equal(FontType.TrueType, fonts1.getFont(4).type, "get font 4 type is TrueType");
181
+ assert.equal("Calibri", fonts1.getFont(4).name, "get Font 4 name");
182
+ assert.equal(4, fonts1.getFont("Calibri").id, "get Font 4, by name");
183
+ assert.equal(4, fonts1.getFont("cAlIbRi").id, "get Font 4, by name case insensitive");
184
+ assert.isUndefined(fonts1.getFont("notfound"), "attempt lookup of a font that should not be found");
185
+ assert.deepEqual(new FontMap(fonts1.toJSON()), fonts1, "toJSON on FontMap"); // eslint-disable-line @typescript-eslint/no-deprecated
186
+ });
187
+ it("should load a known element by Id from an existing iModel", () => {
188
+ assert.exists(imodel1.elements);
189
+ const code1 = new Code({ spec: "0x10", scope: "0x11", value: "RF1.dgn" });
190
+ const el = imodel1.elements.getElement(code1);
191
+ assert.exists(el);
192
+ const el2ById = imodel1.elements.getElement("0x34");
193
+ assert.exists(el2ById);
194
+ const badCode = new Code({ spec: "0x10", scope: "0x11", value: "RF1_does_not_exist.dgn" });
195
+ try {
196
+ imodel1.elements.getElement(badCode); // throws Error
197
+ assert.fail(); // this line should be skipped
198
+ }
199
+ catch (error) {
200
+ assert.instanceOf(error, Error);
201
+ assert.instanceOf(error, IModelError);
202
+ assert.equal(error.errorNumber, IModelStatus.NotFound);
203
+ }
204
+ const element1 = imodel1.elements.tryGetElement(code1);
205
+ const element2 = imodel1.elements.tryGetElement("0x34");
206
+ const element3 = imodel1.elements.tryGetElement(badCode);
207
+ assert.isDefined(element1);
208
+ assert.isDefined(element2);
209
+ assert.isUndefined(element3);
210
+ const elementProps1 = imodel1.elements.tryGetElementProps(code1);
211
+ const elementProps2 = imodel1.elements.tryGetElementProps("0x34");
212
+ const elementProps3 = imodel1.elements.tryGetElementProps(badCode);
213
+ assert.isDefined(elementProps1);
214
+ assert.isDefined(elementProps2);
215
+ assert.isUndefined(elementProps3);
216
+ const model1 = imodel1.models.tryGetModel(IModel.dictionaryId);
217
+ const modelProps1 = imodel1.models.tryGetModelProps(IModel.dictionaryId);
218
+ const subModel1 = imodel1.models.tryGetSubModel(IModel.dictionaryId);
219
+ assert.isDefined(model1);
220
+ assert.isDefined(modelProps1);
221
+ assert.isDefined(subModel1);
222
+ const badModel1 = imodel1.models.tryGetModel(Id64.fromUint32Pair(999, 999));
223
+ const badModelProps1 = imodel1.models.tryGetModelProps(Id64.fromUint32Pair(999, 999));
224
+ const badSubModel1 = imodel1.models.tryGetSubModel(IModel.rootSubjectId);
225
+ const badSubModel2 = imodel1.models.tryGetSubModel(badCode);
226
+ assert.isUndefined(badModel1);
227
+ assert.isUndefined(badModelProps1);
228
+ assert.isUndefined(badSubModel1);
229
+ assert.isUndefined(badSubModel2);
230
+ const subCat = imodel1.elements.getElement("0x2e");
231
+ assert.isTrue(subCat instanceof SubCategory);
232
+ if (subCat instanceof SubCategory) {
233
+ assert.isTrue(subCat.appearance.color.tbgr === 16777215);
234
+ assert.isTrue(subCat.appearance.weight === 2);
235
+ assert.equal(Id64.getLocalId(subCat.id), 46);
236
+ assert.equal(Id64.getBriefcaseId(subCat.id), 0);
237
+ assert.equal(Id64.getLocalId(subCat.code.spec), 30);
238
+ assert.equal(Id64.getBriefcaseId(subCat.code.spec), 0);
239
+ assert.isTrue(subCat.code.scope === "0x2d");
240
+ assert.isTrue(subCat.code.value === "A-Z013-G-Legn");
241
+ roundtripThroughJson(subCat);
242
+ }
243
+ /// Get the parent Category of the subcategory.
244
+ const cat = imodel1.elements.getElement(subCat.getCategoryId());
245
+ assert.isTrue(cat instanceof Category);
246
+ if (cat instanceof Category) {
247
+ assert.equal(Id64.getLocalId(cat.id), 45);
248
+ assert.equal(Id64.getBriefcaseId(cat.id), 0);
249
+ assert.isTrue(cat.description === "Legends, symbols keys");
250
+ assert.equal(Id64.getLocalId(cat.code.spec), 22);
251
+ assert.equal(Id64.getBriefcaseId(cat.code.spec), 0);
252
+ assert.isTrue(cat.code.value === "A-Z013-G-Legn");
253
+ roundtripThroughJson(cat);
254
+ }
255
+ const phys = imodel1.elements.getElement("0x38");
256
+ assert.isTrue(phys instanceof GeometricElement3d);
257
+ const locateMsg = phys.getToolTipMessage();
258
+ assert.isDefined(locateMsg);
259
+ const a2 = imodel2.elements.getElement("0x1d");
260
+ assert.exists(a2);
261
+ expect(a2.federationGuid).equal("18eb4650-b074-414f-b961-d9cfaa6c8746");
262
+ const el3 = imodel2.elements.getElement(a2.federationGuid);
263
+ assert.exists(el3);
264
+ assert.notEqual(a2, el3);
265
+ assert.equal(a2.id, el3.id);
266
+ roundtripThroughJson(el3);
267
+ const newEl = el3.toJSON();
268
+ newEl.federationGuid = undefined;
269
+ newEl.code = { scope: "bad scope", spec: "0x10", value: "new code" };
270
+ expect(() => imodel2.elements.insertElement(newEl)).throws("invalid code scope").to.have.property("metadata");
271
+ newEl.code.scope = "0x34322"; // valid id, but element doesn't exist
272
+ expect(() => imodel2.elements.insertElement(newEl)).throws("invalid code scope").to.have.property("metadata");
273
+ newEl.code.scope = el3.federationGuid;
274
+ const newId = imodel2.elements.insertElement(newEl); // code scope from FederationGuid should get converted to ElementId
275
+ const a4 = imodel2.elements.getElementProps(newId);
276
+ expect(a4.code.scope).equal(el3.id);
277
+ a4.code.scope = "0x13343";
278
+ expect(() => imodel2.elements.updateElement(a4)).throws("invalid code scope").to.have.property("metadata");
279
+ a4.code.scope = "0x1";
280
+ imodel2.elements.updateElement(a4); // should change the code scope to new element
281
+ let a5 = imodel2.elements.getElementProps(newId);
282
+ expect(a5.code.scope).equal("0x1");
283
+ // only pass minimum, but expect model and classFullName to be added.
284
+ const newProps = { id: a4.id, code: a4.code, classFullName: undefined, model: undefined };
285
+ newProps.code.scope = el3.federationGuid; // should convert FederationGuid to ElementId
286
+ imodel2.elements.updateElement(newProps);
287
+ expect(newProps.classFullName).eq(a4.classFullName);
288
+ expect(newProps.model).eq(a4.model);
289
+ a5 = imodel2.elements.getElementProps(newId);
290
+ expect(a5.code.scope).equal(el3.id);
291
+ });
292
+ it("should optionally detect class mismatches", () => {
293
+ // tryGetElement
294
+ const subjectUnvalidated = imodel1.elements.tryGetElement(IModel.rootSubjectId);
295
+ assert.isDefined(subjectUnvalidated);
296
+ const subjectValidated = imodel1.elements.tryGetElement(IModel.rootSubjectId, Subject);
297
+ assert.isDefined(subjectValidated);
298
+ const physicalElementUnvalidated = imodel1.elements.tryGetElement(IModel.rootSubjectId);
299
+ assert.isDefined(physicalElementUnvalidated); // wrong type, but class to validate was not passed
300
+ const physicalElementValidated = imodel1.elements.tryGetElement(IModel.rootSubjectId, PhysicalElement); // abstract class
301
+ assert.isUndefined(physicalElementValidated); // wrong type
302
+ const physicalObjectUnvalidated = imodel1.elements.tryGetElement(IModel.rootSubjectId);
303
+ assert.isDefined(physicalObjectUnvalidated); // wrong type, but class to validate was not passed
304
+ const physicalObjectValidated = imodel1.elements.tryGetElement(IModel.rootSubjectId, PhysicalObject); // concrete class
305
+ assert.isUndefined(physicalObjectValidated); // wrong type
306
+ // tryGetModel
307
+ const dictionaryUnvalidated = imodel1.models.tryGetModel(IModel.dictionaryId);
308
+ assert.isDefined(dictionaryUnvalidated);
309
+ const dictionaryValidated = imodel1.models.tryGetModel(IModel.dictionaryId, DictionaryModel);
310
+ assert.isDefined(dictionaryValidated);
311
+ const geometricModelUnvalidated = imodel1.models.tryGetModel(IModel.dictionaryId);
312
+ assert.isDefined(geometricModelUnvalidated); // wrong type, but class to validate was not passed
313
+ const geometricModelValidated = imodel1.models.tryGetModel(IModel.dictionaryId, GeometricModel); // abstract class
314
+ assert.isUndefined(geometricModelValidated); // wrong type
315
+ const physicalModelUnvalidated = imodel1.models.tryGetModel(IModel.dictionaryId);
316
+ assert.isDefined(physicalModelUnvalidated); // wrong type, but class to validate was not passed
317
+ const physicalModelValidated = imodel1.models.tryGetModel(IModel.dictionaryId, PhysicalModel); // concrete class
318
+ assert.isUndefined(physicalModelValidated); // wrong type
319
+ // tryGetSubModel
320
+ const dictionarySubUnvalidated = imodel1.models.tryGetSubModel(IModel.dictionaryId);
321
+ assert.isDefined(dictionarySubUnvalidated);
322
+ const dictionarySubValidated = imodel1.models.tryGetSubModel(IModel.dictionaryId, DictionaryModel);
323
+ assert.isDefined(dictionarySubValidated);
324
+ const geometricSubModelUnvalidated = imodel1.models.tryGetSubModel(IModel.dictionaryId);
325
+ assert.isDefined(geometricSubModelUnvalidated); // wrong type, but class to validate was not passed
326
+ const geometricSubModelValidated = imodel1.models.tryGetSubModel(IModel.dictionaryId, GeometricModel); // abstract class
327
+ assert.isUndefined(geometricSubModelValidated); // wrong type
328
+ const physicalSubModelUnvalidated = imodel1.models.tryGetSubModel(IModel.dictionaryId);
329
+ assert.isDefined(physicalSubModelUnvalidated); // wrong type, but class to validate was not passed
330
+ const physicalSubModelValidated = imodel1.models.tryGetSubModel(IModel.dictionaryId, PhysicalModel); // concrete class
331
+ assert.isUndefined(physicalSubModelValidated); // wrong type
332
+ });
333
+ it("should create elements", () => {
334
+ const seedElement = imodel2.elements.getElement("0x1d");
335
+ assert.exists(seedElement);
336
+ assert.isTrue(seedElement.federationGuid === "18eb4650-b074-414f-b961-d9cfaa6c8746");
337
+ for (let i = 0; i < 25; i++) {
338
+ const elementProps = {
339
+ classFullName: "Generic:PhysicalObject",
340
+ model: seedElement.model,
341
+ category: seedElement.category,
342
+ code: Code.createEmpty(),
343
+ federationGuid: Guid.createValue(),
344
+ userLabel: `UserLabel-${i}`,
345
+ };
346
+ const element = imodel2.elements.createElement(elementProps);
347
+ element.setUserProperties("performanceTest", { s: `String-${i}`, n: i });
348
+ const elementId = imodel2.elements.insertElement(element.toJSON());
349
+ assert.isTrue(Id64.isValidId64(elementId));
350
+ }
351
+ });
352
+ it("should insert a RenderMaterial", () => {
353
+ const model = imodel2.models.getModel(IModel.dictionaryId);
354
+ expect(model).not.to.be.undefined;
355
+ const testMaterialName = "test material name";
356
+ const testPaletteName = "test palette name";
357
+ const testDescription = "test description";
358
+ const color = [0.3, 0.7, 0.8];
359
+ const specularColor = [0.1, 1, 0];
360
+ const finish = 0.4;
361
+ const transmit = 0.1;
362
+ const diffuse = 0.24;
363
+ const specular = 0.9;
364
+ const reflect = 0.3;
365
+ const reflectColor = [1, 0, 0.5];
366
+ /* eslint-disable @typescript-eslint/naming-convention */
367
+ const textureMapProps = {
368
+ pattern_angle: 3.0,
369
+ pattern_u_flip: false,
370
+ pattern_flip: false,
371
+ pattern_scale: [1.0, 1.0],
372
+ pattern_offset: [0.0, 0.0],
373
+ pattern_scalemode: TextureMapUnits.Inches,
374
+ pattern_mapping: TextureMapping.Mode.Planar,
375
+ pattern_weight: 0.5,
376
+ TextureId: "test_textureid",
377
+ };
378
+ /* eslint-enable @typescript-eslint/naming-convention */
379
+ const renderMaterialParams = {
380
+ paletteName: testPaletteName,
381
+ description: testDescription,
382
+ color,
383
+ specularColor,
384
+ finish,
385
+ transmit,
386
+ diffuse,
387
+ specular,
388
+ reflect,
389
+ reflectColor,
390
+ patternMap: textureMapProps,
391
+ };
392
+ const renderMaterialId = RenderMaterialElement.insert(imodel2, IModel.dictionaryId, testMaterialName, renderMaterialParams);
393
+ const renderMaterial = imodel2.elements.getElement(renderMaterialId);
394
+ assert((renderMaterial instanceof RenderMaterialElement) === true, "did not retrieve an instance of RenderMaterial");
395
+ expect(renderMaterial.paletteName).to.equal(testPaletteName);
396
+ expect(renderMaterial.description).to.equal(testDescription);
397
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasBaseColor).to.equal(true);
398
+ expect(JSON.stringify(renderMaterial.jsonProperties.materialAssets.renderMaterial.color)).to.equal(JSON.stringify(color));
399
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasSpecularColor).to.equal(true);
400
+ expect(JSON.stringify(renderMaterial.jsonProperties.materialAssets.renderMaterial.specular_color)).to.equal(JSON.stringify(specularColor));
401
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasFinish).to.equal(true);
402
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.finish).to.equal(finish);
403
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasTransmit).to.equal(true);
404
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.transmit).to.equal(transmit);
405
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasDiffuse).to.equal(true);
406
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.diffuse).to.equal(diffuse);
407
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasSpecular).to.equal(true);
408
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.specular).to.equal(specular);
409
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasReflect).to.equal(true);
410
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.reflect).to.equal(reflect);
411
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.HasReflectColor).to.equal(true);
412
+ expect(JSON.stringify(renderMaterial.jsonProperties.materialAssets.renderMaterial.reflect_color)).to.equal(JSON.stringify(reflectColor));
413
+ expect(renderMaterial.jsonProperties.materialAssets.renderMaterial.Map).not.to.be.undefined;
414
+ const patternMap = renderMaterial.jsonProperties.materialAssets.renderMaterial.Map.Pattern;
415
+ expect(patternMap).not.to.be.undefined;
416
+ expect(patternMap.pattern_angle).to.equal(textureMapProps.pattern_angle);
417
+ expect(patternMap.pattern_u_flip).to.equal(textureMapProps.pattern_u_flip);
418
+ expect(patternMap.pattern_flip).to.equal(textureMapProps.pattern_flip);
419
+ expect(JSON.stringify(patternMap.pattern_scale)).to.equal(JSON.stringify(textureMapProps.pattern_scale));
420
+ expect(JSON.stringify(patternMap.pattern_offset)).to.equal(JSON.stringify(textureMapProps.pattern_offset));
421
+ expect(patternMap.pattern_scalemode).to.equal(textureMapProps.pattern_scalemode);
422
+ expect(patternMap.pattern_mapping).to.equal(textureMapProps.pattern_mapping);
423
+ expect(patternMap.pattern_weight).to.equal(textureMapProps.pattern_weight);
424
+ expect(patternMap.TextureId).to.equal(textureMapProps.TextureId);
425
+ });
426
+ it("attempt to apply material to new element in imodel5", () => {
427
+ const testTextureName = "fake texture name";
428
+ const testTextureFormat = ImageSourceFormat.Png;
429
+ const testTextureDescription = "empty description";
430
+ const texId = Texture.insertTexture(imodel5, IModel.dictionaryId, testTextureName, testTextureFormat, samplePngTexture.base64, testTextureDescription);
431
+ /* eslint-disable @typescript-eslint/naming-convention */
432
+ const matId = RenderMaterialElement.insert(imodel5, IModel.dictionaryId, "test material name", {
433
+ paletteName: "TestPaletteName",
434
+ patternMap: {
435
+ TextureId: texId,
436
+ pattern_offset: [0, 0],
437
+ pattern_scale: [1, 1],
438
+ pattern_scalemode: TextureMapUnits.Relative,
439
+ },
440
+ });
441
+ /* eslint-enable @typescript-eslint/naming-convention */
442
+ /** Create a simple flat mesh with 4 points (2x2) */
443
+ const width = imodel5.projectExtents.xLength() * 0.2;
444
+ const height = imodel5.projectExtents.yLength() * 0.2;
445
+ let shape;
446
+ const doPolyface = true;
447
+ if (doPolyface) {
448
+ const options = StrokeOptions.createForFacets();
449
+ options.shouldTriangulate = false;
450
+ const builder = PolyfaceBuilder.create(options);
451
+ const quad = [
452
+ Point3d.create(0.0, 0.0, 0.0),
453
+ Point3d.create(width, 0.0, 0.0),
454
+ Point3d.create(width, height, 0.0),
455
+ Point3d.create(0.0, height, 0.0),
456
+ ];
457
+ builder.addQuadFacet(quad);
458
+ shape = builder.claimPolyface();
459
+ }
460
+ else {
461
+ shape = Loop.create(LineString3d.create([
462
+ Point3d.create(0, 0, 0),
463
+ Point3d.create(width, 0, 0),
464
+ Point3d.create(width, height, 0),
465
+ Point3d.create(0, height, 0),
466
+ Point3d.create(0, 0, 0),
467
+ ]));
468
+ }
469
+ const modelId = PhysicalModel.insert(imodel5, IModelDb.rootSubjectId, "test_render_material_model_name");
470
+ const categoryId = SpatialCategory.insert(imodel5, IModel.dictionaryId, "GeoJSON Feature", { color: ColorDef.white.toJSON() });
471
+ /** generate a geometry stream containing the polyface */
472
+ const gsBuilder = new GeometryStreamBuilder();
473
+ const params = new GeometryParams(categoryId);
474
+ params.materialId = matId;
475
+ gsBuilder.appendGeometryParamsChange(params);
476
+ gsBuilder.appendGeometry(shape);
477
+ const geometry = gsBuilder.geometryStream;
478
+ // geometry[0].material = { materialId: matId };
479
+ const props = {
480
+ classFullName: "Generic:PhysicalObject",
481
+ placement: { origin: imodel5.projectExtents.center, angles: new YawPitchRollAngles() },
482
+ model: modelId,
483
+ code: Code.createEmpty(),
484
+ category: categoryId,
485
+ geom: geometry,
486
+ };
487
+ imodel5.elements.insertElement(props);
488
+ imodel5.saveChanges();
489
+ });
490
+ it("should insert a DisplayStyle", () => {
491
+ const model = imodel2.models.getModel(IModel.dictionaryId);
492
+ expect(model).not.to.be.undefined;
493
+ const settings = {
494
+ backgroundColor: ColorDef.blue.toJSON(),
495
+ viewflags: ViewFlags.fromJSON({
496
+ renderMode: RenderMode.SolidFill,
497
+ }),
498
+ };
499
+ const props = {
500
+ classFullName: DisplayStyle3d.classFullName,
501
+ model: IModel.dictionaryId,
502
+ code: { spec: BisCodeSpec.displayStyle, scope: IModel.dictionaryId, value: "test style" },
503
+ isPrivate: false,
504
+ jsonProperties: {
505
+ styles: settings,
506
+ },
507
+ };
508
+ const styleId = imodel2.elements.insertElement(props);
509
+ let style = imodel2.elements.getElement(styleId);
510
+ expect(style instanceof DisplayStyle3d).to.be.true;
511
+ expect(style.code.spec).equal(imodel2.codeSpecs.getByName(BisCodeSpec.displayStyle).id);
512
+ expect(style.settings.viewFlags.renderMode).to.equal(RenderMode.SolidFill);
513
+ expect(style.settings.backgroundColor.equals(ColorDef.blue)).to.be.true;
514
+ const newFlags = style.settings.viewFlags.copy({ renderMode: RenderMode.SmoothShade });
515
+ style.settings.viewFlags = newFlags;
516
+ style.settings.backgroundColor = ColorDef.red;
517
+ style.settings.monochromeColor = ColorDef.green;
518
+ expect(style.jsonProperties.styles.viewflags.renderMode).to.equal(RenderMode.SmoothShade);
519
+ imodel2.elements.updateElement(style.toJSON());
520
+ style = imodel2.elements.getElement(styleId);
521
+ expect(style instanceof DisplayStyle3d).to.be.true;
522
+ expect(style.settings.viewFlags.renderMode).to.equal(RenderMode.SmoothShade);
523
+ expect(style.settings.backgroundColor.equals(ColorDef.red)).to.be.true;
524
+ expect(style.settings.monochromeColor.equals(ColorDef.green)).to.be.true;
525
+ });
526
+ it("should create display styles", () => {
527
+ const defaultViewFlags = new ViewFlags().toJSON();
528
+ const defaultMapImagery = new DisplayStyleSettings({}).toJSON().mapImagery;
529
+ const viewFlags = new ViewFlags({ patterns: false, visibleEdges: true });
530
+ const viewflags = { noWhiteOnWhiteReversal: true, shadows: true, noTransp: true };
531
+ const mapImagery = {
532
+ backgroundBase: ColorDef.red.tbgr,
533
+ backgroundLayers: [{
534
+ name: "x",
535
+ url: "y",
536
+ transparency: 0.5,
537
+ formatId: "WMS",
538
+ visible: true,
539
+ }],
540
+ };
541
+ const props = {
542
+ mapImagery,
543
+ excludedElements: ["0x123", "0xfed"],
544
+ timePoint: 42,
545
+ backgroundColor: ColorDef.green.tbgr,
546
+ };
547
+ const testCases = [
548
+ [undefined, defaultViewFlags, false],
549
+ [{ viewFlags }, viewFlags.toJSON(), false],
550
+ [{ viewflags }, viewflags, false],
551
+ [{ viewflags, viewFlags }, viewFlags.toJSON(), false],
552
+ [props, defaultViewFlags, false],
553
+ [{ ...props, viewflags }, viewflags, false],
554
+ [{ backgroundColor: ColorDef.blue }, defaultViewFlags, false],
555
+ [{ backgroundColor: ColorDef.from(1, 2, 3, 4) }, defaultViewFlags, false],
556
+ [{ backgroundColor: ColorDef.blue.tbgr }, defaultViewFlags, false],
557
+ [{ backgroundColor: ColorDef.from(1, 2, 3, 4).tbgr }, defaultViewFlags, false],
558
+ ];
559
+ let suffix = 123;
560
+ for (const test of testCases) {
561
+ const expected = test[0] ?? {};
562
+ const styleId = DisplayStyle3d.insert(imodel2, IModel.dictionaryId, `TestStyle${suffix++}`, expected);
563
+ const style = imodel2.elements.getElement(styleId).toJSON();
564
+ expect(style.jsonProperties.styles).not.to.be.undefined;
565
+ expect(style.jsonProperties).not.to.be.undefined;
566
+ expect(style.jsonProperties.styles).not.to.be.undefined;
567
+ const actual = style.jsonProperties.styles;
568
+ expect(actual.viewflags).not.to.be.undefined;
569
+ const expectedVf = ViewFlags.fromJSON(test[1]);
570
+ const actualVf = ViewFlags.fromJSON(actual.viewflags);
571
+ expect(actualVf.toJSON()).to.deep.equal(expectedVf.toJSON());
572
+ const expectedBGColor = expected.backgroundColor instanceof ColorDef ? expected.backgroundColor.toJSON() : expected.backgroundColor;
573
+ expect(actual.backgroundColor).to.equal(expectedBGColor);
574
+ // DisplayStyleSettings constructor always initializes json.mapImagery.
575
+ expect(actual.mapImagery).to.deep.equal(expected.mapImagery ?? defaultMapImagery);
576
+ expect(actual.excludedElements).to.deep.equal(expected.excludedElements);
577
+ expect(actual.timePoint).to.deep.equal(expected.timePoint);
578
+ }
579
+ });
580
+ it("should have a valid root subject element", () => {
581
+ const rootSubject = imodel1.elements.getRootSubject();
582
+ assert.exists(rootSubject);
583
+ assert.isTrue(rootSubject instanceof Subject);
584
+ assert.isAtLeast(rootSubject.code.value.length, 1);
585
+ assert.isFalse(imodel1.elements.hasSubModel(IModel.rootSubjectId));
586
+ try {
587
+ imodel1.models.getSubModel(rootSubject.id); // throws error
588
+ assert.fail(); // this line should be skipped
589
+ }
590
+ catch (error) {
591
+ assert.isTrue(error instanceof Error);
592
+ assert.isTrue(error instanceof IModelError);
593
+ assert.equal(error.errorNumber, IModelStatus.NotFound);
594
+ }
595
+ const childIds = imodel1.elements.queryChildren(rootSubject.id);
596
+ assert.isAtLeast(childIds.length, 1);
597
+ for (const childId of childIds) {
598
+ const childElement = imodel1.elements.getElement(childId);
599
+ assert.exists(childElement);
600
+ assert.isTrue(childElement instanceof Element);
601
+ roundtripThroughJson(childElement);
602
+ assert.equal(rootSubject.id, childElement.parent.id);
603
+ const childLocalId = Id64.getLocalId(childId);
604
+ const childBcId = Id64.getBriefcaseId(childId);
605
+ if (childElement instanceof InformationPartitionElement) {
606
+ assert.isTrue(imodel1.elements.hasSubModel(childElement.id));
607
+ const childSubModel = imodel1.models.getSubModel(childElement.id);
608
+ assert.exists(childSubModel, "InformationPartitionElements should have a subModel");
609
+ if (childLocalId === 16 && childBcId === 0) {
610
+ assert.isTrue(childElement instanceof DefinitionPartition, "ChildId 0x00000010 should be a DefinitionPartition");
611
+ assert.isTrue(childElement.code.value === "BisCore.DictionaryModel", "Definition Partition should have code value of BisCore.DictionaryModel");
612
+ }
613
+ else if (childLocalId === 14 && childBcId === 0) {
614
+ assert.isTrue(childElement instanceof LinkPartition);
615
+ assert.isTrue(childElement.code.value === "BisCore.RealityDataSources");
616
+ }
617
+ else if (childLocalId === 17 && childBcId === 0) {
618
+ assert.isTrue(childElement instanceof LinkPartition, "ChildId 0x000000011 should be a LinkPartition");
619
+ assert.isTrue(childElement.code.value === "Repository Links");
620
+ }
621
+ }
622
+ else if (childElement instanceof Subject) {
623
+ assert.isFalse(imodel1.elements.hasSubModel(childElement.id));
624
+ if (childLocalId === 19 && childBcId === 0) {
625
+ assert.isTrue(childElement instanceof Subject);
626
+ assert.isTrue(childElement.code.value === "DgnV8:mf3, A", "Subject should have code value of DgnV8:mf3, A");
627
+ assert.isTrue(childElement.jsonProperties.Subject.Job.DgnV8.V8File === "mf3.dgn", "Subject should have jsonProperty Subject.Job.DgnV.V8File");
628
+ assert.isTrue(childElement.jsonProperties.Subject.Job.DgnV8.V8RootModel === "A", "Subject should have jsonProperty Subject.Job.DgnV.V8RootModel");
629
+ }
630
+ }
631
+ }
632
+ });
633
+ it("should load a known model by Id from an existing iModel", () => {
634
+ assert.exists(imodel1.models);
635
+ const model2 = imodel1.models.getModel("0x1c");
636
+ assert.exists(model2);
637
+ const formatter = model2.getJsonProperty("formatter");
638
+ assert.exists(formatter, "formatter should exist as json property");
639
+ assert.equal(formatter.fmtFlags.angMode, 1, "fmtFlags");
640
+ assert.equal(formatter.mastUnit.label, "m", "mastUnit is meters");
641
+ roundtripThroughJson(model2);
642
+ let model = imodel1.models.getModel(IModel.repositoryModelId);
643
+ assert.exists(model);
644
+ roundtripThroughJson(model);
645
+ const code1 = new Code({ spec: "0x1d", scope: "0x1d", value: "A" });
646
+ model = imodel1.models.getSubModel(code1);
647
+ // By this point, we expect the submodel's class to be in the class registry *cache*
648
+ const geomModel = ClassRegistry.getClass(PhysicalModel.classFullName, imodel1);
649
+ assert.exists(model);
650
+ assert.isTrue(model instanceof geomModel);
651
+ roundtripThroughJson(model);
652
+ const modelExtents = model.queryExtents();
653
+ assert.isBelow(modelExtents.low.x, modelExtents.high.x);
654
+ assert.isBelow(modelExtents.low.y, modelExtents.high.y);
655
+ assert.isBelow(modelExtents.low.z, modelExtents.high.z);
656
+ });
657
+ it("should find a tile tree for a geometric model", async () => {
658
+ // Note: this is an empty model.
659
+ const tree = await imodel1.tiles.requestTileTreeProps("0x1c");
660
+ expect(tree).not.to.be.undefined;
661
+ expect(tree.id).to.equal("0x1c");
662
+ expect(tree.maxTilesToSkip).to.equal(1);
663
+ expect(tree.rootTile).not.to.be.undefined;
664
+ // Empty model => identity transform
665
+ const tf = Transform.fromJSON(tree.location);
666
+ expect(tf.matrix.isIdentity).to.be.true;
667
+ expect(tf.origin.x).to.equal(0);
668
+ expect(tf.origin.y).to.equal(0);
669
+ expect(tf.origin.z).to.equal(0);
670
+ expect(tree.rootTile.contentId).to.equal("0/0/0/0/1");
671
+ // Empty model => null range
672
+ const range = Range3d.fromJSON(tree.rootTile.range);
673
+ expect(range.isNull).to.be.true;
674
+ expect(tree.rootTile.maximumSize).to.equal(0.0); // empty model => undisplayable root tile => size = 0.0
675
+ expect(tree.rootTile.isLeaf).to.be.true; // empty model => empty tile
676
+ expect(tree.rootTile.contentRange).to.be.undefined;
677
+ });
678
+ it("should throw on invalid tile requests", async () => {
679
+ const env_1 = { stack: [], error: void 0, hasError: false };
680
+ try {
681
+ const _r = __addDisposableResource(env_1, new DisableNativeAssertions(), false);
682
+ let error = await getIModelError(imodel1.tiles.requestTileTreeProps("0x12345"));
683
+ expectIModelError(IModelStatus.InvalidId, error);
684
+ error = await getIModelError(imodel1.tiles.requestTileTreeProps("NotAValidId"));
685
+ expectIModelError(IModelStatus.InvalidId, error);
686
+ error = await getIModelError(imodel1.tiles.requestTileContent("0x1c", "0/0/0/0"));
687
+ expectIModelError(IModelStatus.InvalidId, error);
688
+ error = await getIModelError(imodel1.tiles.requestTileContent("0x12345", "0/0/0/0/1"));
689
+ expectIModelError(IModelStatus.InvalidId, error);
690
+ error = await getIModelError(imodel1.tiles.requestTileContent("0x1c", "V/W/X/Y/Z"));
691
+ expectIModelError(IModelStatus.InvalidId, error);
692
+ error = await getIModelError(imodel1.tiles.requestTileContent("0x1c", "NotAValidId"));
693
+ expectIModelError(IModelStatus.InvalidId, error);
694
+ }
695
+ catch (e_1) {
696
+ env_1.error = e_1;
697
+ env_1.hasError = true;
698
+ }
699
+ finally {
700
+ __disposeResources(env_1);
701
+ }
702
+ });
703
+ // NOTE: this test can be removed when the deprecated executeQuery method is removed
704
+ it("should produce an array of rows", () => {
705
+ const rows = IModelTestUtils.executeQuery(imodel1, `SELECT * FROM ${Category.classFullName}`);
706
+ assert.exists(rows);
707
+ assert.isArray(rows);
708
+ assert.isAtLeast(rows.length, 1);
709
+ assert.exists(rows[0].id);
710
+ assert.notEqual(rows[0].id.value, "");
711
+ });
712
+ it("should be some categories", () => {
713
+ const categorySql = `SELECT ECInstanceId FROM ${Category.classFullName}`;
714
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
715
+ imodel1.withPreparedStatement(categorySql, (categoryStatement) => {
716
+ let numCategories = 0;
717
+ while (DbResult.BE_SQLITE_ROW === categoryStatement.step()) {
718
+ numCategories++;
719
+ const categoryId = categoryStatement.getValue(0).getId();
720
+ const category = imodel1.elements.getElement(categoryId);
721
+ assert.isTrue(category instanceof Category, "Should be instance of Category");
722
+ // verify the default subcategory.
723
+ const defaultSubCategoryId = category.myDefaultSubCategoryId();
724
+ const defaultSubCategory = imodel1.elements.getElement(defaultSubCategoryId);
725
+ assert.isTrue(defaultSubCategory instanceof SubCategory, "defaultSubCategory should be instance of SubCategory");
726
+ if (defaultSubCategory instanceof SubCategory) {
727
+ assert.isTrue(defaultSubCategory.parent.id === categoryId, "defaultSubCategory id should be prescribed value");
728
+ assert.isTrue(defaultSubCategory.getSubCategoryName() === category.code.value, "DefaultSubcategory name should match that of Category");
729
+ assert.isTrue(defaultSubCategory.isDefaultSubCategory, "isDefaultSubCategory should return true");
730
+ }
731
+ // get the subcategories
732
+ const subCategorySql = `SELECT ECInstanceId FROM ${SubCategory.classFullName} WHERE Parent.Id=:parentId`;
733
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
734
+ imodel1.withPreparedStatement(subCategorySql, (subCategoryStatement) => {
735
+ let numSubCategories = 0;
736
+ subCategoryStatement.bindId("parentId", categoryId);
737
+ while (DbResult.BE_SQLITE_ROW === subCategoryStatement.step()) {
738
+ numSubCategories++;
739
+ const subCategoryId = subCategoryStatement.getValue(0).getId();
740
+ const subCategory = imodel1.elements.getElement(subCategoryId);
741
+ assert.isTrue(subCategory instanceof SubCategory);
742
+ assert.isTrue(subCategory.parent.id === categoryId);
743
+ }
744
+ assert.isAtLeast(numSubCategories, 1, "Expected query to find at least one SubCategory");
745
+ });
746
+ }
747
+ assert.isAtLeast(numCategories, 1, "Expected query to find some categories");
748
+ });
749
+ });
750
+ it("should be some 2d elements", () => {
751
+ const sql = `SELECT ECInstanceId FROM ${DrawingGraphic.classFullName}`;
752
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
753
+ imodel2.withPreparedStatement(sql, (statement) => {
754
+ let numDrawingGraphics = 0;
755
+ let found25 = false;
756
+ let found26 = false;
757
+ while (DbResult.BE_SQLITE_ROW === statement.step()) {
758
+ numDrawingGraphics++;
759
+ const drawingGraphicId = statement.getValue(0).getId();
760
+ const drawingGraphic = imodel2.elements.getElement({ id: drawingGraphicId, wantGeometry: true });
761
+ assert.exists(drawingGraphic);
762
+ assert.isTrue(drawingGraphic.className === "DrawingGraphic", "Should be instance of DrawingGraphic");
763
+ assert.isTrue(drawingGraphic instanceof DrawingGraphic, "Is instance of DrawingGraphic");
764
+ assert.isTrue(drawingGraphic instanceof GeometricElement2d, "Is instance of GeometricElement2d");
765
+ if (Id64.getLocalId(drawingGraphic.id) === 0x25) {
766
+ found25 = true;
767
+ assert.isTrue(drawingGraphic.placement.origin.x === 0.0);
768
+ assert.isTrue(drawingGraphic.placement.origin.y === 0.0);
769
+ assert.isTrue(drawingGraphic.placement.angle.radians === 0.0);
770
+ assert.isTrue(drawingGraphic.placement.bbox.low.x === 0.0);
771
+ assert.isTrue(drawingGraphic.placement.bbox.low.y === 0.0);
772
+ assert.isTrue(drawingGraphic.placement.bbox.high.x === 1.0);
773
+ assert.isTrue(drawingGraphic.placement.bbox.high.y === 1.0);
774
+ assert.isDefined(drawingGraphic.geom);
775
+ }
776
+ else if (Id64.getLocalId(drawingGraphic.id) === 0x26) {
777
+ found26 = true;
778
+ assert.isTrue(drawingGraphic.placement.origin.x === 1.0);
779
+ assert.isTrue(drawingGraphic.placement.origin.y === 1.0);
780
+ assert.isTrue(drawingGraphic.placement.angle.radians === 0.0);
781
+ assert.isTrue(drawingGraphic.placement.bbox.low.x === 0.0);
782
+ assert.isTrue(drawingGraphic.placement.bbox.low.y === 0.0);
783
+ assert.isTrue(drawingGraphic.placement.bbox.high.x === 2.0);
784
+ assert.isTrue(drawingGraphic.placement.bbox.high.y === 2.0);
785
+ assert.isDefined(drawingGraphic.geom);
786
+ }
787
+ }
788
+ assert.isAtLeast(numDrawingGraphics, 1, "Expected query to find some DrawingGraphics");
789
+ assert.isTrue(found25, "Expected to find a specific element");
790
+ assert.isTrue(found26, "Expected to find a specific element");
791
+ });
792
+ });
793
+ it("should be able to query for ViewDefinitionProps", () => {
794
+ const viewDefinitionProps = imodel2.views.queryViewDefinitionProps(); // query for all ViewDefinitions
795
+ assert.isAtLeast(viewDefinitionProps.length, 3);
796
+ assert.isTrue(viewDefinitionProps[0].classFullName.includes("ViewDefinition"));
797
+ assert.isFalse(viewDefinitionProps[1].isPrivate);
798
+ const spatialViewDefinitionProps = imodel2.views.queryViewDefinitionProps("BisCore.SpatialViewDefinition"); // limit query to SpatialViewDefinitions
799
+ assert.isAtLeast(spatialViewDefinitionProps.length, 3);
800
+ assert.exists(spatialViewDefinitionProps[2].modelSelectorId);
801
+ });
802
+ it("should iterate ViewDefinitions", () => {
803
+ // imodel2 contains 3 SpatialViewDefinitions and no other views.
804
+ let numViews = 0;
805
+ let result = imodel2.views.iterateViews(IModelDb.Views.defaultQueryParams, (_view) => {
806
+ ++numViews;
807
+ return true;
808
+ });
809
+ expect(result).to.be.true;
810
+ expect(numViews).to.equal(3);
811
+ // Query specifically for spatial views
812
+ numViews = 0;
813
+ result = imodel2.views.iterateViews({ from: "BisCore.SpatialViewDefinition" }, (view) => {
814
+ if (view.isSpatialView())
815
+ ++numViews;
816
+ return view.isSpatialView();
817
+ });
818
+ expect(result).to.be.true;
819
+ expect(numViews).to.equal(3);
820
+ // Query specifically for 2d views
821
+ numViews = 0;
822
+ result = imodel2.views.iterateViews({ from: "BisCore.ViewDefinition2d" }, (_view) => {
823
+ ++numViews;
824
+ return true;
825
+ });
826
+ expect(result).to.be.true;
827
+ expect(numViews).to.equal(0);
828
+ // Terminate iteration on first view
829
+ numViews = 0;
830
+ result = imodel2.views.iterateViews(IModelDb.Views.defaultQueryParams, (_view) => {
831
+ ++numViews;
832
+ return false;
833
+ });
834
+ expect(result).to.be.false;
835
+ expect(numViews).to.equal(1);
836
+ });
837
+ it("should be children of RootSubject", () => {
838
+ const sql = `SELECT ECInstanceId FROM ${Model.classFullName} WHERE ParentModel.Id=:parentModelId`;
839
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
840
+ imodel2.withPreparedStatement(sql, (statement) => {
841
+ statement.bindId("parentModelId", IModel.repositoryModelId);
842
+ let numModels = 0;
843
+ while (DbResult.BE_SQLITE_ROW === statement.step()) {
844
+ numModels++;
845
+ const modelId = statement.getValue(0).getId();
846
+ const model = imodel2.models.getModel(modelId);
847
+ assert.exists(model, "Model should exist");
848
+ assert.isTrue(model instanceof Model);
849
+ // should be an element with the same Id.
850
+ const modeledElement = imodel2.elements.getElement(modelId);
851
+ assert.exists(modeledElement, "Modeled Element should exist");
852
+ if (model.className === "LinkModel") {
853
+ // expect LinkModel to be accompanied by LinkPartition
854
+ assert.isTrue(modeledElement instanceof LinkPartition);
855
+ continue;
856
+ }
857
+ else if (model.className === "DictionaryModel") {
858
+ assert.isTrue(modeledElement instanceof DefinitionPartition);
859
+ continue;
860
+ }
861
+ else if (model.className === "PhysicalModel") {
862
+ assert.isTrue(modeledElement instanceof PhysicalPartition);
863
+ continue;
864
+ }
865
+ else if (model.className === "GroupModel") {
866
+ assert.isTrue(modeledElement instanceof GroupInformationPartition);
867
+ continue;
868
+ }
869
+ else if (model.className === "DocumentListModel") {
870
+ assert.isTrue(modeledElement instanceof DocumentPartition);
871
+ continue;
872
+ }
873
+ else if (model.className === "DefinitionModel") {
874
+ assert.isTrue(modeledElement instanceof DefinitionPartition);
875
+ continue;
876
+ }
877
+ else {
878
+ assert.isTrue(false, "Expected a known model type");
879
+ }
880
+ }
881
+ assert.isAtLeast(numModels, 1, "Expected query to find some Models");
882
+ });
883
+ });
884
+ it("should insert and update auto-handled properties", () => {
885
+ const testElem = imodel4.elements.getElement("0x14");
886
+ assert.isDefined(testElem);
887
+ assert.equal(testElem.classFullName, "DgnPlatformTest:TestElementWithNoHandler");
888
+ assert.isUndefined(testElem.asAny.integerProperty1);
889
+ const newTestElem = roundtripThroughJson(testElem);
890
+ assert.equal(newTestElem.classFullName, testElem.classFullName);
891
+ newTestElem.asAny.integerProperty1 = 999;
892
+ assert.isTrue(testElem.asAny.arrayOfPoint3d[0].isAlmostEqual(newTestElem.asAny.arrayOfPoint3d[0]));
893
+ const loc1 = { street: "Elm Street", city: { name: "Downingtown", state: "PA" } };
894
+ const loc2 = { street: "Oak Street", city: { name: "Downingtown", state: "PA" } };
895
+ const loc3 = { street: "Chestnut Street", city: { name: "Philadelphia", state: "PA" } };
896
+ const arrayOfStructs = [loc2, loc3];
897
+ newTestElem.asAny.location = loc1;
898
+ newTestElem.asAny.arrayOfStructs = arrayOfStructs;
899
+ newTestElem.asAny.dtUtc = new Date("2015-03-25");
900
+ newTestElem.asAny.p3d = new Point3d(1, 2, 3);
901
+ const newTestElemId = imodel4.elements.insertElement(newTestElem.toJSON());
902
+ assert.isTrue(Id64.isValidId64(newTestElemId), "insert worked");
903
+ const newTestElemFetched = imodel4.elements.getElement(newTestElemId);
904
+ assert.isDefined(newTestElemFetched);
905
+ assert.isTrue(newTestElemFetched.id === newTestElemId);
906
+ assert.equal(newTestElemFetched.classFullName, newTestElem.classFullName);
907
+ assert.isDefined(newTestElemFetched.asAny.integerProperty1);
908
+ assert.equal(newTestElemFetched.asAny.integerProperty1, newTestElem.asAny.integerProperty1);
909
+ assert.isTrue(newTestElemFetched.asAny.arrayOfPoint3d[0].isAlmostEqual(newTestElem.asAny.arrayOfPoint3d[0]));
910
+ assert.deepEqual(newTestElemFetched.asAny.location, loc1);
911
+ assert.deepEqual(newTestElem.asAny.arrayOfStructs, arrayOfStructs);
912
+ // TODO: getElement must convert date ISO string to Date object assert.deepEqual(newTestElemFetched.dtUtc, newTestElem.dtUtc);
913
+ assert.deepEqual(newTestElemFetched.asAny.dtUtc, newTestElem.asAny.dtUtc.toJSON());
914
+ assert.isTrue(newTestElemFetched.asAny.p3d.isAlmostEqual(newTestElem.asAny.p3d));
915
+ // ----------- updates ----------------
916
+ const wasp3d = newTestElemFetched.asAny.p3d;
917
+ const editElem = newTestElemFetched;
918
+ editElem.asAny.location = loc2;
919
+ try {
920
+ imodel4.elements.updateElement(editElem.toJSON());
921
+ }
922
+ catch {
923
+ assert.fail("Element.update failed");
924
+ }
925
+ const afterUpdateElemFetched = imodel4.elements.getElement(editElem.id);
926
+ assert.deepEqual(afterUpdateElemFetched.asAny.location, loc2, " location property should be the new one");
927
+ assert.deepEqual(afterUpdateElemFetched.asAny.id, editElem.id, " the id should not have changed.");
928
+ assert.deepEqual(afterUpdateElemFetched.asAny.p3d, wasp3d, " p3d property should not have changed");
929
+ // Make array shorter
930
+ assert.equal(afterUpdateElemFetched.asAny.arrayOfInt.length, 300);
931
+ afterUpdateElemFetched.asAny.arrayOfInt = [99, 3];
932
+ imodel4.elements.updateElement(afterUpdateElemFetched.toJSON());
933
+ const afterShortenArray = imodel4.elements.getElement(afterUpdateElemFetched.id);
934
+ assert.equal(afterUpdateElemFetched.asAny.arrayOfInt.length, 2);
935
+ assert.deepEqual(afterShortenArray.asAny.arrayOfInt, [99, 3]);
936
+ // Make array longer
937
+ afterShortenArray.asAny.arrayOfInt = [1, 2, 3];
938
+ imodel4.elements.updateElement(afterShortenArray.toJSON());
939
+ const afterLengthenArray = imodel4.elements.getElement(afterShortenArray.id);
940
+ assert.equal(afterLengthenArray.asAny.arrayOfInt.length, 3);
941
+ assert.deepEqual(afterLengthenArray.asAny.arrayOfInt, [1, 2, 3]);
942
+ // ------------ delete -----------------
943
+ const elid = afterUpdateElemFetched.id;
944
+ imodel4.elements.deleteElement(elid);
945
+ assert.throws(() => imodel4.elements.getElement(elid), IModelError);
946
+ });
947
+ it("should handle parent and child deletion properly", () => {
948
+ const categoryId = SpatialCategory.insert(imodel4, IModel.dictionaryId, "MyTestCategory", new SubCategoryAppearance());
949
+ const category = imodel4.elements.getElement(categoryId);
950
+ const subCategory = imodel4.elements.getElement(category.myDefaultSubCategoryId());
951
+ expect(() => imodel4.elements.deleteElement(categoryId)).throws("error deleting element").to.have.property("metadata");
952
+ assert.exists(imodel4.elements.getElement(categoryId), "Category deletes should be blocked in native code");
953
+ assert.exists(imodel4.elements.getElement(subCategory.id), "Children should not be deleted if parent delete is blocked");
954
+ const modelId = PhysicalModel.insert(imodel4, IModel.rootSubjectId, "MyTestPhysicalModel");
955
+ const elementProps = {
956
+ classFullName: PhysicalObject.classFullName,
957
+ model: modelId,
958
+ category: categoryId,
959
+ code: Code.createEmpty(),
960
+ };
961
+ const parentId = imodel4.elements.insertElement(elementProps);
962
+ elementProps.parent = new ElementOwnsChildElements(parentId);
963
+ const childId1 = imodel4.elements.insertElement(elementProps);
964
+ const childId2 = imodel4.elements.insertElement(elementProps);
965
+ assert.exists(imodel4.elements.getElement(parentId));
966
+ assert.exists(imodel4.elements.getElement(childId1));
967
+ assert.exists(imodel4.elements.getElement(childId2));
968
+ imodel4.elements.deleteElement(parentId);
969
+ assert.throws(() => imodel4.elements.getElement(parentId), IModelError);
970
+ assert.throws(() => imodel4.elements.getElement(childId1), IModelError);
971
+ assert.throws(() => imodel4.elements.getElement(childId2), IModelError);
972
+ });
973
+ function checkElementMetaData(entityClass) {
974
+ assert.isNotNull(entityClass);
975
+ assert.equal(entityClass.fullName, Element.classFullName.replace(":", "."));
976
+ assert.isUndefined(entityClass.baseClass);
977
+ let foundClassHasHandler = false;
978
+ let foundClassHasCurrentTimeStampProperty = false;
979
+ if (entityClass.customAttributes !== undefined) {
980
+ if (entityClass.customAttributes.has("BisCore.ClassHasHandler"))
981
+ foundClassHasHandler = true;
982
+ if (entityClass.customAttributes.has("CoreCustomAttributes.ClassHasCurrentTimeStampProperty"))
983
+ foundClassHasCurrentTimeStampProperty = true;
984
+ }
985
+ assert.isTrue(foundClassHasHandler);
986
+ assert.isTrue(foundClassHasCurrentTimeStampProperty);
987
+ const federationGuid = entityClass.getPropertySync("federationGuid", false);
988
+ if (federationGuid !== undefined) {
989
+ assert.isTrue(federationGuid.isPrimitive());
990
+ assert.equal(federationGuid.propertyType, PropertyType.Binary);
991
+ assert.equal(federationGuid.extendedTypeName, "BeGuid");
992
+ }
993
+ }
994
+ it("should get metadata for class", () => {
995
+ const metaData = imodel1.schemaContext.getSchemaItemSync(Element.classFullName, EntityClass);
996
+ assert.exists(metaData);
997
+ if (metaData !== undefined)
998
+ checkElementMetaData(metaData);
999
+ });
1000
+ it("update the project extents", async () => {
1001
+ const originalExtents = imodel1.projectExtents;
1002
+ const newExtents = Range3d.create(originalExtents.low, originalExtents.high);
1003
+ newExtents.low.x -= 50;
1004
+ newExtents.low.y -= 25;
1005
+ newExtents.low.z -= 189;
1006
+ newExtents.high.x += 1087;
1007
+ newExtents.high.y += 19;
1008
+ newExtents.high.z += .001;
1009
+ imodel1.updateProjectExtents(newExtents);
1010
+ const updatedProps = imodel1[_nativeDb].getIModelProps();
1011
+ assert.isTrue(updatedProps.hasOwnProperty("projectExtents"), "Returned property JSON object has project extents");
1012
+ const updatedExtents = Range3d.fromJSON(updatedProps.projectExtents);
1013
+ assert.isTrue(newExtents.isAlmostEqual(updatedExtents), "Project extents successfully updated in database");
1014
+ });
1015
+ it("read view thumbnail", () => {
1016
+ const viewId = "0x24";
1017
+ const thumbnail = imodel5.views.getThumbnail(viewId);
1018
+ assert.exists(thumbnail);
1019
+ if (!thumbnail)
1020
+ return;
1021
+ assert.equal(thumbnail.format, "jpeg");
1022
+ assert.equal(thumbnail.height, 768);
1023
+ assert.equal(thumbnail.width, 768);
1024
+ assert.equal(thumbnail.image.length, 18062);
1025
+ thumbnail.width = 100;
1026
+ thumbnail.height = 200;
1027
+ thumbnail.format = "png";
1028
+ thumbnail.image = new Uint8Array(200);
1029
+ thumbnail.image.fill(12);
1030
+ const stat = imodel5.views.saveThumbnail(viewId, thumbnail);
1031
+ assert.equal(stat, 0, "save thumbnail");
1032
+ const thumbnail2 = imodel5.views.getThumbnail(viewId);
1033
+ assert.exists(thumbnail2);
1034
+ if (!thumbnail2)
1035
+ return;
1036
+ assert.equal(thumbnail2.format, "png");
1037
+ assert.equal(thumbnail2.height, 200);
1038
+ assert.equal(thumbnail2.width, 100);
1039
+ assert.equal(thumbnail2.image.length, 200);
1040
+ assert.equal(thumbnail2.image[0], 12);
1041
+ });
1042
+ it("ecefLocation for iModels", () => {
1043
+ assert.isTrue(imodel5.isGeoLocated);
1044
+ const center = { x: 289095, y: 3803860, z: 10 }; // near center of project extents, 10 meters above ground.
1045
+ const ecefPt = imodel5.spatialToEcef(center);
1046
+ const pt = { x: -3575156.3661052254, y: 3873432.0891543664, z: 3578996.012643183 };
1047
+ assert.isTrue(ecefPt.isAlmostEqual(pt), "spatialToEcef");
1048
+ const z2 = imodel5.ecefToSpatial(ecefPt);
1049
+ assert.isTrue(z2.isAlmostEqual(center), "ecefToSpatial");
1050
+ const carto = imodel5.spatialToCartographicFromEcef(center);
1051
+ assert.approximately(carto.longitudeDegrees, 132.70683882277805, .1); // this data is in Japan
1052
+ assert.approximately(carto.latitudeDegrees, 34.35462768786055, .1);
1053
+ const c2 = { longitude: 2.3161712773709127, latitude: 0.5996013664499733, height: 10 };
1054
+ assert.isTrue(carto.equalsEpsilon(c2, .001), "spatialToCartographic");
1055
+ imodel5.cartographicToSpatialFromEcef(carto, z2);
1056
+ assert.isTrue(z2.isAlmostEqual(center, .001), "cartographicToSpatial");
1057
+ assert.isTrue(imodel5.geographicCoordinateSystem !== undefined);
1058
+ assert.isTrue(imodel5.geographicCoordinateSystem.horizontalCRS !== undefined);
1059
+ assert.isTrue(imodel5.geographicCoordinateSystem.verticalCRS !== undefined);
1060
+ assert.isTrue(imodel5.geographicCoordinateSystem.verticalCRS.id !== undefined);
1061
+ assert.isTrue(imodel5.geographicCoordinateSystem.horizontalCRS.id === "UTM84-53N");
1062
+ assert.isTrue(imodel5.geographicCoordinateSystem.verticalCRS.id === "ELLIPSOID");
1063
+ });
1064
+ function checkClassHasHandlerMetaData(classToCheck) {
1065
+ assert.isDefined(classToCheck);
1066
+ const propertiesArray = Array.from(classToCheck.getPropertiesSync(true));
1067
+ assert.equal(propertiesArray.length, 1);
1068
+ const restrictionProperty = propertiesArray[0];
1069
+ assert.isDefined(restrictionProperty);
1070
+ assert.equal(restrictionProperty.name, "Restrictions");
1071
+ assert.equal(propertyTypeToString(restrictionProperty.propertyType), "PrimitiveArrayProperty");
1072
+ assert.equal(restrictionProperty.minOccurs, 0);
1073
+ }
1074
+ it("should get metadata for CA class just as well (and we'll see a array-typed property)", () => {
1075
+ const metaData = imodel1.schemaContext.getSchemaItemSync("BisCore.ClassHasHandler", CustomAttributeClass);
1076
+ assert.exists(metaData);
1077
+ if (metaData !== undefined) {
1078
+ assert.equal(metaData.schemaItemType, SchemaItemType.CustomAttributeClass);
1079
+ checkClassHasHandlerMetaData(metaData);
1080
+ }
1081
+ });
1082
+ it("should exercise ECSqlStatement (backend only)", () => {
1083
+ // Reject an invalid statement
1084
+ try {
1085
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1086
+ imodel2.prepareStatement("select no_such_property, codeValue from bis.element", false);
1087
+ assert.fail("prepare should have failed with an exception");
1088
+ }
1089
+ catch (err) {
1090
+ assert.isTrue(err.constructor.name === "IModelError");
1091
+ assert.notEqual(err.status, DbResult.BE_SQLITE_OK);
1092
+ }
1093
+ let lastId = "";
1094
+ let firstCodeValue = "";
1095
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1096
+ imodel2.withPreparedStatement("select ecinstanceid, codeValue from bis.element", (stmt) => {
1097
+ assert.isNotNull(stmt);
1098
+ // Reject an attempt to bind when there are no placeholders in the statement
1099
+ try {
1100
+ stmt.bindStruct(1, { foo: 1 });
1101
+ assert.fail("bindStruct should have failed with an exception");
1102
+ }
1103
+ catch (err2) {
1104
+ assert.isTrue(err2.constructor.name === "IModelError");
1105
+ assert.notEqual(err2.status, DbResult.BE_SQLITE_OK);
1106
+ }
1107
+ // Verify that we get a bunch of rows with the expected shape
1108
+ let count = 0;
1109
+ while (DbResult.BE_SQLITE_ROW === stmt.step()) {
1110
+ const row = stmt.getRow();
1111
+ assert.isNotNull(row);
1112
+ assert.isObject(row);
1113
+ assert.isTrue(row.id !== undefined);
1114
+ assert.isTrue(Id64.isValid(Id64.fromJSON(row.id)));
1115
+ lastId = row.id;
1116
+ if (row.codeValue !== undefined)
1117
+ firstCodeValue = row.codeValue;
1118
+ count = count + 1;
1119
+ }
1120
+ assert.isTrue(count > 1);
1121
+ assert.notEqual(lastId, "");
1122
+ assert.notEqual(firstCodeValue, "");
1123
+ // Try iterator style
1124
+ let firstCodeValueIter = "";
1125
+ let iteratorCount = 0;
1126
+ let lastIterId = "";
1127
+ stmt.reset();
1128
+ for (const row of stmt) {
1129
+ assert.isNotNull(row);
1130
+ assert.isObject(row);
1131
+ assert.isTrue(row.id !== undefined);
1132
+ assert.isTrue(Id64.isValid(Id64.fromJSON(row.id)));
1133
+ lastIterId = row.id;
1134
+ iteratorCount = iteratorCount + 1;
1135
+ if (row.codeValue !== undefined)
1136
+ firstCodeValueIter = row.codeValue;
1137
+ }
1138
+ assert.equal(iteratorCount, count, "iterator loop should find the same number of rows as the step loop");
1139
+ assert.equal(lastIterId, lastId, "iterator loop should see the same last row as the step loop");
1140
+ assert.equal(firstCodeValueIter, firstCodeValue, "iterator loop should find the first non-null code value as the step loop");
1141
+ });
1142
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1143
+ imodel2.withPreparedStatement("select ecinstanceid, codeValue from bis.element WHERE (ecinstanceid=?)", (stmt3) => {
1144
+ // Now try a statement with a placeholder
1145
+ const idToFind = Id64.fromJSON(lastId);
1146
+ stmt3.bindId(1, idToFind);
1147
+ let count = 0;
1148
+ while (DbResult.BE_SQLITE_ROW === stmt3.step()) {
1149
+ count = count + 1;
1150
+ const row = stmt3.getRow();
1151
+ // Verify that we got the row that we asked for
1152
+ assert.isTrue(idToFind === Id64.fromJSON(row.id));
1153
+ }
1154
+ // Verify that we got the row that we asked for
1155
+ assert.equal(count, 1);
1156
+ });
1157
+ let firstCodeValueId;
1158
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1159
+ imodel2.withPreparedStatement("select ecinstanceid, codeValue from bis.element WHERE (codeValue = :codevalue)", (stmt4) => {
1160
+ // Try a named placeholder
1161
+ const codeValueToFind = firstCodeValue;
1162
+ stmt4.bindString("codeValue", codeValueToFind);
1163
+ let count = 0;
1164
+ while (DbResult.BE_SQLITE_ROW === stmt4.step()) {
1165
+ count = count + 1;
1166
+ const row = stmt4.getRow();
1167
+ // Verify that we got the row that we asked for
1168
+ assert.equal(row.codeValue, codeValueToFind);
1169
+ firstCodeValueId = row.id;
1170
+ }
1171
+ // Verify that we got the row that we asked for
1172
+ assert.equal(count, 1);
1173
+ });
1174
+ // make sure we can use parameterized values for queryEnityId (test on parameterized codevalue)
1175
+ const ids = imodel2.queryEntityIds({ from: "bis.element", where: "codevalue=:cv", bindings: { cv: firstCodeValue } });
1176
+ assert.equal(ids.values().next().value, firstCodeValueId);
1177
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1178
+ imodel2.withPreparedStatement("select ecinstanceid as id, codevalue from bis.element", (stmt5) => {
1179
+ while (DbResult.BE_SQLITE_ROW === stmt5.step()) {
1180
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1181
+ imodel2.withPreparedStatement("select codevalue from bis.element where ecinstanceid=?", (stmt6) => {
1182
+ stmt6.bindId(1, stmt5.getRow().id);
1183
+ while (DbResult.BE_SQLITE_ROW === stmt6.step()) {
1184
+ assert.equal(stmt6.getRow().codevalue, stmt5.getRow().codevalue);
1185
+ }
1186
+ });
1187
+ }
1188
+ });
1189
+ // make sure queryEnityIds works fine when all params are specified
1190
+ const physicalObjectIds = imodel2.queryEntityIds({ from: "generic.PhysicalObject", where: "codevalue is null", limit: 1, offset: 1, only: true, orderBy: "ecinstanceid desc" });
1191
+ assert.equal(physicalObjectIds.size, 1);
1192
+ });
1193
+ it("validate BisCodeSpecs", async () => {
1194
+ assert.equal(imodel2.codeSpecs.getByName(BisCodeSpec.nullCodeSpec).scopeType, CodeScopeSpec.Type.Repository);
1195
+ assert.equal(imodel2.codeSpecs.getByName(BisCodeSpec.subCategory).scopeType, CodeScopeSpec.Type.ParentElement);
1196
+ assert.equal(imodel2.codeSpecs.getByName(BisCodeSpec.viewDefinition).scopeType, CodeScopeSpec.Type.Model);
1197
+ assert.equal(imodel2.codeSpecs.getByName(BisCodeSpec.subject).scopeReq, CodeScopeSpec.ScopeRequirement.ElementId);
1198
+ });
1199
+ it("should create and insert CodeSpecs", () => {
1200
+ const testImodel = imodel2;
1201
+ const codeSpec = CodeSpec.create(testImodel, "CodeSpec1", CodeScopeSpec.Type.Model);
1202
+ const codeSpecId = testImodel.codeSpecs.insert(codeSpec); // throws in case of error
1203
+ assert.deepEqual(codeSpecId, codeSpec.id);
1204
+ assert.equal(codeSpec.scopeType, CodeScopeSpec.Type.Model);
1205
+ assert.equal(codeSpec.scopeReq, CodeScopeSpec.ScopeRequirement.ElementId);
1206
+ // Should not be able to insert a duplicate.
1207
+ const codeSpecDup = CodeSpec.create(testImodel, "CodeSpec1", CodeScopeSpec.Type.Model);
1208
+ assert.throws(() => testImodel.codeSpecs.insert(codeSpecDup), "CodeSpec already exists");
1209
+ // We should be able to insert another CodeSpec with a different name.
1210
+ const codeSpec2 = CodeSpec.create(testImodel, "CodeSpec2", CodeScopeSpec.Type.Model, CodeScopeSpec.ScopeRequirement.FederationGuid);
1211
+ const codeSpec2Id = testImodel.codeSpecs.insert(codeSpec2); // throws in case of error
1212
+ assert.deepEqual(codeSpec2Id, codeSpec2.id);
1213
+ assert.notDeepEqual(codeSpec2Id, codeSpecId);
1214
+ // make sure CodeScopeSpec.Type.Repository works
1215
+ const codeSpec3 = CodeSpec.create(testImodel, "CodeSpec3", CodeScopeSpec.Type.Repository, CodeScopeSpec.ScopeRequirement.FederationGuid);
1216
+ const codeSpec3Id = testImodel.codeSpecs.insert(codeSpec3); // throws in case of error
1217
+ assert.notDeepEqual(codeSpec2Id, codeSpec3Id);
1218
+ const codeSpec4 = testImodel.codeSpecs.getById(codeSpec3Id);
1219
+ codeSpec4.name = "CodeSpec4";
1220
+ const codeSpec4Id = testImodel.codeSpecs.insert(codeSpec4); // throws in case of error
1221
+ assert.notDeepEqual(codeSpec3Id, codeSpec4Id);
1222
+ assert.equal(codeSpec4.scopeType, CodeScopeSpec.Type.Repository);
1223
+ assert.equal(codeSpec4.scopeReq, CodeScopeSpec.ScopeRequirement.FederationGuid);
1224
+ const copyOfCodeSpec4 = testImodel.codeSpecs.getById(codeSpec4Id);
1225
+ assert.deepEqual(codeSpec4, copyOfCodeSpec4);
1226
+ assert.isTrue(testImodel.codeSpecs.hasName("CodeSpec1"));
1227
+ assert.isTrue(testImodel.codeSpecs.hasName("CodeSpec2"));
1228
+ assert.isTrue(testImodel.codeSpecs.hasName("CodeSpec3"));
1229
+ assert.isTrue(testImodel.codeSpecs.hasName("CodeSpec4"));
1230
+ assert.isFalse(testImodel.codeSpecs.hasName("CodeSpec5"));
1231
+ assert.isTrue(testImodel.codeSpecs.hasId(codeSpec.id));
1232
+ assert.isTrue(testImodel.codeSpecs.hasId(codeSpec2.id));
1233
+ assert.isTrue(testImodel.codeSpecs.hasId(codeSpec3.id));
1234
+ assert.isTrue(testImodel.codeSpecs.hasId(codeSpec4.id));
1235
+ assert.isFalse(testImodel.codeSpecs.hasId(Id64.invalid));
1236
+ });
1237
+ it("validate CodeSpec properties", async () => {
1238
+ const iModelFileName = IModelTestUtils.prepareOutputFile("IModel", "ReadWriteCodeSpec.bim");
1239
+ const codeSpecName = "CodeSpec1";
1240
+ // Write new CodeSpec to iModel
1241
+ if (true) {
1242
+ const iModelDb = IModelTestUtils.createSnapshotFromSeed(iModelFileName, IModelTestUtils.resolveAssetFile("CompatibilityTestSeed.bim"));
1243
+ const codeSpec = CodeSpec.create(iModelDb, codeSpecName, CodeScopeSpec.Type.Model, CodeScopeSpec.ScopeRequirement.FederationGuid);
1244
+ const codeSpecId = iModelDb.codeSpecs.insert(codeSpec);
1245
+ assert.isTrue(Id64.isValidId64(codeSpec.id));
1246
+ assert.equal(codeSpec.id, codeSpecId);
1247
+ assert.equal(codeSpec.name, codeSpecName);
1248
+ assert.equal(codeSpec.scopeType, CodeScopeSpec.Type.Model);
1249
+ assert.equal(codeSpec.scopeReq, CodeScopeSpec.ScopeRequirement.FederationGuid);
1250
+ iModelDb.saveChanges();
1251
+ iModelDb.close();
1252
+ }
1253
+ // Reopen iModel (ensure CodeSpec cache is cleared) and reconfirm CodeSpec properties
1254
+ if (true) {
1255
+ const iModelDb = SnapshotDb.openFile(iModelFileName);
1256
+ const codeSpec = iModelDb.codeSpecs.getByName(codeSpecName);
1257
+ assert.isTrue(Id64.isValidId64(codeSpec.id));
1258
+ assert.equal(codeSpec.name, codeSpecName);
1259
+ assert.equal(codeSpec.scopeType, CodeScopeSpec.Type.Model);
1260
+ assert.equal(codeSpec.scopeReq, CodeScopeSpec.ScopeRequirement.FederationGuid);
1261
+ iModelDb.close();
1262
+ }
1263
+ });
1264
+ it("snapping", async () => {
1265
+ const worldToView = Matrix4d.createIdentity();
1266
+ const response = await imodel2.requestSnap("0x222", { testPoint: { x: 1, y: 2, z: 3 }, closePoint: { x: 1, y: 2, z: 3 }, id: "0x111", worldToView: worldToView.toJSON() });
1267
+ assert.isDefined(response.status);
1268
+ });
1269
+ it("should import schemas", async () => {
1270
+ const metaData = await imodel1.schemaContext.getSchemaItem("TestBim:TestDocument", EntityClass);
1271
+ assert.isDefined(metaData);
1272
+ if (metaData !== undefined) {
1273
+ const property = await metaData.getProperty("testDocumentProperty");
1274
+ assert.isDefined(property);
1275
+ if (property !== undefined)
1276
+ assert.isDefined(property.propertyType, propertyTypeToString(PropertyType.Integer));
1277
+ }
1278
+ });
1279
+ it("should do CRUD on models", () => {
1280
+ const testImodel = imodel2;
1281
+ const [modeledElementId, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(testImodel, Code.createEmpty(), true);
1282
+ const newModelPersist = testImodel.models.getModel(newModelId);
1283
+ // Check that it has the properties that we set.
1284
+ assert.equal(newModelPersist.classFullName, PhysicalModel.classFullName);
1285
+ assert.isTrue(newModelPersist.isPrivate);
1286
+ assert.deepEqual(newModelPersist.modeledElement.id, modeledElementId);
1287
+ // Update the model
1288
+ newModelPersist.isPrivate = false;
1289
+ testImodel.models.updateModel(newModelPersist.toJSON());
1290
+ // ... and check that it updated the model in the db
1291
+ const newModelPersist2 = testImodel.models.getModel(newModelId);
1292
+ assert.isFalse(newModelPersist2.isPrivate);
1293
+ // Delete the model
1294
+ testImodel.models.deleteModel(newModelId);
1295
+ // Test insertModel error handling
1296
+ assert.throws(() => {
1297
+ testImodel.models.insertModel({
1298
+ classFullName: DefinitionModel.classFullName,
1299
+ modeledElement: { id: "0x10000000bad" },
1300
+ });
1301
+ }, IModelError);
1302
+ });
1303
+ it("should create model with custom relationship to modeled element", async () => {
1304
+ const testImodel = imodel1;
1305
+ assert.doesNotThrow(() => testImodel.schemaContext.getSchemaItemSync("TestBim:TestModelModelsElement", EntityClass), "TestModelModelsElement is expected to be defined in TestBim.ecschema.xml");
1306
+ let newModelId1;
1307
+ let newModelId2;
1308
+ let relClassName1;
1309
+ let relClassName2;
1310
+ if (true) {
1311
+ const newPartition1 = IModelTestUtils.createAndInsertPhysicalPartition(testImodel, Code.createEmpty());
1312
+ relClassName1 = "TestBim:TestModelModelsElement";
1313
+ const modeledElementRef = new RelatedElement({ id: newPartition1, relClassName: relClassName1 });
1314
+ newModelId1 = IModelTestUtils.createAndInsertPhysicalModel(testImodel, modeledElementRef);
1315
+ assert.isTrue(Id64.isValidId64(newModelId1));
1316
+ }
1317
+ if (true) {
1318
+ [, newModelId2] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(testImodel, Code.createEmpty());
1319
+ const newModel2 = testImodel.models.getModel(newModelId2);
1320
+ relClassName2 = newModel2.modeledElement.relClassName;
1321
+ }
1322
+ const model1 = testImodel.models.getModel(newModelId1);
1323
+ const model2 = testImodel.models.getModel(newModelId2);
1324
+ const foundRelClassName1 = model1.modeledElement.relClassName;
1325
+ const foundRelClassName2 = model2.modeledElement.relClassName;
1326
+ assert.equal(foundRelClassName1, relClassName1);
1327
+ assert.equal(foundRelClassName2, relClassName2);
1328
+ });
1329
+ it("should create link table relationship instances", () => {
1330
+ const snapshotFile2 = IModelTestUtils.prepareOutputFile("IModel", "CreateLinkTable.bim");
1331
+ const testImodel = StandaloneDb.createEmpty(snapshotFile2, { rootSubject: { name: "test1" }, allowEdit: JSON.stringify({ txns: true }) });
1332
+ const elements = testImodel.elements;
1333
+ // Create a new physical model
1334
+ const newModelId = PhysicalModel.insert(testImodel, IModel.rootSubjectId, "TestModel");
1335
+ // create a SpatialCategory
1336
+ const spatialCategoryId = SpatialCategory.insert(testImodel, IModel.dictionaryId, "MySpatialCategory", new SubCategoryAppearance({ color: ColorByName.darkRed }));
1337
+ // Create a couple of physical elements.
1338
+ const elementProps = {
1339
+ classFullName: PhysicalObject.classFullName,
1340
+ model: newModelId,
1341
+ category: spatialCategoryId,
1342
+ code: Code.createEmpty(),
1343
+ };
1344
+ const id0 = elements.insertElement(elementProps);
1345
+ const id1 = elements.insertElement(elementProps);
1346
+ const id2 = elements.insertElement(elementProps);
1347
+ const geometricModel = testImodel.models.getModel(newModelId);
1348
+ assert.throws(() => geometricModel.queryExtents()); // no geometry
1349
+ // Create grouping relationships from 0 to 1 and from 0 to 2
1350
+ const r1 = ElementGroupsMembers.create(testImodel, id0, id1, 1);
1351
+ r1.insert();
1352
+ const r2 = ElementGroupsMembers.create(testImodel, id0, id2);
1353
+ r2.insert();
1354
+ // Look up by id
1355
+ const g1 = ElementGroupsMembers.getInstance(testImodel, r1.id);
1356
+ const g2 = ElementGroupsMembers.getInstance(testImodel, r2.id);
1357
+ assert.deepEqual(g1.id, r1.id);
1358
+ assert.equal(g1.classFullName, ElementGroupsMembers.classFullName);
1359
+ assert.equal(g1.memberPriority, 1, "g1.memberPriority");
1360
+ assert.deepEqual(g2.id, r2.id);
1361
+ assert.equal(g2.classFullName, ElementGroupsMembers.classFullName);
1362
+ assert.equal(g2.memberPriority, 0, "g2.memberPriority"); // The memberPriority parameter defaults to 0 in ElementGroupsMembers.create
1363
+ // Look up by source and target
1364
+ const g1byst = ElementGroupsMembers.getInstance(testImodel, { sourceId: r1.sourceId, targetId: r1.targetId });
1365
+ assert.deepEqual(g1byst, g1);
1366
+ // Update relationship instance property
1367
+ r1.asAny.memberPriority = 2;
1368
+ r1.update();
1369
+ const g11 = ElementGroupsMembers.getInstance(testImodel, r1.id);
1370
+ assert.equal(g11.memberPriority, 2, "g11.memberPriority");
1371
+ testImodel.saveChanges("step 1");
1372
+ // Delete relationship instance property
1373
+ g11.delete();
1374
+ testImodel.saveChanges("step 2");
1375
+ assert.throws(() => ElementGroupsMembers.getInstance(testImodel, r1.id), IModelError);
1376
+ const d0 = elements.insertElement(elementProps);
1377
+ const d1 = elements.insertElement(elementProps);
1378
+ const ede1 = ElementDrivesElement.create(testImodel, d0, d1, 0);
1379
+ ede1.insert();
1380
+ testImodel.saveChanges("step 3");
1381
+ ede1.delete();
1382
+ testImodel.saveChanges("step 4");
1383
+ testImodel.close();
1384
+ });
1385
+ it("should insert DefinitionSets", () => {
1386
+ const iModelFileName = IModelTestUtils.prepareOutputFile("IModel", "DefinitionSets.bim");
1387
+ const iModelDb = SnapshotDb.createEmpty(iModelFileName, { rootSubject: { name: "DefinitionSets" }, createClassViews: true });
1388
+ const definitionContainerId = DefinitionContainer.insert(iModelDb, IModel.dictionaryId, Code.createEmpty());
1389
+ assert.exists(iModelDb.elements.getElement(definitionContainerId));
1390
+ assert.exists(iModelDb.models.getModel(definitionContainerId));
1391
+ const categoryId1 = SpatialCategory.insert(iModelDb, definitionContainerId, "Category1", new SubCategoryAppearance());
1392
+ const categoryId2 = SpatialCategory.insert(iModelDb, definitionContainerId, "Category2", new SubCategoryAppearance());
1393
+ const categoryId3 = SpatialCategory.insert(iModelDb, definitionContainerId, "Category3", new SubCategoryAppearance());
1394
+ const definitionGroupId = DefinitionGroup.create(iModelDb, definitionContainerId, Code.createEmpty()).insert();
1395
+ DefinitionGroupGroupsDefinitions.insert(iModelDb, definitionGroupId, categoryId1);
1396
+ DefinitionGroupGroupsDefinitions.insert(iModelDb, definitionGroupId, categoryId2);
1397
+ DefinitionGroupGroupsDefinitions.insert(iModelDb, definitionGroupId, categoryId3);
1398
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1399
+ const numMembers = iModelDb.withPreparedStatement(`SELECT COUNT(*) FROM ${DefinitionGroupGroupsDefinitions.classFullName}`, (statement) => {
1400
+ return statement.step() === DbResult.BE_SQLITE_ROW ? statement.getValue(0).getInteger() : 0;
1401
+ });
1402
+ assert.equal(numMembers, 3);
1403
+ iModelDb.saveChanges();
1404
+ iModelDb.close();
1405
+ });
1406
+ it("should set EC properties of various types", async () => {
1407
+ const testImodel = imodel1;
1408
+ assert.doesNotThrow(() => testImodel.schemaContext.getSchemaItemSync("TestBim:TestPhysicalObject", EntityClass), "TestPhysicalObject is expected to be defined in TestBim.ecschema.xml");
1409
+ // Create a new physical model
1410
+ const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(testImodel, Code.createEmpty(), true);
1411
+ // Find or create a SpatialCategory
1412
+ let spatialCategoryId = SpatialCategory.queryCategoryIdByName(testImodel, IModel.dictionaryId, "MySpatialCategory");
1413
+ if (undefined === spatialCategoryId) {
1414
+ spatialCategoryId = SpatialCategory.insert(testImodel, IModel.dictionaryId, "MySpatialCategory", new SubCategoryAppearance());
1415
+ }
1416
+ const trelClassName = "TestBim:TestPhysicalObjectRelatedToTestPhysicalObject";
1417
+ let id1;
1418
+ let id2;
1419
+ if (true) {
1420
+ // Create a couple of TestPhysicalObjects
1421
+ const elementProps = {
1422
+ classFullName: "TestBim:TestPhysicalObject",
1423
+ model: newModelId,
1424
+ category: spatialCategoryId,
1425
+ code: Code.createEmpty(),
1426
+ };
1427
+ id1 = testImodel.elements.insertElement(testImodel.elements.createElement(elementProps).toJSON());
1428
+ assert.isTrue(Id64.isValidId64(id1));
1429
+ // The second one should point to the first.
1430
+ elementProps.id = Id64.invalid;
1431
+ elementProps.relatedElement = { id: id1, relClassName: trelClassName };
1432
+ elementProps.parent = { id: id1, relClassName: trelClassName };
1433
+ elementProps.longProp = 4294967295; // make sure that we can save values in the range 0 ... UINT_MAX
1434
+ id2 = testImodel.elements.insertElement(testImodel.elements.createElement(elementProps).toJSON());
1435
+ assert.isTrue(Id64.isValidId64(id2));
1436
+ }
1437
+ if (true) {
1438
+ // Test that el2 points to el1
1439
+ const el2 = testImodel.elements.getElement(id2);
1440
+ assert.equal(el2.classFullName, "TestBim:TestPhysicalObject");
1441
+ assert.isTrue("relatedElement" in el2);
1442
+ assert.isTrue("id" in el2.asAny.relatedElement);
1443
+ assert.deepEqual(el2.asAny.relatedElement.id, id1);
1444
+ assert.equal(el2.asAny.longProp, 4294967295);
1445
+ // Even though I didn't set it, the platform knows the relationship class and reports it.
1446
+ assert.isTrue("relClassName" in el2.asAny.relatedElement);
1447
+ assert.equal(el2.asAny.relatedElement.relClassName.replace(".", ":"), trelClassName);
1448
+ }
1449
+ if (true) {
1450
+ // Change el2 to point to itself.
1451
+ const el2Modified = testImodel.elements.getElement(id2);
1452
+ el2Modified.asAny.relatedElement = { id: id2, relClassName: trelClassName };
1453
+ testImodel.elements.updateElement(el2Modified.toJSON());
1454
+ // Test that el2 points to itself.
1455
+ const el2after = testImodel.elements.getElement(id2);
1456
+ assert.deepEqual(el2after.asAny.relatedElement.id, id2);
1457
+ assert.equal(el2after.asAny.relatedElement.relClassName.replace(".", ":"), trelClassName);
1458
+ }
1459
+ if (true) {
1460
+ // Test that we can null out the navigation property
1461
+ const el2Modified = testImodel.elements.getElement(id2);
1462
+ el2Modified.asAny.relatedElement = null;
1463
+ testImodel.elements.updateElement(el2Modified.toJSON());
1464
+ // Test that el2 has no relatedElement property value
1465
+ const el2after = testImodel.elements.getElement(id2);
1466
+ assert.isUndefined(el2after.asAny.relatedElement);
1467
+ }
1468
+ });
1469
+ it("should be able to create a snapshot IModel", async () => {
1470
+ const args = {
1471
+ rootSubject: { name: "TestSubject", description: "test iTwin" },
1472
+ client: "ABC Engineering",
1473
+ globalOrigin: { x: 10, y: 10 },
1474
+ projectExtents: { low: { x: -300, y: -300, z: -20 }, high: { x: 500, y: 500, z: 400 } },
1475
+ guid: Guid.createValue(),
1476
+ };
1477
+ const iModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("IModel", "TestSnapshot.bim"), args);
1478
+ assert.equal(iModel.iModelId, args.guid);
1479
+ assert.equal(iModel.rootSubject.name, args.rootSubject.name);
1480
+ assert.equal(iModel.rootSubject.description, args.rootSubject.description);
1481
+ assert.equal(iModel.projectExtents.low.x, args.projectExtents.low.x);
1482
+ assert.equal(iModel.projectExtents.low.y, args.projectExtents.low.y);
1483
+ assert.equal(iModel.projectExtents.low.z, args.projectExtents.low.z);
1484
+ assert.equal(iModel.globalOrigin.x, args.globalOrigin.x);
1485
+ assert.equal(iModel.globalOrigin.y, args.globalOrigin.y);
1486
+ assert.equal(iModel.globalOrigin.z, 0);
1487
+ const client = iModel.queryFilePropertyString({ name: "Client", namespace: "dgn_Db" });
1488
+ assert.equal(client, args.client, "query Client property");
1489
+ const dbguid = iModel.queryFilePropertyBlob({ name: "DbGuid", namespace: "be_Db" });
1490
+ assert.equal(dbguid.byteLength, 16, "query guid property");
1491
+ const myPropsStr = { name: "MyProp", namespace: "test1", id: 1, subId: 1 };
1492
+ const myStrVal = "this is a test";
1493
+ iModel.saveFileProperty(myPropsStr, myStrVal);
1494
+ const readFromDb = iModel.queryFilePropertyString(myPropsStr);
1495
+ assert.equal(readFromDb, myStrVal, "query string after save");
1496
+ const myPropsBlob = { name: "MyBlob", namespace: "test1", id: 10 };
1497
+ const testRange = new Uint8Array(500);
1498
+ testRange.fill(11);
1499
+ iModel.saveFileProperty(myPropsBlob, undefined, testRange);
1500
+ const blobFromDb = iModel.queryFilePropertyBlob(myPropsBlob);
1501
+ assert.deepEqual(blobFromDb, testRange, "query blob after save");
1502
+ let next = iModel.queryNextAvailableFileProperty(myPropsBlob);
1503
+ assert.equal(11, next, "queryNextAvailableFileProperty blob");
1504
+ next = iModel.queryNextAvailableFileProperty(myPropsStr);
1505
+ assert.equal(2, next, "queryNextAvailableFileProperty str");
1506
+ iModel.deleteFileProperty(myPropsStr);
1507
+ assert.isUndefined(iModel.queryFilePropertyString(myPropsStr), "property was deleted");
1508
+ next = iModel.queryNextAvailableFileProperty(myPropsStr);
1509
+ assert.equal(0, next, "queryNextAvailableFileProperty, should return 0 when none present");
1510
+ const testLocal = "TestLocal";
1511
+ const testValue = "this is a test";
1512
+ const nativeDb = iModel[_nativeDb];
1513
+ assert.isUndefined(nativeDb.queryLocalValue(testLocal));
1514
+ nativeDb.saveLocalValue(testLocal, testValue);
1515
+ assert.equal(nativeDb.queryLocalValue(testLocal), testValue);
1516
+ iModel.close();
1517
+ });
1518
+ it("should be able to create a snapshot IModel and set geolocation by GCS", async () => {
1519
+ const args = {
1520
+ rootSubject: { name: "TestSubject", description: "test iTwin" },
1521
+ client: "ABC Engineering",
1522
+ globalOrigin: { x: 10, y: 10 },
1523
+ projectExtents: { low: { x: -300, y: -300, z: -20 }, high: { x: 500, y: 500, z: 400 } },
1524
+ guid: Guid.createValue(),
1525
+ };
1526
+ const gcs = new GeographicCRS({
1527
+ horizontalCRS: {
1528
+ id: "10TM115-27",
1529
+ description: "",
1530
+ source: "Mentor Software Client",
1531
+ deprecated: false,
1532
+ datumId: "NAD27",
1533
+ unit: "Meter",
1534
+ projection: {
1535
+ method: "TransverseMercator",
1536
+ centralMeridian: -115,
1537
+ latitudeOfOrigin: 0,
1538
+ scaleFactor: 0.9992,
1539
+ falseEasting: 0.0,
1540
+ falseNorthing: 0.0,
1541
+ },
1542
+ extent: {
1543
+ southWest: { latitude: 48, longitude: -120.5 },
1544
+ northEast: { latitude: 84, longitude: -109.5 },
1545
+ },
1546
+ },
1547
+ verticalCRS: { id: "GEOID" },
1548
+ additionalTransform: {
1549
+ helmert2DWithZOffset: {
1550
+ translationX: 10.0,
1551
+ translationY: 15.0,
1552
+ translationZ: 0.02,
1553
+ rotDeg: 1.2,
1554
+ scale: 1.0001,
1555
+ },
1556
+ },
1557
+ });
1558
+ const testFile = IModelTestUtils.prepareOutputFile("IModel", "TestSnapshot2.bim");
1559
+ const iModel = SnapshotDb.createEmpty(testFile, args);
1560
+ let eventListenedTo = false;
1561
+ const gcsListener = (previousGCS) => {
1562
+ assert.equal(previousGCS, undefined);
1563
+ assert.isTrue(iModel.geographicCoordinateSystem !== undefined);
1564
+ assert.isTrue(iModel.geographicCoordinateSystem.equals(gcs));
1565
+ eventListenedTo = true;
1566
+ };
1567
+ iModel.onGeographicCoordinateSystemChanged.addListener(gcsListener);
1568
+ assert.isTrue(iModel.geographicCoordinateSystem === undefined);
1569
+ assert.isFalse(eventListenedTo);
1570
+ iModel.geographicCoordinateSystem = gcs;
1571
+ assert.isTrue(eventListenedTo);
1572
+ iModel.updateIModelProps();
1573
+ iModel.saveChanges();
1574
+ iModel.close();
1575
+ const iModel2 = SnapshotDb.openFile(testFile);
1576
+ assert.isTrue(iModel2.geographicCoordinateSystem !== undefined);
1577
+ // The reloaded gcs will be different as the datum definition will have been expanded
1578
+ assert.isFalse(iModel2.geographicCoordinateSystem.equals(gcs));
1579
+ // But other properties will be identical
1580
+ assert.isTrue(iModel2.geographicCoordinateSystem !== undefined);
1581
+ assert.isTrue(iModel2.geographicCoordinateSystem.verticalCRS !== undefined);
1582
+ assert.isTrue(iModel2.geographicCoordinateSystem.verticalCRS.equals(gcs.verticalCRS));
1583
+ assert.isTrue(iModel2.geographicCoordinateSystem.additionalTransform !== undefined);
1584
+ assert.isTrue(iModel2.geographicCoordinateSystem.additionalTransform.equals(gcs.additionalTransform));
1585
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS !== undefined);
1586
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.projection !== undefined);
1587
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.projection.equals(gcs.horizontalCRS.projection));
1588
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.id !== undefined);
1589
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.id === gcs.horizontalCRS.id);
1590
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.extent !== undefined);
1591
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.extent.equals(gcs.horizontalCRS.extent));
1592
+ // The following were not in initial definition but were completed after storage.
1593
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.datum !== undefined);
1594
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.datum.additionalTransformPaths !== undefined);
1595
+ assert.isTrue(iModel2.geographicCoordinateSystem.horizontalCRS.datum.additionalTransformPaths.length >= 0);
1596
+ // When a gcs is present then the ECEF is automatically defined.
1597
+ assert.isTrue(iModel2.ecefLocation !== undefined);
1598
+ iModel2.close();
1599
+ });
1600
+ if (!ProcessDetector.isIOSAppBackend) {
1601
+ it("should be able to reproject with iModel coordinates to or from any other GeographicCRS", async () => {
1602
+ const convertTest = async (fileName, fileGCS, datum, inputCoord, outputCoord) => {
1603
+ const args = {
1604
+ rootSubject: { name: "TestSubject", description: "test project" },
1605
+ client: "ABC Engineering",
1606
+ globalOrigin: { x: 0.0, y: 0.0 },
1607
+ projectExtents: { low: { x: -300, y: -300, z: -20 }, high: { x: 500, y: 500, z: 400 } },
1608
+ guid: Guid.createValue(),
1609
+ };
1610
+ let datumOrGCS;
1611
+ if (typeof datum === "object")
1612
+ datumOrGCS = JSON.stringify(datum);
1613
+ else
1614
+ datumOrGCS = datum;
1615
+ const testFile = IModelTestUtils.prepareOutputFile("IModel", fileName);
1616
+ const iModel = SnapshotDb.createEmpty(testFile, args);
1617
+ iModel.setGeographicCoordinateSystem(fileGCS);
1618
+ iModel.updateIModelProps();
1619
+ iModel.saveChanges();
1620
+ const testPoint1 = [];
1621
+ testPoint1.push(inputCoord);
1622
+ const requestProps1 = { target: datumOrGCS, iModelCoords: testPoint1 };
1623
+ const response1 = await iModel.getGeoCoordinatesFromIModelCoordinates(requestProps1);
1624
+ expect(response1.geoCoords[0].s === outputCoord.s).to.be.true;
1625
+ // If success or warning we compare result
1626
+ if (outputCoord.s === GeoCoordStatus.Success || outputCoord.s === GeoCoordStatus.OutOfUsefulRange) {
1627
+ const expectedPt1 = Point3d.fromJSON(outputCoord.p);
1628
+ const outPt1 = Point3d.fromJSON(response1.geoCoords[0].p);
1629
+ expect(Geometry.isSamePoint3dXY(expectedPt1, outPt1)).to.be.true;
1630
+ expect(Math.abs(expectedPt1.z - outPt1.z) < 0.0001).to.be.true;
1631
+ // No point testing reversal when Out of useful range since reversibility is doubtful
1632
+ if (outputCoord.s !== GeoCoordStatus.OutOfUsefulRange) {
1633
+ const testPoint2 = [];
1634
+ testPoint2.push(outputCoord.p);
1635
+ const requestProps2 = { source: datumOrGCS, geoCoords: testPoint2 };
1636
+ const response2 = await iModel.getIModelCoordinatesFromGeoCoordinates(requestProps2);
1637
+ const expectedPt2 = Point3d.fromJSON(inputCoord);
1638
+ const outPt2 = Point3d.fromJSON(response2.iModelCoords[0].p);
1639
+ expect(expectedPt2.distanceXY(outPt2) < 0.001).to.be.true;
1640
+ expect(Math.abs(expectedPt2.z - outPt2.z) < 0.001).to.be.true;
1641
+ }
1642
+ }
1643
+ iModel.close();
1644
+ };
1645
+ const EWRGCS = {
1646
+ horizontalCRS: {
1647
+ id: "EPSG:27700",
1648
+ description: "OSGB 1936 / British National Grid",
1649
+ source: "EPSG V6 [Large and medium scale topographic mapping and engin]",
1650
+ datumId: "EPSG:6277",
1651
+ datum: {
1652
+ id: "EPSG:6277",
1653
+ description: "OSGB36 - Use OSGB-7P-2. Consider OSGB/OSTN15 instead",
1654
+ deprecated: true,
1655
+ source: "EPSG V6.12 operation EPSG:1314 [EPSG]",
1656
+ ellipsoidId: "EPSG:7001",
1657
+ ellipsoid: {
1658
+ equatorialRadius: 6377563.396,
1659
+ polarRadius: 6356256.909237,
1660
+ id: "EPSG:7001",
1661
+ description: "Airy 1830",
1662
+ source: "EPSG, Version 6 [EPSG]",
1663
+ },
1664
+ transforms: [
1665
+ {
1666
+ method: "PositionalVector",
1667
+ sourceEllipsoid: {
1668
+ equatorialRadius: 6377563.396,
1669
+ polarRadius: 6356256.909237,
1670
+ id: "EPSG:7001",
1671
+ },
1672
+ targetEllipsoid: {
1673
+ equatorialRadius: 6378137,
1674
+ polarRadius: 6356752.3142,
1675
+ id: "WGS84",
1676
+ },
1677
+ positionalVector: {
1678
+ delta: {
1679
+ x: 446.448,
1680
+ y: -125.157,
1681
+ z: 542.06,
1682
+ },
1683
+ rotation: {
1684
+ x: 0.15,
1685
+ y: 0.247,
1686
+ z: 0.842,
1687
+ },
1688
+ scalePPM: -20.489,
1689
+ },
1690
+ }
1691
+ ],
1692
+ },
1693
+ unit: "Meter",
1694
+ projection: {
1695
+ method: "TransverseMercator",
1696
+ falseEasting: 400000,
1697
+ falseNorthing: -100000,
1698
+ centralMeridian: -2,
1699
+ latitudeOfOrigin: 49,
1700
+ scaleFactor: 0.999601272737422,
1701
+ },
1702
+ extent: {
1703
+ southWest: {
1704
+ latitude: 49.96,
1705
+ longitude: -7.56,
1706
+ },
1707
+ northEast: {
1708
+ latitude: 60.84,
1709
+ longitude: 1.78,
1710
+ },
1711
+ },
1712
+ },
1713
+ verticalCRS: {
1714
+ id: "ELLIPSOID",
1715
+ },
1716
+ additionalTransform: {
1717
+ helmert2DWithZOffset: {
1718
+ translationX: 284597.3343,
1719
+ translationY: 79859.4651,
1720
+ translationZ: 0,
1721
+ rotDeg: 0.5263624458992088,
1722
+ scale: 0.9996703340508721,
1723
+ },
1724
+ },
1725
+ };
1726
+ await convertTest("ExtonCampus1.bim", { horizontalCRS: { id: "EPSG:2272" }, verticalCRS: { id: "NAVD88" } }, "WGS84", { x: 775970.3155166894, y: 83323.24543981979, z: 130.74977547686285 }, { p: { x: -75.68712011112366, y: 40.06524845273591, z: 95.9769083 }, s: GeoCoordStatus.Success });
1727
+ await convertTest("UTM83-10-NGVD29-10.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NAVD88" } }, { horizontalCRS: { id: "UTM27-10" }, verticalCRS: { id: "NGVD29" } }, { x: 548296.472, y: 4179414.470, z: 0.8457 }, { p: { x: 548392.9689991799, y: 4179217.683834238, z: -0.0006774162750405877 }, s: GeoCoordStatus.Success });
1728
+ await convertTest("BritishNatGrid-EllipsoidHelmert1.bim", EWRGCS, "WGS84", { x: 199247.08883859176, y: 150141.68625139236, z: 0.0 }, { p: { x: -0.80184489371471, y: 51.978341907041205, z: 0.0 }, s: GeoCoordStatus.Success });
1729
+ await convertTest("BritishNatGrid-Ellipsoid1.bim", { horizontalCRS: { id: "BritishNatGrid" }, verticalCRS: { id: "ELLIPSOID" } }, "", { x: 170370.718, y: 11572.405, z: 0.0 }, { p: { x: -5.2020119082059511, y: 49.959453295440234, z: 0.0 }, s: GeoCoordStatus.Success });
1730
+ await convertTest("BritishNatGrid-Ellipsoid2.bim", { horizontalCRS: { id: "BritishNatGrid" }, verticalCRS: { id: "ELLIPSOID" } }, "ETRF89", { x: 170370.718, y: 11572.405, z: 0.0 }, { p: { x: -5.2030365061523707, y: 49.960007477936202, z: 0.0 }, s: GeoCoordStatus.Success });
1731
+ await convertTest("BritishNatGrid-Ellipsoid3.bim", { horizontalCRS: { id: "BritishNatGrid" }, verticalCRS: { id: "ELLIPSOID" } }, "OSGB", { x: 170370.718, y: 11572.405, z: 0.0 }, { p: { x: -5.2020119082059511, y: 49.959453295440234, z: 0.0 }, s: GeoCoordStatus.Success });
1732
+ await convertTest("GermanyDHDN-3-Ellipsoid1.bim", { horizontalCRS: { id: "DHDN/3.GK3d-4/EN" }, verticalCRS: { id: "ELLIPSOID" } }, "", { x: 4360857.005, y: 5606083.067, z: 0.0 }, { p: { x: 10.035413954488630, y: 50.575070810112159, z: 0.0 }, s: GeoCoordStatus.Success });
1733
+ await convertTest("GermanyDHDN-3-Ellipsoid2.bim", { horizontalCRS: { id: "DHDN/3.GK3d-4/EN" }, verticalCRS: { id: "ELLIPSOID" } }, "DHDN/3", { x: 4360857.005, y: 5606083.067, z: 0.0 }, { p: { x: 10.035413954488630, y: 50.575070810112159, z: 0.0 }, s: GeoCoordStatus.Success });
1734
+ await convertTest("GermanyDHDN-3-Ellipsoid3.bim", { horizontalCRS: { id: "DHDN/3.GK3d-4/EN" }, verticalCRS: { id: "ELLIPSOID" } }, "WGS84", { x: 4360857.005, y: 5606083.067, z: 0.0 }, { p: { x: 10.034215937440818, y: 50.573862480894853, z: 0.0 }, s: GeoCoordStatus.Success });
1735
+ await convertTest("UTM83-10-NGVD29-1.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, "", { x: 632748.112, y: 4263868.307, z: 0.0 }, { p: { x: -121.47738265889652, y: 38.513305313793019, z: 0.0 }, s: GeoCoordStatus.Success });
1736
+ await convertTest("UTM83-10-NGVD29-2.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, "NAD83", { x: 632748.112, y: 4263868.307, z: 0.0 }, { p: { x: -121.47738265889652, y: 38.513305313793019, z: -30.12668428839329 }, s: GeoCoordStatus.Success });
1737
+ await convertTest("UTM83-10-NGVD29-3.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, "WGS84", { x: 632748.112, y: 4263868.307, z: 0.0 }, { p: { x: -121.47738265889652, y: 38.513305313793019, z: -30.12668428839329 }, s: GeoCoordStatus.Success });
1738
+ await convertTest("UTM27-10-Ellipsoid1.bim", { horizontalCRS: { id: "UTM27-10" }, verticalCRS: { id: "ELLIPSOID" } }, "", { x: 623075.328, y: 4265650.532, z: 0.0 }, { p: { x: -121.58798236995744, y: 38.532616292207997, z: 0.0 }, s: GeoCoordStatus.Success });
1739
+ await convertTest("UTM27-10-Ellipsoid2.bim", { horizontalCRS: { id: "UTM27-10" }, verticalCRS: { id: "ELLIPSOID" } }, "NAD83", { x: 623075.328, y: 4265650.532, z: 0.0 }, { p: { x: -121.58905088839697, y: 38.532522753851708, z: 0.0 }, s: GeoCoordStatus.Success });
1740
+ await convertTest("UTM83-10-NGVD29-4.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, { horizontalCRS: { id: "LL84" }, verticalCRS: { id: "ELLIPSOID" } }, { x: 632748.112, y: 4263868.307, z: 0.0 }, { p: { x: -121.47738265889652, y: 38.513305313793019, z: -30.12668428839329 }, s: GeoCoordStatus.Success });
1741
+ await convertTest("UTM83-10-NGVD29-5.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, { horizontalCRS: { id: "LL84" }, verticalCRS: { id: "GEOID" } }, { x: 632748.112, y: 4263868.307, z: 0.0 }, { p: { x: -121.47738265889652, y: 38.513305313793019, z: 0.7621583779125531 }, s: GeoCoordStatus.Success });
1742
+ await convertTest("UTM83-10-NGVD29-6.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, { horizontalCRS: { id: "CA83-II" }, verticalCRS: { id: "NAVD88" } }, { x: 569024.940, y: 4386341.752, z: 0.0 }, { p: { x: 1983192.529823256, y: 717304.0311293667, z: 0.745910484422781 }, s: GeoCoordStatus.Success });
1743
+ await convertTest("UTM83-10-NGVD29-7.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, { horizontalCRS: { id: "CA83-II" }, verticalCRS: { id: "GEOID" } }, { x: 569024.940, y: 4386341.752, z: 0.0 }, { p: { x: 1983192.529823256, y: 717304.0311293667, z: 0.745910484422781 }, s: GeoCoordStatus.Success });
1744
+ await convertTest("UTM83-10-NGVD29-8.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, { horizontalCRS: { id: "CA83-II" }, verticalCRS: { id: "NGVD29" } }, { x: 569024.940, y: 4386341.752, z: 0.0 }, { p: { x: 1983192.529823256, y: 717304.0311293667, z: 0.0 }, s: GeoCoordStatus.Success });
1745
+ await convertTest("UTM83-10-NGVD29-9.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, { horizontalCRS: { epsg: 26942 }, verticalCRS: { id: "NAVD88" } }, { x: 569024.940, y: 4386341.752, z: 0.0 }, { p: { x: 1983192.529823256, y: 717304.0311293667, z: 0.745910484422781 }, s: GeoCoordStatus.Success });
1746
+ await convertTest("UTM83-10-NGVD29-10.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NAVD88" } }, { horizontalCRS: { id: "UTM27-10" }, verticalCRS: { id: "NGVD29" } }, { x: 548296.472, y: 4179414.470, z: 0.8457 }, { p: { x: 548392.9689991799, y: 4179217.683834238, z: -0.0006774162750405877 }, s: GeoCoordStatus.Success });
1747
+ await convertTest("BritishNatGrid-Ellipsoid4.bim", { horizontalCRS: { id: "BritishNatGrid" }, verticalCRS: { id: "ELLIPSOID" } }, { horizontalCRS: { id: "HS2_Snake_2015" }, verticalCRS: { id: "GEOID" } }, { x: 473327.251, y: 257049.636, z: 0.0 }, { p: { x: 237732.58101946692, y: 364048.01547843055, z: -47.874172425966336 }, s: GeoCoordStatus.Success });
1748
+ await convertTest("BritishNatGrid-Ellipsoid5.bim", { horizontalCRS: { id: "BritishNatGrid" }, verticalCRS: { id: "ELLIPSOID" } }, {
1749
+ horizontalCRS: {
1750
+ id: "HS2-MOCK",
1751
+ description: "USES CUSTOM DATUM",
1752
+ source: "Test",
1753
+ deprecated: false,
1754
+ datumId: "HS2SD_2015",
1755
+ unit: "Meter",
1756
+ projection: {
1757
+ method: "TransverseMercator",
1758
+ centralMeridian: -1.5,
1759
+ latitudeOfOrigin: 52.30,
1760
+ scaleFactor: 1.0,
1761
+ falseEasting: 198873.0046,
1762
+ falseNorthing: 375064.3871,
1763
+ },
1764
+ },
1765
+ verticalCRS: {
1766
+ id: "GEOID",
1767
+ },
1768
+ }, { x: 473327.251, y: 257049.636, z: 0.0 }, { p: { x: 237732.58101952373, y: 364048.01548327296, z: -47.874172425966336 }, s: GeoCoordStatus.Success });
1769
+ await convertTest("BritishNatGrid-Ellipsoid.bim", { horizontalCRS: { id: "BritishNatGrid" }, verticalCRS: { id: "ELLIPSOID" } }, { horizontalCRS: { id: "OSGB-GPS-2015" }, verticalCRS: { id: "GEOID" } }, { x: 473327.251, y: 257049.636, z: 0.0 }, { p: { x: 473325.6830048648, y: 257049.77062273448, z: -47.87643904264457 }, s: GeoCoordStatus.Success });
1770
+ await convertTest("UTM83-10-NGVD29-12.bim", { horizontalCRS: { id: "UTM83-10" }, verticalCRS: { id: "NGVD29" } }, {
1771
+ horizontalCRS: {
1772
+ id: "California2",
1773
+ description: "USES CUSTOM DATUM",
1774
+ source: "Test",
1775
+ deprecated: false,
1776
+ datumId: "NAD83",
1777
+ unit: "Meter",
1778
+ projection: {
1779
+ method: "LambertConformalConicTwoParallels",
1780
+ longitudeOfOrigin: -122,
1781
+ latitudeOfOrigin: 37.66666666667,
1782
+ standardParallel1: 39.833333333333336,
1783
+ standardParallel2: 38.333333333333336,
1784
+ falseEasting: 2000000.0,
1785
+ falseNorthing: 500000.0,
1786
+ },
1787
+ extent: {
1788
+ southWest: {
1789
+ latitude: 35,
1790
+ longitude: -125,
1791
+ },
1792
+ northEast: {
1793
+ latitude: 39.1,
1794
+ longitude: -120.45,
1795
+ },
1796
+ },
1797
+ },
1798
+ verticalCRS: {
1799
+ id: "GEOID",
1800
+ },
1801
+ }, { x: 569024.940, y: 4386341.752, z: 0.0 }, { p: { x: 1983192.529823256, y: 717304.0311293667, z: 0.745910484422781 }, s: GeoCoordStatus.Success });
1802
+ // Do some test that return errors
1803
+ // First test uses one GCS in Eastern USA and the other in UK. This will produce a hard domain error
1804
+ await convertTest("Error1.bim", { horizontalCRS: { id: "UTM84-17N" }, verticalCRS: { id: "ELLIPSOID" } }, { horizontalCRS: { id: "OSGB-GPS-2015" }, verticalCRS: { id: "GEOID" } }, { x: 1473327.251, y: 1257049.636, z: 0.0 }, { p: { x: 473325.6830048648, y: 257049.77062273448, z: -47.87643904264457 }, s: GeoCoordStatus.OutOfMathematicalDomain });
1805
+ // This test performs conversion in a region outside normal use of GCS but still mathematically valid (soft domain error)
1806
+ await convertTest("Error2.bim", { horizontalCRS: { id: "DanishS34-S99" }, verticalCRS: { id: "ELLIPSOID" } }, "", { x: -6618.5925260757449, y: 36058.097489683532, z: 0.0 }, { p: { x: 13.53250346041385, y: 54.71216475341563, z: 0.0 }, s: GeoCoordStatus.OutOfUsefulRange });
1807
+ // -6618.5925260757449, 36058.097489683532
1808
+ // { x: -221748.034, y: -10012.784, z: 0.0 } { p: { x: 10.36481105, y: 54.38462506, z: 0.0 }
1809
+ // This test makes use of a GCS using a grid file that does not even exist and will return a datum conversion error.
1810
+ const userGCSWithinexistentGridFile = {
1811
+ horizontalCRS: {
1812
+ id: "User1",
1813
+ datumId: "UserDatum1",
1814
+ datum: {
1815
+ id: "UserDatum1",
1816
+ ellipsoidId: "CLRK66",
1817
+ transforms: [
1818
+ {
1819
+ method: "GridFiles",
1820
+ sourceEllipsoid: {
1821
+ id: "CLRK66",
1822
+ equatorialRadius: 6378160.0,
1823
+ polarRadius: 6356774.719195306,
1824
+ },
1825
+ targetEllipsoid: {
1826
+ id: "WGS84",
1827
+ equatorialRadius: 6378160.0,
1828
+ polarRadius: 6356774.719195306,
1829
+ },
1830
+ gridFile: {
1831
+ files: [
1832
+ { fileName: "./user/inexistent.gdc", format: "NTv2", direction: "Direct" },
1833
+ ],
1834
+ },
1835
+ },
1836
+ ],
1837
+ },
1838
+ unit: "Meter",
1839
+ projection: {
1840
+ method: "TransverseMercator",
1841
+ centralMeridian: -115,
1842
+ latitudeOfOrigin: 0,
1843
+ scaleFactor: 0.9992,
1844
+ falseEasting: 1.0,
1845
+ falseNorthing: 2.0,
1846
+ },
1847
+ extent: {
1848
+ southWest: { latitude: 48, longitude: -120.5 },
1849
+ northEast: { latitude: 84, longitude: -109.5 },
1850
+ },
1851
+ }, verticalCRS: { id: "ELLIPSOID" },
1852
+ };
1853
+ await convertTest("Error3.bim", userGCSWithinexistentGridFile, "WGS84", { x: 1473327.251, y: 1257049.636, z: 0.0 }, { p: { x: 473325.6830048648, y: 257049.77062273448, z: -47.87643904264457 }, s: GeoCoordStatus.NoDatumConverter });
1854
+ // The model GCS is not valid
1855
+ await convertTest("Error4.bim", { horizontalCRS: { id: "badfood" }, verticalCRS: { id: "ELLIPSOID" } }, { horizontalCRS: { id: "OSGB-GPS-2015" }, verticalCRS: { id: "GEOID" } }, { x: 1473327.251, y: 1257049.636, z: 0.0 }, { p: { x: 473325.6830048648, y: 257049.77062273448, z: -47.87643904264457 }, s: GeoCoordStatus.NoGCSDefined });
1856
+ // The given GCS is not valid
1857
+ await convertTest("Error5.bim", { horizontalCRS: { id: "UTM84-17N" }, verticalCRS: { id: "ELLIPSOID" } }, { horizontalCRS: { id: "badfood" }, verticalCRS: { id: "GEOID" } }, { x: 1473327.251, y: 1257049.636, z: 0.0 }, { p: { x: 473325.6830048648, y: 257049.77062273448, z: -47.87643904264457 }, s: GeoCoordStatus.NoGCSDefined });
1858
+ });
1859
+ }
1860
+ it("should be able to create a snapshot IModel and set geolocation by ECEF", async () => {
1861
+ const args = {
1862
+ rootSubject: { name: "TestSubject", description: "test iTwin" },
1863
+ client: "ABC Engineering",
1864
+ globalOrigin: { x: 10, y: 10 },
1865
+ projectExtents: { low: { x: -300, y: -300, z: -20 }, high: { x: 500, y: 500, z: 400 } },
1866
+ guid: Guid.createValue(),
1867
+ };
1868
+ const ecef = new EcefLocation({
1869
+ origin: [42, 21, 0],
1870
+ orientation: { yaw: 1, pitch: 1, roll: -1 },
1871
+ });
1872
+ const testFile = IModelTestUtils.prepareOutputFile("IModel", "TestSnapshot3.bim");
1873
+ const iModel = SnapshotDb.createEmpty(testFile, args);
1874
+ assert.isTrue(iModel.ecefLocation === undefined);
1875
+ iModel.ecefLocation = ecef;
1876
+ iModel.updateIModelProps();
1877
+ iModel.saveChanges();
1878
+ iModel.close();
1879
+ const iModel2 = SnapshotDb.openFile(testFile);
1880
+ assert.isTrue(iModel2.ecefLocation !== undefined);
1881
+ assert.isTrue(iModel2.ecefLocation.isAlmostEqual(ecef));
1882
+ iModel2.close();
1883
+ });
1884
+ it("should be able to create a snapshot IModel and set geolocation by ECEF with 0,0,0 rotation", async () => {
1885
+ const args = {
1886
+ rootSubject: { name: "TestSubject", description: "test iTwin" },
1887
+ client: "ABC Engineering",
1888
+ globalOrigin: { x: 10, y: 10 },
1889
+ projectExtents: { low: { x: -300, y: -300, z: -20 }, high: { x: 500, y: 500, z: 400 } },
1890
+ guid: Guid.createValue(),
1891
+ };
1892
+ const ecef = new EcefLocation({
1893
+ origin: [42, 21, 0],
1894
+ orientation: { yaw: 0, pitch: 0, roll: 0 },
1895
+ });
1896
+ const testFile = IModelTestUtils.prepareOutputFile("IModel", "TestSnapshot3_000.bim");
1897
+ const iModel = SnapshotDb.createEmpty(testFile, args);
1898
+ assert.isTrue(iModel.ecefLocation === undefined);
1899
+ iModel.ecefLocation = ecef;
1900
+ iModel.updateIModelProps();
1901
+ iModel.saveChanges();
1902
+ iModel.close();
1903
+ const iModel2 = SnapshotDb.openFile(testFile);
1904
+ assert.isTrue(iModel2.ecefLocation !== undefined);
1905
+ assert.isTrue(iModel2.ecefLocation.isAlmostEqual(ecef));
1906
+ iModel2.close();
1907
+ });
1908
+ it("presence of a GCS imposes the ecef value", async () => {
1909
+ const args = {
1910
+ rootSubject: { name: "TestSubject", description: "test iTwin" },
1911
+ client: "ABC Engineering",
1912
+ globalOrigin: { x: 10, y: 10 },
1913
+ projectExtents: { low: { x: -300, y: -300, z: -20 }, high: { x: 500, y: 500, z: 400 } },
1914
+ guid: Guid.createValue(),
1915
+ };
1916
+ const gcs = new GeographicCRS({
1917
+ horizontalCRS: {
1918
+ id: "10TM115-27",
1919
+ description: "",
1920
+ source: "Mentor Software Client",
1921
+ deprecated: false,
1922
+ datumId: "NAD27",
1923
+ unit: "Meter",
1924
+ projection: {
1925
+ method: "TransverseMercator",
1926
+ centralMeridian: -115,
1927
+ latitudeOfOrigin: 0,
1928
+ scaleFactor: 0.9992,
1929
+ falseEasting: 0.0,
1930
+ falseNorthing: 0.0,
1931
+ },
1932
+ extent: {
1933
+ southWest: { latitude: 48, longitude: -120.5 },
1934
+ northEast: { latitude: 84, longitude: -109.5 },
1935
+ },
1936
+ },
1937
+ verticalCRS: { id: "GEOID" },
1938
+ additionalTransform: {
1939
+ helmert2DWithZOffset: {
1940
+ translationX: 10.0,
1941
+ translationY: 15.0,
1942
+ translationZ: 0.02,
1943
+ rotDeg: 1.2,
1944
+ scale: 1.0001,
1945
+ },
1946
+ },
1947
+ });
1948
+ const ecef = new EcefLocation({
1949
+ origin: [42, 21, 0],
1950
+ orientation: { yaw: 1, pitch: 1, roll: -1 },
1951
+ });
1952
+ const testFile = IModelTestUtils.prepareOutputFile("IModel", "TestSnapshot4.bim");
1953
+ const iModel = SnapshotDb.createEmpty(testFile, args);
1954
+ iModel.ecefLocation = ecef;
1955
+ iModel.updateIModelProps();
1956
+ iModel.saveChanges();
1957
+ iModel.close();
1958
+ const iModel2 = SnapshotDb.openForApplyChangesets(testFile);
1959
+ assert.isTrue(iModel2.ecefLocation !== undefined);
1960
+ assert.isTrue(iModel2.ecefLocation.isAlmostEqual(ecef));
1961
+ assert.isTrue(iModel2.geographicCoordinateSystem === undefined);
1962
+ iModel2.geographicCoordinateSystem = gcs;
1963
+ iModel2.updateIModelProps();
1964
+ iModel2.saveChanges();
1965
+ iModel2.close();
1966
+ const iModel3 = SnapshotDb.openFile(testFile);
1967
+ assert.isTrue(iModel3.geographicCoordinateSystem !== undefined);
1968
+ // When a gcs is present then ecef value is imposed by the gcs disregarding previous value.
1969
+ assert.isTrue(iModel3.ecefLocation !== undefined);
1970
+ assert.isFalse(iModel3.ecefLocation.isAlmostEqual(ecef));
1971
+ iModel3.close();
1972
+ });
1973
+ it("should be able to open checkpoints for RPC", async () => {
1974
+ const changeset = { id: "fakeChangeSetId", index: 10 };
1975
+ const iTwinId = "fakeIModelId";
1976
+ const iModelId = "fakeIModelId";
1977
+ const cloudContainer = { accessToken: "sas" };
1978
+ const fakeSnapshotDb = {
1979
+ cloudContainer,
1980
+ isReadonly: () => true,
1981
+ isOpen: () => true,
1982
+ getIModelId: () => iModelId,
1983
+ getITwinId: () => iTwinId,
1984
+ getCurrentChangeset: () => changeset,
1985
+ setIModelDb: () => { },
1986
+ closeFile: () => { },
1987
+ };
1988
+ const errorLogStub = sinon.stub(Logger, "logError").callsFake(() => { });
1989
+ const infoLogStub = sinon.stub(Logger, "logInfo").callsFake(() => { });
1990
+ // Mock iModelHub
1991
+ const mockCheckpointV2 = {
1992
+ accountName: "testAccount",
1993
+ containerId: "imodelblocks-123",
1994
+ sasToken: "testSAS",
1995
+ dbName: "testDb",
1996
+ storageType: "azure?sas=1",
1997
+ };
1998
+ sinon.stub(IModelHost, _hubAccess).get(() => HubMock);
1999
+ sinon.stub(V2CheckpointManager, "attach").callsFake(async () => {
2000
+ return { dbName: "fakeDb", container: { accessToken: "sas" } };
2001
+ });
2002
+ const queryStub = sinon.stub(IModelHost[_hubAccess], "queryV2Checkpoint").callsFake(async () => mockCheckpointV2);
2003
+ const openDgnDbStub = sinon.stub(SnapshotDb, "openDgnDb").returns(fakeSnapshotDb);
2004
+ sinon.stub(IModelDb.prototype, "initializeIModelDb");
2005
+ sinon.stub(IModelDb.prototype, "loadIModelSettings");
2006
+ const accessToken = "token";
2007
+ const checkpoint = await SnapshotDb.openCheckpointFromRpc({ accessToken, iTwinId, iModelId, changeset });
2008
+ expect(openDgnDbStub.calledOnce).to.be.true;
2009
+ expect(openDgnDbStub.firstCall.firstArg.path).to.equal("fakeDb");
2010
+ const props = checkpoint.getRpcProps();
2011
+ assert.equal(props.iModelId, iModelId);
2012
+ assert.equal(props.iTwinId, iTwinId);
2013
+ assert.equal(props.changeset?.id, changeset.id);
2014
+ assert.equal(errorLogStub.callCount, 1);
2015
+ assert.include(errorLogStub.args[0][1], "attached with timestamp that expires before");
2016
+ errorLogStub.resetHistory();
2017
+ expect(cloudContainer.accessToken).equal("sas");
2018
+ await checkpoint.refreshContainerForRpc(accessToken);
2019
+ expect(cloudContainer.accessToken).equal("testSAS");
2020
+ assert.equal(errorLogStub.callCount, 1);
2021
+ assert.include(errorLogStub.args[0][1], "attached with timestamp that expires before");
2022
+ assert.equal(infoLogStub.callCount, 2);
2023
+ assert.include(infoLogStub.args[0][1], "attempting to refresh");
2024
+ assert.include(infoLogStub.args[1][1], "refreshed checkpoint");
2025
+ errorLogStub.resetHistory();
2026
+ queryStub.callsFake(async () => {
2027
+ throw new Error("no checkpoint");
2028
+ });
2029
+ await expect(checkpoint.refreshContainerForRpc(accessToken)).to.eventually.be.rejectedWith("no checkpoint");
2030
+ checkpoint.close();
2031
+ });
2032
+ it("should throw for missing/invalid checkpoint in hub", async () => {
2033
+ process.env.CHECKPOINT_CACHE_DIR = "/foo/";
2034
+ sinon.stub(IModelHost, _hubAccess).get(() => HubMock);
2035
+ sinon.stub(IModelHost[_hubAccess], "queryV2Checkpoint").callsFake(async () => undefined);
2036
+ const accessToken = "token";
2037
+ const error = await getIModelError(SnapshotDb.openCheckpointFromRpc({ accessToken, iTwinId: Guid.createValue(), iModelId: Guid.createValue(), changeset: IModelTestUtils.generateChangeSetId() }));
2038
+ expectIModelError(IModelStatus.NotFound, error);
2039
+ });
2040
+ it("attempting to re-attach a non-checkpoint snapshot should be a no-op", async () => {
2041
+ process.env.CHECKPOINT_CACHE_DIR = "/foo/";
2042
+ const accessToken = "token";
2043
+ await imodel1.refreshContainerForRpc(accessToken);
2044
+ });
2045
+ function hasClassView(db, name) {
2046
+ try {
2047
+ return db.withSqliteStatement(`SELECT ECInstanceId FROM [${name}]`, () => true, false);
2048
+ }
2049
+ catch {
2050
+ return false;
2051
+ }
2052
+ }
2053
+ it("Check busyTimeout option", () => {
2054
+ const standaloneFile = IModelTestUtils.prepareOutputFile("IModel", "StandaloneReadWrite.bim");
2055
+ const tryOpen = (fileName, options) => {
2056
+ const start = performance.now();
2057
+ let didThrow = false;
2058
+ try {
2059
+ StandaloneDb.openFile(fileName, OpenMode.ReadWrite, options);
2060
+ }
2061
+ catch (e) {
2062
+ assert.strictEqual(e.errorNumber, DbResult.BE_SQLITE_BUSY, "Expect error 'Db is busy'");
2063
+ didThrow = true;
2064
+ }
2065
+ assert.isTrue(didThrow);
2066
+ return performance.now() - start;
2067
+ };
2068
+ const seconds = (s) => s * 1000;
2069
+ const db = StandaloneDb.createEmpty(standaloneFile, { rootSubject: { name: "Standalone" } });
2070
+ db.saveChanges();
2071
+ // lock db so another connection cannot write to it.
2072
+ db.saveFileProperty({ name: "test", namespace: "test" }, "");
2073
+ assert.isAtMost(tryOpen(standaloneFile, { busyTimeout: seconds(0) }), seconds(1), "open should fail with busy error instantly");
2074
+ assert.isAtLeast(tryOpen(standaloneFile, { busyTimeout: seconds(1) }), seconds(1), "open should fail with atleast 1 sec delay due to retry");
2075
+ assert.isAtLeast(tryOpen(standaloneFile, { busyTimeout: seconds(2) }), seconds(2), "open should fail with atleast 2 sec delay due to retry");
2076
+ assert.isAtLeast(tryOpen(standaloneFile, { busyTimeout: seconds(3) }), seconds(3), "open should fail with atleast 3 sec delay due to retry");
2077
+ db.abandonChanges();
2078
+ db.close();
2079
+ });
2080
+ it("Standalone iModel properties", () => {
2081
+ const standaloneRootSubjectName = "Standalone";
2082
+ const standaloneFile1 = IModelTestUtils.prepareOutputFile("IModel", "Standalone1.bim");
2083
+ let standaloneDb1 = StandaloneDb.createEmpty(standaloneFile1, { rootSubject: { name: standaloneRootSubjectName } });
2084
+ assert.isTrue(standaloneDb1.isStandaloneDb());
2085
+ assert.isTrue(standaloneDb1.isStandalone);
2086
+ assert.isFalse(standaloneDb1.isReadonly, "Expect standalone iModels to be read-write during create");
2087
+ assert.equal(standaloneDb1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
2088
+ assert.equal(standaloneDb1.pathName, standaloneFile1);
2089
+ assert.equal(standaloneDb1, StandaloneDb.tryFindByKey(standaloneDb1.key), "Should be in the list of open StandaloneDbs");
2090
+ assert.equal(standaloneDb1.elements.getRootSubject().code.value, standaloneRootSubjectName);
2091
+ assert.isTrue(standaloneDb1.isOpen);
2092
+ assert.isTrue(Guid.isV4Guid(standaloneDb1.iModelId));
2093
+ assert.equal(standaloneDb1.iTwinId, Guid.empty);
2094
+ assert.strictEqual("", standaloneDb1.changeset.id);
2095
+ assert.strictEqual(0, standaloneDb1.changeset.index);
2096
+ assert.equal(standaloneDb1.openMode, OpenMode.ReadWrite);
2097
+ standaloneDb1.close();
2098
+ assert.isFalse(standaloneDb1.isOpen);
2099
+ standaloneDb1.close(); // calling `close()` a second time is a no-op
2100
+ assert.isUndefined(StandaloneDb.tryFindByKey(standaloneDb1.key));
2101
+ standaloneDb1 = StandaloneDb.openFile(standaloneFile1);
2102
+ assert.equal(standaloneDb1, StandaloneDb.tryFindByKey(standaloneDb1.key));
2103
+ assert.isFalse(standaloneDb1.isReadonly, "By default, StandaloneDbs are opened read/write");
2104
+ standaloneDb1.close();
2105
+ assert.isUndefined(StandaloneDb.tryFindByKey(standaloneDb1.key));
2106
+ });
2107
+ it("Snapshot iModel properties", () => {
2108
+ const snapshotRootSubjectName = "Snapshot";
2109
+ const snapshotFile1 = IModelTestUtils.prepareOutputFile("IModel", "Snapshot1.bim");
2110
+ const snapshotFile2 = IModelTestUtils.prepareOutputFile("IModel", "Snapshot2.bim");
2111
+ const snapshotFile3 = IModelTestUtils.prepareOutputFile("IModel", "Snapshot3.bim");
2112
+ let snapshotDb1 = SnapshotDb.createEmpty(snapshotFile1, { rootSubject: { name: snapshotRootSubjectName }, createClassViews: true });
2113
+ let snapshotDb2 = SnapshotDb.createFrom(snapshotDb1, snapshotFile2);
2114
+ let snapshotDb3 = SnapshotDb.createFrom(imodel1, snapshotFile3, { createClassViews: true });
2115
+ assert.isTrue(snapshotDb1.isSnapshotDb());
2116
+ assert.isTrue(snapshotDb2.isSnapshotDb());
2117
+ assert.isTrue(snapshotDb3.isSnapshotDb());
2118
+ assert.isTrue(snapshotDb1.isSnapshot);
2119
+ assert.isTrue(snapshotDb2.isSnapshot);
2120
+ assert.isTrue(snapshotDb3.isSnapshot);
2121
+ assert.isFalse(snapshotDb1.isReadonly, "Expect snapshots to be read-write during create");
2122
+ assert.isFalse(snapshotDb2.isReadonly, "Expect snapshots to be read-write during create");
2123
+ assert.isFalse(snapshotDb3.isReadonly, "Expect snapshots to be read-write during create");
2124
+ assert.equal(snapshotDb1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
2125
+ assert.equal(snapshotDb2.getBriefcaseId(), BriefcaseIdValue.Unassigned);
2126
+ assert.equal(snapshotDb3.getBriefcaseId(), BriefcaseIdValue.Unassigned);
2127
+ assert.equal(imodel1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
2128
+ assert.equal(snapshotDb1.pathName, snapshotFile1);
2129
+ assert.equal(snapshotDb2.pathName, snapshotFile2);
2130
+ assert.equal(snapshotDb3.pathName, snapshotFile3);
2131
+ assert.equal(snapshotDb1, SnapshotDb.tryFindByKey(snapshotDb1.key));
2132
+ assert.equal(snapshotDb2, SnapshotDb.tryFindByKey(snapshotDb2.key));
2133
+ assert.equal(snapshotDb3, SnapshotDb.tryFindByKey(snapshotDb3.key));
2134
+ const iModelGuid1 = snapshotDb1.iModelId;
2135
+ const iModelGuid2 = snapshotDb2.iModelId;
2136
+ const iModelGuid3 = snapshotDb3.iModelId;
2137
+ assert.notEqual(iModelGuid1, iModelGuid2, "Expect different iModel GUIDs for each snapshot");
2138
+ assert.notEqual(iModelGuid2, iModelGuid3, "Expect different iModel GUIDs for each snapshot");
2139
+ const rootSubjectName1 = snapshotDb1.elements.getRootSubject().code.value;
2140
+ const rootSubjectName2 = snapshotDb2.elements.getRootSubject().code.value;
2141
+ const rootSubjectName3 = snapshotDb3.elements.getRootSubject().code.value;
2142
+ const imodel1RootSubjectName = imodel1.elements.getRootSubject().code.value;
2143
+ assert.equal(rootSubjectName1, snapshotRootSubjectName);
2144
+ assert.equal(rootSubjectName1, rootSubjectName2, "Expect a snapshot to maintain the root Subject name from its seed");
2145
+ assert.equal(rootSubjectName3, imodel1RootSubjectName, "Expect a snapshot to maintain the root Subject name from its seed");
2146
+ assert.isTrue(snapshotDb1.isOpen);
2147
+ assert.isTrue(snapshotDb2.isOpen);
2148
+ assert.isTrue(snapshotDb3.isOpen);
2149
+ snapshotDb1.close();
2150
+ snapshotDb2.close();
2151
+ snapshotDb3.close();
2152
+ assert.isFalse(snapshotDb1.isOpen);
2153
+ assert.isFalse(snapshotDb2.isOpen);
2154
+ assert.isFalse(snapshotDb3.isOpen);
2155
+ snapshotDb1.close(); // calling `close()` a second time is a no-op
2156
+ snapshotDb2.close(); // calling `close()` a second time is a no-op
2157
+ snapshotDb3.close(); // calling `close()` a second time is a no-op
2158
+ assert.isUndefined(SnapshotDb.tryFindByKey(snapshotDb1.key));
2159
+ assert.isUndefined(SnapshotDb.tryFindByKey(snapshotDb2.key));
2160
+ assert.isUndefined(SnapshotDb.tryFindByKey(snapshotDb3.key));
2161
+ snapshotDb1 = SnapshotDb.openFile(snapshotFile1);
2162
+ snapshotDb2 = SnapshotDb.openFile(snapshotFile2);
2163
+ snapshotDb3 = SnapshotDb.openFile(snapshotFile3);
2164
+ assert.equal(snapshotDb1, SnapshotDb.tryFindByKey(snapshotDb1.key));
2165
+ assert.equal(snapshotDb2, SnapshotDb.tryFindByKey(snapshotDb2.key));
2166
+ assert.equal(snapshotDb3, SnapshotDb.tryFindByKey(snapshotDb3.key));
2167
+ assert.equal(snapshotDb3, SnapshotDb.findByKey(snapshotDb3.key));
2168
+ assert.equal(snapshotDb3, IModelDb.findByKey(snapshotDb3.key));
2169
+ assert.throws(() => BriefcaseDb.findByKey(snapshotDb1.key)); // lookup of key for SnapshotDb via BriefcaseDb should throw
2170
+ assert.throws(() => StandaloneDb.findByKey(snapshotDb1.key)); // likewise for StandaloneDb
2171
+ assert.isTrue(snapshotDb1.isReadonly, "Expect snapshots to be read-only after open");
2172
+ assert.isTrue(snapshotDb2.isReadonly, "Expect snapshots to be read-only after open");
2173
+ assert.isTrue(snapshotDb3.isReadonly, "Expect snapshots to be read-only after open");
2174
+ assert.isTrue(hasClassView(snapshotDb1, "bis.Element"));
2175
+ assert.isTrue(hasClassView(snapshotDb1, "bis.ElementAspect"));
2176
+ assert.isTrue(hasClassView(snapshotDb1, "bis.Model"));
2177
+ assert.isTrue(hasClassView(snapshotDb1, "bis.ElementRefersToElements"));
2178
+ assert.isFalse(hasClassView(snapshotDb2, "bis.Element"));
2179
+ assert.isTrue(hasClassView(snapshotDb3, "bis.Element"));
2180
+ snapshotDb1.close();
2181
+ snapshotDb2.close();
2182
+ snapshotDb3.close();
2183
+ assert.isUndefined(SnapshotDb.tryFindByKey(snapshotDb1.key));
2184
+ assert.isUndefined(SnapshotDb.tryFindByKey(snapshotDb2.key));
2185
+ assert.isUndefined(SnapshotDb.tryFindByKey(snapshotDb3.key));
2186
+ });
2187
+ it("upgrade the domain schema in a StandaloneDb", async () => {
2188
+ const testFileName = IModelTestUtils.prepareOutputFile("UpgradeIModel", "testImodel.bim");
2189
+ const seedFileName = IModelTestUtils.resolveAssetFile("testImodel.bim");
2190
+ IModelJsFs.copySync(seedFileName, testFileName);
2191
+ let iModel = StandaloneDb.openFile(testFileName, OpenMode.ReadWrite);
2192
+ const beforeVersion = iModel.querySchemaVersion("BisCore");
2193
+ assert.isTrue(semver.satisfies(beforeVersion, "= 1.0.0"));
2194
+ iModel.close();
2195
+ const schemaState = StandaloneDb.validateSchemas(testFileName, true);
2196
+ assert.strictEqual(schemaState, SchemaState.UpgradeRecommended);
2197
+ StandaloneDb.upgradeStandaloneSchemas(testFileName);
2198
+ iModel = StandaloneDb.openFile(testFileName, OpenMode.ReadWrite);
2199
+ const afterVersion = iModel.querySchemaVersion("BisCore");
2200
+ assert.isTrue(semver.satisfies(afterVersion, ">= 1.0.10"));
2201
+ iModel.close();
2202
+ });
2203
+ it("Run plain SQL", () => {
2204
+ imodel1.withPreparedSqliteStatement("CREATE TABLE Test(Id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Code INTEGER)", (stmt) => {
2205
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2206
+ });
2207
+ imodel1.withPreparedSqliteStatement("INSERT INTO Test(Name,Code) VALUES(?,?)", (stmt) => {
2208
+ stmt.bindValue(1, "Dummy 1");
2209
+ stmt.bindValue(2, 100);
2210
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2211
+ });
2212
+ imodel1.withPreparedSqliteStatement("INSERT INTO Test(Name,Code) VALUES(?,?)", (stmt) => {
2213
+ stmt.bindValues(["Dummy 2", 200]);
2214
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2215
+ });
2216
+ imodel1.withPreparedSqliteStatement("INSERT INTO Test(Name,Code) VALUES(:p1,:p2)", (stmt) => {
2217
+ stmt.bindValue(":p1", "Dummy 3");
2218
+ stmt.bindValue(":p2", 300);
2219
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2220
+ });
2221
+ imodel1.withPreparedSqliteStatement("INSERT INTO Test(Name,Code) VALUES(:p1,:p2)", (stmt) => {
2222
+ stmt.bindValues({ ":p1": "Dummy 4", ":p2": 400 });
2223
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2224
+ });
2225
+ imodel1.saveChanges();
2226
+ imodel1.withPreparedSqliteStatement("SELECT Id,Name,Code FROM Test ORDER BY Id", (stmt) => {
2227
+ for (let i = 1; i <= 4; i++) {
2228
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_ROW);
2229
+ assert.equal(stmt.getColumnCount(), 3);
2230
+ const val0 = stmt.getValue(0);
2231
+ assert.equal(val0.columnName, "Id");
2232
+ assert.equal(val0.type, SqliteValueType.Integer);
2233
+ assert.isFalse(val0.isNull);
2234
+ assert.equal(val0.getInteger(), i);
2235
+ const val1 = stmt.getValue(1);
2236
+ assert.equal(val1.columnName, "Name");
2237
+ assert.equal(val1.type, SqliteValueType.String);
2238
+ assert.isFalse(val1.isNull);
2239
+ assert.equal(val1.getString(), `Dummy ${i}`);
2240
+ const val2 = stmt.getValue(2);
2241
+ assert.equal(val2.columnName, "Code");
2242
+ assert.equal(val2.type, SqliteValueType.Integer);
2243
+ assert.isFalse(val2.isNull);
2244
+ assert.equal(val2.getInteger(), i * 100);
2245
+ const row = stmt.getRow();
2246
+ assert.equal(row.id, i);
2247
+ assert.equal(row.name, `Dummy ${i}`);
2248
+ assert.equal(row.code, i * 100);
2249
+ }
2250
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2251
+ });
2252
+ imodel1.withPreparedSqliteStatement("SELECT 1 FROM ec_CustomAttribute WHERE ContainerId=? AND Instance LIKE '<IsMixin%' COLLATE NOCASE", (stmt) => {
2253
+ stmt.bindValue(1, "0x1f");
2254
+ assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
2255
+ });
2256
+ });
2257
+ it("Run plain SQL against readonly connection", () => {
2258
+ let iModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("IModel", "sqlitesqlreadonlyconnection.bim"), { rootSubject: { name: "test" } });
2259
+ const iModelPath = iModel.pathName;
2260
+ iModel.close();
2261
+ iModel = SnapshotDb.openFile(iModelPath);
2262
+ iModel.withPreparedSqliteStatement("SELECT Name,StrData FROM be_Prop WHERE Namespace='ec_Db'", (stmt) => {
2263
+ let rowCount = 0;
2264
+ while (stmt.step() === DbResult.BE_SQLITE_ROW) {
2265
+ rowCount++;
2266
+ assert.equal(stmt.getColumnCount(), 2);
2267
+ const nameVal = stmt.getValue(0);
2268
+ assert.equal(nameVal.columnName, "Name");
2269
+ assert.equal(nameVal.type, SqliteValueType.String);
2270
+ assert.isFalse(nameVal.isNull);
2271
+ const name = nameVal.getString();
2272
+ const versionVal = stmt.getValue(1);
2273
+ assert.equal(versionVal.columnName, "StrData");
2274
+ assert.equal(versionVal.type, SqliteValueType.String);
2275
+ assert.isFalse(versionVal.isNull);
2276
+ const profileVersion = JSON.parse(versionVal.getString());
2277
+ assert.isTrue(name === "SchemaVersion" || name === "InitialSchemaVersion");
2278
+ if (name === "SchemaVersion") {
2279
+ assert.equal(profileVersion.major, 4);
2280
+ assert.equal(profileVersion.minor, 0);
2281
+ assert.equal(profileVersion.sub1, 0);
2282
+ assert.isAtLeast(profileVersion.sub2, 1);
2283
+ }
2284
+ else if (name === "InitialSchemaVersion") {
2285
+ assert.equal(profileVersion.major, 4);
2286
+ assert.equal(profileVersion.minor, 0);
2287
+ assert.equal(profileVersion.sub1, 0);
2288
+ assert.isAtLeast(profileVersion.sub2, 1);
2289
+ }
2290
+ }
2291
+ assert.equal(rowCount, 2);
2292
+ });
2293
+ iModel.close();
2294
+ });
2295
+ it("tryPrepareStatement", () => {
2296
+ const env_2 = { stack: [], error: void 0, hasError: false };
2297
+ try {
2298
+ const sql = `SELECT * FROM ${Element.classFullName} LIMIT 1`;
2299
+ const invalidSql = "SELECT * FROM InvalidSchemaName:InvalidClassName LIMIT 1";
2300
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
2301
+ assert.throws(() => imodel1.prepareStatement(invalidSql, false));
2302
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
2303
+ assert.isUndefined(imodel1.tryPrepareStatement(invalidSql));
2304
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
2305
+ const statement = __addDisposableResource(env_2, imodel1.tryPrepareStatement(sql), false);
2306
+ assert.isDefined(statement);
2307
+ assert.isTrue(statement?.isPrepared);
2308
+ }
2309
+ catch (e_2) {
2310
+ env_2.error = e_2;
2311
+ env_2.hasError = true;
2312
+ }
2313
+ finally {
2314
+ __disposeResources(env_2);
2315
+ }
2316
+ });
2317
+ it("containsClass", () => {
2318
+ assert.isTrue(imodel1.containsClass(Element.classFullName));
2319
+ assert.isTrue(imodel1.containsClass("BisCore:Element"));
2320
+ assert.isTrue(imodel1.containsClass("BisCore.Element"));
2321
+ assert.isTrue(imodel1.containsClass("biscore:element"));
2322
+ assert.isTrue(imodel1.containsClass("biscore.element"));
2323
+ assert.isTrue(imodel1.containsClass("bis:Element"));
2324
+ assert.isTrue(imodel1.containsClass("bis.Element"));
2325
+ assert.isTrue(imodel1.containsClass("bis:element"));
2326
+ assert.isTrue(imodel1.containsClass("bis.element"));
2327
+ assert.isFalse(imodel1.containsClass("BisCore:Element:InvalidExtra"));
2328
+ assert.isFalse(imodel1.containsClass("BisCore"));
2329
+ assert.isFalse(imodel1.containsClass(":Element"));
2330
+ assert.isFalse(imodel1.containsClass("BisCore:InvalidClassName"));
2331
+ assert.isFalse(imodel1.containsClass("InvalidSchemaName:Element"));
2332
+ });
2333
+ it("should update Element code", () => {
2334
+ const elementId = imodel4.elements.insertElement({
2335
+ classFullName: "DgnPlatformTest:TestInformationRecord",
2336
+ model: IModel.repositoryModelId,
2337
+ code: Code.createEmpty(),
2338
+ });
2339
+ let element = imodel4.elements.getElement(elementId, InformationRecordElement);
2340
+ assert.isTrue(Code.isValid(element.code));
2341
+ assert.isTrue(Code.isEmpty(element.code));
2342
+ const codeSpecId = imodel4.codeSpecs.insert("TestCodeSpec", CodeScopeSpec.Type.Model);
2343
+ const codeValue = `${element.className}-1`;
2344
+ element.code = new Code({ spec: codeSpecId, scope: IModel.repositoryModelId, value: codeValue });
2345
+ element.update();
2346
+ element = imodel4.elements.getElement(elementId, InformationRecordElement);
2347
+ assert.isTrue(Code.isValid(element.code));
2348
+ assert.isFalse(Code.isEmpty(element.code));
2349
+ assert.equal(element.code.value, codeValue);
2350
+ });
2351
+ it("should update UserLabel", () => {
2352
+ // type coercion reminder!
2353
+ const s = "";
2354
+ assert.isTrue(s === "");
2355
+ assert.isFalse(s ? true : false);
2356
+ // insert element with an undefined UserLabel
2357
+ const elementProps = {
2358
+ classFullName: SpatialCategory.classFullName,
2359
+ model: IModel.dictionaryId,
2360
+ code: SpatialCategory.createCode(imodel1, IModel.dictionaryId, "TestCategoryForClearUserLabel"),
2361
+ };
2362
+ const elementId = imodel1.elements.insertElement(elementProps);
2363
+ let element = imodel1.elements.getElement(elementId);
2364
+ assert.isUndefined(element.userLabel);
2365
+ // update element with a defined userLabel
2366
+ element.userLabel = "UserLabel";
2367
+ element.update();
2368
+ element = imodel1.elements.getElement(elementId);
2369
+ assert.equal(element.userLabel, "UserLabel");
2370
+ // make sure userLabel is not updated when not part of the specified ElementProps
2371
+ imodel1.elements.updateElement({
2372
+ id: element.id,
2373
+ classFullName: element.classFullName,
2374
+ model: element.model,
2375
+ code: element.code,
2376
+ });
2377
+ element = imodel1.elements.getElement(elementId);
2378
+ assert.equal(element.userLabel, "UserLabel"); // NOTE: userLabel is not modified when userLabel is not part of the input ElementProps
2379
+ const elProps = imodel1.elements.getElementProps({ id: elementId, onlyBaseProperties: true });
2380
+ expect(elProps.userLabel).equal(element.userLabel);
2381
+ expect(elProps.classFullName).equal(SpatialCategory.classFullName);
2382
+ expect(elProps.model).equal(element.model);
2383
+ expect(elProps.code.value).equal(element.code.value);
2384
+ expect(elProps.code.scope).equal(element.code.scope);
2385
+ expect(elProps.code.spec).equal(element.code.spec);
2386
+ expect(elProps.federationGuid).equal(element.federationGuid);
2387
+ expect(elProps.isPrivate).undefined;
2388
+ expect(elProps.isInstanceOfEntity).undefined;
2389
+ // remove userlabel by setting it to the blank string
2390
+ element.userLabel = "";
2391
+ element.update();
2392
+ element = imodel1.elements.getElement(elementId);
2393
+ assert.isUndefined(element.userLabel); // NOTE: userLabel is cleared when the empty string is specified
2394
+ });
2395
+ it("should update FederationGuid", () => {
2396
+ // insert element with an undefined FederationGuid
2397
+ const elementProps = {
2398
+ classFullName: SpatialCategory.classFullName,
2399
+ model: IModel.dictionaryId,
2400
+ federationGuid: Guid.empty,
2401
+ code: SpatialCategory.createCode(imodel1, IModel.dictionaryId, "TestCategoryForClearFederationGuid"),
2402
+ };
2403
+ const elementId = imodel1.elements.insertElement(elementProps);
2404
+ let element = imodel1.elements.getElement(elementId);
2405
+ assert.isUndefined(element.federationGuid);
2406
+ assert.isFalse(element.isPrivate);
2407
+ // update element with a defined FederationGuid
2408
+ const federationGuid = Guid.createValue();
2409
+ element.federationGuid = federationGuid;
2410
+ element.isPrivate = true;
2411
+ element.update();
2412
+ element = imodel1.elements.getElement(elementId);
2413
+ assert.equal(element.federationGuid, federationGuid);
2414
+ assert.isTrue(element.isPrivate);
2415
+ // make sure FederationGuid is not updated when not part of the specified ElementProps
2416
+ imodel1.elements.updateElement({
2417
+ id: element.id,
2418
+ classFullName: element.classFullName,
2419
+ model: element.model,
2420
+ code: element.code,
2421
+ });
2422
+ element = imodel1.elements.getElement(elementId);
2423
+ assert.equal(element.federationGuid, federationGuid);
2424
+ assert.isTrue(element.isPrivate);
2425
+ // remove federationGuid by setting it to undefined in ElementProps
2426
+ const elProps = element.toJSON();
2427
+ elProps.federationGuid = undefined;
2428
+ imodel1.elements.updateElement(elProps);
2429
+ element = imodel1.elements.getElement(elementId);
2430
+ assert.isUndefined(element.federationGuid);
2431
+ // ensure that update doesn't change federationGuid from an element immediately after insert (toJSON should remove undefined value)
2432
+ const subject5 = Subject.create(imodel1, IModel.rootSubjectId, "Subject5");
2433
+ const s5Id = subject5.insert();
2434
+ const s5pre = imodel1.elements.getElement(s5Id);
2435
+ subject5.description = "new descr";
2436
+ subject5.update();
2437
+ const s5post = imodel1.elements.getElement(s5Id);
2438
+ expect(s5pre.federationGuid).equal(s5post.federationGuid);
2439
+ expect(s5post.description).equal(subject5.description);
2440
+ });
2441
+ it("should support partial update", () => {
2442
+ // Insert Subject elements - initializing Description and UserLabel to similar values
2443
+ let subject1 = Subject.create(imodel1, IModel.rootSubjectId, "Subject1", "Description1");
2444
+ let subject2 = Subject.create(imodel1, IModel.rootSubjectId, "Subject2", "Description2");
2445
+ let subject3 = Subject.create(imodel1, IModel.rootSubjectId, "Subject3", "");
2446
+ let subject4 = Subject.create(imodel1, IModel.rootSubjectId, "Subject4");
2447
+ subject1.userLabel = "UserLabel1";
2448
+ subject2.userLabel = "UserLabel2";
2449
+ subject3.userLabel = "";
2450
+ subject4.userLabel = undefined;
2451
+ const federationGuid1 = Guid.createValue();
2452
+ const federationGuid2 = Guid.createValue();
2453
+ subject1.federationGuid = federationGuid1;
2454
+ subject2.federationGuid = federationGuid2;
2455
+ subject3.federationGuid = "";
2456
+ subject4.federationGuid = Guid.empty;
2457
+ const subjectId1 = subject1.insert();
2458
+ const subjectId2 = subject2.insert();
2459
+ const subjectId3 = subject3.insert();
2460
+ const subjectId4 = subject4.insert();
2461
+ subject1 = imodel1.elements.getElement(subjectId1, Subject);
2462
+ subject2 = imodel1.elements.getElement(subjectId2, Subject);
2463
+ subject3 = imodel1.elements.getElement(subjectId3, Subject);
2464
+ subject4 = imodel1.elements.getElement(subjectId4, Subject);
2465
+ // Subject.Description is an auto-handled property
2466
+ assert.equal(subject1.description, "Description1");
2467
+ assert.equal(subject2.description, "Description2");
2468
+ assert.equal(subject3.description, ""); // NOTE: different behavior between auto-handled and custom-handled
2469
+ assert.isUndefined(subject4.description);
2470
+ // Test toJSON
2471
+ assert.equal(subject1.toJSON().description, "Description1");
2472
+ assert.equal(subject2.toJSON().description, "Description2");
2473
+ assert.equal(subject3.toJSON().description, "");
2474
+ assert.isUndefined(subject4.toJSON().description);
2475
+ // Element.UserLabel is a custom-handled property
2476
+ assert.equal(subject1.userLabel, "UserLabel1");
2477
+ assert.equal(subject2.userLabel, "UserLabel2");
2478
+ assert.isUndefined(subject3.userLabel); // NOTE: different behavior between auto-handled and custom-handled
2479
+ assert.isUndefined(subject4.userLabel);
2480
+ // Element.FederationGuid is a custom-handled property
2481
+ assert.equal(subject1.federationGuid, federationGuid1);
2482
+ assert.equal(subject2.federationGuid, federationGuid2);
2483
+ assert.isUndefined(subject4.federationGuid);
2484
+ // test partial update of Description (auto-handled)
2485
+ imodel1.elements.updateElement({ id: subject1.id, description: "Description1-Updated" });
2486
+ subject1 = imodel1.elements.getElement(subjectId1, Subject);
2487
+ assert.equal(subject1.description, "Description1-Updated"); // should have been updated
2488
+ assert.isDefined(subject1.model);
2489
+ assert.isDefined(subject1.parent);
2490
+ assert.equal(subject1.code.value, "Subject1"); // should not have changed
2491
+ assert.equal(subject1.userLabel, "UserLabel1"); // should not have changed
2492
+ assert.equal(subject1.federationGuid, federationGuid1); // should not have changed
2493
+ // test partial update of UserLabel (custom-handled)
2494
+ imodel1.elements.updateElement({ id: subject2.id, userLabel: "UserLabel2-Updated" });
2495
+ subject2 = imodel1.elements.getElement(subjectId2, Subject);
2496
+ assert.isDefined(subject2.model);
2497
+ assert.isDefined(subject2.parent);
2498
+ assert.equal(subject2.userLabel, "UserLabel2-Updated"); // should have been updated
2499
+ assert.equal(subject2.code.value, "Subject2"); // should not have changed
2500
+ assert.equal(subject2.description, "Description2"); // should not have changed
2501
+ assert.equal(subject2.federationGuid, federationGuid2); // should not have changed
2502
+ // Update Subject elements - setting Description and UserLabel to similar values
2503
+ subject1.description = undefined;
2504
+ subject2.description = "";
2505
+ subject3.description = "Description3";
2506
+ subject4.description = "Description4";
2507
+ subject2.userLabel = "";
2508
+ subject3.userLabel = "UserLabel3";
2509
+ subject4.userLabel = "UserLabel4";
2510
+ subject1.update();
2511
+ subject2.update();
2512
+ subject3.update();
2513
+ subject4.update();
2514
+ subject1 = imodel1.elements.getElement(subjectId1, Subject);
2515
+ subject2 = imodel1.elements.getElement(subjectId2, Subject);
2516
+ subject3 = imodel1.elements.getElement(subjectId3, Subject);
2517
+ subject4 = imodel1.elements.getElement(subjectId4, Subject);
2518
+ // Subject.Description is an auto-handled property
2519
+ assert.isUndefined(subject1.description);
2520
+ assert.equal(subject2.description, ""); // NOTE: different behavior between auto-handled and custom-handled
2521
+ assert.equal(subject3.description, "Description3");
2522
+ assert.equal(subject4.description, "Description4");
2523
+ // Element.UserLabel is a custom-handled property
2524
+ assert.isUndefined(subject2.userLabel); // NOTE: different behavior between auto-handled and custom-handled
2525
+ assert.equal(subject3.userLabel, "UserLabel3");
2526
+ assert.equal(subject4.userLabel, "UserLabel4");
2527
+ // test partial update of Description to undefined
2528
+ const s3Fed = subject3.federationGuid;
2529
+ imodel1.elements.updateElement({ id: subject3.id, description: undefined });
2530
+ subject3 = imodel1.elements.getElement(subjectId3, Subject);
2531
+ assert.isUndefined(subject3.description); // should have been updated
2532
+ assert.isDefined(subject3.model);
2533
+ assert.isDefined(subject3.parent);
2534
+ assert.equal(subject3.code.value, "Subject3"); // should not have changed
2535
+ assert.equal(subject3.userLabel, "UserLabel3"); // should not have changed
2536
+ assert.equal(subject3.federationGuid, s3Fed); // should not have changed
2537
+ // test partial update of UserLabel to undefined
2538
+ imodel1.elements.updateElement({ id: subject4.id, userLabel: undefined });
2539
+ subject4 = imodel1.elements.getElement(subjectId4, Subject);
2540
+ assert.isDefined(subject4.model);
2541
+ assert.isDefined(subject4.parent);
2542
+ // assert.isUndefined(subject4.userLabel); // should have been updated - WIP WIP WIP
2543
+ assert.equal(subject4.code.value, "Subject4"); // should not have changed
2544
+ assert.equal(subject4.description, "Description4"); // should not have changed
2545
+ assert.isUndefined(subject4.federationGuid); // should not have changed
2546
+ });
2547
+ it('should allow untrimmed codes when using "exact" codeValueBehavior', () => {
2548
+ const imodelPath = IModelTestUtils.prepareOutputFile("IModel", "codeValueBehavior.bim");
2549
+ const imodel = SnapshotDb.createEmpty(imodelPath, { rootSubject: { name: "codeValueBehaviors" } });
2550
+ const getNumberedCodeValAndProps = (n) => {
2551
+ const trimmedCodeVal = `CodeValue${n}`;
2552
+ const untrimmedCodeVal = `${trimmedCodeVal}\xa0`;
2553
+ const spec = imodel.codeSpecs.getByName(SpatialCategory.getCodeSpecName()).id;
2554
+ const props = {
2555
+ // the [[Code]] class still (as it always has) trims unicode space, so avoid it
2556
+ code: { spec, scope: IModelDb.dictionaryId, value: untrimmedCodeVal },
2557
+ model: IModelDb.dictionaryId,
2558
+ classFullName: SpatialCategory.classFullName,
2559
+ };
2560
+ return { trimmedCodeVal, untrimmedCodeVal, props };
2561
+ };
2562
+ expect(imodel.codeValueBehavior).to.equal("trim-unicode-whitespace");
2563
+ const code1 = getNumberedCodeValAndProps(1);
2564
+ const categ1Id = imodel.elements.insertElement(code1.props);
2565
+ const categ1 = imodel.elements.getElementJson({ id: categ1Id });
2566
+ expect(categ1.code.value).to.equal(code1.trimmedCodeVal);
2567
+ imodel.codeValueBehavior = "exact";
2568
+ const code2 = getNumberedCodeValAndProps(2);
2569
+ const categ2Id = imodel.elements.insertElement(code2.props);
2570
+ const categ2 = imodel.elements.getElementJson({ id: categ2Id });
2571
+ expect(categ2.code.value).to.equal(code2.untrimmedCodeVal);
2572
+ imodel.codeValueBehavior = "trim-unicode-whitespace";
2573
+ const code3 = getNumberedCodeValAndProps(3);
2574
+ const categ3Id = imodel.elements.insertElement(code3.props);
2575
+ const categ3 = imodel.elements.getElement({ id: categ3Id });
2576
+ expect(categ3.code.value).to.equal(code3.trimmedCodeVal);
2577
+ imodel.close();
2578
+ });
2579
+ it("throws NotFound when attempting to access element props after closing the iModel", () => {
2580
+ const imodelPath = IModelTestUtils.prepareOutputFile("IModel", "accessAfterClose.bim");
2581
+ const imodel = SnapshotDb.createEmpty(imodelPath, { rootSubject: { name: "accessAfterClose" } });
2582
+ const elem = imodel.elements.getElement(IModel.rootSubjectId);
2583
+ expect(elem.id).to.equal(IModel.rootSubjectId);
2584
+ imodel.close();
2585
+ expect(() => imodel.elements.getElement(IModel.rootSubjectId)).to.throw(IModelError, "Element=0x1", "Not Found");
2586
+ });
2587
+ it("should throw \"constraint failed (BE_SQLITE_CONSTRAINT_UNIQUE)\" when inserting a relationsip instance with the same prop twice", () => {
2588
+ const imodelPath = IModelTestUtils.prepareOutputFile("IModel", "insertDuplicateInstance.bim");
2589
+ const imodel = SnapshotDb.createEmpty(imodelPath, { rootSubject: { name: "insertDuplicateInstance" } });
2590
+ const elements = imodel.elements;
2591
+ // Create a new physical model
2592
+ const newModelId = PhysicalModel.insert(imodel, IModel.rootSubjectId, "TestModel");
2593
+ // create a SpatialCategory
2594
+ const spatialCategoryId = SpatialCategory.insert(imodel, IModel.dictionaryId, "MySpatialCategory", new SubCategoryAppearance({ color: ColorByName.darkRed }));
2595
+ // Create a couple of physical elements.
2596
+ const elementProps = {
2597
+ classFullName: PhysicalObject.classFullName,
2598
+ model: newModelId,
2599
+ category: spatialCategoryId,
2600
+ code: Code.createEmpty(),
2601
+ };
2602
+ const id0 = elements.insertElement(elementProps);
2603
+ const id1 = elements.insertElement(elementProps);
2604
+ const props = {
2605
+ classFullName: "BisCore:ElementGroupsMembers",
2606
+ sourceId: id0,
2607
+ targetId: id1,
2608
+ memberPriority: 1,
2609
+ };
2610
+ imodel.relationships.insertInstance(props);
2611
+ expect(() => imodel.relationships.insertInstance(props)).to.throw(`Failed to insert relationship [${imodelPath}]: rc=2067, constraint failed (BE_SQLITE_CONSTRAINT_UNIQUE)`);
2612
+ imodel.close();
2613
+ });
2614
+ });
2615
+ //# sourceMappingURL=IModel.test.js.map