@itwin/core-backend 4.8.0-dev.9 → 4.9.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +18 -16
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js +16 -15
  5. package/lib/cjs/BackendHubAccess.js.map +1 -1
  6. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  7. package/lib/cjs/BisCoreSchema.js.map +1 -1
  8. package/lib/cjs/BlobContainerService.js.map +1 -1
  9. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  10. package/lib/cjs/BriefcaseManager.js +19 -11
  11. package/lib/cjs/BriefcaseManager.js.map +1 -1
  12. package/lib/cjs/Category.d.ts +0 -6
  13. package/lib/cjs/Category.d.ts.map +1 -1
  14. package/lib/cjs/Category.js +0 -6
  15. package/lib/cjs/Category.js.map +1 -1
  16. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  17. package/lib/cjs/ChangeSummaryManager.js +13 -11
  18. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  19. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
  20. package/lib/cjs/ChangedElementsDb.js +5 -3
  21. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  22. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  23. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  24. package/lib/cjs/ChangesetECAdaptor.js +242 -237
  25. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  26. package/lib/cjs/ChannelControl.d.ts +4 -26
  27. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  28. package/lib/cjs/ChannelControl.js +2 -101
  29. package/lib/cjs/ChannelControl.js.map +1 -1
  30. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  31. package/lib/cjs/CheckpointManager.js +5 -3
  32. package/lib/cjs/CheckpointManager.js.map +1 -1
  33. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  34. package/lib/cjs/ClassRegistry.js +8 -7
  35. package/lib/cjs/ClassRegistry.js.map +1 -1
  36. package/lib/cjs/CloudSqlite.d.ts +1 -1
  37. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  38. package/lib/cjs/CloudSqlite.js +2 -2
  39. package/lib/cjs/CloudSqlite.js.map +1 -1
  40. package/lib/cjs/CodeService.js.map +1 -1
  41. package/lib/cjs/CodeSpecs.js.map +1 -1
  42. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  43. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  44. package/lib/cjs/DevTools.d.ts.map +1 -1
  45. package/lib/cjs/DevTools.js +2 -1
  46. package/lib/cjs/DevTools.js.map +1 -1
  47. package/lib/cjs/DisplayStyle.d.ts +0 -3
  48. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  49. package/lib/cjs/DisplayStyle.js +0 -3
  50. package/lib/cjs/DisplayStyle.js.map +1 -1
  51. package/lib/cjs/ECDb.d.ts +6 -1
  52. package/lib/cjs/ECDb.d.ts.map +1 -1
  53. package/lib/cjs/ECDb.js +19 -14
  54. package/lib/cjs/ECDb.js.map +1 -1
  55. package/lib/cjs/ECSchemaXmlContext.js +2 -2
  56. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  57. package/lib/cjs/ECSqlStatement.d.ts +6 -3
  58. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  59. package/lib/cjs/ECSqlStatement.js +3 -3
  60. package/lib/cjs/ECSqlStatement.js.map +1 -1
  61. package/lib/cjs/Element.d.ts +2 -59
  62. package/lib/cjs/Element.d.ts.map +1 -1
  63. package/lib/cjs/Element.js +7 -63
  64. package/lib/cjs/Element.js.map +1 -1
  65. package/lib/cjs/ElementAspect.d.ts +0 -5
  66. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  67. package/lib/cjs/ElementAspect.js +4 -8
  68. package/lib/cjs/ElementAspect.js.map +1 -1
  69. package/lib/cjs/ElementGraphics.d.ts.map +1 -1
  70. package/lib/cjs/ElementGraphics.js +2 -1
  71. package/lib/cjs/ElementGraphics.js.map +1 -1
  72. package/lib/cjs/ElementTreeWalker.d.ts +19 -0
  73. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  74. package/lib/cjs/ElementTreeWalker.js +23 -9
  75. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  76. package/lib/cjs/Entity.js.map +1 -1
  77. package/lib/cjs/EntityReferences.js.map +1 -1
  78. package/lib/cjs/ExportGraphics.js.map +1 -1
  79. package/lib/cjs/ExternalSource.js.map +1 -1
  80. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  81. package/lib/cjs/GeoCoordConfig.js +2 -1
  82. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  83. package/lib/cjs/GeographicCRSServices.js +2 -2
  84. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  85. package/lib/cjs/GeometrySummary.d.ts.map +1 -1
  86. package/lib/cjs/GeometrySummary.js +49 -48
  87. package/lib/cjs/GeometrySummary.js.map +1 -1
  88. package/lib/cjs/HubMock.js.map +1 -1
  89. package/lib/cjs/IModelCloneContext.js.map +1 -1
  90. package/lib/cjs/IModelDb.d.ts +24 -94
  91. package/lib/cjs/IModelDb.d.ts.map +1 -1
  92. package/lib/cjs/IModelDb.js +196 -151
  93. package/lib/cjs/IModelDb.js.map +1 -1
  94. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  95. package/lib/cjs/IModelElementCloneContext.js +5 -4
  96. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  97. package/lib/cjs/IModelHost.d.ts +5 -3
  98. package/lib/cjs/IModelHost.d.ts.map +1 -1
  99. package/lib/cjs/IModelHost.js +16 -18
  100. package/lib/cjs/IModelHost.js.map +1 -1
  101. package/lib/cjs/IModelJsFs.js.map +1 -1
  102. package/lib/cjs/IpcHost.d.ts.map +1 -1
  103. package/lib/cjs/IpcHost.js +15 -13
  104. package/lib/cjs/IpcHost.js.map +1 -1
  105. package/lib/cjs/LineStyle.js.map +1 -1
  106. package/lib/cjs/LocalHub.d.ts +2 -2
  107. package/lib/cjs/LocalHub.d.ts.map +1 -1
  108. package/lib/cjs/LocalHub.js +18 -18
  109. package/lib/cjs/LocalHub.js.map +1 -1
  110. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  111. package/lib/cjs/LockControl.d.ts +73 -0
  112. package/lib/cjs/LockControl.d.ts.map +1 -0
  113. package/lib/cjs/LockControl.js +11 -0
  114. package/lib/cjs/LockControl.js.map +1 -0
  115. package/lib/cjs/Material.d.ts +2 -5
  116. package/lib/cjs/Material.d.ts.map +1 -1
  117. package/lib/cjs/Material.js +1 -4
  118. package/lib/cjs/Material.js.map +1 -1
  119. package/lib/cjs/Model.d.ts +0 -22
  120. package/lib/cjs/Model.d.ts.map +1 -1
  121. package/lib/cjs/Model.js +5 -26
  122. package/lib/cjs/Model.js.map +1 -1
  123. package/lib/cjs/NativeAppStorage.js.map +1 -1
  124. package/lib/cjs/NativeHost.js.map +1 -1
  125. package/lib/cjs/NavigationRelationship.js.map +1 -1
  126. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  127. package/lib/cjs/PropertyStore.js.map +1 -1
  128. package/lib/cjs/Relationship.d.ts +0 -12
  129. package/lib/cjs/Relationship.d.ts.map +1 -1
  130. package/lib/cjs/Relationship.js +5 -16
  131. package/lib/cjs/Relationship.js.map +1 -1
  132. package/lib/cjs/RpcBackend.js.map +1 -1
  133. package/lib/cjs/SQLiteDb.d.ts +6 -1
  134. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  135. package/lib/cjs/SQLiteDb.js +23 -16
  136. package/lib/cjs/SQLiteDb.js.map +1 -1
  137. package/lib/cjs/Schema.js.map +1 -1
  138. package/lib/cjs/SchemaSync.d.ts +3 -0
  139. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  140. package/lib/cjs/SchemaSync.js +24 -11
  141. package/lib/cjs/SchemaSync.js.map +1 -1
  142. package/lib/cjs/SchemaUtils.js +3 -3
  143. package/lib/cjs/SchemaUtils.js.map +1 -1
  144. package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
  145. package/lib/cjs/SqliteChangesetReader.js +2 -2
  146. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  147. package/lib/cjs/SqliteStatement.js +2 -2
  148. package/lib/cjs/SqliteStatement.js.map +1 -1
  149. package/lib/cjs/TextAnnotationElement.js.map +1 -1
  150. package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
  151. package/lib/cjs/TextAnnotationLayout.js.map +1 -1
  152. package/lib/cjs/Texture.js.map +1 -1
  153. package/lib/cjs/TileStorage.js.map +1 -1
  154. package/lib/cjs/TxnManager.d.ts +2 -1
  155. package/lib/cjs/TxnManager.d.ts.map +1 -1
  156. package/lib/cjs/TxnManager.js +4 -2
  157. package/lib/cjs/TxnManager.js.map +1 -1
  158. package/lib/cjs/ViewDefinition.d.ts +1 -18
  159. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  160. package/lib/cjs/ViewDefinition.js +1 -18
  161. package/lib/cjs/ViewDefinition.js.map +1 -1
  162. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  163. package/lib/cjs/ViewStore.d.ts.map +1 -1
  164. package/lib/cjs/ViewStore.js +6 -5
  165. package/lib/cjs/ViewStore.js.map +1 -1
  166. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  167. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
  168. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
  169. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
  170. package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
  171. package/lib/cjs/core-backend.d.ts +2 -1
  172. package/lib/cjs/core-backend.d.ts.map +1 -1
  173. package/lib/cjs/core-backend.js +3 -5
  174. package/lib/cjs/core-backend.js.map +1 -1
  175. package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
  176. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  177. package/lib/cjs/domains/FunctionalElements.js +0 -10
  178. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  179. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  180. package/lib/cjs/domains/FunctionalSchema.js +2 -1
  181. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  182. package/lib/cjs/domains/GenericElements.d.ts +0 -18
  183. package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
  184. package/lib/cjs/domains/GenericElements.js +0 -18
  185. package/lib/cjs/domains/GenericElements.js.map +1 -1
  186. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  187. package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
  188. package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
  189. package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
  190. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
  191. package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
  192. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
  193. package/lib/cjs/internal/ChannelAdmin.js +117 -0
  194. package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
  195. package/lib/cjs/internal/NativePlatform.d.ts +15 -0
  196. package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
  197. package/lib/cjs/internal/NativePlatform.js +49 -0
  198. package/lib/cjs/internal/NativePlatform.js.map +1 -0
  199. package/lib/cjs/internal/NoLocks.d.ts +6 -0
  200. package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
  201. package/lib/cjs/internal/NoLocks.js +31 -0
  202. package/lib/cjs/internal/NoLocks.js.map +1 -0
  203. package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +10 -16
  204. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
  205. package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +29 -18
  206. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
  207. package/lib/cjs/internal/Symbols.d.ts +11 -0
  208. package/lib/cjs/internal/Symbols.d.ts.map +1 -0
  209. package/lib/cjs/internal/Symbols.js +21 -0
  210. package/lib/cjs/internal/Symbols.js.map +1 -0
  211. package/lib/cjs/internal/cross-package.d.ts +4 -0
  212. package/lib/cjs/internal/cross-package.d.ts.map +1 -0
  213. package/lib/cjs/internal/cross-package.js +16 -0
  214. package/lib/cjs/internal/cross-package.js.map +1 -0
  215. package/lib/cjs/internal/workspace/SettingsImpl.d.ts +2 -2
  216. package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -1
  217. package/lib/cjs/internal/workspace/SettingsImpl.js +3 -3
  218. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  219. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +2 -2
  220. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  221. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  222. package/lib/cjs/internal/workspace/WorkspaceImpl.js +31 -27
  223. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  224. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -1
  225. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +2 -1
  226. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  227. package/lib/cjs/rpc/multipart.js.map +1 -1
  228. package/lib/cjs/rpc/tracing.d.ts.map +1 -1
  229. package/lib/cjs/rpc/tracing.js +5 -2
  230. package/lib/cjs/rpc/tracing.js.map +1 -1
  231. package/lib/cjs/rpc/web/logging.js.map +1 -1
  232. package/lib/cjs/rpc/web/request.js.map +1 -1
  233. package/lib/cjs/rpc/web/response.js.map +1 -1
  234. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  235. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
  236. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  237. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +9 -4
  238. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  239. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  240. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -3
  241. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  242. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  243. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  244. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  245. package/lib/cjs/workspace/Settings.d.ts +3 -3
  246. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  247. package/lib/cjs/workspace/Settings.js +1 -1
  248. package/lib/cjs/workspace/Settings.js.map +1 -1
  249. package/lib/cjs/workspace/SettingsSchemas.d.ts +2 -2
  250. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  251. package/lib/cjs/workspace/SettingsSchemas.js +1 -1
  252. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  253. package/lib/cjs/workspace/Workspace.d.ts +4 -4
  254. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  255. package/lib/cjs/workspace/Workspace.js +1 -1
  256. package/lib/cjs/workspace/Workspace.js.map +1 -1
  257. package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -2
  258. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
  259. package/lib/cjs/workspace/WorkspaceEditor.js +1 -1
  260. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  261. package/package.json +13 -13
  262. package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
  263. package/lib/cjs/ServerBasedLocks.js.map +0 -1
  264. package/lib/cjs/internal/ImplementationProhibited.d.ts +0 -44
  265. package/lib/cjs/internal/ImplementationProhibited.d.ts.map +0 -1
  266. package/lib/cjs/internal/ImplementationProhibited.js +0 -51
  267. package/lib/cjs/internal/ImplementationProhibited.js.map +0 -1
