@itwin/core-backend 5.9.0-dev.4 → 5.9.0-dev.6

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 (658) hide show
  1. package/lib/cjs/BackendHubAccess.js.map +1 -1
  2. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  3. package/lib/cjs/BisCoreSchema.js.map +1 -1
  4. package/lib/cjs/BlobContainerService.js.map +1 -1
  5. package/lib/cjs/BriefcaseManager.js +3 -3
  6. package/lib/cjs/BriefcaseManager.js.map +1 -1
  7. package/lib/cjs/CatalogDb.js.map +1 -1
  8. package/lib/cjs/Category.d.ts +37 -7
  9. package/lib/cjs/Category.d.ts.map +1 -1
  10. package/lib/cjs/Category.js +33 -42
  11. package/lib/cjs/Category.js.map +1 -1
  12. package/lib/cjs/ChangeSummaryManager.js +2 -2
  13. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  14. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  15. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  16. package/lib/cjs/ChangesetECAdaptor.js +253 -250
  17. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  18. package/lib/cjs/ChannelControl.d.ts +29 -0
  19. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  20. package/lib/cjs/ChannelControl.js.map +1 -1
  21. package/lib/cjs/CheckpointManager.js +1 -1
  22. package/lib/cjs/CheckpointManager.js.map +1 -1
  23. package/lib/cjs/ClassRegistry.js +5 -5
  24. package/lib/cjs/ClassRegistry.js.map +1 -1
  25. package/lib/cjs/CloudSqlite.js.map +1 -1
  26. package/lib/cjs/CodeService.js.map +1 -1
  27. package/lib/cjs/CodeSpecs.d.ts +32 -3
  28. package/lib/cjs/CodeSpecs.d.ts.map +1 -1
  29. package/lib/cjs/CodeSpecs.js +48 -20
  30. package/lib/cjs/CodeSpecs.js.map +1 -1
  31. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  32. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  33. package/lib/cjs/DevTools.js.map +1 -1
  34. package/lib/cjs/DisplayStyle.d.ts +18 -3
  35. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  36. package/lib/cjs/DisplayStyle.js +10 -21
  37. package/lib/cjs/DisplayStyle.js.map +1 -1
  38. package/lib/cjs/ECDb.js.map +1 -1
  39. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  40. package/lib/cjs/ECSqlRowExecutor.js.map +1 -1
  41. package/lib/cjs/ECSqlStatement.js.map +1 -1
  42. package/lib/cjs/ECSqlSyncReader.js.map +1 -1
  43. package/lib/cjs/EditTxn.d.ts +262 -0
  44. package/lib/cjs/EditTxn.d.ts.map +1 -0
  45. package/lib/cjs/EditTxn.js +548 -0
  46. package/lib/cjs/EditTxn.js.map +1 -0
  47. package/lib/cjs/Element.d.ts +74 -5
  48. package/lib/cjs/Element.d.ts.map +1 -1
  49. package/lib/cjs/Element.js +63 -75
  50. package/lib/cjs/Element.js.map +1 -1
  51. package/lib/cjs/ElementAspect.d.ts +10 -0
  52. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  53. package/lib/cjs/ElementAspect.js +21 -12
  54. package/lib/cjs/ElementAspect.js.map +1 -1
  55. package/lib/cjs/ElementGraphics.js.map +1 -1
  56. package/lib/cjs/ElementTreeWalker.d.ts +56 -3
  57. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  58. package/lib/cjs/ElementTreeWalker.js +53 -40
  59. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  60. package/lib/cjs/Entity.js.map +1 -1
  61. package/lib/cjs/EntityReferences.js.map +1 -1
  62. package/lib/cjs/ExportGraphics.js.map +1 -1
  63. package/lib/cjs/ExternalSource.d.ts +11 -2
  64. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  65. package/lib/cjs/ExternalSource.js +10 -8
  66. package/lib/cjs/ExternalSource.js.map +1 -1
  67. package/lib/cjs/FontFile.js.map +1 -1
  68. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  69. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  70. package/lib/cjs/GeometrySummary.js +47 -47
  71. package/lib/cjs/GeometrySummary.js.map +1 -1
  72. package/lib/cjs/IModelDb.d.ts +66 -22
  73. package/lib/cjs/IModelDb.d.ts.map +1 -1
  74. package/lib/cjs/IModelDb.js +182 -296
  75. package/lib/cjs/IModelDb.js.map +1 -1
  76. package/lib/cjs/IModelDbFonts.js.map +1 -1
  77. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  78. package/lib/cjs/IModelHost.d.ts +22 -0
  79. package/lib/cjs/IModelHost.d.ts.map +1 -1
  80. package/lib/cjs/IModelHost.js +9 -0
  81. package/lib/cjs/IModelHost.js.map +1 -1
  82. package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
  83. package/lib/cjs/IModelJsFs.js.map +1 -1
  84. package/lib/cjs/ImageSourceConversion.js.map +1 -1
  85. package/lib/cjs/IpcHost.js +2 -2
  86. package/lib/cjs/IpcHost.js.map +1 -1
  87. package/lib/cjs/LineStyle.d.ts +47 -7
  88. package/lib/cjs/LineStyle.d.ts.map +1 -1
  89. package/lib/cjs/LineStyle.js +38 -33
  90. package/lib/cjs/LineStyle.js.map +1 -1
  91. package/lib/cjs/LocalHub.js +1 -1
  92. package/lib/cjs/LocalHub.js.map +1 -1
  93. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  94. package/lib/cjs/LockControl.js.map +1 -1
  95. package/lib/cjs/Material.d.ts +8 -1
  96. package/lib/cjs/Material.d.ts.map +1 -1
  97. package/lib/cjs/Material.js +6 -12
  98. package/lib/cjs/Material.js.map +1 -1
  99. package/lib/cjs/Model.d.ts +59 -20
  100. package/lib/cjs/Model.d.ts.map +1 -1
  101. package/lib/cjs/Model.js +38 -80
  102. package/lib/cjs/Model.js.map +1 -1
  103. package/lib/cjs/NativeAppStorage.js.map +1 -1
  104. package/lib/cjs/NativeHost.js.map +1 -1
  105. package/lib/cjs/NavigationRelationship.js.map +1 -1
  106. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  107. package/lib/cjs/PropertyStore.js.map +1 -1
  108. package/lib/cjs/Relationship.d.ts +72 -7
  109. package/lib/cjs/Relationship.d.ts.map +1 -1
  110. package/lib/cjs/Relationship.js +39 -21
  111. package/lib/cjs/Relationship.js.map +1 -1
  112. package/lib/cjs/RpcBackend.js.map +1 -1
  113. package/lib/cjs/SQLiteDb.js.map +1 -1
  114. package/lib/cjs/Schema.js.map +1 -1
  115. package/lib/cjs/SchemaSync.js +4 -4
  116. package/lib/cjs/SchemaSync.js.map +1 -1
  117. package/lib/cjs/SchemaUtils.js.map +1 -1
  118. package/lib/cjs/SheetIndex.d.ts +9 -0
  119. package/lib/cjs/SheetIndex.d.ts.map +1 -1
  120. package/lib/cjs/SheetIndex.js +38 -35
  121. package/lib/cjs/SheetIndex.js.map +1 -1
  122. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  123. package/lib/cjs/SqliteStatement.js.map +1 -1
  124. package/lib/cjs/StashManager.js +1 -1
  125. package/lib/cjs/StashManager.js.map +1 -1
  126. package/lib/cjs/Texture.d.ts +6 -0
  127. package/lib/cjs/Texture.d.ts.map +1 -1
  128. package/lib/cjs/Texture.js +6 -14
  129. package/lib/cjs/Texture.js.map +1 -1
  130. package/lib/cjs/TileStorage.js.map +1 -1
  131. package/lib/cjs/TxnManager.d.ts +5 -5
  132. package/lib/cjs/TxnManager.d.ts.map +1 -1
  133. package/lib/cjs/TxnManager.js +23 -7
  134. package/lib/cjs/TxnManager.js.map +1 -1
  135. package/lib/cjs/ViewDefinition.d.ts +21 -1
  136. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  137. package/lib/cjs/ViewDefinition.js +27 -66
  138. package/lib/cjs/ViewDefinition.js.map +1 -1
  139. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  140. package/lib/cjs/ViewStore.js.map +1 -1
  141. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
  142. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  143. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +33 -27
  144. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  145. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  146. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  147. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  148. package/lib/cjs/annotations/TextAnnotationElement.js +6 -5
  149. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  150. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
  151. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
  152. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  153. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  154. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
  155. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
  156. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
  157. package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
  158. package/lib/cjs/core-backend.d.ts +1 -0
  159. package/lib/cjs/core-backend.d.ts.map +1 -1
  160. package/lib/cjs/core-backend.js +1 -0
  161. package/lib/cjs/core-backend.js.map +1 -1
  162. package/lib/cjs/domains/FunctionalElements.d.ts +6 -2
  163. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  164. package/lib/cjs/domains/FunctionalElements.js +8 -13
  165. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  166. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  167. package/lib/cjs/domains/GenericElements.d.ts +11 -4
  168. package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
  169. package/lib/cjs/domains/GenericElements.js +13 -24
  170. package/lib/cjs/domains/GenericElements.js.map +1 -1
  171. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  172. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
  173. package/lib/cjs/internal/ChannelAdmin.d.ts +15 -0
  174. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
  175. package/lib/cjs/internal/ChannelAdmin.js +5 -3
  176. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  177. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  178. package/lib/cjs/internal/FontFileImpl.js.map +1 -1
  179. package/lib/cjs/internal/HubMock.js.map +1 -1
  180. package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
  181. package/lib/cjs/internal/IntegrityCheck.js.map +1 -1
  182. package/lib/cjs/internal/NativePlatform.js.map +1 -1
  183. package/lib/cjs/internal/NoLocks.js.map +1 -1
  184. package/lib/cjs/internal/OnlineStatus.js.map +1 -1
  185. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  186. package/lib/cjs/internal/Symbols.d.ts +4 -0
  187. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  188. package/lib/cjs/internal/Symbols.js +5 -1
  189. package/lib/cjs/internal/Symbols.js.map +1 -1
  190. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  191. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  192. package/lib/cjs/internal/annotations/fields.js +7 -6
  193. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  194. package/lib/cjs/internal/cross-package.js.map +1 -1
  195. package/lib/cjs/internal/workspace/SettingsEditorImpl.js.map +1 -1
  196. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  197. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  198. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  199. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  200. package/lib/cjs/rpc/multipart.js.map +1 -1
  201. package/lib/cjs/rpc/tracing.js.map +1 -1
  202. package/lib/cjs/rpc/web/logging.js.map +1 -1
  203. package/lib/cjs/rpc/web/request.js.map +1 -1
  204. package/lib/cjs/rpc/web/response.js.map +1 -1
  205. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  206. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  207. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  208. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  209. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  210. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  211. package/lib/cjs/workspace/Settings.js.map +1 -1
  212. package/lib/cjs/workspace/SettingsDb.js.map +1 -1
  213. package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
  214. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  215. package/lib/cjs/workspace/Workspace.js.map +1 -1
  216. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  217. package/lib/esm/BackendHubAccess.js.map +1 -1
  218. package/lib/esm/BackendLoggerCategory.js.map +1 -1
  219. package/lib/esm/BisCoreSchema.js.map +1 -1
  220. package/lib/esm/BlobContainerService.js.map +1 -1
  221. package/lib/esm/BriefcaseManager.js +3 -3
  222. package/lib/esm/BriefcaseManager.js.map +1 -1
  223. package/lib/esm/CatalogDb.js.map +1 -1
  224. package/lib/esm/Category.d.ts +37 -7
  225. package/lib/esm/Category.d.ts.map +1 -1
  226. package/lib/esm/Category.js +33 -42
  227. package/lib/esm/Category.js.map +1 -1
  228. package/lib/esm/ChangeSummaryManager.js +2 -2
  229. package/lib/esm/ChangeSummaryManager.js.map +1 -1
  230. package/lib/esm/ChangedElementsDb.js.map +1 -1
  231. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  232. package/lib/esm/ChangesetECAdaptor.js +253 -250
  233. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  234. package/lib/esm/ChannelControl.d.ts +29 -0
  235. package/lib/esm/ChannelControl.d.ts.map +1 -1
  236. package/lib/esm/ChannelControl.js.map +1 -1
  237. package/lib/esm/CheckpointManager.js +1 -1
  238. package/lib/esm/CheckpointManager.js.map +1 -1
  239. package/lib/esm/ClassRegistry.js +5 -5
  240. package/lib/esm/ClassRegistry.js.map +1 -1
  241. package/lib/esm/CloudSqlite.js.map +1 -1
  242. package/lib/esm/CodeService.js.map +1 -1
  243. package/lib/esm/CodeSpecs.d.ts +32 -3
  244. package/lib/esm/CodeSpecs.d.ts.map +1 -1
  245. package/lib/esm/CodeSpecs.js +49 -21
  246. package/lib/esm/CodeSpecs.js.map +1 -1
  247. package/lib/esm/ConcurrentQuery.js.map +1 -1
  248. package/lib/esm/CustomViewState3dCreator.js.map +1 -1
  249. package/lib/esm/DevTools.js.map +1 -1
  250. package/lib/esm/DisplayStyle.d.ts +18 -3
  251. package/lib/esm/DisplayStyle.d.ts.map +1 -1
  252. package/lib/esm/DisplayStyle.js +10 -21
  253. package/lib/esm/DisplayStyle.js.map +1 -1
  254. package/lib/esm/ECDb.js.map +1 -1
  255. package/lib/esm/ECSchemaXmlContext.js.map +1 -1
  256. package/lib/esm/ECSqlRowExecutor.js.map +1 -1
  257. package/lib/esm/ECSqlStatement.js.map +1 -1
  258. package/lib/esm/ECSqlSyncReader.js.map +1 -1
  259. package/lib/esm/EditTxn.d.ts +262 -0
  260. package/lib/esm/EditTxn.d.ts.map +1 -0
  261. package/lib/esm/EditTxn.js +543 -0
  262. package/lib/esm/EditTxn.js.map +1 -0
  263. package/lib/esm/Element.d.ts +74 -5
  264. package/lib/esm/Element.d.ts.map +1 -1
  265. package/lib/esm/Element.js +64 -76
  266. package/lib/esm/Element.js.map +1 -1
  267. package/lib/esm/ElementAspect.d.ts +10 -0
  268. package/lib/esm/ElementAspect.d.ts.map +1 -1
  269. package/lib/esm/ElementAspect.js +22 -13
  270. package/lib/esm/ElementAspect.js.map +1 -1
  271. package/lib/esm/ElementGraphics.js.map +1 -1
  272. package/lib/esm/ElementTreeWalker.d.ts +56 -3
  273. package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
  274. package/lib/esm/ElementTreeWalker.js +53 -40
  275. package/lib/esm/ElementTreeWalker.js.map +1 -1
  276. package/lib/esm/Entity.js.map +1 -1
  277. package/lib/esm/EntityReferences.js.map +1 -1
  278. package/lib/esm/ExportGraphics.js.map +1 -1
  279. package/lib/esm/ExternalSource.d.ts +11 -2
  280. package/lib/esm/ExternalSource.d.ts.map +1 -1
  281. package/lib/esm/ExternalSource.js +10 -8
  282. package/lib/esm/ExternalSource.js.map +1 -1
  283. package/lib/esm/FontFile.js.map +1 -1
  284. package/lib/esm/GeoCoordConfig.js.map +1 -1
  285. package/lib/esm/GeographicCRSServices.js.map +1 -1
  286. package/lib/esm/GeometrySummary.js +47 -47
  287. package/lib/esm/GeometrySummary.js.map +1 -1
  288. package/lib/esm/IModelDb.d.ts +66 -22
  289. package/lib/esm/IModelDb.d.ts.map +1 -1
  290. package/lib/esm/IModelDb.js +184 -298
  291. package/lib/esm/IModelDb.js.map +1 -1
  292. package/lib/esm/IModelDbFonts.js.map +1 -1
  293. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  294. package/lib/esm/IModelHost.d.ts +22 -0
  295. package/lib/esm/IModelHost.d.ts.map +1 -1
  296. package/lib/esm/IModelHost.js +9 -0
  297. package/lib/esm/IModelHost.js.map +1 -1
  298. package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
  299. package/lib/esm/IModelJsFs.js.map +1 -1
  300. package/lib/esm/ImageSourceConversion.js.map +1 -1
  301. package/lib/esm/IpcHost.js +3 -3
  302. package/lib/esm/IpcHost.js.map +1 -1
  303. package/lib/esm/LineStyle.d.ts +47 -7
  304. package/lib/esm/LineStyle.d.ts.map +1 -1
  305. package/lib/esm/LineStyle.js +38 -33
  306. package/lib/esm/LineStyle.js.map +1 -1
  307. package/lib/esm/LocalHub.js +1 -1
  308. package/lib/esm/LocalHub.js.map +1 -1
  309. package/lib/esm/LocalhostIpcHost.js.map +1 -1
  310. package/lib/esm/LockControl.js.map +1 -1
  311. package/lib/esm/Material.d.ts +8 -1
  312. package/lib/esm/Material.d.ts.map +1 -1
  313. package/lib/esm/Material.js +6 -12
  314. package/lib/esm/Material.js.map +1 -1
  315. package/lib/esm/Model.d.ts +59 -20
  316. package/lib/esm/Model.d.ts.map +1 -1
  317. package/lib/esm/Model.js +39 -81
  318. package/lib/esm/Model.js.map +1 -1
  319. package/lib/esm/NativeAppStorage.js.map +1 -1
  320. package/lib/esm/NativeHost.js.map +1 -1
  321. package/lib/esm/NavigationRelationship.js.map +1 -1
  322. package/lib/esm/PromiseMemoizer.js.map +1 -1
  323. package/lib/esm/PropertyStore.js.map +1 -1
  324. package/lib/esm/Relationship.d.ts +72 -7
  325. package/lib/esm/Relationship.d.ts.map +1 -1
  326. package/lib/esm/Relationship.js +40 -22
  327. package/lib/esm/Relationship.js.map +1 -1
  328. package/lib/esm/RpcBackend.js.map +1 -1
  329. package/lib/esm/SQLiteDb.js.map +1 -1
  330. package/lib/esm/Schema.js.map +1 -1
  331. package/lib/esm/SchemaSync.js +5 -5
  332. package/lib/esm/SchemaSync.js.map +1 -1
  333. package/lib/esm/SchemaUtils.js.map +1 -1
  334. package/lib/esm/SheetIndex.d.ts +9 -0
  335. package/lib/esm/SheetIndex.d.ts.map +1 -1
  336. package/lib/esm/SheetIndex.js +38 -35
  337. package/lib/esm/SheetIndex.js.map +1 -1
  338. package/lib/esm/SqliteChangesetReader.js.map +1 -1
  339. package/lib/esm/SqliteStatement.js.map +1 -1
  340. package/lib/esm/StashManager.js +1 -1
  341. package/lib/esm/StashManager.js.map +1 -1
  342. package/lib/esm/Texture.d.ts +6 -0
  343. package/lib/esm/Texture.d.ts.map +1 -1
  344. package/lib/esm/Texture.js +6 -14
  345. package/lib/esm/Texture.js.map +1 -1
  346. package/lib/esm/TileStorage.js.map +1 -1
  347. package/lib/esm/TxnManager.d.ts +5 -5
  348. package/lib/esm/TxnManager.d.ts.map +1 -1
  349. package/lib/esm/TxnManager.js +23 -7
  350. package/lib/esm/TxnManager.js.map +1 -1
  351. package/lib/esm/ViewDefinition.d.ts +21 -1
  352. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  353. package/lib/esm/ViewDefinition.js +27 -66
  354. package/lib/esm/ViewDefinition.js.map +1 -1
  355. package/lib/esm/ViewStateHydrator.js.map +1 -1
  356. package/lib/esm/ViewStore.js.map +1 -1
  357. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
  358. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  359. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -27
  360. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  361. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  362. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  363. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  364. package/lib/esm/annotations/TextAnnotationElement.js +6 -5
  365. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  366. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
  367. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
  368. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  369. package/lib/esm/core-backend.d.ts +1 -0
  370. package/lib/esm/core-backend.d.ts.map +1 -1
  371. package/lib/esm/core-backend.js +1 -0
  372. package/lib/esm/core-backend.js.map +1 -1
  373. package/lib/esm/domains/FunctionalElements.d.ts +6 -2
  374. package/lib/esm/domains/FunctionalElements.d.ts.map +1 -1
  375. package/lib/esm/domains/FunctionalElements.js +8 -13
  376. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  377. package/lib/esm/domains/FunctionalSchema.js.map +1 -1
  378. package/lib/esm/domains/GenericElements.d.ts +11 -4
  379. package/lib/esm/domains/GenericElements.d.ts.map +1 -1
  380. package/lib/esm/domains/GenericElements.js +13 -24
  381. package/lib/esm/domains/GenericElements.js.map +1 -1
  382. package/lib/esm/domains/GenericSchema.js.map +1 -1
  383. package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
  384. package/lib/esm/internal/ChannelAdmin.d.ts +15 -0
  385. package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
  386. package/lib/esm/internal/ChannelAdmin.js +6 -4
  387. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  388. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  389. package/lib/esm/internal/FontFileImpl.js.map +1 -1
  390. package/lib/esm/internal/HubMock.js.map +1 -1
  391. package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
  392. package/lib/esm/internal/IntegrityCheck.js.map +1 -1
  393. package/lib/esm/internal/NativePlatform.js.map +1 -1
  394. package/lib/esm/internal/NoLocks.js.map +1 -1
  395. package/lib/esm/internal/OnlineStatus.js.map +1 -1
  396. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  397. package/lib/esm/internal/Symbols.d.ts +4 -0
  398. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  399. package/lib/esm/internal/Symbols.js +4 -0
  400. package/lib/esm/internal/Symbols.js.map +1 -1
  401. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  402. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  403. package/lib/esm/internal/annotations/fields.js +7 -6
  404. package/lib/esm/internal/annotations/fields.js.map +1 -1
  405. package/lib/esm/internal/cross-package.js.map +1 -1
  406. package/lib/esm/internal/workspace/SettingsEditorImpl.js.map +1 -1
  407. package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
  408. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  409. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  410. package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  411. package/lib/esm/rpc/multipart.js.map +1 -1
  412. package/lib/esm/rpc/tracing.js.map +1 -1
  413. package/lib/esm/rpc/web/logging.js.map +1 -1
  414. package/lib/esm/rpc/web/request.js.map +1 -1
  415. package/lib/esm/rpc/web/response.js.map +1 -1
  416. package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  417. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  418. package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  419. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  420. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  421. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  422. package/lib/esm/test/AdvancedEqual.js.map +1 -1
  423. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  424. package/lib/esm/test/AttachDb.test.js +11 -11
  425. package/lib/esm/test/AttachDb.test.js.map +1 -1
  426. package/lib/esm/test/ElementDrivesElement.test.d.ts +20 -19
  427. package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -1
  428. package/lib/esm/test/ElementDrivesElement.test.js +134 -119
  429. package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
  430. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  431. package/lib/esm/test/GeometryTestUtil.js.map +1 -1
  432. package/lib/esm/test/IModelHost.test.js +56 -2
  433. package/lib/esm/test/IModelHost.test.js.map +1 -1
  434. package/lib/esm/test/IModelTestUtils.d.ts +23 -23
  435. package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
  436. package/lib/esm/test/IModelTestUtils.js +466 -449
  437. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  438. package/lib/esm/test/ImageSourceConversion.test.js.map +1 -1
  439. package/lib/esm/test/IpcHost.test.js.map +1 -1
  440. package/lib/esm/test/KnownTestLocations.js.map +1 -1
  441. package/lib/esm/test/PrintElementTree.js.map +1 -1
  442. package/lib/esm/test/PropertyDb.test.js +2 -2
  443. package/lib/esm/test/PropertyDb.test.js.map +1 -1
  444. package/lib/esm/test/RevisionUtility.js.map +1 -1
  445. package/lib/esm/test/SchemaUtils.test.js +25 -25
  446. package/lib/esm/test/SchemaUtils.test.js.map +1 -1
  447. package/lib/esm/test/SequentialLogMatcher.js.map +1 -1
  448. package/lib/esm/test/SquashSchemaAndDataChanges.test.js +156 -147
  449. package/lib/esm/test/SquashSchemaAndDataChanges.test.js.map +1 -1
  450. package/lib/esm/test/TestChangeSetUtility.d.ts.map +1 -1
  451. package/lib/esm/test/TestChangeSetUtility.js +11 -7
  452. package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
  453. package/lib/esm/test/TestEditTxn.d.ts +8 -0
  454. package/lib/esm/test/TestEditTxn.d.ts.map +1 -0
  455. package/lib/esm/test/TestEditTxn.js +34 -0
  456. package/lib/esm/test/TestEditTxn.js.map +1 -0
  457. package/lib/esm/test/TestUtils.d.ts +1 -0
  458. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  459. package/lib/esm/test/TestUtils.js +8 -1
  460. package/lib/esm/test/TestUtils.js.map +1 -1
  461. package/lib/esm/test/annotations/Fields.test.js +135 -143
  462. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  463. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  464. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  465. package/lib/esm/test/annotations/TextAnnotation.test.js +156 -99
  466. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  467. package/lib/esm/test/annotations/TextBlock.test.js +5 -3
  468. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  469. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
  470. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  471. package/lib/esm/test/categories/Category.test.js +63 -3
  472. package/lib/esm/test/categories/Category.test.js.map +1 -1
  473. package/lib/esm/test/codespec/CodeSpec.test.js +88 -5
  474. package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
  475. package/lib/esm/test/ecdb/CTE.test.js +88 -88
  476. package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
  477. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +19 -19
  478. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  479. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +15 -15
  480. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
  481. package/lib/esm/test/ecdb/ECDb.test.js +72 -72
  482. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  483. package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -1
  484. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -1
  485. package/lib/esm/test/ecdb/ECSqlAst.test.js +68 -67
  486. package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
  487. package/lib/esm/test/ecdb/ECSqlQuery.test.js +6 -6
  488. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  489. package/lib/esm/test/ecdb/ECSqlStatement.test.js +332 -333
  490. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  491. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
  492. package/lib/esm/test/ecdb/QueryReaders.test.js +47 -44
  493. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  494. package/lib/esm/test/ecdb/SqliteStatement.test.js +2 -2
  495. package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
  496. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
  497. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +30 -28
  498. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
  499. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +21 -21
  500. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
  501. package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
  502. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  503. package/lib/esm/test/element/DeleteDefinitionElements.test.js +159 -143
  504. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  505. package/lib/esm/test/element/ElementAspect.test.js +90 -82
  506. package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
  507. package/lib/esm/test/element/ElementDependencyGraph.test.d.ts.map +1 -1
  508. package/lib/esm/test/element/ElementDependencyGraph.test.js +51 -43
  509. package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
  510. package/lib/esm/test/element/ElementRoundTrip.test.js +176 -177
  511. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  512. package/lib/esm/test/element/ExcludedElements.test.js +2 -2
  513. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  514. package/lib/esm/test/element/ExternalSource.test.js +40 -38
  515. package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
  516. package/lib/esm/test/element/NullStructArray.test.js +23 -22
  517. package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
  518. package/lib/esm/test/element/ProjectInformationRecord.test.js +5 -2
  519. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
  520. package/lib/esm/test/element/SheetInformationAspect.test.js +43 -11
  521. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
  522. package/lib/esm/test/element/UrlLink.test.js +2 -2
  523. package/lib/esm/test/element/UrlLink.test.js.map +1 -1
  524. package/lib/esm/test/font/FontFile.test.js.map +1 -1
  525. package/lib/esm/test/font/IModelDbFonts.test.js +87 -73
  526. package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
  527. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +194 -155
  528. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  529. package/lib/esm/test/hubaccess/BriefcaseManager.test.js +2 -4
  530. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  531. package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
  532. package/lib/esm/test/hubaccess/Rebase.test.js +369 -303
  533. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  534. package/lib/esm/test/hubaccess/SemanticRebase.test.js +467 -392
  535. package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
  536. package/lib/esm/test/imageData.js.map +1 -1
  537. package/lib/esm/test/imodel/Code.test.js +31 -31
  538. package/lib/esm/test/imodel/Code.test.js.map +1 -1
  539. package/lib/esm/test/imodel/ElementTreeWalker.test.js +57 -48
  540. package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
  541. package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -1
  542. package/lib/esm/test/imodel/IModel.test.js +463 -388
  543. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  544. package/lib/esm/test/imodel/ProjectExtents.test.js +2 -2
  545. package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
  546. package/lib/esm/test/imodel/SchemaXmlImport.test.js +13 -13
  547. package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
  548. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  549. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
  550. package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -1
  551. package/lib/esm/test/incrementalSchemaLocater/TestContext.js +2 -2
  552. package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -1
  553. package/lib/esm/test/index.d.ts +1 -0
  554. package/lib/esm/test/index.d.ts.map +1 -1
  555. package/lib/esm/test/index.js +1 -0
  556. package/lib/esm/test/index.js.map +1 -1
  557. package/lib/esm/test/misc/DevTools.test.js.map +1 -1
  558. package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -1
  559. package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
  560. package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -1
  561. package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -1
  562. package/lib/esm/test/rpc/response.test.js.map +1 -1
  563. package/lib/esm/test/schema/ClassRegistry.test.js +122 -121
  564. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  565. package/lib/esm/test/schema/FunctionalDomain.test.js +36 -34
  566. package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
  567. package/lib/esm/test/schema/GenericDomain.test.js +114 -94
  568. package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
  569. package/lib/esm/test/schema/IModelSchemaContext.test.js +11 -10
  570. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  571. package/lib/esm/test/schema/SchemaImportCallbacks.test.js +226 -211
  572. package/lib/esm/test/schema/SchemaImportCallbacks.test.js.map +1 -1
  573. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts +1 -3
  574. package/lib/esm/test/sheetindex/SheetIndex.test.d.ts.map +1 -1
  575. package/lib/esm/test/sheetindex/SheetIndex.test.js +312 -247
  576. package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
  577. package/lib/esm/test/standalone/ChangeMerge.test.js +101 -82
  578. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  579. package/lib/esm/test/standalone/ChangesetReader.test.js +242 -213
  580. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  581. package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -1
  582. package/lib/esm/test/standalone/DisplayStyle.test.js +43 -40
  583. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
  584. package/lib/esm/test/standalone/Drawing.test.js +4 -3
  585. package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
  586. package/lib/esm/test/standalone/EditTxn.test.d.ts +2 -0
  587. package/lib/esm/test/standalone/EditTxn.test.d.ts.map +1 -0
  588. package/lib/esm/test/standalone/EditTxn.test.js +219 -0
  589. package/lib/esm/test/standalone/EditTxn.test.js.map +1 -0
  590. package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
  591. package/lib/esm/test/standalone/ElementMesh.test.js +16 -13
  592. package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
  593. package/lib/esm/test/standalone/ExportGraphics.test.js +40 -34
  594. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  595. package/lib/esm/test/standalone/GeometryChangeEvents.test.js +11 -15
  596. package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
  597. package/lib/esm/test/standalone/GeometryStream.test.js +212 -165
  598. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  599. package/lib/esm/test/standalone/HubMock.test.js +31 -25
  600. package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
  601. package/lib/esm/test/standalone/IModelLimits.test.js +11 -8
  602. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
  603. package/lib/esm/test/standalone/IModelWrite.test.d.ts +2 -2
  604. package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -1
  605. package/lib/esm/test/standalone/IModelWrite.test.js +211 -169
  606. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  607. package/lib/esm/test/standalone/ITwinWorkspace.test.js.map +1 -1
  608. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js +25 -22
  609. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
  610. package/lib/esm/test/standalone/IntegrityCheck.test.js +20 -18
  611. package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
  612. package/lib/esm/test/standalone/MergeConflict.test.d.ts +2 -2
  613. package/lib/esm/test/standalone/MergeConflict.test.d.ts.map +1 -1
  614. package/lib/esm/test/standalone/MergeConflict.test.js +49 -33
  615. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
  616. package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -1
  617. package/lib/esm/test/standalone/RenderMaterialElement.test.js +5 -5
  618. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  619. package/lib/esm/test/standalone/RenderTimeline.test.js +3 -2
  620. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
  621. package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
  622. package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -1
  623. package/lib/esm/test/standalone/SectionDrawing.test.js +7 -7
  624. package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
  625. package/lib/esm/test/standalone/ServerBasedLocks.test.js +21 -19
  626. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  627. package/lib/esm/test/standalone/Setting.test.js.map +1 -1
  628. package/lib/esm/test/standalone/Settings.test.js +7 -4
  629. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  630. package/lib/esm/test/standalone/SettingsSchemas.test.js +2 -1
  631. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  632. package/lib/esm/test/standalone/SnapshotDb.test.js +3 -1
  633. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  634. package/lib/esm/test/standalone/StandaloneDb.test.js +27 -26
  635. package/lib/esm/test/standalone/StandaloneDb.test.js.map +1 -1
  636. package/lib/esm/test/standalone/Texture.test.js +5 -4
  637. package/lib/esm/test/standalone/Texture.test.js.map +1 -1
  638. package/lib/esm/test/standalone/TileCache.test.d.ts.map +1 -1
  639. package/lib/esm/test/standalone/TileCache.test.js +5 -3
  640. package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
  641. package/lib/esm/test/standalone/TileTree.test.js +35 -31
  642. package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
  643. package/lib/esm/test/standalone/TxnManager.test.js +700 -653
  644. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  645. package/lib/esm/test/standalone/ViewDefinition.test.js +295 -229
  646. package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
  647. package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
  648. package/lib/esm/test/standalone/Workspace.test.js +25 -23
  649. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  650. package/lib/esm/test/standalone/iModelDb.test.js.map +1 -1
  651. package/lib/esm/test/workspace/SettingsDb.test.js.map +1 -1
  652. package/lib/esm/workspace/Settings.js.map +1 -1
  653. package/lib/esm/workspace/SettingsDb.js.map +1 -1
  654. package/lib/esm/workspace/SettingsEditor.js.map +1 -1
  655. package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
  656. package/lib/esm/workspace/Workspace.js.map +1 -1
  657. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  658. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAY,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAiB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,0CAA0C;AAE1C;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACnB,gBAAgB;IACA,CAAC,SAAS,CAAC,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC3D,qBAAqB,GAAG,IAAI,cAAc,EAAmB,CAAC;IAEtE,gBAAgB;IACT,MAAM,CAAC,YAAY;QACxB,OAAO,IAAI,YAAY,CAAC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EATW,cAAc,GAAd,uBAAc,KAAd,uBAAc,QASzB;AAgDH,CAAC,EAjIgB,QAAQ,KAAR,QAAQ,QAiIxB","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 SQLiteDb\n */\n\nimport * as fs from \"fs\";\nimport { dirname } from \"path\";\nimport * as semver from \"semver\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\nimport { LocalFileName, SqliteError } from \"@itwin/core-common\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\n// cspell:ignore savepoint julianday rowid\n\n/**\n * A \"generic\" SQLiteDb. This class may be used to access local files or databases in a cloud container.\n * @public\n */\nexport class SQLiteDb {\n /** @internal */\n public readonly [_nativeDb] = new IModelNative.platform.SQLiteDb();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n\n /** @internal */\n public static createBlobIO(): SQLiteDb.BlobIO {\n return new IModelNative.platform.BlobIO();\n }\n\n /** alias for closeDb.\n * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use [[closeDb]]\n */\n public dispose(): void {\n this.closeDb();\n }\n\n /** Create a SQLiteDb\n * @param dbName The path to the SQLiteDb file to create.\n */\n public createDb(dbName: string): void;\n /** @beta */\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void {\n this[_nativeDb].createDb(dbName, container, params);\n }\n\n /** Open a SQLiteDb.\n * @param dbName The path to the SQLiteDb file to open\n */\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;\n /**\n * @param container optional CloudContainer holding database\n * @beta\n */\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void {\n this[_nativeDb].openDb(dbName, openMode, container);\n }\n\n /** Close SQLiteDb.\n * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.\n */\n public closeDb(saveChanges?: boolean): void {\n if (saveChanges && this.isOpen)\n this.saveChanges();\n this._sqliteStatementCache.clear();\n this[_nativeDb].closeDb();\n }\n\n /** Returns true if this SQLiteDb is open */\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\n\n /** Returns true if this SQLiteDb is open readonly */\n public get isReadonly(): boolean { return this[_nativeDb].isReadonly(); }\n\n /** Create a new table in this database. */\n protected createTable(args: {\n /** The name of the table to create. */\n tableName: string;\n /** all of the columns in the table. */\n columns: string;\n /** any unique or foreign key constraints */\n constraints?: string;\n /** if true, add a \"lastMod\" timestamp column and triggers to automatically update it. */\n addTimestamp?: boolean;\n }) {\n const timestampCol = args.addTimestamp ? \",lastMod TIMESTAMP NOT NULL DEFAULT(julianday('now'))\" : \"\";\n const constraints = args.constraints ? `,${args.constraints}` : \"\";\n this.executeSQL(`CREATE TABLE ${args.tableName}(${args.columns}${timestampCol}${constraints})`);\n if (args.addTimestamp)\n this.executeSQL(`CREATE TRIGGER ${args.tableName}_timestamp AFTER UPDATE ON ${args.tableName} WHEN old.lastMod=new.lastMod AND old.lastMod != julianday('now') BEGIN UPDATE ${args.tableName} SET lastMod=julianday('now') WHERE rowid=new.rowid; END`);\n }\n\n /**\n * Get the last modified date for a row in a table of this database.\n * @note the table must have been created with `addTimestamp: true`\n */\n public readLastModTime(tableName: string, rowId: number): Date {\n return this.withSqliteStatement(`SELECT lastMod from ${tableName} WHERE rowid=?`, (stmt) => {\n stmt.bindInteger(1, rowId);\n return stmt.getValueDate(0);\n });\n }\n\n /**\n * Open a database, perform an operation, then close the database.\n *\n * Details:\n * - if database is open, throw an error\n * - open a database\n * - call a function with the database opened. If it is async, await its return.\n * - if function throws, abandon all changes, close database, and rethrow\n * - save all changes\n * - close the database\n * @return value from operation\n */\n public withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T {\n if (this.isOpen)\n SqliteError.throwError(\"already-open\", \"database is already open\", args.dbName);\n\n const save = () => this.closeDb(true), abandon = () => this.closeDb(false);\n this.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\n try {\n const result = operation();\n result instanceof Promise ? result.then(save, abandon) : save();\n return result;\n } catch (e) {\n abandon();\n throw e;\n }\n }\n\n /** The cloud container backing this SQLite database, if any.\n * @beta\n */\n public get cloudContainer(): CloudSqlite.CloudContainer | undefined {\n return this[_nativeDb].cloudContainer;\n }\n\n /** Returns the Id of the most-recently-inserted row in this database, per [sqlite3_last_insert_rowid](https://www.sqlite.org/c3ref/last_insert_rowid.html). */\n public getLastInsertRowId(): number {\n return this[_nativeDb].getLastInsertRowId();\n }\n\n /**\n * Perform an operation on a database in a CloudContainer with the write lock held.\n *\n * Details:\n * - acquire the write lock on a CloudContainer\n * - call `withOpenDb` with openMode `ReadWrite`\n * - upload changes\n * - release the write lock\n * @param args arguments to lock the container and open the database\n * @param operation an operation performed on the database with the write lock held.\n * @return value from operation\n * @internal\n */\n public async withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => Promise<T>) {\n return CloudSqlite.withWriteLock(args, async () => this.withOpenDb({ ...args, openMode: args.openMode ?? OpenMode.ReadWrite }, operation));\n }\n\n /** vacuum this database\n * @see https://www.sqlite.org/lang_vacuum.html\n */\n public vacuum(args?: SQLiteDb.VacuumDbArgs) {\n this[_nativeDb].vacuum(args);\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */\n public saveChanges(): void {\n this[_nativeDb].saveChanges();\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */\n public abandonChanges(): void {\n this[_nativeDb].abandonChanges();\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @returns the value returned by `callback`.\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n val instanceof Promise ? val.then(release, release) : release();\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @returns the value returned by `callback`.\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\n const stmt = this.prepareSqliteStatement(sql);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val = callback(stmt);\n val instanceof Promise ? val.then(release, release) : release();\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the\n * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back\n * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.\n */\n public withSavePoint(savePointName: string, operation: () => void) {\n if (this.isReadonly)\n SqliteError.throwError(\"readonly\", \"database is readonly\", this[_nativeDb].getFilePath());\n\n this.executeSQL(`SAVEPOINT ${savePointName}`);\n try {\n operation();\n this.executeSQL(`RELEASE ${savePointName}`);\n } catch (e) {\n this.executeSQL(`ROLLBACK TO ${savePointName}`);\n throw e;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determine if errors are logged or not\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this[_nativeDb], logErrors);\n return stmt;\n }\n\n /** execute an SQL statement */\n public executeSQL(sql: string): DbResult {\n using stmt = this.prepareSqliteStatement(sql);\n return stmt.step();\n }\n}\n\n/**\n * Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.\n * This class provides version checking when the database is opened, to guarantee that a valid version of software is\n * always used for access.\n *\n * Notes:\n * - This class may be used either to access a local file, or one stored in a cloud container.\n * - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its\n * tables.\n * @beta\n */\nexport abstract class VersionedSqliteDb extends SQLiteDb {\n protected static _versionProps = { namespace: \"SQLiteDb\", name: \"versions\" } as const;\n\n /** The current semver \"persistence version\" of this class.\n * @note This value should only be changed when logic in its code is modified in a way that affects the operation of extant copies.\n * If this value is outside of the range of accepted versions of a to-be-opened VersionedSqliteDb, the operation will fail. In this manner, if\n * changes are made to the format of a VersionedSqliteDb, or if bug fixes are necessary, the `requiredVersions` property in a VersionedSqliteDb may be updated\n * and immediately old versions of the package will refuse to open the VersionedSqliteDb, with a message to the user that they need to upgrade their\n * software. Likewise, if a new version of the package is asked to open an older VersionedSqliteDb that has not been upgraded to the lowest version\n * supported by it, the user will be informed that they need to upgrade their software.\n * @note this identifier is independent of versions in `package.json` files.\n */\n public abstract myVersion: string;\n\n /**\n * Change the \"versions required to open this database\" property stored in this database. After this call,\n * versions of software that don't meet the supplied ranges will fail.\n * @param versions the new versions required for reading and writing this database.\n * @note the database must be opened for write access.\n */\n public setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges) {\n // NOTE: It might look tempting to just stringify the supplied `versions` object, but we only include required members - there may be others.\n this[_nativeDb].saveFileProperty(VersionedSqliteDb._versionProps, JSON.stringify({ readVersion: versions.readVersion, writeVersion: versions.writeVersion }));\n }\n\n /** Get the required version ranges necessary to open this VersionedSqliteDb. */\n public getRequiredVersions() {\n const checkIsString = (value: any) => {\n if (typeof value !== \"string\")\n SqliteError.throwError(\"invalid-versions-property\", `CloudDb has invalid \"versions\" property`, this[_nativeDb].getFilePath());\n return value;\n };\n const versionJson = checkIsString(this[_nativeDb].queryFileProperty(VersionedSqliteDb._versionProps, true));\n const versionRanges = JSON.parse(versionJson) as SQLiteDb.RequiredVersionRanges;\n checkIsString(versionRanges.readVersion);\n checkIsString(versionRanges.writeVersion);\n return versionRanges;\n }\n\n /**\n * Implement this method to create all tables for this subclass of `VersionedSqliteDb` when a new database file is created. Called from [[createNewDb]].\n */\n protected abstract createDDL(args: any): void;\n\n /**\n * Create a new database file for the subclass of VersionedSqliteDb.\n * @note The required versions are saved as [[myVersion]] or newer for both read and write.\n */\n public static createNewDb(fileName: LocalFileName, setupArgs?: any) {\n const db = new (this as any)() as VersionedSqliteDb; // \"as any\" necessary because VersionedSqliteDb is abstract\n IModelJsFs.recursiveMkDirSync(dirname(fileName));\n if (fs.existsSync(fileName))\n fs.unlinkSync(fileName);\n\n db.createDb(fileName);\n db.createDDL(setupArgs);\n const minVer = `^${db.myVersion}`;\n db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });\n db.closeDb(true);\n }\n\n /**\n * Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\n * Throws otherwise.\n */\n protected verifyVersions() {\n const versions = this.getRequiredVersions();\n const isReadonly = this.isReadonly; // so we can tell read/write after the file is closed.\n const range = isReadonly ? versions.readVersion : versions.writeVersion;\n if (semver.satisfies(this.myVersion, range))\n return;\n\n this.closeDb();\n const tooNew = semver.gtr(this.myVersion, range);\n SqliteError.throwError(\"incompatible-version\", `requires ${tooNew ? \"older\" : \"newer\"} version of ${this.constructor.name} for ${isReadonly ? \"read\" : \"write\"}`, this[_nativeDb].getFilePath());\n\n }\n\n /**\n * Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\n * Throws otherwise.\n * @see [[SqliteDb.openDb]] for argument types\n */\n public override openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer) {\n super.openDb(dbName, openMode, container);\n this.verifyVersions();\n }\n\n public async upgradeSchema(arg: { dbName: string, lockContainer?: { container: CloudSqlite.CloudContainer, user: string }, upgradeFn: () => void }) {\n // can't use \"this\" because it checks for version, which we don't want here\n return (arg.lockContainer) ?\n super.withLockedContainer({ dbName: arg.dbName, ...arg.lockContainer }, async () => arg.upgradeFn) :\n super.withOpenDb({ ...arg, openMode: OpenMode.ReadWrite }, arg.upgradeFn);\n }\n}\n\n/** @public */\nexport namespace SQLiteDb {\n /** A semver version range.\n * @see https://docs.npmjs.com/cli/v6/using-npm/semver\n */\n export type VersionRange = string;\n\n /**\n * A pair of semver [[SQLiteDb.VersionRange]]s, one for read and one for write, required to access a [[VersionedSqliteDb]].\n * If the version of the software attempting to read or write the database does not satisfy the range, access is denied.\n */\n export interface RequiredVersionRanges {\n /** a range of acceptable persistence versions for reading from a VersionedSqliteDb. */\n readonly readVersion: VersionRange;\n /** a range of acceptable persistence versions for writing to a VersionedSqliteDb. */\n readonly writeVersion: VersionRange;\n }\n\n /** interface for reading and writing to a blob in a SQLiteDb\n * @internal\n */\n export interface BlobIO {\n /** Close this BlobIO if it is opened.\n * @note this BlobIO *may* be reused after this call by calling `open` again.\n */\n close(): void;\n /** get the total number of bytes in the blob */\n getNumBytes(): number;\n /** @return true if this BlobIO was successfully opened and may be use to read or write the blob */\n isValid(): boolean;\n /** Open this BlobIO against a table/row/column in a Db */\n open(\n /** The database for the blob */\n db: IModelJsNative.AnyDb,\n args: {\n /** the name of the table for the blob*/\n tableName: string;\n /** the name of the column for the blob */\n columnName: string;\n /** The rowId of the blob */\n row: number;\n /** If true, open this BlobIO for write access */\n writeable?: boolean;\n }): void;\n /** Read from a blob\n * @returns the contents of the requested byte range\n */\n read(args: {\n /** The number of bytes to read */\n numBytes: number;\n /** starting offset within the blob to read */\n offset: number;\n /** If present and of sufficient size, use this ArrayBuffer for the value. */\n blob?: ArrayBuffer;\n }): Uint8Array;\n /** Reposition this BlobIO to a new rowId\n * @note this BlobIO must be valid when this methods is called.\n */\n changeRow(row: number): void;\n /** Write to a blob */\n write(args: {\n /** The number of bytes to write */\n numBytes: number;\n /** starting offset within the blob to write */\n offset: number;\n /** the value to write */\n blob: ArrayBuffer;\n }): void;\n }\n\n /** Default transaction mode for SQLiteDbs.\n * @see https://www.sqlite.org/lang_transaction.html\n */\n export enum DefaultTxnMode {\n /** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */\n None = 0,\n /** A deferred transaction is started when the file is first opened. This is the default. */\n Deferred = 1,\n /** An immediate transaction is started when the file is first opened. */\n Immediate = 2,\n /** An exclusive transaction is started when the file is first opened. */\n Exclusive = 3\n }\n\n /** parameters common to opening or creating a new SQLiteDb */\n export interface OpenOrCreateParams {\n /** If true, do not require that the `be_Prop` table exist */\n rawSQLite?: boolean;\n /** @see immutable option at https://www.sqlite.org/c3ref/open.html */\n immutable?: boolean;\n /** Do not attempt to verify that the file is a valid sQLite file before opening. */\n skipFileCheck?: boolean;\n /** the default transaction mode\n * @see [[SQLiteDb.DefaultTxnMode]]\n */\n defaultTxn?: 0 | 1 | 2 | 3;\n /** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */\n queryParam?: string;\n }\n\n /** Parameters for opening an existing SQLiteDb */\n export interface OpenParams extends OpenOrCreateParams {\n /** use OpenMode.ReadWrite to open the file with write access */\n openMode: OpenMode;\n }\n\n /** Size of a SQLiteDb page in bytes */\n export interface PageSize {\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\n pageSize?: number;\n }\n\n /** Parameters for creating a new SQLiteDb */\n export type CreateParams = OpenOrCreateParams & PageSize;\n\n /** Arguments for `SqliteDb.withOpenDb` */\n export interface WithOpenDbArgs {\n /** The name of the database to open */\n dbName: string;\n /** either an object with the open parameters or just OpenMode value. */\n openMode?: OpenMode | SQLiteDb.OpenParams;\n /** @internal */\n container?: CloudSqlite.CloudContainer;\n }\n\n /** Arguments for `SQLiteDb.vacuum` */\n export interface VacuumDbArgs extends PageSize {\n /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */\n into?: LocalFileName;\n }\n}\n"]}
