@itwin/core-backend 5.0.0-dev.9 → 5.0.0-dev.92

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