@itwin/core-backend 5.10.0-dev.8 → 5.10.0

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 (278) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +8 -1
  3. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  4. package/lib/cjs/BriefcaseManager.js.map +1 -1
  5. package/lib/cjs/Category.d.ts +4 -4
  6. package/lib/cjs/Category.js.map +1 -1
  7. package/lib/cjs/ChangesetECAdaptor.d.ts +6 -6
  8. package/lib/cjs/ChangesetECAdaptor.js +4 -4
  9. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  10. package/lib/cjs/ChangesetReader.d.ts +84 -1
  11. package/lib/cjs/ChangesetReader.d.ts.map +1 -1
  12. package/lib/cjs/ChangesetReader.js +108 -12
  13. package/lib/cjs/ChangesetReader.js.map +1 -1
  14. package/lib/cjs/ClassRegistry.d.ts +3 -3
  15. package/lib/cjs/ClassRegistry.js +3 -3
  16. package/lib/cjs/ClassRegistry.js.map +1 -1
  17. package/lib/cjs/CodeSpecs.d.ts +3 -3
  18. package/lib/cjs/CodeSpecs.js.map +1 -1
  19. package/lib/cjs/DisplayStyle.d.ts +2 -2
  20. package/lib/cjs/DisplayStyle.js.map +1 -1
  21. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  22. package/lib/cjs/ECSqlStatement.js +4 -0
  23. package/lib/cjs/ECSqlStatement.js.map +1 -1
  24. package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -1
  25. package/lib/cjs/ECSqlSyncReader.js +1 -0
  26. package/lib/cjs/ECSqlSyncReader.js.map +1 -1
  27. package/lib/cjs/Element.d.ts +16 -13
  28. package/lib/cjs/Element.d.ts.map +1 -1
  29. package/lib/cjs/Element.js +8 -5
  30. package/lib/cjs/Element.js.map +1 -1
  31. package/lib/cjs/ElementAspect.d.ts +1 -1
  32. package/lib/cjs/ElementAspect.js.map +1 -1
  33. package/lib/cjs/ElementTreeWalker.d.ts +5 -5
  34. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  35. package/lib/cjs/Entity.d.ts +13 -5
  36. package/lib/cjs/Entity.d.ts.map +1 -1
  37. package/lib/cjs/Entity.js +13 -5
  38. package/lib/cjs/Entity.js.map +1 -1
  39. package/lib/cjs/ExternalSource.d.ts +2 -2
  40. package/lib/cjs/ExternalSource.js.map +1 -1
  41. package/lib/cjs/IModelDb.d.ts +112 -40
  42. package/lib/cjs/IModelDb.d.ts.map +1 -1
  43. package/lib/cjs/IModelDb.js +215 -42
  44. package/lib/cjs/IModelDb.js.map +1 -1
  45. package/lib/cjs/LineStyle.d.ts +6 -6
  46. package/lib/cjs/LineStyle.js.map +1 -1
  47. package/lib/cjs/LocalHub.d.ts +6 -0
  48. package/lib/cjs/LocalHub.d.ts.map +1 -1
  49. package/lib/cjs/LocalHub.js +23 -0
  50. package/lib/cjs/LocalHub.js.map +1 -1
  51. package/lib/cjs/Material.d.ts +1 -1
  52. package/lib/cjs/Material.js.map +1 -1
  53. package/lib/cjs/Model.d.ts +6 -6
  54. package/lib/cjs/Model.js.map +1 -1
  55. package/lib/cjs/Relationship.d.ts +13 -11
  56. package/lib/cjs/Relationship.d.ts.map +1 -1
  57. package/lib/cjs/Relationship.js +9 -7
  58. package/lib/cjs/Relationship.js.map +1 -1
  59. package/lib/cjs/SheetIndex.d.ts +4 -4
  60. package/lib/cjs/SheetIndex.js.map +1 -1
  61. package/lib/cjs/Texture.d.ts +1 -1
  62. package/lib/cjs/Texture.js.map +1 -1
  63. package/lib/cjs/TxnManager.d.ts.map +1 -1
  64. package/lib/cjs/TxnManager.js +7 -0
  65. package/lib/cjs/TxnManager.js.map +1 -1
  66. package/lib/cjs/ViewDefinition.d.ts +6 -6
  67. package/lib/cjs/ViewDefinition.js.map +1 -1
  68. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  69. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  70. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -1
  71. package/lib/cjs/annotations/FrameGeometry.js +2 -3
  72. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  73. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +6 -2
  74. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +1 -0
  75. package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
  76. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  77. package/lib/cjs/domains/GenericElements.d.ts +2 -2
  78. package/lib/cjs/domains/GenericElements.js.map +1 -1
  79. package/lib/cjs/internal/ChannelAdmin.d.ts +2 -2
  80. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  81. package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -1
  82. package/lib/cjs/internal/ElementLRUCache.js +23 -4
  83. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  84. package/lib/cjs/internal/HubMock.d.ts +24 -1
  85. package/lib/cjs/internal/HubMock.d.ts.map +1 -1
  86. package/lib/cjs/internal/HubMock.js +60 -39
  87. package/lib/cjs/internal/HubMock.js.map +1 -1
  88. package/lib/cjs/internal/ServerBasedLocks.d.ts +19 -1
  89. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
  90. package/lib/cjs/internal/ServerBasedLocks.js +55 -1
  91. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  92. package/lib/cjs/internal/cross-package.d.ts +1 -1
  93. package/lib/cjs/internal/cross-package.d.ts.map +1 -1
  94. package/lib/cjs/internal/cross-package.js +1 -2
  95. package/lib/cjs/internal/cross-package.js.map +1 -1
  96. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
  97. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +55 -9
  98. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  99. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  100. package/lib/cjs/internal/workspace/WorkspaceImpl.js +7 -11
  101. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  102. package/lib/cjs/workspace/SettingsSchemas.d.ts +20 -3
  103. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  104. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  105. package/lib/cjs/workspace/Workspace.d.ts +3 -1
  106. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  107. package/lib/cjs/workspace/Workspace.js.map +1 -1
  108. package/lib/esm/BriefcaseManager.d.ts +8 -1
  109. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  110. package/lib/esm/BriefcaseManager.js.map +1 -1
  111. package/lib/esm/Category.d.ts +4 -4
  112. package/lib/esm/Category.js.map +1 -1
  113. package/lib/esm/ChangesetECAdaptor.d.ts +6 -6
  114. package/lib/esm/ChangesetECAdaptor.js +4 -4
  115. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  116. package/lib/esm/ChangesetReader.d.ts +84 -1
  117. package/lib/esm/ChangesetReader.d.ts.map +1 -1
  118. package/lib/esm/ChangesetReader.js +108 -12
  119. package/lib/esm/ChangesetReader.js.map +1 -1
  120. package/lib/esm/ClassRegistry.d.ts +3 -3
  121. package/lib/esm/ClassRegistry.js +3 -3
  122. package/lib/esm/ClassRegistry.js.map +1 -1
  123. package/lib/esm/CodeSpecs.d.ts +3 -3
  124. package/lib/esm/CodeSpecs.js.map +1 -1
  125. package/lib/esm/DisplayStyle.d.ts +2 -2
  126. package/lib/esm/DisplayStyle.js.map +1 -1
  127. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  128. package/lib/esm/ECSqlStatement.js +4 -0
  129. package/lib/esm/ECSqlStatement.js.map +1 -1
  130. package/lib/esm/ECSqlSyncReader.d.ts.map +1 -1
  131. package/lib/esm/ECSqlSyncReader.js +1 -0
  132. package/lib/esm/ECSqlSyncReader.js.map +1 -1
  133. package/lib/esm/Element.d.ts +16 -13
  134. package/lib/esm/Element.d.ts.map +1 -1
  135. package/lib/esm/Element.js +8 -5
  136. package/lib/esm/Element.js.map +1 -1
  137. package/lib/esm/ElementAspect.d.ts +1 -1
  138. package/lib/esm/ElementAspect.js.map +1 -1
  139. package/lib/esm/ElementTreeWalker.d.ts +5 -5
  140. package/lib/esm/ElementTreeWalker.js.map +1 -1
  141. package/lib/esm/Entity.d.ts +13 -5
  142. package/lib/esm/Entity.d.ts.map +1 -1
  143. package/lib/esm/Entity.js +13 -5
  144. package/lib/esm/Entity.js.map +1 -1
  145. package/lib/esm/ExternalSource.d.ts +2 -2
  146. package/lib/esm/ExternalSource.js.map +1 -1
  147. package/lib/esm/IModelDb.d.ts +112 -40
  148. package/lib/esm/IModelDb.d.ts.map +1 -1
  149. package/lib/esm/IModelDb.js +216 -43
  150. package/lib/esm/IModelDb.js.map +1 -1
  151. package/lib/esm/LineStyle.d.ts +6 -6
  152. package/lib/esm/LineStyle.js.map +1 -1
  153. package/lib/esm/LocalHub.d.ts +6 -0
  154. package/lib/esm/LocalHub.d.ts.map +1 -1
  155. package/lib/esm/LocalHub.js +23 -0
  156. package/lib/esm/LocalHub.js.map +1 -1
  157. package/lib/esm/Material.d.ts +1 -1
  158. package/lib/esm/Material.js.map +1 -1
  159. package/lib/esm/Model.d.ts +6 -6
  160. package/lib/esm/Model.js.map +1 -1
  161. package/lib/esm/Relationship.d.ts +13 -11
  162. package/lib/esm/Relationship.d.ts.map +1 -1
  163. package/lib/esm/Relationship.js +9 -7
  164. package/lib/esm/Relationship.js.map +1 -1
  165. package/lib/esm/SheetIndex.d.ts +4 -4
  166. package/lib/esm/SheetIndex.js.map +1 -1
  167. package/lib/esm/Texture.d.ts +1 -1
  168. package/lib/esm/Texture.js.map +1 -1
  169. package/lib/esm/TxnManager.d.ts.map +1 -1
  170. package/lib/esm/TxnManager.js +7 -0
  171. package/lib/esm/TxnManager.js.map +1 -1
  172. package/lib/esm/ViewDefinition.d.ts +6 -6
  173. package/lib/esm/ViewDefinition.js.map +1 -1
  174. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  175. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  176. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -1
  177. package/lib/esm/annotations/FrameGeometry.js +2 -3
  178. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  179. package/lib/esm/domains/FunctionalElements.d.ts +1 -1
  180. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  181. package/lib/esm/domains/GenericElements.d.ts +2 -2
  182. package/lib/esm/domains/GenericElements.js.map +1 -1
  183. package/lib/esm/internal/ChannelAdmin.d.ts +2 -2
  184. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  185. package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -1
  186. package/lib/esm/internal/ElementLRUCache.js +23 -4
  187. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  188. package/lib/esm/internal/HubMock.d.ts +24 -1
  189. package/lib/esm/internal/HubMock.d.ts.map +1 -1
  190. package/lib/esm/internal/HubMock.js +61 -40
  191. package/lib/esm/internal/HubMock.js.map +1 -1
  192. package/lib/esm/internal/ServerBasedLocks.d.ts +19 -1
  193. package/lib/esm/internal/ServerBasedLocks.d.ts.map +1 -1
  194. package/lib/esm/internal/ServerBasedLocks.js +55 -1
  195. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  196. package/lib/esm/internal/cross-package.d.ts +1 -1
  197. package/lib/esm/internal/cross-package.d.ts.map +1 -1
  198. package/lib/esm/internal/cross-package.js +1 -1
  199. package/lib/esm/internal/cross-package.js.map +1 -1
  200. package/lib/esm/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
  201. package/lib/esm/internal/workspace/SettingsSchemasImpl.js +55 -9
  202. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  203. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  204. package/lib/esm/internal/workspace/WorkspaceImpl.js +7 -11
  205. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  206. package/lib/esm/test/ElementLRUCache.test.js +60 -0
  207. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  208. package/lib/esm/test/SchemaChangesetCanBeReversed.test.d.ts +2 -0
  209. package/lib/esm/test/SchemaChangesetCanBeReversed.test.d.ts.map +1 -0
  210. package/lib/esm/test/SchemaChangesetCanBeReversed.test.js +239 -0
  211. package/lib/esm/test/SchemaChangesetCanBeReversed.test.js.map +1 -0
  212. package/lib/esm/test/annotations/FrameGeometry.test.js +2 -1
  213. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  214. package/lib/esm/test/ecdb/CTE.test.js +1 -0
  215. package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
  216. package/lib/esm/test/ecdb/ECSqlQuery.test.js +10 -2
  217. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  218. package/lib/esm/test/ecdb/ECSqlStatement.test.js +10 -0
  219. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  220. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +1 -0
  221. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
  222. package/lib/esm/test/ecdb/QueryReaders.test.js +13 -0
  223. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  224. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +1 -0
  225. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  226. package/lib/esm/test/element/DeleteDefinitionElements.test.js +6 -2
  227. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  228. package/lib/esm/test/element/ElementRoundTrip.test.js +5 -0
  229. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  230. package/lib/esm/test/element/ExcludedElements.test.js +1 -0
  231. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  232. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +10 -0
  233. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  234. package/lib/esm/test/hubaccess/SemanticRebase.test.js +1 -0
  235. package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
  236. package/lib/esm/test/imodel/IModel.test.js +31 -0
  237. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  238. package/lib/esm/test/schema/ClassRegistry.test.js +3 -0
  239. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  240. package/lib/esm/test/schema/IModelSchemaContext.test.js +2 -0
  241. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  242. package/lib/esm/test/schema/SchemaViewHidden.test.d.ts +2 -0
  243. package/lib/esm/test/schema/SchemaViewHidden.test.d.ts.map +1 -0
  244. package/lib/esm/test/schema/SchemaViewHidden.test.js +275 -0
  245. package/lib/esm/test/schema/SchemaViewHidden.test.js.map +1 -0
  246. package/lib/esm/test/schema/SchemaViewKoQ.test.d.ts +2 -0
  247. package/lib/esm/test/schema/SchemaViewKoQ.test.d.ts.map +1 -0
  248. package/lib/esm/test/schema/SchemaViewKoQ.test.js +184 -0
  249. package/lib/esm/test/schema/SchemaViewKoQ.test.js.map +1 -0
  250. package/lib/esm/test/schema/SchemaViewLifecycle.test.d.ts +2 -0
  251. package/lib/esm/test/schema/SchemaViewLifecycle.test.d.ts.map +1 -0
  252. package/lib/esm/test/schema/SchemaViewLifecycle.test.js +141 -0
  253. package/lib/esm/test/schema/SchemaViewLifecycle.test.js.map +1 -0
  254. package/lib/esm/test/schema/SchemaViewValidation.test.d.ts +2 -0
  255. package/lib/esm/test/schema/SchemaViewValidation.test.d.ts.map +1 -0
  256. package/lib/esm/test/schema/SchemaViewValidation.test.js +475 -0
  257. package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -0
  258. package/lib/esm/test/standalone/ChangesetReader.test.js +945 -337
  259. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  260. package/lib/esm/test/standalone/DeleteElements.test.js +45 -0
  261. package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
  262. package/lib/esm/test/standalone/IModelWrite.test.js +6 -0
  263. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  264. package/lib/esm/test/standalone/ServerBasedLocks.test.js +62 -0
  265. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  266. package/lib/esm/test/standalone/Settings.test.js +2 -0
  267. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  268. package/lib/esm/test/standalone/SettingsSchemas.test.js +397 -0
  269. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  270. package/lib/esm/test/standalone/Workspace.test.js +23 -0
  271. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  272. package/lib/esm/workspace/SettingsSchemas.d.ts +20 -3
  273. package/lib/esm/workspace/SettingsSchemas.d.ts.map +1 -1
  274. package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
  275. package/lib/esm/workspace/Workspace.d.ts +3 -1
  276. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  277. package/lib/esm/workspace/Workspace.js.map +1 -1
  278. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"ChangesetReader.js","sourceRoot":"","sources":["../../src/ChangesetReader.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAwF;AACxF,oDAAiD;AAEjD,8DAAyD;AACzD,gDAA+C;AAE/C,iEAA6H;AAI7H,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAa,eAAe;IACT,aAAa,GAAmC,IAAI,6BAAY,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;IAC7G,+EAA+E;IACvE,WAAW,CAAoB;IAC/B,WAAW,GAAmB,qCAAc,CAAC,GAAG,CAAC;IACjD,YAAY,GAAG,CAAC,CAAC;IACjB,GAAG,CAAkB;IACrB,UAAU,CAAW;IACrB,UAAU,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,IAAI,CAAC,WAAW;4BAC5B,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;4BACvD,UAAU,EAAE,IAAI,CAAC,WAAW;4BAC5B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;yBACzC;qBACF,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,IAAW,EAAE;QACX,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;YACxB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,oGAAoG,CAAC,CAAC;QACvJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,8EAA8E;IAC9E,YAAY;IACZ,8EAA8E;IAE9E;;;OAGG;IACI,KAAK;QACV,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AArXD,0CAqXC","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 { DbChangeStage, DbOpcode, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { ChangeInstance, ChangesetReaderArgs, ChangeSource, PropertyFilter, RowFormatOptions } from \"./ChangesetReaderTypes\";\nimport { AnyDb, SqliteChangeOp } from \"./SqliteChangesetReader\";\n\n\n// ---------------------------------------------------------------------------\n// ChangesetReader\n// ---------------------------------------------------------------------------\n\n/**\n * Reads EC-typed changeset data natively from a changeset file, changeset group,\n * in-memory transaction, or local un-pushed changes.\n *\n * Implements [ChangeSource]($backend) so rows can be fed directly into\n * [PartialChangeUnifier]($backend) to merge partial (per-table) instances into\n * complete EC instances.\n *\n * When the current row is a non-EC internal SQLite table, [[isECTable]] is `false`\n * and both [[inserted]] and [[deleted]] remain `undefined`.\n *\n * @note The native reader operates one SQLite table-row at a time. Multi-table EC\n * instances must be merged using [PartialChangeUnifier]($backend).\n * @beta\n */\nexport class ChangesetReader implements Disposable, ChangeSource {\n private readonly _nativeReader: IModelJsNative.ChangesetReader = new IModelNative.platform.ChangesetReader();\n // Internal options — keep ECClassId as raw Id so the unifier can use it as-is.\n private _rowOptions?: RowFormatOptions;\n private _propFilter: PropertyFilter = PropertyFilter.All;\n private _changeIndex = 0;\n private _op?: SqliteChangeOp;\n private _isECTable?: boolean;\n private _tableName?: string;\n private _isIndirectChange?: boolean;\n\n /** The db used for EC schema resolution. */\n public readonly db: AnyDb;\n\n /**\n * `true` when the current row belongs to an EC-mapped table.\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get isECTable(): boolean {\n if (this._isECTable === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.isECTable is only valid after step() has positioned the reader on a current valid change.\");\n return this._isECTable;\n }\n\n /**\n * Name of the SQLite table for the current change row.\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get tableName(): string {\n if (this._tableName === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.tableName is only valid after step() has positioned the reader on a current valid change.\");\n return this._tableName;\n }\n\n /**\n * `true` when the current change was applied indirectly\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get isIndirectChange(): boolean {\n if (this._isIndirectChange === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.isIndirectChange is only valid after step() has positioned the reader on a current valid change.\");\n return this._isIndirectChange;\n }\n\n /**\n * Post-change (inserted or updated-new) EC instance, populated after each [[step]] call.\n * `undefined` when the current row is a Delete or a non-EC table row or [[step]] returned false.\n * @beta\n */\n public inserted?: ChangeInstance;\n\n /**\n * Pre-change (deleted or updated-old) EC instance, populated after each [[step]] call.\n * `undefined` when the current row is an Insert or a non-EC table row or [[step]] returned false.\n * @beta\n */\n public deleted?: ChangeInstance;\n\n // Private — callers use static factory methods.\n private constructor(db: AnyDb) {\n this.db = db;\n }\n\n /** Map public RowFormatOptions to the native adaptor options.\n * @internal */\n private toNativeRowOptions(opts: RowFormatOptions): IModelJsNative.ECSqlRowAdaptorOptions {\n return {\n abbreviateBlobs: opts.abbreviateBlobs,\n classIdsToClassNames: opts.classIdsToClassNames,\n useJsName: opts.useJsName,\n };\n }\n\n // ---------------------------------------------------------------------------\n // Static factory methods\n // ---------------------------------------------------------------------------\n\n /**\n * Open a changeset file from disk.\n * @param args.fileName Absolute path to the changeset file.\n * @param args.db Database at or after the changeset's ending state, used for schema resolution.\n * @param args.invert When `true`, invert all operations (Insert↔Delete).\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openFile(args: { readonly fileName: string } & ChangesetReaderArgs): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openFile(args.db[_nativeDb], args.fileName, args.invert ?? false, reader._propFilter);\n }\n catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Concatenate multiple changeset files and read them as a single logical stream.\n * @param args.changesetFiles Ordered list of changeset file paths.\n * @param args.db Database with schema at or ahead of the last changeset.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openGroup(args: { readonly changesetFiles: string[] } & ChangesetReaderArgs): ChangesetReader {\n if (args.changesetFiles.length === 0)\n throw new Error(\"changesetFiles must contain at least one file.\");\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openGroup(args.db[_nativeDb], args.changesetFiles, args.invert ?? false, reader._propFilter);\n }\n catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Read pending (not yet pushed) local changes from an open IModelDb.\n * @param args.db Must be an [IModelDb]($backend) (not [ECDb]($backend)).\n * @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openLocalChanges(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb; includeInMemoryChanges?: boolean },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openLocalChanges(args.db[_nativeDb], args.includeInMemoryChanges ?? false, args.invert ?? false, reader._propFilter);\n } catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Read the in-memory (not yet saved to disk) changes of an open IModelDb.\n * @param args.db Must be an [IModelDb]($backend).\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openInMemoryChanges(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openInMemoryChanges(args.db[_nativeDb], args.invert ?? false, reader._propFilter);\n } catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Read a single saved transaction by its id.\n * @param args.db Must be an [IModelDb]($backend) ([ECDb]($backend) does not support transactions).\n * @param args.txnId The id of the saved transaction to read.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openTxn(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb; txnId: Id64String },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions ?? {};\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openTxn(args.db[_nativeDb], args.txnId, args.invert ?? false, reader._propFilter);\n } catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n // ---------------------------------------------------------------------------\n // Filtering\n // ---------------------------------------------------------------------------\n\n /**\n * Restrict iteration to changes from the named SQLite tables.\n * That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.\n * @param tableNames SQLite table names to include.\n * Note: Table names must be provided in the correct case for proper filtering.\n * @beta\n */\n public setTableNameFilters(tableNames: Set<string>): void {\n this._nativeReader.setTableNameFilters(Array.from(tableNames));\n }\n\n /**\n * Restrict iteration to changes with the given operation types.\n * That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.\n * @param ops Operations to include.\n * @beta\n */\n public setOpCodeFilters(ops: Set<SqliteChangeOp>): void {\n this._nativeReader.setOpCodeFilters(Array.from(ops));\n }\n\n /**\n * Restrict iteration to changes for the given EC class names.\n * That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.\n * @param classNames EC class names to include. The classNames should be in the full name format(i.e. \"SchemaName:ClassName\").\n * Note: Schema names and class names must be provided in the correct case for proper filtering. Derived classes are not automatically included, so they must be specified explicitly if needed.\n * @beta\n */\n public setClassNameFilters(classNames: Set<string>): void {\n this._nativeReader.setClassNameFilters(Array.from(classNames));\n }\n\n /**\n * Remove the table-name filters\n * @beta\n */\n public clearTableNameFilters(): void {\n this._nativeReader.clearTableNameFilters();\n }\n\n /**\n * Remove the op-code filters\n * @beta\n */\n public clearOpCodeFilters(): void {\n this._nativeReader.clearOpCodeFilters();\n }\n\n /**\n * Remove the class-name filters\n * @beta\n */\n public clearClassNameFilters(): void {\n this._nativeReader.clearClassNameFilters();\n }\n\n // ---------------------------------------------------------------------------\n // Iteration\n // ---------------------------------------------------------------------------\n\n /**\n * Advance to the next change and populate `inserted` and/or `deleted`.\n * @returns `true` while positioned on a valid change; `false` when the stream is exhausted.\n * @beta\n */\n public step(): boolean {\n this.inserted = undefined;\n this.deleted = undefined;\n this._op = undefined;\n this._isECTable = undefined;\n this._tableName = undefined;\n this._isIndirectChange = undefined;\n\n if (this._nativeReader.step()) {\n this._changeIndex++;\n const meta = this._nativeReader.getChangeMetadata();\n const nativeOp = meta.opCode;\n const op: SqliteChangeOp = nativeOp === DbOpcode.Insert ? \"Inserted\" : nativeOp === DbOpcode.Update ? \"Updated\" : \"Deleted\";\n this._op = op;\n\n this._tableName = meta.tableName;\n this._isIndirectChange = meta.isIndirectChange;\n this._isECTable = meta.isECTable;\n\n const nativeRowOpts = this._rowOptions ? this.toNativeRowOptions(this._rowOptions) : {};\n\n if (op === \"Inserted\" || op === \"Updated\") {\n const rowValue = this._nativeReader.getValue(DbChangeStage.New, nativeRowOpts);\n if (rowValue !== undefined) {\n this.inserted = {\n ...rowValue.data,\n $meta: {\n op,\n tables: [this._tableName],\n changeIndexes: [this._changeIndex],\n stage: \"New\",\n instanceKey: rowValue.key,\n propFilter: this._propFilter,\n changeFetchedPropNames: rowValue.changeFetchedPropNames,\n rowOptions: this._rowOptions,\n isIndirectChange: this._isIndirectChange,\n },\n };\n }\n }\n\n if (op === \"Deleted\" || op === \"Updated\") {\n const rowValue = this._nativeReader.getValue(DbChangeStage.Old, nativeRowOpts);\n if (rowValue !== undefined) {\n this.deleted = {\n ...rowValue.data,\n $meta: {\n op,\n tables: [this._tableName],\n changeIndexes: [this._changeIndex],\n stage: \"Old\",\n instanceKey: rowValue.key,\n propFilter: this._propFilter,\n changeFetchedPropNames: rowValue.changeFetchedPropNames,\n rowOptions: this._rowOptions,\n isIndirectChange: this._isIndirectChange,\n },\n };\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * SQLite opcode of the current change.\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get op(): SqliteChangeOp {\n if (this._op === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.op is only valid after step() has positioned the reader on a current valid change.\");\n return this._op;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /**\n * Close the reader and release all native resources.\n * @beta\n */\n public close(): void {\n this._changeIndex = 0;\n this._op = undefined;\n this._isECTable = undefined;\n this._tableName = undefined;\n this._isIndirectChange = undefined;\n this.inserted = undefined;\n this.deleted = undefined;\n this._nativeReader.close();\n }\n\n /**\n * Implements the `Disposable` contract — calls [[close]].\n * @beta\n */\n public [Symbol.dispose](): void {\n this.close();\n }\n}\n\n\n"]}