1
+ {"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAY,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAiB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,0CAA0C;AAE1C;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACnB,gBAAgB;IACA,CAAC,SAAS,CAAC,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC3D,qBAAqB,GAAG,IAAI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AAY,CAAA;QACZ,yEAAyE;QACzE,6DAAa,CAAA;QACb,yEAAyE;QACzE,6DAAa,CAAA;IACf,CAAC,EATW,cAAc,GAAd,uBAAc,KAAd,uBAAc,QASzB;AAgDH,CAAC,EAjIgB,QAAQ,KAAR,QAAQ,QAiIxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport * as fs from \"fs\";\r\nimport { dirname } from \"path\";\r\nimport * as semver from \"semver\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { LocalFileName, SqliteError } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\n\r\n// cspell:ignore savepoint julianday rowid\r\n\r\n/**\r\n * A \"generic\" SQLiteDb. This class may be used to access local files or databases in a cloud container.\r\n * @public\r\n */\r\nexport class SQLiteDb {\r\n /** @internal */\r\n public readonly [_nativeDb] = new IModelNative.platform.SQLiteDb();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** @internal */\r\n public static createBlobIO(): SQLiteDb.BlobIO {\r\n return new IModelNative.platform.BlobIO();\r\n }\r\n\r\n /** alias for closeDb.\r\n * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use [[closeDb]]\r\n */\r\n public dispose(): void {\r\n this.closeDb();\r\n }\r\n\r\n /** Create a SQLiteDb\r\n * @param dbName The path to the SQLiteDb file to create.\r\n */\r\n public createDb(dbName: string): void;\r\n /** @beta */\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void {\r\n this[_nativeDb].createDb(dbName, container, params);\r\n }\r\n\r\n /** Open a SQLiteDb.\r\n * @param dbName The path to the SQLiteDb file to open\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;\r\n /**\r\n * @param container optional CloudContainer holding database\r\n * @beta\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void {\r\n this[_nativeDb].openDb(dbName, openMode, container);\r\n }\r\n\r\n /** Close SQLiteDb.\r\n * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.\r\n */\r\n public closeDb(saveChanges?: boolean): void {\r\n if (saveChanges && this.isOpen)\r\n this.saveChanges();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** Returns true if this SQLiteDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Returns true if this SQLiteDb is open readonly */\r\n public get isReadonly(): boolean { return this[_nativeDb].isReadonly(); }\r\n\r\n /** Create a new table in this database. */\r\n protected createTable(args: {\r\n /** The name of the table to create. */\r\n tableName: string;\r\n /** all of the columns in the table. */\r\n columns: string;\r\n /** any unique or foreign key constraints */\r\n constraints?: string;\r\n /** if true, add a \"lastMod\" timestamp column and triggers to automatically update it. */\r\n addTimestamp?: boolean;\r\n }) {\r\n const timestampCol = args.addTimestamp ? \",lastMod TIMESTAMP NOT NULL DEFAULT(julianday('now'))\" : \"\";\r\n const constraints = args.constraints ? `,${args.constraints}` : \"\";\r\n this.executeSQL(`CREATE TABLE ${args.tableName}(${args.columns}${timestampCol}${constraints})`);\r\n if (args.addTimestamp)\r\n this.executeSQL(`CREATE TRIGGER ${args.tableName}_timestamp AFTER UPDATE ON ${args.tableName} WHEN old.lastMod=new.lastMod AND old.lastMod != julianday('now') BEGIN UPDATE ${args.tableName} SET lastMod=julianday('now') WHERE rowid=new.rowid; END`);\r\n }\r\n\r\n /**\r\n * Get the last modified date for a row in a table of this database.\r\n * @note the table must have been created with `addTimestamp: true`\r\n */\r\n public readLastModTime(tableName: string, rowId: number): Date {\r\n return this.withSqliteStatement(`SELECT lastMod from ${tableName} WHERE rowid=?`, (stmt) => {\r\n stmt.bindInteger(1, rowId);\r\n return stmt.getValueDate(0);\r\n });\r\n }\r\n\r\n /**\r\n * Open a database, perform an operation, then close the database.\r\n *\r\n * Details:\r\n * - if database is open, throw an error\r\n * - open a database\r\n * - call a function with the database opened. If it is async, await its return.\r\n * - if function throws, abandon all changes, close database, and rethrow\r\n * - save all changes\r\n * - close the database\r\n * @return value from operation\r\n */\r\n public withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T {\r\n if (this.isOpen)\r\n SqliteError.throwError(\"already-open\", \"database is already open\", args.dbName);\r\n\r\n const save = () => this.closeDb(true), abandon = () => this.closeDb(false);\r\n this.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\r\n try {\r\n const result = operation();\r\n result instanceof Promise ? result.then(save, abandon) : save();\r\n return result;\r\n } catch (e) {\r\n abandon();\r\n throw e;\r\n }\r\n }\r\n\r\n /** The cloud container backing this SQLite database, if any.\r\n * @beta\r\n */\r\n public get cloudContainer(): CloudSqlite.CloudContainer | undefined {\r\n return this[_nativeDb].cloudContainer;\r\n }\r\n\r\n /** Returns the Id of the most-recently-inserted row in this database, per [sqlite3_last_insert_rowid](https://www.sqlite.org/c3ref/last_insert_rowid.html). */\r\n public getLastInsertRowId(): number {\r\n return this[_nativeDb].getLastInsertRowId();\r\n }\r\n\r\n /**\r\n * Perform an operation on a database in a CloudContainer with the write lock held.\r\n *\r\n * Details:\r\n * - acquire the write lock on a CloudContainer\r\n * - call `withOpenDb` with openMode `ReadWrite`\r\n * - upload changes\r\n * - release the write lock\r\n * @param args arguments to lock the container and open the database\r\n * @param operation an operation performed on the database with the write lock held.\r\n * @return value from operation\r\n * @internal\r\n */\r\n public async withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => Promise<T>) {\r\n return CloudSqlite.withWriteLock(args, async () => this.withOpenDb({ ...args, openMode: args.openMode ?? OpenMode.ReadWrite }, operation));\r\n }\r\n\r\n /** vacuum this database\r\n * @see https://www.sqlite.org/lang_vacuum.html\r\n */\r\n public vacuum(args?: SQLiteDb.VacuumDbArgs) {\r\n this[_nativeDb].vacuum(args);\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */\r\n public saveChanges(): void {\r\n this[_nativeDb].saveChanges();\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */\r\n public abandonChanges(): void {\r\n this[_nativeDb].abandonChanges();\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the\r\n * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back\r\n * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.\r\n */\r\n public withSavePoint(savePointName: string, operation: () => void) {\r\n if (this.isReadonly)\r\n SqliteError.throwError(\"readonly\", \"database is readonly\", this[_nativeDb].getFilePath());\r\n\r\n this.executeSQL(`SAVEPOINT ${savePointName}`);\r\n try {\r\n operation();\r\n this.executeSQL(`RELEASE ${savePointName}`);\r\n } catch (e) {\r\n this.executeSQL(`ROLLBACK TO ${savePointName}`);\r\n throw e;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this[_nativeDb], logErrors);\r\n return stmt;\r\n }\r\n\r\n /** execute an SQL statement */\r\n public executeSQL(sql: string): DbResult {\r\n using stmt = this.prepareSqliteStatement(sql);\r\n return stmt.step();\r\n }\r\n}\r\n\r\n/**\r\n * Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.\r\n * This class provides version checking when the database is opened, to guarantee that a valid version of software is\r\n * always used for access.\r\n *\r\n * Notes:\r\n * - This class may be used either to access a local file, or one stored in a cloud container.\r\n * - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its\r\n * tables.\r\n * @beta\r\n */\r\nexport abstract class VersionedSqliteDb extends SQLiteDb {\r\n protected static _versionProps = { namespace: \"SQLiteDb\", name: \"versions\" } as const;\r\n\r\n /** The current semver \"persistence version\" of this class.\r\n * @note This value should only be changed when logic in its code is modified in a way that affects the operation of extant copies.\r\n * If this value is outside of the range of accepted versions of a to-be-opened VersionedSqliteDb, the operation will fail. In this manner, if\r\n * changes are made to the format of a VersionedSqliteDb, or if bug fixes are necessary, the `requiredVersions` property in a VersionedSqliteDb may be updated\r\n * and immediately old versions of the package will refuse to open the VersionedSqliteDb, with a message to the user that they need to upgrade their\r\n * software. Likewise, if a new version of the package is asked to open an older VersionedSqliteDb that has not been upgraded to the lowest version\r\n * supported by it, the user will be informed that they need to upgrade their software.\r\n * @note this identifier is independent of versions in `package.json` files.\r\n */\r\n public abstract myVersion: string;\r\n\r\n /**\r\n * Change the \"versions required to open this database\" property stored in this database. After this call,\r\n * versions of software that don't meet the supplied ranges will fail.\r\n * @param versions the new versions required for reading and writing this database.\r\n * @note the database must be opened for write access.\r\n */\r\n public setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges) {\r\n // NOTE: It might look tempting to just stringify the supplied `versions` object, but we only include required members - there may be others.\r\n this[_nativeDb].saveFileProperty(VersionedSqliteDb._versionProps, JSON.stringify({ readVersion: versions.readVersion, writeVersion: versions.writeVersion }));\r\n }\r\n\r\n /** Get the required version ranges necessary to open this VersionedSqliteDb. */\r\n public getRequiredVersions() {\r\n const checkIsString = (value: any) => {\r\n if (typeof value !== \"string\")\r\n SqliteError.throwError(\"invalid-versions-property\", `CloudDb has invalid \"versions\" property`, this[_nativeDb].getFilePath());\r\n return value;\r\n };\r\n const versionJson = checkIsString(this[_nativeDb].queryFileProperty(VersionedSqliteDb._versionProps, true));\r\n const versionRanges = JSON.parse(versionJson) as SQLiteDb.RequiredVersionRanges;\r\n checkIsString(versionRanges.readVersion);\r\n checkIsString(versionRanges.writeVersion);\r\n return versionRanges;\r\n }\r\n\r\n /**\r\n * Implement this method to create all tables for this subclass of `VersionedSqliteDb` when a new database file is created. Called from [[createNewDb]].\r\n */\r\n protected abstract createDDL(args: any): void;\r\n\r\n /**\r\n * Create a new database file for the subclass of VersionedSqliteDb.\r\n * @note The required versions are saved as [[myVersion]] or newer for both read and write.\r\n */\r\n public static createNewDb(fileName: LocalFileName, setupArgs?: any) {\r\n const db = new (this as any)() as VersionedSqliteDb; // \"as any\" necessary because VersionedSqliteDb is abstract\r\n IModelJsFs.recursiveMkDirSync(dirname(fileName));\r\n if (fs.existsSync(fileName))\r\n fs.unlinkSync(fileName);\r\n\r\n db.createDb(fileName);\r\n db.createDDL(setupArgs);\r\n const minVer = `^${db.myVersion}`;\r\n db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });\r\n db.closeDb(true);\r\n }\r\n\r\n /**\r\n * Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n */\r\n protected verifyVersions() {\r\n const versions = this.getRequiredVersions();\r\n const isReadonly = this.isReadonly; // so we can tell read/write after the file is closed.\r\n const range = isReadonly ? versions.readVersion : versions.writeVersion;\r\n if (semver.satisfies(this.myVersion, range))\r\n return;\r\n\r\n this.closeDb();\r\n const tooNew = semver.gtr(this.myVersion, range);\r\n SqliteError.throwError(\"incompatible-version\", `requires ${tooNew ? \"older\" : \"newer\"} version of ${this.constructor.name} for ${isReadonly ? \"read\" : \"write\"}`, this[_nativeDb].getFilePath());\r\n\r\n }\r\n\r\n /**\r\n * Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n * @see [[SqliteDb.openDb]] for argument types\r\n */\r\n public override openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer) {\r\n super.openDb(dbName, openMode, container);\r\n this.verifyVersions();\r\n }\r\n\r\n public async upgradeSchema(arg: { dbName: string, lockContainer?: { container: CloudSqlite.CloudContainer, user: string }, upgradeFn: () => void }) {\r\n // can't use \"this\" because it checks for version, which we don't want here\r\n return (arg.lockContainer) ?\r\n super.withLockedContainer({ dbName: arg.dbName, ...arg.lockContainer }, async () => arg.upgradeFn) :\r\n super.withOpenDb({ ...arg, openMode: OpenMode.ReadWrite }, arg.upgradeFn);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace SQLiteDb {\r\n /** A semver version range.\r\n * @see https://docs.npmjs.com/cli/v6/using-npm/semver\r\n */\r\n export type VersionRange = string;\r\n\r\n /**\r\n * A pair of semver [[SQLiteDb.VersionRange]]s, one for read and one for write, required to access a [[VersionedSqliteDb]].\r\n * If the version of the software attempting to read or write the database does not satisfy the range, access is denied.\r\n */\r\n export interface RequiredVersionRanges {\r\n /** a range of acceptable persistence versions for reading from a VersionedSqliteDb. */\r\n readonly readVersion: VersionRange;\r\n /** a range of acceptable persistence versions for writing to a VersionedSqliteDb. */\r\n readonly writeVersion: VersionRange;\r\n }\r\n\r\n /** interface for reading and writing to a blob in a SQLiteDb\r\n * @internal\r\n */\r\n export interface BlobIO {\r\n /** Close this BlobIO if it is opened.\r\n * @note this BlobIO *may* be reused after this call by calling `open` again.\r\n */\r\n close(): void;\r\n /** get the total number of bytes in the blob */\r\n getNumBytes(): number;\r\n /** @return true if this BlobIO was successfully opened and may be use to read or write the blob */\r\n isValid(): boolean;\r\n /** Open this BlobIO against a table/row/column in a Db */\r\n open(\r\n /** The database for the blob */\r\n db: IModelJsNative.AnyDb,\r\n args: {\r\n /** the name of the table for the blob*/\r\n tableName: string;\r\n /** the name of the column for the blob */\r\n columnName: string;\r\n /** The rowId of the blob */\r\n row: number;\r\n /** If true, open this BlobIO for write access */\r\n writeable?: boolean;\r\n }): void;\r\n /** Read from a blob\r\n * @returns the contents of the requested byte range\r\n */\r\n read(args: {\r\n /** The number of bytes to read */\r\n numBytes: number;\r\n /** starting offset within the blob to read */\r\n offset: number;\r\n /** If present and of sufficient size, use this ArrayBuffer for the value. */\r\n blob?: ArrayBuffer;\r\n }): Uint8Array;\r\n /** Reposition this BlobIO to a new rowId\r\n * @note this BlobIO must be valid when this methods is called.\r\n */\r\n changeRow(row: number): void;\r\n /** Write to a blob */\r\n write(args: {\r\n /** The number of bytes to write */\r\n numBytes: number;\r\n /** starting offset within the blob to write */\r\n offset: number;\r\n /** the value to write */\r\n blob: ArrayBuffer;\r\n }): void;\r\n }\r\n\r\n /** Default transaction mode for SQLiteDbs.\r\n * @see https://www.sqlite.org/lang_transaction.html\r\n */\r\n export enum DefaultTxnMode {\r\n /** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */\r\n None = 0,\r\n /** A deferred transaction is started when the file is first opened. This is the default. */\r\n Deferred = 1,\r\n /** An immediate transaction is started when the file is first opened. */\r\n Immediate = 2,\r\n /** An exclusive transaction is started when the file is first opened. */\r\n Exclusive = 3\r\n }\r\n\r\n /** parameters common to opening or creating a new SQLiteDb */\r\n export interface OpenOrCreateParams {\r\n /** If true, do not require that the `be_Prop` table exist */\r\n rawSQLite?: boolean;\r\n /** @see immutable option at https://www.sqlite.org/c3ref/open.html */\r\n immutable?: boolean;\r\n /** Do not attempt to verify that the file is a valid sQLite file before opening. */\r\n skipFileCheck?: boolean;\r\n /** the default transaction mode\r\n * @see [[SQLiteDb.DefaultTxnMode]]\r\n */\r\n defaultTxn?: 0 | 1 | 2 | 3;\r\n /** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */\r\n queryParam?: string;\r\n }\r\n\r\n /** Parameters for opening an existing SQLiteDb */\r\n export interface OpenParams extends OpenOrCreateParams {\r\n /** use OpenMode.ReadWrite to open the file with write access */\r\n openMode: OpenMode;\r\n }\r\n\r\n /** Size of a SQLiteDb page in bytes */\r\n export interface PageSize {\r\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\r\n pageSize?: number;\r\n }\r\n\r\n /** Parameters for creating a new SQLiteDb */\r\n export type CreateParams = OpenOrCreateParams & PageSize;\r\n\r\n /** Arguments for `SqliteDb.withOpenDb` */\r\n export interface WithOpenDbArgs {\r\n /** The name of the database to open */\r\n dbName: string;\r\n /** either an object with the open parameters or just OpenMode value. */\r\n openMode?: OpenMode | SQLiteDb.OpenParams;\r\n /** @internal */\r\n container?: CloudSqlite.CloudContainer;\r\n }\r\n\r\n /** Arguments for `SQLiteDb.vacuum` */\r\n export interface VacuumDbArgs extends PageSize {\r\n /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */\r\n into?: LocalFileName;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,MAAM;IACjB;;;;OAIG;IACI,MAAM,KAAK,UAAU,KAAa,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAElH;;OAEG;IACI,MAAM,KAAK,SAAS;QACzB,mGAAmG;QACnG,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,0FAA0F;IACzJ,CAAC;IAED;;;OAGG;IACI,MAAM,KAAK,uBAAuB,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAEtE;;;;;;OAMG;IACI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B,CAAC,CAAC;QAC3G,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,OAAO;IACV,MAAM,CAAU,cAAc,GAAG,IAAI,SAAS,EAAE,CAAC;IACzD,gBAAwB,CAAC,CAAC,sBAAsB;IAEhD;;;OAGG;IACI,MAAM,CAAC,cAAc,CAAC,MAAqB;QAChD,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,UAAkB;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,SAAS,KAAK,MAAM;YACtB,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,mBAAmB,CAAC,UAAkB,IAA+B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { IModelStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { ClassRegistry } from \"./ClassRegistry\";\nimport { ECVersion, SchemaKey } from \"@itwin/ecschema-metadata\";\n\n/** Base class for all schema classes - see [working with schemas and elements in TypeScript]($docs/learning/backend/SchemasAndElementsInTypeScript.md).\n *\n * When subclassing from Schema, it is good practice to follow this pattern:\n *\n * ```typescript\n * class MyCustomSchema extends Schema {\n * public static override get schemaName(): string { return \"MyCustomSchema\"; }\n * public static get classes(): typeof Entity[] {\n * return [MyOwnECClass, AnotherECClass];\n * }\n * public static registerSchema() {\n * if (this !== Schemas.getRegisteredSchema(this.schemaName)) {\n * Schemas.unregisterSchema(this.schemaName);\n * Schemas.registerSchema(this);\n * for (const ecClass of this.classes) {\n * ClassRegistry.register(ecClass, this);\n * }\n * }\n * }\n *\n * public static unregisterSchema() {\n * Schemas.unregisterSchema(this.schemaName);\n * }\n * }\n * ```\n *\n * @public\n */\nexport class Schema {\n /** The name of the BIS schema handled by this Schema.\n * @note Every subclass of Schema ** MUST ** override this method to identify its BIS schema.\n * Failure to do so will ordinarily result in an error when the schema is registered, since there may only\n * be one JavaScript class for a given BIS schema (usually the errant schema will collide with its superclass.)\n */\n public static get schemaName(): string { throw new Error(`you must override static schemaName in ${this.name}`); }\n\n /** Unique identifier for this schema, typed variant of [[schemaName]].\n * @internal\n */\n public static get schemaKey(): SchemaKey {\n // We cannot cache this here because the schemaName may be overridden without this being overridden\n return new SchemaKey(this.schemaName, ECVersion.NO_VERSION); // backend cares little for versions right now, as only one version can exist in an imodel\n }\n\n /** if true, this Schema is a proxy for a missing Domain marked with the `BisCore.SchemaHasBehavior` customAttribute.\n * Classes generated for this Schema will disallow protected operations.\n * @internal\n */\n public static get missingRequiredBehavior(): boolean { return false; }\n\n /** Get a semver-compatible string from a padded version string.\n * works on unpadded version strings as well\n * if there is no write version, it will be added\n * @example Schema.toSemverString(\"1.02.03\") === \"1.2.3\"\n * @example Schema.toSemverString(\"1.01\") === \"1.0.1\" // write version was added\n * @beta\n */\n public static toSemverString(paddedVersion: string): string {\n const tuple = paddedVersion.split(\".\").map(Number);\n const noWriteVersion = tuple.length === 2;\n if (noWriteVersion)\n tuple.splice(1, 0, 0); // insert 0 before the second element\n return tuple.join(\".\");\n }\n\n /** Schemas may not be instantiated. The method is not private only because that precludes subclassing. It throws an\n * error if it is ever called.\n * @internal\n */\n protected constructor() { throw new Error(`cannot create an instance of a Schema ${this.constructor.name}`); }\n}\n\n/**\n * Holds a map of registered schemas.\n * @public\n */\nexport class SchemaMap {\n private readonly _schemas = new Map<string, typeof Schema>();\n\n /** @internal */\n public get(schemaName: string): typeof Schema | undefined {\n return this._schemas.get(schemaName.toLowerCase());\n }\n\n /** @internal */\n public set(schemaName: string, schema: typeof Schema): void {\n this._schemas.set(schemaName.toLowerCase(), schema);\n }\n\n /** @internal */\n public delete(schemaName: string): boolean {\n return this._schemas.delete(schemaName.toLowerCase());\n }\n\n /** Register a schema prior to using it.\n * @throws [[IModelError]] if a schema of the same name is already registered.\n * @public\n */\n public registerSchema(schema: typeof Schema) {\n const key = schema.schemaName.toLowerCase();\n if (this.get(key))\n throw new IModelError(IModelStatus.DuplicateName, `Schema \"${schema.schemaName}\" is already registered`);\n this.set(key, schema);\n }\n}\n\n/** Manages registered schemas\n * @public\n */\nexport class Schemas {\n private static readonly _globalSchemas = new SchemaMap();\n private constructor() { } // this is a singleton\n\n /** Register a schema prior to using it.\n * This method registers the schema globally, to register a schema within the scope of a single iModel, use `IModelDb.schemaMap`.\n * @throws [[IModelError]] if a schema of the same name is already registered.\n */\n public static registerSchema(schema: typeof Schema) {\n this._globalSchemas.registerSchema(schema);\n }\n\n /** Unregister a schema, by name, if one is already registered.\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 schemaName Name of the schema to unregister\n * @return true if the schema was unregistered\n */\n public static unregisterSchema(schemaName: string): boolean {\n const schema = this.getRegisteredSchema(schemaName);\n if (undefined !== schema)\n ClassRegistry.unregisterClassesFrom(schema);\n\n return this._globalSchemas.delete(schemaName.toLowerCase());\n }\n\n /** Look up a previously registered schema\n * @param schemaName The name of the schema\n * @returns the previously registered schema or undefined if not registered.\n */\n public static getRegisteredSchema(schemaName: string): typeof Schema | undefined { return this._globalSchemas.get(schemaName.toLowerCase()); }\n}\n"]}
1
+ {"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../src/Schema.ts"],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CAAC,MAAM,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,mBAAmB,CAAC,UAAkB,IAA+B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { IModelStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { ClassRegistry } from \"./ClassRegistry\";\r\nimport { ECVersion, SchemaKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/** Base class for all schema classes - see [working with schemas and elements in TypeScript]($docs/learning/backend/SchemasAndElementsInTypeScript.md).\r\n *\r\n * When subclassing from Schema, it is good practice to follow this pattern:\r\n *\r\n * ```typescript\r\n * class MyCustomSchema extends Schema {\r\n * public static override get schemaName(): string { return \"MyCustomSchema\"; }\r\n * public static get classes(): typeof Entity[] {\r\n * return [MyOwnECClass, AnotherECClass];\r\n * }\r\n * public static registerSchema() {\r\n * if (this !== Schemas.getRegisteredSchema(this.schemaName)) {\r\n * Schemas.unregisterSchema(this.schemaName);\r\n * Schemas.registerSchema(this);\r\n * for (const ecClass of this.classes) {\r\n * ClassRegistry.register(ecClass, this);\r\n * }\r\n * }\r\n * }\r\n *\r\n * public static unregisterSchema() {\r\n * Schemas.unregisterSchema(this.schemaName);\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class Schema {\r\n /** The name of the BIS schema handled by this Schema.\r\n * @note Every subclass of Schema ** MUST ** override this method to identify its BIS schema.\r\n * Failure to do so will ordinarily result in an error when the schema is registered, since there may only\r\n * be one JavaScript class for a given BIS schema (usually the errant schema will collide with its superclass.)\r\n */\r\n public static get schemaName(): string { throw new Error(`you must override static schemaName in ${this.name}`); }\r\n\r\n /** Unique identifier for this schema, typed variant of [[schemaName]].\r\n * @internal\r\n */\r\n public static get schemaKey(): SchemaKey {\r\n // We cannot cache this here because the schemaName may be overridden without this being overridden\r\n return new SchemaKey(this.schemaName, ECVersion.NO_VERSION); // backend cares little for versions right now, as only one version can exist in an imodel\r\n }\r\n\r\n /** if true, this Schema is a proxy for a missing Domain marked with the `BisCore.SchemaHasBehavior` customAttribute.\r\n * Classes generated for this Schema will disallow protected operations.\r\n * @internal\r\n */\r\n public static get missingRequiredBehavior(): boolean { return false; }\r\n\r\n /** Get a semver-compatible string from a padded version string.\r\n * works on unpadded version strings as well\r\n * if there is no write version, it will be added\r\n * @example Schema.toSemverString(\"1.02.03\") === \"1.2.3\"\r\n * @example Schema.toSemverString(\"1.01\") === \"1.0.1\" // write version was added\r\n * @beta\r\n */\r\n public static toSemverString(paddedVersion: string): string {\r\n const tuple = paddedVersion.split(\".\").map(Number);\r\n const noWriteVersion = tuple.length === 2;\r\n if (noWriteVersion)\r\n tuple.splice(1, 0, 0); // insert 0 before the second element\r\n return tuple.join(\".\");\r\n }\r\n\r\n /** Schemas may not be instantiated. The method is not private only because that precludes subclassing. It throws an\r\n * error if it is ever called.\r\n * @internal\r\n */\r\n protected constructor() { throw new Error(`cannot create an instance of a Schema ${this.constructor.name}`); }\r\n}\r\n\r\n/**\r\n * Holds a map of registered schemas.\r\n * @public\r\n */\r\nexport class SchemaMap {\r\n private readonly _schemas = new Map<string, typeof Schema>();\r\n\r\n /** @internal */\r\n public get(schemaName: string): typeof Schema | undefined {\r\n return this._schemas.get(schemaName.toLowerCase());\r\n }\r\n\r\n /** @internal */\r\n public set(schemaName: string, schema: typeof Schema): void {\r\n this._schemas.set(schemaName.toLowerCase(), schema);\r\n }\r\n\r\n /** @internal */\r\n public delete(schemaName: string): boolean {\r\n return this._schemas.delete(schemaName.toLowerCase());\r\n }\r\n\r\n /** Register a schema prior to using it.\r\n * @throws [[IModelError]] if a schema of the same name is already registered.\r\n * @public\r\n */\r\n public registerSchema(schema: typeof Schema) {\r\n const key = schema.schemaName.toLowerCase();\r\n if (this.get(key))\r\n throw new IModelError(IModelStatus.DuplicateName, `Schema \"${schema.schemaName}\" is already registered`);\r\n this.set(key, schema);\r\n }\r\n}\r\n\r\n/** Manages registered schemas\r\n * @public\r\n */\r\nexport class Schemas {\r\n private static readonly _globalSchemas = new SchemaMap();\r\n private constructor() { } // this is a singleton\r\n\r\n /** Register a schema prior to using it.\r\n * This method registers the schema globally, to register a schema within the scope of a single iModel, use `IModelDb.schemaMap`.\r\n * @throws [[IModelError]] if a schema of the same name is already registered.\r\n */\r\n public static registerSchema(schema: typeof Schema) {\r\n this._globalSchemas.registerSchema(schema);\r\n }\r\n\r\n /** Unregister a schema, by name, if one is already registered.\r\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.\r\n * @param schemaName Name of the schema to unregister\r\n * @return true if the schema was unregistered\r\n */\r\n public static unregisterSchema(schemaName: string): boolean {\r\n const schema = this.getRegisteredSchema(schemaName);\r\n if (undefined !== schema)\r\n ClassRegistry.unregisterClassesFrom(schema);\r\n\r\n return this._globalSchemas.delete(schemaName.toLowerCase());\r\n }\r\n\r\n /** Look up a previously registered schema\r\n * @param schemaName The name of the schema\r\n * @returns the previously registered schema or undefined if not registered.\r\n */\r\n public static getRegisteredSchema(schemaName: string): typeof Schema | undefined { return this._globalSchemas.get(schemaName.toLowerCase()); }\r\n}\r\n"]}
@@ -11,7 +11,7 @@ import { BriefcaseDb, IModelDb } from "./IModelDb";
11
11
  import { DbResult, OpenMode } from "@itwin/core-bentley";
