@itwin/core-backend 3.4.0-dev.47 → 3.4.0-dev.48

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 (219) hide show
  1. package/lib/cjs/AliCloudStorageService.d.ts +17 -17
  2. package/lib/cjs/AliCloudStorageService.js +68 -68
  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 +82 -82
  8. package/lib/cjs/BackendLoggerCategory.js +90 -90
  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 +165 -165
  14. package/lib/cjs/BriefcaseManager.js +405 -405
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +153 -153
  17. package/lib/cjs/Category.js +243 -243
  18. package/lib/cjs/Category.js.map +1 -1
  19. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  20. package/lib/cjs/ChangeSummaryManager.js +445 -445
  21. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  22. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  23. package/lib/cjs/ChangedElementsDb.js +165 -165
  24. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  25. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  26. package/lib/cjs/ChangedElementsManager.js +88 -88
  27. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  28. package/lib/cjs/CheckpointManager.d.ts +122 -122
  29. package/lib/cjs/CheckpointManager.js +354 -354
  30. package/lib/cjs/CheckpointManager.js.map +1 -1
  31. package/lib/cjs/ClassRegistry.d.ts +71 -71
  32. package/lib/cjs/ClassRegistry.js +213 -213
  33. package/lib/cjs/ClassRegistry.js.map +1 -1
  34. package/lib/cjs/CloudSqlite.d.ts +328 -328
  35. package/lib/cjs/CloudSqlite.js +135 -135
  36. package/lib/cjs/CloudSqlite.js.map +1 -1
  37. package/lib/cjs/CloudStorageBackend.d.ts +46 -46
  38. package/lib/cjs/CloudStorageBackend.js +164 -164
  39. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  40. package/lib/cjs/CodeService.d.ts +391 -391
  41. package/lib/cjs/CodeService.js +61 -61
  42. package/lib/cjs/CodeService.js.map +1 -1
  43. package/lib/cjs/CodeSpecs.d.ts +50 -50
  44. package/lib/cjs/CodeSpecs.js +112 -112
  45. package/lib/cjs/CodeSpecs.js.map +1 -1
  46. package/lib/cjs/ConcurrentQuery.d.ts +11 -11
  47. package/lib/cjs/ConcurrentQuery.js +30 -30
  48. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  49. package/lib/cjs/CustomViewState3dCreator.d.ts +32 -32
  50. package/lib/cjs/CustomViewState3dCreator.js +99 -99
  51. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  52. package/lib/cjs/DevTools.d.ts +71 -71
  53. package/lib/cjs/DevTools.js +154 -154
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.d.ts +106 -106
  56. package/lib/cjs/DisplayStyle.js +256 -256
  57. package/lib/cjs/DisplayStyle.js.map +1 -1
  58. package/lib/cjs/ECDb.d.ts +191 -191
  59. package/lib/cjs/ECDb.js +350 -350
  60. package/lib/cjs/ECDb.js.map +1 -1
  61. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  62. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  63. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  64. package/lib/cjs/ECSqlStatement.d.ts +466 -466
  65. package/lib/cjs/ECSqlStatement.js +791 -791
  66. package/lib/cjs/ECSqlStatement.js.map +1 -1
  67. package/lib/cjs/Element.d.ts +1109 -1109
  68. package/lib/cjs/Element.js +1421 -1421
  69. package/lib/cjs/Element.js.map +1 -1
  70. package/lib/cjs/ElementAspect.d.ts +156 -156
  71. package/lib/cjs/ElementAspect.js +178 -178
  72. package/lib/cjs/ElementAspect.js.map +1 -1
  73. package/lib/cjs/ElementGraphics.d.ts +9 -9
  74. package/lib/cjs/ElementGraphics.js +41 -41
  75. package/lib/cjs/ElementGraphics.js.map +1 -1
  76. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  77. package/lib/cjs/ElementTreeWalker.js +409 -409
  78. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  79. package/lib/cjs/Entity.d.ts +76 -76
  80. package/lib/cjs/Entity.js +82 -82
  81. package/lib/cjs/Entity.js.map +1 -1
  82. package/lib/cjs/ExportGraphics.d.ts +317 -317
  83. package/lib/cjs/ExportGraphics.js +208 -208
  84. package/lib/cjs/ExportGraphics.js.map +1 -1
  85. package/lib/cjs/ExternalSource.d.ts +94 -94
  86. package/lib/cjs/ExternalSource.js +125 -125
  87. package/lib/cjs/ExternalSource.js.map +1 -1
  88. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  89. package/lib/cjs/GeoCoordConfig.js +82 -82
  90. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  91. package/lib/cjs/GeometrySummary.d.ts +4 -4
  92. package/lib/cjs/GeometrySummary.js +380 -380
  93. package/lib/cjs/GeometrySummary.js.map +1 -1
  94. package/lib/cjs/HubMock.d.ts +93 -93
  95. package/lib/cjs/HubMock.js +190 -190
  96. package/lib/cjs/HubMock.js.map +1 -1
  97. package/lib/cjs/IModelCloneContext.d.ts +85 -85
  98. package/lib/cjs/IModelCloneContext.js +150 -150
  99. package/lib/cjs/IModelCloneContext.js.map +1 -1
  100. package/lib/cjs/IModelDb.d.ts +1164 -1164
  101. package/lib/cjs/IModelDb.js +2321 -2321
  102. package/lib/cjs/IModelDb.js.map +1 -1
  103. package/lib/cjs/IModelHost.d.ts +347 -347
  104. package/lib/cjs/IModelHost.js +457 -457
  105. package/lib/cjs/IModelHost.js.map +1 -1
  106. package/lib/cjs/IModelJsFs.d.ts +62 -62
  107. package/lib/cjs/IModelJsFs.js +140 -140
  108. package/lib/cjs/IModelJsFs.js.map +1 -1
  109. package/lib/cjs/IpcHost.d.ts +98 -98
  110. package/lib/cjs/IpcHost.js +234 -234
  111. package/lib/cjs/IpcHost.js.map +1 -1
  112. package/lib/cjs/LineStyle.d.ts +311 -311
  113. package/lib/cjs/LineStyle.js +295 -295
  114. package/lib/cjs/LineStyle.js.map +1 -1
  115. package/lib/cjs/LocalHub.d.ts +162 -162
  116. package/lib/cjs/LocalHub.js +587 -587
  117. package/lib/cjs/LocalHub.js.map +1 -1
  118. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  119. package/lib/cjs/LocalhostIpcHost.js +81 -81
  120. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  121. package/lib/cjs/Material.d.ts +103 -103
  122. package/lib/cjs/Material.js +147 -147
  123. package/lib/cjs/Material.js.map +1 -1
  124. package/lib/cjs/Model.d.ts +386 -386
  125. package/lib/cjs/Model.js +468 -468
  126. package/lib/cjs/Model.js.map +1 -1
  127. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  128. package/lib/cjs/NativeAppStorage.js +202 -202
  129. package/lib/cjs/NativeAppStorage.js.map +1 -1
  130. package/lib/cjs/NativeHost.d.ts +52 -52
  131. package/lib/cjs/NativeHost.js +168 -168
  132. package/lib/cjs/NativeHost.js.map +1 -1
  133. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  134. package/lib/cjs/NavigationRelationship.js +225 -225
  135. package/lib/cjs/NavigationRelationship.js.map +1 -1
  136. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  137. package/lib/cjs/PromiseMemoizer.js +95 -95
  138. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  139. package/lib/cjs/PropertyStore.d.ts +132 -132
  140. package/lib/cjs/PropertyStore.js +11 -11
  141. package/lib/cjs/PropertyStore.js.map +1 -1
  142. package/lib/cjs/Relationship.d.ts +400 -400
  143. package/lib/cjs/Relationship.js +465 -465
  144. package/lib/cjs/Relationship.js.map +1 -1
  145. package/lib/cjs/RpcBackend.d.ts +28 -28
  146. package/lib/cjs/RpcBackend.js +126 -126
  147. package/lib/cjs/RpcBackend.js.map +1 -1
  148. package/lib/cjs/SQLiteDb.d.ts +219 -219
  149. package/lib/cjs/SQLiteDb.js +214 -214
  150. package/lib/cjs/SQLiteDb.js.map +1 -1
  151. package/lib/cjs/Schema.d.ts +55 -55
  152. package/lib/cjs/Schema.js +83 -83
  153. package/lib/cjs/Schema.js.map +1 -1
  154. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  155. package/lib/cjs/ServerBasedLocks.js +168 -168
  156. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  157. package/lib/cjs/SqliteStatement.d.ts +283 -283
  158. package/lib/cjs/SqliteStatement.js +448 -448
  159. package/lib/cjs/SqliteStatement.js.map +1 -1
  160. package/lib/cjs/Texture.d.ts +58 -58
  161. package/lib/cjs/Texture.js +82 -82
  162. package/lib/cjs/Texture.js.map +1 -1
  163. package/lib/cjs/TxnManager.d.ts +202 -202
  164. package/lib/cjs/TxnManager.js +353 -353
  165. package/lib/cjs/TxnManager.js.map +1 -1
  166. package/lib/cjs/ViewDefinition.d.ts +435 -435
  167. package/lib/cjs/ViewDefinition.js +629 -629
  168. package/lib/cjs/ViewDefinition.js.map +1 -1
  169. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  170. package/lib/cjs/ViewStateHydrator.js +103 -103
  171. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  172. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  173. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  174. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  175. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  176. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  177. package/lib/cjs/core-backend.d.ts +178 -178
  178. package/lib/cjs/core-backend.js +198 -198
  179. package/lib/cjs/core-backend.js.map +1 -1
  180. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  181. package/lib/cjs/domains/FunctionalElements.js +145 -145
  182. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  183. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  184. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  185. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  186. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  187. package/lib/cjs/domains/GenericElements.js +263 -263
  188. package/lib/cjs/domains/GenericElements.js.map +1 -1
  189. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  190. package/lib/cjs/domains/GenericSchema.js +28 -28
  191. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  192. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  193. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  194. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  195. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +45 -45
  196. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +262 -262
  197. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  198. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +20 -20
  199. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +195 -195
  200. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  201. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  202. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +165 -165
  203. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  204. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  205. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  206. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  207. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  208. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  209. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  210. package/lib/cjs/workspace/Settings.d.ts +186 -186
  211. package/lib/cjs/workspace/Settings.js +152 -152
  212. package/lib/cjs/workspace/Settings.js.map +1 -1
  213. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  214. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  215. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  216. package/lib/cjs/workspace/Workspace.d.ts +405 -405
  217. package/lib/cjs/workspace/Workspace.js +539 -539
  218. package/lib/cjs/workspace/Workspace.js.map +1 -1
  219. package/package.json +11 -11
