@itwin/core-backend 5.5.0-dev.1 → 5.5.0-dev.2

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 (381) hide show
  1. package/lib/cjs/BackendHubAccess.js.map +1 -1
  2. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  3. package/lib/cjs/BisCoreSchema.js.map +1 -1
  4. package/lib/cjs/BlobContainerService.js.map +1 -1
  5. package/lib/cjs/BriefcaseManager.js.map +1 -1
  6. package/lib/cjs/CatalogDb.js.map +1 -1
  7. package/lib/cjs/Category.js.map +1 -1
  8. package/lib/cjs/ChangeSummaryManager.js +2 -2
  9. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  10. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  11. package/lib/cjs/ChangesetECAdaptor.js +248 -248
  12. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  13. package/lib/cjs/ChannelControl.js.map +1 -1
  14. package/lib/cjs/CheckpointManager.js.map +1 -1
  15. package/lib/cjs/ClassRegistry.js +5 -5
  16. package/lib/cjs/ClassRegistry.js.map +1 -1
  17. package/lib/cjs/CloudSqlite.js.map +1 -1
  18. package/lib/cjs/CodeService.js.map +1 -1
  19. package/lib/cjs/CodeSpecs.js.map +1 -1
  20. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  21. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  22. package/lib/cjs/DevTools.js.map +1 -1
  23. package/lib/cjs/DisplayStyle.js.map +1 -1
  24. package/lib/cjs/ECDb.js.map +1 -1
  25. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  26. package/lib/cjs/ECSqlStatement.js.map +1 -1
  27. package/lib/cjs/Element.js.map +1 -1
  28. package/lib/cjs/ElementAspect.js.map +1 -1
  29. package/lib/cjs/ElementGraphics.js.map +1 -1
  30. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  31. package/lib/cjs/Entity.js.map +1 -1
  32. package/lib/cjs/EntityReferences.js.map +1 -1
  33. package/lib/cjs/ExportGraphics.js.map +1 -1
  34. package/lib/cjs/ExternalSource.js.map +1 -1
  35. package/lib/cjs/FontFile.js.map +1 -1
  36. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  37. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  38. package/lib/cjs/GeometrySummary.js +47 -47
  39. package/lib/cjs/GeometrySummary.js.map +1 -1
  40. package/lib/cjs/IModelDb.js +8 -8
  41. package/lib/cjs/IModelDb.js.map +1 -1
  42. package/lib/cjs/IModelDbFonts.js.map +1 -1
  43. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  44. package/lib/cjs/IModelHost.js.map +1 -1
  45. package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
  46. package/lib/cjs/IModelJsFs.js.map +1 -1
  47. package/lib/cjs/ImageSourceConversion.js.map +1 -1
  48. package/lib/cjs/IpcHost.js.map +1 -1
  49. package/lib/cjs/LineStyle.js.map +1 -1
  50. package/lib/cjs/LocalHub.js +1 -1
  51. package/lib/cjs/LocalHub.js.map +1 -1
  52. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  53. package/lib/cjs/LockControl.js.map +1 -1
  54. package/lib/cjs/Material.js.map +1 -1
  55. package/lib/cjs/Model.js.map +1 -1
  56. package/lib/cjs/NativeAppStorage.js.map +1 -1
  57. package/lib/cjs/NativeHost.js.map +1 -1
  58. package/lib/cjs/NavigationRelationship.js.map +1 -1
  59. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  60. package/lib/cjs/PropertyStore.js.map +1 -1
  61. package/lib/cjs/Relationship.js.map +1 -1
  62. package/lib/cjs/RpcBackend.js.map +1 -1
  63. package/lib/cjs/SQLiteDb.js.map +1 -1
  64. package/lib/cjs/Schema.js.map +1 -1
  65. package/lib/cjs/SchemaSync.js.map +1 -1
  66. package/lib/cjs/SchemaUtils.js.map +1 -1
  67. package/lib/cjs/SheetIndex.js.map +1 -1
  68. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  69. package/lib/cjs/SqliteStatement.js.map +1 -1
  70. package/lib/cjs/StashManager.js.map +1 -1
  71. package/lib/cjs/Texture.js.map +1 -1
  72. package/lib/cjs/TileStorage.js.map +1 -1
  73. package/lib/cjs/TxnManager.js.map +1 -1
  74. package/lib/cjs/ViewDefinition.js.map +1 -1
  75. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  76. package/lib/cjs/ViewStore.js.map +1 -1
  77. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  78. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  79. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  80. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  81. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
  82. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
  83. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  84. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  85. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
  86. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
  87. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
  88. package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
  89. package/lib/cjs/core-backend.js.map +1 -1
  90. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  91. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  92. package/lib/cjs/domains/GenericElements.js.map +1 -1
  93. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  94. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
  95. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  96. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  97. package/lib/cjs/internal/FontFileImpl.js.map +1 -1
  98. package/lib/cjs/internal/HubMock.js.map +1 -1
  99. package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
  100. package/lib/cjs/internal/NativePlatform.js.map +1 -1
  101. package/lib/cjs/internal/NoLocks.js.map +1 -1
  102. package/lib/cjs/internal/OnlineStatus.js.map +1 -1
  103. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  104. package/lib/cjs/internal/Symbols.js.map +1 -1
  105. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  106. package/lib/cjs/internal/cross-package.js.map +1 -1
  107. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  108. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  109. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  110. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  111. package/lib/cjs/rpc/multipart.js.map +1 -1
  112. package/lib/cjs/rpc/tracing.js.map +1 -1
  113. package/lib/cjs/rpc/web/logging.js.map +1 -1
  114. package/lib/cjs/rpc/web/request.js.map +1 -1
  115. package/lib/cjs/rpc/web/response.js.map +1 -1
  116. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  117. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  118. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  119. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  120. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  121. package/lib/cjs/workspace/Settings.js.map +1 -1
  122. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  123. package/lib/cjs/workspace/Workspace.js.map +1 -1
  124. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  125. package/lib/esm/BackendHubAccess.js.map +1 -1
  126. package/lib/esm/BackendLoggerCategory.js.map +1 -1
  127. package/lib/esm/BisCoreSchema.js.map +1 -1
  128. package/lib/esm/BlobContainerService.js.map +1 -1
  129. package/lib/esm/BriefcaseManager.js.map +1 -1
  130. package/lib/esm/CatalogDb.js.map +1 -1
  131. package/lib/esm/Category.js.map +1 -1
  132. package/lib/esm/ChangeSummaryManager.js +2 -2
  133. package/lib/esm/ChangeSummaryManager.js.map +1 -1
  134. package/lib/esm/ChangedElementsDb.js.map +1 -1
  135. package/lib/esm/ChangesetECAdaptor.js +248 -248
  136. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  137. package/lib/esm/ChannelControl.js.map +1 -1
  138. package/lib/esm/CheckpointManager.js.map +1 -1
  139. package/lib/esm/ClassRegistry.js +5 -5
  140. package/lib/esm/ClassRegistry.js.map +1 -1
  141. package/lib/esm/CloudSqlite.js.map +1 -1
  142. package/lib/esm/CodeService.js.map +1 -1
  143. package/lib/esm/CodeSpecs.js.map +1 -1
  144. package/lib/esm/ConcurrentQuery.js.map +1 -1
  145. package/lib/esm/CustomViewState3dCreator.js.map +1 -1
  146. package/lib/esm/DevTools.js.map +1 -1
  147. package/lib/esm/DisplayStyle.js.map +1 -1
  148. package/lib/esm/ECDb.js.map +1 -1
  149. package/lib/esm/ECSchemaXmlContext.js.map +1 -1
  150. package/lib/esm/ECSqlStatement.js.map +1 -1
  151. package/lib/esm/Element.js.map +1 -1
  152. package/lib/esm/ElementAspect.js.map +1 -1
  153. package/lib/esm/ElementGraphics.js.map +1 -1
  154. package/lib/esm/ElementTreeWalker.js.map +1 -1
  155. package/lib/esm/Entity.js.map +1 -1
  156. package/lib/esm/EntityReferences.js.map +1 -1
  157. package/lib/esm/ExportGraphics.js.map +1 -1
  158. package/lib/esm/ExternalSource.js.map +1 -1
  159. package/lib/esm/FontFile.js.map +1 -1
  160. package/lib/esm/GeoCoordConfig.js.map +1 -1
  161. package/lib/esm/GeographicCRSServices.js.map +1 -1
  162. package/lib/esm/GeometrySummary.js +47 -47
  163. package/lib/esm/GeometrySummary.js.map +1 -1
  164. package/lib/esm/IModelDb.js +8 -8
  165. package/lib/esm/IModelDb.js.map +1 -1
  166. package/lib/esm/IModelDbFonts.js.map +1 -1
  167. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  168. package/lib/esm/IModelHost.js.map +1 -1
  169. package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
  170. package/lib/esm/IModelJsFs.js.map +1 -1
  171. package/lib/esm/ImageSourceConversion.js.map +1 -1
  172. package/lib/esm/IpcHost.js.map +1 -1
  173. package/lib/esm/LineStyle.js.map +1 -1
  174. package/lib/esm/LocalHub.js +1 -1
  175. package/lib/esm/LocalHub.js.map +1 -1
  176. package/lib/esm/LocalhostIpcHost.js.map +1 -1
  177. package/lib/esm/LockControl.js.map +1 -1
  178. package/lib/esm/Material.js.map +1 -1
  179. package/lib/esm/Model.js.map +1 -1
  180. package/lib/esm/NativeAppStorage.js.map +1 -1
  181. package/lib/esm/NativeHost.js.map +1 -1
  182. package/lib/esm/NavigationRelationship.js.map +1 -1
  183. package/lib/esm/PromiseMemoizer.js.map +1 -1
  184. package/lib/esm/PropertyStore.js.map +1 -1
  185. package/lib/esm/Relationship.js.map +1 -1
  186. package/lib/esm/RpcBackend.js.map +1 -1
  187. package/lib/esm/SQLiteDb.js.map +1 -1
  188. package/lib/esm/Schema.js.map +1 -1
  189. package/lib/esm/SchemaSync.js.map +1 -1
  190. package/lib/esm/SchemaUtils.js.map +1 -1
  191. package/lib/esm/SheetIndex.js.map +1 -1
  192. package/lib/esm/SqliteChangesetReader.js.map +1 -1
  193. package/lib/esm/SqliteStatement.js.map +1 -1
  194. package/lib/esm/StashManager.js.map +1 -1
  195. package/lib/esm/Texture.js.map +1 -1
  196. package/lib/esm/TileStorage.js.map +1 -1
  197. package/lib/esm/TxnManager.js.map +1 -1
  198. package/lib/esm/ViewDefinition.js.map +1 -1
  199. package/lib/esm/ViewStateHydrator.js.map +1 -1
  200. package/lib/esm/ViewStore.js.map +1 -1
  201. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  202. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  203. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  204. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  205. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
  206. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
  207. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  208. package/lib/esm/core-backend.js.map +1 -1
  209. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  210. package/lib/esm/domains/FunctionalSchema.js.map +1 -1
  211. package/lib/esm/domains/GenericElements.js.map +1 -1
  212. package/lib/esm/domains/GenericSchema.js.map +1 -1
  213. package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
  214. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  215. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  216. package/lib/esm/internal/FontFileImpl.js.map +1 -1
  217. package/lib/esm/internal/HubMock.js.map +1 -1
  218. package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
  219. package/lib/esm/internal/NativePlatform.js.map +1 -1
  220. package/lib/esm/internal/NoLocks.js.map +1 -1
  221. package/lib/esm/internal/OnlineStatus.js.map +1 -1
  222. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  223. package/lib/esm/internal/Symbols.js.map +1 -1
  224. package/lib/esm/internal/annotations/fields.js.map +1 -1
  225. package/lib/esm/internal/cross-package.js.map +1 -1
  226. package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
  227. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  228. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  229. package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  230. package/lib/esm/rpc/multipart.js.map +1 -1
  231. package/lib/esm/rpc/tracing.js.map +1 -1
  232. package/lib/esm/rpc/web/logging.js.map +1 -1
  233. package/lib/esm/rpc/web/request.js.map +1 -1
  234. package/lib/esm/rpc/web/response.js.map +1 -1
  235. package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  236. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  237. package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  238. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  239. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  240. package/lib/esm/test/AdvancedEqual.js.map +1 -1
  241. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  242. package/lib/esm/test/AttachDb.test.js +11 -11
  243. package/lib/esm/test/AttachDb.test.js.map +1 -1
  244. package/lib/esm/test/ElementDrivesElement.test.js +23 -23
  245. package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
  246. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  247. package/lib/esm/test/GeometryTestUtil.js.map +1 -1
  248. package/lib/esm/test/IModelHost.test.js.map +1 -1
  249. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  250. package/lib/esm/test/ImageSourceConversion.test.js.map +1 -1
  251. package/lib/esm/test/IpcHost.test.js.map +1 -1
  252. package/lib/esm/test/KnownTestLocations.js.map +1 -1
  253. package/lib/esm/test/PrintElementTree.js.map +1 -1
  254. package/lib/esm/test/PropertyDb.test.js.map +1 -1
  255. package/lib/esm/test/RevisionUtility.js.map +1 -1
  256. package/lib/esm/test/SchemaUtils.test.js +25 -25
  257. package/lib/esm/test/SchemaUtils.test.js.map +1 -1
  258. package/lib/esm/test/SequentialLogMatcher.js.map +1 -1
  259. package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
  260. package/lib/esm/test/TestUtils.js.map +1 -1
  261. package/lib/esm/test/annotations/Fields.test.js +53 -53
  262. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  263. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  264. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  265. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  266. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  267. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
  268. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  269. package/lib/esm/test/categories/Category.test.js.map +1 -1
  270. package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
  271. package/lib/esm/test/ecdb/CTE.test.js +88 -88
  272. package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
  273. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +15 -15
  274. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  275. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +15 -15
  276. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
  277. package/lib/esm/test/ecdb/ECDb.test.js +72 -72
  278. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  279. package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -1
  280. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -1
  281. package/lib/esm/test/ecdb/ECSqlAst.test.js +65 -65
  282. package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
  283. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  284. package/lib/esm/test/ecdb/ECSqlReader.test.js +16 -16
  285. package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
  286. package/lib/esm/test/ecdb/ECSqlStatement.test.js +332 -332
  287. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  288. package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
  289. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
  290. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +21 -21
  291. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
  292. package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
  293. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  294. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  295. package/lib/esm/test/element/ElementAspect.test.js +22 -22
  296. package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
  297. package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
  298. package/lib/esm/test/element/ElementRoundTrip.test.js +139 -139
  299. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  300. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  301. package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
  302. package/lib/esm/test/element/NullStructArray.test.js +13 -13
  303. package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
  304. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
  305. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
  306. package/lib/esm/test/element/UrlLink.test.js.map +1 -1
  307. package/lib/esm/test/font/FontFile.test.js.map +1 -1
  308. package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
  309. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +32 -32
  310. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  311. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  312. package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
  313. package/lib/esm/test/hubaccess/Rebase.test.js +40 -40
  314. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  315. package/lib/esm/test/imageData.js.map +1 -1
  316. package/lib/esm/test/imodel/Code.test.js.map +1 -1
  317. package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
  318. package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -1
  319. package/lib/esm/test/imodel/IModel.test.js +44 -44
  320. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  321. package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
  322. package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
  323. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  324. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
  325. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +1 -1
  326. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +1 -1
  327. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +1 -1
  328. package/lib/esm/test/index.js.map +1 -1
  329. package/lib/esm/test/misc/DevTools.test.js.map +1 -1
  330. package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -1
  331. package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
  332. package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -1
  333. package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -1
  334. package/lib/esm/test/rpc/response.test.js.map +1 -1
  335. package/lib/esm/test/schema/ClassRegistry.test.js +99 -99
  336. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  337. package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
  338. package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
  339. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  340. package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
  341. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  342. package/lib/esm/test/standalone/ChangesetReader.test.js +124 -124
  343. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  344. package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -1
  345. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
  346. package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
  347. package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
  348. package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
  349. package/lib/esm/test/standalone/ExportGraphics.test.js +14 -14
  350. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  351. package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
  352. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  353. package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
  354. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
  355. package/lib/esm/test/standalone/IModelWrite.test.js +27 -27
  356. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  357. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
  358. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
  359. package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -1
  360. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  361. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
  362. package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
  363. package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -1
  364. package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
  365. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  366. package/lib/esm/test/standalone/Setting.test.js.map +1 -1
  367. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  368. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  369. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  370. package/lib/esm/test/standalone/Texture.test.js.map +1 -1
  371. package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
  372. package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
  373. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  374. package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
  375. package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
  376. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  377. package/lib/esm/workspace/Settings.js.map +1 -1
  378. package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
  379. package/lib/esm/workspace/Workspace.js.map +1 -1
  380. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  381. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3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/B,CAAA;IAED;;OAEG;IACH,SAAgB,gBAAgB,CAAC,GAAqC;QACpE,OAAO;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;YACrB,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC;SAC1C,CAAC;IACJ,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAoQD,uDAAuD;IACvD,MAAa,KAAM,SAAQ,YAAY;QACrC,6EAA6E;QAC7D,OAAO,CAAU;QACjC,uGAAuG;QACvF,QAAQ,CAAsC;QAE9D,gBAAgB;QAChB,YAAY,OAAgB,EAAE,MAAc,EAAE,OAAe,EAAE,QAA6C;YAC1G,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,CAAC;KACF;IAZY,iBAAK,QAYjB,CAAA;AAgCH,CAAC,EA9dgB,WAAW,KAAX,WAAW,QA8d3B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\r\nimport { CodeProps, FontId, FontType } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { SettingsContainer } from \"./workspace/Settings\";\r\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\r\n\r\n/**\r\n * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.\r\n * See [CodeService]($docs/learning/backend/CodeService).\r\n * @alpha\r\n */\r\nexport interface CodeService {\r\n /** @internal */\r\n close: () => void;\r\n\r\n initialize(iModel: IModelDb): Promise<void>;\r\n\r\n /** the index for external Codes for this CodeService */\r\n readonly externalCodes?: CloudSqlite.DbAccess<CodeService.CodesDb, CodeService.ReadMethods, CodeService.WriteMethods>;\r\n\r\n /** the index for internal Codes for this CodeService */\r\n readonly internalCodes?: CloudSqlite.DbAccess<CodeService.InternalCodes, CodeService.InternalReadMethods, CodeService.InternalWriteMethods>;\r\n\r\n /**\r\n * Application-supplied parameters for reserving new codes.\r\n */\r\n readonly appParams: CodeService.AuthorAndOrigin;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(props: CodeService.ElementCodeProps): void;\r\n}\r\n\r\n/** @alpha */\r\nexport namespace CodeService {\r\n\r\n export interface WriteMethods {\r\n /** Add a new code spec to this code service.\r\n */\r\n addCodeSpec(val: CodeService.NameAndJson): Promise<void>;\r\n\r\n /**\r\n * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.\r\n * @returns the number of codes actually added.\r\n * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,\r\n * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since\r\n * any codes or code specs that are already in the index are ignored.\r\n */\r\n addAllCodes(iModel: IModelDb): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve a single proposed code.\r\n * @throws `CodeService.Error` if the proposed code cannot be reserved.\r\n */\r\n reserveCode(code: CodeService.ProposedCode): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of proposed codes.\r\n * @returns number of codes actually reserved.\r\n * @see the `problems` member of the `CodeService.Error` exception\r\n * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.\r\n */\r\n reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve the next available code for a code sequence and scope.\r\n */\r\n reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of the next available codes for a code sequence and scope.\r\n * The length of the array determines the number of codes requested. The values for the new codes are returned\r\n * in the array, so they can be associated with the supplied GUIDs.\r\n * @returns number of codes actually reserved.\r\n */\r\n reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;\r\n\r\n /**\r\n * Update the properties of a single code.\r\n */\r\n updateCode(props: CodeService.UpdatedCode): Promise<void>;\r\n\r\n /**\r\n * Update the properties of an array codes.\r\n * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @returns number of codes actually updated.\r\n */\r\n updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;\r\n\r\n /** Delete an array of codes by their guids. */\r\n deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;\r\n }\r\n\r\n export interface ReadMethods {\r\n /**\r\n * Find the next available value for the supplied `SequenceScope`.\r\n * If the sequence is full (there are no available values), this will throw an exception with `errorId=\"SequenceFull\"`\r\n * @param from the sequence and scope to search\r\n * @returns the next available CodeValue in the sequence.\r\n */\r\n findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;\r\n\r\n /**\r\n * Find the highest currently used value for the supplied `SequenceScope`\r\n * @param from the sequence and scope to search\r\n * @returns the highest used value, or undefined if no values have been used.\r\n */\r\n findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;\r\n\r\n /** Determine whether a code is present in this CodeIndex by its Guid. */\r\n isCodePresent(guid: CodeService.CodeGuid): boolean;\r\n\r\n /** Get the data for a code in this CodeIndex by its Guid.\r\n * @returns the data for the code or undefined if no code is present for the supplied Guid.\r\n */\r\n getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;\r\n\r\n /** Look up a code by its Scope, Spec, and Value.\r\n * @returns the Guid of the code, or undefined if not present.\r\n */\r\n findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;\r\n\r\n /** Look up a code spec by its name\r\n * @throws if the spec is not present.\r\n */\r\n getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;\r\n\r\n /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */\r\n forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;\r\n\r\n /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */\r\n forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(specName: string, arg: CodeService.ElementCodeProps): void;\r\n }\r\n\r\n export type CodesDb = VersionedSqliteDb & WriteMethods & ReadMethods;\r\n\r\n export interface InternalWriteMethods extends WriteMethods {\r\n /** @internal */\r\n reserveFontId(props: CodeService.FontIndexProps): Promise<FontId>;\r\n /** @internal */\r\n reserveEmbeddedFaceDataId(facesKey: string): Promise<number>;\r\n /** @internal */\r\n reserveBisCodeSpecs(specs: CodeService.BisCodeSpecIndexProps[]): Promise<void>;\r\n }\r\n export interface InternalReadMethods extends ReadMethods {\r\n /** @internal */\r\n verifyBisCodeSpec(spec: CodeService.BisCodeSpecIndexProps): void;\r\n }\r\n\r\n export type InternalCodes = CodesDb & InternalWriteMethods & InternalReadMethods;\r\n\r\n /** @internal */\r\n const codeSequences = new Map<string, CodeSequence>();\r\n\r\n /** @internal */\r\n export let createForIModel: ((db: IModelDb) => Promise<CodeService>) | undefined;\r\n\r\n /** Register an instance of a`CodeSequence` so it can be looked up by name. */\r\n export function registerSequence(seq: CodeSequence) {\r\n codeSequences.set(seq.sequenceName, seq);\r\n }\r\n\r\n /** Get a previously registered `CodeSequence` by its name.\r\n * @throws if no sequence by that name was registered.\r\n */\r\n export function getSequence(name: string): CodeSequence {\r\n const seq = codeSequences.get(name);\r\n if (!seq)\r\n throw new Error(\"SequenceNotFound\", -1, `code sequence ${name} not found`);\r\n return seq;\r\n }\r\n\r\n /**\r\n * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.\r\n * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and\r\n * the `scope` member refers to the element Id of the scope element in the iModel. This helper function\r\n * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.\r\n */\r\n export function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec {\r\n const scopeGuid = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scopeGuid)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scopeGuid, specName: iModel.codeSpecs.getById(code.spec).name };\r\n }\r\n\r\n /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.\r\n * @see [[makeScopeAndSpec]] for explanation of why this is necessary.\r\n */\r\n export function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode {\r\n return {\r\n ...arg.props,\r\n value: arg.code.value,\r\n ...makeScopeAndSpec(arg.iModel, arg.code),\r\n };\r\n }\r\n\r\n /** The name of a code spec */\r\n export type CodeSpecName = string;\r\n\r\n /**\r\n * The name that identifies the \"originator\" of a code. Usually this is the Guid of the iModel from which a code was added,\r\n * but can also be used to identify a system or type from an external code service.\r\n */\r\n export type CodeOriginName = string;\r\n\r\n /** The name that identifies the \"author\" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */\r\n export type AuthorName = string;\r\n\r\n /** The value for a code. */\r\n export type CodeValue = string;\r\n\r\n /** The guid for a code. This identifies the real-world entity associated with the code. */\r\n export type CodeGuid = GuidString;\r\n\r\n /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */\r\n export type ScopeGuid = GuidString;\r\n\r\n /** An optional number associated with a code that may be used for \"status\" information. Values must be defined by applications. */\r\n export type CodeState = number;\r\n\r\n /** The return status of an iteration function. The value \"stop\" causes the iteration to terminate. */\r\n export type IterationReturn = void | \"stop\";\r\n\r\n /** An iteration function over codes in a code index. It is called with the Guid of a each code. */\r\n export type CodeIteration = (guid: GuidString) => IterationReturn;\r\n\r\n /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */\r\n export type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;\r\n\r\n /** Argument for reserving an array of new codes. */\r\n export interface ReserveCodesArgs {\r\n /** an array of proposed codes to reserve.\r\n * @note the guid of each proposed code must be supplied by the caller.\r\n */\r\n readonly codes: CodeService.ProposedCode[];\r\n /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Argument for reserving a code from a code sequence. */\r\n export interface ReserveNextArgs {\r\n /** the properties of the new code */\r\n readonly code: CodeService.ProposedCodeProps;\r\n /** The code sequence and scope for the new code. */\r\n readonly from: SequenceScope;\r\n }\r\n\r\n /** Argument for reserving an array of codes from a code sequence. */\r\n export interface ReserveNextArrayArgs {\r\n /** an array of proposed codes to reserve. */\r\n readonly codes: CodeService.ProposedCodeProps[];\r\n /** The code sequence and scope for the new codes. */\r\n readonly from: CodeService.SequenceScope;\r\n /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,\r\n * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.\r\n * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many\r\n * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.\r\n */\r\n readonly asManyAsPossible?: true;\r\n }\r\n\r\n /** Argument for updating an array of codes. */\r\n export interface UpdateCodesArgs {\r\n /** Properties of the codes to update */\r\n readonly props: CodeService.UpdatedCode[];\r\n /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Arguments for CodeService.makeProposedCode */\r\n export interface MakeProposedCodeArgs {\r\n readonly iModel: IModelDb;\r\n readonly code: Required<CodeProps>;\r\n readonly props: CodeService.CodeGuidStateJson;\r\n }\r\n\r\n /** The properties of an Element to be checked against the code index.\r\n * @see CodeService.verifyCode\r\n */\r\n export interface ElementCodeProps {\r\n /** iModel from which the code is being inserted/updated. */\r\n readonly iModel: IModelDb;\r\n /** Properties of the code */\r\n readonly props: {\r\n /** The imodel-specific code properties. */\r\n readonly code: CodeProps;\r\n /**\r\n * The federationGuid of the element being inserted or updated.\r\n * If federationGuid is defined, it is must match the value in the code index or an error is thrown.\r\n * If it is undefined, the value from the code index is returned here.\r\n */\r\n federationGuid?: GuidString;\r\n };\r\n }\r\n\r\n /** a name and a json object. Used for code specs, authors and origins. */\r\n export interface NameAndJson {\r\n readonly name: string;\r\n readonly json?: SettingsContainer;\r\n }\r\n\r\n /** A code Scope guid, and code spec name. */\r\n export interface ScopeAndSpec {\r\n readonly specName: CodeSpecName;\r\n readonly scopeGuid: ScopeGuid;\r\n }\r\n\r\n /** A code Scope guid, code spec, and code value. */\r\n export interface ScopeSpecAndValue extends ScopeAndSpec {\r\n readonly value: CodeValue;\r\n }\r\n\r\n /** The data held in a code index for a single code. */\r\n export interface CodeEntry {\r\n /** The name of the code spec for this code. */\r\n readonly specName: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scopeGuid: ScopeGuid;\r\n /** The value of this code. */\r\n readonly value: CodeValue;\r\n /** The guid of the entity this code identifies. */\r\n readonly guid: CodeGuid;\r\n /** the state of the code. May be undefined. */\r\n readonly state?: CodeState;\r\n /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */\r\n readonly origin: CodeOriginName;\r\n /** The name of the author of this code. May be undefined. */\r\n readonly author?: AuthorName;\r\n /** Option json properties associated with this code. May be undefined. */\r\n readonly json?: SettingsContainer;\r\n }\r\n\r\n /** A filter used to limit and/or sort the values returned by an iteration. */\r\n export interface ValueFilter {\r\n /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */\r\n readonly value?: string;\r\n /** The comparison operator for `value`. Default is `=` */\r\n readonly valueCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\r\n /** Order results ascending or descending. If not supplied, the results are unordered (random). */\r\n readonly orderBy?: \"ASC\" | \"DESC\";\r\n /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */\r\n readonly sqlExpression?: string;\r\n }\r\n\r\n /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */\r\n export interface CodeFilter extends ValueFilter {\r\n /** If supplied, limit results to only those with this spec */\r\n readonly specName?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scopeGuid?: ScopeGuid;\r\n /** If supplied, limit results to only those with this origin */\r\n readonly origin?: CodeOriginName;\r\n }\r\n\r\n /** Author and origin information supplied when codes are reserved. */\r\n export interface AuthorAndOrigin {\r\n /** The name of the individual or group for whom the code was reserved. */\r\n readonly author: Mutable<NameAndJson>;\r\n /** The identity of the \"originator\" of the code. This is usually a guid of an iModel, but can be any unique string. */\r\n readonly origin: Mutable<NameAndJson>;\r\n }\r\n\r\n /** The Guid, state, and json properties of a code. */\r\n export interface CodeGuidStateJson {\r\n /** The Guid of the new code. This must be always be supplied by the application. */\r\n readonly guid: CodeGuid;\r\n /** An optional value for the state of the code. */\r\n readonly state?: CodeState;\r\n /** An optional json object to be stored with the code. */\r\n readonly json?: SettingsContainer;\r\n }\r\n\r\n /** Properties of a \"proposed\" new code to be reserved.\r\n * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since\r\n * this may be used to reserve codes from a sequence where the value is generated.\r\n */\r\n export interface ProposedCodeProps extends CodeGuidStateJson {\r\n /** The value for the proposed code.\r\n * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.\r\n */\r\n value?: CodeValue;\r\n }\r\n\r\n /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */\r\n export type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;\r\n\r\n /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */\r\n export interface SequenceScope extends ScopeAndSpec {\r\n /** The code sequence. */\r\n readonly seq: CodeSequence;\r\n /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */\r\n readonly start?: CodeValue;\r\n }\r\n\r\n /** Properties of a code to be updated.\r\n * @note The `guid` member identifies the code to be updated and is required.\r\n * All other properties are optional - if `undefined`, its value is not changed.\r\n */\r\n export type UpdatedCode = MarkRequired<Partial<ProposedCode>, \"guid\">;\r\n\r\n /** A proposed code that could not be reserved due to some error. */\r\n export interface ReserveProblem {\r\n /** the proposed code that failed. */\r\n readonly code: ProposedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for this proposed code. */\r\n readonly message: string;\r\n }\r\n\r\n /** A update to a code that failed for some error. */\r\n export interface UpdateProblem {\r\n /** The properties of the code that was to be updated */\r\n readonly prop: UpdatedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for the update request. */\r\n readonly message: string;\r\n }\r\n\r\n /**\r\n * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and\r\n * a way to get the next valid value from an existing valid value.\r\n * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.\r\n */\r\n export interface CodeSequence {\r\n /** the name of this CodeSequence. */\r\n get sequenceName(): string;\r\n /** Get the first valid value for this CodeSequence */\r\n getFirstValue(): CodeValue;\r\n /** Get the last valid value for this CodeSequence */\r\n getLastValue(): CodeValue;\r\n /** Get the next valid value for this CodeSequence from the supplied value.\r\n * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId=\"SequenceFull\".\r\n * @return the next valid value according to the rules of this CodeSequence.\r\n */\r\n getNextValue(code: CodeValue): CodeValue;\r\n /** Determine whether this supplied value is valid for this sequence. */\r\n isValidCode(code: CodeValue): boolean;\r\n }\r\n\r\n /** @internal */\r\n export interface FontIndexProps {\r\n id?: number;\r\n fontType: FontType;\r\n fontName: string;\r\n }\r\n /** @internal */\r\n export interface BisCodeSpecIndexProps {\r\n id?: number;\r\n name: string;\r\n props: string;\r\n }\r\n\r\n /** Exception class thrown by `CodeService` methods. */\r\n export class Error extends BentleyError {\r\n /** A string that indicates the type of problem that caused the exception. */\r\n public readonly errorId: ErrorId;\r\n /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */\r\n public readonly problems?: ReserveProblem[] | UpdateProblem[];\r\n\r\n /** @internal */\r\n constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]) {\r\n super(errNum, message);\r\n this.errorId = errorId;\r\n this.problems = problems;\r\n }\r\n }\r\n\r\n /** Identifiers for exceptions thrown by `CodeService` methods.\r\n * @see [[CodeService.Error.errorId]]\r\n */\r\n export type ErrorId =\r\n \"BadIndexProps\" |\r\n \"CorruptIModel\" |\r\n \"CorruptIndex\" |\r\n \"DuplicateValue\" |\r\n \"GuidIsInUse\" |\r\n \"GuidMismatch\" |\r\n \"IllegalValue\" |\r\n \"InconsistentIModels\" |\r\n \"IndexReadonly\" |\r\n \"InvalidCodeScope\" |\r\n \"InvalidGuid\" |\r\n \"InvalidSequence\" |\r\n \"MissingCode\" |\r\n \"MissingGuid\" |\r\n \"MissingInput\" |\r\n \"MissingSpec\" |\r\n \"NoCodeIndex\" |\r\n \"NotAuthorized\" |\r\n \"SequenceFull\" |\r\n \"ReserveErrors\" |\r\n \"SequenceNotFound\" |\r\n \"SqlLogicError\" |\r\n \"UpdateErrors\" |\r\n \"ValueIsInUse\" |\r\n \"WrongVersion\";\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"CodeService.js","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,YAAY,EAAc,YAAY,EAAyB,MAAM,qBAAqB,CAAC;AAyCpG,aAAa;AACb,MAAM,KAAW,WAAW,CA8d3B;AA9dD,WAAiB,WAAW;IAiI1B,gBAAgB;IAChB,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAKtD,8EAA8E;IAC9E,SAAgB,gBAAgB,CAAC,GAAiB;QAChD,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAFe,4BAAgB,mBAE/B,CAAA;IAED;;OAEG;IACH,SAAgB,WAAW,CAAC,IAAY;QACtC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG;YACN,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,iBAAiB,IAAI,YAAY,CAAC,CAAC;QAC7E,OAAO,GAAG,CAAC;IACb,CAAC;IALe,uBAAW,cAK1B,CAAA;IAED;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,MAAgB,EAAE,IAAe;QAChE,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC;QAC/G,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,aAAa,EAAE,YAAY,CAAC,WAAW,EAAE,0CAA0C,CAAC,CAAC;QAEnH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3E,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAED;;OAEG;IACH,SAAgB,gBAAgB,CAAC,GAAqC;QACpE,OAAO;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;YACrB,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC;SAC1C,CAAC;IACJ,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAoQD,uDAAuD;IACvD,MAAa,KAAM,SAAQ,YAAY;QACrC,6EAA6E;QAC7D,OAAO,CAAU;QACjC,uGAAuG;QACvF,QAAQ,CAAsC;QAE9D,gBAAgB;QAChB,YAAY,OAAgB,EAAE,MAAc,EAAE,OAAe,EAAE,QAA6C;YAC1G,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,CAAC;KACF;IAZY,iBAAK,QAYjB,CAAA;AAgCH,CAAC,EA9dgB,WAAW,KAAX,WAAW,QA8d3B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\nimport { CodeProps, FontId, FontType } from \"@itwin/core-common\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelDb } from \"./IModelDb\";\nimport { SettingsContainer } from \"./workspace/Settings\";\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\n\n/**\n * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.\n * See [CodeService]($docs/learning/backend/CodeService).\n * @alpha\n */\nexport interface CodeService {\n /** @internal */\n close: () => void;\n\n initialize(iModel: IModelDb): Promise<void>;\n\n /** the index for external Codes for this CodeService */\n readonly externalCodes?: CloudSqlite.DbAccess<CodeService.CodesDb, CodeService.ReadMethods, CodeService.WriteMethods>;\n\n /** the index for internal Codes for this CodeService */\n readonly internalCodes?: CloudSqlite.DbAccess<CodeService.InternalCodes, CodeService.InternalReadMethods, CodeService.InternalWriteMethods>;\n\n /**\n * Application-supplied parameters for reserving new codes.\n */\n readonly appParams: CodeService.AuthorAndOrigin;\n\n /**\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\n * 1. has already been reserved,\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\n * the value from the code index is returned.\n *\n * If not, throw an exception. Elements with no CodeValue are ignored.\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\n */\n verifyCode(props: CodeService.ElementCodeProps): void;\n}\n\n/** @alpha */\nexport namespace CodeService {\n\n export interface WriteMethods {\n /** Add a new code spec to this code service.\n */\n addCodeSpec(val: CodeService.NameAndJson): Promise<void>;\n\n /**\n * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.\n * @returns the number of codes actually added.\n * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,\n * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since\n * any codes or code specs that are already in the index are ignored.\n */\n addAllCodes(iModel: IModelDb): Promise<number>;\n\n /**\n * Attempt to reserve a single proposed code.\n * @throws `CodeService.Error` if the proposed code cannot be reserved.\n */\n reserveCode(code: CodeService.ProposedCode): Promise<void>;\n\n /**\n * Attempt to reserve an array of proposed codes.\n * @returns number of codes actually reserved.\n * @see the `problems` member of the `CodeService.Error` exception\n * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.\n * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.\n */\n reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;\n\n /**\n * Attempt to reserve the next available code for a code sequence and scope.\n */\n reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;\n\n /**\n * Attempt to reserve an array of the next available codes for a code sequence and scope.\n * The length of the array determines the number of codes requested. The values for the new codes are returned\n * in the array, so they can be associated with the supplied GUIDs.\n * @returns number of codes actually reserved.\n */\n reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;\n\n /**\n * Update the properties of a single code.\n */\n updateCode(props: CodeService.UpdatedCode): Promise<void>;\n\n /**\n * Update the properties of an array codes.\n * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.\n * @returns number of codes actually updated.\n */\n updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;\n\n /** Delete an array of codes by their guids. */\n deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;\n }\n\n export interface ReadMethods {\n /**\n * Find the next available value for the supplied `SequenceScope`.\n * If the sequence is full (there are no available values), this will throw an exception with `errorId=\"SequenceFull\"`\n * @param from the sequence and scope to search\n * @returns the next available CodeValue in the sequence.\n */\n findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;\n\n /**\n * Find the highest currently used value for the supplied `SequenceScope`\n * @param from the sequence and scope to search\n * @returns the highest used value, or undefined if no values have been used.\n */\n findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;\n\n /** Determine whether a code is present in this CodeIndex by its Guid. */\n isCodePresent(guid: CodeService.CodeGuid): boolean;\n\n /** Get the data for a code in this CodeIndex by its Guid.\n * @returns the data for the code or undefined if no code is present for the supplied Guid.\n */\n getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;\n\n /** Look up a code by its Scope, Spec, and Value.\n * @returns the Guid of the code, or undefined if not present.\n */\n findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;\n\n /** Look up a code spec by its name\n * @throws if the spec is not present.\n */\n getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;\n\n /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */\n forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;\n\n /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */\n forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;\n\n /**\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\n * 1. has already been reserved,\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\n * the value from the code index is returned.\n *\n * If not, throw an exception. Elements with no CodeValue are ignored.\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\n */\n verifyCode(specName: string, arg: CodeService.ElementCodeProps): void;\n }\n\n export type CodesDb = VersionedSqliteDb & WriteMethods & ReadMethods;\n\n export interface InternalWriteMethods extends WriteMethods {\n /** @internal */\n reserveFontId(props: CodeService.FontIndexProps): Promise<FontId>;\n /** @internal */\n reserveEmbeddedFaceDataId(facesKey: string): Promise<number>;\n /** @internal */\n reserveBisCodeSpecs(specs: CodeService.BisCodeSpecIndexProps[]): Promise<void>;\n }\n export interface InternalReadMethods extends ReadMethods {\n /** @internal */\n verifyBisCodeSpec(spec: CodeService.BisCodeSpecIndexProps): void;\n }\n\n export type InternalCodes = CodesDb & InternalWriteMethods & InternalReadMethods;\n\n /** @internal */\n const codeSequences = new Map<string, CodeSequence>();\n\n /** @internal */\n export let createForIModel: ((db: IModelDb) => Promise<CodeService>) | undefined;\n\n /** Register an instance of a`CodeSequence` so it can be looked up by name. */\n export function registerSequence(seq: CodeSequence) {\n codeSequences.set(seq.sequenceName, seq);\n }\n\n /** Get a previously registered `CodeSequence` by its name.\n * @throws if no sequence by that name was registered.\n */\n export function getSequence(name: string): CodeSequence {\n const seq = codeSequences.get(name);\n if (!seq)\n throw new Error(\"SequenceNotFound\", -1, `code sequence ${name} not found`);\n return seq;\n }\n\n /**\n * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.\n * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and\n * the `scope` member refers to the element Id of the scope element in the iModel. This helper function\n * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.\n */\n export function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec {\n const scopeGuid = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\n if (undefined === scopeGuid)\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\n\n return { scopeGuid, specName: iModel.codeSpecs.getById(code.spec).name };\n }\n\n /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.\n * @see [[makeScopeAndSpec]] for explanation of why this is necessary.\n */\n export function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode {\n return {\n ...arg.props,\n value: arg.code.value,\n ...makeScopeAndSpec(arg.iModel, arg.code),\n };\n }\n\n /** The name of a code spec */\n export type CodeSpecName = string;\n\n /**\n * The name that identifies the \"originator\" of a code. Usually this is the Guid of the iModel from which a code was added,\n * but can also be used to identify a system or type from an external code service.\n */\n export type CodeOriginName = string;\n\n /** The name that identifies the \"author\" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */\n export type AuthorName = string;\n\n /** The value for a code. */\n export type CodeValue = string;\n\n /** The guid for a code. This identifies the real-world entity associated with the code. */\n export type CodeGuid = GuidString;\n\n /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */\n export type ScopeGuid = GuidString;\n\n /** An optional number associated with a code that may be used for \"status\" information. Values must be defined by applications. */\n export type CodeState = number;\n\n /** The return status of an iteration function. The value \"stop\" causes the iteration to terminate. */\n export type IterationReturn = void | \"stop\";\n\n /** An iteration function over codes in a code index. It is called with the Guid of a each code. */\n export type CodeIteration = (guid: GuidString) => IterationReturn;\n\n /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */\n export type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;\n\n /** Argument for reserving an array of new codes. */\n export interface ReserveCodesArgs {\n /** an array of proposed codes to reserve.\n * @note the guid of each proposed code must be supplied by the caller.\n */\n readonly codes: CodeService.ProposedCode[];\n /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */\n readonly allOrNothing?: true;\n }\n\n /** Argument for reserving a code from a code sequence. */\n export interface ReserveNextArgs {\n /** the properties of the new code */\n readonly code: CodeService.ProposedCodeProps;\n /** The code sequence and scope for the new code. */\n readonly from: SequenceScope;\n }\n\n /** Argument for reserving an array of codes from a code sequence. */\n export interface ReserveNextArrayArgs {\n /** an array of proposed codes to reserve. */\n readonly codes: CodeService.ProposedCodeProps[];\n /** The code sequence and scope for the new codes. */\n readonly from: CodeService.SequenceScope;\n /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,\n * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.\n * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many\n * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.\n */\n readonly asManyAsPossible?: true;\n }\n\n /** Argument for updating an array of codes. */\n export interface UpdateCodesArgs {\n /** Properties of the codes to update */\n readonly props: CodeService.UpdatedCode[];\n /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */\n readonly allOrNothing?: true;\n }\n\n /** Arguments for CodeService.makeProposedCode */\n export interface MakeProposedCodeArgs {\n readonly iModel: IModelDb;\n readonly code: Required<CodeProps>;\n readonly props: CodeService.CodeGuidStateJson;\n }\n\n /** The properties of an Element to be checked against the code index.\n * @see CodeService.verifyCode\n */\n export interface ElementCodeProps {\n /** iModel from which the code is being inserted/updated. */\n readonly iModel: IModelDb;\n /** Properties of the code */\n readonly props: {\n /** The imodel-specific code properties. */\n readonly code: CodeProps;\n /**\n * The federationGuid of the element being inserted or updated.\n * If federationGuid is defined, it is must match the value in the code index or an error is thrown.\n * If it is undefined, the value from the code index is returned here.\n */\n federationGuid?: GuidString;\n };\n }\n\n /** a name and a json object. Used for code specs, authors and origins. */\n export interface NameAndJson {\n readonly name: string;\n readonly json?: SettingsContainer;\n }\n\n /** A code Scope guid, and code spec name. */\n export interface ScopeAndSpec {\n readonly specName: CodeSpecName;\n readonly scopeGuid: ScopeGuid;\n }\n\n /** A code Scope guid, code spec, and code value. */\n export interface ScopeSpecAndValue extends ScopeAndSpec {\n readonly value: CodeValue;\n }\n\n /** The data held in a code index for a single code. */\n export interface CodeEntry {\n /** The name of the code spec for this code. */\n readonly specName: CodeSpecName;\n /** The guid of the entity that provides the scope for this code. */\n readonly scopeGuid: ScopeGuid;\n /** The value of this code. */\n readonly value: CodeValue;\n /** The guid of the entity this code identifies. */\n readonly guid: CodeGuid;\n /** the state of the code. May be undefined. */\n readonly state?: CodeState;\n /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */\n readonly origin: CodeOriginName;\n /** The name of the author of this code. May be undefined. */\n readonly author?: AuthorName;\n /** Option json properties associated with this code. May be undefined. */\n readonly json?: SettingsContainer;\n }\n\n /** A filter used to limit and/or sort the values returned by an iteration. */\n export interface ValueFilter {\n /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */\n readonly value?: string;\n /** The comparison operator for `value`. Default is `=` */\n readonly valueCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\n /** Order results ascending or descending. If not supplied, the results are unordered (random). */\n readonly orderBy?: \"ASC\" | \"DESC\";\n /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */\n readonly sqlExpression?: string;\n }\n\n /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */\n export interface CodeFilter extends ValueFilter {\n /** If supplied, limit results to only those with this spec */\n readonly specName?: CodeSpecName;\n /** If supplied, limit results to only those with this scope Guid */\n readonly scopeGuid?: ScopeGuid;\n /** If supplied, limit results to only those with this origin */\n readonly origin?: CodeOriginName;\n }\n\n /** Author and origin information supplied when codes are reserved. */\n export interface AuthorAndOrigin {\n /** The name of the individual or group for whom the code was reserved. */\n readonly author: Mutable<NameAndJson>;\n /** The identity of the \"originator\" of the code. This is usually a guid of an iModel, but can be any unique string. */\n readonly origin: Mutable<NameAndJson>;\n }\n\n /** The Guid, state, and json properties of a code. */\n export interface CodeGuidStateJson {\n /** The Guid of the new code. This must be always be supplied by the application. */\n readonly guid: CodeGuid;\n /** An optional value for the state of the code. */\n readonly state?: CodeState;\n /** An optional json object to be stored with the code. */\n readonly json?: SettingsContainer;\n }\n\n /** Properties of a \"proposed\" new code to be reserved.\n * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since\n * this may be used to reserve codes from a sequence where the value is generated.\n */\n export interface ProposedCodeProps extends CodeGuidStateJson {\n /** The value for the proposed code.\n * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.\n */\n value?: CodeValue;\n }\n\n /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */\n export type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;\n\n /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */\n export interface SequenceScope extends ScopeAndSpec {\n /** The code sequence. */\n readonly seq: CodeSequence;\n /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */\n readonly start?: CodeValue;\n }\n\n /** Properties of a code to be updated.\n * @note The `guid` member identifies the code to be updated and is required.\n * All other properties are optional - if `undefined`, its value is not changed.\n */\n export type UpdatedCode = MarkRequired<Partial<ProposedCode>, \"guid\">;\n\n /** A proposed code that could not be reserved due to some error. */\n export interface ReserveProblem {\n /** the proposed code that failed. */\n readonly code: ProposedCode;\n /** the reason for the failure */\n readonly errorId: ErrorId;\n /** the error message from the exception for this proposed code. */\n readonly message: string;\n }\n\n /** A update to a code that failed for some error. */\n export interface UpdateProblem {\n /** The properties of the code that was to be updated */\n readonly prop: UpdatedCode;\n /** the reason for the failure */\n readonly errorId: ErrorId;\n /** the error message from the exception for the update request. */\n readonly message: string;\n }\n\n /**\n * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and\n * a way to get the next valid value from an existing valid value.\n * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.\n */\n export interface CodeSequence {\n /** the name of this CodeSequence. */\n get sequenceName(): string;\n /** Get the first valid value for this CodeSequence */\n getFirstValue(): CodeValue;\n /** Get the last valid value for this CodeSequence */\n getLastValue(): CodeValue;\n /** Get the next valid value for this CodeSequence from the supplied value.\n * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId=\"SequenceFull\".\n * @return the next valid value according to the rules of this CodeSequence.\n */\n getNextValue(code: CodeValue): CodeValue;\n /** Determine whether this supplied value is valid for this sequence. */\n isValidCode(code: CodeValue): boolean;\n }\n\n /** @internal */\n export interface FontIndexProps {\n id?: number;\n fontType: FontType;\n fontName: string;\n }\n /** @internal */\n export interface BisCodeSpecIndexProps {\n id?: number;\n name: string;\n props: string;\n }\n\n /** Exception class thrown by `CodeService` methods. */\n export class Error extends BentleyError {\n /** A string that indicates the type of problem that caused the exception. */\n public readonly errorId: ErrorId;\n /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */\n public readonly problems?: ReserveProblem[] | UpdateProblem[];\n\n /** @internal */\n constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]) {\n super(errNum, message);\n this.errorId = errorId;\n this.problems = problems;\n }\n }\n\n /** Identifiers for exceptions thrown by `CodeService` methods.\n * @see [[CodeService.Error.errorId]]\n */\n export type ErrorId =\n \"BadIndexProps\" |\n \"CorruptIModel\" |\n \"CorruptIndex\" |\n \"DuplicateValue\" |\n \"GuidIsInUse\" |\n \"GuidMismatch\" |\n \"IllegalValue\" |\n \"InconsistentIModels\" |\n \"IndexReadonly\" |\n \"InvalidCodeScope\" |\n \"InvalidGuid\" |\n \"InvalidSequence\" |\n \"MissingCode\" |\n \"MissingGuid\" |\n \"MissingInput\" |\n \"MissingSpec\" |\n \"NoCodeIndex\" |\n \"NotAuthorized\" |\n \"SequenceFull\" |\n \"ReserveErrors\" |\n \"SequenceNotFound\" |\n \"SqlLogicError\" |\n \"UpdateErrors\" |\n \"ValueIsInUse\" |\n \"WrongVersion\";\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAc,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAiB,QAAQ,EAAsB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAI9F;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;IAClC,OAAO,CAAW;IAClB,gBAAgB,GAAe,EAAE,CAAC;IAE1C,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC;YAC3B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACrG,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YACzB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,C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I,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Codes\r\n */\r\n\r\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CodeService } from \"./CodeService\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public @preview\r\n */\r\nexport class CodeSpecs {\r\n private static tableName = \"bis_CodeSpec\";\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n private findByName(name: string): Id64String | undefined {\r\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\r\n stmt.bindString(1, name);\r\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\r\n });\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n const id = this.findByName(name);\r\n if (!id)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\r\n return id;\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\r\n const iModel = this._imodel;\r\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\r\n if (this.findByName(spec.name))\r\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\r\n\r\n const internalCodes = iModel.codeService?.internalCodes;\r\n if (internalCodes) {\r\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\r\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\r\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\r\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\r\n internalCodes.reader.verifyBisCodeSpec(spec);\r\n } else {\r\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\r\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\r\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\r\n }\r\n\r\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\r\n stmt.bindInteger(1, id);\r\n stmt.bindString(2, spec.name);\r\n stmt.bindString(3, spec.props);\r\n const rc = stmt.step();\r\n if (rc !== DbResult.BE_SQLITE_DONE)\r\n throw new BentleyError(rc, \"Error inserting codeSpec\");\r\n });\r\n\r\n return Id64.fromLocalAndBriefcaseIds(id, 0);\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\r\n codeSpecOrName.id = id;\r\n return id;\r\n }\r\n if (props === undefined)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n\r\n if (typeof props === \"object\")\r\n return this.insertCodeSpec(codeSpecOrName, props);\r\n\r\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\r\n return this.insertCodeSpec(spec.name, spec.properties);\r\n }\r\n\r\n /** Update the Json properties of an existing CodeSpec.\r\n * @param codeSpec The codeSpec holding Json properties values to update\r\n * @throws if unable to update the codeSpec.\r\n */\r\n public updateProperties(codeSpec: CodeSpec): void {\r\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\r\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\r\n stmt.bindId(2, codeSpec.id);\r\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\r\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\r\n });\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\r\n stmt.bindId(1, id);\r\n if (!stmt.nextRow())\r\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\r\n\r\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IA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IAAI,QAAQ,CAAC,cAAc,KAAK,IAAI,CAAC,IAAI,EAAE;gBACzC,MAAM,IAAI,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,EAAc;QACxB,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,mCAAmC,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;YACpH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,IAAI,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Codes\n */\n\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\n\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public @preview\n */\nexport class CodeSpecs {\n private static tableName = \"bis_CodeSpec\";\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n private findByName(name: string): Id64String | undefined {\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\n stmt.bindString(1, name);\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\n });\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n const id = this.findByName(name);\n if (!id)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return id;\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch {\n return false;\n }\n }\n\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\n const iModel = this._imodel;\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\n if (this.findByName(spec.name))\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\n\n const internalCodes = iModel.codeService?.internalCodes;\n if (internalCodes) {\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\n internalCodes.reader.verifyBisCodeSpec(spec);\n } else {\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\n }\n\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\n stmt.bindInteger(1, id);\n stmt.bindString(2, spec.name);\n stmt.bindString(3, spec.props);\n const rc = stmt.step();\n if (rc !== DbResult.BE_SQLITE_DONE)\n throw new BentleyError(rc, \"Error inserting codeSpec\");\n });\n\n return Id64.fromLocalAndBriefcaseIds(id, 0);\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n */\n public insert(codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\n if (codeSpecOrName instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\n codeSpecOrName.id = id;\n return id;\n }\n if (props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrName, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param codeSpec The codeSpec holding Json properties values to update\n * @throws if unable to update the codeSpec.\n */\n public updateProperties(codeSpec: CodeSpec): void {\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\n stmt.bindId(2, codeSpec.id);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\n });\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\n stmt.bindId(1, id);\n if (!stmt.nextRow())\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\n\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ConcurrentQuery.js","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AACA;;;+FAG+F;AAC/F,OAAO,EAAiF,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKlI,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAC1B,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAgD,EAAE,OAAuB;QAC/G,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,OAAO,CAAC,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC;YACnC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA2B,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAgD,EAAE,OAAsB;QAC7G,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YAC7C,OAAO,CAAC,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC;YACpC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA0B,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACM,MAAM,CAAC,WAAW,CAAC,IAAgD,EAAE,MAAsB;QAChG,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,QAAQ,CAAC,IAAgD;QACrE,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { IModelJsNative } from \"@bentley/imodeljs-native\";\r\n/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse, DbRequestKind } from \"@itwin/core-common\";\r\n\r\n/** @internal */\r\nexport type OnResponse = (response: Response) => void;\r\n\r\n/** @internal */\r\nexport class ConcurrentQuery {\r\n /** @internal */\r\n public static async executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse> {\r\n return new Promise<DbQueryResponse>((resolve) => {\r\n request.kind = DbRequestKind.ECSql;\r\n conn.concurrentQueryExecute(request as any, (response: any) => {\r\n resolve(response as DbQueryResponse);\r\n });\r\n });\r\n }\r\n /** @internal */\r\n public static async executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse> {\r\n return new Promise<DbBlobResponse>((resolve) => {\r\n request.kind = DbRequestKind.BlobIO;\r\n conn.concurrentQueryExecute(request as any, (response: any) => {\r\n resolve(response as DbBlobResponse);\r\n });\r\n });\r\n }\r\n public static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig {\r\n return conn.concurrentQueryResetConfig(config);\r\n }\r\n public static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb) {\r\n conn.concurrentQueryShutdown();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ConcurrentQuery.js","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AACA;;;+FAG+F;AAC/F,OAAO,EAAiF,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKlI,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAC1B,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAgD,EAAE,OAAuB;QAC/G,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,OAAO,CAAC,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC;YACnC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA2B,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAgD,EAAE,OAAsB;QAC7G,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YAC7C,OAAO,CAAC,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC;YACpC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA0B,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACM,MAAM,CAAC,WAAW,CAAC,IAAgD,EAAE,MAAsB;QAChG,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,QAAQ,CAAC,IAAgD;QACrE,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { IModelJsNative } from \"@bentley/imodeljs-native\";\n/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse, DbRequestKind } from \"@itwin/core-common\";\n\n/** @internal */\nexport type OnResponse = (response: Response) => void;\n\n/** @internal */\nexport class ConcurrentQuery {\n /** @internal */\n public static async executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse> {\n return new Promise<DbQueryResponse>((resolve) => {\n request.kind = DbRequestKind.ECSql;\n conn.concurrentQueryExecute(request as any, (response: any) => {\n resolve(response as DbQueryResponse);\n });\n });\n }\n /** @internal */\n public static async executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse> {\n return new Promise<DbBlobResponse>((resolve) => {\n request.kind = DbRequestKind.BlobIO;\n conn.concurrentQueryExecute(request as any, (response: any) => {\n resolve(response as DbBlobResponse);\n });\n });\n }\n public static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig {\n return conn.concurrentQueryResetConfig(config);\n }\n public static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb) {\n conn.concurrentQueryShutdown();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomViewState3dCreator.js","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,iBAAiB,EAAyB,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,MAAM,cAAc,GAAG,qBAAqB,CAAC,wBAAwB,CAAC;AAEtE;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAC3B,OAAO,CAAW;IAC1B,YAAmB,MAAgB;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IACD;;;OAGG;IACI,KAAK,CAAC,wBAAwB,CAAC,OAAwC;QAC5E,IAAI,oBAAoB,CAAC;QACzB,IAAI,OAAO,EAAE,QAAQ,KAAK,SAAS;YACjC,oBAAoB,G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AAC,CAAC;QAEpG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kFAAkF;IAC1E,KAAK,CAAC,aAAa;QACzB,yFAAyF;QACzF,sGAAsG;QACtG,6JAA6J;QAC7J,MAAM,MAAM,GAAG,8FAA8F,CAAC;QAC9G,MAAM,gBAAgB,GAAG,sEAAsE,CAAC;QAEhG,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;QAC/D,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,MAAM,IAAI,gBAAgB,EAAE,CAAC,CAAC;QACrE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,aAAa,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;QAC9C,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEpB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;CACH","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { CompressedId64Set, Id64Array, Id64String, Logger, StopWatch } from \"@itwin/core-bentley\";\r\nimport { CustomViewState3dCreatorOptions, CustomViewState3dProps } from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.CustomViewState3dCreator;\r\n\r\n/**\r\n * Class which helps to generate a custom ViewState3d.\r\n * @internal\r\n */\r\nexport class CustomViewState3dCreator {\r\n private _imodel: IModelDb;\r\n public constructor(iModel: IModelDb) {\r\n this._imodel = iModel;\r\n }\r\n /** Gets default view state data such as category Ids and modelextents. If no model ids are passed in, all 3D models in the iModel are used.\r\n * @param [modelIds] Ids of models to display in the view.\r\n * @throws [IModelError]($common) If no 3d models are found in the iModel.\r\n */\r\n public async getCustomViewState3dData(options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps> {\r\n let decompressedModelIds;\r\n if (options?.modelIds !== undefined)\r\n decompressedModelIds = CompressedId64Set.decompressArray(options.modelIds);\r\n\r\n const models: Id64Array = decompressedModelIds ?? await this._getAllModels();\r\n const categories: Id64Array = await this._getAllCategories();\r\n const modelExtents: Range3d = await this._getModelExtents(models);\r\n return {\r\n modelIds: CompressedId64Set.sortAndCompress(models),\r\n categoryIds: CompressedId64Set.sortAndCompress(categories),\r\n modelExtents: modelExtents.toJSON(),\r\n };\r\n }\r\n\r\n private async _getAllCategories(): Promise<Id64Array> {\r\n // Only use categories with elements in them\r\n Logger.logInfo(loggerCategory, \"Starting getAllCategories query.\");\r\n const query = `SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)`;\r\n const categories: Id64Array = await this._executeQuery(query);\r\n Logger.logInfo(loggerCategory, \"Finished getAllCategories query.\");\r\n return categories;\r\n }\r\n\r\n /** Compute the union of the extents of all the specified models. */\r\n private async _getModelExtents(modelIds: Id64String[]): Promise<Range3d> {\r\n if (modelIds.length === 0)\r\n return new Range3d();\r\n\r\n const timer = new StopWatch(\"getModelExtents query\", true);\r\n const range = await this._imodel.models.queryRange(modelIds);\r\n\r\n timer.stop();\r\n Logger.logInfo(loggerCategory, \"Finished getModelExtents query.\", { timeElapsedMs: timer.elapsed });\r\n\r\n return range;\r\n }\r\n\r\n /** Get the Ids of all spatially-located, non-template 3d models in the iModel. */\r\n private async _getAllModels(): Promise<Id64Array> {\r\n // Note: IsNotSpatiallyLocated was introduced in a later version of the BisCore ECSchema.\r\n // If the iModel has an earlier version, the statement will throw because the property does not exist.\r\n // If the iModel was created from an earlier version and later upgraded to a newer version, the property may be NULL for models created prior to the upgrade.\r\n const select = \"SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false\";\r\n const spatialCriterion = \"AND (IsNotSpatiallyLocated IS NULL OR IsNotSpatiallyLocated = false)\";\r\n\r\n let models = [];\r\n Logger.logInfo(loggerCategory, \"Starting getAllModels query.\");\r\n try {\r\n models = await this._executeQuery(`${select} ${spatialCriterion}`);\r\n } catch {\r\n models = await this._executeQuery(select);\r\n }\r\n\r\n Logger.logInfo(loggerCategory, \"Finished getAllModels query.\");\r\n return models;\r\n }\r\n\r\n private _executeQuery = async (query: string) => {\r\n const rows = [];\r\n for await (const row of this._imodel.createQueryReader(query))\r\n rows.push(row.id);\r\n\r\n return rows;\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"CustomViewState3dCreator.js","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,iBAAiB,EAAyB,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,MAAM,cAAc,GAAG,qBAAqB,CAAC,wBAAwB,CAAC;AAEtE;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAC3B,OAAO,CAAW;IAC1B,YAAmB,MAAgB;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IACD;;;OAGG;I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,CAAC,IAAI,EAAE,CAAC;QACb,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,iCAAiC,EAAE,EAAE,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAEpG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kFAAkF;IAC1E,KAAK,CAAC,aAAa;QACzB,yFAAyF;QACzF,sGAAsG;QACtG,6JAA6J;QAC7J,MAAM,MAAM,GAAG,8FAA8F,CAAC;QAC9G,MAAM,gBAAgB,GAAG,sEAAsE,CAAC;QAEhG,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;QAC/D,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,MAAM,IAAI,gBAAgB,EAAE,CAAC,CAAC;QACrE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,aAAa,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;QAC9C,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEpB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;CACH","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { CompressedId64Set, Id64Array, Id64String, Logger, StopWatch } from \"@itwin/core-bentley\";\nimport { CustomViewState3dCreatorOptions, CustomViewState3dProps } from \"@itwin/core-common\";\nimport { Range3d } from \"@itwin/core-geometry\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelDb } from \"./IModelDb\";\n\nconst loggerCategory = BackendLoggerCategory.CustomViewState3dCreator;\n\n/**\n * Class which helps to generate a custom ViewState3d.\n * @internal\n */\nexport class CustomViewState3dCreator {\n private _imodel: IModelDb;\n public constructor(iModel: IModelDb) {\n this._imodel = iModel;\n }\n /** Gets default view state data such as category Ids and modelextents. If no model ids are passed in, all 3D models in the iModel are used.\n * @param [modelIds] Ids of models to display in the view.\n * @throws [IModelError]($common) If no 3d models are found in the iModel.\n */\n public async getCustomViewState3dData(options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps> {\n let decompressedModelIds;\n if (options?.modelIds !== undefined)\n decompressedModelIds = CompressedId64Set.decompressArray(options.modelIds);\n\n const models: Id64Array = decompressedModelIds ?? await this._getAllModels();\n const categories: Id64Array = await this._getAllCategories();\n const modelExtents: Range3d = await this._getModelExtents(models);\n return {\n modelIds: CompressedId64Set.sortAndCompress(models),\n categoryIds: CompressedId64Set.sortAndCompress(categories),\n modelExtents: modelExtents.toJSON(),\n };\n }\n\n private async _getAllCategories(): Promise<Id64Array> {\n // Only use categories with elements in them\n Logger.logInfo(loggerCategory, \"Starting getAllCategories query.\");\n const query = `SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)`;\n const categories: Id64Array = await this._executeQuery(query);\n Logger.logInfo(loggerCategory, \"Finished getAllCategories query.\");\n return categories;\n }\n\n /** Compute the union of the extents of all the specified models. */\n private async _getModelExtents(modelIds: Id64String[]): Promise<Range3d> {\n if (modelIds.length === 0)\n return new Range3d();\n\n const timer = new StopWatch(\"getModelExtents query\", true);\n const range = await this._imodel.models.queryRange(modelIds);\n\n timer.stop();\n Logger.logInfo(loggerCategory, \"Finished getModelExtents query.\", { timeElapsedMs: timer.elapsed });\n\n return range;\n }\n\n /** Get the Ids of all spatially-located, non-template 3d models in the iModel. */\n private async _getAllModels(): Promise<Id64Array> {\n // Note: IsNotSpatiallyLocated was introduced in a later version of the BisCore ECSchema.\n // If the iModel has an earlier version, the statement will throw because the property does not exist.\n // If the iModel was created from an earlier version and later upgraded to a newer version, the property may be NULL for models created prior to the upgrade.\n const select = \"SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false\";\n const spatialCriterion = \"AND (IsNotSpatiallyLocated IS NULL OR IsNotSpatiallyLocated = false)\";\n\n let models = [];\n Logger.logInfo(loggerCategory, \"Starting getAllModels query.\");\n try {\n models = await this._executeQuery(`${select} ${spatialCriterion}`);\n } catch {\n models = await this._executeQuery(select);\n }\n\n Logger.logInfo(loggerCategory, \"Finished getAllModels query.\");\n return models;\n }\n\n private _executeQuery = async (query: string) => {\n const rows = [];\n for await (const row of this._imodel.createQueryReader(query))\n rows.push(row.id);\n\n return rows;\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,MAAM,EAAY,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,0BAA0B;AAE1B,MAAM,cAAc,GAAW,qBAAqB,CAAC,QAAQ,CAAC;AAwC9D;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACzB,MAAM,CAAU,cAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,E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AAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAC5C,YAAY,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAC3C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iEAAiE;IAC1D,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,MAAM,aAAa,GAA4B,EAAE,CAAC;QAClD,OAAO;YACL,WAAW,EAAE,UAAU,CAAC,kBAAkB;YAC1C,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,4DAA4D;YAC5G,aAAa,EAAE,4BAA4B;SAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as os from \"os\";\r\nimport * as process from \"process\";\r\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { RpcInterfaceEndpoints } from \"@itwin/core-common\";\r\n\r\n// cspell:ignore ppid elap\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.DevTools;\r\n\r\ninterface StringIndexedObject<T> {\r\n [index: string]: T;\r\n}\r\n\r\n/**\r\n * Performance and Memory statistics of backend\r\n * @internal\r\n */\r\nexport interface DevToolsStats {\r\n os: DevToolsOsStats;\r\n process: DevToolsProcessStats;\r\n}\r\n\r\n/**\r\n * OS stats of backend\r\n * @internal\r\n */\r\nexport interface DevToolsOsStats {\r\n platform: NodeJS.Platform;\r\n hostname: string;\r\n totalmem: number;\r\n freemem: number;\r\n uptime: number;\r\n cpus: os.CpuInfo[];\r\n cpuUsage: number;\r\n}\r\n\r\n/**\r\n * Process stats of backend\r\n * @internal\r\n */\r\nexport interface DevToolsProcessStats {\r\n uptime: number;\r\n pid: number;\r\n ppid: number;\r\n memoryUsage: NodeJS.MemoryUsage;\r\n}\r\n\r\n/** Utility to format the JSON created by DevTools.stats() to include the appropriate units\r\n * @internal\r\n */\r\nexport class DevToolsStatsFormatter {\r\n private static readonly _megaByteProps = [\"totalmem\", \"freemem\", \"rss\", \"heapTotal\", \"heapUsed\", \"external\"];\r\n private static readonly _percentProps = [\"user\", \"nice\", \"sys\", \"idle\", \"irq\", \"cpuUsage\"];\r\n private static readonly _mHzProps = [\"speed\"];\r\n private static readonly _secondsProps = [\"uptime\"];\r\n\r\n /** Replacer that includes units - can be used with JSON.stringify() */\r\n private static _replacer = (key: string, value: any) => {\r\n if (DevToolsStatsFormatter._megaByteProps.includes(key))\r\n return `${value.toFixed()} MB`;\r\n if (DevToolsStatsFormatter._percentProps.includes(key))\r\n return `${value.toFixed()}%`;\r\n if (DevToolsStatsFormatter._mHzProps.includes(key))\r\n return `${value.toString()} MHz`;\r\n if (DevToolsStatsFormatter._secondsProps.includes(key))\r\n return `${value.toFixed()} secs`;\r\n return value;\r\n };\r\n\r\n /** Converts the input stats to another JSON object with the appropriate units setup for various fields */\r\n public static toFormattedJson(stats: any) {\r\n // Serialize the stats to a string with a replacer that sets up units during the serialization\r\n const statsStr = JSON.stringify(stats, DevToolsStatsFormatter._replacer);\r\n\r\n // Deserialize back to JSON\r\n return JSON.parse(statsStr);\r\n }\r\n}\r\n\r\n/**\r\n * Internal diagnostic utility\r\n * @internal\r\n */\r\nexport class DevTools {\r\n\r\n /** Receives a ping and returns true */\r\n public static ping(): boolean {\r\n Logger.logInfo(loggerCategory, \"Received ping at backend\");\r\n return true;\r\n }\r\n\r\n private static hrtimeToMS(hrtime: any) {\r\n return hrtime[0] * 1000 + hrtime[1] / 1000000;\r\n }\r\n\r\n private static bytesToMegaBytes(bytes: number): number {\r\n const megaBytes = bytes / Math.pow(1024, 2);\r\n return Math.round(megaBytes * 100) / 100;\r\n }\r\n\r\n private static evaluateCpuUsage(): number {\r\n const NUMBER_OF_CPUS = os.cpus().length;\r\n const startTime = process.hrtime();\r\n const startUsage = process.cpuUsage();\r\n\r\n // spin the CPU for 500 milliseconds\r\n const now = Date.now();\r\n while (Date.now() - now < 500)\r\n ;\r\n\r\n const elapTime = process.hrtime(startTime);\r\n const elapUsage = process.cpuUsage(startUsage);\r\n\r\n const elapTimeMS = this.hrtimeToMS(elapTime);\r\n\r\n const elapUserMS = elapUsage.user / 1000; // microseconds to milliseconds\r\n const elapSystMS = elapUsage.system / 1000;\r\n const cpuPercent = Math.round((100 * (elapUserMS + elapSystMS) / elapTimeMS / NUMBER_OF_CPUS));\r\n\r\n return cpuPercent;\r\n }\r\n\r\n private static evaluateCpus(): os.CpuInfo[] {\r\n // Create a clone\r\n const srcCpus = os.cpus();\r\n const cpus = new Array<os.CpuInfo>(srcCpus.length);\r\n let ii = 0;\r\n for (const srcCpu of srcCpus)\r\n cpus[ii++] = { ...srcCpu };\r\n\r\n // Evaluate cpu usage as percentages\r\n for (const cpu of Object.values(cpus)) {\r\n const total = Object.values(cpu.times).reduce((_total: number, currValue) => _total += currValue, 0);\r\n const cpuTimes = cpu.times as StringIndexedObject<number>;\r\n for (const type of Object.keys(cpuTimes)) {\r\n const cpuPercent = Math.round(100 * cpuTimes[type] / total);\r\n cpuTimes[type] = cpuPercent;\r\n }\r\n }\r\n return cpus;\r\n }\r\n\r\n private static evaluateMemoryUsage() {\r\n // Create a clone\r\n const memUsage = { ...process.memoryUsage() } as NodeJS.MemoryUsage;\r\n const memUsageObj = (memUsage as any) as StringIndexedObject<number>;\r\n // Evaluate memory usage as mega bytes\r\n for (const type of Object.keys(memUsageObj)) {\r\n memUsageObj[type] = this.bytesToMegaBytes(memUsageObj[type]);\r\n }\r\n return memUsage;\r\n }\r\n\r\n private static evaluateProcessStats(): DevToolsProcessStats {\r\n return {\r\n uptime: process.uptime(),\r\n pid: process.pid,\r\n ppid: process.ppid,\r\n memoryUsage: this.evaluateMemoryUsage(),\r\n } as DevToolsProcessStats;\r\n }\r\n\r\n private static evaluateOsStats(): DevToolsOsStats {\r\n return {\r\n platform: os.platform(),\r\n hostname: os.hostname(),\r\n totalmem: this.bytesToMegaBytes(os.totalmem()),\r\n freemem: this.bytesToMegaBytes(os.freemem()),\r\n uptime: os.uptime(),\r\n cpus: this.evaluateCpus(),\r\n cpuUsage: this.evaluateCpuUsage(),\r\n } as DevToolsOsStats;\r\n }\r\n\r\n /** Returns JSON object with backend statistics */\r\n public static stats(): DevToolsStats {\r\n try {\r\n const stats = {\r\n os: this.evaluateOsStats(),\r\n process: this.evaluateProcessStats(),\r\n } as DevToolsStats;\r\n return stats;\r\n } catch (error) {\r\n Logger.logError(loggerCategory, \"Could not fetch stats at backend\");\r\n throw error;\r\n }\r\n }\r\n\r\n /** Sets up a log level at the backend and returns the old log level */\r\n public static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined {\r\n const oldLevel = Logger.getLevel(inLoggerCategory);\r\n Logger.logInfo(loggerCategory, `Setting log level`, () => ({ loggerCategory: inLoggerCategory, oldLevel, newLevel }));\r\n Logger.setLevel(inLoggerCategory, newLevel);\r\n IModelNative.platform.clearLogLevelCache();\r\n return oldLevel;\r\n }\r\n\r\n /** Obtains the backend application and iTwin.js Core versions */\r\n public static async versions() {\r\n const availableRpcs: RpcInterfaceEndpoints[] = [];\r\n return {\r\n application: IModelHost.applicationVersion,\r\n iTwinJs: require(\"../../package.json\").version, // eslint-disable-line @typescript-eslint/no-require-imports\r\n availableRpcs, // filled in on the frontend\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DevTools.js","sourceRoot":"","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,CAAC,YAAY,EAAE;YACzB,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE;SACf,CAAC;IACvB,CAAC;IAED,kDAAkD;IAC3C,MAAM,CAAC,KAAK;QACjB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG;gBACZ,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE;gBAC1B,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE;aACpB,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,kCAAkC,CAAC,CAAC;YACpE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,WAAW,CAAC,gBAAwB,EAAE,QAAkB;QACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAC5C,YAAY,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAC3C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iEAAiE;IAC1D,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,MAAM,aAAa,GAA4B,EAAE,CAAC;QAClD,OAAO;YACL,WAAW,EAAE,UAAU,CAAC,kBAAkB;YAC1C,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,4DAA4D;YAC5G,aAAa,EAAE,4BAA4B;SAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport * as os from \"os\";\nimport * as process from \"process\";\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { RpcInterfaceEndpoints } from \"@itwin/core-common\";\n\n// cspell:ignore ppid elap\n\nconst loggerCategory: string = BackendLoggerCategory.DevTools;\n\ninterface StringIndexedObject<T> {\n [index: string]: T;\n}\n\n/**\n * Performance and Memory statistics of backend\n * @internal\n */\nexport interface DevToolsStats {\n os: DevToolsOsStats;\n process: DevToolsProcessStats;\n}\n\n/**\n * OS stats of backend\n * @internal\n */\nexport interface DevToolsOsStats {\n platform: NodeJS.Platform;\n hostname: string;\n totalmem: number;\n freemem: number;\n uptime: number;\n cpus: os.CpuInfo[];\n cpuUsage: number;\n}\n\n/**\n * Process stats of backend\n * @internal\n */\nexport interface DevToolsProcessStats {\n uptime: number;\n pid: number;\n ppid: number;\n memoryUsage: NodeJS.MemoryUsage;\n}\n\n/** Utility to format the JSON created by DevTools.stats() to include the appropriate units\n * @internal\n */\nexport class DevToolsStatsFormatter {\n private static readonly _megaByteProps = [\"totalmem\", \"freemem\", \"rss\", \"heapTotal\", \"heapUsed\", \"external\"];\n private static readonly _percentProps = [\"user\", \"nice\", \"sys\", \"idle\", \"irq\", \"cpuUsage\"];\n private static readonly _mHzProps = [\"speed\"];\n private static readonly _secondsProps = [\"uptime\"];\n\n /** Replacer that includes units - can be used with JSON.stringify() */\n private static _replacer = (key: string, value: any) => {\n if (DevToolsStatsFormatter._megaByteProps.includes(key))\n return `${value.toFixed()} MB`;\n if (DevToolsStatsFormatter._percentProps.includes(key))\n return `${value.toFixed()}%`;\n if (DevToolsStatsFormatter._mHzProps.includes(key))\n return `${value.toString()} MHz`;\n if (DevToolsStatsFormatter._secondsProps.includes(key))\n return `${value.toFixed()} secs`;\n return value;\n };\n\n /** Converts the input stats to another JSON object with the appropriate units setup for various fields */\n public static toFormattedJson(stats: any) {\n // Serialize the stats to a string with a replacer that sets up units during the serialization\n const statsStr = JSON.stringify(stats, DevToolsStatsFormatter._replacer);\n\n // Deserialize back to JSON\n return JSON.parse(statsStr);\n }\n}\n\n/**\n * Internal diagnostic utility\n * @internal\n */\nexport class DevTools {\n\n /** Receives a ping and returns true */\n public static ping(): boolean {\n Logger.logInfo(loggerCategory, \"Received ping at backend\");\n return true;\n }\n\n private static hrtimeToMS(hrtime: any) {\n return hrtime[0] * 1000 + hrtime[1] / 1000000;\n }\n\n private static bytesToMegaBytes(bytes: number): number {\n const megaBytes = bytes / Math.pow(1024, 2);\n return Math.round(megaBytes * 100) / 100;\n }\n\n private static evaluateCpuUsage(): number {\n const NUMBER_OF_CPUS = os.cpus().length;\n const startTime = process.hrtime();\n const startUsage = process.cpuUsage();\n\n // spin the CPU for 500 milliseconds\n const now = Date.now();\n while (Date.now() - now < 500)\n ;\n\n const elapTime = process.hrtime(startTime);\n const elapUsage = process.cpuUsage(startUsage);\n\n const elapTimeMS = this.hrtimeToMS(elapTime);\n\n const elapUserMS = elapUsage.user / 1000; // microseconds to milliseconds\n const elapSystMS = elapUsage.system / 1000;\n const cpuPercent = Math.round((100 * (elapUserMS + elapSystMS) / elapTimeMS / NUMBER_OF_CPUS));\n\n return cpuPercent;\n }\n\n private static evaluateCpus(): os.CpuInfo[] {\n // Create a clone\n const srcCpus = os.cpus();\n const cpus = new Array<os.CpuInfo>(srcCpus.length);\n let ii = 0;\n for (const srcCpu of srcCpus)\n cpus[ii++] = { ...srcCpu };\n\n // Evaluate cpu usage as percentages\n for (const cpu of Object.values(cpus)) {\n const total = Object.values(cpu.times).reduce((_total: number, currValue) => _total += currValue, 0);\n const cpuTimes = cpu.times as StringIndexedObject<number>;\n for (const type of Object.keys(cpuTimes)) {\n const cpuPercent = Math.round(100 * cpuTimes[type] / total);\n cpuTimes[type] = cpuPercent;\n }\n }\n return cpus;\n }\n\n private static evaluateMemoryUsage() {\n // Create a clone\n const memUsage = { ...process.memoryUsage() } as NodeJS.MemoryUsage;\n const memUsageObj = (memUsage as any) as StringIndexedObject<number>;\n // Evaluate memory usage as mega bytes\n for (const type of Object.keys(memUsageObj)) {\n memUsageObj[type] = this.bytesToMegaBytes(memUsageObj[type]);\n }\n return memUsage;\n }\n\n private static evaluateProcessStats(): DevToolsProcessStats {\n return {\n uptime: process.uptime(),\n pid: process.pid,\n ppid: process.ppid,\n memoryUsage: this.evaluateMemoryUsage(),\n } as DevToolsProcessStats;\n }\n\n private static evaluateOsStats(): DevToolsOsStats {\n return {\n platform: os.platform(),\n hostname: os.hostname(),\n totalmem: this.bytesToMegaBytes(os.totalmem()),\n freemem: this.bytesToMegaBytes(os.freemem()),\n uptime: os.uptime(),\n cpus: this.evaluateCpus(),\n cpuUsage: this.evaluateCpuUsage(),\n } as DevToolsOsStats;\n }\n\n /** Returns JSON object with backend statistics */\n public static stats(): DevToolsStats {\n try {\n const stats = {\n os: this.evaluateOsStats(),\n process: this.evaluateProcessStats(),\n } as DevToolsStats;\n return stats;\n } catch (error) {\n Logger.logError(loggerCategory, \"Could not fetch stats at backend\");\n throw error;\n }\n }\n\n /** Sets up a log level at the backend and returns the old log level */\n public static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined {\n const oldLevel = Logger.getLevel(inLoggerCategory);\n Logger.logInfo(loggerCategory, `Setting log level`, () => ({ loggerCategory: inLoggerCategory, oldLevel, newLevel }));\n Logger.setLevel(inLoggerCategory, newLevel);\n IModelNative.platform.clearLogLevelCache();\n return oldLevel;\n }\n\n /** Obtains the backend application and iTwin.js Core versions */\n public static async versions() {\n const availableRpcs: RpcInterfaceEndpoints[] = [];\n return {\n application: IModelHost.applicationVersion,\n iTwinJs: require(\"../../package.json\").version, // eslint-disable-line @typescript-eslint/no-require-imports\n availableRpcs, // filled in on the frontend\n };\n }\n}\n"]}