1
+ {"version":3,"file":"ChangesetReader.js","sourceRoot":"","sources":["../../src/ChangesetReader.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAwF;AACxF,oDAAiD;AAEjD,8DAAyD;AACzD,gDAA+C;AAE/C,iEAA6H;AAI7H,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAa,eAAe;IAClB,MAAM,CAAU,4BAA4B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,C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;4BACZ,WAAW,EAAE,QAAQ,CAAC,GAAG;4BACzB,UAAU,EAAE,IAAI,CAAC,WAAW;4BAC5B,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;4BACvD,UAAU,EAAE,IAAI,CAAC,WAAW;4BAC5B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;yBACzC;qBACF,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,IAAW,EAAE;QACX,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;YACxB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,oGAAoG,CAAC,CAAC;QACvJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,8EAA8E;IAC9E,YAAY;IACZ,8EAA8E;IAE9E;;;;;;;OAOG;IACI,KAAK;QACV,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;;AAvdH,0CAwdC","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 { DbChangeStage, DbOpcode, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { ChangeInstance, ChangesetReaderArgs, ChangeSource, PropertyFilter, RowFormatOptions } from \"./ChangesetReaderTypes\";\nimport { AnyDb, SqliteChangeOp } from \"./SqliteChangesetReader\";\n\n\n// ---------------------------------------------------------------------------\n// ChangesetReader\n// ---------------------------------------------------------------------------\n\n/**\n * Reads EC-typed changeset data natively from a changeset file, changeset group,\n * in-memory transaction, or local un-pushed changes.\n *\n * Implements [ChangeSource]($backend) so rows can be fed directly into\n * [PartialChangeUnifier]($backend) to merge partial (per-table) instances into\n * complete EC instances.\n *\n * When the current row is a non-EC internal SQLite table, [[isECTable]] is `false`\n * and both [[inserted]] and [[deleted]] remain `undefined`.\n *\n * @note The native reader operates one SQLite table-row at a time. Multi-table EC\n * instances must be merged using [PartialChangeUnifier]($backend).\n * @beta\n */\nexport class ChangesetReader implements Disposable, ChangeSource {\n private static readonly defaultSpillThresholdInBytes = 50 * 1024 * 1024; // 50 MiB\n private readonly _nativeReader: IModelJsNative.ChangesetReader = new IModelNative.platform.ChangesetReader();\n // Internal options — keep ECClassId as raw Id so the unifier can use it as-is.\n private _rowOptions?: RowFormatOptions;\n private _propFilter: PropertyFilter = PropertyFilter.All;\n private _changeIndex = 0;\n private _op?: SqliteChangeOp;\n private _isECTable?: boolean;\n private _tableName?: string;\n private _isIndirectChange?: boolean;\n\n /** The db used for EC schema resolution. */\n public readonly db: AnyDb;\n\n /**\n * `true` when the current row belongs to an EC-mapped table.\n * Valid only after a successful call to [[step]].\n * @throws [[IModelError]] if called before a successful [[step]] call.\n * @beta\n */\n public get isECTable(): boolean {\n if (this._isECTable === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.isECTable is only valid after step() has positioned the reader on a current valid change.\");\n return this._isECTable;\n }\n\n /**\n * Name of the SQLite table for the current change row.\n * Valid only after a successful call to [[step]].\n * @throws [[IModelError]] if called before a successful [[step]] call.\n * @beta\n */\n public get tableName(): string {\n if (this._tableName === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.tableName is only valid after step() has positioned the reader on a current valid change.\");\n return this._tableName;\n }\n\n /**\n * `true` when the current change was applied indirectly\n * Valid only after a successful call to [[step]].\n * @throws [[IModelError]] if called before a successful [[step]] call.\n * @beta\n */\n public get isIndirectChange(): boolean {\n if (this._isIndirectChange === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.isIndirectChange is only valid after step() has positioned the reader on a current valid change.\");\n return this._isIndirectChange;\n }\n\n /**\n * Post-change (inserted or updated-new) EC instance, populated after each [[step]] call.\n * `undefined` when the current row is a Delete or a non-EC table row or [[step]] returned false.\n * @beta\n */\n public inserted?: ChangeInstance;\n\n /**\n * Pre-change (deleted or updated-old) EC instance, populated after each [[step]] call.\n * `undefined` when the current row is an Insert or a non-EC table row or [[step]] returned false.\n * @beta\n */\n public deleted?: ChangeInstance;\n\n // Private — callers use static factory methods.\n private constructor(db: AnyDb) {\n this.db = db;\n }\n\n /** Map public RowFormatOptions to the native adaptor options.\n * @internal */\n private toNativeRowOptions(opts: RowFormatOptions): IModelJsNative.ECSqlRowAdaptorOptions {\n return {\n abbreviateBlobs: opts.abbreviateBlobs,\n classIdsToClassNames: opts.classIdsToClassNames,\n useJsName: opts.useJsName,\n };\n }\n\n // ---------------------------------------------------------------------------\n // Static factory methods\n // ---------------------------------------------------------------------------\n\n /**\n * Open a changeset file from disk.\n * @param args.fileName Absolute path to the changeset file.\n * @param args.db Database at or after the changeset's ending state, used for schema resolution.\n * @param args.invert When `true`, invert all operations (Insert↔Delete).\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @throws if the native layer fails to open the file.\n * @beta\n */\n public static openFile(args: { readonly fileName: string } & ChangesetReaderArgs): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openFile(args.db[_nativeDb], args.fileName, args.invert ?? false, reader._propFilter);\n }\n catch (e) {\n reader.handleCloseErrorWhileOpening(e);\n throw e;\n }\n return reader;\n }\n\n /**\n * Concatenate multiple changeset files and read them as a single logical stream.\n * @param args.changesetFiles Ordered list of changeset file paths.\n * @param args.db Database with schema at or ahead of the last changeset.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @param args.spillThresholdInBytes When the total size of the changeset data in the change group exceeds this threshold (in bytes),\n * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.\n * This keeps peak memory usage bounded, making the API suitable for processing large changeset groups under low-memory conditions.\n * Defaults to 50 MiB.\n * @throws if `changesetFiles` is empty, or if the native layer fails to open\n * the group.\n * @beta\n */\n public static openGroup(args: { readonly changesetFiles: string[], spillThresholdInBytes?: number } & ChangesetReaderArgs): ChangesetReader {\n if (args.changesetFiles.length === 0)\n throw new IModelError(IModelStatus.BadArg, \"changesetFiles must contain at least one file.\");\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openGroup(args.db[_nativeDb], args.changesetFiles, args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);\n }\n catch (e) {\n reader.handleCloseErrorWhileOpening(e);\n throw e;\n }\n return reader;\n }\n\n /**\n * Read pending (not yet pushed) local changes from an open IModelDb.\n * @param args.db Must be an [IModelDb]($backend) (not [ECDb]($backend)).\n * @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @param args.spillThresholdInBytes When the total size of all local un-pushed saved changes exceeds this threshold (in bytes),\n * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.\n * This keeps peak memory usage bounded, making the API suitable for iModels with large local change backlogs under low-memory conditions.\n * Defaults to 50 MiB.\n * @throws if the native layer\n * fails to open the local changes.\n * @beta\n */\n public static openLocalChanges(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb; includeInMemoryChanges?: boolean, spillThresholdInBytes?: number },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openLocalChanges(args.db[_nativeDb], args.includeInMemoryChanges ?? false, args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);\n } catch (e) {\n reader.handleCloseErrorWhileOpening(e);\n throw e;\n }\n return reader;\n }\n\n /**\n * Read the in-memory (not yet saved to disk) changes of an open IModelDb.\n * @param args.db Must be an [IModelDb]($backend).\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @param args.spillThresholdInBytes When the total size of the in-memory (unsaved) change data exceeds this threshold (in bytes),\n * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.\n * This keeps peak memory usage bounded, making the API suitable for large in-memory transactions under low-memory conditions.\n * Defaults to 50 MiB.\n * @throws if the native layer encounters an error while opening the in-memory changes.\n * @beta\n */\n public static openInMemoryChanges(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb, spillThresholdInBytes?: number },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openInMemoryChanges(args.db[_nativeDb], args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);\n } catch (e) {\n reader.handleCloseErrorWhileOpening(e);\n throw e;\n }\n return reader;\n }\n\n /**\n * Read a single saved transaction by its id.\n * @param args.db Must be an [IModelDb]($backend) ([ECDb]($backend) does not support transactions).\n * @param args.txnId The id of the saved transaction to read.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @param args.spillThresholdInBytes When the total size of the transaction's change data exceeds this threshold (in bytes),\n * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.\n * This keeps peak memory usage bounded, making the API suitable for large transactions under low-memory conditions.\n * Defaults to 50 MiB.\n * @throws if `txnId` is not found, or\n * the native layer fails to open the transaction data.\n * @beta\n */\n public static openTxn(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb; txnId: Id64String, spillThresholdInBytes?: number },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openTxn(args.db[_nativeDb], args.txnId, args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);\n } catch (e) {\n reader.handleCloseErrorWhileOpening(e);\n throw e;\n }\n return reader;\n }\n\n /** Handle errors that occur while auto closing the reader if there is also an error while opening the reader */\n private handleCloseErrorWhileOpening(e: unknown): void {\n try {\n this.close();\n } catch (closeError) {\n throw new IModelError(IModelStatus.BadArg, `Failed to open ChangesetReader with error ${e instanceof Error ? e.message : String(e)}.\n Additionally, that triggered an automatic closure of the reader\n releasing native resources which also failed with failure ${closeError instanceof Error ? closeError.message : String(closeError)}.\n Check native error logs for more details.`);\n }\n }\n\n // ---------------------------------------------------------------------------\n // Filtering\n // ---------------------------------------------------------------------------\n\n /**\n * Restrict iteration to changes from the named SQLite tables.\n * That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.\n * @param tableNames SQLite table names to include.\n * Note: Table names must be provided in the correct case for proper filtering.\n * @throws if the native layer encounters an error while setting the filter.\n * @beta\n */\n public setTableNameFilters(tableNames: Set<string>): void {\n this._nativeReader.setTableNameFilters(Array.from(tableNames));\n }\n\n /**\n * Restrict iteration to changes with the given operation types.\n * That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.\n * @param ops Operations to include.\n * @throws if the native layer encounters an error while setting the filter.\n * @beta\n */\n public setOpCodeFilters(ops: Set<SqliteChangeOp>): void {\n this._nativeReader.setOpCodeFilters(Array.from(ops));\n }\n\n /**\n * Restrict iteration to changes for the given EC class names.\n * That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.\n * @param classNames EC class names to include. The classNames should be in the full name format(i.e. \"SchemaName:ClassName\").\n * Note: Schema names and class names must be provided in the correct case for proper filtering. Derived classes are not automatically included, so they must be specified explicitly if needed.\n * @throws if the native layer encounters an error while setting the filter.\n * @beta\n */\n public setClassNameFilters(classNames: Set<string>): void {\n this._nativeReader.setClassNameFilters(Array.from(classNames));\n }\n\n /**\n * Remove the table-name filters\n * @throws if the native layer encounters an error.\n * @beta\n */\n public clearTableNameFilters(): void {\n this._nativeReader.clearTableNameFilters();\n }\n\n /**\n * Remove the op-code filters\n * @throws if the native layer encounters an error.\n * @beta\n */\n public clearOpCodeFilters(): void {\n this._nativeReader.clearOpCodeFilters();\n }\n\n /**\n * Remove the class-name filters\n * @throws if the native layer encounters an error.\n * @beta\n */\n public clearClassNameFilters(): void {\n this._nativeReader.clearClassNameFilters();\n }\n\n // ---------------------------------------------------------------------------\n // Strict mode\n // ---------------------------------------------------------------------------\n\n /**\n * Enable strict mode on the reader.\n *\n * Strict mode affects how the reader handles a **column-count mismatch** between a change\n * record and the corresponding live database table. Such a mismatch can occur when columns\n * have been added to a table after the changeset was created.\n *\n * When strict mode is **enabled**: if the number of columns recorded in a change row differs\n * from the number of columns currently present in the live table, the reader throws an error\n * instead of processing that row.\n *\n * Use strict mode when you need to be certain that every change row is interpreted against\n * exactly the schema that was in effect when the changeset was written.\n *\n * @see [[disableStrictMode]] — the default (lenient) behaviour.\n * @throws if the native layer encounters an error.\n * @beta\n */\n public enableStrictMode(): void {\n this._nativeReader.enableStrictMode();\n }\n\n /**\n * Disable strict mode on the reader (this is the default).\n *\n * When strict mode is **disabled**: if the number of columns recorded in a change row differs\n * from the number of columns currently present in the live table, the reader takes the\n * **minimum** of the two column counts and proceeds normally with that subset. This is safe\n * because SQLite only ever appends new columns at the end of a table and never removes them —\n * so older change records simply lack the trailing columns that were added later, and those\n * missing columns are silently ignored.\n *\n * @see [[enableStrictMode]] — throw on column-count mismatches instead.\n * @throws if the native layer encounters an error.\n * @beta\n */\n public disableStrictMode(): void {\n this._nativeReader.disableStrictMode();\n }\n\n // ---------------------------------------------------------------------------\n // Iteration\n // ---------------------------------------------------------------------------\n\n /**\n * Advance to the next change and populate `inserted` and/or `deleted`.\n * @returns `true` while positioned on a valid change; `false` when the stream is exhausted.\n * @throws if the native layer encounters an error while reading or decoding\n * the next change.\n * @beta\n */\n public step(): boolean {\n this.inserted = undefined;\n this.deleted = undefined;\n this._op = undefined;\n this._isECTable = undefined;\n this._tableName = undefined;\n this._isIndirectChange = undefined;\n\n if (this._nativeReader.step()) {\n this._changeIndex++;\n const meta = this._nativeReader.getChangeMetadata();\n const nativeOp = meta.opCode;\n const op: SqliteChangeOp = nativeOp === DbOpcode.Insert ? \"Inserted\" : nativeOp === DbOpcode.Update ? \"Updated\" : \"Deleted\";\n this._op = op;\n\n this._tableName = meta.tableName;\n this._isIndirectChange = meta.isIndirectChange;\n this._isECTable = meta.isECTable;\n\n const nativeRowOpts = this._rowOptions ? this.toNativeRowOptions(this._rowOptions) : {};\n\n if (op === \"Inserted\" || op === \"Updated\") {\n const rowValue = this._nativeReader.getValue(DbChangeStage.New, nativeRowOpts);\n if (rowValue !== undefined) {\n this.inserted = {\n ...rowValue.data,\n $meta: {\n op,\n tables: [this._tableName],\n changeIndexes: [this._changeIndex],\n stage: \"New\",\n instanceKey: rowValue.key,\n propFilter: this._propFilter,\n changeFetchedPropNames: rowValue.changeFetchedPropNames,\n rowOptions: this._rowOptions,\n isIndirectChange: this._isIndirectChange,\n },\n };\n }\n }\n\n if (op === \"Deleted\" || op === \"Updated\") {\n const rowValue = this._nativeReader.getValue(DbChangeStage.Old, nativeRowOpts);\n if (rowValue !== undefined) {\n this.deleted = {\n ...rowValue.data,\n $meta: {\n op,\n tables: [this._tableName],\n changeIndexes: [this._changeIndex],\n stage: \"Old\",\n instanceKey: rowValue.key,\n propFilter: this._propFilter,\n changeFetchedPropNames: rowValue.changeFetchedPropNames,\n rowOptions: this._rowOptions,\n isIndirectChange: this._isIndirectChange,\n },\n };\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * SQLite opcode of the current change.\n * Valid only after a successful call to [[step]].\n * @throws [[IModelError]] if called before a successful [[step]] call.\n * @beta\n */\n public get op(): SqliteChangeOp {\n if (this._op === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.op is only valid after step() has positioned the reader on a current valid change.\");\n return this._op;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /**\n * Close the reader and release all native resources.\n *\n * @throws if the native layer encounters an error during cleanup. Native resources\n * are not fully released when this throws — check the native error\n * logs for details.\n * @beta\n */\n public close(): void {\n this._changeIndex = 0;\n this._op = undefined;\n this._isECTable = undefined;\n this._tableName = undefined;\n this._isIndirectChange = undefined;\n this.inserted = undefined;\n this.deleted = undefined;\n this._nativeReader.close();\n }\n\n /**\n * Implements the `Disposable` contract — delegates to [[close]].\n *\n * @throws if the native layer fails to release its resources (re-thrown from [[close]]).\n * @beta\n */\n public [Symbol.dispose](): void {\n this.close();\n }\n}\n\n\n"]}
@@ -115,7 +115,7 @@ export declare class ClassRegistry {
115
115
  * A cache that records the mapping between class names and class metadata.
116
116
  * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.
117
117
  * @internal
118
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.
118
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` from the `iModel` instead.
119
119
  *
120
120
  * @example
121
121
  * @
@@ -126,8 +126,8 @@ export declare class ClassRegistry {
126
126
  *
127
127
  * Replacement:
128
128
  * ```ts
129
- * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync("SchemaName.ClassName", EntityClass);
130
- * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync("SchemaName", "ClassName", RelationshipClass);
129
+ * const view = await iModel.getSchemaView();
130
+ * const cls = view.findClass("SchemaName:ClassName");
131
131
  * ```
132
132
  */
133
133
  export declare class MetaDataRegistry {
@@ -297,7 +297,7 @@ exports.ClassRegistry = ClassRegistry;
297
297
  * A cache that records the mapping between class names and class metadata.
298
298
  * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.
299
299
  * @internal
300
- * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.
300
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` from the `iModel` instead.
301
301
  *
302
302
  * @example
303
303
  * @
@@ -308,8 +308,8 @@ exports.ClassRegistry = ClassRegistry;
308
308
  *
309
309
  * Replacement:
310
310
  * ```ts
311
- * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync("SchemaName.ClassName", EntityClass);
312
- * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync("SchemaName", "ClassName", RelationshipClass);
311
+ * const view = await iModel.getSchemaView();
312
+ * const cls = view.findClass("SchemaName:ClassName");
313
313
  * ```
314
314
  */
315
315
  class MetaDataRegistry {
@@ -1 +1 @@
1
- {"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;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AW,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,4CAwBC","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 Schema\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * @public\n */\nexport class EntityJsClassMap {\n private readonly _classMap = new Map<string, typeof Entity>();\n\n /** @internal */\n public has(classFullName: string): boolean {\n return this._classMap.has(classFullName.toLowerCase());\n }\n\n /** @internal */\n public get(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** @internal */\n public set(classFullName: string, entityClass: typeof Entity): void {\n this._classMap.set(classFullName.toLowerCase(), entityClass);\n }\n\n /** @internal */\n public delete(classFullName: string): boolean {\n return this._classMap.delete(classFullName.toLowerCase());\n }\n\n /** @internal */\n public clear(): void {\n this._classMap.clear();\n }\n\n /** @internal */\n public [Symbol.iterator](): IterableIterator<[string, typeof Entity]> {\n return this._classMap[Symbol.iterator]();\n }\n\n /**\n * Registers a single `entityClass` defined in the specified `schema`.\n * This method registers the class globally. To register a class for a specific iModel, use [[IModelDb.jsClassMap]].\n *\n * @param entityClass - The JavaScript class that implements the BIS [ECClass](@itwin/core-common) to be registered.\n * @param schema - The schema that contains the `entityClass`.\n *\n * @throws Error if the class is already registered.\n *\n * @public\n */\n public register(entityClass: typeof Entity, schema: typeof Schema): void {\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n entityClass.schema = schema;\n this.set(key, entityClass);\n }\n}\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup\n * to establish their mappings.\n *\n * When creating custom Entity subclasses for registration, you should:\n * - Override the `className` property to match your ECClass name:\n * ```typescript\n * public static override get className() { return \"TestElement\"; }\n * ```\n * - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration\n *\n * @public\n */\nexport class ClassRegistry {\n private static readonly _globalClassMap = new EntityJsClassMap();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** Register a single `entityClass` defined in the specified `schema`.\n * @see [[registerModule]] to register multiple classes.\n * @public\n */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n this._globalClassMap.register(entityClass, schema);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n iModel.schemaMap.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel[_nativeDb].getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${entityMetaData.ecclass} has no superclass`);\n\n // make sure schema exists\n let schema = iModel.schemaMap.get(domainName) ?? Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superClassFullName = entityMetaData.baseClasses[0].toLowerCase();\n const superclass = iModel.jsClassMap.get(superClassFullName) ?? this._globalClassMap.get(superClassFullName);\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${entityMetaData.ecclass}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel[_nativeDb].getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n iModel.jsClassMap.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from [[Entity]].\n * [[register]] will be invoked for each subclass of `Entity` exported by `moduleObj`.\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema that contains all of the [ECClass]($ecschema-metadata)es exported by `moduleObj`.\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._globalClassMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n return iModel.jsClassMap.get(key) ?? this._globalClassMap.get(key) ?? this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterClass(classFullName: string) { return this._globalClassMap.delete(classFullName.toLowerCase()); }\n\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._globalClassMap)) {\n if (entry[1].schema === schema)\n this.unregisterClass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.\n *\n * @example\n * @\n * Current Usage:\n * ```ts\n * const metaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(\"SchemaName:ClassName\");\n * ```\n *\n * Replacement:\n * ```ts\n * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName.ClassName\", EntityClass);\n * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName\", \"ClassName\", RelationshipClass);\n * ```\n */\nexport class MetaDataRegistry {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _registry = new Map<string, EntityMetaData>();\n private _classIdToName = new Map<Id64String, string>();\n\n /** Get the specified Entity metadata */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public find(classFullName: string): EntityMetaData | undefined {\n return this._registry.get(classFullName.toLowerCase());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public findByClassId(classId: Id64String): EntityMetaData | undefined {\n const name = this._classIdToName.get(classId);\n return undefined !== name ? this.find(name) : undefined;\n }\n\n /** Add metadata to the cache */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public add(classFullName: string, metaData: EntityMetaData): void {\n const name = classFullName.toLowerCase();\n this._registry.set(name, metaData);\n this._classIdToName.set(metaData.classId, name);\n }\n}\n"]}
1
+ {"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuF;AACvF,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AACjC,gDAA+C;AAE/C,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE9D,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB,EAAE,WAA0B;QAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAqB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,gBAAgB;IACT,KAAK;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,gBAAgB;IACT,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EA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IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,4DAA4D;IACrD,GAAG,CAAC,aAAqB,EAAE,QAAwB;QACxD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,4CAwBC","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 Schema\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * @public\n */\nexport class EntityJsClassMap {\n private readonly _classMap = new Map<string, typeof Entity>();\n\n /** @internal */\n public has(classFullName: string): boolean {\n return this._classMap.has(classFullName.toLowerCase());\n }\n\n /** @internal */\n public get(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** @internal */\n public set(classFullName: string, entityClass: typeof Entity): void {\n this._classMap.set(classFullName.toLowerCase(), entityClass);\n }\n\n /** @internal */\n public delete(classFullName: string): boolean {\n return this._classMap.delete(classFullName.toLowerCase());\n }\n\n /** @internal */\n public clear(): void {\n this._classMap.clear();\n }\n\n /** @internal */\n public [Symbol.iterator](): IterableIterator<[string, typeof Entity]> {\n return this._classMap[Symbol.iterator]();\n }\n\n /**\n * Registers a single `entityClass` defined in the specified `schema`.\n * This method registers the class globally. To register a class for a specific iModel, use [[IModelDb.jsClassMap]].\n *\n * @param entityClass - The JavaScript class that implements the BIS [ECClass](@itwin/core-common) to be registered.\n * @param schema - The schema that contains the `entityClass`.\n *\n * @throws Error if the class is already registered.\n *\n * @public\n */\n public register(entityClass: typeof Entity, schema: typeof Schema): void {\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n entityClass.schema = schema;\n this.set(key, entityClass);\n }\n}\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup\n * to establish their mappings.\n *\n * When creating custom Entity subclasses for registration, you should:\n * - Override the `className` property to match your ECClass name:\n * ```typescript\n * public static override get className() { return \"TestElement\"; }\n * ```\n * - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration\n *\n * @public\n */\nexport class ClassRegistry {\n private static readonly _globalClassMap = new EntityJsClassMap();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** Register a single `entityClass` defined in the specified `schema`.\n * @see [[registerModule]] to register multiple classes.\n * @public\n */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n this._globalClassMap.register(entityClass, schema);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n iModel.schemaMap.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel[_nativeDb].getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${entityMetaData.ecclass} has no superclass`);\n\n // make sure schema exists\n let schema = iModel.schemaMap.get(domainName) ?? Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superClassFullName = entityMetaData.baseClasses[0].toLowerCase();\n const superclass = iModel.jsClassMap.get(superClassFullName) ?? this._globalClassMap.get(superClassFullName);\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${entityMetaData.ecclass}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel[_nativeDb].getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n iModel.jsClassMap.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from [[Entity]].\n * [[register]] will be invoked for each subclass of `Entity` exported by `moduleObj`.\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema that contains all of the [ECClass]($ecschema-metadata)es exported by `moduleObj`.\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._globalClassMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n return iModel.jsClassMap.get(key) ?? this._globalClassMap.get(key) ?? this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterClass(classFullName: string) { return this._globalClassMap.delete(classFullName.toLowerCase()); }\n\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._globalClassMap)) {\n if (entry[1].schema === schema)\n this.unregisterClass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `getSchemaView()` from the `iModel` instead.\n *\n * @example\n * @\n * Current Usage:\n * ```ts\n * const metaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(\"SchemaName:ClassName\");\n * ```\n *\n * Replacement:\n * ```ts\n * const view = await iModel.getSchemaView();\n * const cls = view.findClass(\"SchemaName:ClassName\");\n * ```\n */\nexport class MetaDataRegistry {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _registry = new Map<string, EntityMetaData>();\n private _classIdToName = new Map<Id64String, string>();\n\n /** Get the specified Entity metadata */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public find(classFullName: string): EntityMetaData | undefined {\n return this._registry.get(classFullName.toLowerCase());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public findByClassId(classId: Id64String): EntityMetaData | undefined {\n const name = this._classIdToName.get(classId);\n return undefined !== name ? this.find(name) : undefined;\n }\n\n /** Add metadata to the cache */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public add(classFullName: string, metaData: EntityMetaData): void {\n const name = classFullName.toLowerCase();\n this._registry.set(name, metaData);\n this._classIdToName.set(metaData.classId, name);\n }\n}\n"]}
@@ -56,7 +56,7 @@ export declare class CodeSpecs {
56
56
  * @returns The Id of the persistent CodeSpec.
57
57
  * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec
58
58
  * @throws IModelError if the insertion fails
59
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, codeSpec) instead.
59
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, codeSpec) instead.
60
60
  */
