@itwin/core-backend 4.0.0-dev.51 → 4.0.0-dev.54

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 (267) hide show
  1. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  2. package/lib/cjs/AliCloudStorageService.js +71 -71
  3. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  5. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendHubAccess.js.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.d.ts +90 -91
  9. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  10. package/lib/cjs/BackendLoggerCategory.js +98 -99
  11. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  12. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  13. package/lib/cjs/BisCoreSchema.js +60 -60
  14. package/lib/cjs/BisCoreSchema.js.map +1 -1
  15. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  16. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  17. package/lib/cjs/BriefcaseManager.js +408 -408
  18. package/lib/cjs/BriefcaseManager.js.map +1 -1
  19. package/lib/cjs/Category.d.ts +153 -153
  20. package/lib/cjs/Category.js +243 -243
  21. package/lib/cjs/Category.js.map +1 -1
  22. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  23. package/lib/cjs/ChangeSummaryManager.js +446 -446
  24. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  25. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  26. package/lib/cjs/ChangedElementsDb.js +165 -165
  27. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  28. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  29. package/lib/cjs/ChangedElementsManager.js +88 -88
  30. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  31. package/lib/cjs/ChannelControl.d.ts +69 -69
  32. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  33. package/lib/cjs/ChannelControl.js +88 -88
  34. package/lib/cjs/ChannelControl.js.map +1 -1
  35. package/lib/cjs/CheckpointManager.d.ts +121 -121
  36. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  37. package/lib/cjs/CheckpointManager.js +351 -351
  38. package/lib/cjs/CheckpointManager.js.map +1 -1
  39. package/lib/cjs/ClassRegistry.d.ts +79 -79
  40. package/lib/cjs/ClassRegistry.js +254 -249
  41. package/lib/cjs/ClassRegistry.js.map +1 -1
  42. package/lib/cjs/CloudSqlite.d.ts +355 -355
  43. package/lib/cjs/CloudSqlite.js +154 -154
  44. package/lib/cjs/CloudSqlite.js.map +1 -1
  45. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  46. package/lib/cjs/CloudStorageBackend.js +170 -170
  47. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  48. package/lib/cjs/CodeService.d.ts +396 -396
  49. package/lib/cjs/CodeService.js +63 -63
  50. package/lib/cjs/CodeService.js.map +1 -1
  51. package/lib/cjs/CodeSpecs.d.ts +55 -55
  52. package/lib/cjs/CodeSpecs.js +124 -124
  53. package/lib/cjs/CodeSpecs.js.map +1 -1
  54. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  55. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  56. package/lib/cjs/ConcurrentQuery.js +36 -36
  57. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  58. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  59. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  60. package/lib/cjs/CustomViewState3dCreator.js +82 -81
  61. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  62. package/lib/cjs/DevTools.d.ts +74 -73
  63. package/lib/cjs/DevTools.d.ts.map +1 -1
  64. package/lib/cjs/DevTools.js +156 -156
  65. package/lib/cjs/DevTools.js.map +1 -1
  66. package/lib/cjs/DisplayStyle.d.ts +106 -106
  67. package/lib/cjs/DisplayStyle.js +253 -253
  68. package/lib/cjs/DisplayStyle.js.map +1 -1
  69. package/lib/cjs/ECDb.d.ts +194 -191
  70. package/lib/cjs/ECDb.d.ts.map +1 -1
  71. package/lib/cjs/ECDb.js +353 -348
  72. package/lib/cjs/ECDb.js.map +1 -1
  73. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  74. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  75. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  76. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  77. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  78. package/lib/cjs/ECSqlStatement.js +791 -791
  79. package/lib/cjs/ECSqlStatement.js.map +1 -1
  80. package/lib/cjs/Element.d.ts +1113 -1113
  81. package/lib/cjs/Element.js +1424 -1424
  82. package/lib/cjs/Element.js.map +1 -1
  83. package/lib/cjs/ElementAspect.d.ts +176 -176
  84. package/lib/cjs/ElementAspect.js +203 -203
  85. package/lib/cjs/ElementAspect.js.map +1 -1
  86. package/lib/cjs/ElementGraphics.d.ts +9 -9
  87. package/lib/cjs/ElementGraphics.js +41 -41
  88. package/lib/cjs/ElementGraphics.js.map +1 -1
  89. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  90. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  91. package/lib/cjs/ElementTreeWalker.js +409 -409
  92. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  93. package/lib/cjs/Entity.d.ts +106 -106
  94. package/lib/cjs/Entity.d.ts.map +1 -1
  95. package/lib/cjs/Entity.js +134 -134
  96. package/lib/cjs/Entity.js.map +1 -1
  97. package/lib/cjs/EntityReferences.d.ts +49 -49
  98. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  99. package/lib/cjs/EntityReferences.js +95 -95
  100. package/lib/cjs/EntityReferences.js.map +1 -1
  101. package/lib/cjs/ExportGraphics.d.ts +317 -317
  102. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  103. package/lib/cjs/ExportGraphics.js +208 -208
  104. package/lib/cjs/ExportGraphics.js.map +1 -1
  105. package/lib/cjs/ExternalSource.d.ts +96 -96
  106. package/lib/cjs/ExternalSource.js +131 -131
  107. package/lib/cjs/ExternalSource.js.map +1 -1
  108. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  109. package/lib/cjs/GeoCoordConfig.js +85 -85
  110. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  111. package/lib/cjs/GeometrySummary.d.ts +4 -4
  112. package/lib/cjs/GeometrySummary.js +380 -380
  113. package/lib/cjs/GeometrySummary.js.map +1 -1
  114. package/lib/cjs/HubMock.d.ts +94 -94
  115. package/lib/cjs/HubMock.js +220 -220
  116. package/lib/cjs/HubMock.js.map +1 -1
  117. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  118. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  119. package/lib/cjs/IModelCloneContext.js +15 -15
  120. package/lib/cjs/IModelCloneContext.js.map +1 -1
  121. package/lib/cjs/IModelDb.d.ts +1216 -1213
  122. package/lib/cjs/IModelDb.d.ts.map +1 -1
  123. package/lib/cjs/IModelDb.js +2387 -2380
  124. package/lib/cjs/IModelDb.js.map +1 -1
  125. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  126. package/lib/cjs/IModelElementCloneContext.js +159 -159
  127. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  128. package/lib/cjs/IModelHost.d.ts +369 -369
  129. package/lib/cjs/IModelHost.js +488 -488
  130. package/lib/cjs/IModelHost.js.map +1 -1
  131. package/lib/cjs/IModelJsFs.d.ts +62 -62
  132. package/lib/cjs/IModelJsFs.js +139 -139
  133. package/lib/cjs/IModelJsFs.js.map +1 -1
  134. package/lib/cjs/IpcHost.d.ts +104 -104
  135. package/lib/cjs/IpcHost.js +276 -276
  136. package/lib/cjs/IpcHost.js.map +1 -1
  137. package/lib/cjs/LineStyle.d.ts +311 -311
  138. package/lib/cjs/LineStyle.js +295 -295
  139. package/lib/cjs/LineStyle.js.map +1 -1
  140. package/lib/cjs/LocalHub.d.ts +162 -162
  141. package/lib/cjs/LocalHub.d.ts.map +1 -1
  142. package/lib/cjs/LocalHub.js +580 -580
  143. package/lib/cjs/LocalHub.js.map +1 -1
  144. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  145. package/lib/cjs/LocalhostIpcHost.js +79 -79
  146. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  147. package/lib/cjs/Material.d.ts +131 -131
  148. package/lib/cjs/Material.js +180 -180
  149. package/lib/cjs/Material.js.map +1 -1
  150. package/lib/cjs/Model.d.ts +392 -392
  151. package/lib/cjs/Model.js +489 -489
  152. package/lib/cjs/Model.js.map +1 -1
  153. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  154. package/lib/cjs/NativeAppStorage.js +202 -202
  155. package/lib/cjs/NativeAppStorage.js.map +1 -1
  156. package/lib/cjs/NativeHost.d.ts +52 -52
  157. package/lib/cjs/NativeHost.js +160 -160
  158. package/lib/cjs/NativeHost.js.map +1 -1
  159. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  160. package/lib/cjs/NavigationRelationship.js +225 -225
  161. package/lib/cjs/NavigationRelationship.js.map +1 -1
  162. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  163. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  164. package/lib/cjs/PromiseMemoizer.js +101 -101
  165. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  166. package/lib/cjs/PropertyStore.d.ts +132 -132
  167. package/lib/cjs/PropertyStore.js +11 -11
  168. package/lib/cjs/PropertyStore.js.map +1 -1
  169. package/lib/cjs/Relationship.d.ts +416 -416
  170. package/lib/cjs/Relationship.js +494 -494
  171. package/lib/cjs/Relationship.js.map +1 -1
  172. package/lib/cjs/RpcBackend.d.ts +5 -5
  173. package/lib/cjs/RpcBackend.js +32 -32
  174. package/lib/cjs/RpcBackend.js.map +1 -1
  175. package/lib/cjs/SQLiteDb.d.ts +219 -219
  176. package/lib/cjs/SQLiteDb.js +212 -212
  177. package/lib/cjs/SQLiteDb.js.map +1 -1
  178. package/lib/cjs/Schema.d.ts +55 -55
  179. package/lib/cjs/Schema.js +83 -83
  180. package/lib/cjs/Schema.js.map +1 -1
  181. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  182. package/lib/cjs/ServerBasedLocks.js +168 -168
  183. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  184. package/lib/cjs/SqliteStatement.d.ts +360 -360
  185. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  186. package/lib/cjs/SqliteStatement.js +586 -586
  187. package/lib/cjs/SqliteStatement.js.map +1 -1
  188. package/lib/cjs/Texture.d.ts +58 -58
  189. package/lib/cjs/Texture.js +82 -82
  190. package/lib/cjs/Texture.js.map +1 -1
  191. package/lib/cjs/TileStorage.d.ts +18 -18
  192. package/lib/cjs/TileStorage.js +87 -87
  193. package/lib/cjs/TileStorage.js.map +1 -1
  194. package/lib/cjs/TxnManager.d.ts +202 -202
  195. package/lib/cjs/TxnManager.d.ts.map +1 -1
  196. package/lib/cjs/TxnManager.js +356 -356
  197. package/lib/cjs/TxnManager.js.map +1 -1
  198. package/lib/cjs/ViewDefinition.d.ts +435 -435
  199. package/lib/cjs/ViewDefinition.js +646 -646
  200. package/lib/cjs/ViewDefinition.js.map +1 -1
  201. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  202. package/lib/cjs/ViewStateHydrator.js +103 -103
  203. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  204. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  205. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  206. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  207. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  208. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  209. package/lib/cjs/core-backend.d.ts +185 -185
  210. package/lib/cjs/core-backend.js +209 -205
  211. package/lib/cjs/core-backend.js.map +1 -1
  212. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  213. package/lib/cjs/domains/FunctionalElements.js +145 -145
  214. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  215. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  216. package/lib/cjs/domains/FunctionalSchema.js +39 -39
  217. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  218. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  219. package/lib/cjs/domains/GenericElements.js +263 -263
  220. package/lib/cjs/domains/GenericElements.js.map +1 -1
  221. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  222. package/lib/cjs/domains/GenericSchema.js +28 -28
  223. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  224. package/lib/cjs/rpc/multipart.d.ts +11 -11
  225. package/lib/cjs/rpc/multipart.js +71 -71
  226. package/lib/cjs/rpc/multipart.js.map +1 -1
  227. package/lib/cjs/rpc/tracing.d.ts +28 -28
  228. package/lib/cjs/rpc/tracing.js +73 -73
  229. package/lib/cjs/rpc/tracing.js.map +1 -1
  230. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  231. package/lib/cjs/rpc/web/logging.js +43 -43
  232. package/lib/cjs/rpc/web/logging.js.map +1 -1
  233. package/lib/cjs/rpc/web/request.d.ts +6 -6
  234. package/lib/cjs/rpc/web/request.js +73 -73
  235. package/lib/cjs/rpc/web/request.js.map +1 -1
  236. package/lib/cjs/rpc/web/response.d.ts +6 -6
  237. package/lib/cjs/rpc/web/response.js +105 -105
  238. package/lib/cjs/rpc/web/response.js.map +1 -1
  239. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  240. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  241. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  242. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  243. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -293
  244. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  245. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  246. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  247. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  248. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  249. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -166
  250. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  251. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  252. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -42
  253. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  254. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  255. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  256. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  257. package/lib/cjs/workspace/Settings.d.ts +186 -186
  258. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  259. package/lib/cjs/workspace/Settings.js +154 -154
  260. package/lib/cjs/workspace/Settings.js.map +1 -1
  261. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  262. package/lib/cjs/workspace/SettingsSchemas.js +190 -190
  263. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  264. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  265. package/lib/cjs/workspace/Workspace.js +537 -537
  266. package/lib/cjs/workspace/Workspace.js.map +1 -1
  267. package/package.json +12 -12