@@ -17,6 +17,7 @@ const core_geometry_1 = require("@itwin/core-geometry");
17
17
  const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
18
18
  const BriefcaseManager_1 = require("./BriefcaseManager");
19
19
  const ChannelControl_1 = require("./ChannelControl");
20
+ const ChannelAdmin_1 = require("./internal/ChannelAdmin");
20
21
  const CheckpointManager_1 = require("./CheckpointManager");
21
22
  const ClassRegistry_1 = require("./ClassRegistry");
22
23
  const CloudSqlite_1 = require("./CloudSqlite");
@@ -34,7 +35,7 @@ const IpcHost_1 = require("./IpcHost");
34
35
  const Model_1 = require("./Model");
35
36
  const Relationship_1 = require("./Relationship");
36
37
  const SchemaSync_1 = require("./SchemaSync");
37
- const ServerBasedLocks_1 = require("./ServerBasedLocks");
38
+ const ServerBasedLocks_1 = require("./internal/ServerBasedLocks");
38
39
  const SqliteStatement_1 = require("./SqliteStatement");
39
40
  const TxnManager_1 = require("./TxnManager");
40
41
  const ViewDefinition_1 = require("./ViewDefinition");
@@ -43,21 +44,11 @@ const Settings_1 = require("./workspace/Settings");
43
44
  const Workspace_1 = require("./workspace/Workspace");
44
45
  const WorkspaceImpl_1 = require("./internal/workspace/WorkspaceImpl");
45
46
  const SettingsImpl_1 = require("./internal/workspace/SettingsImpl");
47
+ const NativePlatform_1 = require("./internal/NativePlatform");
48
+ const NoLocks_1 = require("./internal/NoLocks");
49
+ const Symbols_1 = require("./internal/Symbols");
46
50
  // spell:ignore fontid fontmap
47
51
  const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
48
- /** A null-implementation of LockControl that does not attempt to limit access between briefcases. This relies on change-merging to resolve conflicts. */
49
- class NoLocks {
50
- get isServerBased() { return false; }
51
- close() { }
52
- clearAllLocks() { }
53
- holdsExclusiveLock() { return false; }
54
- holdsSharedLock() { return false; }
55
- checkExclusiveLock() { }
56
- checkSharedLock() { }
57
- elementWasCreated() { }
58
- async acquireLocks() { }
59
- async releaseAllLocks() { }
60
- }
61
52
  /** @internal */
62
53
  var BriefcaseLocalValue;