61
61
  insert(codeSpec: CodeSpec): Id64String;
62
62
  /** Add a new CodeSpec to the IModelDb.
@@ -64,7 +64,7 @@ export declare class CodeSpecs {
64
64
  * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.
65
65
  * @returns The Id of the persistent CodeSpec.
66
66
  * @throws IModelError if the insertion fails
67
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, ...) instead.
67
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, ...) instead.
68
68
  */
69
69
  insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;
70
70
  /** Update the Json properties of an existing CodeSpec.
@@ -77,7 +77,7 @@ export declare class CodeSpecs {
77
77
  /** Update the Json properties of an existing CodeSpec.
78
78
  * @param codeSpec The codeSpec holding Json properties values to update.
79
79
  * @throws if unable to update the codeSpec.
80
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use CodeSpecs.updateProperties(txn, codeSpec) instead.
80
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use CodeSpecs.updateProperties(txn, codeSpec) instead.
81
81
  */
82
82
  updateProperties(codeSpec: CodeSpec): void;
83
83
  /** Load a CodeSpec from the iModel
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA4G;AAC5G,uCAAoC;AAGpC,gDAAkD;AAElD;;GAEG;AACH,MAAa,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,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,IAAY;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE;YACL,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CAA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AAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAjPH,8BAkPC","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, EditTxnError, IModelError } from \"@itwin/core-common\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\nimport { _implicitTxn } from \"./internal/Symbols\";\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 txn The active EditTxn.\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 * @beta\n */\n public insert(txn: EditTxn, codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the iModel.\n * @param txn The active EditTxn.\n * @param name The name for the new CodeSpec.\n * @param properties The properties of 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 * @beta\n */\n public insert(txn: EditTxn, name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\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 * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, codeSpec) instead.\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 * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, ...) instead.\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(\n txnOrCodeSpec: EditTxn | CodeSpec | string,\n codeSpecOrNameOrProps?: CodeSpec | string | CodeSpecProperties | CodeScopeSpec.Type,\n props?: CodeSpecProperties | CodeScopeSpec.Type,\n ): Id64String {\n if (txnOrCodeSpec instanceof EditTxn) {\n const txn = txnOrCodeSpec;\n if (txn.iModel !== this._imodel)\n EditTxnError.throwError(\"wrong-imodel\", \"EditTxn does not belong to this iModel\", txn.iModel.key);\n // CodeSpec insertion writes directly to SQLite, so enforce txn writability explicitly.\n txn.verifyWriteable();\n if (codeSpecOrNameOrProps instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrNameOrProps.name, codeSpecOrNameOrProps.properties);\n codeSpecOrNameOrProps.id = id;\n return id;\n }\n if (typeof codeSpecOrNameOrProps !== \"string\" || props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrNameOrProps, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrNameOrProps, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n // Deprecated overloads - use implicit transaction.\n if (txnOrCodeSpec instanceof CodeSpec)\n return this.insert(this._imodel[_implicitTxn], txnOrCodeSpec);\n\n if (codeSpecOrNameOrProps === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof codeSpecOrNameOrProps === \"string\" || codeSpecOrNameOrProps instanceof CodeSpec)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n return this.insert(this._imodel[_implicitTxn], txnOrCodeSpec, codeSpecOrNameOrProps);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param txn The active EditTxn.\n * @param codeSpec The codeSpec holding Json properties values to update.\n * @throws if unable to update the codeSpec.\n * @beta\n */\n public updateProperties(txn: EditTxn, codeSpec: CodeSpec): void;\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 * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use CodeSpecs.updateProperties(txn, codeSpec) instead.\n */\n public updateProperties(codeSpec: CodeSpec): void;\n public updateProperties(txnOrCodeSpec: EditTxn | CodeSpec, codeSpec?: CodeSpec): void {\n let effectiveTxn: EditTxn;\n let effectiveCodeSpec: CodeSpec;\n\n if (txnOrCodeSpec instanceof EditTxn) {\n effectiveTxn = txnOrCodeSpec;\n if (effectiveTxn.iModel !== this._imodel)\n EditTxnError.throwError(\"wrong-imodel\", \"EditTxn does not belong to this iModel\", effectiveTxn.iModel.key);\n\n if (undefined === codeSpec)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n effectiveCodeSpec = codeSpec;\n } else {\n effectiveTxn = this._imodel[_implicitTxn];\n effectiveCodeSpec = txnOrCodeSpec;\n }\n\n effectiveTxn.verifyWriteable();\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(effectiveCodeSpec.properties));\n stmt.bindId(2, effectiveCodeSpec.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
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA4G;AAC5G,uCAAoC;AAGpC,gDAAkD;AAElD;;GAEG;AACH,MAAa,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,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,IAAY;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE;YACL,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CAAC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AC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAjPH,8BAkPC","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, EditTxnError, IModelError } from \"@itwin/core-common\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\nimport { _implicitTxn } from \"./internal/Symbols\";\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 txn The active EditTxn.\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 * @beta\n */\n public insert(txn: EditTxn, codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the iModel.\n * @param txn The active EditTxn.\n * @param name The name for the new CodeSpec.\n * @param properties The properties of 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 * @beta\n */\n public insert(txn: EditTxn, name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\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 * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, codeSpec) instead.\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 * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use CodeSpecs.insert(txn, ...) instead.\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(\n txnOrCodeSpec: EditTxn | CodeSpec | string,\n codeSpecOrNameOrProps?: CodeSpec | string | CodeSpecProperties | CodeScopeSpec.Type,\n props?: CodeSpecProperties | CodeScopeSpec.Type,\n ): Id64String {\n if (txnOrCodeSpec instanceof EditTxn) {\n const txn = txnOrCodeSpec;\n if (txn.iModel !== this._imodel)\n EditTxnError.throwError(\"wrong-imodel\", \"EditTxn does not belong to this iModel\", txn.iModel.key);\n // CodeSpec insertion writes directly to SQLite, so enforce txn writability explicitly.\n txn.verifyWriteable();\n if (codeSpecOrNameOrProps instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrNameOrProps.name, codeSpecOrNameOrProps.properties);\n codeSpecOrNameOrProps.id = id;\n return id;\n }\n if (typeof codeSpecOrNameOrProps !== \"string\" || props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrNameOrProps, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrNameOrProps, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n // Deprecated overloads - use implicit transaction.\n if (txnOrCodeSpec instanceof CodeSpec)\n return this.insert(this._imodel[_implicitTxn], txnOrCodeSpec);\n\n if (codeSpecOrNameOrProps === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof codeSpecOrNameOrProps === \"string\" || codeSpecOrNameOrProps instanceof CodeSpec)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n return this.insert(this._imodel[_implicitTxn], txnOrCodeSpec, codeSpecOrNameOrProps);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param txn The active EditTxn.\n * @param codeSpec The codeSpec holding Json properties values to update.\n * @throws if unable to update the codeSpec.\n * @beta\n */\n public updateProperties(txn: EditTxn, codeSpec: CodeSpec): void;\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 * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use CodeSpecs.updateProperties(txn, codeSpec) instead.\n */\n public updateProperties(codeSpec: CodeSpec): void;\n public updateProperties(txnOrCodeSpec: EditTxn | CodeSpec, codeSpec?: CodeSpec): void {\n let effectiveTxn: EditTxn;\n let effectiveCodeSpec: CodeSpec;\n\n if (txnOrCodeSpec instanceof EditTxn) {\n effectiveTxn = txnOrCodeSpec;\n if (effectiveTxn.iModel !== this._imodel)\n EditTxnError.throwError(\"wrong-imodel\", \"EditTxn does not belong to this iModel\", effectiveTxn.iModel.key);\n\n if (undefined === codeSpec)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n effectiveCodeSpec = codeSpec;\n } else {\n effectiveTxn = this._imodel[_implicitTxn];\n effectiveCodeSpec = txnOrCodeSpec;\n }\n\n effectiveTxn.verifyWriteable();\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(effectiveCodeSpec.properties));\n stmt.bindId(2, effectiveCodeSpec.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"]}
@@ -60,7 +60,7 @@ export declare class DisplayStyle2d extends DisplayStyle {
60
60
  static insert(txn: EditTxn, definitionModelId: Id64String, name: string): Id64String;
61
61
  /**
62
62
  * Insert a DisplayStyle2d for use by a ViewDefinition.
63
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use DisplayStyle2d.insert(txn, ...) instead.
63
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use DisplayStyle2d.insert(txn, ...) instead.
64
64
  */
65
65
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String;
66
66
  }