12
12
  import { IModelError } from "@itwin/core-common";
13
13
  import { IModelNative } from "./internal/NativePlatform";
14
- import { _nativeDb } from "./internal/Symbols";
14
+ import { _implicitTxn, _nativeDb } from "./internal/Symbols";
15
15
  /** @internal */
16
16
  export var SchemaSync;
17
17
  (function (SchemaSync) {
@@ -91,7 +91,7 @@ export var SchemaSync;
91
91
  const schemaSyncDbUri = syncAccess.getUri();
92
92
  iModel.clearCaches();
93
93
  iModel[_nativeDb].schemaSyncPull(schemaSyncDbUri);
94
- iModel.saveChanges("schema synchronized with cloud container");
94
+ iModel[_implicitTxn].saveChanges("schema synchronized with cloud container");
95
95
  });
96
96
  }
97
97
  };
@@ -107,17 +107,17 @@ export var SchemaSync;
107
107
  await briefcase.pullChanges();
108
108
  }
109
109
  try {
110
- iModel.saveFileProperty(syncProperty, JSON.stringify(props));
110
+ iModel[_implicitTxn].saveFileProperty(syncProperty, JSON.stringify(props));
111
111
  await SchemaSync.withLockedAccess(arg.iModel, { operationName: "initialize schemaSync", openMode: OpenMode.Readonly }, async (syncAccess) => {
112
112
  iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);
113
- iModel.saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);
113
+ iModel[_implicitTxn].saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);
114
114
  });
