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

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