@itwin/core-backend 3.6.0-dev.51 → 3.6.0-dev.53

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