@@ -1 +1 @@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,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;QAEjI,MAAM,QAAQ,GAAgC;YAC5C,GAAG,OAAO;YACV,SAAS;YACT,eAAe;SAChB,CAAC;QAEF,MAAM,iBAAiB,GAAwB;YAC7C,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,KAAK,EAAE,iBAAiB;YACxB,cAAc,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;YACpC,SAAS,EAAE,KAAK;SAEjB,CAAC;QAEF,OAAO,IAAI,cAAc,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IACD;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,OAAqC;QACzH,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ViewDefinitions\r\n */\r\n\r\nimport { CompressedId64Set, Id64, Id64Array, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, ColorDef, DisplayStyle3dProps, DisplayStyle3dSettings, DisplayStyle3dSettingsProps,\r\n DisplayStyleProps, DisplayStyleSettings, DisplayStyleSubCategoryProps, EntityReferenceSet, PlanProjectionSettingsProps, RenderSchedule, SkyBoxImageProps, ViewFlags,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement, RenderTimeline } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\r\nimport { DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\r\n\r\n/** A DisplayStyle defines the parameters for 'styling' the contents of a view.\r\n * Internally a DisplayStyle consists of a dictionary of several named 'styles' describing specific aspects of the display style as a whole.\r\n * Many ViewDefinitions may share the same DisplayStyle.\r\n * @public @preview\r\n */\r\nexport abstract class DisplayStyle extends DefinitionElement {\r\n public static override get className(): string { return \"DisplayStyle\"; }\r\n public abstract get settings(): DisplayStyleSettings;\r\n\r\n protected constructor(props: DisplayStyleProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n\r\n /** @beta */\r\n public static override deserialize(props: DeserializeEntityArgs): DisplayStyleProps {\r\n const elProps = super.deserialize(props) as DisplayStyleProps;\r\n const displayOptions = props.options?.element?.displayStyle;\r\n // Uncompress excludedElements if they are compressed\r\n if (!displayOptions?.compressExcludedElementIds && elProps.jsonProperties?.styles?.excludedElements) {\r\n const excludedElements = elProps.jsonProperties.styles.excludedElements;\r\n if (typeof excludedElements === \"string\" && excludedElements.startsWith(\"+\")) {\r\n const ids: string[] = [];\r\n CompressedId64Set.decompressSet(excludedElements).forEach((id: string) => {\r\n ids.push(id);\r\n });\r\n elProps.jsonProperties.styles.excludedElements = ids;\r\n }\r\n }\r\n // Omit Schedule Script Element Ids if the option is set\r\n if (displayOptions?.omitScheduleScriptElementIds && elProps.jsonProperties?.styles?.scheduleScript) {\r\n const scheduleScript: RenderSchedule.ScriptProps = elProps.jsonProperties.styles.scheduleScript;\r\n elProps.jsonProperties.styles.scheduleScript = RenderSchedule.Script.removeScheduleScriptElementIds(scheduleScript);\r\n }\r\n return elProps;\r\n }\r\n\r\n /** @beta */\r\n public static override serialize(props: DisplayStyleProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n return inst;\r\n }\r\n\r\n /** Create a Code for a DisplayStyle given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the DisplayStyle and provides the scope for its name.\r\n * @param codeValue The DisplayStyle name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.displayStyle);\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n for (const [id] of this.settings.subCategoryOverrides) {\r\n referenceIds.addElement(id);\r\n }\r\n\r\n for (const excludedElementId of this.settings.excludedElementIds)\r\n referenceIds.addElement(excludedElementId);\r\n\r\n if (this.settings.renderTimeline) {\r\n referenceIds.addElement(this.settings.renderTimeline);\r\n } else {\r\n const script = this.loadScheduleScript();\r\n if (script)\r\n script.script.discloseIds(referenceIds);\r\n }\r\n }\r\n\r\n /** @alpha */\r\n protected static override async onCloned(context: IModelElementCloneContext, sourceElementProps: DisplayStyleProps, targetElementProps: DisplayStyleProps): Promise<void> {\r\n await super.onCloned(context, sourceElementProps, targetElementProps);\r\n\r\n if (!context.isBetweenIModels || !targetElementProps.jsonProperties?.styles)\r\n return;\r\n\r\n const settings = targetElementProps.jsonProperties.styles;\r\n if (settings.subCategoryOvr) {\r\n const targetOverrides: DisplayStyleSubCategoryProps[] = [];\r\n for (const ovr of settings.subCategoryOvr) {\r\n ovr.subCategory;\r\n const targetSubCategoryId = context.findTargetElementId(Id64.fromJSON(ovr.subCategory));\r\n if (Id64.isValid(targetSubCategoryId))\r\n targetOverrides.push({...ovr, subCategory: targetSubCategoryId});\r\n }\r\n settings.subCategoryOvr = targetOverrides;\r\n }\r\n\r\n if (settings.excludedElements) {\r\n const excluded: Id64Array = \"string\" === typeof settings.excludedElements ? CompressedId64Set.decompressArray(settings.excludedElements) : settings.excludedElements;\r\n const excludedTargetElements: Id64Array = [];\r\n for (const excludedElement of excluded) {\r\n const remapped = context.findTargetElementId(excludedElement);\r\n if (Id64.isValid(remapped))\r\n excludedTargetElements.push(remapped);\r\n }\r\n\r\n if (0 === excludedTargetElements.length)\r\n delete settings.excludedElements;\r\n else\r\n settings.excludedElements = CompressedId64Set.compressIds(OrderedId64Iterable.sortArray(excludedTargetElements));\r\n }\r\n\r\n if (settings.renderTimeline) {\r\n const renderTimeline = context.findTargetElementId(settings.renderTimeline);\r\n if (Id64.isValid(renderTimeline))\r\n settings.renderTimeline = renderTimeline;\r\n else\r\n delete settings.renderTimeline;\r\n } else if (settings.scheduleScript) {\r\n const scheduleScript = RenderTimeline.remapScript(context, settings.scheduleScript);\r\n if (scheduleScript.length > 0)\r\n settings.scheduleScript = scheduleScript;\r\n else\r\n delete settings.scheduleScript;\r\n }\r\n }\r\n\r\n public loadScheduleScript(): RenderSchedule.ScriptReference | undefined {\r\n let script;\r\n let sourceId;\r\n if (this.settings.renderTimeline) {\r\n const timeline = this.iModel.elements.tryGetElement<RenderTimeline>(this.settings.renderTimeline);\r\n if (timeline) {\r\n script = RenderSchedule.Script.fromJSON(timeline.scriptProps);\r\n sourceId = timeline.id;\r\n }\r\n } else if (this.settings.scheduleScriptProps) {\r\n script = RenderSchedule.Script.fromJSON(this.settings.scheduleScriptProps);\r\n sourceId = this.id;\r\n }\r\n\r\n return undefined !== sourceId && undefined !== script ? new RenderSchedule.ScriptReference(sourceId, script) : undefined;\r\n }\r\n}\r\n\r\n/** A DisplayStyle for 2d views.\r\n * @public @preview\r\n */\r\nexport class DisplayStyle2d extends DisplayStyle {\r\n public static override get className(): string { return \"DisplayStyle2d\"; }\r\n private readonly _settings: DisplayStyleSettings;\r\n\r\n public get settings(): DisplayStyleSettings { return this._settings; }\r\n\r\n protected constructor(props: DisplayStyleProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this._settings = new DisplayStyleSettings(this.jsonProperties);\r\n }\r\n /** Create a DisplayStyle2d for use by a ViewDefinition.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the DisplayStyle2d\r\n * @returns The newly constructed DisplayStyle2d element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DisplayStyle2d {\r\n const displayStyleProps: DisplayStyleProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n model: definitionModelId,\r\n isPrivate: false,\r\n jsonProperties: {\r\n styles: {\r\n backgroundColor: 0,\r\n monochromeColor: ColorDef.white.toJSON(),\r\n viewflags: ViewFlags.defaults,\r\n },\r\n },\r\n };\r\n return new DisplayStyle2d(displayStyleProps, iModelDb);\r\n }\r\n /** Insert a DisplayStyle2d for use by a ViewDefinition.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new DisplayStyle2d into this DefinitionModel\r\n * @param name The name of the DisplayStyle2d\r\n * @returns The Id of the newly inserted DisplayStyle2d element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String {\r\n const displayStyle = this.create(iModelDb, definitionModelId, name);\r\n return iModelDb.elements.insertElement(displayStyle.toJSON());\r\n }\r\n}\r\n\r\n/** Describes initial settings for a new [[DisplayStyle3d]].\r\n * Most properties are inherited from [DisplayStyle3dSettingsProps]($common), but for backwards compatibility reasons, this interface is slightly awkward:\r\n * - It adds a `viewFlags` member that differs only in case and type from [DisplayStyleSettingsProps.viewflags]($common); and\r\n * - It extends the type of [DisplayStyleSettingsProps.backgroundColor]($common) to include [ColorDef]($common).\r\n * These idiosyncrasies will be addressed in a future version of core-backend.\r\n * @see [[DisplayStyle3d.create]].\r\n * @public @preview\r\n */\r\nexport interface DisplayStyleCreationOptions extends Omit<DisplayStyle3dSettingsProps, \"backgroundColor\" | \"scheduleScript\"> {\r\n /** If supplied, the [ViewFlags]($common) applied by the display style.\r\n * If undefined, [DisplayStyle3dSettingsProps.viewflags]($common) will be used if present (note the difference in case); otherwise, default-constructed [ViewFlags]($common) will be used.\r\n */\r\n viewFlags?: ViewFlags;\r\n backgroundColor?: ColorDef | number;\r\n}\r\n\r\n/** A DisplayStyle for 3d views.\r\n * See [how to create a DisplayStyle3d]$(docs/learning/backend/CreateElements.md#DisplayStyle3d).\r\n * @public @preview\r\n */\r\nexport class DisplayStyle3d extends DisplayStyle {\r\n public static override get className(): string { return \"DisplayStyle3d\"; }\r\n private readonly _settings: DisplayStyle3dSettings;\r\n\r\n public get settings(): DisplayStyle3dSettings { return this._settings; }\r\n\r\n protected constructor(props: DisplayStyle3dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this._settings = new DisplayStyle3dSettings(this.jsonProperties);\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n for (const textureId of this.settings.environment.sky.textureIds)\r\n referenceIds.addElement(textureId);\r\n\r\n if (this.settings.planProjectionSettings)\r\n for (const planProjectionSetting of this.settings.planProjectionSettings)\r\n referenceIds.addElement(planProjectionSetting[0]);\r\n\r\n const groups = this.settings.contours.groups;\r\n for (const group of groups) {\r\n const subCategories = group.subCategories;\r\n for (const subCategoryId of subCategories) {\r\n referenceIds.addElement(subCategoryId);\r\n }\r\n }\r\n }\r\n\r\n /** @alpha */\r\n protected static override async onCloned(context: IModelElementCloneContext, sourceElementProps: DisplayStyle3dProps, targetElementProps: DisplayStyle3dProps): Promise<void> {\r\n await super.onCloned(context, sourceElementProps, targetElementProps);\r\n if (context.isBetweenIModels) {\r\n const convertTexture = (id: string) => Id64.isValidId64(id) ? context.findTargetElementId(id) : id;\r\n\r\n const skyBoxImageProps: SkyBoxImageProps | undefined = targetElementProps?.jsonProperties?.styles?.environment?.sky?.image;\r\n if (skyBoxImageProps?.texture && Id64.isValidId64(skyBoxImageProps.texture))\r\n skyBoxImageProps.texture = convertTexture(skyBoxImageProps.texture);\r\n\r\n if (skyBoxImageProps?.textures) {\r\n skyBoxImageProps.textures.front = convertTexture(skyBoxImageProps.textures.front);\r\n skyBoxImageProps.textures.back = convertTexture(skyBoxImageProps.textures.back);\r\n skyBoxImageProps.textures.left = convertTexture(skyBoxImageProps.textures.left);\r\n skyBoxImageProps.textures.right = convertTexture(skyBoxImageProps.textures.right);\r\n skyBoxImageProps.textures.top = convertTexture(skyBoxImageProps.textures.top);\r\n skyBoxImageProps.textures.bottom = convertTexture(skyBoxImageProps.textures.bottom);\r\n }\r\n\r\n if (targetElementProps?.jsonProperties?.styles?.planProjections) {\r\n const remappedPlanProjections: { [modelId: string]: PlanProjectionSettingsProps } = {};\r\n for (const entry of Object.entries(targetElementProps.jsonProperties.styles.planProjections)) {\r\n const remappedModelId: Id64String = context.findTargetElementId(entry[0]);\r\n if (Id64.isValidId64(remappedModelId)) {\r\n remappedPlanProjections[remappedModelId] = entry[1];\r\n }\r\n }\r\n targetElementProps.jsonProperties.styles.planProjections = remappedPlanProjections;\r\n }\r\n\r\n const groups = targetElementProps?.jsonProperties?.styles?.contours?.groups;\r\n if (groups) {\r\n for (const group of groups) {\r\n if (group.subCategories) {\r\n const subCategories = CompressedId64Set.decompressArray(group.subCategories);\r\n const remappedSubCategories: Id64String[] = [];\r\n for (const subCategoryId of subCategories) {\r\n const remappedSubCategoryId: Id64String = context.findTargetElementId(subCategoryId);\r\n if (Id64.isValidId64(remappedSubCategoryId)) {\r\n remappedSubCategories.push(remappedSubCategoryId);\r\n }\r\n }\r\n group.subCategories = CompressedId64Set.sortAndCompress(remappedSubCategories);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Create a DisplayStyle3d for use by a ViewDefinition.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the DisplayStyle3d\r\n * @returns The newly constructed DisplayStyle3d element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): DisplayStyle3d {\r\n options = options ?? {};\r\n let viewflags = options.viewFlags?.toJSON();\r\n if (!viewflags)\r\n viewflags = options.viewflags ?? new ViewFlags().toJSON();\r\n\r\n const backgroundColor = options.backgroundColor instanceof ColorDef ? options.backgroundColor.toJSON() : options.backgroundColor;\r\n\r\n const settings: DisplayStyle3dSettingsProps = {\r\n ...options,\r\n viewflags,\r\n backgroundColor,\r\n };\r\n\r\n const displayStyleProps: DisplayStyle3dProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n model: definitionModelId,\r\n jsonProperties: { styles: settings },\r\n isPrivate: false,\r\n\r\n };\r\n\r\n return new DisplayStyle3d(displayStyleProps, iModelDb);\r\n }\r\n /**\r\n * Insert a DisplayStyle3d for use by a ViewDefinition.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]\r\n * @param name The name of the DisplayStyle3d\r\n * @returns The Id of the newly inserted DisplayStyle3d element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String {\r\n const displayStyle = this.create(iModelDb, definitionModelId, name, options);\r\n return iModelDb.elements.insertElement(displayStyle.toJSON());\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DisplayStyle.js","sourceRoot":"","sources":["../../src/DisplayStyle.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAyB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EACL,WAAW,EAAE,IAAI,EAA4B,QAAQ,EAAuB,sBAAsB,EAC/E,oBAAoB,EA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QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,KAAK,EAAE,iBAAiB;YACxB,cAAc,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;YACpC,SAAS,EAAE,KAAK;SAEjB,CAAC;QAEF,OAAO,IAAI,cAAc,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IACD;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,OAAqC;QACzH,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ViewDefinitions\n */\n\nimport { CompressedId64Set, Id64, Id64Array, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, ColorDef, DisplayStyle3dProps, DisplayStyle3dSettings, DisplayStyle3dSettingsProps,\n DisplayStyleProps, DisplayStyleSettings, DisplayStyleSubCategoryProps, EntityReferenceSet, PlanProjectionSettingsProps, RenderSchedule, SkyBoxImageProps, ViewFlags,\n} from \"@itwin/core-common\";\nimport { DefinitionElement, RenderTimeline } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\nimport { DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\n\n/** A DisplayStyle defines the parameters for 'styling' the contents of a view.\n * Internally a DisplayStyle consists of a dictionary of several named 'styles' describing specific aspects of the display style as a whole.\n * Many ViewDefinitions may share the same DisplayStyle.\n * @public @preview\n */\nexport abstract class DisplayStyle extends DefinitionElement {\n public static override get className(): string { return \"DisplayStyle\"; }\n public abstract get settings(): DisplayStyleSettings;\n\n protected constructor(props: DisplayStyleProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n /** @beta */\n public static override deserialize(props: DeserializeEntityArgs): DisplayStyleProps {\n const elProps = super.deserialize(props) as DisplayStyleProps;\n const displayOptions = props.options?.element?.displayStyle;\n // Uncompress excludedElements if they are compressed\n if (!displayOptions?.compressExcludedElementIds && elProps.jsonProperties?.styles?.excludedElements) {\n const excludedElements = elProps.jsonProperties.styles.excludedElements;\n if (typeof excludedElements === \"string\" && excludedElements.startsWith(\"+\")) {\n const ids: string[] = [];\n CompressedId64Set.decompressSet(excludedElements).forEach((id: string) => {\n ids.push(id);\n });\n elProps.jsonProperties.styles.excludedElements = ids;\n }\n }\n // Omit Schedule Script Element Ids if the option is set\n if (displayOptions?.omitScheduleScriptElementIds && elProps.jsonProperties?.styles?.scheduleScript) {\n const scheduleScript: RenderSchedule.ScriptProps = elProps.jsonProperties.styles.scheduleScript;\n elProps.jsonProperties.styles.scheduleScript = RenderSchedule.Script.removeScheduleScriptElementIds(scheduleScript);\n }\n return elProps;\n }\n\n /** @beta */\n public static override serialize(props: DisplayStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n return inst;\n }\n\n /** Create a Code for a DisplayStyle given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModelDb\n * @param scopeModelId The Id of the DefinitionModel that contains the DisplayStyle and provides the scope for its name.\n * @param codeValue The DisplayStyle name\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.displayStyle);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n for (const [id] of this.settings.subCategoryOverrides) {\n referenceIds.addElement(id);\n }\n\n for (const excludedElementId of this.settings.excludedElementIds)\n referenceIds.addElement(excludedElementId);\n\n if (this.settings.renderTimeline) {\n referenceIds.addElement(this.settings.renderTimeline);\n } else {\n const script = this.loadScheduleScript();\n if (script)\n script.script.discloseIds(referenceIds);\n }\n }\n\n /** @alpha */\n protected static override async onCloned(context: IModelElementCloneContext, sourceElementProps: DisplayStyleProps, targetElementProps: DisplayStyleProps): Promise<void> {\n await super.onCloned(context, sourceElementProps, targetElementProps);\n\n if (!context.isBetweenIModels || !targetElementProps.jsonProperties?.styles)\n return;\n\n const settings = targetElementProps.jsonProperties.styles;\n if (settings.subCategoryOvr) {\n const targetOverrides: DisplayStyleSubCategoryProps[] = [];\n for (const ovr of settings.subCategoryOvr) {\n ovr.subCategory;\n const targetSubCategoryId = context.findTargetElementId(Id64.fromJSON(ovr.subCategory));\n if (Id64.isValid(targetSubCategoryId))\n targetOverrides.push({...ovr, subCategory: targetSubCategoryId});\n }\n settings.subCategoryOvr = targetOverrides;\n }\n\n if (settings.excludedElements) {\n const excluded: Id64Array = \"string\" === typeof settings.excludedElements ? CompressedId64Set.decompressArray(settings.excludedElements) : settings.excludedElements;\n const excludedTargetElements: Id64Array = [];\n for (const excludedElement of excluded) {\n const remapped = context.findTargetElementId(excludedElement);\n if (Id64.isValid(remapped))\n excludedTargetElements.push(remapped);\n }\n\n if (0 === excludedTargetElements.length)\n delete settings.excludedElements;\n else\n settings.excludedElements = CompressedId64Set.compressIds(OrderedId64Iterable.sortArray(excludedTargetElements));\n }\n\n if (settings.renderTimeline) {\n const renderTimeline = context.findTargetElementId(settings.renderTimeline);\n if (Id64.isValid(renderTimeline))\n settings.renderTimeline = renderTimeline;\n else\n delete settings.renderTimeline;\n } else if (settings.scheduleScript) {\n const scheduleScript = RenderTimeline.remapScript(context, settings.scheduleScript);\n if (scheduleScript.length > 0)\n settings.scheduleScript = scheduleScript;\n else\n delete settings.scheduleScript;\n }\n }\n\n public loadScheduleScript(): RenderSchedule.ScriptReference | undefined {\n let script;\n let sourceId;\n if (this.settings.renderTimeline) {\n const timeline = this.iModel.elements.tryGetElement<RenderTimeline>(this.settings.renderTimeline);\n if (timeline) {\n script = RenderSchedule.Script.fromJSON(timeline.scriptProps);\n sourceId = timeline.id;\n }\n } else if (this.settings.scheduleScriptProps) {\n script = RenderSchedule.Script.fromJSON(this.settings.scheduleScriptProps);\n sourceId = this.id;\n }\n\n return undefined !== sourceId && undefined !== script ? new RenderSchedule.ScriptReference(sourceId, script) : undefined;\n }\n}\n\n/** A DisplayStyle for 2d views.\n * @public @preview\n */\nexport class DisplayStyle2d extends DisplayStyle {\n public static override get className(): string { return \"DisplayStyle2d\"; }\n private readonly _settings: DisplayStyleSettings;\n\n public get settings(): DisplayStyleSettings { return this._settings; }\n\n protected constructor(props: DisplayStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this._settings = new DisplayStyleSettings(this.jsonProperties);\n }\n /** Create a DisplayStyle2d for use by a ViewDefinition.\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the DisplayStyle2d\n * @returns The newly constructed DisplayStyle2d element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DisplayStyle2d {\n const displayStyleProps: DisplayStyleProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, definitionModelId, name),\n model: definitionModelId,\n isPrivate: false,\n jsonProperties: {\n styles: {\n backgroundColor: 0,\n monochromeColor: ColorDef.white.toJSON(),\n viewflags: ViewFlags.defaults,\n },\n },\n };\n return new DisplayStyle2d(displayStyleProps, iModelDb);\n }\n /** Insert a DisplayStyle2d for use by a ViewDefinition.\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DisplayStyle2d into this DefinitionModel\n * @param name The name of the DisplayStyle2d\n * @returns The Id of the newly inserted DisplayStyle2d element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String {\n const displayStyle = this.create(iModelDb, definitionModelId, name);\n return iModelDb.elements.insertElement(displayStyle.toJSON());\n }\n}\n\n/** Describes initial settings for a new [[DisplayStyle3d]].\n * Most properties are inherited from [DisplayStyle3dSettingsProps]($common), but for backwards compatibility reasons, this interface is slightly awkward:\n * - It adds a `viewFlags` member that differs only in case and type from [DisplayStyleSettingsProps.viewflags]($common); and\n * - It extends the type of [DisplayStyleSettingsProps.backgroundColor]($common) to include [ColorDef]($common).\n * These idiosyncrasies will be addressed in a future version of core-backend.\n * @see [[DisplayStyle3d.create]].\n * @public @preview\n */\nexport interface DisplayStyleCreationOptions extends Omit<DisplayStyle3dSettingsProps, \"backgroundColor\" | \"scheduleScript\"> {\n /** If supplied, the [ViewFlags]($common) applied by the display style.\n * If undefined, [DisplayStyle3dSettingsProps.viewflags]($common) will be used if present (note the difference in case); otherwise, default-constructed [ViewFlags]($common) will be used.\n */\n viewFlags?: ViewFlags;\n backgroundColor?: ColorDef | number;\n}\n\n/** A DisplayStyle for 3d views.\n * See [how to create a DisplayStyle3d]$(docs/learning/backend/CreateElements.md#DisplayStyle3d).\n * @public @preview\n */\nexport class DisplayStyle3d extends DisplayStyle {\n public static override get className(): string { return \"DisplayStyle3d\"; }\n private readonly _settings: DisplayStyle3dSettings;\n\n public get settings(): DisplayStyle3dSettings { return this._settings; }\n\n protected constructor(props: DisplayStyle3dProps, iModel: IModelDb) {\n super(props, iModel);\n this._settings = new DisplayStyle3dSettings(this.jsonProperties);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n for (const textureId of this.settings.environment.sky.textureIds)\n referenceIds.addElement(textureId);\n\n if (this.settings.planProjectionSettings)\n for (const planProjectionSetting of this.settings.planProjectionSettings)\n referenceIds.addElement(planProjectionSetting[0]);\n\n const groups = this.settings.contours.groups;\n for (const group of groups) {\n const subCategories = group.subCategories;\n for (const subCategoryId of subCategories) {\n referenceIds.addElement(subCategoryId);\n }\n }\n }\n\n /** @alpha */\n protected static override async onCloned(context: IModelElementCloneContext, sourceElementProps: DisplayStyle3dProps, targetElementProps: DisplayStyle3dProps): Promise<void> {\n await super.onCloned(context, sourceElementProps, targetElementProps);\n if (context.isBetweenIModels) {\n const convertTexture = (id: string) => Id64.isValidId64(id) ? context.findTargetElementId(id) : id;\n\n const skyBoxImageProps: SkyBoxImageProps | undefined = targetElementProps?.jsonProperties?.styles?.environment?.sky?.image;\n if (skyBoxImageProps?.texture && Id64.isValidId64(skyBoxImageProps.texture))\n skyBoxImageProps.texture = convertTexture(skyBoxImageProps.texture);\n\n if (skyBoxImageProps?.textures) {\n skyBoxImageProps.textures.front = convertTexture(skyBoxImageProps.textures.front);\n skyBoxImageProps.textures.back = convertTexture(skyBoxImageProps.textures.back);\n skyBoxImageProps.textures.left = convertTexture(skyBoxImageProps.textures.left);\n skyBoxImageProps.textures.right = convertTexture(skyBoxImageProps.textures.right);\n skyBoxImageProps.textures.top = convertTexture(skyBoxImageProps.textures.top);\n skyBoxImageProps.textures.bottom = convertTexture(skyBoxImageProps.textures.bottom);\n }\n\n if (targetElementProps?.jsonProperties?.styles?.planProjections) {\n const remappedPlanProjections: { [modelId: string]: PlanProjectionSettingsProps } = {};\n for (const entry of Object.entries(targetElementProps.jsonProperties.styles.planProjections)) {\n const remappedModelId: Id64String = context.findTargetElementId(entry[0]);\n if (Id64.isValidId64(remappedModelId)) {\n remappedPlanProjections[remappedModelId] = entry[1];\n }\n }\n targetElementProps.jsonProperties.styles.planProjections = remappedPlanProjections;\n }\n\n const groups = targetElementProps?.jsonProperties?.styles?.contours?.groups;\n if (groups) {\n for (const group of groups) {\n if (group.subCategories) {\n const subCategories = CompressedId64Set.decompressArray(group.subCategories);\n const remappedSubCategories: Id64String[] = [];\n for (const subCategoryId of subCategories) {\n const remappedSubCategoryId: Id64String = context.findTargetElementId(subCategoryId);\n if (Id64.isValidId64(remappedSubCategoryId)) {\n remappedSubCategories.push(remappedSubCategoryId);\n }\n }\n group.subCategories = CompressedId64Set.sortAndCompress(remappedSubCategories);\n }\n }\n }\n }\n }\n\n /** Create a DisplayStyle3d for use by a ViewDefinition.\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the DisplayStyle3d\n * @returns The newly constructed DisplayStyle3d element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): DisplayStyle3d {\n options = options ?? {};\n let viewflags = options.viewFlags?.toJSON();\n if (!viewflags)\n viewflags = options.viewflags ?? new ViewFlags().toJSON();\n\n const backgroundColor = options.backgroundColor instanceof ColorDef ? options.backgroundColor.toJSON() : options.backgroundColor;\n\n const settings: DisplayStyle3dSettingsProps = {\n ...options,\n viewflags,\n backgroundColor,\n };\n\n const displayStyleProps: DisplayStyle3dProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, definitionModelId, name),\n model: definitionModelId,\n jsonProperties: { styles: settings },\n isPrivate: false,\n\n };\n\n return new DisplayStyle3d(displayStyleProps, iModelDb);\n }\n /**\n * Insert a DisplayStyle3d for use by a ViewDefinition.\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]\n * @param name The name of the DisplayStyle3d\n * @returns The Id of the newly inserted DisplayStyle3d element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String {\n const displayStyle = this.create(iModelDb, definitionModelId, name, options);\n return iModelDb.elements.insertElement(displayStyle.toJSON());\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ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AChB,IAAW,CAAC,SAAS,CAAC;QACpB,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;SAWK;IACE,iBAAiB,CAAC,KAAa,EAAE,MAAoB,EAAE,MAAqB;QACjF,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAG;YACf,OAAO,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;gBACzC,OAAO,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;YACvE,CAAC;SACF,CAAC;QACF,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { assert, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements Disposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelNative.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public [Symbol.dispose](): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n /**\r\n * Attach an iModel file to this connection and load and register its schemas.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param fileName IModel file name\r\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\r\n */\r\n public attachDb(fileName: string, alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this[_nativeDb].attachDb(fileName, alias);\r\n }\r\n /**\r\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param alias identifer that was used in the call to [[attachDb]]\r\n */\r\n public detachDb(alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this.clearStatementCache();\r\n this[_nativeDb].detachDb(alias);\r\n }\r\n\r\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */\r\n public dispose(): void {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this[_nativeDb].abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n }\r\n\r\n /** Removes unused schemas from the database.\r\n *\r\n * If the removal was successful, the database is automatically saved to disk.\r\n * @param schemaNames Array of schema names to drop\r\n * @throws [IModelError]($common) if the database if the operation failed.\r\n * @alpha\r\n */\r\n public dropSchemas(schemaNames: string[]): void {\r\n if (schemaNames.length === 0)\r\n return;\r\n if (this[_nativeDb].schemaSyncEnabled())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot drop schemas when schema sync is enabled\");\r\n\r\n try {\r\n this[_nativeDb].dropSchemas(schemaNames);\r\n this.saveChanges('dropped unused schemas');\r\n } catch (error: any) {\r\n Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);\r\n this.abandonChanges();\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this[_nativeDb].getSchemaProps(name);\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withWriteStatement]]\r\n * @beta\r\n */\r\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(new ECSqlWriteStatement(stmt));\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withCachedWriteStatement]]\r\n * @beta\r\n */\r\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @beta\r\n */\r\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this[_nativeDb], logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get [_nativeDb](): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are streamed.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n}\r\n"]}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AC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,IAAW,CAAC,SAAS,CAAC;QACpB,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;SAWK;IACE,iBAAiB,CAAC,KAAa,EAAE,MAAoB,EAAE,MAAqB;QACjF,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAG;YACf,OAAO,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;gBACzC,OAAO,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;YACvE,CAAC;SACF,CAAC;QACF,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECDb\n */\nimport { assert, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\n\n/** Modes for how to open [ECDb]($backend) files.\n * @public\n */\nexport enum ECDbOpenMode {\n Readonly,\n ReadWrite,\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\n FileUpgrade,\n}\n\n/** An ECDb file\n * @public\n */\nexport class ECDb implements Disposable {\n private _nativeDb?: IModelJsNative.ECDb;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n\n /** only for tests\n * @internal\n */\n public resetSqliteCache(size: number) {\n this._sqliteStatementCache.clear();\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\n }\n\n constructor() {\n this._nativeDb = new IModelNative.platform.ECDb();\n }\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\n * ECDb object.\n */\n public [Symbol.dispose](): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n /**\n * Attach an iModel file to this connection and load and register its schemas.\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\n * @param fileName IModel file name\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\n */\n public attachDb(fileName: string, alias: string): void {\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\n }\n this[_nativeDb].attachDb(fileName, alias);\n }\n /**\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\n * @param alias identifer that was used in the call to [[attachDb]]\n */\n public detachDb(alias: string): void {\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\n }\n this.clearStatementCache();\n this[_nativeDb].detachDb(alias);\n }\n\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n\n /** Create an ECDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n public createDb(pathName: string): void {\n const status: DbResult = this[_nativeDb].createDb(pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the ECDb.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Returns true if the ECDb is open */\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this._statementCache.clear();\n this._sqliteStatementCache.clear();\n this[_nativeDb].closeDb();\n }\n\n /** @internal use to test statement caching */\n public clearStatementCache() {\n this._statementCache.clear();\n }\n\n /** @internal use to test statement caching */\n public getCachedStatementCount() {\n return this._statementCache.size;\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\n * @param changesetName The name of the operation that generated these changes.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public saveChanges(changesetName?: string): void {\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to save changes\");\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public abandonChanges(): void {\n const status: DbResult = this[_nativeDb].abandonChanges();\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to abandon changes\");\n }\n\n /** Import a schema.\n *\n * If the import was successful, the database is automatically saved to disk.\n * @param pathName Path to ECSchema XML file to import.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public importSchema(pathName: string): void {\n const status: DbResult = this[_nativeDb].importSchema(pathName);\n if (status !== DbResult.BE_SQLITE_OK) {\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\n }\n }\n\n /** Removes unused schemas from the database.\n *\n * If the removal was successful, the database is automatically saved to disk.\n * @param schemaNames Array of schema names to drop\n * @throws [IModelError]($common) if the database if the operation failed.\n * @alpha\n */\n public dropSchemas(schemaNames: string[]): void {\n if (schemaNames.length === 0)\n return;\n if (this[_nativeDb].schemaSyncEnabled())\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot drop schemas when schema sync is enabled\");\n\n try {\n this[_nativeDb].dropSchemas(schemaNames);\n this.saveChanges('dropped unused schemas');\n } catch (error: any) {\n Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);\n this.abandonChanges();\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);\n }\n }\n\n /**\n * Returns the full schema for the input name.\n * @param name The name of the schema e.g. 'ECDbMeta'\n * @returns The SchemaProps for the requested schema\n * @throws if the schema can not be found or loaded.\n */\n public getSchemaProps(name: string): ECSchemaProps {\n return this[_nativeDb].getSchemaProps(name);\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withWriteStatement]]\n * @beta\n */\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(new ECSqlWriteStatement(stmt));\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withCachedWriteStatement]]\n * @beta\n */\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @beta\n */\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withStatement]]\n * @public\n * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = this.prepareStatement(ecsql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = new ECSqlStatement();\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\n return stmt;\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @public\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this.prepareSqliteStatement(sql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this[_nativeDb], logErrors);\n return stmt;\n }\n\n /** @internal */\n public get [_nativeDb](): IModelJsNative.ECDb {\n assert(undefined !== this._nativeDb);\n return this._nativeDb;\n }\n\n /** Allow to execute query and read results along with meta data. The result are streamed.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\n *\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param config Allow to specify certain flags which control how query is executed.\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\n * @public\n * */\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\n }\n const executor = {\n execute: async (request: DbQueryRequest) => {\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\n },\n };\n return new ECSqlReader(executor, ecsql, params, config);\n }\n}\n"]}