@@ -1,1214 +1,1217 @@
1
- /** @packageDocumentation
2
- * @module iModels
3
- */
4
- import { IModelJsNative } from "@bentley/imodeljs-native";
5
- import { AccessToken, BeEvent, DbResult, GuidString, Id64Arg, Id64Array, Id64Set, Id64String, IModelStatus, OpenMode } from "@itwin/core-bentley";
6
- import { AxisAlignedBox3d, BRepGeometryCreate, BriefcaseId, ChangesetIdWithIndex, Code, CodeProps, CodeSpec, CreateEmptySnapshotIModelProps, CreateEmptyStandaloneIModelProps, CreateSnapshotIModelProps, EcefLocation, ECSchemaProps, ECSqlReader, ElementAspectProps, ElementGeometryRequest, ElementGraphicsRequestProps, ElementLoadProps, ElementProps, EntityMetaData, EntityProps, EntityQueryParams, FilePropertyProps, FontId, FontMap, FontType, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, IModel, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelTileTreeProps, LocalFileName, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps, ModelLoadProps, ModelProps, OpenBriefcaseProps, PropertyCallback, QueryBinder, QueryOptions, SchemaState, SnapRequestProps, SnapResponseProps, SnapshotOpenOptions, SubCategoryResultRow, TextureData, TextureLoadProps, ThumbnailProps, UpgradeOptions, ViewDefinitionProps, ViewQueryParams, ViewStateLoadProps, ViewStateProps } from "@itwin/core-common";
7
- import { Range3d } from "@itwin/core-geometry";
8
- import { PullChangesArgs, PushChangesArgs } from "./BriefcaseManager";
9
- import { CheckpointProps } from "./CheckpointManager";
10
- import { MetaDataRegistry } from "./ClassRegistry";
11
- import { CloudSqlite } from "./CloudSqlite";
12
- import { CodeService } from "./CodeService";
13
- import { CodeSpecs } from "./CodeSpecs";
14
- import { ECSqlStatement } from "./ECSqlStatement";
15
- import { Element, Subject } from "./Element";
16
- import { ElementAspect } from "./ElementAspect";
17
- import { Entity, EntityClassType } from "./Entity";
18
- import { ExportGraphicsOptions, ExportPartGraphicsOptions } from "./ExportGraphics";
19
- import { Model } from "./Model";
20
- import { Relationships } from "./Relationship";
21
- import { SqliteStatement } from "./SqliteStatement";
22
- import { TxnManager } from "./TxnManager";
23
- import { ViewDefinition } from "./ViewDefinition";
24
- import { SettingDictionary } from "./workspace/Settings";
25
- import { Workspace } from "./workspace/Workspace";
26
- import { ECSchemaXmlContext } from "./ECSchemaXmlContext";
27
- import { ChannelControl } from "./ChannelControl";
28
- /** Options for [[IModelDb.Models.updateModel]]
29
- * @note To mark *only* the geometry as changed, use [[IModelDb.Models.updateGeometryGuid]] instead.
30
- * @public
31
- */
32
- export interface UpdateModelOptions extends ModelProps {
33
- /** If defined, update the last modify time of the Model */
34
- updateLastMod?: boolean;
35
- /** If defined, update the GeometryGuid of the Model */
36
- geometryChanged?: boolean;
37
- }
38
- /** Options supplied to [[IModelDb.computeProjectExtents]].
39
- * @public
40
- */
41
- export interface ComputeProjectExtentsOptions {
42
- /** If true, the result will include `extentsWithOutliers`. */
43
- reportExtentsWithOutliers?: boolean;
44
- /** If true, the result will include `outliers`. */
45
- reportOutliers?: boolean;
46
- }
47
- /** The result of [[IModelDb.computeProjectExtents]].
48
- * @public
49
- */
50
- export interface ComputedProjectExtents {
51
- /** The computed extents, excluding any outlier elements. */
52
- extents: Range3d;
53
- /** If requested by caller, the computed extents, *including* any outlier elements. */
54
- extentsWithOutliers?: Range3d;
55
- /** If requested by caller, the Ids of outlier elements excluded from the computed extents. */
56
- outliers?: Id64Array;
57
- }
58
- /**
59
- * Interface for acquiring element locks to coordinate simultaneous edits from multiple briefcases.
60
- * @beta
61
- */
62
- export interface LockControl {
63
- /**
64
- * true if this LockControl uses a server-based concurrency approach.
65
- */
66
- readonly isServerBased: boolean;
67
- /**
68
- * Close the local lock control database
69
- * @internal
70
- */
71
- close(): void;
72
- /**
73
- * Notification that a new element was just created. Called by [[Element.onInserted]]
74
- * @internal
75
- */
76
- elementWasCreated(id: Id64String): void;
77
- /**
78
- * Throw if locks are required and the exclusive lock is not held on the supplied element.
79
- * Note: there is no need to check the shared locks on parents/models since an element cannot hold the exclusive lock without first obtaining them.
80
- * Called by [[Element.onUpdate]], [[Element.onDelete]], etc.
81
- * @internal
82
- */
83
- checkExclusiveLock(id: Id64String, type: string, operation: string): void;
84
- /**
85
- * Throw if locks are required and a shared lock is not held on the supplied element.
86
- * Called by [[Element.onInsert]] to ensure shared lock is held on model and parent.
87
- * @internal
88
- */
89
- checkSharedLock(id: Id64String, type: string, operation: string): void;
90
- /**
91
- * Determine whether the supplied element currently holds the exclusive lock
92
- */
93
- holdsExclusiveLock(id: Id64String): boolean;
94
- /**
95
- * Determine whether the supplied element currently holds a shared lock
96
- */
97
- holdsSharedLock(id: Id64String): boolean;
98
- /**
99
- * Acquire locks on one or more elements from the lock server, if required and not already held.
100
- * If any required lock is not available, this method throws an exception and *none* of the requested locks are acquired.
101
- * > Note: acquiring the exclusive lock on an element requires also obtaining a shared lock on all its owner elements. This method will
102
- * attempt to acquire all necessary locks for both sets of input ids.
103
- */
104
- acquireLocks(arg: {
105
- /** if present, one or more elements to obtain shared lock */
106
- shared?: Id64Arg;
107
- /** if present, one or more elements to obtain exclusive lock */
108
- exclusive?: Id64Arg;
109
- }): Promise<void>;
110
- /**
111
- * Release all locks currently held by this Briefcase from the lock server.
112
- */
113
- releaseAllLocks(): Promise<void>;
114
- }
115
- /**
116
- * Options for the importing of schemas
117
- * @public
118
- */
119
- export interface SchemaImportOptions {
120
- /**
121
- * An [[ECSchemaXmlContext]] to use instead of building a default one.
122
- * This can be useful in rare cases where custom schema location logic is necessary
123
- * @internal
124
- */
125
- ecSchemaXmlContext?: ECSchemaXmlContext;
126
- }
127
- /** @internal */
128
- export declare enum BriefcaseLocalValue {
129
- StandaloneEdit = "StandaloneEdit",
130
- NoLocking = "NoLocking"
131
- }
132
- /** An iModel database file. The database file can either be a briefcase or a snapshot.
133
- * @see [Accessing iModels]($docs/learning/backend/AccessingIModels.md)
134
- * @see [About IModelDb]($docs/learning/backend/IModelDb.md)
135
- * @public
136
- */
137
- export declare abstract class IModelDb extends IModel {
138
- private _initialized;
139
- /** Keep track of open imodels to support `tryFind` for RPC purposes */
140
- private static readonly _openDbs;
141
- static readonly defaultLimit = 1000;
142
- static readonly maxLimit = 10000;
143
- readonly models: IModelDb.Models;
144
- readonly elements: IModelDb.Elements;
145
- readonly views: IModelDb.Views;
146
- readonly tiles: IModelDb.Tiles;
147
- /** @beta */
148
- readonly channels: ChannelControl;
149
- private _relationships?;
150
- private readonly _statementCache;
151
- private readonly _sqliteStatementCache;
152
- private _codeSpecs?;
153
- private _classMetaDataRegistry?;
154
- protected _fontMap?: FontMap;
155
- /** @internal */
156
- private _workspace?;
157
- private readonly _snaps;
158
- private static _shutdownListener;
159
- /** @internal */
160
- protected _locks?: LockControl;
161
- /** @internal */
162
- protected _codeService?: CodeService;
163
- /** @alpha */
164
- get codeService(): CodeService | undefined;
165
- /**
166
- * Get the [[LockControl]] for this iModel.
167
- * @beta
168
- */
169
- get locks(): LockControl;
170
- /**
171
- * Get the [[Workspace]] for this iModel.
172
- * @beta
173
- */
174
- get workspace(): Workspace;
175
- /** Acquire the exclusive schema lock on this iModel.
176
- * > Note: To acquire the schema lock, all other briefcases must first release *all* their locks. No other briefcases
177
- * will be able to acquire *any* locks while the schema lock is held.
178
- */
179
- acquireSchemaLock(): Promise<void>;
180
- /** determine whether the schema lock is currently held for this iModel. */
181
- get holdsSchemaLock(): boolean;
182
- /** Event called after a changeset is applied to this IModelDb. */
183
- readonly onChangesetApplied: BeEvent<() => void>;
184
- /** @internal */
185
- notifyChangesetApplied(): void;
186
- get fontMap(): FontMap;
187
- /** @internal */
188
- clearFontMap(): void;
189
- /**
190
- * Add a new font name/type to the FontMap for this iModel and return its FontId.
191
- * @param name The name of the font to add
192
- * @param type The type of the font. Default is TrueType.
193
- * @returns The FontId for the newly added font. If a font by that name/type already exists, this method does not fail, it returns the existing Id.
194
- * @see [FontId and FontMap]($docs/learning/backend/Fonts.md#fontid-and-fontmap)
195
- * @beta
196
- */
197
- addNewFont(name: string, type?: FontType): FontId;
198
- /** Check if this iModel has been opened read-only or not. */
199
- get isReadonly(): boolean;
200
- /** The Guid that identifies this iModel. */
201
- get iModelId(): GuidString;
202
- private _nativeDb?;
203
- /** @internal*/
204
- get nativeDb(): IModelJsNative.DgnDb;
205
- /** Get the full path fileName of this iModelDb
206
- * @note this member is only valid while the iModel is opened.
207
- */
208
- get pathName(): LocalFileName;
209
- /** @internal */
210
- protected constructor(args: {
211
- nativeDb: IModelJsNative.DgnDb;
212
- key: string;
213
- changeset?: ChangesetIdWithIndex;
214
- });
215
- /** Close this IModel, if it is currently open. */
216
- close(): void;
217
- /** @internal */
218
- refreshContainerSas(_userAccessToken: AccessToken): Promise<void>;
219
- /** Event called when the iModel is about to be closed. */
220
- readonly onBeforeClose: BeEvent<() => void>;
221
- /**
222
- * Called by derived classes before closing the connection
223
- * @internal
224
- */
225
- protected beforeClose(): void;
226
- /** @internal */
227
- protected initializeIModelDb(): void;
228
- /** Returns true if this is a BriefcaseDb
229
- * @see [[BriefcaseDb.open]]
230
- */
231
- get isBriefcase(): boolean;
232
- /** Type guard for instanceof [[BriefcaseDb]] */
233
- isBriefcaseDb(): this is BriefcaseDb;
234
- /** Returns true if this is a SnapshotDb
235
- * @see [[SnapshotDb.open]]
236
- */
237
- get isSnapshot(): boolean;
238
- /** Type guard for instanceof [[SnapshotDb]] */
239
- isSnapshotDb(): this is SnapshotDb;
240
- /** Returns true if this is a *standalone* iModel
241
- * @see [[StandaloneDb.open]]
242
- * @internal
243
- */
244
- get isStandalone(): boolean;
245
- /** Type guard for instanceof [[StandaloneDb]]
246
- * @internal
247
- */
248
- isStandaloneDb(): this is StandaloneDb;
249
- /** Return `true` if the underlying nativeDb is open and valid.
250
- * @internal
251
- */
252
- get isOpen(): boolean;
253
- /** Get the briefcase Id of this iModel */
254
- getBriefcaseId(): BriefcaseId;
255
- /**
256
- * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
257
- * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
258
- * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be
259
- * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
260
- * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].
261
- * @param sql The SQLite SQL statement to execute
262
- * @param callback the callback to invoke on the prepared statement
263
- * @param logErrors Determines if error will be logged if statement fail to prepare
264
- * @returns the value returned by `callback`.
265
- * @see [[withStatement]]
266
- * @public
267
- */
268
- withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
269
- /**
270
- * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.
271
- * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.
272
- * For statements that will be reused often, instead use [[withPreparedStatement]].
273
- * @param sql The SQLite SQL statement to execute
274
- * @param callback the callback to invoke on the prepared statement
275
- * @param logErrors Determines if error will be logged if statement fail to prepare
276
- * @returns the value returned by `callback`.
277
- * @see [[withPreparedStatement]]
278
- * @public
279
- */
280
- withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
281
- /** Allow to execute query and read results along with meta data. The result are streamed.
282
- * @param params The values to bind to the parameters (if the ECSQL has any).
283
- * @param config Allow to specify certain flags which control how query is executed.
284
- * @returns Returns *ECSqlQueryReader* which help iterate over result set and also give access to meta data.
285
- * @beta
286
- * */
287
- createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader;
288
- /** Execute a query and stream its results
289
- * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.
290
- * [ECSQL row]($docs/learning/ECSQLRowFormat).
291
- *
292
- * See also:
293
- * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
294
- * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
295
- *
296
- * @param ecsql The ECSQL statement to execute
297
- * @param params The values to bind to the parameters (if the ECSQL has any).
298
- * @param options Allow to specify certain flags which control how query is executed.
299
- * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
300
- * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
301
- * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
302
- */
303
- query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any>;
304
- /** Compute number of rows that would be returned by the ECSQL.
305
- *
306
- * See also:
307
- * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
308
- * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
309
- *
310
- * @param ecsql The ECSQL statement to execute
311
- * @param params The values to bind to the parameters (if the ECSQL has any).
312
- * See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
313
- * @returns Return row count.
314
- * @throws [IModelError]($common) If the statement is invalid
315
- */
316
- queryRowCount(ecsql: string, params?: QueryBinder): Promise<number>;
317
- /** Cancel any previous query with same token and run execute the current specified query.
318
- * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.
319
- * [ECSQL row]($docs/learning/ECSQLRowFormat).
320
- *
321
- * See also:
322
- * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
323
- * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
324
- *
325
- * @param ecsql The ECSQL statement to execute
326
- * @param token None empty restart token. The previous query with same token would be cancelled. This would cause
327
- * exception which user code must handle.
328
- * @param params The values to bind to the parameters (if the ECSQL has any).
329
- * @param options Allow to specify certain flags which control how query is executed.
330
- * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
331
- * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
332
- * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
333
- */
334
- restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any>;
335
- /**
336
- * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist
337
- * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
338
- * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be
339
- * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
340
- * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].
341
- * @param sql The SQLite SQL statement to execute
342
- * @param callback the callback to invoke on the prepared statement
343
- * @param logErrors Determine if errors are logged or not
344
- * @returns the value returned by `callback`.
345
- * @see [[withPreparedStatement]]
346
- * @public
347
- */
348
- withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors?: boolean): T;
349
- /**
350
- * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.
351
- * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.
352
- * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].
353
- * @param sql The SQLite SQL statement to execute
354
- * @param callback the callback to invoke on the prepared statement
355
- * @param logErrors Determine if errors are logged or not
356
- * @returns the value returned by `callback`.
357
- * @public
358
- */
359
- withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors?: boolean): T;
360
- /** Prepare an SQL statement.
361
- * @param sql The SQL statement to prepare
362
- * @throws [[IModelError]] if there is a problem preparing the statement.
363
- * @internal
364
- */
365
- prepareSqliteStatement(sql: string, logErrors?: boolean): SqliteStatement;
366
- /**
367
- * queries the BisCore.SubCategory table for the entries that are children of the passed categoryIds
368
- * @param categoryIds categoryIds to query
369
- * @returns array of SubCategoryResultRow
370
- * @internal
371
- */
372
- querySubCategories(categoryIds: Iterable<Id64String>): Promise<SubCategoryResultRow[]>;
373
- /** Query for a set of entity ids, given an EntityQueryParams
374
- * @param params The query parameters. The `limit` and `offset` members should be used to page results.
375
- * @returns an Id64Set with results of query
376
- * @throws [[IModelError]] if the generated statement is invalid or [IModelDb.maxLimit]($backend) exceeded when collecting ids.
377
- *
378
- * *Example:*
379
- * ``` ts
380
- * [[include:ECSQL-backend-queries.select-element-by-code-value-using-queryEntityIds]]
381
- * ```
382
- */
383
- queryEntityIds(params: EntityQueryParams): Id64Set;
384
- /** Clear all in-memory caches held in this IModelDb. */
385
- clearCaches(): void;
386
- /** Update the project extents for this iModel.
387
- * <p><em>Example:</em>
388
- * ``` ts
389
- * [[include:IModelDb.updateProjectExtents]]
390
- * ```
391
- */
392
- updateProjectExtents(newExtents: AxisAlignedBox3d): void;
393
- /** Compute an appropriate project extents for this iModel based on the ranges of all spatial elements.
394
- * Typically, the result is simply the union of the ranges of all spatial elements. However, the algorithm also detects "outlier elements",
395
- * whose placements locate them so far from the rest of the spatial geometry that they are considered statistically insignificant. The
396
- * range of an outlier element does not contribute to the computed extents.
397
- * @param options Specifies the level of detail desired in the return value.
398
- * @returns the computed extents.
399
- * @note This method does not modify the IModel's stored project extents. @see [[updateProjectExtents]].
400
- */
401
- computeProjectExtents(options?: ComputeProjectExtentsOptions): ComputedProjectExtents;
402
- /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel. */
403
- updateEcefLocation(ecef: EcefLocation): void;
404
- /** Update the IModelProps of this iModel in the database. */
405
- updateIModelProps(): void;
406
- /** Commit pending changes to this iModel.
407
- * @param description Optional description of the changes
408
- * @throws [[IModelError]] if there is a problem saving changes or if there are pending, un-processed lock or code requests.
409
- */
410
- saveChanges(description?: string): void;
411
- /** Abandon pending changes in this iModel. */
412
- abandonChanges(): void;
413
- /**
414
- * Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
415
- * This ensures that all changes to the database since it was opened are saved to its file and the WAL file is truncated.
416
- * @note Checkpoint automatically happens when IModelDbs are closed. However, the checkpoint
417
- * operation itself can take some time. It may be useful to call this method prior to closing so that the checkpoint "penalty" is paid earlier.
418
- * @note Another use for this function is to permit the file to be copied while it is open for write. iModel files should
419
- * rarely be copied, and even less so while they're opened. But this scenario is sometimes encountered for tests.
420
- */
421
- performCheckpoint(): void;
422
- /** @internal */
423
- reverseTxns(numOperations: number): IModelStatus;
424
- /** @internal */
425
- reinstateTxn(): IModelStatus;
426
- /** @internal */
427
- restartTxnSession(): void;
428
- /** Import an ECSchema. On success, the schema definition is stored in the iModel.
429
- * This method is asynchronous (must be awaited) because, in the case where this IModelDb is a briefcase, this method first obtains the schema lock from the iModel server.
430
- * You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
431
- * @param schemaFileName array of Full paths to ECSchema.xml files to be imported.
432
- * @param {SchemaImportOptions} options - options during schema import.
433
- * @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
434
- * @note Changes are saved if importSchemas is successful and abandoned if not successful.
435
- * @see querySchemaVersion
436
- */
437
- importSchemas(schemaFileNames: LocalFileName[], options?: SchemaImportOptions): Promise<void>;
438
- /** Import ECSchema(s) serialized to XML. On success, the schema definition is stored in the iModel.
439
- * This method is asynchronous (must be awaited) because, in the case where this IModelDb is a briefcase, this method first obtains the schema lock from the iModel server.
440
- * You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
441
- * @param serializedXmlSchemas The xml string(s) created from a serialized ECSchema.
442
- * @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
443
- * @note Changes are saved if importSchemaStrings is successful and abandoned if not successful.
444
- * @see querySchemaVersion
445
- * @alpha
446
- */
447
- importSchemaStrings(serializedXmlSchemas: string[]): Promise<void>;
448
- /** Find an opened instance of any subclass of IModelDb, by filename
449
- * @note this method returns an IModelDb if the filename is open for *any* subclass of IModelDb
450
- */
451
- static findByFilename(fileName: LocalFileName): IModelDb | undefined;
452
- /** Find an open IModelDb by its key.
453
- * @note This method is mainly for use by RPC implementations.
454
- * @throws [[IModelNotFoundResponse]] if an open IModelDb matching the key is not found.
455
- * @see [IModel.key]($common)
456
- */
457
- static findByKey(key: string): IModelDb;
458
- /** Attempt to find an open IModelDb by key.
459
- * @returns The matching IModelDb or `undefined`.
460
- */
461
- static tryFindByKey(key: string): IModelDb | undefined;
462
- /** @internal */
463
- static openDgnDb(file: {
464
- path: LocalFileName;
465
- key?: string;
466
- }, openMode: OpenMode, upgradeOptions?: UpgradeOptions, props?: SnapshotOpenOptions & CloudContainerArgs): IModelJsNative.DgnDb;
467
- /**
468
- * Determines if the schemas in the Db must or can be upgraded by comparing them with those included in the
469
- * current version of the software.
470
- * @param filePath Full name of the briefcase including path
471
- * @param forReadWrite Pass true if validating for read-write scenarios - note that the schema version requirements
472
- * for opening the DgnDb read-write is more stringent than when opening the database read-only
473
- * @throws [[IModelError]] If the Db was in an invalid state and that causes a problem with validating schemas
474
- * @see [[BriefcaseDb.upgradeSchemas]] or [[StandaloneDb.upgradeSchemas]]
475
- * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
476
- */
477
- static validateSchemas(filePath: LocalFileName, forReadWrite: boolean): SchemaState;
478
- /** Get the ClassMetaDataRegistry for this iModel.
479
- * @internal
480
- */
481
- get classMetaDataRegistry(): MetaDataRegistry;
482
- /** Get the linkTableRelationships for this IModel */
483
- get relationships(): Relationships;
484
- /** Get the CodeSpecs in this IModel. */
485
- get codeSpecs(): CodeSpecs;
486
- /** @internal */
487
- insertCodeSpec(codeSpec: CodeSpec): Id64String;
488
- /** Prepare an ECSQL statement.
489
- * @param sql The ECSQL statement to prepare
490
- * @param logErrors Determines if error will be logged if statement fail to prepare
491
- * @throws [[IModelError]] if there is a problem preparing the statement.
492
- */
493
- prepareStatement(sql: string, logErrors?: boolean): ECSqlStatement;
494
- /** Prepare an ECSQL statement.
495
- * @param sql The ECSQL statement to prepare
496
- * @returns `undefined` if there is a problem preparing the statement.
497
- */
498
- tryPrepareStatement(sql: string): ECSqlStatement | undefined;
499
- /** Construct an entity (Element or Model) from an iModel.
500
- * @throws [[IModelError]] if the entity cannot be constructed.
501
- */
502
- constructEntity<T extends Entity>(props: EntityProps): T;
503
- /** Get the JavaScript class that handles a given entity class. */
504
- getJsClass<T extends typeof Entity>(classFullName: string): T;
505
- /** Get metadata for a class. This method will load the metadata from the iModel into the cache as a side-effect, if necessary.
506
- * @throws [[IModelError]] if the metadata cannot be found nor loaded.
507
- */
508
- getMetaData(classFullName: string): EntityMetaData;
509
- /** Invoke a callback on each property of the specified class, optionally including superclass properties.
510
- * @param iModel The IModel that contains the schema
511
- * @param classFullName The full class name to load the metadata, if necessary
512
- * @param wantSuper If true, superclass properties will also be processed
513
- * @param func The callback to be invoked on each property
514
- * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
515
- * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
516
- */
517
- static forEachMetaData(iModel: IModelDb, classFullName: string, wantSuper: boolean, func: PropertyCallback, includeCustom?: boolean): void;
518
- /** @internal */
519
- private loadMetaData;
520
- /** Returns the full schema for the input name.
521
- * @param name The name of the schema e.g. 'BisCore'
522
- * @returns The SchemaProps for the requested schema
523
- * @throws if the schema can not be found or loaded.
524
- */
525
- getSchemaProps(name: string): ECSchemaProps;
526
- /** Query if this iModel contains the definition of the specified class.
527
- * @param classFullName The full name of the class, for example, SomeSchema:SomeClass
528
- * @returns true if the iModel contains the class definition or false if not.
529
- * @see querySchemaVersion
530
- * @see importSchema
531
- */
532
- containsClass(classFullName: string): boolean;
533
- /** Query for a schema of the specified name in this iModel.
534
- * @returns The schema version as a semver-compatible string or `undefined` if the schema has not been imported.
535
- */
536
- querySchemaVersion(schemaName: string): string | undefined;
537
- /** Retrieve a named texture image from this iModel, as a TextureData.
538
- * @param props the texture load properties which must include the name of the texture to load
539
- * @returns the TextureData or undefined if the texture image is not present.
540
- * @alpha
541
- */
542
- queryTextureData(props: TextureLoadProps): Promise<TextureData | undefined>;
543
- /** Query a "file property" from this iModel, as a string.
544
- * @returns the property string or undefined if the property is not present.
545
- */
546
- queryFilePropertyString(prop: FilePropertyProps): string | undefined;
547
- /** Query a "file property" from this iModel, as a blob.
548
- * @returns the property blob or undefined if the property is not present.
549
- */
550
- queryFilePropertyBlob(prop: FilePropertyProps): Uint8Array | undefined;
551
- /** Save a "file property" to this iModel
552
- * @param prop the FilePropertyProps that describes the new property
553
- * @param value either a string or a blob to save as the file property
554
- */
555
- saveFileProperty(prop: FilePropertyProps, strValue: string | undefined, blobVal?: Uint8Array): void;
556
- /** delete a "file property" from this iModel
557
- * @param prop the FilePropertyProps that describes the property
558
- */
559
- deleteFileProperty(prop: FilePropertyProps): void;
560
- /** Query for the next available major id for a "file property" from this iModel.
561
- * @param prop the FilePropertyProps that describes the property
562
- * @returns the next available (that is, an unused) id for prop. If none are present, will return 0.
563
- */
564
- queryNextAvailableFileProperty(prop: FilePropertyProps): number;
565
- /** @internal */
566
- requestSnap(sessionId: string, props: SnapRequestProps): Promise<SnapResponseProps>;
567
- /** Cancel a previously requested snap.
568
- * @internal
569
- */
570
- cancelSnap(sessionId: string): void;
571
- /** Get the clip containment status for the supplied elements. */
572
- getGeometryContainment(props: GeometryContainmentRequestProps): Promise<GeometryContainmentResponseProps>;
573
- /** Get the mass properties for the supplied elements. */
574
- getMassProperties(props: MassPropertiesRequestProps): Promise<MassPropertiesResponseProps>;
575
- /** Get the IModel coordinate corresponding to each GeoCoordinate point in the input */
576
- getIModelCoordinatesFromGeoCoordinates(props: IModelCoordinatesRequestProps): Promise<IModelCoordinatesResponseProps>;
577
- /** Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input */
578
- getGeoCoordinatesFromIModelCoordinates(props: GeoCoordinatesRequestProps): Promise<GeoCoordinatesResponseProps>;
579
- /** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
580
- * * Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend,
581
- * or that shared backends export a limited number of elements at a time.
582
- * * Vertices are exported in the IModelDb's world coordinate system, which is right-handed with Z pointing up.
583
- * * The results of changing [ExportGraphicsOptions]($core-backend) during the [ExportGraphicsOptions.onGraphics]($core-backend) callback are not defined.
584
- *
585
- * Example that prints the mesh for element 1 to stdout in [OBJ format](https://en.wikipedia.org/wiki/Wavefront_.obj_file)
586
- * ```ts
587
- * const onGraphics: ExportGraphicsFunction = (info: ExportGraphicsInfo) => {
588
- * const mesh: ExportGraphicsMesh = info.mesh;
589
- * for (let i = 0; i < mesh.points.length; i += 3) {
590
- * process.stdout.write(`v ${mesh.points[i]} ${mesh.points[i + 1]} ${mesh.points[i + 2]}\n`);
591
- * process.stdout.write(`vn ${mesh.normals[i]} ${mesh.normals[i + 1]} ${mesh.normals[i + 2]}\n`);
592
- * }
593
- *
594
- * for (let i = 0; i < mesh.params.length; i += 2) {
595
- * process.stdout.write(`vt ${mesh.params[i]} ${mesh.params[i + 1]}\n`);
596
- * }
597
- *
598
- * for (let i = 0; i < mesh.indices.length; i += 3) {
599
- * const p1 = mesh.indices[i];
600
- * const p2 = mesh.indices[i + 1];
601
- * const p3 = mesh.indices[i + 2];
602
- * process.stdout.write(`f ${p1}/${p1}/${p1} ${p2}/${p2}/${p2} ${p3}/${p3}/${p3}\n`);
603
- * }
604
- * };
605
- *
606
- * iModel.exportGraphics(({ onGraphics, elementIdArray: ["0x1"] }));
607
- * ```
608
- * @returns 0 if successful, status otherwise
609
- * @public
610
- */
611
- exportGraphics(exportProps: ExportGraphicsOptions): DbResult;
612
- /**
613
- * Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
614
- * in this IModelDb.
615
- * The expected use case is to call [IModelDb.exportGraphics]($core-backend) and supply the
616
- * optional partInstanceArray argument, then call this function for each unique GeometryPart from
617
- * that list.
618
- * * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
619
- * [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
620
- * * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
621
- * @returns 0 is successful, status otherwise
622
- * @public
623
- */
624
- exportPartGraphics(exportProps: ExportPartGraphicsOptions): DbResult;
625
- /** Request geometry stream information from an element in binary format instead of json.
626
- * @returns IModelStatus.Success if successful
627
- * @alpha
628
- */
629
- elementGeometryRequest(requestProps: ElementGeometryRequest): IModelStatus;
630
- /** Create brep geometry for inclusion in an element's geometry stream.
631
- * @returns IModelStatus.Success if successful
632
- * @throws [[IModelError]] to report issues with input geometry or parameters
633
- * @alpha
634
- */
635
- createBRepGeometry(createProps: BRepGeometryCreate): IModelStatus;
636
- /** Generate graphics for an element or geometry stream.
637
- * @see [readElementGraphics]($frontend) to convert the result to a [RenderGraphic]($frontend) for display.
638
- */
639
- generateElementGraphics(request: ElementGraphicsRequestProps): Promise<Uint8Array | undefined>;
640
- private static _settingPropNamespace;
641
- /** Save a `SettingDictionary` in this iModel that will be loaded into [[workspace.settings]] every time this iModel is opened in future sessions.
642
- * @param name The name for the SettingDictionary. If a dictionary by that name already exists in the iModel, its value is replaced.
643
- * @param dict The SettingDictionary object to stringify and save.
644
- * @note All saved `SettingDictionary`s are loaded into [[workspace.settings]] every time an iModel is opened.
645
- * @beta
646
- */
647
- saveSettingDictionary(name: string, dict: SettingDictionary): void;
648
- /** Delete a SettingDictionary, previously added with [[saveSettingDictionary]], from this iModel.
649
- * @param name The name of the dictionary to delete.
650
- * @beta
651
- */
652
- deleteSettingDictionary(name: string): void;
653
- /** Load all setting dictionaries in this iModel into `this.workspace.settings` */
654
- private loadSettingDictionaries;
655
- }
656
- /** @public */
657
- export declare namespace IModelDb {
658
- /** The collection of models in an [[IModelDb]].
659
- * @public
660
- */
661
- class Models {
662
- private _iModel;
663
- /** @internal */
664
- constructor(_iModel: IModelDb);
665
- /** Get the ModelProps with the specified identifier.
666
- * @param modelId The Model identifier.
667
- * @throws [[IModelError]] if the model is not found or cannot be loaded.
668
- * @see tryGetModelProps
669
- */
670
- getModelProps<T extends ModelProps>(id: Id64String): T;
671
- /** Get the ModelProps with the specified identifier.
672
- * @param modelId The Model identifier.
673
- * @returns The ModelProps or `undefined` if the model is not found.
674
- * @throws [[IModelError]] if the model cannot be loaded.
675
- * @note Useful for cases when a model may or may not exist and throwing an `Error` would be overkill.
676
- * @see getModelProps
677
- */
678
- tryGetModelProps<T extends ModelProps>(id: Id64String): T | undefined;
679
- /** Query for the last modified time of the specified Model.
680
- * @internal
681
- */
682
- queryLastModifiedTime(modelId: Id64String): string;
683
- /** Get the Model with the specified identifier.
684
- * @param modelId The Model identifier.
685
- * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
686
- * @throws [[IModelError]] if the model is not found, cannot be loaded, or fails validation when `modelClass` is specified.
687
- * @see tryGetModel
688
- */
689
- getModel<T extends Model>(modelId: Id64String, modelClass?: EntityClassType<Model>): T;
690
- /** Get the Model with the specified identifier.
691
- * @param modelId The Model identifier.
692
- * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
693
- * @returns The Model or `undefined` if the model is not found or fails validation when `modelClass` is specified.
694
- * @throws [[IModelError]] if the model cannot be loaded.
695
- * @note Useful for cases when a model may or may not exist and throwing an `Error` would be overkill.
696
- * @see getModel
697
- */
698
- tryGetModel<T extends Model>(modelId: Id64String, modelClass?: EntityClassType<Model>): T | undefined;
699
- /** Read the properties for a Model as a json string.
700
- * @param modelIdArg a json string with the identity of the model to load. Must have either "id" or "code".
701
- * @returns a json string with the properties of the model.
702
- * @throws [[IModelError]] if the model is not found or cannot be loaded.
703
- * @see tryGetModelJson
704
- * @internal
705
- */
706
- getModelJson<T extends ModelProps>(modelIdArg: ModelLoadProps): T;
707
- /** Read the properties for a Model as a json string.
708
- * @param modelIdArg a json string with the identity of the model to load. Must have either "id" or "code".
709
- * @returns a json string with the properties of the model or `undefined` if the model is not found.
710
- * @see getModelJson
711
- */
712
- private tryGetModelJson;
713
- /** Get the sub-model of the specified Element.
714
- * See [[IModelDb.Elements.queryElementIdByCode]] for more on how to find an element by Code.
715
- * @param modeledElementId Identifies the modeled element.
716
- * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
717
- * @throws [[IModelError]] if the sub-model is not found, cannot be loaded, or fails validation when `modelClass` is specified.
718
- * @see tryGetSubModel
719
- */
720
- getSubModel<T extends Model>(modeledElementId: Id64String | GuidString | Code, modelClass?: EntityClassType<Model>): T;
721
- /** Get the sub-model of the specified Element.
722
- * See [[IModelDb.Elements.queryElementIdByCode]] for more on how to find an element by Code.
723
- * @param modeledElementId Identifies the modeled element.
724
- * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
725
- * @returns The sub-model or `undefined` if the specified element does not have a sub-model or fails validation when `modelClass` is specified.
726
- * @see getSubModel
727
- */
728
- tryGetSubModel<T extends Model>(modeledElementId: Id64String | GuidString | Code, modelClass?: EntityClassType<Model>): T | undefined;
729
- /** Create a new model in memory.
730
- * See the example in [[InformationPartitionElement]].
731
- * @param modelProps The properties to use when creating the model.
732
- * @throws [[IModelError]] if there is a problem creating the model.
733
- */
734
- createModel<T extends Model>(modelProps: ModelProps): T;
735
- /** Insert a new model.
736
- * @param props The data for the new model.
737
- * @returns The newly inserted model's Id.
738
- * @throws [[IModelError]] if unable to insert the model.
739
- */
740
- insertModel(props: ModelProps): Id64String;
741
- /** Update an existing model.
742
- * @param props the properties of the model to change
743
- * @throws [[IModelError]] if unable to update the model.
744
- */
745
- updateModel(props: UpdateModelOptions): void;
746
- /** Mark the geometry of [[GeometricModel]] as having changed, by recording an indirect change to its GeometryGuid property.
747
- * Typically the GeometryGuid changes automatically when [[GeometricElement]]s within the model are modified, but
748
- * explicitly updating it is occasionally useful after modifying definition elements like line styles or materials that indirectly affect the appearance of
749
- * [[GeometricElement]]s that reference those definition elements in their geometry streams.
750
- * Cached [Tile]($frontend)s are only invalidated after the geometry guid of the model changes.
751
- * @note This will throw IModelError with [IModelStatus.VersionTooOld]($core-bentley) if a version of the BisCore schema older than 1.0.11 is present in the iModel.
752
- * @throws IModelError if unable to update the geometry guid.
753
- * @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
754
- */
755
- updateGeometryGuid(modelId: Id64String): void;
756
- /** Delete one or more existing models.
757
- * @param ids The Ids of the models to be deleted
758
- * @throws [[IModelError]]
759
- */
760
- deleteModel(ids: Id64Arg): void;
761
- /** For each specified [[GeometricModel]], attempts to obtain the union of the volumes of all geometric elements within that model.
762
- * @param ids The Id or Ids of the [[GeometricModel]]s for which to obtain the extents.
763
- * @returns An array of results, one per supplied Id, in the order in which the Ids were supplied. If the extents could not be obtained, the
764
- * corresponding results entry's `extents` will be a "null" range (@see [Range3d.isNull]($geometry)) and its `status` will indicate
765
- * why the extents could not be obtained (e.g., because the Id did not identify a [[GeometricModel]]).
766
- * @see [[queryRange]] to obtain the union of all of the models' extents.
767
- */
768
- queryExtents(ids: Id64String | Id64String[]): Promise<ModelExtentsProps[]>;
769
- /** Computes the union of the volumes of all geoemtric elements within any number of [[GeometricModel]]s, specified by model Id.
770
- * @see [[queryExtents]] to obtain discrete volumes for each model.
771
- */
772
- queryRange(ids: Id64String | Id64String[]): Promise<AxisAlignedBox3d>;
773
- }
774
- /** The collection of elements in an [[IModelDb]].
775
- * @public
776
- */
777
- class Elements {
778
- private _iModel;
779
- /** @internal */
780
- constructor(_iModel: IModelDb);
781
- /** Read element data from the iModel as JSON
782
- * @param elementIdArg a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
783
- * @returns The JSON properties of the element.
784
- * @throws [[IModelError]] if the element is not found or cannot be loaded.
785
- * @see tryGetElementJson
786
- * @internal
787
- */
788
- getElementJson<T extends ElementProps>(elementId: ElementLoadProps): T;
789
- /** Read element data from the iModel as JSON
790
- * @param loadProps - a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
791
- * @returns The JSON properties of the element or `undefined` if the element is not found.
792
- * @throws [[IModelError]] if the element exists, but cannot be loaded.
793
- * @see getElementJson
794
- */
795
- private tryGetElementJson;
796
- /** Get properties of an Element by Id, FederationGuid, or Code
797
- * @throws [[IModelError]] if the element is not found or cannot be loaded.
798
- * @see tryGetElementProps
799
- */
800
- getElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): T;
801
- /** Get properties of an Element by Id, FederationGuid, or Code
802
- * @returns The properties of the element or `undefined` if the element is not found.
803
- * @throws [[IModelError]] if the element exists, but cannot be loaded.
804
- * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
805
- * @see getElementProps
806
- */
807
- tryGetElementProps<T extends ElementProps>(elementId: Id64String | GuidString | Code | ElementLoadProps): T | undefined;
808
- /** Get an element by Id, FederationGuid, or Code
809
- * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
810
- * @param elementClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
811
- * @throws [[IModelError]] if the element is not found, cannot be loaded, or fails validation when `elementClass` is specified.
812
- * @see tryGetElement
813
- */
814
- getElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T;
815
- /** Get an element by Id, FederationGuid, or Code
816
- * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
817
- * @param elementClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
818
- * @returns The element or `undefined` if the element is not found or fails validation when `elementClass` is specified.
819
- * @throws [[IModelError]] if the element exists, but cannot be loaded.
820
- * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
821
- * @see getElement
822
- */
823
- tryGetElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T | undefined;
824
- /** Query for the Id of the element that has a specified code.
825
- * This method is for the case where you know the element's Code.
826
- * If you only know the code *value*, then in the simplest case, you can query on that
827
- * and filter the results.
828
- * In the simple case, call [[IModelDb.queryEntityIds]], specifying the code value in the where clause of the query params.
829
- * Or, you can execute an ECSQL select statement. See
830
- * [frequently used ECSQL queries]($docs/learning/backend/ECSQL-queries.md) for an example.
831
- * @param code The code to look for
832
- * @returns The element that uses the code or undefined if the code is not used.
833
- * @throws IModelError if the code is invalid
834
- */
835
- queryElementIdByCode(code: Required<CodeProps>): Id64String | undefined;
836
- /** Query for the last modified time of the specified element.
837
- * @internal
838
- */
839
- queryLastModifiedTime(elementId: Id64String): string;
840
- /** Create a new instance of an element.
841
- * @param elProps The properties of the new element.
842
- * @throws [[IModelError]] if there is a problem creating the element.
843
- */
844
- createElement<T extends Element>(elProps: ElementProps): T;
845
- /** Insert a new element into the iModel.
846
- * @param elProps The properties of the new element.
847
- * @returns The newly inserted element's Id.
848
- * @throws [[IModelError]] if unable to insert the element.
849
- * @note For convenience, the value of `elProps.id` is updated to reflect the resultant element's id.
850
- * However when `elProps.federationGuid` is not present or undefined, a new Guid will be generated and stored on the resultant element. But
851
- * the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
852
- * if you intend to continue working with it. That will ensure its values reflect the persistent state.
853
- */
854
- insertElement(elProps: ElementProps): Id64String;
855
- /** Update some properties of an existing element.
856
- * To support clearing a property value, every property name that is present in the `elProps` object will be updated even if the value is `undefined`.
857
- * To keep an individual element property unchanged, it should either be excluded from the `elProps` parameter or set to its current value.
858
- * @param elProps the properties of the element to update.
859
- * @note As described above, this is a special case where there is a difference between a property being excluded and a property being present in `elProps` but set to `undefined`.
860
- * @throws [[IModelError]] if unable to update the element.
861
- */
862
- updateElement(elProps: ElementProps): void;
863
- /** Delete one or more elements from this iModel.
864
- * @param ids The set of Ids of the element(s) to be deleted
865
- * @throws [[IModelError]]
866
- * @see deleteDefinitionElements
867
- */
868
- deleteElement(ids: Id64Arg): void;
869
- /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
870
- * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
871
- * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
872
- * This method performs those expensive checks and then calls *delete* if not referenced.
873
- * @param ids The Ids of the DefinitionElements to attempt to delete. To prevent multiple passes over the same GeometricElements, it is best to pass in the entire array of
874
- * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
875
- * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
876
- * @see deleteElement
877
- * @beta
878
- */
879
- deleteDefinitionElements(definitionElementIds: Id64Array): Id64Set;
880
- /** Query for the child elements of the specified element.
881
- * @returns Returns an array of child element identifiers.
882
- * @throws [[IModelError]]
883
- */
884
- queryChildren(elementId: Id64String): Id64String[];
885
- /** Query for the parent of the specified element.
886
- * @param elementId The element to check for a parent
887
- * @returns The identifier of the element's parent or undefined if the element has no parent
888
- * @throws [[IModelError]] if the element does not exist
889
- */
890
- queryParent(elementId: Id64String): Id64String | undefined;
891
- /** Returns true if the specified Element has a sub-model.
892
- * @see [[IModelDb.Models.getSubModel]]
893
- */
894
- hasSubModel(elementId: Id64String): boolean;
895
- /** Get the root subject element. */
896
- getRootSubject(): Subject;
897
- /** Query for aspects of a particular class (polymorphically) associated with this element.
898
- * @throws [[IModelError]]
899
- * @note Most cases should use the [[getAspects]] wrapper rather than calling this method directly.
900
- * @internal
901
- */
902
- _queryAspects(elementId: Id64String, fromClassFullName: string, excludedClassFullNames?: Set<string>): ElementAspect[];
903
- /** Query for aspect by ECInstanceId
904
- * @throws [[IModelError]]
905
- */
906
- private _queryAspect;
907
- /** Get a single ElementAspect by its instance Id.
908
- * @throws [[IModelError]]
909
- */
910
- getAspect(aspectInstanceId: Id64String): ElementAspect;
911
- /** Get the ElementAspect instances that are owned by the specified element.
912
- * @param elementId Get ElementAspects associated with this Element
913
- * @param aspectClassFullName Optionally filter ElementAspects polymorphically by this class name
914
- * @throws [[IModelError]]
915
- */
916
- getAspects(elementId: Id64String, aspectClassFullName?: string): ElementAspect[];
917
- /** Insert a new ElementAspect into the iModel.
918
- * @param aspectProps The properties of the new ElementAspect.
919
- * @throws [[IModelError]] if unable to insert the ElementAspect.
920
- * @returns the id of the newly inserted aspect.
921
- * @note Aspect Ids may collide with element Ids, so don't put both in a container like Set or Map
922
- * use [EntityReference]($common) for that instead.
923
- */
924
- insertAspect(aspectProps: ElementAspectProps): Id64String;
925
- /** Update an exist ElementAspect within the iModel.
926
- * @param aspectProps The properties to use to update the ElementAspect.
927
- * @throws [[IModelError]] if unable to update the ElementAspect.
928
- */
929
- updateAspect(aspectProps: ElementAspectProps): void;
930
- /** Delete one or more ElementAspects from this iModel.
931
- * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
932
- * @throws [[IModelError]] if unable to delete the ElementAspect.
933
- */
934
- deleteAspect(aspectInstanceIds: Id64Arg): void;
935
- }
936
- /** The collection of views in an [[IModelDb]].
937
- * @public
938
- */
939
- class Views {
940
- private _iModel;
941
- /** @internal */
942
- constructor(_iModel: IModelDb);
943
- /** Query for the array of ViewDefinitionProps of the specified class and matching the specified IsPrivate setting.
944
- * @param className Query for view definitions of this class.
945
- * @param wantPrivate If true, include private view definitions.
946
- */
947
- queryViewDefinitionProps(className?: string, limit?: number, offset?: number, wantPrivate?: boolean): ViewDefinitionProps[];
948
- /** Default parameters for iterating/querying ViewDefinitions. Includes all subclasses of ViewDefinition, excluding only those marked 'private'. */
949
- static readonly defaultQueryParams: ViewQueryParams;
950
- /** Iterate all ViewDefinitions matching the supplied query.
951
- * @param params Specifies the query by which views are selected.
952
- * @param callback Function invoked for each ViewDefinition matching the query. Return false to terminate iteration, true to continue.
953
- * @returns true if all views were iterated, false if iteration was terminated early due to callback returning false.
954
- *
955
- * **Example: Finding all views of a specific DrawingModel**
956
- * ``` ts
957
- * [[include:IModelDb.Views.iterateViews]]
958
- * ```
959
- */
960
- iterateViews(params: ViewQueryParams, callback: (view: ViewDefinition) => boolean): boolean;
961
- private loadViewStateProps;
962
- /** @deprecated in 3.x. use [[getViewStateProps]]. */
963
- getViewStateData(viewDefinitionId: string, options?: ViewStateLoadProps): ViewStateProps;
964
- /** Obtain a [ViewStateProps]($common) for a [[ViewDefinition]] specified by element Id. */
965
- getViewStateProps(viewDefinitionId: string, options?: ViewStateLoadProps): Promise<ViewStateProps>;
966
- private getViewThumbnailArg;
967
- /** Get the thumbnail for a view.
968
- * @param viewDefinitionId The Id of the view for thumbnail
969
- * @returns the ThumbnailProps, or undefined if no thumbnail exists.
970
- */
971
- getThumbnail(viewDefinitionId: Id64String): ThumbnailProps | undefined;
972
- /** Save a thumbnail for a view.
973
- * @param viewDefinitionId The Id of the view for thumbnail
974
- * @param thumbnail The thumbnail data.
975
- * @returns 0 if successful
976
- */
977
- saveThumbnail(viewDefinitionId: Id64String, thumbnail: ThumbnailProps): number;
978
- /** Set the default view property the iModel
979
- * @param viewId The Id of the ViewDefinition to use as the default
980
- */
981
- setDefaultViewId(viewId: Id64String): void;
982
- }
983
- /** Represents the current state of a pollable tile content request.
984
- * Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
985
- * @internal
986
- */
987
- enum TileContentState {
988
- New = 0,
989
- Pending = 1,
990
- Loading = 2
991
- }
992
- /** @internal */
993
- class Tiles {
994
- private _iModel;
995
- /** @internal */
996
- constructor(_iModel: IModelDb);
997
- /** @internal */
998
- requestTileTreeProps(id: string): Promise<IModelTileTreeProps>;
999
- private pollTileContent;
1000
- /** @internal */
1001
- requestTileContent(treeId: string, tileId: string): Promise<IModelJsNative.TileContent>;
1002
- /** @internal */
1003
- getTileContent(treeId: string, tileId: string): Promise<Uint8Array>;
1004
- }
1005
- }
1006
- /**
1007
- * Argument to a function that can accept a valid access token.
1008
- * @public
1009
- */
1010
- export interface TokenArg {
1011
- /** If present, the access token for the requested operation. If not present, use [[IModelHost.getAccessToken]] */
1012
- readonly accessToken?: AccessToken;
1013
- }
1014
- /** Augments a [[SnapshotDbOpenArgs]] or [[OpenBriefcaseArgs]] with a [CloudContainer]($docs/learning/backend/Workspace.md).
1015
- * The properties are this interface are reserved for internal use only.
1016
- * @public
1017
- */
1018
- export interface CloudContainerArgs {
1019
- /** @internal */
1020
- container?: CloudSqlite.CloudContainer;
1021
- }
1022
- /** Options to open a [SnapshotDb]($backend).
1023
- * @public
1024
- */
1025
- export declare type SnapshotDbOpenArgs = SnapshotOpenOptions & CloudContainerArgs;
1026
- /**
1027
- * Arguments to open a BriefcaseDb
1028
- * @public
1029
- */
1030
- export declare type OpenBriefcaseArgs = OpenBriefcaseProps & CloudContainerArgs;
1031
- /**
1032
- * A local copy of an iModel from iModelHub that can pull and potentially push changesets.
1033
- * BriefcaseDb raises a set of events to allow apps and subsystems to track its object life cycle, including [[onOpen]] and [[onOpened]].
1034
- * @public
1035
- */
1036
- export declare class BriefcaseDb extends IModelDb {
1037
- /** Manages local changes to this briefcase. */
1038
- readonly txns: TxnManager;
1039
- /** override superclass method */
1040
- get isBriefcase(): boolean;
1041
- readonly briefcaseId: BriefcaseId;
1042
- /**
1043
- * Event raised just before a BriefcaseDb is opened. Supplies the arguments that will be used to open the BriefcaseDb.
1044
- * Throw an exception to stop the open.
1045
- *
1046
- * **Example:**
1047
- * ``` ts
1048
- * [[include:BriefcaseDb.onOpen]]
1049
- * ```
1050
- */
1051
- static readonly onOpen: BeEvent<(_args: OpenBriefcaseArgs) => void>;
1052
- /**
1053
- * Event raised just after a BriefcaseDb is opened. Supplies the newly opened BriefcaseDb and the arguments that were used to open it.
1054
- *
1055
- * **Example:**
1056
- * ``` ts
1057
- * [[include:BriefcaseDb.onOpened]]
1058
- * ```
1059
- */
1060
- static readonly onOpened: BeEvent<(_iModelDb: BriefcaseDb, _args: OpenBriefcaseArgs) => void>;
1061
- /** @alpha */
1062
- static readonly onCodeServiceCreated: BeEvent<(service: CodeService) => void>;
1063
- static findByKey(key: string): BriefcaseDb;
1064
- static tryFindByKey(key: string): BriefcaseDb | undefined;
1065
- /**
1066
- * The Guid that identifies the *context* that owns this iModel.
1067
- * GuidString | undefined for the superclass, but required for BriefcaseDb
1068
- * */
1069
- get iTwinId(): GuidString;
1070
- /**
1071
- * Determine whether this BriefcaseDb should use a lock server.
1072
- * All must be true:
1073
- * - file is open for write
1074
- * - has an assigned briefcaseId
1075
- * - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
1076
- */
1077
- protected get useLockServer(): boolean;
1078
- protected constructor(args: {
1079
- nativeDb: IModelJsNative.DgnDb;
1080
- key: string;
1081
- openMode: OpenMode;
1082
- briefcaseId: number;
1083
- });
1084
- /** Upgrades the profile or domain schemas. File must be closed before this call and is always left closed. */
1085
- private static doUpgrade;
1086
- /** Upgrades the schemas in the iModel based on the current version of the software. Follows a sequence of operations -
1087
- * * Acquires a schema lock to prevent other users from making any other changes while upgrade is happening
1088
- * * Updates the local briefcase with the schema changes.
1089
- * * Pushes the resulting changeset(s) to iModelHub.
1090
- * Note that the upgrade requires that the local briefcase be closed, and may result in one or two change sets depending on whether both
1091
- * profile and domain schemas need to get upgraded.
1092
- * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1093
- */
1094
- static upgradeSchemas(briefcase: OpenBriefcaseArgs): Promise<void>;
1095
- /** Open a briefcase file and return a new BriefcaseDb to interact with it.
1096
- * @param args parameters that specify the file name, and options for opening the briefcase file
1097
- */
1098
- static open(args: OpenBriefcaseArgs): Promise<BriefcaseDb>;
1099
- private closeAndReopen;
1100
- /** Pull and apply changesets from iModelHub */
1101
- pullChanges(arg?: PullChangesArgs): Promise<void>;
1102
- /** Push changes to iModelHub. */
1103
- pushChanges(arg: PushChangesArgs): Promise<void>;
1104
- }
1105
- /** A *snapshot* iModel database file that is used for archival and data transfer purposes.
1106
- * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1107
- * @see [About IModelDb]($docs/learning/backend/IModelDb.md)
1108
- * @public
1109
- */
1110
- export declare class SnapshotDb extends IModelDb {
1111
- get isSnapshot(): boolean;
1112
- private _refreshSas;
1113
- private _createClassViewsOnClose?;
1114
- private constructor();
1115
- static findByKey(key: string): SnapshotDb;
1116
- static tryFindByKey(key: string): SnapshotDb | undefined;
1117
- /** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
1118
- * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1119
- * > Note: A *snapshot* cannot be modified after [[close]] is called.
1120
- * @param filePath The file that will contain the new iModel *snapshot*
1121
- * @param options The parameters that define the new iModel *snapshot*
1122
- * @returns A writeable SnapshotDb
1123
- * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1124
- */
1125
- static createEmpty(filePath: LocalFileName, options: CreateEmptySnapshotIModelProps): SnapshotDb;
1126
- /** Create a local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file, using this iModel as a *seed* or starting point.
1127
- * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1128
- * > Note: A *snapshot* cannot be modified after [[close]] is called.
1129
- * @param iModelDb The snapshot will be initialized from the current contents of this iModelDb
1130
- * @param snapshotFile The file that will contain the new iModel *snapshot*
1131
- * @param options Optional properties that determine how the snapshot iModel is created.
1132
- * @returns A writeable SnapshotDb
1133
- * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1134
- */
1135
- static createFrom(iModelDb: IModelDb, snapshotFile: string, options?: CreateSnapshotIModelProps): SnapshotDb;
1136
- /** open this SnapshotDb read/write, strictly to apply incoming changesets. Used for creating new checkpoints.
1137
- * @internal
1138
- */
1139
- static openForApplyChangesets(path: LocalFileName, props?: SnapshotDbOpenArgs): SnapshotDb;
1140
- /** Open a read-only iModel *snapshot*.
1141
- * @param path the full path of the snapshot iModel file to open.
1142
- * @param props options for opening snapshot
1143
- * @see [[close]]
1144
- * @throws [[IModelError]] If the file is not found or is not a valid *snapshot*.
1145
- */
1146
- static openFile(path: LocalFileName, opts?: SnapshotDbOpenArgs): SnapshotDb;
1147
- /** Open a previously downloaded V1 checkpoint file.
1148
- * @note The key is generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1149
- * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1150
- * servicing the same checkpoint.
1151
- * @internal
1152
- */
1153
- static openCheckpointV1(fileName: LocalFileName, checkpoint: CheckpointProps): SnapshotDb;
1154
- /** Open a V2 *checkpoint*, a special form of snapshot iModel that represents a read-only snapshot of an iModel from iModelHub at a particular point in time.
1155
- * > Note: The checkpoint daemon must already be running and a checkpoint must already exist in iModelHub's storage *before* this function is called.
1156
- * @param checkpoint The checkpoint to open
1157
- * @note The key generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1158
- * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1159
- * servicing the same checkpoint.
1160
- * @throws [[IModelError]] If the checkpoint is not found in iModelHub or the checkpoint daemon is not supported in the current environment.
1161
- * @internal
1162
- */
1163
- static openCheckpointV2(checkpoint: CheckpointProps): Promise<SnapshotDb>;
1164
- /** Used to refresh the container sasToken using the current user's accessToken
1165
- * @internal
1166
- */
1167
- refreshContainerSas(userAccessToken: AccessToken): Promise<void>;
1168
- /** @internal */
1169
- beforeClose(): void;
1170
- }
1171
- /**
1172
- * Standalone iModels are read/write files that are not associated with an iTwin or managed by iModelHub.
1173
- * They are relevant only for testing, or for small-scale single-user scenarios.
1174
- * Standalone iModels are designed such that the API for Standalone iModels and Briefcase
1175
- * iModels (those synchronized with iModelHub) are as similar and consistent as possible.
1176
- * This leads to a straightforward process where the a user starts with StandaloneDb and can
1177
- * optionally choose to upgrade to an iTwin.
1178
- *
1179
- * Some additional details. Standalone iModels:
1180
- * - always have [Guid.empty]($bentley) for their iTwinId (they are "unassociated" files)
1181
- * - always have BriefcaseId === [BriefcaseIdValue.Unassigned]($common)
1182
- * - are connected to the frontend via [BriefcaseConnection.openStandalone]($frontend)
1183
- * - may be opened without supplying any user credentials
1184
- * - may be opened read/write
1185
- * - cannot apply a changeset to nor generate a changesets (since there is no timeline from which to get/push changesets)
1186
- * @public
1187
- */
1188
- export declare class StandaloneDb extends BriefcaseDb {
1189
- get isStandalone(): boolean;
1190
- protected get useLockServer(): boolean;
1191
- static findByKey(key: string): StandaloneDb;
1192
- static tryFindByKey(key: string): StandaloneDb | undefined;
1193
- /** Create an *empty* standalone iModel.
1194
- * @param filePath The file path for the iModel
1195
- * @param args The parameters that define the new iModel
1196
- */
1197
- static createEmpty(filePath: LocalFileName, args: CreateEmptyStandaloneIModelProps): StandaloneDb;
1198
- /**
1199
- * Upgrades the schemas in the standalone iModel file.
1200
- * Note that the upgrade requires that the file be closed, and will leave it back in the closed state.
1201
- * @param filePath Full path name of the standalone iModel file.
1202
- * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1203
- * @see [[StandaloneDb.validateSchemas]]
1204
- */
1205
- static upgradeStandaloneSchemas(filePath: LocalFileName): void;
1206
- /** Open a standalone iModel file.
1207
- * @param filePath The path of the standalone iModel file.
1208
- * @param openMode Optional open mode for the standalone iModel. The default is read/write.
1209
- * @throws [[IModelError]] if the file is not a standalone iModel.
1210
- * @see [BriefcaseConnection.openStandalone]($frontend) to open a StandaloneDb from the frontend
1211
- */
1212
- static openFile(filePath: LocalFileName, openMode?: OpenMode, options?: SnapshotDbOpenArgs): StandaloneDb;
1213
- }
1
+ /** @packageDocumentation
2
+ * @module iModels
3
+ */
4
+ import { IModelJsNative } from "@bentley/imodeljs-native";
5
+ import { AccessToken, BeEvent, DbResult, GuidString, Id64Arg, Id64Array, Id64Set, Id64String, IModelStatus, OpenMode } from "@itwin/core-bentley";
6
+ import { AxisAlignedBox3d, BRepGeometryCreate, BriefcaseId, ChangesetIdWithIndex, Code, CodeProps, CodeSpec, CreateEmptySnapshotIModelProps, CreateEmptyStandaloneIModelProps, CreateSnapshotIModelProps, EcefLocation, ECSchemaProps, ECSqlReader, ElementAspectProps, ElementGeometryRequest, ElementGraphicsRequestProps, ElementLoadProps, ElementProps, EntityMetaData, EntityProps, EntityQueryParams, FilePropertyProps, FontId, FontMap, FontType, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, IModel, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelTileTreeProps, LocalFileName, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps, ModelLoadProps, ModelProps, OpenBriefcaseProps, PropertyCallback, QueryBinder, QueryOptions, SchemaState, SnapRequestProps, SnapResponseProps, SnapshotOpenOptions, SubCategoryResultRow, TextureData, TextureLoadProps, ThumbnailProps, UpgradeOptions, ViewDefinitionProps, ViewQueryParams, ViewStateLoadProps, ViewStateProps } from "@itwin/core-common";
7
+ import { Range3d } from "@itwin/core-geometry";
8
+ import { PullChangesArgs, PushChangesArgs } from "./BriefcaseManager";
9
+ import { CheckpointProps } from "./CheckpointManager";
10
+ import { MetaDataRegistry } from "./ClassRegistry";
11
+ import { CloudSqlite } from "./CloudSqlite";
12
+ import { CodeService } from "./CodeService";
13
+ import { CodeSpecs } from "./CodeSpecs";
14
+ import { ECSqlStatement } from "./ECSqlStatement";
15
+ import { Element, Subject } from "./Element";
16
+ import { ElementAspect } from "./ElementAspect";
17
+ import { Entity, EntityClassType } from "./Entity";
18
+ import { ExportGraphicsOptions, ExportPartGraphicsOptions } from "./ExportGraphics";
19
+ import { Model } from "./Model";
20
+ import { Relationships } from "./Relationship";
21
+ import { SqliteStatement } from "./SqliteStatement";
22
+ import { TxnManager } from "./TxnManager";
23
+ import { ViewDefinition } from "./ViewDefinition";
24
+ import { SettingDictionary } from "./workspace/Settings";
25
+ import { Workspace } from "./workspace/Workspace";
26
+ import { ECSchemaXmlContext } from "./ECSchemaXmlContext";
27
+ import { ChannelControl } from "./ChannelControl";
28
+ /** Options for [[IModelDb.Models.updateModel]]
29
+ * @note To mark *only* the geometry as changed, use [[IModelDb.Models.updateGeometryGuid]] instead.
30
+ * @public
31
+ */
32
+ export interface UpdateModelOptions extends ModelProps {
33
+ /** If defined, update the last modify time of the Model */
34
+ updateLastMod?: boolean;
35
+ /** If defined, update the GeometryGuid of the Model */
36
+ geometryChanged?: boolean;
37
+ }
38
+ /** Options supplied to [[IModelDb.computeProjectExtents]].
39
+ * @public
40
+ */
41
+ export interface ComputeProjectExtentsOptions {
42
+ /** If true, the result will include `extentsWithOutliers`. */
43
+ reportExtentsWithOutliers?: boolean;
44
+ /** If true, the result will include `outliers`. */
45
+ reportOutliers?: boolean;
46
+ }
47
+ /** The result of [[IModelDb.computeProjectExtents]].
48
+ * @public
49
+ */
50
+ export interface ComputedProjectExtents {
51
+ /** The computed extents, excluding any outlier elements. */
52
+ extents: Range3d;
53
+ /** If requested by caller, the computed extents, *including* any outlier elements. */
54
+ extentsWithOutliers?: Range3d;
55
+ /** If requested by caller, the Ids of outlier elements excluded from the computed extents. */
56
+ outliers?: Id64Array;
57
+ }
58
+ /**
59
+ * Interface for acquiring element locks to coordinate simultaneous edits from multiple briefcases.
60
+ * @beta
61
+ */
62
+ export interface LockControl {
63
+ /**
64
+ * true if this LockControl uses a server-based concurrency approach.
65
+ */
66
+ readonly isServerBased: boolean;
67
+ /**
68
+ * Close the local lock control database
69
+ * @internal
70
+ */
71
+ close(): void;
72
+ /**
73
+ * Notification that a new element was just created. Called by [[Element.onInserted]]
74
+ * @internal
75
+ */
76
+ elementWasCreated(id: Id64String): void;
77
+ /**
78
+ * Throw if locks are required and the exclusive lock is not held on the supplied element.
79
+ * Note: there is no need to check the shared locks on parents/models since an element cannot hold the exclusive lock without first obtaining them.
80
+ * Called by [[Element.onUpdate]], [[Element.onDelete]], etc.
81
+ * @internal
82
+ */
83
+ checkExclusiveLock(id: Id64String, type: string, operation: string): void;
84
+ /**
85
+ * Throw if locks are required and a shared lock is not held on the supplied element.
86
+ * Called by [[Element.onInsert]] to ensure shared lock is held on model and parent.
87
+ * @internal
88
+ */
89
+ checkSharedLock(id: Id64String, type: string, operation: string): void;
90
+ /**
91
+ * Determine whether the supplied element currently holds the exclusive lock
92
+ */
93
+ holdsExclusiveLock(id: Id64String): boolean;
94
+ /**
95
+ * Determine whether the supplied element currently holds a shared lock
96
+ */
97
+ holdsSharedLock(id: Id64String): boolean;
98
+ /**
99
+ * Acquire locks on one or more elements from the lock server, if required and not already held.
100
+ * If any required lock is not available, this method throws an exception and *none* of the requested locks are acquired.
101
+ * > Note: acquiring the exclusive lock on an element requires also obtaining a shared lock on all its owner elements. This method will
102
+ * attempt to acquire all necessary locks for both sets of input ids.
103
+ */
104
+ acquireLocks(arg: {
105
+ /** if present, one or more elements to obtain shared lock */
106
+ shared?: Id64Arg;
107
+ /** if present, one or more elements to obtain exclusive lock */
108
+ exclusive?: Id64Arg;
109
+ }): Promise<void>;
110
+ /**
111
+ * Release all locks currently held by this Briefcase from the lock server.
112
+ */
113
+ releaseAllLocks(): Promise<void>;
114
+ }
115
+ /**
116
+ * Options for the importing of schemas
117
+ * @public
118
+ */
119
+ export interface SchemaImportOptions {
120
+ /**
121
+ * An [[ECSchemaXmlContext]] to use instead of building a default one.
122
+ * This can be useful in rare cases where custom schema location logic is necessary
123
+ * @internal
124
+ */
125
+ ecSchemaXmlContext?: ECSchemaXmlContext;
126
+ }
127
+ /** @internal */
128
+ export declare enum BriefcaseLocalValue {
129
+ StandaloneEdit = "StandaloneEdit",
130
+ NoLocking = "NoLocking"
131
+ }
132
+ /** An iModel database file. The database file can either be a briefcase or a snapshot.
133
+ * @see [Accessing iModels]($docs/learning/backend/AccessingIModels.md)
134
+ * @see [About IModelDb]($docs/learning/backend/IModelDb.md)
135
+ * @public
136
+ */
137
+ export declare abstract class IModelDb extends IModel {
138
+ private _initialized;
139
+ /** Keep track of open imodels to support `tryFind` for RPC purposes */
140
+ private static readonly _openDbs;
141
+ static readonly defaultLimit = 1000;
142
+ static readonly maxLimit = 10000;
143
+ readonly models: IModelDb.Models;
144
+ readonly elements: IModelDb.Elements;
145
+ readonly views: IModelDb.Views;
146
+ readonly tiles: IModelDb.Tiles;
147
+ /** @beta */
148
+ readonly channels: ChannelControl;
149
+ private _relationships?;
150
+ private readonly _statementCache;
151
+ private readonly _sqliteStatementCache;
152
+ private _codeSpecs?;
153
+ private _classMetaDataRegistry?;
154
+ protected _fontMap?: FontMap;
155
+ /** @internal */
156
+ private _workspace?;
157
+ private readonly _snaps;
158
+ private static _shutdownListener;
159
+ /** @internal */
160
+ protected _locks?: LockControl;
161
+ /** @internal */
162
+ protected _codeService?: CodeService;
163
+ /** @alpha */
164
+ get codeService(): CodeService | undefined;
165
+ /**
166
+ * Get the [[LockControl]] for this iModel.
167
+ * @beta
168
+ */
169
+ get locks(): LockControl;
170
+ /**
171
+ * Get the [[Workspace]] for this iModel.
172
+ * @beta
173
+ */
174
+ get workspace(): Workspace;
175
+ /** Acquire the exclusive schema lock on this iModel.
176
+ * > Note: To acquire the schema lock, all other briefcases must first release *all* their locks. No other briefcases
177
+ * will be able to acquire *any* locks while the schema lock is held.
178
+ */
179
+ acquireSchemaLock(): Promise<void>;
180
+ /** determine whether the schema lock is currently held for this iModel. */
181
+ get holdsSchemaLock(): boolean;
182
+ /** Event called after a changeset is applied to this IModelDb. */
183
+ readonly onChangesetApplied: BeEvent<() => void>;
184
+ /** @internal */
185
+ notifyChangesetApplied(): void;
186
+ get fontMap(): FontMap;
187
+ /** @internal */
188
+ clearFontMap(): void;
189
+ /**
190
+ * Add a new font name/type to the FontMap for this iModel and return its FontId.
191
+ * @param name The name of the font to add
192
+ * @param type The type of the font. Default is TrueType.
193
+ * @returns The FontId for the newly added font. If a font by that name/type already exists, this method does not fail, it returns the existing Id.
194
+ * @see [FontId and FontMap]($docs/learning/backend/Fonts.md#fontid-and-fontmap)
195
+ * @beta
196
+ */
197
+ addNewFont(name: string, type?: FontType): FontId;
198
+ /** Check if this iModel has been opened read-only or not. */
199
+ get isReadonly(): boolean;
200
+ /** The Guid that identifies this iModel. */
201
+ get iModelId(): GuidString;
202
+ private _nativeDb?;
203
+ /** @internal*/
204
+ get nativeDb(): IModelJsNative.DgnDb;
205
+ /** Get the full path fileName of this iModelDb
206
+ * @note this member is only valid while the iModel is opened.
207
+ */
208
+ get pathName(): LocalFileName;
209
+ /** @internal */
210
+ protected constructor(args: {
211
+ nativeDb: IModelJsNative.DgnDb;
212
+ key: string;
213
+ changeset?: ChangesetIdWithIndex;
214
+ });
215
+ /** Close this IModel, if it is currently open. */
216
+ close(): void;
217
+ /** @internal */
218
+ refreshContainerSas(_userAccessToken: AccessToken): Promise<void>;
219
+ /** Event called when the iModel is about to be closed. */
220
+ readonly onBeforeClose: BeEvent<() => void>;
221
+ /**
222
+ * Called by derived classes before closing the connection
223
+ * @internal
224
+ */
225
+ protected beforeClose(): void;
226
+ /** @internal */
227
+ protected initializeIModelDb(): void;
228
+ /** Returns true if this is a BriefcaseDb
229
+ * @see [[BriefcaseDb.open]]
230
+ */
231
+ get isBriefcase(): boolean;
232
+ /** Type guard for instanceof [[BriefcaseDb]] */
233
+ isBriefcaseDb(): this is BriefcaseDb;
234
+ /** Returns true if this is a SnapshotDb
235
+ * @see [[SnapshotDb.open]]
236
+ */
237
+ get isSnapshot(): boolean;
238
+ /** Type guard for instanceof [[SnapshotDb]] */
239
+ isSnapshotDb(): this is SnapshotDb;
240
+ /** Returns true if this is a *standalone* iModel
241
+ * @see [[StandaloneDb.open]]
242
+ * @internal
243
+ */
244
+ get isStandalone(): boolean;
245
+ /** Type guard for instanceof [[StandaloneDb]]
246
+ * @internal
247
+ */
248
+ isStandaloneDb(): this is StandaloneDb;
249
+ /** Return `true` if the underlying nativeDb is open and valid.
250
+ * @internal
251
+ */
252
+ get isOpen(): boolean;
253
+ /** Get the briefcase Id of this iModel */
254
+ getBriefcaseId(): BriefcaseId;
255
+ /**
256
+ * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
257
+ * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
258
+ * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be
259
+ * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
260
+ * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].
261
+ * @param sql The SQLite SQL statement to execute
262
+ * @param callback the callback to invoke on the prepared statement
263
+ * @param logErrors Determines if error will be logged if statement fail to prepare
264
+ * @returns the value returned by `callback`.
265
+ * @see [[withStatement]]
266
+ * @public
267
+ */
268
+ withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
269
+ /**
270
+ * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.
271
+ * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.
272
+ * For statements that will be reused often, instead use [[withPreparedStatement]].
273
+ * @param sql The SQLite SQL statement to execute
274
+ * @param callback the callback to invoke on the prepared statement
275
+ * @param logErrors Determines if error will be logged if statement fail to prepare
276
+ * @returns the value returned by `callback`.
277
+ * @see [[withPreparedStatement]]
278
+ * @public
279
+ */
280
+ withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
281
+ /** Allow to execute query and read results along with meta data. The result are streamed.
282
+ * @param params The values to bind to the parameters (if the ECSQL has any).
283
+ * @param config Allow to specify certain flags which control how query is executed.
284
+ * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.
285
+ * @beta
286
+ * */
287
+ createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader;
288
+ /** Execute a query and stream its results
289
+ * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.
290
+ * [ECSQL row]($docs/learning/ECSQLRowFormat).
291
+ *
292
+ * See also:
293
+ * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
294
+ * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
295
+ *
296
+ * @param ecsql The ECSQL statement to execute
297
+ * @param params The values to bind to the parameters (if the ECSQL has any).
298
+ * @param options Allow to specify certain flags which control how query is executed.
299
+ * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
300
+ * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
301
+ * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
302
+ * @deprecated in 3.7. Use [[createQueryReader]] instead; it accepts the same parameters.
303
+ */
304
+ query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any>;
305
+ /** Compute number of rows that would be returned by the ECSQL.
306
+ *
307
+ * See also:
308
+ * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
309
+ * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
310
+ *
311
+ * @param ecsql The ECSQL statement to execute
312
+ * @param params The values to bind to the parameters (if the ECSQL has any).
313
+ * See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
314
+ * @returns Return row count.
315
+ * @throws [IModelError]($common) If the statement is invalid
316
+ * @deprecated in 3.7. Count the number of results using `count(*)` where the original query is a subquery instead. E.g., `SELECT count(*) FROM (<query-whose-rows-to-count>)`.
317
+ */
318
+ queryRowCount(ecsql: string, params?: QueryBinder): Promise<number>;
319
+ /** Cancel any previous query with same token and run execute the current specified query.
320
+ * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.
321
+ * [ECSQL row]($docs/learning/ECSQLRowFormat).
322
+ *
323
+ * See also:
324
+ * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
325
+ * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
326
+ *
327
+ * @param ecsql The ECSQL statement to execute
328
+ * @param token None empty restart token. The previous query with same token would be cancelled. This would cause
329
+ * exception which user code must handle.
330
+ * @param params The values to bind to the parameters (if the ECSQL has any).
331
+ * @param options Allow to specify certain flags which control how query is executed.
332
+ * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
333
+ * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
334
+ * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
335
+ * @deprecated in 3.7. Use [[createQueryReader]] instead. Pass in the restart token as part of the `config` argument; e.g., `{ restartToken: myToken }` or `new QueryOptionsBuilder().setRestartToken(myToken).getOptions()`.
336
+ */
337
+ restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any>;
338
+ /**
339
+ * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist
340
+ * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
341
+ * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be
342
+ * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
343
+ * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].
344
+ * @param sql The SQLite SQL statement to execute
345
+ * @param callback the callback to invoke on the prepared statement
346
+ * @param logErrors Determine if errors are logged or not
347
+ * @returns the value returned by `callback`.
348
+ * @see [[withPreparedStatement]]
349
+ * @public
350
+ */
351
+ withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors?: boolean): T;
352
+ /**
353
+ * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.
354
+ * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.
355
+ * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].
356
+ * @param sql The SQLite SQL statement to execute
357
+ * @param callback the callback to invoke on the prepared statement
358
+ * @param logErrors Determine if errors are logged or not
359
+ * @returns the value returned by `callback`.
360
+ * @public
361
+ */
362
+ withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors?: boolean): T;
363
+ /** Prepare an SQL statement.
364
+ * @param sql The SQL statement to prepare
365
+ * @throws [[IModelError]] if there is a problem preparing the statement.
366
+ * @internal
367
+ */
368
+ prepareSqliteStatement(sql: string, logErrors?: boolean): SqliteStatement;
369
+ /**
370
+ * queries the BisCore.SubCategory table for the entries that are children of the passed categoryIds
371
+ * @param categoryIds categoryIds to query
372
+ * @returns array of SubCategoryResultRow
373
+ * @internal
374
+ */
375
+ querySubCategories(categoryIds: Iterable<Id64String>): Promise<SubCategoryResultRow[]>;
376
+ /** Query for a set of entity ids, given an EntityQueryParams
377
+ * @param params The query parameters. The `limit` and `offset` members should be used to page results.
378
+ * @returns an Id64Set with results of query
379
+ * @throws [[IModelError]] if the generated statement is invalid or [IModelDb.maxLimit]($backend) exceeded when collecting ids.
380
+ *
381
+ * *Example:*
382
+ * ``` ts
383
+ * [[include:ECSQL-backend-queries.select-element-by-code-value-using-queryEntityIds]]
384
+ * ```
385
+ */
386
+ queryEntityIds(params: EntityQueryParams): Id64Set;
387
+ /** Clear all in-memory caches held in this IModelDb. */
388
+ clearCaches(): void;
389
+ /** Update the project extents for this iModel.
390
+ * <p><em>Example:</em>
391
+ * ``` ts
392
+ * [[include:IModelDb.updateProjectExtents]]
393
+ * ```
394
+ */
395
+ updateProjectExtents(newExtents: AxisAlignedBox3d): void;
396
+ /** Compute an appropriate project extents for this iModel based on the ranges of all spatial elements.
397
+ * Typically, the result is simply the union of the ranges of all spatial elements. However, the algorithm also detects "outlier elements",
398
+ * whose placements locate them so far from the rest of the spatial geometry that they are considered statistically insignificant. The
399
+ * range of an outlier element does not contribute to the computed extents.
400
+ * @param options Specifies the level of detail desired in the return value.
401
+ * @returns the computed extents.
402
+ * @note This method does not modify the IModel's stored project extents. @see [[updateProjectExtents]].
403
+ */
404
+ computeProjectExtents(options?: ComputeProjectExtentsOptions): ComputedProjectExtents;
405
+ /** Update the [EcefLocation]($docs/learning/glossary#eceflocation) of this iModel. */
406
+ updateEcefLocation(ecef: EcefLocation): void;
407
+ /** Update the IModelProps of this iModel in the database. */
408
+ updateIModelProps(): void;
409
+ /** Commit pending changes to this iModel.
410
+ * @param description Optional description of the changes
411
+ * @throws [[IModelError]] if there is a problem saving changes or if there are pending, un-processed lock or code requests.
412
+ */
413
+ saveChanges(description?: string): void;
414
+ /** Abandon pending changes in this iModel. */
415
+ abandonChanges(): void;
416
+ /**
417
+ * Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
418
+ * This ensures that all changes to the database since it was opened are saved to its file and the WAL file is truncated.
419
+ * @note Checkpoint automatically happens when IModelDbs are closed. However, the checkpoint
420
+ * operation itself can take some time. It may be useful to call this method prior to closing so that the checkpoint "penalty" is paid earlier.
421
+ * @note Another use for this function is to permit the file to be copied while it is open for write. iModel files should
422
+ * rarely be copied, and even less so while they're opened. But this scenario is sometimes encountered for tests.
423
+ */
424
+ performCheckpoint(): void;
425
+ /** @internal */
426
+ reverseTxns(numOperations: number): IModelStatus;
427
+ /** @internal */
428
+ reinstateTxn(): IModelStatus;
429
+ /** @internal */
430
+ restartTxnSession(): void;
431
+ /** Import an ECSchema. On success, the schema definition is stored in the iModel.
432
+ * This method is asynchronous (must be awaited) because, in the case where this IModelDb is a briefcase, this method first obtains the schema lock from the iModel server.
433
+ * You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
434
+ * @param schemaFileName array of Full paths to ECSchema.xml files to be imported.
435
+ * @param {SchemaImportOptions} options - options during schema import.
436
+ * @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
437
+ * @note Changes are saved if importSchemas is successful and abandoned if not successful.
438
+ * @see querySchemaVersion
439
+ */
440
+ importSchemas(schemaFileNames: LocalFileName[], options?: SchemaImportOptions): Promise<void>;
441
+ /** Import ECSchema(s) serialized to XML. On success, the schema definition is stored in the iModel.
442
+ * This method is asynchronous (must be awaited) because, in the case where this IModelDb is a briefcase, this method first obtains the schema lock from the iModel server.
443
+ * You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
444
+ * @param serializedXmlSchemas The xml string(s) created from a serialized ECSchema.
445
+ * @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
446
+ * @note Changes are saved if importSchemaStrings is successful and abandoned if not successful.
447
+ * @see querySchemaVersion
448
+ * @alpha
449
+ */
450
+ importSchemaStrings(serializedXmlSchemas: string[]): Promise<void>;
451
+ /** Find an opened instance of any subclass of IModelDb, by filename
452
+ * @note this method returns an IModelDb if the filename is open for *any* subclass of IModelDb
453
+ */
454
+ static findByFilename(fileName: LocalFileName): IModelDb | undefined;
455
+ /** Find an open IModelDb by its key.
456
+ * @note This method is mainly for use by RPC implementations.
457
+ * @throws [[IModelNotFoundResponse]] if an open IModelDb matching the key is not found.
458
+ * @see [IModel.key]($common)
459
+ */
460
+ static findByKey(key: string): IModelDb;
461
+ /** Attempt to find an open IModelDb by key.
462
+ * @returns The matching IModelDb or `undefined`.
463
+ */
464
+ static tryFindByKey(key: string): IModelDb | undefined;
465
+ /** @internal */
466
+ static openDgnDb(file: {
467
+ path: LocalFileName;
468
+ key?: string;
469
+ }, openMode: OpenMode, upgradeOptions?: UpgradeOptions, props?: SnapshotOpenOptions & CloudContainerArgs): IModelJsNative.DgnDb;
470
+ /**
471
+ * Determines if the schemas in the Db must or can be upgraded by comparing them with those included in the
472
+ * current version of the software.
473
+ * @param filePath Full name of the briefcase including path
474
+ * @param forReadWrite Pass true if validating for read-write scenarios - note that the schema version requirements
475
+ * for opening the DgnDb read-write is more stringent than when opening the database read-only
476
+ * @throws [[IModelError]] If the Db was in an invalid state and that causes a problem with validating schemas
477
+ * @see [[BriefcaseDb.upgradeSchemas]] or [[StandaloneDb.upgradeSchemas]]
478
+ * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
479
+ */
480
+ static validateSchemas(filePath: LocalFileName, forReadWrite: boolean): SchemaState;
481
+ /** Get the ClassMetaDataRegistry for this iModel.
482
+ * @internal
483
+ */
484
+ get classMetaDataRegistry(): MetaDataRegistry;
485
+ /** Get the linkTableRelationships for this IModel */
486
+ get relationships(): Relationships;
487
+ /** Get the CodeSpecs in this IModel. */
488
+ get codeSpecs(): CodeSpecs;
489
+ /** @internal */
490
+ insertCodeSpec(codeSpec: CodeSpec): Id64String;
491
+ /** Prepare an ECSQL statement.
492
+ * @param sql The ECSQL statement to prepare
493
+ * @param logErrors Determines if error will be logged if statement fail to prepare
494
+ * @throws [[IModelError]] if there is a problem preparing the statement.
495
+ */
496
+ prepareStatement(sql: string, logErrors?: boolean): ECSqlStatement;
497
+ /** Prepare an ECSQL statement.
498
+ * @param sql The ECSQL statement to prepare
499
+ * @returns `undefined` if there is a problem preparing the statement.
500
+ */
501
+ tryPrepareStatement(sql: string): ECSqlStatement | undefined;
502
+ /** Construct an entity (Element or Model) from an iModel.
503
+ * @throws [[IModelError]] if the entity cannot be constructed.
504
+ */
505
+ constructEntity<T extends Entity>(props: EntityProps): T;
506
+ /** Get the JavaScript class that handles a given entity class. */
507
+ getJsClass<T extends typeof Entity>(classFullName: string): T;
508
+ /** Get metadata for a class. This method will load the metadata from the iModel into the cache as a side-effect, if necessary.
509
+ * @throws [[IModelError]] if the metadata cannot be found nor loaded.
510
+ */
511
+ getMetaData(classFullName: string): EntityMetaData;
512
+ /** Invoke a callback on each property of the specified class, optionally including superclass properties.
513
+ * @param iModel The IModel that contains the schema
514
+ * @param classFullName The full class name to load the metadata, if necessary
515
+ * @param wantSuper If true, superclass properties will also be processed
516
+ * @param func The callback to be invoked on each property
517
+ * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
518
+ * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
519
+ */
520
+ static forEachMetaData(iModel: IModelDb, classFullName: string, wantSuper: boolean, func: PropertyCallback, includeCustom?: boolean): void;
521
+ /** @internal */
522
+ private loadMetaData;
523
+ /** Returns the full schema for the input name.
524
+ * @param name The name of the schema e.g. 'BisCore'
525
+ * @returns The SchemaProps for the requested schema
526
+ * @throws if the schema can not be found or loaded.
527
+ */
528
+ getSchemaProps(name: string): ECSchemaProps;
529
+ /** Query if this iModel contains the definition of the specified class.
530
+ * @param classFullName The full name of the class, for example, SomeSchema:SomeClass
531
+ * @returns true if the iModel contains the class definition or false if not.
532
+ * @see querySchemaVersion
533
+ * @see importSchema
534
+ */
535
+ containsClass(classFullName: string): boolean;
536
+ /** Query for a schema of the specified name in this iModel.
537
+ * @returns The schema version as a semver-compatible string or `undefined` if the schema has not been imported.
538
+ */
539
+ querySchemaVersion(schemaName: string): string | undefined;
540
+ /** Retrieve a named texture image from this iModel, as a TextureData.
541
+ * @param props the texture load properties which must include the name of the texture to load
542
+ * @returns the TextureData or undefined if the texture image is not present.
543
+ * @alpha
544
+ */
545
+ queryTextureData(props: TextureLoadProps): Promise<TextureData | undefined>;
546
+ /** Query a "file property" from this iModel, as a string.
547
+ * @returns the property string or undefined if the property is not present.
548
+ */
549
+ queryFilePropertyString(prop: FilePropertyProps): string | undefined;
550
+ /** Query a "file property" from this iModel, as a blob.
551
+ * @returns the property blob or undefined if the property is not present.
552
+ */
553
+ queryFilePropertyBlob(prop: FilePropertyProps): Uint8Array | undefined;
554
+ /** Save a "file property" to this iModel
555
+ * @param prop the FilePropertyProps that describes the new property
556
+ * @param value either a string or a blob to save as the file property
557
+ */
558
+ saveFileProperty(prop: FilePropertyProps, strValue: string | undefined, blobVal?: Uint8Array): void;
559
+ /** delete a "file property" from this iModel
560
+ * @param prop the FilePropertyProps that describes the property
561
+ */
562
+ deleteFileProperty(prop: FilePropertyProps): void;
563
+ /** Query for the next available major id for a "file property" from this iModel.
564
+ * @param prop the FilePropertyProps that describes the property
565
+ * @returns the next available (that is, an unused) id for prop. If none are present, will return 0.
566
+ */
567
+ queryNextAvailableFileProperty(prop: FilePropertyProps): number;
568
+ /** @internal */
569
+ requestSnap(sessionId: string, props: SnapRequestProps): Promise<SnapResponseProps>;
570
+ /** Cancel a previously requested snap.
571
+ * @internal
572
+ */
573
+ cancelSnap(sessionId: string): void;
574
+ /** Get the clip containment status for the supplied elements. */
575
+ getGeometryContainment(props: GeometryContainmentRequestProps): Promise<GeometryContainmentResponseProps>;
576
+ /** Get the mass properties for the supplied elements. */
577
+ getMassProperties(props: MassPropertiesRequestProps): Promise<MassPropertiesResponseProps>;
578
+ /** Get the IModel coordinate corresponding to each GeoCoordinate point in the input */
579
+ getIModelCoordinatesFromGeoCoordinates(props: IModelCoordinatesRequestProps): Promise<IModelCoordinatesResponseProps>;
580
+ /** Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input */
581
+ getGeoCoordinatesFromIModelCoordinates(props: GeoCoordinatesRequestProps): Promise<GeoCoordinatesResponseProps>;
582
+ /** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
583
+ * * Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend,
584
+ * or that shared backends export a limited number of elements at a time.
585
+ * * Vertices are exported in the IModelDb's world coordinate system, which is right-handed with Z pointing up.
586
+ * * The results of changing [ExportGraphicsOptions]($core-backend) during the [ExportGraphicsOptions.onGraphics]($core-backend) callback are not defined.
587
+ *
588
+ * Example that prints the mesh for element 1 to stdout in [OBJ format](https://en.wikipedia.org/wiki/Wavefront_.obj_file)
589
+ * ```ts
590
+ * const onGraphics: ExportGraphicsFunction = (info: ExportGraphicsInfo) => {
591
+ * const mesh: ExportGraphicsMesh = info.mesh;
592
+ * for (let i = 0; i < mesh.points.length; i += 3) {
593
+ * process.stdout.write(`v ${mesh.points[i]} ${mesh.points[i + 1]} ${mesh.points[i + 2]}\n`);
594
+ * process.stdout.write(`vn ${mesh.normals[i]} ${mesh.normals[i + 1]} ${mesh.normals[i + 2]}\n`);
595
+ * }
596
+ *
597
+ * for (let i = 0; i < mesh.params.length; i += 2) {
598
+ * process.stdout.write(`vt ${mesh.params[i]} ${mesh.params[i + 1]}\n`);
599
+ * }
600
+ *
601
+ * for (let i = 0; i < mesh.indices.length; i += 3) {
602
+ * const p1 = mesh.indices[i];
603
+ * const p2 = mesh.indices[i + 1];
604
+ * const p3 = mesh.indices[i + 2];
605
+ * process.stdout.write(`f ${p1}/${p1}/${p1} ${p2}/${p2}/${p2} ${p3}/${p3}/${p3}\n`);
606
+ * }
607
+ * };
608
+ *
609
+ * iModel.exportGraphics(({ onGraphics, elementIdArray: ["0x1"] }));
610
+ * ```
611
+ * @returns 0 if successful, status otherwise
612
+ * @public
613
+ */
614
+ exportGraphics(exportProps: ExportGraphicsOptions): DbResult;
615
+ /**
616
+ * Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
617
+ * in this IModelDb.
618
+ * The expected use case is to call [IModelDb.exportGraphics]($core-backend) and supply the
619
+ * optional partInstanceArray argument, then call this function for each unique GeometryPart from
620
+ * that list.
621
+ * * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
622
+ * [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
623
+ * * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
624
+ * @returns 0 is successful, status otherwise
625
+ * @public
626
+ */
627
+ exportPartGraphics(exportProps: ExportPartGraphicsOptions): DbResult;
628
+ /** Request geometry stream information from an element in binary format instead of json.
629
+ * @returns IModelStatus.Success if successful
630
+ * @alpha
631
+ */
632
+ elementGeometryRequest(requestProps: ElementGeometryRequest): IModelStatus;
633
+ /** Create brep geometry for inclusion in an element's geometry stream.
634
+ * @returns IModelStatus.Success if successful
635
+ * @throws [[IModelError]] to report issues with input geometry or parameters
636
+ * @alpha
637
+ */
638
+ createBRepGeometry(createProps: BRepGeometryCreate): IModelStatus;
639
+ /** Generate graphics for an element or geometry stream.
640
+ * @see [readElementGraphics]($frontend) to convert the result to a [RenderGraphic]($frontend) for display.
641
+ */
642
+ generateElementGraphics(request: ElementGraphicsRequestProps): Promise<Uint8Array | undefined>;
643
+ private static _settingPropNamespace;
644
+ /** Save a `SettingDictionary` in this iModel that will be loaded into [[workspace.settings]] every time this iModel is opened in future sessions.
645
+ * @param name The name for the SettingDictionary. If a dictionary by that name already exists in the iModel, its value is replaced.
646
+ * @param dict The SettingDictionary object to stringify and save.
647
+ * @note All saved `SettingDictionary`s are loaded into [[workspace.settings]] every time an iModel is opened.
648
+ * @beta
649
+ */
650
+ saveSettingDictionary(name: string, dict: SettingDictionary): void;
651
+ /** Delete a SettingDictionary, previously added with [[saveSettingDictionary]], from this iModel.
652
+ * @param name The name of the dictionary to delete.
653
+ * @beta
654
+ */
655
+ deleteSettingDictionary(name: string): void;
656
+ /** Load all setting dictionaries in this iModel into `this.workspace.settings` */
657
+ private loadSettingDictionaries;
658
+ }
659
+ /** @public */
660
+ export declare namespace IModelDb {
661
+ /** The collection of models in an [[IModelDb]].
662
+ * @public
663
+ */
664
+ class Models {
665
+ private _iModel;
666
+ /** @internal */
667
+ constructor(_iModel: IModelDb);
668
+ /** Get the ModelProps with the specified identifier.
669
+ * @param modelId The Model identifier.
670
+ * @throws [[IModelError]] if the model is not found or cannot be loaded.
671
+ * @see tryGetModelProps
672
+ */
673
+ getModelProps<T extends ModelProps>(id: Id64String): T;
674
+ /** Get the ModelProps with the specified identifier.
675
+ * @param modelId The Model identifier.
676
+ * @returns The ModelProps or `undefined` if the model is not found.
677
+ * @throws [[IModelError]] if the model cannot be loaded.
678
+ * @note Useful for cases when a model may or may not exist and throwing an `Error` would be overkill.
679
+ * @see getModelProps
680
+ */
681
+ tryGetModelProps<T extends ModelProps>(id: Id64String): T | undefined;
682
+ /** Query for the last modified time of the specified Model.
683
+ * @internal
684
+ */
685
+ queryLastModifiedTime(modelId: Id64String): string;
686
+ /** Get the Model with the specified identifier.
687
+ * @param modelId The Model identifier.
688
+ * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
689
+ * @throws [[IModelError]] if the model is not found, cannot be loaded, or fails validation when `modelClass` is specified.
690
+ * @see tryGetModel
691
+ */
692
+ getModel<T extends Model>(modelId: Id64String, modelClass?: EntityClassType<Model>): T;
693
+ /** Get the Model with the specified identifier.
694
+ * @param modelId The Model identifier.
695
+ * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
696
+ * @returns The Model or `undefined` if the model is not found or fails validation when `modelClass` is specified.
697
+ * @throws [[IModelError]] if the model cannot be loaded.
698
+ * @note Useful for cases when a model may or may not exist and throwing an `Error` would be overkill.
699
+ * @see getModel
700
+ */
701
+ tryGetModel<T extends Model>(modelId: Id64String, modelClass?: EntityClassType<Model>): T | undefined;
702
+ /** Read the properties for a Model as a json string.
703
+ * @param modelIdArg a json string with the identity of the model to load. Must have either "id" or "code".
704
+ * @returns a json string with the properties of the model.
705
+ * @throws [[IModelError]] if the model is not found or cannot be loaded.
706
+ * @see tryGetModelJson
707
+ * @internal
708
+ */
709
+ getModelJson<T extends ModelProps>(modelIdArg: ModelLoadProps): T;
710
+ /** Read the properties for a Model as a json string.
711
+ * @param modelIdArg a json string with the identity of the model to load. Must have either "id" or "code".
712
+ * @returns a json string with the properties of the model or `undefined` if the model is not found.
713
+ * @see getModelJson
714
+ */
715
+ private tryGetModelJson;
716
+ /** Get the sub-model of the specified Element.
717
+ * See [[IModelDb.Elements.queryElementIdByCode]] for more on how to find an element by Code.
718
+ * @param modeledElementId Identifies the modeled element.
719
+ * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
720
+ * @throws [[IModelError]] if the sub-model is not found, cannot be loaded, or fails validation when `modelClass` is specified.
721
+ * @see tryGetSubModel
722
+ */
723
+ getSubModel<T extends Model>(modeledElementId: Id64String | GuidString | Code, modelClass?: EntityClassType<Model>): T;
724
+ /** Get the sub-model of the specified Element.
725
+ * See [[IModelDb.Elements.queryElementIdByCode]] for more on how to find an element by Code.
726
+ * @param modeledElementId Identifies the modeled element.
727
+ * @param modelClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
728
+ * @returns The sub-model or `undefined` if the specified element does not have a sub-model or fails validation when `modelClass` is specified.
729
+ * @see getSubModel
730
+ */
731
+ tryGetSubModel<T extends Model>(modeledElementId: Id64String | GuidString | Code, modelClass?: EntityClassType<Model>): T | undefined;
732
+ /** Create a new model in memory.
733
+ * See the example in [[InformationPartitionElement]].
734
+ * @param modelProps The properties to use when creating the model.
735
+ * @throws [[IModelError]] if there is a problem creating the model.
736
+ */
737
+ createModel<T extends Model>(modelProps: ModelProps): T;
738
+ /** Insert a new model.
739
+ * @param props The data for the new model.
740
+ * @returns The newly inserted model's Id.
741
+ * @throws [[IModelError]] if unable to insert the model.
742
+ */
743
+ insertModel(props: ModelProps): Id64String;
744
+ /** Update an existing model.
745
+ * @param props the properties of the model to change
746
+ * @throws [[IModelError]] if unable to update the model.
747
+ */
748
+ updateModel(props: UpdateModelOptions): void;
749
+ /** Mark the geometry of [[GeometricModel]] as having changed, by recording an indirect change to its GeometryGuid property.
750
+ * Typically the GeometryGuid changes automatically when [[GeometricElement]]s within the model are modified, but
751
+ * explicitly updating it is occasionally useful after modifying definition elements like line styles or materials that indirectly affect the appearance of
752
+ * [[GeometricElement]]s that reference those definition elements in their geometry streams.
753
+ * Cached [Tile]($frontend)s are only invalidated after the geometry guid of the model changes.
754
+ * @note This will throw IModelError with [IModelStatus.VersionTooOld]($core-bentley) if a version of the BisCore schema older than 1.0.11 is present in the iModel.
755
+ * @throws IModelError if unable to update the geometry guid.
756
+ * @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
757
+ */
758
+ updateGeometryGuid(modelId: Id64String): void;
759
+ /** Delete one or more existing models.
760
+ * @param ids The Ids of the models to be deleted
761
+ * @throws [[IModelError]]
762
+ */
763
+ deleteModel(ids: Id64Arg): void;
764
+ /** For each specified [[GeometricModel]], attempts to obtain the union of the volumes of all geometric elements within that model.
765
+ * @param ids The Id or Ids of the [[GeometricModel]]s for which to obtain the extents.
766
+ * @returns An array of results, one per supplied Id, in the order in which the Ids were supplied. If the extents could not be obtained, the
767
+ * corresponding results entry's `extents` will be a "null" range (@see [Range3d.isNull]($geometry)) and its `status` will indicate
768
+ * why the extents could not be obtained (e.g., because the Id did not identify a [[GeometricModel]]).
769
+ * @see [[queryRange]] to obtain the union of all of the models' extents.
770
+ */
771
+ queryExtents(ids: Id64String | Id64String[]): Promise<ModelExtentsProps[]>;
772
+ /** Computes the union of the volumes of all geoemtric elements within any number of [[GeometricModel]]s, specified by model Id.
773
+ * @see [[queryExtents]] to obtain discrete volumes for each model.
774
+ */
775
+ queryRange(ids: Id64String | Id64String[]): Promise<AxisAlignedBox3d>;
776
+ }
777
+ /** The collection of elements in an [[IModelDb]].
778
+ * @public
779
+ */
780
+ class Elements {
781
+ private _iModel;
782
+ /** @internal */
783
+ constructor(_iModel: IModelDb);
784
+ /** Read element data from the iModel as JSON
785
+ * @param elementIdArg a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
786
+ * @returns The JSON properties of the element.
787
+ * @throws [[IModelError]] if the element is not found or cannot be loaded.
788
+ * @see tryGetElementJson
789
+ * @internal
790
+ */
791
+ getElementJson<T extends ElementProps>(elementId: ElementLoadProps): T;
792
+ /** Read element data from the iModel as JSON
793
+ * @param loadProps - a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
794
+ * @returns The JSON properties of the element or `undefined` if the element is not found.
795
+ * @throws [[IModelError]] if the element exists, but cannot be loaded.
796
+ * @see getElementJson
797
+ */
798
+ private tryGetElementJson;
799
+ /** Get properties of an Element by Id, FederationGuid, or Code
800
+ * @throws [[IModelError]] if the element is not found or cannot be loaded.
801
+ * @see tryGetElementProps
802
+ */
803
+ getElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): T;
804
+ /** Get properties of an Element by Id, FederationGuid, or Code
805
+ * @returns The properties of the element or `undefined` if the element is not found.
806
+ * @throws [[IModelError]] if the element exists, but cannot be loaded.
807
+ * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
808
+ * @see getElementProps
809
+ */
810
+ tryGetElementProps<T extends ElementProps>(elementId: Id64String | GuidString | Code | ElementLoadProps): T | undefined;
811
+ /** Get an element by Id, FederationGuid, or Code
812
+ * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
813
+ * @param elementClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
814
+ * @throws [[IModelError]] if the element is not found, cannot be loaded, or fails validation when `elementClass` is specified.
815
+ * @see tryGetElement
816
+ */
817
+ getElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T;
818
+ /** Get an element by Id, FederationGuid, or Code
819
+ * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
820
+ * @param elementClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
821
+ * @returns The element or `undefined` if the element is not found or fails validation when `elementClass` is specified.
822
+ * @throws [[IModelError]] if the element exists, but cannot be loaded.
823
+ * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
824
+ * @see getElement
825
+ */
826
+ tryGetElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T | undefined;
827
+ /** Query for the Id of the element that has a specified code.
828
+ * This method is for the case where you know the element's Code.
829
+ * If you only know the code *value*, then in the simplest case, you can query on that
830
+ * and filter the results.
831
+ * In the simple case, call [[IModelDb.queryEntityIds]], specifying the code value in the where clause of the query params.
832
+ * Or, you can execute an ECSQL select statement. See
833
+ * [frequently used ECSQL queries]($docs/learning/backend/ECSQL-queries.md) for an example.
834
+ * @param code The code to look for
835
+ * @returns The element that uses the code or undefined if the code is not used.
836
+ * @throws IModelError if the code is invalid
837
+ */
838
+ queryElementIdByCode(code: Required<CodeProps>): Id64String | undefined;
839
+ /** Query for the last modified time of the specified element.
840
+ * @internal
841
+ */
842
+ queryLastModifiedTime(elementId: Id64String): string;
843
+ /** Create a new instance of an element.
844
+ * @param elProps The properties of the new element.
845
+ * @throws [[IModelError]] if there is a problem creating the element.
846
+ */
847
+ createElement<T extends Element>(elProps: ElementProps): T;
848
+ /** Insert a new element into the iModel.
849
+ * @param elProps The properties of the new element.
850
+ * @returns The newly inserted element's Id.
851
+ * @throws [[IModelError]] if unable to insert the element.
852
+ * @note For convenience, the value of `elProps.id` is updated to reflect the resultant element's id.
853
+ * However when `elProps.federationGuid` is not present or undefined, a new Guid will be generated and stored on the resultant element. But
854
+ * the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
855
+ * if you intend to continue working with it. That will ensure its values reflect the persistent state.
856
+ */
857
+ insertElement(elProps: ElementProps): Id64String;
858
+ /** Update some properties of an existing element.
859
+ * To support clearing a property value, every property name that is present in the `elProps` object will be updated even if the value is `undefined`.
860
+ * To keep an individual element property unchanged, it should either be excluded from the `elProps` parameter or set to its current value.
861
+ * @param elProps the properties of the element to update.
862
+ * @note As described above, this is a special case where there is a difference between a property being excluded and a property being present in `elProps` but set to `undefined`.
863
+ * @throws [[IModelError]] if unable to update the element.
864
+ */
865
+ updateElement(elProps: ElementProps): void;
866
+ /** Delete one or more elements from this iModel.
867
+ * @param ids The set of Ids of the element(s) to be deleted
868
+ * @throws [[IModelError]]
869
+ * @see deleteDefinitionElements
870
+ */
871
+ deleteElement(ids: Id64Arg): void;
872
+ /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
873
+ * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
874
+ * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
875
+ * This method performs those expensive checks and then calls *delete* if not referenced.
876
+ * @param ids The Ids of the DefinitionElements to attempt to delete. To prevent multiple passes over the same GeometricElements, it is best to pass in the entire array of
877
+ * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
878
+ * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
879
+ * @see deleteElement
880
+ * @beta
881
+ */
882
+ deleteDefinitionElements(definitionElementIds: Id64Array): Id64Set;
883
+ /** Query for the child elements of the specified element.
884
+ * @returns Returns an array of child element identifiers.
885
+ * @throws [[IModelError]]
886
+ */
887
+ queryChildren(elementId: Id64String): Id64String[];
888
+ /** Query for the parent of the specified element.
889
+ * @param elementId The element to check for a parent
890
+ * @returns The identifier of the element's parent or undefined if the element has no parent
891
+ * @throws [[IModelError]] if the element does not exist
892
+ */
893
+ queryParent(elementId: Id64String): Id64String | undefined;
894
+ /** Returns true if the specified Element has a sub-model.
895
+ * @see [[IModelDb.Models.getSubModel]]
896
+ */
897
+ hasSubModel(elementId: Id64String): boolean;
898
+ /** Get the root subject element. */
899
+ getRootSubject(): Subject;
900
+ /** Query for aspects of a particular class (polymorphically) associated with this element.
901
+ * @throws [[IModelError]]
902
+ * @note Most cases should use the [[getAspects]] wrapper rather than calling this method directly.
903
+ * @internal
904
+ */
905
+ _queryAspects(elementId: Id64String, fromClassFullName: string, excludedClassFullNames?: Set<string>): ElementAspect[];
906
+ /** Query for aspect by ECInstanceId
907
+ * @throws [[IModelError]]
908
+ */
909
+ private _queryAspect;
910
+ /** Get a single ElementAspect by its instance Id.
911
+ * @throws [[IModelError]]
912
+ */
913
+ getAspect(aspectInstanceId: Id64String): ElementAspect;
914
+ /** Get the ElementAspect instances that are owned by the specified element.
915
+ * @param elementId Get ElementAspects associated with this Element
916
+ * @param aspectClassFullName Optionally filter ElementAspects polymorphically by this class name
917
+ * @throws [[IModelError]]
918
+ */
919
+ getAspects(elementId: Id64String, aspectClassFullName?: string): ElementAspect[];
920
+ /** Insert a new ElementAspect into the iModel.
921
+ * @param aspectProps The properties of the new ElementAspect.
922
+ * @throws [[IModelError]] if unable to insert the ElementAspect.
923
+ * @returns the id of the newly inserted aspect.
924
+ * @note Aspect Ids may collide with element Ids, so don't put both in a container like Set or Map
925
+ * use [EntityReference]($common) for that instead.
926
+ */
927
+ insertAspect(aspectProps: ElementAspectProps): Id64String;
928
+ /** Update an exist ElementAspect within the iModel.
929
+ * @param aspectProps The properties to use to update the ElementAspect.
930
+ * @throws [[IModelError]] if unable to update the ElementAspect.
931
+ */
932
+ updateAspect(aspectProps: ElementAspectProps): void;
933
+ /** Delete one or more ElementAspects from this iModel.
934
+ * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
935
+ * @throws [[IModelError]] if unable to delete the ElementAspect.
936
+ */
937
+ deleteAspect(aspectInstanceIds: Id64Arg): void;
938
+ }
939
+ /** The collection of views in an [[IModelDb]].
940
+ * @public
941
+ */
942
+ class Views {
943
+ private _iModel;
944
+ /** @internal */
945
+ constructor(_iModel: IModelDb);
946
+ /** Query for the array of ViewDefinitionProps of the specified class and matching the specified IsPrivate setting.
947
+ * @param className Query for view definitions of this class.
948
+ * @param wantPrivate If true, include private view definitions.
949
+ */
950
+ queryViewDefinitionProps(className?: string, limit?: number, offset?: number, wantPrivate?: boolean): ViewDefinitionProps[];
951
+ /** Default parameters for iterating/querying ViewDefinitions. Includes all subclasses of ViewDefinition, excluding only those marked 'private'. */
952
+ static readonly defaultQueryParams: ViewQueryParams;
953
+ /** Iterate all ViewDefinitions matching the supplied query.
954
+ * @param params Specifies the query by which views are selected.
955
+ * @param callback Function invoked for each ViewDefinition matching the query. Return false to terminate iteration, true to continue.
956
+ * @returns true if all views were iterated, false if iteration was terminated early due to callback returning false.
957
+ *
958
+ * **Example: Finding all views of a specific DrawingModel**
959
+ * ``` ts
960
+ * [[include:IModelDb.Views.iterateViews]]
961
+ * ```
962
+ */
963
+ iterateViews(params: ViewQueryParams, callback: (view: ViewDefinition) => boolean): boolean;
964
+ private loadViewStateProps;
965
+ /** @deprecated in 3.x. use [[getViewStateProps]]. */
966
+ getViewStateData(viewDefinitionId: string, options?: ViewStateLoadProps): ViewStateProps;
967
+ /** Obtain a [ViewStateProps]($common) for a [[ViewDefinition]] specified by element Id. */
968
+ getViewStateProps(viewDefinitionId: string, options?: ViewStateLoadProps): Promise<ViewStateProps>;
969
+ private getViewThumbnailArg;
970
+ /** Get the thumbnail for a view.
971
+ * @param viewDefinitionId The Id of the view for thumbnail
972
+ * @returns the ThumbnailProps, or undefined if no thumbnail exists.
973
+ */
974
+ getThumbnail(viewDefinitionId: Id64String): ThumbnailProps | undefined;
975
+ /** Save a thumbnail for a view.
976
+ * @param viewDefinitionId The Id of the view for thumbnail
977
+ * @param thumbnail The thumbnail data.
978
+ * @returns 0 if successful
979
+ */
980
+ saveThumbnail(viewDefinitionId: Id64String, thumbnail: ThumbnailProps): number;
981
+ /** Set the default view property the iModel
982
+ * @param viewId The Id of the ViewDefinition to use as the default
983
+ */
984
+ setDefaultViewId(viewId: Id64String): void;
985
+ }
986
+ /** Represents the current state of a pollable tile content request.
987
+ * Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
988
+ * @internal
989
+ */
990
+ enum TileContentState {
991
+ New = 0,
992
+ Pending = 1,
993
+ Loading = 2
994
+ }
995
+ /** @internal */
996
+ class Tiles {
997
+ private _iModel;
998
+ /** @internal */
999
+ constructor(_iModel: IModelDb);
1000
+ /** @internal */
1001
+ requestTileTreeProps(id: string): Promise<IModelTileTreeProps>;
1002
+ private pollTileContent;
1003
+ /** @internal */
1004
+ requestTileContent(treeId: string, tileId: string): Promise<IModelJsNative.TileContent>;
1005
+ /** @internal */
1006
+ getTileContent(treeId: string, tileId: string): Promise<Uint8Array>;
1007
+ }
1008
+ }
1009
+ /**
1010
+ * Argument to a function that can accept a valid access token.
1011
+ * @public
1012
+ */
1013
+ export interface TokenArg {
1014
+ /** If present, the access token for the requested operation. If not present, use [[IModelHost.getAccessToken]] */
1015
+ readonly accessToken?: AccessToken;
1016
+ }
1017
+ /** Augments a [[SnapshotDbOpenArgs]] or [[OpenBriefcaseArgs]] with a [CloudContainer]($docs/learning/backend/Workspace.md).
1018
+ * The properties are this interface are reserved for internal use only.
1019
+ * @public
1020
+ */
1021
+ export interface CloudContainerArgs {
1022
+ /** @internal */
1023
+ container?: CloudSqlite.CloudContainer;
1024
+ }
1025
+ /** Options to open a [SnapshotDb]($backend).
1026
+ * @public
1027
+ */
1028
+ export type SnapshotDbOpenArgs = SnapshotOpenOptions & CloudContainerArgs;
1029
+ /**
1030
+ * Arguments to open a BriefcaseDb
1031
+ * @public
1032
+ */
1033
+ export type OpenBriefcaseArgs = OpenBriefcaseProps & CloudContainerArgs;
1034
+ /**
1035
+ * A local copy of an iModel from iModelHub that can pull and potentially push changesets.
1036
+ * BriefcaseDb raises a set of events to allow apps and subsystems to track its object life cycle, including [[onOpen]] and [[onOpened]].
1037
+ * @public
1038
+ */
1039
+ export declare class BriefcaseDb extends IModelDb {
1040
+ /** Manages local changes to this briefcase. */
1041
+ readonly txns: TxnManager;
1042
+ /** override superclass method */
1043
+ get isBriefcase(): boolean;
1044
+ readonly briefcaseId: BriefcaseId;
1045
+ /**
1046
+ * Event raised just before a BriefcaseDb is opened. Supplies the arguments that will be used to open the BriefcaseDb.
1047
+ * Throw an exception to stop the open.
1048
+ *
1049
+ * **Example:**
1050
+ * ``` ts
1051
+ * [[include:BriefcaseDb.onOpen]]
1052
+ * ```
1053
+ */
1054
+ static readonly onOpen: BeEvent<(_args: OpenBriefcaseArgs) => void>;
1055
+ /**
1056
+ * Event raised just after a BriefcaseDb is opened. Supplies the newly opened BriefcaseDb and the arguments that were used to open it.
1057
+ *
1058
+ * **Example:**
1059
+ * ``` ts
1060
+ * [[include:BriefcaseDb.onOpened]]
1061
+ * ```
1062
+ */
1063
+ static readonly onOpened: BeEvent<(_iModelDb: BriefcaseDb, _args: OpenBriefcaseArgs) => void>;
1064
+ /** @alpha */
1065
+ static readonly onCodeServiceCreated: BeEvent<(service: CodeService) => void>;
1066
+ static findByKey(key: string): BriefcaseDb;
1067
+ static tryFindByKey(key: string): BriefcaseDb | undefined;
1068
+ /**
1069
+ * The Guid that identifies the *context* that owns this iModel.
1070
+ * GuidString | undefined for the superclass, but required for BriefcaseDb
1071
+ * */
1072
+ get iTwinId(): GuidString;
1073
+ /**
1074
+ * Determine whether this BriefcaseDb should use a lock server.
1075
+ * All must be true:
1076
+ * - file is open for write
1077
+ * - has an assigned briefcaseId
1078
+ * - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
1079
+ */
1080
+ protected get useLockServer(): boolean;
1081
+ protected constructor(args: {
1082
+ nativeDb: IModelJsNative.DgnDb;
1083
+ key: string;
1084
+ openMode: OpenMode;
1085
+ briefcaseId: number;
1086
+ });
1087
+ /** Upgrades the profile or domain schemas. File must be closed before this call and is always left closed. */
1088
+ private static doUpgrade;
1089
+ /** Upgrades the schemas in the iModel based on the current version of the software. Follows a sequence of operations -
1090
+ * * Acquires a schema lock to prevent other users from making any other changes while upgrade is happening
1091
+ * * Updates the local briefcase with the schema changes.
1092
+ * * Pushes the resulting changeset(s) to iModelHub.
1093
+ * Note that the upgrade requires that the local briefcase be closed, and may result in one or two change sets depending on whether both
1094
+ * profile and domain schemas need to get upgraded.
1095
+ * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1096
+ */
1097
+ static upgradeSchemas(briefcase: OpenBriefcaseArgs): Promise<void>;
1098
+ /** Open a briefcase file and return a new BriefcaseDb to interact with it.
1099
+ * @param args parameters that specify the file name, and options for opening the briefcase file
1100
+ */
1101
+ static open(args: OpenBriefcaseArgs): Promise<BriefcaseDb>;
1102
+ private closeAndReopen;
1103
+ /** Pull and apply changesets from iModelHub */
1104
+ pullChanges(arg?: PullChangesArgs): Promise<void>;
1105
+ /** Push changes to iModelHub. */
1106
+ pushChanges(arg: PushChangesArgs): Promise<void>;
1107
+ }
1108
+ /** A *snapshot* iModel database file that is used for archival and data transfer purposes.
1109
+ * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1110
+ * @see [About IModelDb]($docs/learning/backend/IModelDb.md)
1111
+ * @public
1112
+ */
1113
+ export declare class SnapshotDb extends IModelDb {
1114
+ get isSnapshot(): boolean;
1115
+ private _refreshSas;
1116
+ private _createClassViewsOnClose?;
1117
+ private constructor();
1118
+ static findByKey(key: string): SnapshotDb;
1119
+ static tryFindByKey(key: string): SnapshotDb | undefined;
1120
+ /** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
1121
+ * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1122
+ * > Note: A *snapshot* cannot be modified after [[close]] is called.
1123
+ * @param filePath The file that will contain the new iModel *snapshot*
1124
+ * @param options The parameters that define the new iModel *snapshot*
1125
+ * @returns A writeable SnapshotDb
1126
+ * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1127
+ */
1128
+ static createEmpty(filePath: LocalFileName, options: CreateEmptySnapshotIModelProps): SnapshotDb;
1129
+ /** Create a local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file, using this iModel as a *seed* or starting point.
1130
+ * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1131
+ * > Note: A *snapshot* cannot be modified after [[close]] is called.
1132
+ * @param iModelDb The snapshot will be initialized from the current contents of this iModelDb
1133
+ * @param snapshotFile The file that will contain the new iModel *snapshot*
1134
+ * @param options Optional properties that determine how the snapshot iModel is created.
1135
+ * @returns A writeable SnapshotDb
1136
+ * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1137
+ */
1138
+ static createFrom(iModelDb: IModelDb, snapshotFile: string, options?: CreateSnapshotIModelProps): SnapshotDb;
1139
+ /** open this SnapshotDb read/write, strictly to apply incoming changesets. Used for creating new checkpoints.
1140
+ * @internal
1141
+ */
1142
+ static openForApplyChangesets(path: LocalFileName, props?: SnapshotDbOpenArgs): SnapshotDb;
1143
+ /** Open a read-only iModel *snapshot*.
1144
+ * @param path the full path of the snapshot iModel file to open.
1145
+ * @param props options for opening snapshot
1146
+ * @see [[close]]
1147
+ * @throws [[IModelError]] If the file is not found or is not a valid *snapshot*.
1148
+ */
1149
+ static openFile(path: LocalFileName, opts?: SnapshotDbOpenArgs): SnapshotDb;
1150
+ /** Open a previously downloaded V1 checkpoint file.
1151
+ * @note The key is generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1152
+ * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1153
+ * servicing the same checkpoint.
1154
+ * @internal
1155
+ */
1156
+ static openCheckpointV1(fileName: LocalFileName, checkpoint: CheckpointProps): SnapshotDb;
1157
+ /** Open a V2 *checkpoint*, a special form of snapshot iModel that represents a read-only snapshot of an iModel from iModelHub at a particular point in time.
1158
+ * > Note: The checkpoint daemon must already be running and a checkpoint must already exist in iModelHub's storage *before* this function is called.
1159
+ * @param checkpoint The checkpoint to open
1160
+ * @note The key generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1161
+ * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1162
+ * servicing the same checkpoint.
1163
+ * @throws [[IModelError]] If the checkpoint is not found in iModelHub or the checkpoint daemon is not supported in the current environment.
1164
+ * @internal
1165
+ */
1166
+ static openCheckpointV2(checkpoint: CheckpointProps): Promise<SnapshotDb>;
1167
+ /** Used to refresh the container sasToken using the current user's accessToken
1168
+ * @internal
1169
+ */
1170
+ refreshContainerSas(userAccessToken: AccessToken): Promise<void>;
1171
+ /** @internal */
1172
+ beforeClose(): void;
1173
+ }
1174
+ /**
1175
+ * Standalone iModels are read/write files that are not associated with an iTwin or managed by iModelHub.
1176
+ * They are relevant only for testing, or for small-scale single-user scenarios.
1177
+ * Standalone iModels are designed such that the API for Standalone iModels and Briefcase
1178
+ * iModels (those synchronized with iModelHub) are as similar and consistent as possible.
1179
+ * This leads to a straightforward process where the a user starts with StandaloneDb and can
1180
+ * optionally choose to upgrade to an iTwin.
1181
+ *
1182
+ * Some additional details. Standalone iModels:
1183
+ * - always have [Guid.empty]($bentley) for their iTwinId (they are "unassociated" files)
1184
+ * - always have BriefcaseId === [BriefcaseIdValue.Unassigned]($common)
1185
+ * - are connected to the frontend via [BriefcaseConnection.openStandalone]($frontend)
1186
+ * - may be opened without supplying any user credentials
1187
+ * - may be opened read/write
1188
+ * - cannot apply a changeset to nor generate a changesets (since there is no timeline from which to get/push changesets)
1189
+ * @public
1190
+ */
1191
+ export declare class StandaloneDb extends BriefcaseDb {
1192
+ get isStandalone(): boolean;
1193
+ protected get useLockServer(): boolean;
1194
+ static findByKey(key: string): StandaloneDb;
1195
+ static tryFindByKey(key: string): StandaloneDb | undefined;
1196
+ /** Create an *empty* standalone iModel.
1197
+ * @param filePath The file path for the iModel
1198
+ * @param args The parameters that define the new iModel
1199
+ */
1200
+ static createEmpty(filePath: LocalFileName, args: CreateEmptyStandaloneIModelProps): StandaloneDb;
1201
+ /**
1202
+ * Upgrades the schemas in the standalone iModel file.
1203
+ * Note that the upgrade requires that the file be closed, and will leave it back in the closed state.
1204
+ * @param filePath Full path name of the standalone iModel file.
1205
+ * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1206
+ * @see [[StandaloneDb.validateSchemas]]
1207
+ */
1208
+ static upgradeStandaloneSchemas(filePath: LocalFileName): void;
1209
+ /** Open a standalone iModel file.
1210
+ * @param filePath The path of the standalone iModel file.
1211
+ * @param openMode Optional open mode for the standalone iModel. The default is read/write.
1212
+ * @throws [[IModelError]] if the file is not a standalone iModel.
1213
+ * @see [BriefcaseConnection.openStandalone]($frontend) to open a StandaloneDb from the frontend
1214
+ */
1215
+ static openFile(filePath: LocalFileName, openMode?: OpenMode, options?: SnapshotDbOpenArgs): StandaloneDb;
1216
+ }
1214
1217
  //# sourceMappingURL=IModelDb.d.ts.map