63
54
  (function (BriefcaseLocalValue) {
@@ -96,10 +87,7 @@ class IModelSettings extends SettingsImpl_1.SettingsImpl {
96
87
  class IModelDb extends core_common_1.IModel {
97
88
  /** @alpha */
98
89
  get codeService() { return this._codeService; }
99
- /**
100
- * Get the [[LockControl]] for this iModel.
101
- * @beta
102
- */
90
+ /** The [[LockControl]] that orchestrates [concurrent editing]($docs/learning/backend/ConcurrencyControl.md) of this iModel. */
103
91
  get locks() { return this._locks; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
104
92
  /**
105
93
  * Get the [[Workspace]] for this iModel.
@@ -111,7 +99,7 @@ class IModelDb extends core_common_1.IModel {
111
99
  return this._workspace;
112
100
  }
113
101
  /** Acquire the exclusive schema lock on this iModel.
114
- * > Note: To acquire the schema lock, all other briefcases must first release *all* their locks. No other briefcases
102
+ * @note: To acquire the schema lock, all other briefcases must first release *all* their locks. No other briefcases
115
103
  * will be able to acquire *any* locks while the schema lock is held.
116
104
  */
117
105
  async acquireSchemaLock() {
@@ -123,15 +111,15 @@ class IModelDb extends core_common_1.IModel {
123
111
  }
124
112
  /** @internal */
125
113
  notifyChangesetApplied() {
126
- this.changeset = this.nativeDb.getCurrentChangeset();
114
+ this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
127
115
  this.onChangesetApplied.raiseEvent();
128
116
  }
129
117
  /** @internal */
130
118
  restartDefaultTxn() {
131
- this.nativeDb.restartDefaultTxn();
119
+ this[Symbols_1._nativeDb].restartDefaultTxn();
132
120
  }
133
121
  get fontMap() {
134
- return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this.nativeDb.readFontMap()));
122
+ return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this[Symbols_1._nativeDb].readFontMap()));
135
123
  }
136
124
  /** @internal */
137
125
  clearFontMap() {
@@ -148,7 +136,7 @@ class IModelDb extends core_common_1.IModel {
148
136
  addNewFont(name, type) {
149
137
  this.locks.checkExclusiveLock(core_common_1.IModel.repositoryModelId, "schema", "addNewFont");
150
138
  this.clearFontMap();
151
- return this.nativeDb.addNewFont({ name, type: type ?? core_common_1.FontType.TrueType });
139
+ return this[Symbols_1._nativeDb].addNewFont({ name, type: type ?? core_common_1.FontType.TrueType });
152
140
  }
153
141
  /** Check if this iModel has been opened read-only or not. */
154
142
  get isReadonly() { return this.openMode === core_bentley_1.OpenMode.Readonly; }
@@ -157,10 +145,14 @@ class IModelDb extends core_common_1.IModel {
157
145
  (0, core_bentley_1.assert)(undefined !== super.iModelId);
158
146
  return super.iModelId;
159
147
  } // GuidString | undefined for the IModel superclass, but required for all IModelDb subclasses
148
+ /** @internal
149
+ * @deprecated in 4.8. This internal API will be removed in 5.0. Use IModelDb's public API instead.
150
+ */
151
+ get nativeDb() { return this[Symbols_1._nativeDb]; }
160
152
  /** Get the full path fileName of this iModelDb
161
153
  * @note this member is only valid while the iModel is opened.
162
154
  */
163
- get pathName() { return this.nativeDb.getFilePath(); }
155
+ get pathName() { return this[Symbols_1._nativeDb].getFilePath(); }
164
156
  /** Get the full path to this iModel's "watch file".
165
157
  * A read-only briefcase opened with `watchForChanges: true` creates this file next to the briefcase file on open, if it doesn't already exist.
166
158
  * A writable briefcase "touches" this file if it exists whenever it commits changes to the briefcase.
@@ -178,29 +170,29 @@ class IModelDb extends core_common_1.IModel {
178
170
  this.views = new IModelDb.Views(this);
179
171
  this.tiles = new IModelDb.Tiles(this);
180
172
  /** @beta */
181
- this.channels = new ChannelControl_1.ChannelAdmin(this);
173
+ this.channels = (0, ChannelAdmin_1.createChannelControl)(this);
182
174
  this._statementCache = new SqliteStatement_1.StatementCache();
183
175
  this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
184
176
  this._snaps = new Map();
185
177
  /** @internal */
186
- this._locks = new NoLocks();
178
+ this._locks = (0, NoLocks_1.createNoOpLockControl)();
187
179
  /** Event called after a changeset is applied to this IModelDb. */
188
180
  this.onChangesetApplied = new core_bentley_1.BeEvent();
189
181
  /** Event called when the iModel is about to be closed. */
190
182
  this.onBeforeClose = new core_bentley_1.BeEvent();
191
- this.nativeDb = args.nativeDb;
183
+ this[Symbols_1._nativeDb] = args.nativeDb;
192
184
  // it is illegal to create an IModelDb unless the nativeDb has been opened. Throw otherwise.
193
185
  if (!this.isOpen)
194
186
  throw new Error("cannot create an IModelDb unless it has already been opened");
195
187
  // PR https://github.com/iTwin/imodel-native/pull/558 renamed closeIModel to closeFile because it changed its behavior.
196
188
  // Ideally, nobody outside of core-backend would be calling it, but somebody important is.
197
189
  // Make closeIModel available so their code doesn't break.
198
- this.nativeDb.closeIModel = () => {
190
+ this[Symbols_1._nativeDb].closeIModel = () => {
199
191
  if (!this.isReadonly)
200
192
  this.saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
201
- this.nativeDb.closeFile();
193
+ this[Symbols_1._nativeDb].closeFile();
202
194
  };
203
- this.nativeDb.setIModelDb(this);
195
+ this[Symbols_1._nativeDb].setIModelDb(this);
204
196
  this.loadIModelSettings();
205
197
  GeoCoordConfig_1.GeoCoordConfig.loadForImodel(this.workspace.settings); // load gcs data specified by iModel's settings dictionaries, must be done before calling initializeIModelDb
206
198
  this.initializeIModelDb();
@@ -224,13 +216,13 @@ class IModelDb extends core_common_1.IModel {
224
216
  this.beforeClose();
225
217
  IModelDb._openDbs.delete(this._fileKey);
226
218
  this._workspace?.close();
227
- this.locks.close();
219
+ this.locks[Symbols_1._close]();
228
220
  this._locks = undefined;
229
221
  this._codeService?.close();
230
222
  this._codeService = undefined;
231
223
  if (!this.isReadonly)
232
224
  this.saveChanges();
233
- this.nativeDb.closeFile();
225
+ this[Symbols_1._nativeDb].closeFile();
234
226
  }
235
227
  /** @internal */
236
228
  async refreshContainerForRpc(_userAccessToken) { }
@@ -244,7 +236,7 @@ class IModelDb extends core_common_1.IModel {
244
236
  }
245
237
  /** @internal */
246
238
  initializeIModelDb() {
247
- const props = this.nativeDb.getIModelProps();
239
+ const props = this[Symbols_1._nativeDb].getIModelProps();
248
240
  super.initialize(props.rootSubject.name, props);
249
241
  if (this._initialized)
250
242
  return;
@@ -281,9 +273,9 @@ class IModelDb extends core_common_1.IModel {
281
273
  /** Return `true` if the underlying nativeDb is open and valid.
282
274
  * @internal
283
275
  */
284
- get isOpen() { return this.nativeDb.isOpen(); }
276
+ get isOpen() { return this[Symbols_1._nativeDb].isOpen(); }
285
277
  /** Get the briefcase Id of this iModel */
286
- getBriefcaseId() { return this.isOpen ? this.nativeDb.getBriefcaseId() : core_common_1.BriefcaseIdValue.Illegal; }
278
+ getBriefcaseId() { return this.isOpen ? this[Symbols_1._nativeDb].getBriefcaseId() : core_common_1.BriefcaseIdValue.Illegal; }
287
279
  /**
288
280
  * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
289
281
  * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
@@ -357,11 +349,11 @@ class IModelDb extends core_common_1.IModel {
357
349
  * @public
358
350
  * */
359
351
  createQueryReader(ecsql, params, config) {
360
- if (!this.nativeDb.isOpen())
352
+ if (!this[Symbols_1._nativeDb].isOpen())
361
353
  throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "db not open");
362
354
  const executor = {
363
355
  execute: async (request) => {
364
- return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.nativeDb, request);
356
+ return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this[Symbols_1._nativeDb], request);
365
357
  },
366
358
  };
367
359
  return new core_common_1.ECSqlReader(executor, ecsql, params, config);
@@ -496,11 +488,36 @@ class IModelDb extends core_common_1.IModel {
496
488
  */
497
489
  prepareSqliteStatement(sql, logErrors = true) {
498
490
  const stmt = new SqliteStatement_1.SqliteStatement(sql);
499
- stmt.prepare(this.nativeDb, logErrors);
491
+ stmt.prepare(this[Symbols_1._nativeDb], logErrors);
500
492
  return stmt;
501
493
  }
502
494
  /**
503
- * queries the BisCore.SubCategory table for the entries that are children of the passed categoryIds
495
+ * queries the BisCore.SubCategory table for entries that are children of used spatial categories and 3D elements.
496
+ * @returns array of SubCategoryResultRow
497
+ * @internal
498
+ */
499
+ async queryAllUsedSpatialSubCategories() {
500
+ const result = [];
501
+ const parentCategoriesQuery = `SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)`;
502
+ const parentCategories = [];
503
+ for await (const row of this.createQueryReader(parentCategoriesQuery)) {
504
+ parentCategories.push(row.id);
505
+ }
506
+ ;
507
+ const where = [...parentCategories].join(",");
508
+ const query = `SELECT ECInstanceId as id, Parent.Id as parentId, Properties as appearance FROM BisCore.SubCategory WHERE Parent.Id IN (${where})`;
509
+ try {
510
+ for await (const row of this.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames })) {
511
+ result.push(row.toRow());
512
+ }
513
+ }
514
+ catch {
515
+ // We can ignore the error here, and just return whatever we were able to query.
516
+ }
517
+ return result;
518
+ }
519
+ /**
520
+ * queries the BisCore.SubCategory table for the entries that are children of the passed categoryIds.
504
521
  * @param categoryIds categoryIds to query
505
522
  * @returns array of SubCategoryResultRow
506
523
  * @internal
@@ -584,7 +601,7 @@ class IModelDb extends core_common_1.IModel {
584
601
  computeProjectExtents(options) {
585
602
  const wantFullExtents = true === options?.reportExtentsWithOutliers;
586
603
  const wantOutliers = true === options?.reportOutliers;
587
- const result = this.nativeDb.computeProjectExtents(wantFullExtents, wantOutliers);
604
+ const result = this[Symbols_1._nativeDb].computeProjectExtents(wantFullExtents, wantOutliers);
588
605
  return {
589
606
  extents: core_geometry_1.Range3d.fromJSON(result.extents),
590
607
  extentsWithOutliers: result.fullExtents ? core_geometry_1.Range3d.fromJSON(result.fullExtents) : undefined,
@@ -598,7 +615,7 @@ class IModelDb extends core_common_1.IModel {
598
615
  }
599
616
  /** Update the IModelProps of this iModel in the database. */
600
617
  updateIModelProps() {
601
- this.nativeDb.updateIModelProps(this.toJSON());
618
+ this[Symbols_1._nativeDb].updateIModelProps(this.toJSON());
602
619
  }
603
620
  /** Commit pending changes to this iModel.
604
621
  * @param description Optional description of the changes
@@ -607,13 +624,13 @@ class IModelDb extends core_common_1.IModel {
607
624
  saveChanges(description) {
608
625
  if (this.openMode === core_bentley_1.OpenMode.Readonly)
609
626
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.ReadOnly, "IModelDb was opened read-only");
610
- const stat = this.nativeDb.saveChanges(description);
627
+ const stat = this[Symbols_1._nativeDb].saveChanges(description);
611
628
  if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat)
612
629
  throw new core_common_1.IModelError(stat, `Could not save changes (${description})`);
613
630
  }
614
631
  /** Abandon pending changes in this iModel. */
615
632
  abandonChanges() {
616
- this.nativeDb.abandonChanges();
633
+ this[Symbols_1._nativeDb].abandonChanges();
617
634
  }
618
635
  /**
619
636
  * Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
@@ -626,20 +643,22 @@ class IModelDb extends core_common_1.IModel {
626
643
  performCheckpoint() {
627
644
  if (!this.isReadonly) {
628
645
  this.saveChanges();
629
- this.nativeDb.performCheckpoint();
646
+ this[Symbols_1._nativeDb].performCheckpoint();
630
647
  }
631
648
  }
632
- /** @internal */
649
+ /** @internal
650
+ * @deprecated in 4.8. Use `txns.reverseTxns`.
651
+ */
633
652
  reverseTxns(numOperations) {
634
- return this.nativeDb.reverseTxns(numOperations);
653
+ return this[Symbols_1._nativeDb].reverseTxns(numOperations);
635
654
  }
636
655
  /** @internal */
637
656
  reinstateTxn() {
638
- return this.nativeDb.reinstateTxn();
657
+ return this[Symbols_1._nativeDb].reinstateTxn();
639
658
  }
640
659
  /** @internal */
641
660
  restartTxnSession() {
642
- return this.nativeDb.restartTxnSession();
661
+ return this[Symbols_1._nativeDb].restartTxnSession();
643
662
  }
644
663
  /** Import an ECSchema. On success, the schema definition is stored in the iModel.
645
664
  * 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.
@@ -655,20 +674,20 @@ class IModelDb extends core_common_1.IModel {
655
674
  if (schemaFileNames.length === 0)
656
675
  return;
657
676
  const maybeCustomNativeContext = options?.ecSchemaXmlContext?.nativeContext;
658
- if (this.nativeDb.schemaSyncEnabled()) {
677
+ if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
659
678
  await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
660
679
  const schemaSyncDbUri = syncAccess.getUri();
661
680
  this.saveChanges();
662
681
  try {
663
- this.nativeDb.importSchemas(schemaFileNames, { schemaLockHeld: false, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
682
+ this[Symbols_1._nativeDb].importSchemas(schemaFileNames, { schemaLockHeld: false, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
664
683
  }
665
684
  catch (outerErr) {
666
685
  if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
667
686
  this.abandonChanges();
668
- if (this.nativeDb.getITwinId() !== core_bentley_1.Guid.empty)
687
+ if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
669
688
  await this.acquireSchemaLock();
670
689
  try {
671
- this.nativeDb.importSchemas(schemaFileNames, { schemaLockHeld: true, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
690
+ this[Symbols_1._nativeDb].importSchemas(schemaFileNames, { schemaLockHeld: true, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
672
691
  }
673
692
  catch (innerErr) {
674
693
  throw new core_common_1.IModelError(innerErr.errorNumber, innerErr.message);
@@ -685,10 +704,10 @@ class IModelDb extends core_common_1.IModel {
685
704
  schemaLockHeld: true,
686
705
  ecSchemaXmlContext: maybeCustomNativeContext,
687
706
  };
688
- if (this.nativeDb.getITwinId() !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
707
+ if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
689
708
  await this.acquireSchemaLock();
690
709
  try {
691
- this.nativeDb.importSchemas(schemaFileNames, nativeImportOptions);
710
+ this[Symbols_1._nativeDb].importSchemas(schemaFileNames, nativeImportOptions);
692
711
  }
693
712
  catch (err) {
694
713
  throw new core_common_1.IModelError(err.errorNumber, err.message);
@@ -708,20 +727,20 @@ class IModelDb extends core_common_1.IModel {
708
727
  async importSchemaStrings(serializedXmlSchemas) {
709
728
  if (serializedXmlSchemas.length === 0)
710
729
  return;
711
- if (this.nativeDb.schemaSyncEnabled()) {
730
+ if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
712
731
  await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schemaSync" }, async (syncAccess) => {
713
732
  const schemaSyncDbUri = syncAccess.getUri();
714
733
  this.saveChanges();
715
734
  try {
716
- this.nativeDb.importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: false, schemaSyncDbUri });
735
+ this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: false, schemaSyncDbUri });
717
736
  }
718
737
  catch (outerErr) {
719
738
  if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
720
739
  this.abandonChanges();
721
- if (this.nativeDb.getITwinId() !== core_bentley_1.Guid.empty)
740
+ if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
722
741
  await this.acquireSchemaLock();
723
742
  try {
724
- this.nativeDb.importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true, schemaSyncDbUri });
743
+ this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true, schemaSyncDbUri });
725
744
  }
726
745
  catch (innerErr) {
727
746
  throw new core_common_1.IModelError(innerErr.errorNumber, innerErr.message);
@@ -737,7 +756,7 @@ class IModelDb extends core_common_1.IModel {
737
756
  if (this.iTwinId && this.iTwinId !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
738
757
  await this.acquireSchemaLock();
739
758
  try {
740
- this.nativeDb.importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true });
759
+ this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true });
741
760
  }
742
761
  catch (err) {
743
762
  throw new core_common_1.IModelError(err.errorNumber, err.message);
@@ -782,7 +801,7 @@ class IModelDb extends core_common_1.IModel {
782
801
  if (isUpgradeRequested && openMode !== core_bentley_1.OpenMode.ReadWrite)
783
802
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.UpgradeFailed, "Cannot upgrade a Readonly Db");
784
803
  try {
785
- const nativeDb = new IModelHost_1.IModelHost.platform.DgnDb();
804
+ const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
786
805
  const container = props?.container;
787
806
  if (container) {
788
807
  // temp files for cloud-based Dbs should be in the profileDir in a subdirectory named for their container
@@ -872,7 +891,7 @@ class IModelDb extends core_common_1.IModel {
872
891
  */
873
892
  prepareStatement(sql, logErrors = true) {
874
893
  const stmt = new ECSqlStatement_1.ECSqlStatement();
875
- stmt.prepare(this.nativeDb, sql, logErrors);
894
+ stmt.prepare(this[Symbols_1._nativeDb], sql, logErrors);
876
895
  return stmt;
877
896
  }
878
897
  /** Prepare an ECSQL statement.
@@ -881,7 +900,7 @@ class IModelDb extends core_common_1.IModel {
881
900
  */
882
901
  tryPrepareStatement(sql) {
883
902
  const statement = new ECSqlStatement_1.ECSqlStatement();
884
- const result = statement.tryPrepare(this.nativeDb, sql);
903
+ const result = statement.tryPrepare(this[Symbols_1._nativeDb], sql);
885
904
  return core_bentley_1.DbResult.BE_SQLITE_OK === result.status ? statement : undefined;
886
905
  }
887
906
  /** Construct an entity (Element or Model) from an iModel.
@@ -961,7 +980,7 @@ class IModelDb extends core_common_1.IModel {
961
980
  const className = classFullName.split(":");
962
981
  if (className.length !== 2)
963
982
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, `Invalid classFullName: ${classFullName}`);
964
- const val = this.nativeDb.getECClassMetaData(className[0], className[1]);
983
+ const val = this[Symbols_1._nativeDb].getECClassMetaData(className[0], className[1]);
965
984
  if (val.error)
966
985
  throw new core_common_1.IModelError(val.error.status, `Error getting class meta data for: ${classFullName}`);
967
986
  (0, core_bentley_1.assert)(undefined !== val.result);
@@ -977,7 +996,7 @@ class IModelDb extends core_common_1.IModel {
977
996
  * @throws if the schema can not be found or loaded.
978
997
  */
979
998
  getSchemaProps(name) {
980
- return this.nativeDb.getSchemaProps(name);
999
+ return this[Symbols_1._nativeDb].getSchemaProps(name);
981
1000
  }
982
1001
  /** Query if this iModel contains the definition of the specified class.
983
1002
  * @param classFullName The full name of the class, for example, SomeSchema:SomeClass
@@ -987,7 +1006,7 @@ class IModelDb extends core_common_1.IModel {
987
1006
  */
988
1007
  containsClass(classFullName) {
989
1008
  const classNameParts = classFullName.replace(".", ":").split(":");
990
- return classNameParts.length === 2 && this.nativeDb.getECClassMetaData(classNameParts[0], classNameParts[1]).error === undefined;
1009
+ return classNameParts.length === 2 && this[Symbols_1._nativeDb].getECClassMetaData(classNameParts[0], classNameParts[1]).error === undefined;
991
1010
  }
992
1011
  /** Query for a schema of the specified name in this iModel.
993
1012
  * @returns The schema version as a semver-compatible string or `undefined` if the schema has not been imported.
@@ -1011,49 +1030,49 @@ class IModelDb extends core_common_1.IModel {
1011
1030
  * @alpha
1012
1031
  */
1013
1032
  async queryTextureData(props) {
1014
- return this.nativeDb.queryTextureData(props);
1033
+ return this[Symbols_1._nativeDb].queryTextureData(props);
1015
1034
  }
1016
1035
  /** Query a "file property" from this iModel, as a string.
1017
1036
  * @returns the property string or undefined if the property is not present.
1018
1037
  */
1019
1038
  queryFilePropertyString(prop) {
1020
- return this.nativeDb.queryFileProperty(prop, true);
1039
+ return this[Symbols_1._nativeDb].queryFileProperty(prop, true);
1021
1040
  }
1022
1041
  /** Query a "file property" from this iModel, as a blob.
1023
1042
  * @returns the property blob or undefined if the property is not present.
1024
1043
  */
1025
1044
  queryFilePropertyBlob(prop) {
1026
- return this.nativeDb.queryFileProperty(prop, false);
1045
+ return this[Symbols_1._nativeDb].queryFileProperty(prop, false);
1027
1046
  }
1028
1047
  /** Save a "file property" to this iModel
1029
1048
  * @param prop the FilePropertyProps that describes the new property
1030
1049
  * @param value either a string or a blob to save as the file property
1031
1050
  */
1032
1051
  saveFileProperty(prop, strValue, blobVal) {
1033
- this.nativeDb.saveFileProperty(prop, strValue, blobVal);
1052
+ this[Symbols_1._nativeDb].saveFileProperty(prop, strValue, blobVal);
1034
1053
  }
1035
1054
  /** delete a "file property" from this iModel
1036
1055
  * @param prop the FilePropertyProps that describes the property
1037
1056
  */
1038
1057
  deleteFileProperty(prop) {
1039
- this.nativeDb.saveFileProperty(prop, undefined, undefined);
1058
+ this[Symbols_1._nativeDb].saveFileProperty(prop, undefined, undefined);
1040
1059
  }
1041
1060
  /** Query for the next available major id for a "file property" from this iModel.
1042
1061
  * @param prop the FilePropertyProps that describes the property
1043
1062
  * @returns the next available (that is, an unused) id for prop. If none are present, will return 0.
1044
1063
  */
1045
- queryNextAvailableFileProperty(prop) { return this.nativeDb.queryNextAvailableFileProperty(prop); }
1064
+ queryNextAvailableFileProperty(prop) { return this[Symbols_1._nativeDb].queryNextAvailableFileProperty(prop); }
1046
1065
  /** @internal */
1047
1066
  async requestSnap(sessionId, props) {
1048
1067
  let request = this._snaps.get(sessionId);
1049
1068
  if (undefined === request) {
1050
- request = new IModelHost_1.IModelHost.platform.SnapRequest();
1069
+ request = new NativePlatform_1.IModelNative.platform.SnapRequest();
1051
1070
  this._snaps.set(sessionId, request);
1052
1071
  }
1053
1072
  else
1054
1073
  request.cancelSnap();
1055
1074
  try {
1056
- return await request.doSnap(this.nativeDb, core_bentley_1.JsonUtils.toObject(props));
1075
+ return await request.doSnap(this[Symbols_1._nativeDb], core_bentley_1.JsonUtils.toObject(props));
1057
1076
  }
1058
1077
  finally {
1059
1078
  this._snaps.delete(sessionId);
@@ -1071,19 +1090,19 @@ class IModelDb extends core_common_1.IModel {
1071
1090
  }
1072
1091
  /** Get the clip containment status for the supplied elements. */
1073
1092
  async getGeometryContainment(props) {
1074
- return this.nativeDb.getGeometryContainment(core_bentley_1.JsonUtils.toObject(props));
1093
+ return this[Symbols_1._nativeDb].getGeometryContainment(core_bentley_1.JsonUtils.toObject(props));
1075
1094
  }
1076
1095
  /** Get the mass properties for the supplied elements. */
1077
1096
  async getMassProperties(props) {
1078
- return this.nativeDb.getMassProperties(core_bentley_1.JsonUtils.toObject(props));
1097
+ return this[Symbols_1._nativeDb].getMassProperties(core_bentley_1.JsonUtils.toObject(props));
1079
1098
  }
1080
1099
  /** Get the IModel coordinate corresponding to each GeoCoordinate point in the input */
1081
1100
  async getIModelCoordinatesFromGeoCoordinates(props) {
1082
- return this.nativeDb.getIModelCoordinatesFromGeoCoordinates(props);
1101
+ return this[Symbols_1._nativeDb].getIModelCoordinatesFromGeoCoordinates(props);
1083
1102
  }
1084
1103
  /** Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input */
1085
1104
  async getGeoCoordinatesFromIModelCoordinates(props) {
1086
- return this.nativeDb.getGeoCoordinatesFromIModelCoordinates(props);
1105
+ return this[Symbols_1._nativeDb].getGeoCoordinatesFromIModelCoordinates(props);
1087
1106
  }
1088
1107
  /** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
1089
1108
  * * Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend,
@@ -1118,7 +1137,7 @@ class IModelDb extends core_common_1.IModel {
1118
1137
  * @public
1119
1138
  */
1120
1139
  exportGraphics(exportProps) {
1121
- return this.nativeDb.exportGraphics(exportProps);
1140
+ return this[Symbols_1._nativeDb].exportGraphics(exportProps);
1122
1141
  }
1123
1142
  /**
1124
1143
  * Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
@@ -1133,14 +1152,14 @@ class IModelDb extends core_common_1.IModel {
1133
1152
  * @public
1134
1153
  */
1135
1154
  exportPartGraphics(exportProps) {
1136
- return this.nativeDb.exportPartGraphics(exportProps);
1155
+ return this[Symbols_1._nativeDb].exportPartGraphics(exportProps);
1137
1156
  }
1138
1157
  /** Request geometry stream information from an element in binary format instead of json.
1139
1158
  * @returns IModelStatus.Success if successful
1140
1159
  * @beta
1141
1160
  */
1142
1161
  elementGeometryRequest(requestProps) {
1143
- return this.nativeDb.processGeometryStream(requestProps);
1162
+ return this[Symbols_1._nativeDb].processGeometryStream(requestProps);
1144
1163
  }
1145
1164
  /** Create brep geometry for inclusion in an element's geometry stream.
1146
1165
  * @returns IModelStatus.Success if successful
@@ -1148,7 +1167,7 @@ class IModelDb extends core_common_1.IModel {
1148
1167
  * @alpha
1149
1168
  */
1150
1169
  createBRepGeometry(createProps) {
1151
- return this.nativeDb.createBRepGeometry(createProps);
1170
+ return this[Symbols_1._nativeDb].createBRepGeometry(createProps);
1152
1171
  }
1153
1172
  /** Generate graphics for an element or geometry stream.
1154
1173
  * @see [readElementGraphics]($frontend) to convert the result to a [RenderGraphic]($frontend) for display.
@@ -1185,7 +1204,7 @@ class IModelDb extends core_common_1.IModel {
1185
1204
  }
1186
1205
  /** Load all setting dictionaries in this iModel into `this.workspace.settings` */
1187
1206
  loadIModelSettings() {
1188
- if (!this.nativeDb.isOpen())
1207
+ if (!this[Symbols_1._nativeDb].isOpen())
1189
1208
  return;
1190
1209
  this.withSqliteStatement("SELECT Name,StrData FROM be_Prop WHERE Namespace=?", (stmt) => {
1191
1210
  stmt.bindString(1, IModelDb._settingPropNamespace);
@@ -1235,14 +1254,14 @@ class IModelDb extends core_common_1.IModel {
1235
1254
  * @public
1236
1255
  */
1237
1256
  get codeValueBehavior() {
1238
- return this.nativeDb.getCodeValueBehavior();
1257
+ return this[Symbols_1._nativeDb].getCodeValueBehavior();
1239
1258
  }
1240
1259
  set codeValueBehavior(newBehavior) {
1241
- this.nativeDb.setCodeValueBehavior(newBehavior);
1260
+ this[Symbols_1._nativeDb].setCodeValueBehavior(newBehavior);
1242
1261
  }
1243
1262
  /** @internal */
1244
1263
  computeRangesForText(args) {
1245
- const props = this.nativeDb.computeRangesForText(args.chars, args.fontId, args.bold, args.italic, args.widthFactor, args.lineHeight);
1264
+ const props = this[Symbols_1._nativeDb].computeRangesForText(args.chars, args.fontId, args.bold, args.italic, args.widthFactor, args.lineHeight);
1246
1265
  return {
1247
1266
  layout: core_geometry_1.Range2d.fromJSON(props.layout),
1248
1267
  justification: core_geometry_1.Range2d.fromJSON(props.justification),
@@ -1348,7 +1367,7 @@ IModelDb._settingPropNamespace = "settings";
1348
1367
  */
1349
1368
  tryGetModelJson(modelIdArg) {
1350
1369
  try {
1351
- return this._iModel.nativeDb.getModel(modelIdArg);
1370
+ return this._iModel[Symbols_1._nativeDb].getModel(modelIdArg);
1352
1371
  }
1353
1372
  catch (err) {
1354
1373
  return undefined;
@@ -1393,7 +1412,7 @@ IModelDb._settingPropNamespace = "settings";
1393
1412
  */
1394
1413
  insertModel(props) {
1395
1414
  try {
1396
- return props.id = this._iModel.nativeDb.insertModel(props);
1415
+ return props.id = this._iModel[Symbols_1._nativeDb].insertModel(props);
1397
1416
  }
1398
1417
  catch (err) {
1399
1418
  throw new core_common_1.IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
@@ -1405,7 +1424,7 @@ IModelDb._settingPropNamespace = "settings";
1405
1424
  */
1406
1425
  updateModel(props) {
1407
1426
  try {
1408
- this._iModel.nativeDb.updateModel(props);
1427
+ this._iModel[Symbols_1._nativeDb].updateModel(props);
1409
1428
  }
1410
1429
  catch (err) {
1411
1430
  throw new core_common_1.IModelError(err.errorNumber, `error updating model [${err.message}] id=${props.id}`);
@@ -1421,7 +1440,7 @@ IModelDb._settingPropNamespace = "settings";
1421
1440
  * @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
1422
1441
  */
1423
1442
  updateGeometryGuid(modelId) {
1424
- const error = this._iModel.nativeDb.updateModelGeometryGuid(modelId);
1443
+ const error = this._iModel[Symbols_1._nativeDb].updateModelGeometryGuid(modelId);
1425
1444
  if (error !== core_bentley_1.IModelStatus.Success)
1426
1445
  throw new core_common_1.IModelError(error, `updating geometry guid for model ${modelId}`);
1427
1446
  }
@@ -1432,7 +1451,7 @@ IModelDb._settingPropNamespace = "settings";
1432
1451
  deleteModel(ids) {
1433
1452
  core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
1434
1453
  try {
1435
- this._iModel.nativeDb.deleteModel(id);
1454
+ this._iModel[Symbols_1._nativeDb].deleteModel(id);
1436
1455
  }
1437
1456
  catch (err) {
1438
1457
  throw new core_common_1.IModelError(err.errorNumber, `error deleting model [${err.message}] id ${id}`);
@@ -1450,7 +1469,7 @@ IModelDb._settingPropNamespace = "settings";
1450
1469
  ids = typeof ids === "string" ? [ids] : ids;
1451
1470
  if (ids.length === 0)
1452
1471
  return [];
1453
- return this._iModel.nativeDb.queryModelExtentsAsync(ids);
1472
+ return this._iModel[Symbols_1._nativeDb].queryModelExtentsAsync(ids);
1454
1473
  }
1455
1474
  /** Computes the union of the volumes of all geometric elements within one or more [[GeometricModel]]s, specified by model Id.
1456
1475
  * @see [[queryExtents]] to obtain discrete volumes for each model.
@@ -1505,7 +1524,7 @@ IModelDb._settingPropNamespace = "settings";
1505
1524
  */
1506
1525
  tryGetElementJson(loadProps) {
1507
1526
  try {
1508
- return this._iModel.nativeDb.getElement(loadProps);
1527
+ return this._iModel[Symbols_1._nativeDb].getElement(loadProps);
1509
1528
  }
1510
1529
  catch (err) {
1511
1530
  return undefined;
@@ -1523,7 +1542,7 @@ IModelDb._settingPropNamespace = "settings";
1523
1542
  props = { code: props };
1524
1543
  }
1525
1544
  try {
1526
- return this._iModel.nativeDb.getElement(props);
1545
+ return this._iModel[Symbols_1._nativeDb].getElement(props);
1527
1546
  }
1528
1547
  catch (err) {
1529
1548
  throw new core_common_1.IModelError(err.errorNumber, err.message);
@@ -1637,7 +1656,7 @@ IModelDb._settingPropNamespace = "settings";
1637
1656
  */
1638
1657
  insertElement(elProps) {
1639
1658
  try {
1640
- return elProps.id = this._iModel.nativeDb.insertElement(elProps);
1659
+ return elProps.id = this._iModel[Symbols_1._nativeDb].insertElement(elProps);
1641
1660
  }
1642
1661
  catch (err) {
1643
1662
  err.message = `Error inserting element [${err.message}]`;
@@ -1658,7 +1677,7 @@ IModelDb._settingPropNamespace = "settings";
1658
1677
  */
1659
1678
  updateElement(elProps) {
1660
1679
  try {
1661
- this._iModel.nativeDb.updateElement(elProps);
1680
+ this._iModel[Symbols_1._nativeDb].updateElement(elProps);
1662
1681
  }
1663
1682
  catch (err) {
1664
1683
  err.message = `Error updating element [${err.message}], id: ${elProps.id}`;
@@ -1675,7 +1694,7 @@ IModelDb._settingPropNamespace = "settings";
1675
1694
  const iModel = this._iModel;
1676
1695
  core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
1677
1696
  try {
1678
- iModel.nativeDb.deleteElement(id);
1697
+ iModel[Symbols_1._nativeDb].deleteElement(id);
1679
1698
  }
1680
1699
  catch (err) {
1681
1700
  err.message = `Error deleting element [${err.message}], id: ${id}`;
@@ -1695,7 +1714,7 @@ IModelDb._settingPropNamespace = "settings";
1695
1714
  * @beta
1696
1715
  */
1697
1716
  deleteDefinitionElements(definitionElementIds) {
1698
- const usageInfo = this._iModel.nativeDb.queryDefinitionElementUsage(definitionElementIds);
1717
+ const usageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(definitionElementIds);
1699
1718
  if (!usageInfo) {
1700
1719
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Error querying for DefinitionElement usage");
1701
1720
  }
@@ -1709,7 +1728,7 @@ IModelDb._settingPropNamespace = "settings";
1709
1728
  }
1710
1729
  };
1711
1730
  try {
1712
- this._iModel.nativeDb.beginPurgeOperation();
1731
+ this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
1713
1732
  deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);
1714
1733
  deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);
1715
1734
  deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);
@@ -1726,7 +1745,7 @@ IModelDb._settingPropNamespace = "settings";
1726
1745
  }
1727
1746
  }
1728
1747
  finally {
1729
- this._iModel.nativeDb.endPurgeOperation();
1748
+ this._iModel[Symbols_1._nativeDb].endPurgeOperation();
1730
1749
  }
1731
1750
  if (usageInfo.viewDefinitionIds) {
1732
1751
  // take another pass in case a deleted ViewDefinition was the only usage of these view-related DefinitionElements
@@ -1738,17 +1757,17 @@ IModelDb._settingPropNamespace = "settings";
1738
1757
  if (usageInfo.modelSelectorIds)
1739
1758
  viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));
1740
1759
  if (viewRelatedIds.length > 0) {
1741
- const viewRelatedUsageInfo = this._iModel.nativeDb.queryDefinitionElementUsage(viewRelatedIds);
1760
+ const viewRelatedUsageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(viewRelatedIds);
1742
1761
  if (viewRelatedUsageInfo) {
1743
1762
  const usedViewRelatedIdSet = viewRelatedUsageInfo.usedIds ? core_bentley_1.Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set();
1744
1763
  try {
1745
- this._iModel.nativeDb.beginPurgeOperation();
1764
+ this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
1746
1765
  deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);
1747
1766
  deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);
1748
1767
  deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);
1749
1768
  }
1750
1769
  finally {
1751
- this._iModel.nativeDb.endPurgeOperation();
1770
+ this._iModel[Symbols_1._nativeDb].endPurgeOperation();
1752
1771
  }
1753
1772
  viewRelatedIds.forEach((id) => {
1754
1773
  if (!usedViewRelatedIdSet.has(id))
@@ -1886,9 +1905,9 @@ IModelDb._settingPropNamespace = "settings";
1886
1905
  */
1887
1906
  getAspects(elementId, aspectClassFullName, excludedClassFullNames) {
1888
1907
  if (aspectClassFullName === undefined) {
1889
- const allAspects = this.runInstanceQuery(`SELECT $ FROM (
1890
- SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
1891
- UNION ALL
1908
+ const allAspects = this.runInstanceQuery(`SELECT $ FROM (
1909
+ SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
1910
+ UNION ALL
1892
1911
  SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
1893
1912
  if (allAspects.length === 0)
1894
1913
  core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
@@ -1896,7 +1915,7 @@ IModelDb._settingPropNamespace = "settings";
1896
1915
  }
1897
1916
  // Check if class is abstract
1898
1917
  const fullClassName = aspectClassFullName.replace(".", ":").split(":");
1899
- const val = this._iModel.nativeDb.getECClassMetaData(fullClassName[0], fullClassName[1]);
1918
+ const val = this._iModel[Symbols_1._nativeDb].getECClassMetaData(fullClassName[0], fullClassName[1]);
1900
1919
  if (val.result !== undefined) {
1901
1920
  const metaData = new core_common_1.EntityMetaData(JSON.parse(val.result));
1902
1921
  if (metaData.modifier !== "Abstract") // Class is not abstract, use normal query to retrieve aspects
@@ -1906,7 +1925,7 @@ IModelDb._settingPropNamespace = "settings";
1906
1925
  let classIdList = IModelDb.Elements.classMap.get(aspectClassFullName);
1907
1926
  if (classIdList === undefined) {
1908
1927
  const classIds = [];
1909
- this._iModel.withPreparedStatement(`select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name='${fullClassName[1]}'
1928
+ this._iModel.withPreparedStatement(`select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name='${fullClassName[1]}'
1910
1929
  and Schema.Id = (select ECInstanceId from meta.ECSchemaDef where Name='${fullClassName[0]}')) and SourceECInstanceId != TargetECInstanceId`, (statement) => {
1911
1930
  while (statement.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
1912
1931
  classIds.push(statement.getValue(0).getId());
@@ -1921,10 +1940,10 @@ IModelDb._settingPropNamespace = "settings";
1921
1940
  return [];
1922
1941
  }
1923
1942
  // Execute an instance query to retrieve all aspects from all the derived classes
1924
- const aspects = this.runInstanceQuery(`SELECT $ FROM (
1925
- SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
1926
- UNION ALL
1927
- SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
1943
+ const aspects = this.runInstanceQuery(`SELECT $ FROM (
1944
+ SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
1945
+ UNION ALL
1946
+ SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
1928
1947
  ) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
1929
1948
  if (aspects.length === 0)
1930
1949
  core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
@@ -1939,7 +1958,7 @@ IModelDb._settingPropNamespace = "settings";
1939
1958
  */
1940
1959
  insertAspect(aspectProps) {
1941
1960
  try {
1942
- return this._iModel.nativeDb.insertElementAspect(aspectProps);
1961
+ return this._iModel[Symbols_1._nativeDb].insertElementAspect(aspectProps);
1943
1962
  }
1944
1963
  catch (err) {
1945
1964
  throw new core_common_1.IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`);
@@ -1951,7 +1970,7 @@ IModelDb._settingPropNamespace = "settings";
1951
1970
  */
1952
1971
  updateAspect(aspectProps) {
1953
1972
  try {
1954
- this._iModel.nativeDb.updateElementAspect(aspectProps);
1973
+ this._iModel[Symbols_1._nativeDb].updateElementAspect(aspectProps);
1955
1974
  }
1956
1975
  catch (err) {
1957
1976
  throw new core_common_1.IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`);
@@ -1965,7 +1984,7 @@ IModelDb._settingPropNamespace = "settings";
1965
1984
  const iModel = this._iModel;
1966
1985
  core_bentley_1.Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {
1967
1986
  try {
1968
- iModel.nativeDb.deleteElementAspect(aspectInstanceId);
1987
+ iModel[Symbols_1._nativeDb].deleteElementAspect(aspectInstanceId);
1969
1988
  }
1970
1989
  catch (err) {
1971
1990
  throw new core_common_1.IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
@@ -2110,7 +2129,7 @@ IModelDb._settingPropNamespace = "settings";
2110
2129
  const viewStateData = this.loadViewData(viewDefinitionId, options);
2111
2130
  const baseModelId = viewStateData.viewDefinitionProps.baseModelId;
2112
2131
  if (baseModelId) {
2113
- const drawingExtents = core_geometry_1.Range3d.fromJSON(this._iModel.nativeDb.queryModelExtents({ id: baseModelId }).modelExtents);
2132
+ const drawingExtents = core_geometry_1.Range3d.fromJSON(this._iModel[Symbols_1._nativeDb].queryModelExtents({ id: baseModelId }).modelExtents);
2114
2133
  if (!drawingExtents.isNull)
2115
2134
  viewStateData.modelExtents = drawingExtents.toJSON();
2116
2135
  }
@@ -2138,11 +2157,11 @@ IModelDb._settingPropNamespace = "settings";
2138
2157
  */
2139
2158
  getThumbnail(viewDefinitionId) {
2140
2159
  const viewArg = this.getViewThumbnailArg(viewDefinitionId);
2141
- const sizeProps = this._iModel.nativeDb.queryFileProperty(viewArg, true);
2160
+ const sizeProps = this._iModel[Symbols_1._nativeDb].queryFileProperty(viewArg, true);
2142
2161
  if (undefined === sizeProps)
2143
2162
  return undefined;
2144
2163
  const out = JSON.parse(sizeProps);
2145
- out.image = this._iModel.nativeDb.queryFileProperty(viewArg, false);
2164
+ out.image = this._iModel[Symbols_1._nativeDb].queryFileProperty(viewArg, false);
2146
2165
  return out;
2147
2166
  }
2148
2167
  /** Save a thumbnail for a view.
@@ -2153,7 +2172,7 @@ IModelDb._settingPropNamespace = "settings";
2153
2172
  saveThumbnail(viewDefinitionId, thumbnail) {
2154
2173
  const viewArg = this.getViewThumbnailArg(viewDefinitionId);
2155
2174
  const props = { format: thumbnail.format, height: thumbnail.height, width: thumbnail.width };
2156
- this._iModel.nativeDb.saveFileProperty(viewArg, JSON.stringify(props), thumbnail.image);
2175
+ this._iModel[Symbols_1._nativeDb].saveFileProperty(viewArg, JSON.stringify(props), thumbnail.image);
2157
2176
  return 0;
2158
2177
  }
2159
2178
  /** Set the default view property the iModel.
@@ -2193,7 +2212,7 @@ IModelDb._settingPropNamespace = "settings";
2193
2212
  /** @internal */
2194
2213
  async requestTileTreeProps(id) {
2195
2214
  return new Promise((resolve, reject) => {
2196
- this._iModel.nativeDb.getTileTree(id, (ret) => {
2215
+ this._iModel[Symbols_1._nativeDb].getTileTree(id, (ret) => {
2197
2216
  if (undefined !== ret.error)
2198
2217
  reject(new core_common_1.IModelError(ret.error.status, `TreeId=${id}`));
2199
2218
  else
@@ -2204,7 +2223,7 @@ IModelDb._settingPropNamespace = "settings";
2204
2223
  pollTileContent(resolve, reject, treeId, tileId) {
2205
2224
  let ret;
2206
2225
  try {
2207
- ret = this._iModel.nativeDb.pollTileContent(treeId, tileId);
2226
+ ret = this._iModel[Symbols_1._nativeDb].pollTileContent(treeId, tileId);
2208
2227
  }
2209
2228
  catch (err) {
2210
2229
  // Typically "imodel not open".
@@ -2243,7 +2262,7 @@ IModelDb._settingPropNamespace = "settings";
2243
2262
  /** @internal */
2244
2263
  async getTileContent(treeId, tileId) {
2245
2264
  const ret = await new Promise((resolve) => {
2246
- this._iModel.nativeDb.getTileContent(treeId, tileId, resolve);
2265
+ this._iModel[Symbols_1._nativeDb].getTileContent(treeId, tileId, resolve);
2247
2266
  });
2248
2267
  if (undefined !== ret.error) {
2249
2268
  throw new core_common_1.IModelError(ret.error.status, `TreeId=${treeId} TileId=${tileId}`);
@@ -2282,12 +2301,12 @@ class BriefcaseDb extends IModelDb {
2282
2301
  * - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
2283
2302
  */
2284
2303
  get useLockServer() {
2285
- return !this.nativeDb.isReadonly() && (this.briefcaseId !== core_common_1.BriefcaseIdValue.Unassigned) && (undefined === this.nativeDb.queryLocalValue(BriefcaseLocalValue.NoLocking));
2304
+ return !this[Symbols_1._nativeDb].isReadonly() && (this.briefcaseId !== core_common_1.BriefcaseIdValue.Unassigned) && (undefined === this[Symbols_1._nativeDb].queryLocalValue(BriefcaseLocalValue.NoLocking));
2286
2305
  }
2287
2306
  // if the iModel uses a lock server, create a ServerBasedLocks LockControl for this BriefcaseDb.
2288
2307
  makeLockControl() {
2289
2308
  if (this.useLockServer)
2290
- this._locks = new ServerBasedLocks_1.ServerBasedLocks(this);
2309
+ this._locks = (0, ServerBasedLocks_1.createServerBasedLocks)(this);
2291
2310
  }
2292
2311
  constructor(args) {
2293
2312
  super({ ...args, changeset: args.nativeDb.getCurrentChangeset() });
@@ -2309,14 +2328,14 @@ class BriefcaseDb extends IModelDb {
2309
2328
  };
2310
2329
  const isSchemaSyncEnabled = await withBriefcaseDb(briefcase, async (db) => {
2311
2330
  await SchemaSync_1.SchemaSync.pull(db);
2312
- return db.nativeDb.schemaSyncEnabled();
2331
+ return db[Symbols_1._nativeDb].schemaSyncEnabled();
2313
2332
  });
2314
2333
  if (isSchemaSyncEnabled) {
2315
2334
  await SchemaSync_1.SchemaSync.withLockedAccess(briefcase, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
2316
2335
  const schemaSyncDbUri = syncAccess.getUri();
2317
2336
  executeUpgrade();
2318
2337
  await withBriefcaseDb(briefcase, async (db) => {
2319
- db.nativeDb.schemaSyncPush(schemaSyncDbUri);
2338
+ db[Symbols_1._nativeDb].schemaSyncPush(schemaSyncDbUri);
2320
2339
  db.saveChanges();
2321
2340
  });
2322
2341
  syncAccess.synchronizeWithCloud();
@@ -2358,7 +2377,7 @@ class BriefcaseDb extends IModelDb {
2358
2377
  await this.doUpgrade(briefcase, { domain: core_common_1.DomainOptions.Upgrade, schemaLockHeld: true }, "Upgraded domain schemas");
2359
2378
  }
2360
2379
  finally {
2361
- await withBriefcaseDb(briefcase, async (db) => db.locks.releaseAllLocks());
2380
+ await withBriefcaseDb(briefcase, async (db) => db.locks[Symbols_1._releaseAllLocks]());
2362
2381
  }
2363
2382
  return;
2364
2383
  }
@@ -2375,7 +2394,7 @@ class BriefcaseDb extends IModelDb {
2375
2394
  await this.doUpgrade(briefcase, { domain: core_common_1.DomainOptions.Upgrade, schemaLockHeld: true }, "Upgraded domain schemas");
2376
2395
  }
2377
2396
  finally {
2378
- await withBriefcaseDb(briefcase, async (db) => db.locks.releaseAllLocks());
2397
+ await withBriefcaseDb(briefcase, async (db) => db.locks[Symbols_1._releaseAllLocks]());
2379
2398
  }
2380
2399
  }
2381
2400
  throw error;
@@ -2399,6 +2418,7 @@ class BriefcaseDb extends IModelDb {
2399
2418
  // Restart default txn to trigger events when watch file is changed by some other process.
2400
2419
  const watcher = fs.watch(briefcaseDb.watchFilePathName, { persistent: false }, () => {
2401
2420
  nativeDb.restartDefaultTxn();
2421
+ briefcaseDb.changeset = briefcaseDb[Symbols_1._nativeDb].getCurrentChangeset();
2402
2422
  });
2403
2423
  // Stop the watcher when we close this connection.
2404
2424
  briefcaseDb.onBeforeClose.addOnce(() => {
@@ -2413,16 +2433,29 @@ class BriefcaseDb extends IModelDb {
2413
2433
  this.onCodeServiceCreated.raiseEvent(briefcaseDb);
2414
2434
  }
2415
2435
  catch (e) {
2416
- if (e.errorId !== "NoCodeIndex") // no code index means iModel isn't enforcing codes.
2417
- throw e;
2436
+ if (e.errorId !== "NoCodeIndex") { // no code index means iModel isn't enforcing codes.
2437
+ core_bentley_1.Logger.logWarning(loggerCategory, `The CodeService is not available for this briefcase: errorId: ${e.errorId}, errorMessage; ${e.message}. Proceeding with BriefcaseDb.open(), but all operations involving codes will fail.`);
2438
+ briefcaseDb._codeService = {
2439
+ verifyCode: (props) => {
2440
+ if (!core_common_1.Code.isEmpty(props.props.code)) {
2441
+ e.message = `The CodeService is not available for this briefcase: errorId: ${e.errorId}, errorMessage; ${e.message}.`;
2442
+ throw e;
2443
+ }
2444
+ },
2445
+ appParams: {
2446
+ author: { name: "unknown" },
2447
+ origin: { name: "unknown" },
2448
+ },
2449
+ close: () => { },
2450
+ initialize: async () => { },
2451
+ };
2452
+ }
2418
2453
  }
2419
2454
  }
2420
2455
  this.onOpened.raiseEvent(briefcaseDb, args);
2421
2456
  return briefcaseDb;
2422
2457
  }
2423
- /** This is called by native code when applying a changeset
2424
- * @internal
2425
- */
2458
+ /** This is called by native code when applying a changeset */
2426
2459
  onChangesetConflict(args) {
2427
2460
  // returning undefined will result in native handler to resolve conflict
2428
2461
  const category = "DgnCore";
@@ -2505,7 +2538,7 @@ class BriefcaseDb extends IModelDb {
2505
2538
  const nConflicts = args.getForeignKeyConflicts();
2506
2539
  // Note: There is no performance implication of follow code as it happen toward end of
2507
2540
  // apply_changeset only once so we be querying value for 'DebugAllowFkViolations' only once.
2508
- if (this.nativeDb.queryLocalValue("DebugAllowFkViolations")) {
2541
+ if (this[Symbols_1._nativeDb].queryLocalValue("DebugAllowFkViolations")) {
2509
2542
  core_bentley_1.Logger.logError(category, `Detected ${nConflicts} foreign key conflicts in changeset. Continuing merge as 'DebugAllowFkViolations' flag is set. Run 'PRAGMA foreign_key_check' to get list of violations.`);
2510
2543
  return core_bentley_1.DbConflictResolution.Skip;
2511
2544
  }
@@ -2580,7 +2613,7 @@ class BriefcaseDb extends IModelDb {
2580
2613
  finally {
2581
2614
  if (isReadonly) {
2582
2615
  if (locks !== this._locks) { // did we have to create a ServerBasedLocks?
2583
- this.locks.close(); // yes, close it and reset back to previous
2616
+ this.locks[Symbols_1._close](); // yes, close it and reset back to previous
2584
2617
  this._locks = locks;
2585
2618
  }
2586
2619
  this.closeAndReopen(core_bentley_1.OpenMode.Readonly, fileName);
@@ -2591,14 +2624,14 @@ class BriefcaseDb extends IModelDb {
2591
2624
  // Unclosed statements will produce BUSY error when attempting to close.
2592
2625
  this.clearCaches();
2593
2626
  // The following resets the native db's pointer to this JavaScript object.
2594
- this.nativeDb.closeFile();
2595
- this.nativeDb.openIModel(fileName, openMode);
2627
+ this[Symbols_1._nativeDb].closeFile();
2628
+ this[Symbols_1._nativeDb].openIModel(fileName, openMode);
2596
2629
  // Restore the native db's pointer to this JavaScript object.
2597
- this.nativeDb.setIModelDb(this);
2630
+ this[Symbols_1._nativeDb].setIModelDb(this);
2598
2631
  // refresh cached properties that could have been changed by another process writing to the same briefcase
2599
- this.changeset = this.nativeDb.getCurrentChangeset();
2632
+ this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
2600
2633
  // assert what should never change
2601
- if (this.iModelId !== this.nativeDb.getIModelId() || this.iTwinId !== this.nativeDb.getITwinId())
2634
+ if (this.iModelId !== this[Symbols_1._nativeDb].getIModelId() || this.iTwinId !== this[Symbols_1._nativeDb].getITwinId())
2602
2635
  throw new Error("closeAndReopen detected change in iModelId and/or iTwinId");
2603
2636
  }
2604
2637
  /** Pull and apply changesets from iModelHub */
@@ -2609,15 +2642,22 @@ class BriefcaseDb extends IModelDb {
2609
2642
  this.initializeIModelDb();
2610
2643
  });
2611
2644
  IpcHost_1.IpcHost.notifyTxns(this, "notifyPulledChanges", this.changeset);
2645
+ this.txns.touchWatchFile();
2612
2646
  }
2613
2647
  /** Push changes to iModelHub. */
2614
2648
  async pushChanges(arg) {
2615
2649
  if (this.briefcaseId === core_common_1.BriefcaseIdValue.Unassigned)
2616
2650
  return;
2617
- if (this.nativeDb.hasUnsavedChanges())
2651
+ if (this[Symbols_1._nativeDb].hasUnsavedChanges()) {
2618
2652
  throw new core_common_1.IModelError(core_bentley_1.ChangeSetStatus.HasUncommittedChanges, "Cannot push with unsaved changes");
2619
- if (!this.nativeDb.hasPendingTxns())
2620
- return; // nothing to push
2653
+ }
2654
+ else if (!this[Symbols_1._nativeDb].hasPendingTxns()) {
2655
+ // Nothing to push.
2656
+ if (!arg.retainLocks) {
2657
+ await this.locks.releaseAllLocks();
2658
+ }
2659
+ return;
2660
+ }
2621
2661
  // pushing changes requires a writeable briefcase
2622
2662
  await this.executeWritable(async () => {
2623
2663
  await BriefcaseManager_1.BriefcaseManager.pullMergePush(this, arg);
@@ -2625,6 +2665,7 @@ class BriefcaseDb extends IModelDb {
2625
2665
  });
2626
2666
  const changeset = this.changeset;
2627
2667
  IpcHost_1.IpcHost.notifyTxns(this, "notifyPushedChanges", changeset);
2668
+ this.txns.touchWatchFile();
2628
2669
  }
2629
2670
  close() {
2630
2671
  super.close();
@@ -2669,7 +2710,7 @@ class RefreshV2CheckpointSas {
2669
2710
  core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.Authorization, "attempting to refresh sasToken for checkpoint");
2670
2711
  try {
2671
2712
  // this exchanges the supplied user accessToken for an expiring blob-store token to read the checkpoint.
2672
- const container = iModel.nativeDb.cloudContainer;
2713
+ const container = iModel[Symbols_1._nativeDb].cloudContainer;
2673
2714
  if (!container)
2674
2715
  throw new Error("checkpoint is not from a cloud container");
2675
2716
  (0, core_bentley_1.assert)(undefined !== iModel.iTwinId);
@@ -2719,14 +2760,14 @@ class SnapshotDb extends IModelDb {
2719
2760
  }
2720
2761
  /** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
2721
2762
  * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
2722
- * > Note: A *snapshot* cannot be modified after [[close]] is called.
2763
+ * @note: A *snapshot* cannot be modified after [[close]] is called.
2723
2764
  * @param filePath The file that will contain the new iModel *snapshot*
2724
2765
  * @param options The parameters that define the new iModel *snapshot*
2725
2766
  * @returns A writeable SnapshotDb
2726
2767
  * @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
2727
2768
  */
2728
2769
  static createEmpty(filePath, options) {
2729
- const nativeDb = new IModelHost_1.IModelHost.platform.DgnDb();
2770
+ const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
2730
2771
  nativeDb.createIModel(filePath, options);
2731
2772
  nativeDb.resetBriefcaseId(core_common_1.BriefcaseIdValue.Unassigned);
2732
2773
  const snapshotDb = new SnapshotDb(nativeDb, core_bentley_1.Guid.createValue());
@@ -2737,7 +2778,7 @@ class SnapshotDb extends IModelDb {
2737
2778
  }
2738
2779
  /** Create a local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file, using this iModel as a *seed* or starting point.
2739
2780
  * Snapshots are not synchronized with iModelHub, so do not have a change timeline.
2740
- * > Note: A *snapshot* cannot be modified after [[close]] is called.
2781
+ * @note: A *snapshot* cannot be modified after [[close]] is called.
2741
2782
  * @param iModelDb The snapshot will be initialized from the current contents of this iModelDb
2742
2783
  * @param snapshotFile The file that will contain the new iModel *snapshot*
2743
2784
  * @param options Optional properties that determine how the snapshot iModel is created.
@@ -2747,7 +2788,7 @@ class SnapshotDb extends IModelDb {
2747
2788
  static createFrom(iModelDb, snapshotFile, options) {
2748
2789
  iModelDb.performCheckpoint();
2749
2790
  IModelJsFs_1.IModelJsFs.copySync(iModelDb.pathName, snapshotFile);
2750
- const nativeDb = new IModelHost_1.IModelHost.platform.DgnDb();
2791
+ const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
2751
2792
  nativeDb.openIModel(snapshotFile, core_bentley_1.OpenMode.ReadWrite, undefined, options);
2752
2793
  nativeDb.vacuum();
2753
2794
  // Replace iModelId if seedFile is a snapshot, preserve iModelId if seedFile is an iModelHub-managed briefcase
@@ -2780,7 +2821,11 @@ class SnapshotDb extends IModelDb {
2780
2821
  static openFile(path, opts) {
2781
2822
  this.onOpen.raiseEvent(path, opts);
2782
2823
  const file = { path, key: opts?.key };
2824
+ const wasKeyUndefined = opts?.key === undefined;
2783
2825
  const nativeDb = this.openDgnDb(file, core_bentley_1.OpenMode.Readonly, undefined, opts);
2826
+ if (wasKeyUndefined) {
2827
+ file.key = `${nativeDb.getIModelId()}:${nativeDb.getCurrentChangeset().id}`;
2828
+ }
2784
2829
  (0, core_bentley_1.assert)(undefined !== file.key);
2785
2830
  const db = new SnapshotDb(nativeDb, file.key);
2786
2831
  this.onOpened.raiseEvent(db);
@@ -2809,7 +2854,7 @@ class SnapshotDb extends IModelDb {
2809
2854
  snapshot.restartDefaultTxn();
2810
2855
  }, (10 * 60) * 1000).unref(); // 10 minutes
2811
2856
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2812
- snapshot._refreshSas = new RefreshV2CheckpointSas(snapshot.nativeDb.cloudContainer.accessToken, checkpoint.reattachSafetySeconds);
2857
+ snapshot._refreshSas = new RefreshV2CheckpointSas(snapshot[Symbols_1._nativeDb].cloudContainer.accessToken, checkpoint.reattachSafetySeconds);
2813
2858
  return snapshot;
2814
2859
  }
2815
2860
  /**
@@ -2833,7 +2878,7 @@ class SnapshotDb extends IModelDb {
2833
2878
  if (this._restartDefaultTxnTimer)
2834
2879
  clearTimeout(this._restartDefaultTxnTimer);
2835
2880
  if (this._createClassViewsOnClose) { // check for flag set during create
2836
- if (core_bentley_1.BentleyStatus.SUCCESS !== this.nativeDb.createClassViewsInDb()) {
2881
+ if (core_bentley_1.BentleyStatus.SUCCESS !== this[Symbols_1._nativeDb].createClassViewsInDb()) {
2837
2882
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.SQLiteError, "Error creating class views");
2838
2883
  }
2839
2884
  else {
@@ -2877,7 +2922,7 @@ class StandaloneDb extends BriefcaseDb {
2877
2922
  * @param args The parameters that define the new iModel
2878
2923
  */
2879
2924
  static createEmpty(filePath, args) {
2880
- const nativeDb = new IModelHost_1.IModelHost.platform.DgnDb();
2925
+ const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
2881
2926
  nativeDb.createIModel(filePath, args);
2882
2927
  nativeDb.saveLocalValue(BriefcaseLocalValue.StandaloneEdit, args.allowEdit);
2883
2928
  nativeDb.setITwinId(core_bentley_1.Guid.empty);
@@ -2909,7 +2954,7 @@ class StandaloneDb extends BriefcaseDb {
2909
2954
  * @beta
2910
2955
  */
2911
2956
  createClassViews() {
2912
- const result = this.nativeDb.createClassViewsInDb();
2957
+ const result = this[Symbols_1._nativeDb].createClassViewsInDb();
2913
2958
  if (core_bentley_1.BentleyStatus.SUCCESS !== result)
2914
2959
  throw new core_common_1.IModelError(result, "Error creating class views");
2915
2960
  else