115
115
  }
116
116
  catch (err) {
117
117
  throw err;
118
118
  }
119
119
  finally {
120
- iModel.abandonChanges();
120
+ iModel[_implicitTxn].abandonChanges();
121
121
  }
122
122
  if (briefcase) {
123
123
  if (arg.overrideContainer)
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WA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CAAC;;gBAEzH,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,mDAAmD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzH,CAAC;IACH,CAAC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,WAAW,CAAC,QAAsB;QACjE,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1I,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAiC;YAChE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EAtIgB,UAAU,KAAV,UAAU,QAsI1B","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\n/** @packageDocumentation\n * @module SQLiteDb\n */\n\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\n/** @internal */\nexport namespace SchemaSync {\n const lockParams: CloudSqlite.ObtainLockParams = { retryDelayMs: 1000, nRetries: 30 };\n\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\n export class SchemaSyncDb extends VersionedSqliteDb {\n public override readonly myVersion = \"4.0.0\";\n protected override createDDL() { }\n }\n\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\n const defaultDbName = \"SchemaSyncDb\";\n const testSyncCachePropKey = \"test.schema_sync.cache_name\";\n // for tests only\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\n if (cacheName)\n iModel[_nativeDb].saveLocalValue(testSyncCachePropKey, cacheName);\n else\n iModel[_nativeDb].deleteLocalValue(testSyncCachePropKey);\n };\n\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\n let nativeDb: IModelJsNative.DgnDb | undefined;\n const argIsIModelDb = arg instanceof IModelDb;\n if (argIsIModelDb) {\n nativeDb = arg[_nativeDb];\n } else {\n nativeDb = new IModelNative.platform.DgnDb();\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\n }\n\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\n if (!propsString)\n throw new Error(\"iModel does not have a SchemaSyncDb\");\n try {\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\n const accessToken = await CloudSqlite.requestToken(props);\n const access = new CloudAccess({ ...props, accessToken });\n Object.assign(access.lockParams, lockParams);\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\n if (testSyncCache)\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\n return access;\n } finally {\n if (!argIsIModelDb) {\n nativeDb.closeFile();\n }\n }\n };\n\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\n const access = await getCloudAccess(iModel);\n try {\n await access.withLockedDb(args, async () => operation(access));\n } finally {\n access.close();\n }\n };\n\n export const withReadonlyAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\n const access = await getCloudAccess(iModel);\n access.synchronizeWithCloud();\n access.openForRead();\n try {\n await operation(access);\n } finally {\n access.close();\n }\n };\n\n export const isEnabled = (iModel: IModelDb) => {\n return iModel[_nativeDb].schemaSyncEnabled();\n };\n\n /** Synchronize local briefcase schemas with cloud container */\n export const pull = async (iModel: IModelDb) => {\n if (iModel[_nativeDb].schemaSyncEnabled() && !iModel.isReadonly) {\n await SchemaSync.withReadonlyAccess(iModel, async (syncAccess) => {\n const schemaSyncDbUri = syncAccess.getUri();\n iModel.clearCaches();\n iModel[_nativeDb].schemaSyncPull(schemaSyncDbUri);\n iModel.saveChanges(\"schema synchronized with cloud container\");\n });\n }\n };\n\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\n const iModel = arg.iModel;\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\n await iModel.acquireSchemaLock();\n if (briefcase) {\n if (briefcase.txns.hasLocalChanges) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\n }\n await briefcase.pullChanges();\n }\n try {\n iModel.saveFileProperty(syncProperty, JSON.stringify(props));\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\n iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\n iModel.saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\n });\n } catch (err) {\n throw err;\n } finally {\n iModel.abandonChanges();\n }\n\n if (briefcase) {\n if (arg.overrideContainer)\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\n else\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\n }\n };\n\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\n public constructor(props: CloudSqlite.ContainerAccessProps) {\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\n }\n\n public getUri() {\n return `${this.getCloudDb()[_nativeDb].getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\n }\n /**\n * Initialize a cloud container for use as a SchemaSync. The container must first be created via its storage supplier api (e.g. Azure, or AWS).\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\n * @note this deletes any existing content in the container.\n */\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\n }\n }\n}\n\n"]}
1
+ {"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE7D,gBAAgB;AAChB,MAAM,KAAW,UAAU,CAsI1B;AAtID,WAAiB,UAAU;IACzB,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AC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,WAAW,CAAC,QAAsB;QACjE,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1I,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAiC;YAChE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EAtIgB,UAAU,KAAV,UAAU,QAsI1B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\r\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\r\n\r\n/** @internal */\r\nexport namespace SchemaSync {\r\n const lockParams: CloudSqlite.ObtainLockParams = { retryDelayMs: 1000, nRetries: 30 };\r\n\r\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\r\n export class SchemaSyncDb extends VersionedSqliteDb {\r\n public override readonly myVersion = \"4.0.0\";\r\n protected override createDDL() { }\r\n }\r\n\r\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\r\n const defaultDbName = \"SchemaSyncDb\";\r\n const testSyncCachePropKey = \"test.schema_sync.cache_name\";\r\n // for tests only\r\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\r\n if (cacheName)\r\n iModel[_nativeDb].saveLocalValue(testSyncCachePropKey, cacheName);\r\n else\r\n iModel[_nativeDb].deleteLocalValue(testSyncCachePropKey);\r\n };\r\n\r\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\r\n let nativeDb: IModelJsNative.DgnDb | undefined;\r\n const argIsIModelDb = arg instanceof IModelDb;\r\n if (argIsIModelDb) {\r\n nativeDb = arg[_nativeDb];\r\n } else {\r\n nativeDb = new IModelNative.platform.DgnDb();\r\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\r\n }\r\n\r\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\r\n if (!propsString)\r\n throw new Error(\"iModel does not have a SchemaSyncDb\");\r\n try {\r\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\r\n const accessToken = await CloudSqlite.requestToken(props);\r\n const access = new CloudAccess({ ...props, accessToken });\r\n Object.assign(access.lockParams, lockParams);\r\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\r\n if (testSyncCache)\r\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\r\n return access;\r\n } finally {\r\n if (!argIsIModelDb) {\r\n nativeDb.closeFile();\r\n }\r\n }\r\n };\r\n\r\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\r\n const access = await getCloudAccess(iModel);\r\n try {\r\n await access.withLockedDb(args, async () => operation(access));\r\n } finally {\r\n access.close();\r\n }\r\n };\r\n\r\n export const withReadonlyAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\r\n const access = await getCloudAccess(iModel);\r\n access.synchronizeWithCloud();\r\n access.openForRead();\r\n try {\r\n await operation(access);\r\n } finally {\r\n access.close();\r\n }\r\n };\r\n\r\n export const isEnabled = (iModel: IModelDb) => {\r\n return iModel[_nativeDb].schemaSyncEnabled();\r\n };\r\n\r\n /** Synchronize local briefcase schemas with cloud container */\r\n export const pull = async (iModel: IModelDb) => {\r\n if (iModel[_nativeDb].schemaSyncEnabled() && !iModel.isReadonly) {\r\n await SchemaSync.withReadonlyAccess(iModel, async (syncAccess) => {\r\n const schemaSyncDbUri = syncAccess.getUri();\r\n iModel.clearCaches();\r\n iModel[_nativeDb].schemaSyncPull(schemaSyncDbUri);\r\n iModel[_implicitTxn].saveChanges(\"schema synchronized with cloud container\");\r\n });\r\n }\r\n };\r\n\r\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\r\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\r\n const iModel = arg.iModel;\r\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\r\n await iModel.acquireSchemaLock();\r\n if (briefcase) {\r\n if (briefcase.txns.hasLocalChanges) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\r\n }\r\n await briefcase.pullChanges();\r\n }\r\n try {\r\n iModel[_implicitTxn].saveFileProperty(syncProperty, JSON.stringify(props));\r\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\r\n iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\r\n iModel[_implicitTxn].saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\r\n });\r\n } catch (err) {\r\n throw err;\r\n } finally {\r\n iModel[_implicitTxn].abandonChanges();\r\n }\r\n\r\n if (briefcase) {\r\n if (arg.overrideContainer)\r\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\r\n else\r\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\r\n }\r\n };\r\n\r\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\r\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\r\n public constructor(props: CloudSqlite.ContainerAccessProps) {\r\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\r\n }\r\n\r\n public getUri() {\r\n return `${this.getCloudDb()[_nativeDb].getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\r\n }\r\n /**\r\n * Initialize a cloud container for use as a SchemaSync. The container must first be created via its storage supplier api (e.g. Azure, or AWS).\r\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\r\n * @note this deletes any existing content in the container.\r\n */\r\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\r\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\r\n }\r\n }\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaUtils.js","sourceRoot":"","sources":["../../src/SchemaUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,aAAuB,EAAE,aAAkC;IACvG,MAAM,kBAAkB,GAAG,aAAa,EAAE,aAAa,CAAC;IACxD,MAAM,aAAa,GAAa,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;IAC5H,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,kCAAkC,CAAC,CAAC;IAEjF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAoB,EAAE,aAAkC;IACnG,MAAM,kBAAkB,GAAG,aAAa,EAAE,aAAa,CAAC;IACxD,MAAM,sBAAsB,GAAa,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IACrI,IAAI,sBAAsB,CAAC,MAAM,KAAK,CAAC;QACrC,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,mDAAmD,CAAC,CAAC;IAElG,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { ECSchemaXmlContext } from \"./ECSchemaXmlContext\";\nimport { IModelNative } from \"./internal/NativePlatform\";\n\n/** Converts EC2 Xml ECSchema(s). On success, the `EC2 Xml schemas` are converted into `EC3.2 Xml schemas`.\n * @param ec2XmlSchemas The EC2 Xml string(s) created from a serialized ECSchema.\n * @returns EC3.2 Xml ECSchema(s).\n * @throws [[IModelError]] if there is a problem converting the EC2 schemas.\n * @beta\n */\nexport function convertEC2SchemasToEC3Schemas(ec2XmlSchemas: string[], schemaContext?: ECSchemaXmlContext): string[] {\n const maybeNativeContext = schemaContext?.nativeContext;\n const ec3XmlSchemas: string[] = IModelNative.platform.SchemaUtility.convertEC2XmlSchemas(ec2XmlSchemas, maybeNativeContext);\n if (ec2XmlSchemas.length === 0)\n throw new IModelError(BentleyStatus.ERROR, \"Error converting EC2 Xml schemas\");\n\n return ec3XmlSchemas;\n}\n\n/** Converts schema metadata to EC3 concepts by traversing custom attributes of the supplied schema and calling converters based on schemaName:customAttributeName\n * @param xmlSchemas The ECSchema Xml string(s).\n * @returns EC3.2 Xml ECSchema(s) with converted custom attributes.\n * @throws [[IModelError]] if there is a problem converting the custom attributes of a schema.\n * @beta\n */\nexport function upgradeCustomAttributesToEC3(xmlSchemas: string[], schemaContext?: ECSchemaXmlContext): string[] {\n const maybeNativeContext = schemaContext?.nativeContext;\n const schemasWithConvertedCA: string[] = IModelNative.platform.SchemaUtility.convertCustomAttributes(xmlSchemas, maybeNativeContext);\n if (schemasWithConvertedCA.length === 0)\n throw new IModelError(BentleyStatus.ERROR, \"Error converting custom attributes of Xml schemas\");\n\n return schemasWithConvertedCA;\n}\n"]}
1
+ {"version":3,"file":"SchemaUtils.js","sourceRoot":"","sources":["../../src/SchemaUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,aAAuB,EAAE,aAAkC;IACvG,MAAM,kBAAkB,GAAG,aAAa,EAAE,aAAa,CAAC;IACxD,MAAM,aAAa,GAAa,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;IAC5H,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,kCAAkC,CAAC,CAAC;IAEjF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAoB,EAAE,aAAkC;IACnG,MAAM,kBAAkB,GAAG,aAAa,EAAE,aAAa,CAAC;IACxD,MAAM,sBAAsB,GAAa,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IACrI,IAAI,sBAAsB,CAAC,MAAM,KAAK,CAAC;QACrC,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,mDAAmD,CAAC,CAAC;IAElG,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { ECSchemaXmlContext } from \"./ECSchemaXmlContext\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\n\r\n/** Converts EC2 Xml ECSchema(s). On success, the `EC2 Xml schemas` are converted into `EC3.2 Xml schemas`.\r\n * @param ec2XmlSchemas The EC2 Xml string(s) created from a serialized ECSchema.\r\n * @returns EC3.2 Xml ECSchema(s).\r\n * @throws [[IModelError]] if there is a problem converting the EC2 schemas.\r\n * @beta\r\n */\r\nexport function convertEC2SchemasToEC3Schemas(ec2XmlSchemas: string[], schemaContext?: ECSchemaXmlContext): string[] {\r\n const maybeNativeContext = schemaContext?.nativeContext;\r\n const ec3XmlSchemas: string[] = IModelNative.platform.SchemaUtility.convertEC2XmlSchemas(ec2XmlSchemas, maybeNativeContext);\r\n if (ec2XmlSchemas.length === 0)\r\n throw new IModelError(BentleyStatus.ERROR, \"Error converting EC2 Xml schemas\");\r\n\r\n return ec3XmlSchemas;\r\n}\r\n\r\n/** Converts schema metadata to EC3 concepts by traversing custom attributes of the supplied schema and calling converters based on schemaName:customAttributeName\r\n * @param xmlSchemas The ECSchema Xml string(s).\r\n * @returns EC3.2 Xml ECSchema(s) with converted custom attributes.\r\n * @throws [[IModelError]] if there is a problem converting the custom attributes of a schema.\r\n * @beta\r\n */\r\nexport function upgradeCustomAttributesToEC3(xmlSchemas: string[], schemaContext?: ECSchemaXmlContext): string[] {\r\n const maybeNativeContext = schemaContext?.nativeContext;\r\n const schemasWithConvertedCA: string[] = IModelNative.platform.SchemaUtility.convertCustomAttributes(xmlSchemas, maybeNativeContext);\r\n if (schemasWithConvertedCA.length === 0)\r\n throw new IModelError(BentleyStatus.ERROR, \"Error converting custom attributes of Xml schemas\");\r\n\r\n return schemasWithConvertedCA;\r\n}\r\n"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { Code, CodeScopeProps, EntityReferenceSet, RelatedElementProps, SheetIndexEntryProps, SheetIndexReferenceProps, SheetReferenceProps } from "@itwin/core-common";
5
5
  import { InformationReferenceElement } from "./Element";
6
+ import { EditTxn } from "./EditTxn";
6
7
  import { IModelDb } from "./IModelDb";
7
8
  import { Id64String } from "@itwin/core-bentley";
8
9
  import { SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from "./NavigationRelationship";
@@ -63,6 +64,8 @@ export declare class SheetIndex extends InformationReferenceElement {
63
64
  * @returns The Id of the newly inserted SheetIndex
64
65
  * @throws [[IModelError]] if there is a problem inserting the SheetIndex
65
66
  */
67
+ static insert(txn: EditTxn, modelId: Id64String, name: string): Id64String;
68
+ /** @deprecated Use SheetIndex.insert(txn, ...) instead. */
66
69
  static insert(iModelDb: IModelDb, modelId: Id64String, name: string): Id64String;
67
70
  }
68
71
  /** The base class for all elements that can participate in a [[SheetIndex]] hierarchy.
@@ -97,6 +100,8 @@ export declare class SheetIndexFolder extends SheetIndexEntry {
97
100
  * @returns The Id of the newly inserted SheetIndexFolder element.
98
101
  * @throws [[IModelError]] if unable to create the element.
99
102
  */
103
+ static insert(txn: EditTxn, arg: Omit<SheetIndexEntryCreateArgs, "iModelDb">): Id64String;
104
+ /** @deprecated Use SheetIndexFolder.insert(txn, ...) instead. */
100
105
  static insert(arg: SheetIndexEntryCreateArgs): Id64String;
101
106
  }
102
107
  /** A node within one [[SheetIndex]] that incorporates another [[SheetIndex]] as a sub-tree.
@@ -118,6 +123,8 @@ export declare class SheetIndexReference extends SheetIndexEntry {
118
123
  * @returns The Id of the newly inserted SheetIndexReference element.
119
124
  * @throws [[IModelError]] if unable to create the element.
120
125
  */
126
+ static insert(txn: EditTxn, arg: Omit<SheetIndexReferenceCreateArgs, "iModelDb">): Id64String;
127
+ /** @deprecated Use SheetIndexReference.insert(txn, ...) instead. */
121
128
  static insert(arg: SheetIndexReferenceCreateArgs): Id64String;
122
129
  /** @alpha */
123
130
  protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
@@ -141,6 +148,8 @@ export declare class SheetReference extends SheetIndexEntry {
141
148
  * @returns The Id of the newly inserted SheetReference element.
142
149
  * @throws [[IModelError]] if unable to create the element.
143
150
  */
151
+ static insert(txn: EditTxn, arg: Omit<SheetReferenceCreateArgs, "iModelDb">): Id64String;
152
+ /** @deprecated Use SheetReference.insert(txn, ...) instead. */
144
153
  static insert(arg: SheetReferenceCreateArgs): Id64String;
145
154
  /** @alpha */
146
155
  protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
@@ -1 +1 @@
1
- {"version":3,"file":"SheetIndex.d.ts","sourceRoot":"","sources":["../../src/SheetIndex.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAe,IAAI,EAAE,cAAc,EAA0B,kBAAkB,EAAe,mBAAmB,EAAE,oBAAoB,EA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;IAWlE,SAAS,CAAC,MAAM,CAAC,gCAAgC,CAAC,EAAE,EAAE,UAAU,GAAG,mBAAmB;IAItE,MAAM,IAAI,mBAAmB;IAO7C;;;OAGG;WACW,MAAM,CAAC,GAAG,EAAE,wBAAwB;IAQlD;;;OAGG;WACW,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,GAAG,UAAU;IAC/F,+DAA+D;WACjD,MAAM,CAAC,GAAG,EAAE,wBAAwB,GAAG,UAAU;IAe/D,aAAa;cACM,mBAAmB,CAAC,YAAY,EAAE,kBAAkB,GAAG,IAAI;CAK/E"}
@@ -7,8 +7,10 @@
7
7
  */
8
8
  import { BisCodeSpec, Code, IModelError } from "@itwin/core-common";
9
9
  import { InformationReferenceElement } from "./Element";
10
+ import { EditTxn } from "./EditTxn";
10
11
  import { IModelStatus } from "@itwin/core-bentley";
11
12
  import { SheetIndexFolderOwnsEntries, SheetIndexOwnsEntries, SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from "./NavigationRelationship";
13
+ import { _implicitTxn } from "./internal/Symbols";
12
14
  /** A [structured collection]($docs/bis/domains/drawings-sheets#sheet-index) of [[SheetIndexEntry]]s.
13
15
  * The sheet index is a tree whose leaf nodes refer to [[Sheet]]s, optionally grouped by [[SheetIndexFolder]]s and/or incorporating
14
16
  * sub-trees via [[SheetIndexReference]]s.
@@ -40,17 +42,10 @@ export class SheetIndex extends InformationReferenceElement {
40
42
  };
41
43
  return new this(props, iModelDb);
42
44
  }
43
- /** Insert a SheetIndex
44
- * @param iModelDb The IModelDb
45
- * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.
46
- * @param name The name (codeValue) of the SheetIndex
47
- * @returns The Id of the newly inserted SheetIndex
48
- * @throws [[IModelError]] if there is a problem inserting the SheetIndex
49
- */
50
- static insert(iModelDb, modelId, name) {
51
- const instance = this.create(iModelDb, modelId, name);
52
- const elements = iModelDb.elements;
53
- instance.id = elements.insertElement(instance.toJSON());
45
+ static insert(txnOrDb, modelId, name) {
46
+ const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];
47
+ const instance = this.create(txn.iModel, modelId, name);
48
+ instance.id = instance.insert(txn);
54
49
  return instance.id;
55
50
  }
56
51
  }
@@ -108,14 +103,16 @@ export class SheetIndexFolder extends SheetIndexEntry {
108
103
  const props = this.createProps(arg);
109
104
  return new this(props, arg.iModelDb);
110
105
  }
111
- /** Create a new SheetIndexFolder
112
- * @returns The Id of the newly inserted SheetIndexFolder element.
113
- * @throws [[IModelError]] if unable to create the element.
114
- */
115
- static insert(arg) {
116
- const instance = this.create(arg);
117
- const elements = arg.iModelDb.elements;
118
- instance.id = elements.insertElement(instance.toJSON());
106
+ static insert(txnOrArg, arg) {
107
+ const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];
108
+ const createArg = txnOrArg instanceof EditTxn ? arg : {
109
+ sheetIndexModelId: txnOrArg.sheetIndexModelId,
110
+ parentId: txnOrArg.parentId,
111
+ name: txnOrArg.name,
112
+ priority: txnOrArg.priority,
113
+ };
114
+ const instance = this.create({ ...createArg, iModelDb: txn.iModel });
115
+ instance.id = instance.insert(txn);
119
116
  return instance.id;
120
117
  }
121
118
  }
@@ -155,14 +152,17 @@ export class SheetIndexReference extends SheetIndexEntry {
155
152
  };
156
153
  return new this(props, arg.iModelDb);
157
154
  }
158
- /** Create a new SheetIndexReference
159
- * @returns The Id of the newly inserted SheetIndexReference element.
160
- * @throws [[IModelError]] if unable to create the element.
161
- */
162
- static insert(arg) {
163
- const instance = this.create(arg);
164
- const elements = arg.iModelDb.elements;
165
- instance.id = elements.insertElement(instance.toJSON());
155
+ static insert(txnOrArg, arg) {
156
+ const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];
157
+ const createArg = txnOrArg instanceof EditTxn ? arg : {
158
+ sheetIndexModelId: txnOrArg.sheetIndexModelId,
159
+ parentId: txnOrArg.parentId,
160
+ name: txnOrArg.name,
161
+ priority: txnOrArg.priority,
162
+ sheetIndexId: txnOrArg.sheetIndexId,
163
+ };
164
+ const instance = this.create({ ...createArg, iModelDb: txn.iModel });
165
+ instance.id = instance.insert(txn);
166
166
  return instance.id;
167
167
  }
168
168
  /** @alpha */
@@ -208,14 +208,17 @@ export class SheetReference extends SheetIndexEntry {
208
208
  };
209
209
  return new this(props, arg.iModelDb);
210
210
  }
211
- /** Insert a new SheetReference
212
- * @returns The Id of the newly inserted SheetReference element.
213
- * @throws [[IModelError]] if unable to create the element.
214
- */
215
- static insert(arg) {
216
- const instance = this.create(arg);
217
- const elements = arg.iModelDb.elements;
218
- instance.id = elements.insertElement(instance.toJSON());
211
+ static insert(txnOrArg, arg) {
212
+ const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];
213
+ const createArg = txnOrArg instanceof EditTxn ? arg : {
214
+ sheetIndexModelId: txnOrArg.sheetIndexModelId,
215
+ parentId: txnOrArg.parentId,
216
+ name: txnOrArg.name,
217
+ priority: txnOrArg.priority,
218
+ sheetId: txnOrArg.sheetId,
219
+ };
220
+ const instance = this.create({ ...createArg, iModelDb: txn.iModel });
221
+ instance.id = instance.insert(txn);
219
222
  return instance.id;
220
223
  }
221
224
  /** @alpha */
@@ -1 +1 @@
1
- {"version":3,"file":"SheetIndex.js","sourceRoot":"","sources":["../../src/SheetIndex.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,IAAI,EAA8D,WAAW,EAAmH,MAAM,oBAAoB,CAAC;AACjP,OAAO,EAAE,2BAA2B,EAAS,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAc,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,qCAAqC,EAAE,2BAA2B,EAAE,MAAM,0BA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AAM,KAAK,GAAwB;YACjC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;YACxB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,gCAAgC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;SACpF,CAAC;QACF,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,GAA6B;QAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACvC,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAED,aAAa;IACM,mBAAmB,CAAC,YAAgC;QACrE,KAAK,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, ElementProps, EntityReferenceSet, IModelError, RelatedElementProps, SheetIndexEntryProps, SheetIndexFolderProps, SheetIndexReferenceProps, SheetReferenceProps } from \"@itwin/core-common\";\nimport { InformationReferenceElement, Sheet } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { SheetIndexFolderOwnsEntries, SheetIndexOwnsEntries, SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from \"./NavigationRelationship\";\n\n/** Arguments used to create a [[SheetIndexEntry]].\n * @beta\n */\nexport interface SheetIndexEntryCreateArgs {\n /** The iModel that will contain the sheet index entry. */\n iModelDb: IModelDb;\n /** The Id of the [[SheetIndexModel]] that will contain the sheet index entry. */\n sheetIndexModelId: Id64String;\n /** The [[SheetIndex]] or [[SheetIndexFolder]] that is parent to this SheetIndexEntry */\n parentId: Id64String;\n /** The name of the SheetIndexEntry */\n name: string;\n /** The priority of the SheetIndexEntry */\n priority: number;\n}\n\n/** Arguments supplied when creating a [[SheetIndexReference]].\n * @beta\n */\nexport interface SheetIndexReferenceCreateArgs extends SheetIndexEntryCreateArgs {\n /** The [[SheetIndex]] to which the reference refers. */\n sheetIndexId?: Id64String;\n}\n\n/** Arguments supplied when creating a [[SheetReference]].\n * @beta\n */\nexport interface SheetReferenceCreateArgs extends SheetIndexEntryCreateArgs {\n /** The [[Sheet]] to which the reference refers. */\n sheetId?: Id64String;\n}\n\n/** A [structured collection]($docs/bis/domains/drawings-sheets#sheet-index) of [[SheetIndexEntry]]s.\n * The sheet index is a tree whose leaf nodes refer to [[Sheet]]s, optionally grouped by [[SheetIndexFolder]]s and/or incorporating\n * sub-trees via [[SheetIndexReference]]s.\n * @beta\n */\nexport class SheetIndex extends InformationReferenceElement {\n public static override get className(): string { return \"SheetIndex\"; }\n\n /** Create a Code for a SheetIndex given a name that is meant to be unique within the scope of the specified SheetIndexModel.\n * @param iModel The IModelDb\n * @param scopeSheetIndexModelId The Id of the Model that contains the LinkElement and provides the scope for its name.\n * @param codeValue The SheetIndex name\n */\n public static createCode(iModel: IModelDb, scopeSheetIndexModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.sheetIndex);\n return new Code({ spec: codeSpec.id, scope: scopeSheetIndexModelId, value: codeValue });\n }\n\n /** Create a SheetIndex\n * @param iModelDb The IModelDb\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\n * @param name The name (codeValue) of the SheetIndex\n * @returns The newly constructed SheetIndex\n * @throws [[IModelError]] if there is a problem creating the SheetIndex\n */\n public static create(iModelDb: IModelDb, modelId: Id64String, name: string): SheetIndex {\n const props: ElementProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, modelId, name).toJSON(),\n model: modelId,\n };\n return new this(props, iModelDb);\n }\n\n /** Insert a SheetIndex\n * @param iModelDb The IModelDb\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\n * @param name The name (codeValue) of the SheetIndex\n * @returns The Id of the newly inserted SheetIndex\n * @throws [[IModelError]] if there is a problem inserting the SheetIndex\n */\n public static insert(iModelDb: IModelDb, modelId: Id64String, name: string): Id64String {\n const instance = this.create(iModelDb, modelId, name);\n const elements = iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n}\n\n/** The base class for all elements that can participate in a [[SheetIndex]] hierarchy.\n * @beta\n*/\nexport abstract class SheetIndexEntry extends InformationReferenceElement {\n public static override get className(): string { return \"SheetIndexEntry\"; }\n /** Can be used to prioritize or order members within a SheetIndex or SheetIndexFolder. */\n public entryPriority: number;\n\n protected constructor(props: SheetIndexEntryProps, iModel: IModelDb) {\n super(props, iModel);\n this.entryPriority = props.entryPriority;\n }\n\n public override toJSON(): SheetIndexEntryProps {\n return { ...super.toJSON(), entryPriority: this.entryPriority };\n }\n\n /** Create a Code for a Sheet Index Entry given a name that is meant to be unique within the scope of the specified SheetIndexModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the [[SheetIndexModel]] that contains the [[SheetIndexEntry]] and provides the scope for its name.\n * @param codeValue The name of the entry\n */\n public static createCode(iModelDb: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.sheetIndexEntry);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n protected static createParentRelationshipProps(iModelDb: IModelDb, id: Id64String): RelatedElementProps {\n const parentElementProps = iModelDb.elements.getElementProps(id);\n const isFolder = parentElementProps.classFullName === SheetIndexFolder.classFullName;\n const relClass = isFolder ? SheetIndexFolderOwnsEntries : SheetIndexOwnsEntries;\n return { id, relClassName: relClass.classFullName };\n }\n\n protected static createProps(arg: SheetIndexEntryCreateArgs) {\n const parent = this.createParentRelationshipProps(arg.iModelDb, arg.parentId);\n const props: SheetIndexEntryProps = {\n classFullName: this.classFullName,\n model: arg.sheetIndexModelId,\n code: this.createCode(arg.iModelDb, arg.sheetIndexModelId, arg.name),\n entryPriority: arg.priority,\n parent,\n };\n return props;\n }\n}\n\n/** A container used to group [[SheetIndexEntry]]s within a [[SheetIndex]].\n * @beta\n */\nexport class SheetIndexFolder extends SheetIndexEntry {\n public static override get className(): string { return \"SheetIndexFolder\"; }\n\n /** Create a new SheetIndexFolder\n * @returns The newly constructed SheetIndexFolder element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetIndexEntryCreateArgs) {\n const props: SheetIndexFolderProps = this.createProps(arg);\n return new this(props, arg.iModelDb);\n }\n\n /** Create a new SheetIndexFolder\n * @returns The Id of the newly inserted SheetIndexFolder element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(arg: SheetIndexEntryCreateArgs): Id64String {\n const instance = this.create(arg);\n const elements = arg.iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n}\n\n/** A node within one [[SheetIndex]] that incorporates another [[SheetIndex]] as a sub-tree.\n * @beta\n*/\nexport class SheetIndexReference extends SheetIndexEntry {\n public static override get className(): string { return \"SheetIndexReference\"; }\n\n /** The bis:SheetIndex that this bis:SheetIndexReference is pointing to. */\n public sheetIndex?: SheetIndexReferenceRefersToSheetIndex;\n\n protected constructor(props: SheetIndexReferenceProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.sheetIndex) {\n const sheetIndex = iModel.elements.tryGetElement<SheetIndex>(props.sheetIndex.id);\n if (!sheetIndex)\n throw new IModelError(IModelStatus.NotFound, \"SheetIndex not found\");\n\n this.sheetIndex = new SheetIndexReferenceRefersToSheetIndex(props.sheetIndex.id);\n }\n }\n\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\n }\n\n public override toJSON(): SheetIndexReferenceProps { // This override only specializes the return type\n return {\n ...super.toJSON(),\n sheetIndex: this.sheetIndex ? this.sheetIndex.toJSON() : undefined,\n } as SheetIndexReferenceProps;\n }\n\n /** Create a new SheetIndexReference\n * @returns The newly constructed SheetIndexReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetIndexReferenceCreateArgs) {\n const props: SheetIndexReferenceProps = {\n ...this.createProps(arg),\n sheetIndex: arg.sheetIndexId ? this.createReferenceRelationshipProps(arg.sheetIndexId) : undefined,\n };\n return new this(props, arg.iModelDb);\n }\n\n /** Create a new SheetIndexReference\n * @returns The Id of the newly inserted SheetIndexReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(arg: SheetIndexReferenceCreateArgs): Id64String {\n const instance = this.create(arg);\n const elements = arg.iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n\n /** @alpha */\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.sheetIndex)\n referenceIds.addElement(this.sheetIndex.id);\n }\n}\n\n/** A leaf node in a [[SheetIndex]] that refers to a specific [[Sheet]].\n * @beta\n*/\nexport class SheetReference extends SheetIndexEntry {\n public static override get className(): string { return \"SheetReference\"; }\n\n /** The bis:Sheet that this bis:SheetReference is pointing to. */\n public sheet: SheetReferenceRefersToSheet | undefined;\n\n protected constructor(props: SheetReferenceProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.sheet) {\n const sheet = iModel.elements.tryGetElement<Sheet>(props.sheet.id);\n if (!sheet)\n throw new IModelError(IModelStatus.NotFound, \"Sheet not found\");\n\n this.sheet = new SheetReferenceRefersToSheet(sheet.id);\n }\n }\n\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\n }\n\n public override toJSON(): SheetReferenceProps { // This override only specializes the return type\n return {\n ...super.toJSON(),\n sheet: this.sheet ? this.sheet.toJSON() : undefined,\n } as SheetReferenceProps;\n }\n\n /** Create a new SheetReference\n * @returns The newly constructed SheetReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetReferenceCreateArgs) {\n const props: SheetReferenceProps = {\n ...this.createProps(arg),\n sheet: arg.sheetId ? this.createReferenceRelationshipProps(arg.sheetId) : undefined,\n };\n return new this(props, arg.iModelDb);\n }\n\n /** Insert a new SheetReference\n * @returns The Id of the newly inserted SheetReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(arg: SheetReferenceCreateArgs): Id64String {\n const instance = this.create(arg);\n const elements = arg.iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n\n /** @alpha */\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.sheet)\n referenceIds.addModel(this.sheet.id);\n }\n}\n"]}
1
+ {"version":3,"file":"SheetIndex.js","sourceRoot":"","sources":["../../src/SheetIndex.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,IAAI,EAA8D,WAAW,EAAmH,MAAM,oBAAoB,CAAC;AACjP,OAAO,EAAE,2BAA2B,EAAS,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAc,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,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ACjH,MAAM,GAAG,GAAG,QAAQ,YAAY,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACrF,MAAM,SAAS,GAAG,QAAQ,YAAY,OAAO,CAAC,CAAC,CAAC,GAAI,CAAC,CAAC,CAAC;YACrD,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;YAC7C,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACrE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAED,aAAa;IACM,mBAAmB,CAAC,YAAgC;QACrE,KAAK,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, ElementProps, EntityReferenceSet, IModelError, RelatedElementProps, SheetIndexEntryProps, SheetIndexFolderProps, SheetIndexReferenceProps, SheetReferenceProps } from \"@itwin/core-common\";\r\nimport { InformationReferenceElement, Sheet } from \"./Element\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { SheetIndexFolderOwnsEntries, SheetIndexOwnsEntries, SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from \"./NavigationRelationship\";\r\nimport { _implicitTxn } from \"./internal/Symbols\";\r\n\r\n/** Arguments used to create a [[SheetIndexEntry]].\r\n * @beta\r\n */\r\nexport interface SheetIndexEntryCreateArgs {\r\n /** The iModel that will contain the sheet index entry. */\r\n iModelDb: IModelDb;\r\n /** The Id of the [[SheetIndexModel]] that will contain the sheet index entry. */\r\n sheetIndexModelId: Id64String;\r\n /** The [[SheetIndex]] or [[SheetIndexFolder]] that is parent to this SheetIndexEntry */\r\n parentId: Id64String;\r\n /** The name of the SheetIndexEntry */\r\n name: string;\r\n /** The priority of the SheetIndexEntry */\r\n priority: number;\r\n}\r\n\r\n/** Arguments supplied when creating a [[SheetIndexReference]].\r\n * @beta\r\n */\r\nexport interface SheetIndexReferenceCreateArgs extends SheetIndexEntryCreateArgs {\r\n /** The [[SheetIndex]] to which the reference refers. */\r\n sheetIndexId?: Id64String;\r\n}\r\n\r\n/** Arguments supplied when creating a [[SheetReference]].\r\n * @beta\r\n */\r\nexport interface SheetReferenceCreateArgs extends SheetIndexEntryCreateArgs {\r\n /** The [[Sheet]] to which the reference refers. */\r\n sheetId?: Id64String;\r\n}\r\n\r\n/** A [structured collection]($docs/bis/domains/drawings-sheets#sheet-index) of [[SheetIndexEntry]]s.\r\n * The sheet index is a tree whose leaf nodes refer to [[Sheet]]s, optionally grouped by [[SheetIndexFolder]]s and/or incorporating\r\n * sub-trees via [[SheetIndexReference]]s.\r\n * @beta\r\n */\r\nexport class SheetIndex extends InformationReferenceElement {\r\n public static override get className(): string { return \"SheetIndex\"; }\r\n\r\n /** Create a Code for a SheetIndex given a name that is meant to be unique within the scope of the specified SheetIndexModel.\r\n * @param iModel The IModelDb\r\n * @param scopeSheetIndexModelId The Id of the Model that contains the LinkElement and provides the scope for its name.\r\n * @param codeValue The SheetIndex name\r\n */\r\n public static createCode(iModel: IModelDb, scopeSheetIndexModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.sheetIndex);\r\n return new Code({ spec: codeSpec.id, scope: scopeSheetIndexModelId, value: codeValue });\r\n }\r\n\r\n /** Create a SheetIndex\r\n * @param iModelDb The IModelDb\r\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\r\n * @param name The name (codeValue) of the SheetIndex\r\n * @returns The newly constructed SheetIndex\r\n * @throws [[IModelError]] if there is a problem creating the SheetIndex\r\n */\r\n public static create(iModelDb: IModelDb, modelId: Id64String, name: string): SheetIndex {\r\n const props: ElementProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, modelId, name).toJSON(),\r\n model: modelId,\r\n };\r\n return new this(props, iModelDb);\r\n }\r\n\r\n /** Insert a SheetIndex\r\n * @param iModelDb The IModelDb\r\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\r\n * @param name The name (codeValue) of the SheetIndex\r\n * @returns The Id of the newly inserted SheetIndex\r\n * @throws [[IModelError]] if there is a problem inserting the SheetIndex\r\n */\r\n public static insert(txn: EditTxn, modelId: Id64String, name: string): Id64String;\r\n /** @deprecated Use SheetIndex.insert(txn, ...) instead. */\r\n public static insert(iModelDb: IModelDb, modelId: Id64String, name: string): Id64String;\r\n public static insert(txnOrDb: EditTxn | IModelDb, modelId: Id64String, name: string): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const instance = this.create(txn.iModel, modelId, name);\r\n instance.id = instance.insert(txn);\r\n return instance.id;\r\n }\r\n}\r\n\r\n/** The base class for all elements that can participate in a [[SheetIndex]] hierarchy.\r\n * @beta\r\n*/\r\nexport abstract class SheetIndexEntry extends InformationReferenceElement {\r\n public static override get className(): string { return \"SheetIndexEntry\"; }\r\n /** Can be used to prioritize or order members within a SheetIndex or SheetIndexFolder. */\r\n public entryPriority: number;\r\n\r\n protected constructor(props: SheetIndexEntryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.entryPriority = props.entryPriority;\r\n }\r\n\r\n public override toJSON(): SheetIndexEntryProps {\r\n return { ...super.toJSON(), entryPriority: this.entryPriority };\r\n }\r\n\r\n /** Create a Code for a Sheet Index Entry given a name that is meant to be unique within the scope of the specified SheetIndexModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the [[SheetIndexModel]] that contains the [[SheetIndexEntry]] and provides the scope for its name.\r\n * @param codeValue The name of the entry\r\n */\r\n public static createCode(iModelDb: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.sheetIndexEntry);\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n protected static createParentRelationshipProps(iModelDb: IModelDb, id: Id64String): RelatedElementProps {\r\n const parentElementProps = iModelDb.elements.getElementProps(id);\r\n const isFolder = parentElementProps.classFullName === SheetIndexFolder.classFullName;\r\n const relClass = isFolder ? SheetIndexFolderOwnsEntries : SheetIndexOwnsEntries;\r\n return { id, relClassName: relClass.classFullName };\r\n }\r\n\r\n protected static createProps(arg: SheetIndexEntryCreateArgs) {\r\n const parent = this.createParentRelationshipProps(arg.iModelDb, arg.parentId);\r\n const props: SheetIndexEntryProps = {\r\n classFullName: this.classFullName,\r\n model: arg.sheetIndexModelId,\r\n code: this.createCode(arg.iModelDb, arg.sheetIndexModelId, arg.name),\r\n entryPriority: arg.priority,\r\n parent,\r\n };\r\n return props;\r\n }\r\n}\r\n\r\n/** A container used to group [[SheetIndexEntry]]s within a [[SheetIndex]].\r\n * @beta\r\n */\r\nexport class SheetIndexFolder extends SheetIndexEntry {\r\n public static override get className(): string { return \"SheetIndexFolder\"; }\r\n\r\n /** Create a new SheetIndexFolder\r\n * @returns The newly constructed SheetIndexFolder element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(arg: SheetIndexEntryCreateArgs) {\r\n const props: SheetIndexFolderProps = this.createProps(arg);\r\n return new this(props, arg.iModelDb);\r\n }\r\n\r\n /** Create a new SheetIndexFolder\r\n * @returns The Id of the newly inserted SheetIndexFolder element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static insert(txn: EditTxn, arg: Omit<SheetIndexEntryCreateArgs, \"iModelDb\">): Id64String;\r\n /** @deprecated Use SheetIndexFolder.insert(txn, ...) instead. */\r\n public static insert(arg: SheetIndexEntryCreateArgs): Id64String;\r\n public static insert(txnOrArg: EditTxn | SheetIndexEntryCreateArgs, arg?: Omit<SheetIndexEntryCreateArgs, \"iModelDb\">): Id64String {\r\n const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];\r\n const createArg = txnOrArg instanceof EditTxn ? arg! : {\r\n sheetIndexModelId: txnOrArg.sheetIndexModelId,\r\n parentId: txnOrArg.parentId,\r\n name: txnOrArg.name,\r\n priority: txnOrArg.priority,\r\n };\r\n const instance = this.create({ ...createArg, iModelDb: txn.iModel });\r\n instance.id = instance.insert(txn);\r\n return instance.id;\r\n }\r\n}\r\n\r\n/** A node within one [[SheetIndex]] that incorporates another [[SheetIndex]] as a sub-tree.\r\n * @beta\r\n*/\r\nexport class SheetIndexReference extends SheetIndexEntry {\r\n public static override get className(): string { return \"SheetIndexReference\"; }\r\n\r\n /** The bis:SheetIndex that this bis:SheetIndexReference is pointing to. */\r\n public sheetIndex?: SheetIndexReferenceRefersToSheetIndex;\r\n\r\n protected constructor(props: SheetIndexReferenceProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.sheetIndex) {\r\n const sheetIndex = iModel.elements.tryGetElement<SheetIndex>(props.sheetIndex.id);\r\n if (!sheetIndex)\r\n throw new IModelError(IModelStatus.NotFound, \"SheetIndex not found\");\r\n\r\n this.sheetIndex = new SheetIndexReferenceRefersToSheetIndex(props.sheetIndex.id);\r\n }\r\n }\r\n\r\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\r\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\r\n }\r\n\r\n public override toJSON(): SheetIndexReferenceProps { // This override only specializes the return type\r\n return {\r\n ...super.toJSON(),\r\n sheetIndex: this.sheetIndex ? this.sheetIndex.toJSON() : undefined,\r\n } as SheetIndexReferenceProps;\r\n }\r\n\r\n /** Create a new SheetIndexReference\r\n * @returns The newly constructed SheetIndexReference element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(arg: SheetIndexReferenceCreateArgs) {\r\n const props: SheetIndexReferenceProps = {\r\n ...this.createProps(arg),\r\n sheetIndex: arg.sheetIndexId ? this.createReferenceRelationshipProps(arg.sheetIndexId) : undefined,\r\n };\r\n return new this(props, arg.iModelDb);\r\n }\r\n\r\n /** Create a new SheetIndexReference\r\n * @returns The Id of the newly inserted SheetIndexReference element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static insert(txn: EditTxn, arg: Omit<SheetIndexReferenceCreateArgs, \"iModelDb\">): Id64String;\r\n /** @deprecated Use SheetIndexReference.insert(txn, ...) instead. */\r\n public static insert(arg: SheetIndexReferenceCreateArgs): Id64String;\r\n public static insert(txnOrArg: EditTxn | SheetIndexReferenceCreateArgs, arg?: Omit<SheetIndexReferenceCreateArgs, \"iModelDb\">): Id64String {\r\n const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];\r\n const createArg = txnOrArg instanceof EditTxn ? arg! : {\r\n sheetIndexModelId: txnOrArg.sheetIndexModelId,\r\n parentId: txnOrArg.parentId,\r\n name: txnOrArg.name,\r\n priority: txnOrArg.priority,\r\n sheetIndexId: txnOrArg.sheetIndexId,\r\n };\r\n const instance = this.create({ ...createArg, iModelDb: txn.iModel });\r\n instance.id = instance.insert(txn);\r\n return instance.id;\r\n }\r\n\r\n /** @alpha */\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n if (this.sheetIndex)\r\n referenceIds.addElement(this.sheetIndex.id);\r\n }\r\n}\r\n\r\n/** A leaf node in a [[SheetIndex]] that refers to a specific [[Sheet]].\r\n * @beta\r\n*/\r\nexport class SheetReference extends SheetIndexEntry {\r\n public static override get className(): string { return \"SheetReference\"; }\r\n\r\n /** The bis:Sheet that this bis:SheetReference is pointing to. */\r\n public sheet: SheetReferenceRefersToSheet | undefined;\r\n\r\n protected constructor(props: SheetReferenceProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.sheet) {\r\n const sheet = iModel.elements.tryGetElement<Sheet>(props.sheet.id);\r\n if (!sheet)\r\n throw new IModelError(IModelStatus.NotFound, \"Sheet not found\");\r\n\r\n this.sheet = new SheetReferenceRefersToSheet(sheet.id);\r\n }\r\n }\r\n\r\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\r\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\r\n }\r\n\r\n public override toJSON(): SheetReferenceProps { // This override only specializes the return type\r\n return {\r\n ...super.toJSON(),\r\n sheet: this.sheet ? this.sheet.toJSON() : undefined,\r\n } as SheetReferenceProps;\r\n }\r\n\r\n /** Create a new SheetReference\r\n * @returns The newly constructed SheetReference element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(arg: SheetReferenceCreateArgs) {\r\n const props: SheetReferenceProps = {\r\n ...this.createProps(arg),\r\n sheet: arg.sheetId ? this.createReferenceRelationshipProps(arg.sheetId) : undefined,\r\n };\r\n return new this(props, arg.iModelDb);\r\n }\r\n\r\n /** Insert a new SheetReference\r\n * @returns The Id of the newly inserted SheetReference element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static insert(txn: EditTxn, arg: Omit<SheetReferenceCreateArgs, \"iModelDb\">): Id64String;\r\n /** @deprecated Use SheetReference.insert(txn, ...) instead. */\r\n public static insert(arg: SheetReferenceCreateArgs): Id64String;\r\n public static insert(txnOrArg: EditTxn | SheetReferenceCreateArgs, arg?: Omit<SheetReferenceCreateArgs, \"iModelDb\">): Id64String {\r\n const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];\r\n const createArg = txnOrArg instanceof EditTxn ? arg! : {\r\n sheetIndexModelId: txnOrArg.sheetIndexModelId,\r\n parentId: txnOrArg.parentId,\r\n name: txnOrArg.name,\r\n priority: txnOrArg.priority,\r\n sheetId: txnOrArg.sheetId,\r\n };\r\n const instance = this.create({ ...createArg, iModelDb: txn.iModel });\r\n instance.id = instance.insert(txn);\r\n return instance.id;\r\n }\r\n\r\n /** @alpha */\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n if (this.sheet)\r\n referenceIds.addModel(this.sheet.id);\r\n }\r\n}\r\n"]}