@itwin/core-backend 3.7.13 → 3.7.15

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