@@ -1,1165 +1,1165 @@
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, 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
- }
736
- /** The collection of elements in an [[IModelDb]].
737
- * @public
738
- */
739
- class Elements {
740
- private _iModel;
741
- /** @internal */
742
- constructor(_iModel: IModelDb);
743
- /** Read element data from the iModel as JSON
744
- * @param elementIdArg a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
745
- * @returns The JSON properties of the element.
746
- * @throws [[IModelError]] if the element is not found or cannot be loaded.
747
- * @see tryGetElementJson
748
- * @internal
749
- */
750
- getElementJson<T extends ElementProps>(elementId: ElementLoadProps): T;
751
- /** Read element data from the iModel as JSON
752
- * @param loadProps - a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
753
- * @returns The JSON properties of the element or `undefined` if the element is not found.
754
- * @throws [[IModelError]] if the element exists, but cannot be loaded.
755
- * @see getElementJson
756
- */
757
- private tryGetElementJson;
758
- /** Get properties of an Element by Id, FederationGuid, or Code
759
- * @throws [[IModelError]] if the element is not found or cannot be loaded.
760
- * @see tryGetElementProps
761
- */
762
- getElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): T;
763
- /** Get properties of an Element by Id, FederationGuid, or Code
764
- * @returns The properties of the element or `undefined` if the element is not found.
765
- * @throws [[IModelError]] if the element exists, but cannot be loaded.
766
- * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
767
- * @see getElementProps
768
- */
769
- tryGetElementProps<T extends ElementProps>(elementId: Id64String | GuidString | Code | ElementLoadProps): T | undefined;
770
- /** Get an element by Id, FederationGuid, or Code
771
- * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
772
- * @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.
773
- * @throws [[IModelError]] if the element is not found, cannot be loaded, or fails validation when `elementClass` is specified.
774
- * @see tryGetElement
775
- */
776
- getElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T;
777
- /** Get an element by Id, FederationGuid, or Code
778
- * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
779
- * @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.
780
- * @returns The element or `undefined` if the element is not found or fails validation when `elementClass` is specified.
781
- * @throws [[IModelError]] if the element exists, but cannot be loaded.
782
- * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
783
- * @see getElement
784
- */
785
- tryGetElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T | undefined;
786
- /** Query for the Id of the element that has a specified code.
787
- * This method is for the case where you know the element's Code.
788
- * If you only know the code *value*, then in the simplest case, you can query on that
789
- * and filter the results.
790
- * In the simple case, call [[IModelDb.queryEntityIds]], specifying the code value in the where clause of the query params.
791
- * Or, you can execute an ECSQL select statement. See
792
- * [frequently used ECSQL queries]($docs/learning/backend/ECSQL-queries.md) for an example.
793
- * @param code The code to look for
794
- * @returns The element that uses the code or undefined if the code is not used.
795
- * @throws IModelError if the code is invalid
796
- */
797
- queryElementIdByCode(code: Required<CodeProps>): Id64String | undefined;
798
- /** Query for the last modified time of the specified element.
799
- * @internal
800
- */
801
- queryLastModifiedTime(elementId: Id64String): string;
802
- /** Create a new instance of an element.
803
- * @param elProps The properties of the new element.
804
- * @throws [[IModelError]] if there is a problem creating the element.
805
- */
806
- createElement<T extends Element>(elProps: ElementProps): T;
807
- /** Insert a new element into the iModel.
808
- * @param elProps The properties of the new element.
809
- * @returns The newly inserted element's Id.
810
- * @throws [[IModelError]] if unable to insert the element.
811
- */
812
- insertElement(elProps: ElementProps): Id64String;
813
- /** Update some properties of an existing element.
814
- * 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`.
815
- * To keep an individual element property unchanged, it should either be excluded from the `elProps` parameter or set to its current value.
816
- * @param elProps the properties of the element to update.
817
- * @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`.
818
- * @throws [[IModelError]] if unable to update the element.
819
- */
820
- updateElement(elProps: ElementProps): void;
821
- /** Delete one or more elements from this iModel.
822
- * @param ids The set of Ids of the element(s) to be deleted
823
- * @throws [[IModelError]]
824
- * @see deleteDefinitionElements
825
- */
826
- deleteElement(ids: Id64Arg): void;
827
- /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
828
- * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
829
- * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
830
- * This method performs those expensive checks and then calls *delete* if not referenced.
831
- * @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
832
- * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
833
- * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
834
- * @see deleteElement
835
- * @beta
836
- */
837
- deleteDefinitionElements(definitionElementIds: Id64Array): Id64Set;
838
- /** Query for the child elements of the specified element.
839
- * @returns Returns an array of child element identifiers.
840
- * @throws [[IModelError]]
841
- */
842
- queryChildren(elementId: Id64String): Id64String[];
843
- /** Query for the parent of the specified element.
844
- * @param elementId The element to check for a parent
845
- * @returns The identifier of the element's parent or undefined if the element has no parent
846
- * @throws [[IModelError]] if the element does not exist
847
- */
848
- queryParent(elementId: Id64String): Id64String | undefined;
849
- /** Returns true if the specified Element has a sub-model.
850
- * @see [[IModelDb.Models.getSubModel]]
851
- */
852
- hasSubModel(elementId: Id64String): boolean;
853
- /** Get the root subject element. */
854
- getRootSubject(): Subject;
855
- /** Query for aspects of a particular class (polymorphically) associated with this element.
856
- * @throws [[IModelError]]
857
- * @note Most cases should use the [[getAspects]] wrapper rather than calling this method directly.
858
- * @internal
859
- */
860
- _queryAspects(elementId: Id64String, fromClassFullName: string, excludedClassFullNames?: Set<string>): ElementAspect[];
861
- /** Query for aspect by ECInstanceId
862
- * @throws [[IModelError]]
863
- */
864
- private _queryAspect;
865
- /** Get a single ElementAspect by its instance Id.
866
- * @throws [[IModelError]]
867
- */
868
- getAspect(aspectInstanceId: Id64String): ElementAspect;
869
- /** Get the ElementAspect instances that are owned by the specified element.
870
- * @param elementId Get ElementAspects associated with this Element
871
- * @param aspectClassFullName Optionally filter ElementAspects polymorphically by this class name
872
- * @throws [[IModelError]]
873
- */
874
- getAspects(elementId: Id64String, aspectClassFullName?: string): ElementAspect[];
875
- /** Insert a new ElementAspect into the iModel.
876
- * @param aspectProps The properties of the new ElementAspect.
877
- * @throws [[IModelError]] if unable to insert the ElementAspect.
878
- */
879
- insertAspect(aspectProps: ElementAspectProps): void;
880
- /** Update an exist ElementAspect within the iModel.
881
- * @param aspectProps The properties to use to update the ElementAspect.
882
- * @throws [[IModelError]] if unable to update the ElementAspect.
883
- */
884
- updateAspect(aspectProps: ElementAspectProps): void;
885
- /** Delete one or more ElementAspects from this iModel.
886
- * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
887
- * @throws [[IModelError]] if unable to delete the ElementAspect.
888
- */
889
- deleteAspect(aspectInstanceIds: Id64Arg): void;
890
- }
891
- /** The collection of views in an [[IModelDb]].
892
- * @public
893
- */
894
- class Views {
895
- private _iModel;
896
- /** @internal */
897
- constructor(_iModel: IModelDb);
898
- /** Query for the array of ViewDefinitionProps of the specified class and matching the specified IsPrivate setting.
899
- * @param className Query for view definitions of this class.
900
- * @param wantPrivate If true, include private view definitions.
901
- */
902
- queryViewDefinitionProps(className?: string, limit?: number, offset?: number, wantPrivate?: boolean): ViewDefinitionProps[];
903
- /** Default parameters for iterating/querying ViewDefinitions. Includes all subclasses of ViewDefinition, excluding only those marked 'private'. */
904
- static readonly defaultQueryParams: ViewQueryParams;
905
- /** Iterate all ViewDefinitions matching the supplied query.
906
- * @param params Specifies the query by which views are selected.
907
- * @param callback Function invoked for each ViewDefinition matching the query. Return false to terminate iteration, true to continue.
908
- * @returns true if all views were iterated, false if iteration was terminated early due to callback returning false.
909
- *
910
- * **Example: Finding all views of a specific DrawingModel**
911
- * ``` ts
912
- * [[include:IModelDb.Views.iterateViews]]
913
- * ```
914
- */
915
- iterateViews(params: ViewQueryParams, callback: (view: ViewDefinition) => boolean): boolean;
916
- getViewStateData(viewDefinitionId: string, options?: ViewStateLoadProps): ViewStateProps;
917
- private getViewThumbnailArg;
918
- /** Get the thumbnail for a view.
919
- * @param viewDefinitionId The Id of the view for thumbnail
920
- * @returns the ThumbnailProps, or undefined if no thumbnail exists.
921
- */
922
- getThumbnail(viewDefinitionId: Id64String): ThumbnailProps | undefined;
923
- /** Save a thumbnail for a view.
924
- * @param viewDefinitionId The Id of the view for thumbnail
925
- * @param thumbnail The thumbnail data.
926
- * @returns 0 if successful
927
- */
928
- saveThumbnail(viewDefinitionId: Id64String, thumbnail: ThumbnailProps): number;
929
- /** Set the default view property the iModel
930
- * @param viewId The Id of the ViewDefinition to use as the default
931
- */
932
- setDefaultViewId(viewId: Id64String): void;
933
- }
934
- /** Represents the current state of a pollable tile content request.
935
- * Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
936
- * @internal
937
- */
938
- enum TileContentState {
939
- New = 0,
940
- Pending = 1,
941
- Loading = 2
942
- }
943
- /** @internal */
944
- class Tiles {
945
- private _iModel;
946
- /** @internal */
947
- constructor(_iModel: IModelDb);
948
- /** @internal */
949
- requestTileTreeProps(id: string): Promise<IModelTileTreeProps>;
950
- private pollTileContent;
951
- /** @internal */
952
- requestTileContent(treeId: string, tileId: string): Promise<IModelJsNative.TileContent>;
953
- /** @internal */
954
- getTileContent(treeId: string, tileId: string): Promise<Uint8Array>;
955
- }
956
- }
957
- /**
958
- * Argument to a function that can accept a valid access token.
959
- * @public
960
- */
961
- export interface TokenArg {
962
- /** If present, the access token for the requested operation. If not present, use [[IModelHost.getAccessToken]] */
963
- readonly accessToken?: AccessToken;
964
- }
965
- /** Augments a [[SnapshotDbOpenArgs]] or [[OpenBriefcaseArgs]] with a [CloudContainer]($docs/learning/backend/Workspace.md).
966
- * The properties are this interface are reserved for internal use only.
967
- * @public
968
- */
969
- export interface CloudContainerArgs {
970
- /** @internal */
971
- container?: CloudSqlite.CloudContainer;
972
- }
973
- /** Options to open a [SnapshotDb]($backend).
974
- * @public
975
- */
976
- export declare type SnapshotDbOpenArgs = SnapshotOpenOptions & CloudContainerArgs;
977
- /**
978
- * Arguments to open a BriefcaseDb
979
- * @public
980
- */
981
- export declare type OpenBriefcaseArgs = OpenBriefcaseProps & CloudContainerArgs;
982
- /**
983
- * A local copy of an iModel from iModelHub that can pull and potentially push changesets.
984
- * BriefcaseDb raises a set of events to allow apps and subsystems to track its object life cycle, including [[onOpen]] and [[onOpened]].
985
- * @public
986
- */
987
- export declare class BriefcaseDb extends IModelDb {
988
- /** Manages local changes to this briefcase. */
989
- readonly txns: TxnManager;
990
- /** override superclass method */
991
- get isBriefcase(): boolean;
992
- readonly briefcaseId: BriefcaseId;
993
- /**
994
- * Event raised just before a BriefcaseDb is opened. Supplies the arguments that will be used to open the BriefcaseDb.
995
- * Throw an exception to stop the open.
996
- *
997
- * **Example:**
998
- * ``` ts
999
- * [[include:BriefcaseDb.onOpen]]
1000
- * ```
1001
- */
1002
- static readonly onOpen: BeEvent<(_args: OpenBriefcaseArgs) => void>;
1003
- /**
1004
- * Event raised just after a BriefcaseDb is opened. Supplies the newly opened BriefcaseDb and the arguments that were used to open it.
1005
- *
1006
- * **Example:**
1007
- * ``` ts
1008
- * [[include:BriefcaseDb.onOpened]]
1009
- * ```
1010
- */
1011
- static readonly onOpened: BeEvent<(_iModelDb: BriefcaseDb, _args: OpenBriefcaseArgs) => void>;
1012
- /** @alpha */
1013
- static readonly onCodeServiceCreated: BeEvent<(service: CodeService) => void>;
1014
- static findByKey(key: string): BriefcaseDb;
1015
- static tryFindByKey(key: string): BriefcaseDb | undefined;
1016
- /**
1017
- * The Guid that identifies the *context* that owns this iModel.
1018
- * GuidString | undefined for the superclass, but required for BriefcaseDb
1019
- * */
1020
- get iTwinId(): GuidString;
1021
- /**
1022
- * Determine whether this BriefcaseDb should use a lock server.
1023
- * All must be true:
1024
- * - file is open for write
1025
- * - has an assigned briefcaseId
1026
- * - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
1027
- */
1028
- protected get useLockServer(): boolean;
1029
- protected constructor(args: {
1030
- nativeDb: IModelJsNative.DgnDb;
1031
- key: string;
1032
- openMode: OpenMode;
1033
- briefcaseId: number;
1034
- });
1035
- /** Upgrades the profile or domain schemas. File must be closed before this call and is always left closed. */
1036
- private static doUpgrade;
1037
- /** Upgrades the schemas in the iModel based on the current version of the software. Follows a sequence of operations -
1038
- * * Acquires a schema lock to prevent other users from making any other changes while upgrade is happening
1039
- * * Updates the local briefcase with the schema changes.
1040
- * * Pushes the resulting changeset(s) to iModelHub.
1041
- * Note that the upgrade requires that the local briefcase be closed, and may result in one or two change sets depending on whether both
1042
- * profile and domain schemas need to get upgraded.
1043
- * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1044
- */
1045
- static upgradeSchemas(briefcase: OpenBriefcaseArgs): Promise<void>;
1046
- /** Open a briefcase file and return a new BriefcaseDb to interact with it.
1047
- * @param args parameters that specify the file name, and options for opening the briefcase file
1048
- */
1049
- static open(args: OpenBriefcaseArgs): Promise<BriefcaseDb>;
1050
- private closeAndReopen;
1051
- /** Pull and apply changesets from iModelHub */
1052
- pullChanges(arg?: PullChangesArgs): Promise<void>;
1053
- /** Push changes to iModelHub. */
1054
- pushChanges(arg: PushChangesArgs): Promise<void>;
1055
- }
1056
- /** A *snapshot* iModel database file that is used for archival and data transfer purposes.
1057
- * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1058
- * @see [About IModelDb]($docs/learning/backend/IModelDb.md)
1059
- * @public
1060
- */
1061
- export declare class SnapshotDb extends IModelDb {
1062
- get isSnapshot(): boolean;
1063
- private _refreshSas;
1064
- private _createClassViewsOnClose?;
1065
- private constructor();
1066
- static findByKey(key: string): SnapshotDb;
1067
- static tryFindByKey(key: string): SnapshotDb | undefined;
1068
- /** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
1069
- * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1070
- * > Note: A *snapshot* cannot be modified after [[close]] is called.
1071
- * @param filePath The file that will contain the new iModel *snapshot*
1072
- * @param options The parameters that define the new iModel *snapshot*
1073
- * @returns A writeable SnapshotDb
1074
- * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1075
- */
1076
- static createEmpty(filePath: LocalFileName, options: CreateEmptySnapshotIModelProps): SnapshotDb;
1077
- /** Create a local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file, using this iModel as a *seed* or starting point.
1078
- * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1079
- * > Note: A *snapshot* cannot be modified after [[close]] is called.
1080
- * @param iModelDb The snapshot will be initialized from the current contents of this iModelDb
1081
- * @param snapshotFile The file that will contain the new iModel *snapshot*
1082
- * @param options Optional properties that determine how the snapshot iModel is created.
1083
- * @returns A writeable SnapshotDb
1084
- * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1085
- */
1086
- static createFrom(iModelDb: IModelDb, snapshotFile: string, options?: CreateSnapshotIModelProps): SnapshotDb;
1087
- /** open this SnapshotDb read/write, strictly to apply incoming changesets. Used for creating new checkpoints.
1088
- * @internal
1089
- */
1090
- static openForApplyChangesets(path: LocalFileName, props?: SnapshotDbOpenArgs): SnapshotDb;
1091
- /** Open a read-only iModel *snapshot*.
1092
- * @param path the full path of the snapshot iModel file to open.
1093
- * @param props options for opening snapshot
1094
- * @see [[close]]
1095
- * @throws [[IModelError]] If the file is not found or is not a valid *snapshot*.
1096
- */
1097
- static openFile(path: LocalFileName, opts?: SnapshotDbOpenArgs): SnapshotDb;
1098
- /** Open a previously downloaded V1 checkpoint file.
1099
- * @note The key is generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1100
- * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1101
- * servicing the same checkpoint.
1102
- * @internal
1103
- */
1104
- static openCheckpointV1(fileName: LocalFileName, checkpoint: CheckpointProps): SnapshotDb;
1105
- /** 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.
1106
- * > Note: The checkpoint daemon must already be running and a checkpoint must already exist in iModelHub's storage *before* this function is called.
1107
- * @param checkpoint The checkpoint to open
1108
- * @note The key generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1109
- * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1110
- * servicing the same checkpoint.
1111
- * @throws [[IModelError]] If the checkpoint is not found in iModelHub or the checkpoint daemon is not supported in the current environment.
1112
- * @internal
1113
- */
1114
- static openCheckpointV2(checkpoint: CheckpointProps): Promise<SnapshotDb>;
1115
- /** Used to refresh the container sasToken using the current user's accessToken
1116
- * @internal
1117
- */
1118
- refreshContainerSas(userAccessToken: AccessToken): Promise<void>;
1119
- /** @internal */
1120
- beforeClose(): void;
1121
- }
1122
- /**
1123
- * Standalone iModels are read/write files that are not associated with an iTwin or managed by iModelHub.
1124
- * They are relevant only for testing, or for small-scale single-user scenarios.
1125
- * Standalone iModels are designed such that the API for Standalone iModels and Briefcase
1126
- * iModels (those synchronized with iModelHub) are as similar and consistent as possible.
1127
- * This leads to a straightforward process where the a user starts with StandaloneDb and can
1128
- * optionally choose to upgrade to an iTwin.
1129
- *
1130
- * Some additional details. Standalone iModels:
1131
- * - always have [Guid.empty]($bentley) for their iTwinId (they are "unassociated" files)
1132
- * - always have BriefcaseId === [BriefcaseIdValue.Unassigned]($common)
1133
- * - are connected to the frontend via [BriefcaseConnection.openStandalone]($frontend)
1134
- * - may be opened without supplying any user credentials
1135
- * - may be opened read/write
1136
- * - cannot apply a changeset to nor generate a changesets (since there is no timeline from which to get/push changesets)
1137
- * @public
1138
- */
1139
- export declare class StandaloneDb extends BriefcaseDb {
1140
- get isStandalone(): boolean;
1141
- protected get useLockServer(): boolean;
1142
- static findByKey(key: string): StandaloneDb;
1143
- static tryFindByKey(key: string): StandaloneDb | undefined;
1144
- /** Create an *empty* standalone iModel.
1145
- * @param filePath The file path for the iModel
1146
- * @param args The parameters that define the new iModel
1147
- */
1148
- static createEmpty(filePath: LocalFileName, args: CreateEmptyStandaloneIModelProps): StandaloneDb;
1149
- /**
1150
- * Upgrades the schemas in the standalone iModel file.
1151
- * Note that the upgrade requires that the file be closed, and will leave it back in the closed state.
1152
- * @param filePath Full path name of the standalone iModel file.
1153
- * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1154
- * @see [[StandaloneDb.validateSchemas]]
1155
- */
1156
- static upgradeStandaloneSchemas(filePath: LocalFileName): void;
1157
- /** Open a standalone iModel file.
1158
- * @param filePath The path of the standalone iModel file.
1159
- * @param openMode Optional open mode for the standalone iModel. The default is read/write.
1160
- * @throws [[IModelError]] if the file is not a standalone iModel.
1161
- * @see [BriefcaseConnection.openStandalone]($frontend) to open a StandaloneDb from the frontend
1162
- */
1163
- static openFile(filePath: LocalFileName, openMode?: OpenMode, options?: SnapshotDbOpenArgs): StandaloneDb;
1164
- }
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, 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
+ }
736
+ /** The collection of elements in an [[IModelDb]].
737
+ * @public
738
+ */
739
+ class Elements {
740
+ private _iModel;
741
+ /** @internal */
742
+ constructor(_iModel: IModelDb);
743
+ /** Read element data from the iModel as JSON
744
+ * @param elementIdArg a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
745
+ * @returns The JSON properties of the element.
746
+ * @throws [[IModelError]] if the element is not found or cannot be loaded.
747
+ * @see tryGetElementJson
748
+ * @internal
749
+ */
750
+ getElementJson<T extends ElementProps>(elementId: ElementLoadProps): T;
751
+ /** Read element data from the iModel as JSON
752
+ * @param loadProps - a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
753
+ * @returns The JSON properties of the element or `undefined` if the element is not found.
754
+ * @throws [[IModelError]] if the element exists, but cannot be loaded.
755
+ * @see getElementJson
756
+ */
757
+ private tryGetElementJson;
758
+ /** Get properties of an Element by Id, FederationGuid, or Code
759
+ * @throws [[IModelError]] if the element is not found or cannot be loaded.
760
+ * @see tryGetElementProps
761
+ */
762
+ getElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): T;
763
+ /** Get properties of an Element by Id, FederationGuid, or Code
764
+ * @returns The properties of the element or `undefined` if the element is not found.
765
+ * @throws [[IModelError]] if the element exists, but cannot be loaded.
766
+ * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
767
+ * @see getElementProps
768
+ */
769
+ tryGetElementProps<T extends ElementProps>(elementId: Id64String | GuidString | Code | ElementLoadProps): T | undefined;
770
+ /** Get an element by Id, FederationGuid, or Code
771
+ * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
772
+ * @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.
773
+ * @throws [[IModelError]] if the element is not found, cannot be loaded, or fails validation when `elementClass` is specified.
774
+ * @see tryGetElement
775
+ */
776
+ getElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T;
777
+ /** Get an element by Id, FederationGuid, or Code
778
+ * @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
779
+ * @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.
780
+ * @returns The element or `undefined` if the element is not found or fails validation when `elementClass` is specified.
781
+ * @throws [[IModelError]] if the element exists, but cannot be loaded.
782
+ * @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
783
+ * @see getElement
784
+ */
785
+ tryGetElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps, elementClass?: EntityClassType<Element>): T | undefined;
786
+ /** Query for the Id of the element that has a specified code.
787
+ * This method is for the case where you know the element's Code.
788
+ * If you only know the code *value*, then in the simplest case, you can query on that
789
+ * and filter the results.
790
+ * In the simple case, call [[IModelDb.queryEntityIds]], specifying the code value in the where clause of the query params.
791
+ * Or, you can execute an ECSQL select statement. See
792
+ * [frequently used ECSQL queries]($docs/learning/backend/ECSQL-queries.md) for an example.
793
+ * @param code The code to look for
794
+ * @returns The element that uses the code or undefined if the code is not used.
795
+ * @throws IModelError if the code is invalid
796
+ */
797
+ queryElementIdByCode(code: Required<CodeProps>): Id64String | undefined;
798
+ /** Query for the last modified time of the specified element.
799
+ * @internal
800
+ */
801
+ queryLastModifiedTime(elementId: Id64String): string;
802
+ /** Create a new instance of an element.
803
+ * @param elProps The properties of the new element.
804
+ * @throws [[IModelError]] if there is a problem creating the element.
805
+ */
806
+ createElement<T extends Element>(elProps: ElementProps): T;
807
+ /** Insert a new element into the iModel.
808
+ * @param elProps The properties of the new element.
809
+ * @returns The newly inserted element's Id.
810
+ * @throws [[IModelError]] if unable to insert the element.
811
+ */
812
+ insertElement(elProps: ElementProps): Id64String;
813
+ /** Update some properties of an existing element.
814
+ * 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`.
815
+ * To keep an individual element property unchanged, it should either be excluded from the `elProps` parameter or set to its current value.
816
+ * @param elProps the properties of the element to update.
817
+ * @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`.
818
+ * @throws [[IModelError]] if unable to update the element.
819
+ */
820
+ updateElement(elProps: ElementProps): void;
821
+ /** Delete one or more elements from this iModel.
822
+ * @param ids The set of Ids of the element(s) to be deleted
823
+ * @throws [[IModelError]]
824
+ * @see deleteDefinitionElements
825
+ */
826
+ deleteElement(ids: Id64Arg): void;
827
+ /** DefinitionElements can only be deleted if it can be determined that they are not referenced by other Elements.
828
+ * This *usage query* can be expensive since it may involve scanning the GeometryStreams of all GeometricElements.
829
+ * Since [[deleteElement]] does not perform these additional checks, it fails in order to prevent potentially referenced DefinitionElements from being deleted.
830
+ * This method performs those expensive checks and then calls *delete* if not referenced.
831
+ * @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
832
+ * DefinitionElements rather than calling this method separately for each one. Ids that are not valid DefinitionElements will be ignored.
833
+ * @returns An IdSet of the DefinitionElements that are used and were therefore not deleted.
834
+ * @see deleteElement
835
+ * @beta
836
+ */
837
+ deleteDefinitionElements(definitionElementIds: Id64Array): Id64Set;
838
+ /** Query for the child elements of the specified element.
839
+ * @returns Returns an array of child element identifiers.
840
+ * @throws [[IModelError]]
841
+ */
842
+ queryChildren(elementId: Id64String): Id64String[];
843
+ /** Query for the parent of the specified element.
844
+ * @param elementId The element to check for a parent
845
+ * @returns The identifier of the element's parent or undefined if the element has no parent
846
+ * @throws [[IModelError]] if the element does not exist
847
+ */
848
+ queryParent(elementId: Id64String): Id64String | undefined;
849
+ /** Returns true if the specified Element has a sub-model.
850
+ * @see [[IModelDb.Models.getSubModel]]
851
+ */
852
+ hasSubModel(elementId: Id64String): boolean;
853
+ /** Get the root subject element. */
854
+ getRootSubject(): Subject;
855
+ /** Query for aspects of a particular class (polymorphically) associated with this element.
856
+ * @throws [[IModelError]]
857
+ * @note Most cases should use the [[getAspects]] wrapper rather than calling this method directly.
858
+ * @internal
859
+ */
860
+ _queryAspects(elementId: Id64String, fromClassFullName: string, excludedClassFullNames?: Set<string>): ElementAspect[];
861
+ /** Query for aspect by ECInstanceId
862
+ * @throws [[IModelError]]
863
+ */
864
+ private _queryAspect;
865
+ /** Get a single ElementAspect by its instance Id.
866
+ * @throws [[IModelError]]
867
+ */
868
+ getAspect(aspectInstanceId: Id64String): ElementAspect;
869
+ /** Get the ElementAspect instances that are owned by the specified element.
870
+ * @param elementId Get ElementAspects associated with this Element
871
+ * @param aspectClassFullName Optionally filter ElementAspects polymorphically by this class name
872
+ * @throws [[IModelError]]
873
+ */
874
+ getAspects(elementId: Id64String, aspectClassFullName?: string): ElementAspect[];
875
+ /** Insert a new ElementAspect into the iModel.
876
+ * @param aspectProps The properties of the new ElementAspect.
877
+ * @throws [[IModelError]] if unable to insert the ElementAspect.
878
+ */
879
+ insertAspect(aspectProps: ElementAspectProps): void;
880
+ /** Update an exist ElementAspect within the iModel.
881
+ * @param aspectProps The properties to use to update the ElementAspect.
882
+ * @throws [[IModelError]] if unable to update the ElementAspect.
883
+ */
884
+ updateAspect(aspectProps: ElementAspectProps): void;
885
+ /** Delete one or more ElementAspects from this iModel.
886
+ * @param aspectInstanceIds The set of instance Ids of the ElementAspect(s) to be deleted
887
+ * @throws [[IModelError]] if unable to delete the ElementAspect.
888
+ */
889
+ deleteAspect(aspectInstanceIds: Id64Arg): void;
890
+ }
891
+ /** The collection of views in an [[IModelDb]].
892
+ * @public
893
+ */
894
+ class Views {
895
+ private _iModel;
896
+ /** @internal */
897
+ constructor(_iModel: IModelDb);
898
+ /** Query for the array of ViewDefinitionProps of the specified class and matching the specified IsPrivate setting.
899
+ * @param className Query for view definitions of this class.
900
+ * @param wantPrivate If true, include private view definitions.
901
+ */
902
+ queryViewDefinitionProps(className?: string, limit?: number, offset?: number, wantPrivate?: boolean): ViewDefinitionProps[];
903
+ /** Default parameters for iterating/querying ViewDefinitions. Includes all subclasses of ViewDefinition, excluding only those marked 'private'. */
904
+ static readonly defaultQueryParams: ViewQueryParams;
905
+ /** Iterate all ViewDefinitions matching the supplied query.
906
+ * @param params Specifies the query by which views are selected.
907
+ * @param callback Function invoked for each ViewDefinition matching the query. Return false to terminate iteration, true to continue.
908
+ * @returns true if all views were iterated, false if iteration was terminated early due to callback returning false.
909
+ *
910
+ * **Example: Finding all views of a specific DrawingModel**
911
+ * ``` ts
912
+ * [[include:IModelDb.Views.iterateViews]]
913
+ * ```
914
+ */
915
+ iterateViews(params: ViewQueryParams, callback: (view: ViewDefinition) => boolean): boolean;
916
+ getViewStateData(viewDefinitionId: string, options?: ViewStateLoadProps): ViewStateProps;
917
+ private getViewThumbnailArg;
918
+ /** Get the thumbnail for a view.
919
+ * @param viewDefinitionId The Id of the view for thumbnail
920
+ * @returns the ThumbnailProps, or undefined if no thumbnail exists.
921
+ */
922
+ getThumbnail(viewDefinitionId: Id64String): ThumbnailProps | undefined;
923
+ /** Save a thumbnail for a view.
924
+ * @param viewDefinitionId The Id of the view for thumbnail
925
+ * @param thumbnail The thumbnail data.
926
+ * @returns 0 if successful
927
+ */
928
+ saveThumbnail(viewDefinitionId: Id64String, thumbnail: ThumbnailProps): number;
929
+ /** Set the default view property the iModel
930
+ * @param viewId The Id of the ViewDefinition to use as the default
931
+ */
932
+ setDefaultViewId(viewId: Id64String): void;
933
+ }
934
+ /** Represents the current state of a pollable tile content request.
935
+ * Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
936
+ * @internal
937
+ */
938
+ enum TileContentState {
939
+ New = 0,
940
+ Pending = 1,
941
+ Loading = 2
942
+ }
943
+ /** @internal */
944
+ class Tiles {
945
+ private _iModel;
946
+ /** @internal */
947
+ constructor(_iModel: IModelDb);
948
+ /** @internal */
949
+ requestTileTreeProps(id: string): Promise<IModelTileTreeProps>;
950
+ private pollTileContent;
951
+ /** @internal */
952
+ requestTileContent(treeId: string, tileId: string): Promise<IModelJsNative.TileContent>;
953
+ /** @internal */
954
+ getTileContent(treeId: string, tileId: string): Promise<Uint8Array>;
955
+ }
956
+ }
957
+ /**
958
+ * Argument to a function that can accept a valid access token.
959
+ * @public
960
+ */
961
+ export interface TokenArg {
962
+ /** If present, the access token for the requested operation. If not present, use [[IModelHost.getAccessToken]] */
963
+ readonly accessToken?: AccessToken;
964
+ }
965
+ /** Augments a [[SnapshotDbOpenArgs]] or [[OpenBriefcaseArgs]] with a [CloudContainer]($docs/learning/backend/Workspace.md).
966
+ * The properties are this interface are reserved for internal use only.
967
+ * @public
968
+ */
969
+ export interface CloudContainerArgs {
970
+ /** @internal */
971
+ container?: CloudSqlite.CloudContainer;
972
+ }
973
+ /** Options to open a [SnapshotDb]($backend).
974
+ * @public
975
+ */
976
+ export declare type SnapshotDbOpenArgs = SnapshotOpenOptions & CloudContainerArgs;
977
+ /**
978
+ * Arguments to open a BriefcaseDb
979
+ * @public
980
+ */
981
+ export declare type OpenBriefcaseArgs = OpenBriefcaseProps & CloudContainerArgs;
982
+ /**
983
+ * A local copy of an iModel from iModelHub that can pull and potentially push changesets.
984
+ * BriefcaseDb raises a set of events to allow apps and subsystems to track its object life cycle, including [[onOpen]] and [[onOpened]].
985
+ * @public
986
+ */
987
+ export declare class BriefcaseDb extends IModelDb {
988
+ /** Manages local changes to this briefcase. */
989
+ readonly txns: TxnManager;
990
+ /** override superclass method */
991
+ get isBriefcase(): boolean;
992
+ readonly briefcaseId: BriefcaseId;
993
+ /**
994
+ * Event raised just before a BriefcaseDb is opened. Supplies the arguments that will be used to open the BriefcaseDb.
995
+ * Throw an exception to stop the open.
996
+ *
997
+ * **Example:**
998
+ * ``` ts
999
+ * [[include:BriefcaseDb.onOpen]]
1000
+ * ```
1001
+ */
1002
+ static readonly onOpen: BeEvent<(_args: OpenBriefcaseArgs) => void>;
1003
+ /**
1004
+ * Event raised just after a BriefcaseDb is opened. Supplies the newly opened BriefcaseDb and the arguments that were used to open it.
1005
+ *
1006
+ * **Example:**
1007
+ * ``` ts
1008
+ * [[include:BriefcaseDb.onOpened]]
1009
+ * ```
1010
+ */
1011
+ static readonly onOpened: BeEvent<(_iModelDb: BriefcaseDb, _args: OpenBriefcaseArgs) => void>;
1012
+ /** @alpha */
1013
+ static readonly onCodeServiceCreated: BeEvent<(service: CodeService) => void>;
1014
+ static findByKey(key: string): BriefcaseDb;
1015
+ static tryFindByKey(key: string): BriefcaseDb | undefined;
1016
+ /**
1017
+ * The Guid that identifies the *context* that owns this iModel.
1018
+ * GuidString | undefined for the superclass, but required for BriefcaseDb
1019
+ * */
1020
+ get iTwinId(): GuidString;
1021
+ /**
1022
+ * Determine whether this BriefcaseDb should use a lock server.
1023
+ * All must be true:
1024
+ * - file is open for write
1025
+ * - has an assigned briefcaseId
1026
+ * - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
1027
+ */
1028
+ protected get useLockServer(): boolean;
1029
+ protected constructor(args: {
1030
+ nativeDb: IModelJsNative.DgnDb;
1031
+ key: string;
1032
+ openMode: OpenMode;
1033
+ briefcaseId: number;
1034
+ });
1035
+ /** Upgrades the profile or domain schemas. File must be closed before this call and is always left closed. */
1036
+ private static doUpgrade;
1037
+ /** Upgrades the schemas in the iModel based on the current version of the software. Follows a sequence of operations -
1038
+ * * Acquires a schema lock to prevent other users from making any other changes while upgrade is happening
1039
+ * * Updates the local briefcase with the schema changes.
1040
+ * * Pushes the resulting changeset(s) to iModelHub.
1041
+ * Note that the upgrade requires that the local briefcase be closed, and may result in one or two change sets depending on whether both
1042
+ * profile and domain schemas need to get upgraded.
1043
+ * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1044
+ */
1045
+ static upgradeSchemas(briefcase: OpenBriefcaseArgs): Promise<void>;
1046
+ /** Open a briefcase file and return a new BriefcaseDb to interact with it.
1047
+ * @param args parameters that specify the file name, and options for opening the briefcase file
1048
+ */
1049
+ static open(args: OpenBriefcaseArgs): Promise<BriefcaseDb>;
1050
+ private closeAndReopen;
1051
+ /** Pull and apply changesets from iModelHub */
1052
+ pullChanges(arg?: PullChangesArgs): Promise<void>;
1053
+ /** Push changes to iModelHub. */
1054
+ pushChanges(arg: PushChangesArgs): Promise<void>;
1055
+ }
1056
+ /** A *snapshot* iModel database file that is used for archival and data transfer purposes.
1057
+ * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1058
+ * @see [About IModelDb]($docs/learning/backend/IModelDb.md)
1059
+ * @public
1060
+ */
1061
+ export declare class SnapshotDb extends IModelDb {
1062
+ get isSnapshot(): boolean;
1063
+ private _refreshSas;
1064
+ private _createClassViewsOnClose?;
1065
+ private constructor();
1066
+ static findByKey(key: string): SnapshotDb;
1067
+ static tryFindByKey(key: string): SnapshotDb | undefined;
1068
+ /** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
1069
+ * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1070
+ * > Note: A *snapshot* cannot be modified after [[close]] is called.
1071
+ * @param filePath The file that will contain the new iModel *snapshot*
1072
+ * @param options The parameters that define the new iModel *snapshot*
1073
+ * @returns A writeable SnapshotDb
1074
+ * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1075
+ */
1076
+ static createEmpty(filePath: LocalFileName, options: CreateEmptySnapshotIModelProps): SnapshotDb;
1077
+ /** Create a local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file, using this iModel as a *seed* or starting point.
1078
+ * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
1079
+ * > Note: A *snapshot* cannot be modified after [[close]] is called.
1080
+ * @param iModelDb The snapshot will be initialized from the current contents of this iModelDb
1081
+ * @param snapshotFile The file that will contain the new iModel *snapshot*
1082
+ * @param options Optional properties that determine how the snapshot iModel is created.
1083
+ * @returns A writeable SnapshotDb
1084
+ * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
1085
+ */
1086
+ static createFrom(iModelDb: IModelDb, snapshotFile: string, options?: CreateSnapshotIModelProps): SnapshotDb;
1087
+ /** open this SnapshotDb read/write, strictly to apply incoming changesets. Used for creating new checkpoints.
1088
+ * @internal
1089
+ */
1090
+ static openForApplyChangesets(path: LocalFileName, props?: SnapshotDbOpenArgs): SnapshotDb;
1091
+ /** Open a read-only iModel *snapshot*.
1092
+ * @param path the full path of the snapshot iModel file to open.
1093
+ * @param props options for opening snapshot
1094
+ * @see [[close]]
1095
+ * @throws [[IModelError]] If the file is not found or is not a valid *snapshot*.
1096
+ */
1097
+ static openFile(path: LocalFileName, opts?: SnapshotDbOpenArgs): SnapshotDb;
1098
+ /** Open a previously downloaded V1 checkpoint file.
1099
+ * @note The key is generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1100
+ * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1101
+ * servicing the same checkpoint.
1102
+ * @internal
1103
+ */
1104
+ static openCheckpointV1(fileName: LocalFileName, checkpoint: CheckpointProps): SnapshotDb;
1105
+ /** 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.
1106
+ * > Note: The checkpoint daemon must already be running and a checkpoint must already exist in iModelHub's storage *before* this function is called.
1107
+ * @param checkpoint The checkpoint to open
1108
+ * @note The key generated by this call is predictable and is formed from the IModelId and ChangeSetId.
1109
+ * This is so every backend working on the same checkpoint will use the same key, to permit multiple backends
1110
+ * servicing the same checkpoint.
1111
+ * @throws [[IModelError]] If the checkpoint is not found in iModelHub or the checkpoint daemon is not supported in the current environment.
1112
+ * @internal
1113
+ */
1114
+ static openCheckpointV2(checkpoint: CheckpointProps): Promise<SnapshotDb>;
1115
+ /** Used to refresh the container sasToken using the current user's accessToken
1116
+ * @internal
1117
+ */
1118
+ refreshContainerSas(userAccessToken: AccessToken): Promise<void>;
1119
+ /** @internal */
1120
+ beforeClose(): void;
1121
+ }
1122
+ /**
1123
+ * Standalone iModels are read/write files that are not associated with an iTwin or managed by iModelHub.
1124
+ * They are relevant only for testing, or for small-scale single-user scenarios.
1125
+ * Standalone iModels are designed such that the API for Standalone iModels and Briefcase
1126
+ * iModels (those synchronized with iModelHub) are as similar and consistent as possible.
1127
+ * This leads to a straightforward process where the a user starts with StandaloneDb and can
1128
+ * optionally choose to upgrade to an iTwin.
1129
+ *
1130
+ * Some additional details. Standalone iModels:
1131
+ * - always have [Guid.empty]($bentley) for their iTwinId (they are "unassociated" files)
1132
+ * - always have BriefcaseId === [BriefcaseIdValue.Unassigned]($common)
1133
+ * - are connected to the frontend via [BriefcaseConnection.openStandalone]($frontend)
1134
+ * - may be opened without supplying any user credentials
1135
+ * - may be opened read/write
1136
+ * - cannot apply a changeset to nor generate a changesets (since there is no timeline from which to get/push changesets)
1137
+ * @public
1138
+ */
1139
+ export declare class StandaloneDb extends BriefcaseDb {
1140
+ get isStandalone(): boolean;
1141
+ protected get useLockServer(): boolean;
1142
+ static findByKey(key: string): StandaloneDb;
1143
+ static tryFindByKey(key: string): StandaloneDb | undefined;
1144
+ /** Create an *empty* standalone iModel.
1145
+ * @param filePath The file path for the iModel
1146
+ * @param args The parameters that define the new iModel
1147
+ */
1148
+ static createEmpty(filePath: LocalFileName, args: CreateEmptyStandaloneIModelProps): StandaloneDb;
1149
+ /**
1150
+ * Upgrades the schemas in the standalone iModel file.
1151
+ * Note that the upgrade requires that the file be closed, and will leave it back in the closed state.
1152
+ * @param filePath Full path name of the standalone iModel file.
1153
+ * @see ($docs/learning/backend/IModelDb.md#upgrading-schemas-in-an-imodel)
1154
+ * @see [[StandaloneDb.validateSchemas]]
1155
+ */
1156
+ static upgradeStandaloneSchemas(filePath: LocalFileName): void;
1157
+ /** Open a standalone iModel file.
1158
+ * @param filePath The path of the standalone iModel file.
1159
+ * @param openMode Optional open mode for the standalone iModel. The default is read/write.
1160
+ * @throws [[IModelError]] if the file is not a standalone iModel.
1161
+ * @see [BriefcaseConnection.openStandalone]($frontend) to open a StandaloneDb from the frontend
1162
+ */
1163
+ static openFile(filePath: LocalFileName, openMode?: OpenMode, options?: SnapshotDbOpenArgs): StandaloneDb;
1164
+ }
1165
1165
  //# sourceMappingURL=IModelDb.d.ts.map