@itwin/core-backend 4.0.0-dev.8 → 4.0.0-dev.81

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