@@ -112,7 +112,7 @@ export declare class DisplayStyle3d extends DisplayStyle {
112
112
  static insert(txn: EditTxn, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;
113
113
  /**
114
114
  * Insert a DisplayStyle3d for use by a ViewDefinition.
115
- * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use DisplayStyle3d.insert(txn, ...) instead.
115
+ * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use DisplayStyle3d.insert(txn, ...) instead.
116
116
  */
117
117
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;
118
118
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayStyle.js","sourceRoot":"","sources":["../../src/DisplayStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0G;AAC1G,oDAG4B;AAC5B,uCAA8D;AAC9D,uCAAoC;AAIpC,gDAAkD;AAElD;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,2BAAiB;IACnD,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IAGzE,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;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,QAAQ,CAAC,CAAC;IACzD,CAAC;IAiBM,MAAM,CAAC,MAAM,CAAC,OAA2B,EAAE,iBAA6B,EAAE,IAAY,EAAE,OAAqC;QAClI,MAAM,GAAG,GAAG,OAAO,YAAY,iBAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAY,CAAC,CAAC;QACzE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/E,OAAO,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF;AAnID,wCAmIC","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 { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\nimport { DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\nimport { _implicitTxn } from \"./internal/Symbols\";\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);\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 /**\n * Insert a DisplayStyle2d for use by a ViewDefinition.\n * @param txn The EditTxn to use\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 * @beta\n */\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string): Id64String;\n /**\n * Insert a DisplayStyle2d for use by a ViewDefinition.\n * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use DisplayStyle2d.insert(txn, ...) instead.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const displayStyle = this.create(txn.iModel, definitionModelId, name);\n return displayStyle.insert(txn);\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 txn The EditTxn to use\n * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]\n * @param name The name of the DisplayStyle3d\n * @param options Creation options\n * @returns The Id of the newly inserted DisplayStyle3d element.\n * @throws [[IModelError]] if unable to insert the element.\n * @beta\n */\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;\n /**\n * Insert a DisplayStyle3d for use by a ViewDefinition.\n * @deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use DisplayStyle3d.insert(txn, ...) instead.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const displayStyle = this.create(txn.iModel, definitionModelId, name, options);\n return displayStyle.insert(txn);\n }\n}\n\n\n\n"]}
1
+ {"version":3,"file":"DisplayStyle.js","sourceRoot":"","sources":["../../src/DisplayStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0G;AAC1G,oDAG4B;AAC5B,uCAA8D;AAC9D,uCAAoC;AAIpC,gDAAkD;AAElD;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,2BAAiB;IACnD,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IAGzE,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,YAAY;IACL,MAAM,CAAU,WAAW,CAAC,KAA4B;QAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC;QAC5D,qDAAqD;QACrD,IAAI,CAAC,cAAc,EAAE,0BAA0B,IAAI,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;YACpG,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,gBAAgB,CAAC;YACxE,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CA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O,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAC5C,IAAI,CAAC,SAAS;YACZ,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,uBAAS,EAAE,CAAC,MAAM,EAAE,CAAC;QAE5D,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,YAAY,sBAAQ,CAAC,CAAC,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;IAiBM,MAAM,CAAC,MAAM,CAAC,OAA2B,EAAE,iBAA6B,EAAE,IAAY,EAAE,OAAqC;QAClI,MAAM,GAAG,GAAG,OAAO,YAAY,iBAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAY,CAAC,CAAC;QACzE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/E,OAAO,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF;AAnID,wCAmIC","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 { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\nimport { DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\nimport { _implicitTxn } from \"./internal/Symbols\";\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);\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 /**\n * Insert a DisplayStyle2d for use by a ViewDefinition.\n * @param txn The EditTxn to use\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 * @beta\n */\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string): Id64String;\n /**\n * Insert a DisplayStyle2d for use by a ViewDefinition.\n * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use DisplayStyle2d.insert(txn, ...) instead.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const displayStyle = this.create(txn.iModel, definitionModelId, name);\n return displayStyle.insert(txn);\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 txn The EditTxn to use\n * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]\n * @param name The name of the DisplayStyle3d\n * @param options Creation options\n * @returns The Id of the newly inserted DisplayStyle3d element.\n * @throws [[IModelError]] if unable to insert the element.\n * @beta\n */\n public static insert(txn: EditTxn, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;\n /**\n * Insert a DisplayStyle3d for use by a ViewDefinition.\n * @deprecated in 5.9.0 - will not be removed until after 2026-08-04. Use DisplayStyle3d.insert(txn, ...) instead.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const displayStyle = this.create(txn.iModel, definitionModelId, name, options);\n return displayStyle.insert(txn);\n }\n}\n\n\n\n"]}