@itwin/core-backend 4.0.0-dev.51 → 4.0.0-dev.54

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/lib/cjs/AliCloudStorageService.d.ts +23 -23
  2. package/lib/cjs/AliCloudStorageService.js +71 -71
  3. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  5. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendHubAccess.js.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.d.ts +90 -91
  9. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  10. package/lib/cjs/BackendLoggerCategory.js +98 -99
  11. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  12. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  13. package/lib/cjs/BisCoreSchema.js +60 -60
  14. package/lib/cjs/BisCoreSchema.js.map +1 -1
  15. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  16. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  17. package/lib/cjs/BriefcaseManager.js +408 -408
  18. package/lib/cjs/BriefcaseManager.js.map +1 -1
  19. package/lib/cjs/Category.d.ts +153 -153
  20. package/lib/cjs/Category.js +243 -243
  21. package/lib/cjs/Category.js.map +1 -1
  22. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  23. package/lib/cjs/ChangeSummaryManager.js +446 -446
  24. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  25. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  26. package/lib/cjs/ChangedElementsDb.js +165 -165
  27. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  28. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  29. package/lib/cjs/ChangedElementsManager.js +88 -88
  30. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  31. package/lib/cjs/ChannelControl.d.ts +69 -69
  32. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  33. package/lib/cjs/ChannelControl.js +88 -88
  34. package/lib/cjs/ChannelControl.js.map +1 -1
  35. package/lib/cjs/CheckpointManager.d.ts +121 -121
  36. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  37. package/lib/cjs/CheckpointManager.js +351 -351
  38. package/lib/cjs/CheckpointManager.js.map +1 -1
  39. package/lib/cjs/ClassRegistry.d.ts +79 -79
  40. package/lib/cjs/ClassRegistry.js +254 -249
  41. package/lib/cjs/ClassRegistry.js.map +1 -1
  42. package/lib/cjs/CloudSqlite.d.ts +355 -355
  43. package/lib/cjs/CloudSqlite.js +154 -154
  44. package/lib/cjs/CloudSqlite.js.map +1 -1
  45. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  46. package/lib/cjs/CloudStorageBackend.js +170 -170
  47. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  48. package/lib/cjs/CodeService.d.ts +396 -396
  49. package/lib/cjs/CodeService.js +63 -63
  50. package/lib/cjs/CodeService.js.map +1 -1
  51. package/lib/cjs/CodeSpecs.d.ts +55 -55
  52. package/lib/cjs/CodeSpecs.js +124 -124
  53. package/lib/cjs/CodeSpecs.js.map +1 -1
  54. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  55. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  56. package/lib/cjs/ConcurrentQuery.js +36 -36
  57. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  58. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  59. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  60. package/lib/cjs/CustomViewState3dCreator.js +82 -81
  61. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  62. package/lib/cjs/DevTools.d.ts +74 -73
  63. package/lib/cjs/DevTools.d.ts.map +1 -1
  64. package/lib/cjs/DevTools.js +156 -156
  65. package/lib/cjs/DevTools.js.map +1 -1
  66. package/lib/cjs/DisplayStyle.d.ts +106 -106
  67. package/lib/cjs/DisplayStyle.js +253 -253
  68. package/lib/cjs/DisplayStyle.js.map +1 -1
  69. package/lib/cjs/ECDb.d.ts +194 -191
  70. package/lib/cjs/ECDb.d.ts.map +1 -1
  71. package/lib/cjs/ECDb.js +353 -348
  72. package/lib/cjs/ECDb.js.map +1 -1
  73. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  74. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  75. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  76. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  77. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  78. package/lib/cjs/ECSqlStatement.js +791 -791
  79. package/lib/cjs/ECSqlStatement.js.map +1 -1
  80. package/lib/cjs/Element.d.ts +1113 -1113
  81. package/lib/cjs/Element.js +1424 -1424
  82. package/lib/cjs/Element.js.map +1 -1
  83. package/lib/cjs/ElementAspect.d.ts +176 -176
  84. package/lib/cjs/ElementAspect.js +203 -203
  85. package/lib/cjs/ElementAspect.js.map +1 -1
  86. package/lib/cjs/ElementGraphics.d.ts +9 -9
  87. package/lib/cjs/ElementGraphics.js +41 -41
  88. package/lib/cjs/ElementGraphics.js.map +1 -1
  89. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  90. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  91. package/lib/cjs/ElementTreeWalker.js +409 -409
  92. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  93. package/lib/cjs/Entity.d.ts +106 -106
  94. package/lib/cjs/Entity.d.ts.map +1 -1
  95. package/lib/cjs/Entity.js +134 -134
  96. package/lib/cjs/Entity.js.map +1 -1
  97. package/lib/cjs/EntityReferences.d.ts +49 -49
  98. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  99. package/lib/cjs/EntityReferences.js +95 -95
  100. package/lib/cjs/EntityReferences.js.map +1 -1
  101. package/lib/cjs/ExportGraphics.d.ts +317 -317
  102. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  103. package/lib/cjs/ExportGraphics.js +208 -208
  104. package/lib/cjs/ExportGraphics.js.map +1 -1
  105. package/lib/cjs/ExternalSource.d.ts +96 -96
  106. package/lib/cjs/ExternalSource.js +131 -131
  107. package/lib/cjs/ExternalSource.js.map +1 -1
  108. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  109. package/lib/cjs/GeoCoordConfig.js +85 -85
  110. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  111. package/lib/cjs/GeometrySummary.d.ts +4 -4
  112. package/lib/cjs/GeometrySummary.js +380 -380
  113. package/lib/cjs/GeometrySummary.js.map +1 -1
  114. package/lib/cjs/HubMock.d.ts +94 -94
  115. package/lib/cjs/HubMock.js +220 -220
  116. package/lib/cjs/HubMock.js.map +1 -1
  117. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  118. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  119. package/lib/cjs/IModelCloneContext.js +15 -15
  120. package/lib/cjs/IModelCloneContext.js.map +1 -1
  121. package/lib/cjs/IModelDb.d.ts +1216 -1213
  122. package/lib/cjs/IModelDb.d.ts.map +1 -1
  123. package/lib/cjs/IModelDb.js +2387 -2380
  124. package/lib/cjs/IModelDb.js.map +1 -1
  125. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  126. package/lib/cjs/IModelElementCloneContext.js +159 -159
  127. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  128. package/lib/cjs/IModelHost.d.ts +369 -369
  129. package/lib/cjs/IModelHost.js +488 -488
  130. package/lib/cjs/IModelHost.js.map +1 -1
  131. package/lib/cjs/IModelJsFs.d.ts +62 -62
  132. package/lib/cjs/IModelJsFs.js +139 -139
  133. package/lib/cjs/IModelJsFs.js.map +1 -1
  134. package/lib/cjs/IpcHost.d.ts +104 -104
  135. package/lib/cjs/IpcHost.js +276 -276
  136. package/lib/cjs/IpcHost.js.map +1 -1
  137. package/lib/cjs/LineStyle.d.ts +311 -311
  138. package/lib/cjs/LineStyle.js +295 -295
  139. package/lib/cjs/LineStyle.js.map +1 -1
  140. package/lib/cjs/LocalHub.d.ts +162 -162
  141. package/lib/cjs/LocalHub.d.ts.map +1 -1
  142. package/lib/cjs/LocalHub.js +580 -580
  143. package/lib/cjs/LocalHub.js.map +1 -1
  144. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  145. package/lib/cjs/LocalhostIpcHost.js +79 -79
  146. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  147. package/lib/cjs/Material.d.ts +131 -131
  148. package/lib/cjs/Material.js +180 -180
  149. package/lib/cjs/Material.js.map +1 -1
  150. package/lib/cjs/Model.d.ts +392 -392
  151. package/lib/cjs/Model.js +489 -489
  152. package/lib/cjs/Model.js.map +1 -1
  153. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  154. package/lib/cjs/NativeAppStorage.js +202 -202
  155. package/lib/cjs/NativeAppStorage.js.map +1 -1
  156. package/lib/cjs/NativeHost.d.ts +52 -52
  157. package/lib/cjs/NativeHost.js +160 -160
  158. package/lib/cjs/NativeHost.js.map +1 -1
  159. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  160. package/lib/cjs/NavigationRelationship.js +225 -225
  161. package/lib/cjs/NavigationRelationship.js.map +1 -1
  162. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  163. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  164. package/lib/cjs/PromiseMemoizer.js +101 -101
  165. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  166. package/lib/cjs/PropertyStore.d.ts +132 -132
  167. package/lib/cjs/PropertyStore.js +11 -11
  168. package/lib/cjs/PropertyStore.js.map +1 -1
  169. package/lib/cjs/Relationship.d.ts +416 -416
  170. package/lib/cjs/Relationship.js +494 -494
  171. package/lib/cjs/Relationship.js.map +1 -1
  172. package/lib/cjs/RpcBackend.d.ts +5 -5
  173. package/lib/cjs/RpcBackend.js +32 -32
  174. package/lib/cjs/RpcBackend.js.map +1 -1
  175. package/lib/cjs/SQLiteDb.d.ts +219 -219
  176. package/lib/cjs/SQLiteDb.js +212 -212
  177. package/lib/cjs/SQLiteDb.js.map +1 -1
  178. package/lib/cjs/Schema.d.ts +55 -55
  179. package/lib/cjs/Schema.js +83 -83
  180. package/lib/cjs/Schema.js.map +1 -1
  181. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  182. package/lib/cjs/ServerBasedLocks.js +168 -168
  183. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  184. package/lib/cjs/SqliteStatement.d.ts +360 -360
  185. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  186. package/lib/cjs/SqliteStatement.js +586 -586
  187. package/lib/cjs/SqliteStatement.js.map +1 -1
  188. package/lib/cjs/Texture.d.ts +58 -58
  189. package/lib/cjs/Texture.js +82 -82
  190. package/lib/cjs/Texture.js.map +1 -1
  191. package/lib/cjs/TileStorage.d.ts +18 -18
  192. package/lib/cjs/TileStorage.js +87 -87
  193. package/lib/cjs/TileStorage.js.map +1 -1
  194. package/lib/cjs/TxnManager.d.ts +202 -202
  195. package/lib/cjs/TxnManager.d.ts.map +1 -1
  196. package/lib/cjs/TxnManager.js +356 -356
  197. package/lib/cjs/TxnManager.js.map +1 -1
  198. package/lib/cjs/ViewDefinition.d.ts +435 -435
  199. package/lib/cjs/ViewDefinition.js +646 -646
  200. package/lib/cjs/ViewDefinition.js.map +1 -1
  201. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  202. package/lib/cjs/ViewStateHydrator.js +103 -103
  203. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  204. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  205. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  206. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  207. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  208. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  209. package/lib/cjs/core-backend.d.ts +185 -185
  210. package/lib/cjs/core-backend.js +209 -205
  211. package/lib/cjs/core-backend.js.map +1 -1
  212. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  213. package/lib/cjs/domains/FunctionalElements.js +145 -145
  214. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  215. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  216. package/lib/cjs/domains/FunctionalSchema.js +39 -39
  217. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  218. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  219. package/lib/cjs/domains/GenericElements.js +263 -263
  220. package/lib/cjs/domains/GenericElements.js.map +1 -1
  221. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  222. package/lib/cjs/domains/GenericSchema.js +28 -28
  223. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  224. package/lib/cjs/rpc/multipart.d.ts +11 -11
  225. package/lib/cjs/rpc/multipart.js +71 -71
  226. package/lib/cjs/rpc/multipart.js.map +1 -1
  227. package/lib/cjs/rpc/tracing.d.ts +28 -28
  228. package/lib/cjs/rpc/tracing.js +73 -73
  229. package/lib/cjs/rpc/tracing.js.map +1 -1
  230. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  231. package/lib/cjs/rpc/web/logging.js +43 -43
  232. package/lib/cjs/rpc/web/logging.js.map +1 -1
  233. package/lib/cjs/rpc/web/request.d.ts +6 -6
  234. package/lib/cjs/rpc/web/request.js +73 -73
  235. package/lib/cjs/rpc/web/request.js.map +1 -1
  236. package/lib/cjs/rpc/web/response.d.ts +6 -6
  237. package/lib/cjs/rpc/web/response.js +105 -105
  238. package/lib/cjs/rpc/web/response.js.map +1 -1
  239. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  240. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  241. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  242. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  243. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -293
  244. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  245. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  246. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  247. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  248. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  249. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -166
  250. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  251. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  252. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -42
  253. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  254. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  255. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  256. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  257. package/lib/cjs/workspace/Settings.d.ts +186 -186
  258. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  259. package/lib/cjs/workspace/Settings.js +154 -154
  260. package/lib/cjs/workspace/Settings.js.map +1 -1
  261. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  262. package/lib/cjs/workspace/SettingsSchemas.js +190 -190
  263. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  264. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  265. package/lib/cjs/workspace/Workspace.js +537 -537
  266. package/lib/cjs/workspace/Workspace.js.map +1 -1
  267. package/package.json +12 -12
@@ -1,89 +1,89 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChangedElementsManager = void 0;
4
- const BriefcaseManager_1 = require("./BriefcaseManager");
5
- const ChangedElementsDb_1 = require("./ChangedElementsDb");
6
- const IModelJsFs_1 = require("./IModelJsFs");
7
- /** Utilities for querying changed elements caches */
8
- /** @internal */
9
- class ChangedElementsManager {
10
- static getChangedElementsPathName(iModelId) { return BriefcaseManager_1.BriefcaseManager.getChangedElementsPathName(iModelId); }
11
- /** Get changed elements Db */
12
- static getChangedElementsDb(iModelId) {
13
- if (this._entry && this._entry.iModelId === iModelId)
14
- return this._entry.db;
15
- if (this._entry && this._entry.iModelId !== iModelId) {
16
- this._entry.db.closeDb();
17
- this._entry.db.cleanCaches();
18
- this._entry = undefined;
19
- }
20
- if (!this._entry) {
21
- const path = ChangedElementsManager.getChangedElementsPathName(iModelId);
22
- if (!IModelJsFs_1.IModelJsFs.existsSync(path))
23
- return undefined;
24
- const db = ChangedElementsDb_1.ChangedElementsDb.openDb(path);
25
- this._entry = {
26
- iModelId,
27
- db,
28
- };
29
- return db;
30
- }
31
- return undefined;
32
- }
33
- static cleanUp() {
34
- if (this._entry) {
35
- this._entry.db.closeDb();
36
- this._entry.db.cleanCaches();
37
- this._entry = undefined;
38
- }
39
- }
40
- /** Gets the changed elements from the cache if found
41
- * @param iModelId Id of the iModel
42
- * @param startChangesetId Start changeset Id
43
- * @param endChangesetId End changeset Id
44
- * @returns Changed elements if found
45
- */
46
- static getChangedElements(iModelId, startChangesetId, endChangesetId) {
47
- const db = ChangedElementsManager.getChangedElementsDb(iModelId);
48
- if (!db)
49
- return undefined;
50
- return db.getChangedElements(startChangesetId, endChangesetId);
51
- }
52
- /** Gets the changed models from the cache if found
53
- * @param iModelId Id of the iModel
54
- * @param startChangesetId Start changeset Id
55
- * @param endChangesetId End changeset Id
56
- * @returns Changed models if found
57
- */
58
- static getChangedModels(iModelId, startChangesetId, endChangesetId) {
59
- const db = ChangedElementsManager.getChangedElementsDb(iModelId);
60
- if (!db)
61
- return undefined;
62
- return db.getChangedModels(startChangesetId, endChangesetId);
63
- }
64
- /** Gets the change data (models and elements) from the cache if found
65
- * @param iModelId Id of the iModel
66
- * @param startChangesetId Start changeset Id
67
- * @param endChangesetId End changeset Id
68
- * @returns Changed models if found
69
- */
70
- static getChangeData(iModelId, startChangesetId, endChangesetId) {
71
- const db = ChangedElementsManager.getChangedElementsDb(iModelId);
72
- if (!db)
73
- return undefined;
74
- return db.getChangeData(startChangesetId, endChangesetId);
75
- }
76
- /** Checks if the cache contains information about the changeset
77
- * @param iModelId Id of the iModel
78
- * @param changesetId Changeset to check for
79
- * @returns true if the changeset has been processed and exists in the cache
80
- */
81
- static isProcessed(iModelId, changesetId) {
82
- const db = ChangedElementsManager.getChangedElementsDb(iModelId);
83
- if (!db)
84
- return false;
85
- return db.isProcessed(changesetId);
86
- }
87
- }
88
- exports.ChangedElementsManager = ChangedElementsManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangedElementsManager = void 0;
4
+ const BriefcaseManager_1 = require("./BriefcaseManager");
5
+ const ChangedElementsDb_1 = require("./ChangedElementsDb");
6
+ const IModelJsFs_1 = require("./IModelJsFs");
7
+ /** Utilities for querying changed elements caches */
8
+ /** @internal */
9
+ class ChangedElementsManager {
10
+ static getChangedElementsPathName(iModelId) { return BriefcaseManager_1.BriefcaseManager.getChangedElementsPathName(iModelId); }
11
+ /** Get changed elements Db */
12
+ static getChangedElementsDb(iModelId) {
13
+ if (this._entry && this._entry.iModelId === iModelId)
14
+ return this._entry.db;
15
+ if (this._entry && this._entry.iModelId !== iModelId) {
16
+ this._entry.db.closeDb();
17
+ this._entry.db.cleanCaches();
18
+ this._entry = undefined;
19
+ }
20
+ if (!this._entry) {
21
+ const path = ChangedElementsManager.getChangedElementsPathName(iModelId);
22
+ if (!IModelJsFs_1.IModelJsFs.existsSync(path))
23
+ return undefined;
24
+ const db = ChangedElementsDb_1.ChangedElementsDb.openDb(path);
25
+ this._entry = {
26
+ iModelId,
27
+ db,
28
+ };
29
+ return db;
30
+ }
31
+ return undefined;
32
+ }
33
+ static cleanUp() {
34
+ if (this._entry) {
35
+ this._entry.db.closeDb();
36
+ this._entry.db.cleanCaches();
37
+ this._entry = undefined;
38
+ }
39
+ }
40
+ /** Gets the changed elements from the cache if found
41
+ * @param iModelId Id of the iModel
42
+ * @param startChangesetId Start changeset Id
43
+ * @param endChangesetId End changeset Id
44
+ * @returns Changed elements if found
45
+ */
46
+ static getChangedElements(iModelId, startChangesetId, endChangesetId) {
47
+ const db = ChangedElementsManager.getChangedElementsDb(iModelId);
48
+ if (!db)
49
+ return undefined;
50
+ return db.getChangedElements(startChangesetId, endChangesetId);
51
+ }
52
+ /** Gets the changed models from the cache if found
53
+ * @param iModelId Id of the iModel
54
+ * @param startChangesetId Start changeset Id
55
+ * @param endChangesetId End changeset Id
56
+ * @returns Changed models if found
57
+ */
58
+ static getChangedModels(iModelId, startChangesetId, endChangesetId) {
59
+ const db = ChangedElementsManager.getChangedElementsDb(iModelId);
60
+ if (!db)
61
+ return undefined;
62
+ return db.getChangedModels(startChangesetId, endChangesetId);
63
+ }
64
+ /** Gets the change data (models and elements) from the cache if found
65
+ * @param iModelId Id of the iModel
66
+ * @param startChangesetId Start changeset Id
67
+ * @param endChangesetId End changeset Id
68
+ * @returns Changed models if found
69
+ */
70
+ static getChangeData(iModelId, startChangesetId, endChangesetId) {
71
+ const db = ChangedElementsManager.getChangedElementsDb(iModelId);
72
+ if (!db)
73
+ return undefined;
74
+ return db.getChangeData(startChangesetId, endChangesetId);
75
+ }
76
+ /** Checks if the cache contains information about the changeset
77
+ * @param iModelId Id of the iModel
78
+ * @param changesetId Changeset to check for
79
+ * @returns true if the changeset has been processed and exists in the cache
80
+ */
81
+ static isProcessed(iModelId, changesetId) {
82
+ const db = ChangedElementsManager.getChangedElementsDb(iModelId);
83
+ if (!db)
84
+ return false;
85
+ return db.isProcessed(changesetId);
86
+ }
87
+ }
88
+ exports.ChangedElementsManager = ChangedElementsManager;
89
89
  //# sourceMappingURL=ChangedElementsManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChangedElementsManager.js","sourceRoot":"","sources":["../../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------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { ChangeData, ChangedElements, ChangedModels } from \"@itwin/core-common\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { ChangedElementsDb } from \"./ChangedElementsDb\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\n\r\n/** @internal */\r\ninterface ChangedElementsDbCacheEntry {\r\n iModelId: GuidString;\r\n db: ChangedElementsDb;\r\n}\r\n\r\n/** Utilities for querying changed elements caches */\r\n/** @internal */\r\nexport class ChangedElementsManager {\r\n /** Maintains a single entry since we will only have a cache per iModel, which means a ChangedElementsDb per backend instance */\r\n private static _entry: ChangedElementsDbCacheEntry | undefined;\r\n\r\n public static getChangedElementsPathName(iModelId: GuidString): string { return BriefcaseManager.getChangedElementsPathName(iModelId); }\r\n\r\n /** Get changed elements Db */\r\n private static getChangedElementsDb(iModelId: GuidString): ChangedElementsDb | undefined {\r\n if (this._entry && this._entry.iModelId === iModelId)\r\n return this._entry.db;\r\n if (this._entry && this._entry.iModelId !== iModelId) {\r\n this._entry.db.closeDb();\r\n this._entry.db.cleanCaches();\r\n this._entry = undefined;\r\n }\r\n if (!this._entry) {\r\n const path = ChangedElementsManager.getChangedElementsPathName(iModelId);\r\n if (!IModelJsFs.existsSync(path))\r\n return undefined;\r\n\r\n const db: ChangedElementsDb = ChangedElementsDb.openDb(path);\r\n this._entry = {\r\n iModelId,\r\n db,\r\n };\r\n\r\n return db;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n public static cleanUp() {\r\n if (this._entry) {\r\n this._entry.db.closeDb();\r\n this._entry.db.cleanCaches();\r\n this._entry = undefined;\r\n }\r\n }\r\n\r\n /** Gets the changed elements from the cache if found\r\n * @param iModelId Id of the iModel\r\n * @param startChangesetId Start changeset Id\r\n * @param endChangesetId End changeset Id\r\n * @returns Changed elements if found\r\n */\r\n public static getChangedElements(iModelId: GuidString, startChangesetId: string, endChangesetId: string): ChangedElements | undefined {\r\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\r\n if (!db)\r\n return undefined;\r\n\r\n return db.getChangedElements(startChangesetId, endChangesetId);\r\n }\r\n\r\n /** Gets the changed models from the cache if found\r\n * @param iModelId Id of the iModel\r\n * @param startChangesetId Start changeset Id\r\n * @param endChangesetId End changeset Id\r\n * @returns Changed models if found\r\n */\r\n public static getChangedModels(iModelId: GuidString, startChangesetId: string, endChangesetId: string): ChangedModels | undefined {\r\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\r\n if (!db)\r\n return undefined;\r\n\r\n return db.getChangedModels(startChangesetId, endChangesetId);\r\n }\r\n\r\n /** Gets the change data (models and elements) from the cache if found\r\n * @param iModelId Id of the iModel\r\n * @param startChangesetId Start changeset Id\r\n * @param endChangesetId End changeset Id\r\n * @returns Changed models if found\r\n */\r\n public static getChangeData(iModelId: GuidString, startChangesetId: string, endChangesetId: string): ChangeData | undefined {\r\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\r\n if (!db)\r\n return undefined;\r\n\r\n return db.getChangeData(startChangesetId, endChangesetId);\r\n }\r\n\r\n /** Checks if the cache contains information about the changeset\r\n * @param iModelId Id of the iModel\r\n * @param changesetId Changeset to check for\r\n * @returns true if the changeset has been processed and exists in the cache\r\n */\r\n public static isProcessed(iModelId: GuidString, changesetId: string): boolean {\r\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\r\n if (!db)\r\n return false;\r\n\r\n return db.isProcessed(changesetId);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ChangedElementsManager.js","sourceRoot":"","sources":["../../src/ChangedElementsManager.ts"],"names":[],"mappings":";;;AAMA,yDAAsD;AACtD,2DAAwD;AACxD,6CAA0C;AAQ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CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,kBAAkB,CAAC,QAAoB,EAAE,gBAAwB,EAAE,cAAsB;QACrG,MAAM,EAAE,GAAkC,sBAAsB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAChG,IAAI,CAAC,EAAE;YACL,OAAO,SAAS,CAAC;QAEnB,OAAO,EAAE,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACjE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,gBAAgB,CAAC,QAAoB,EAAE,gBAAwB,EAAE,cAAsB;QACnG,MAAM,EAAE,GAAkC,sBAAsB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAChG,IAAI,CAAC,EAAE;YACL,OAAO,SAAS,CAAC;QAEnB,OAAO,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,QAAoB,EAAE,gBAAwB,EAAE,cAAsB;QAChG,MAAM,EAAE,GAAkC,sBAAsB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAChG,IAAI,CAAC,EAAE;YACL,OAAO,SAAS,CAAC;QAEnB,OAAO,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,QAAoB,EAAE,WAAmB;QACjE,MAAM,EAAE,GAAkC,sBAAsB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAChG,IAAI,CAAC,EAAE;YACL,OAAO,KAAK,CAAC;QAEf,OAAO,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;CACF;AA9FD,wDA8FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { GuidString } from \"@itwin/core-bentley\";\nimport { ChangeData, ChangedElements, ChangedModels } from \"@itwin/core-common\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { ChangedElementsDb } from \"./ChangedElementsDb\";\nimport { IModelJsFs } from \"./IModelJsFs\";\n\n/** @internal */\ninterface ChangedElementsDbCacheEntry {\n iModelId: GuidString;\n db: ChangedElementsDb;\n}\n\n/** Utilities for querying changed elements caches */\n/** @internal */\nexport class ChangedElementsManager {\n /** Maintains a single entry since we will only have a cache per iModel, which means a ChangedElementsDb per backend instance */\n private static _entry: ChangedElementsDbCacheEntry | undefined;\n\n public static getChangedElementsPathName(iModelId: GuidString): string { return BriefcaseManager.getChangedElementsPathName(iModelId); }\n\n /** Get changed elements Db */\n private static getChangedElementsDb(iModelId: GuidString): ChangedElementsDb | undefined {\n if (this._entry && this._entry.iModelId === iModelId)\n return this._entry.db;\n if (this._entry && this._entry.iModelId !== iModelId) {\n this._entry.db.closeDb();\n this._entry.db.cleanCaches();\n this._entry = undefined;\n }\n if (!this._entry) {\n const path = ChangedElementsManager.getChangedElementsPathName(iModelId);\n if (!IModelJsFs.existsSync(path))\n return undefined;\n\n const db: ChangedElementsDb = ChangedElementsDb.openDb(path);\n this._entry = {\n iModelId,\n db,\n };\n\n return db;\n }\n\n return undefined;\n }\n\n public static cleanUp() {\n if (this._entry) {\n this._entry.db.closeDb();\n this._entry.db.cleanCaches();\n this._entry = undefined;\n }\n }\n\n /** Gets the changed elements from the cache if found\n * @param iModelId Id of the iModel\n * @param startChangesetId Start changeset Id\n * @param endChangesetId End changeset Id\n * @returns Changed elements if found\n */\n public static getChangedElements(iModelId: GuidString, startChangesetId: string, endChangesetId: string): ChangedElements | undefined {\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\n if (!db)\n return undefined;\n\n return db.getChangedElements(startChangesetId, endChangesetId);\n }\n\n /** Gets the changed models from the cache if found\n * @param iModelId Id of the iModel\n * @param startChangesetId Start changeset Id\n * @param endChangesetId End changeset Id\n * @returns Changed models if found\n */\n public static getChangedModels(iModelId: GuidString, startChangesetId: string, endChangesetId: string): ChangedModels | undefined {\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\n if (!db)\n return undefined;\n\n return db.getChangedModels(startChangesetId, endChangesetId);\n }\n\n /** Gets the change data (models and elements) from the cache if found\n * @param iModelId Id of the iModel\n * @param startChangesetId Start changeset Id\n * @param endChangesetId End changeset Id\n * @returns Changed models if found\n */\n public static getChangeData(iModelId: GuidString, startChangesetId: string, endChangesetId: string): ChangeData | undefined {\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\n if (!db)\n return undefined;\n\n return db.getChangeData(startChangesetId, endChangesetId);\n }\n\n /** Checks if the cache contains information about the changeset\n * @param iModelId Id of the iModel\n * @param changesetId Changeset to check for\n * @returns true if the changeset has been processed and exists in the cache\n */\n public static isProcessed(iModelId: GuidString, changesetId: string): boolean {\n const db: ChangedElementsDb | undefined = ChangedElementsManager.getChangedElementsDb(iModelId);\n if (!db)\n return false;\n\n return db.isProcessed(changesetId);\n }\n}\n"]}
@@ -1,70 +1,70 @@
1
- /** @packageDocumentation
2
- * @module Elements
3
- */
4
- import { Id64String } from "@itwin/core-bentley";
5
- import { IModelDb } from "./IModelDb";
6
- /** The key for a channel. Used for "allowed channels" in [[ChannelControl]]
7
- * @beta
8
- */
9
- export declare type ChannelKey = string;
10
- /**
11
- * Controls which channels of an iModel are permitted for write operations. An implementation of this interface is
12
- * available via [[IModelDb.channels]].
13
- * @see [Working With Channels]($docs/learning/backend/Channel.md) for details
14
- * @beta
15
- */
16
- export interface ChannelControl {
17
- /** Determine whether this [[IModelDb]] has any channels in it. */
18
- get hasChannels(): boolean;
19
- /** Add a new channel to the list of allowed channels of the [[IModelDb]] for this session.
20
- * @param channelKey The key for the channel to become editable in this session.
21
- */
22
- addAllowedChannel(channelKey: ChannelKey): void;
23
- /** Remove a channel from the list of allowed channels of the [[IModelDb]] for this session.
24
- * @param channelKey The key of the channel that should no longer be editable in this session.
25
- */
26
- removeAllowedChannel(channelKey: ChannelKey): void;
27
- /** Get the channelKey of the channel for an element by ElementId.
28
- * @throws if the element does not exist
29
- */
30
- getChannelKey(elementId: Id64String): ChannelKey;
31
- /** Insert a new Subject element that defines a new Channel in this iModel.
32
- * @returns the ElementId of the new Subject element.
33
- */
34
- insertChannelSubject(args: {
35
- /** The name of the new Subject element */
36
- subjectName: string;
37
- /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/
38
- channelKey: ChannelKey;
39
- /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */
40
- parentSubjectId?: Id64String;
41
- /** Optional description for new Subject. */
42
- description?: string;
43
- }): Id64String;
44
- /** @internal */
45
- verifyChannel(modelId: Id64String): void;
46
- }
47
- /** @internal */
48
- export declare class ChannelAdmin implements ChannelControl {
49
- private _iModel;
50
- /** the name of the special "shared" channel holding information that is editable by any application. */
51
- static readonly sharedChannel = "shared";
52
- static readonly channelClassName = "bis:ChannelRootAspect";
53
- private _allowedChannels;
54
- private _allowedModels;
55
- private _deniedModels;
56
- private _hasChannels?;
57
- constructor(_iModel: IModelDb);
58
- addAllowedChannel(channelKey: ChannelKey): void;
59
- removeAllowedChannel(channelKey: ChannelKey): void;
60
- get hasChannels(): boolean;
61
- getChannelKey(elementId: Id64String): ChannelKey;
62
- verifyChannel(modelId: Id64String): void;
63
- insertChannelSubject(args: {
64
- subjectName: string;
65
- channelKey: ChannelKey;
66
- parentSubjectId?: Id64String;
67
- description?: string;
68
- }): Id64String;
69
- }
1
+ /** @packageDocumentation
2
+ * @module Elements
3
+ */
4
+ import { Id64String } from "@itwin/core-bentley";
5
+ import { IModelDb } from "./IModelDb";
6
+ /** The key for a channel. Used for "allowed channels" in [[ChannelControl]]
7
+ * @beta
8
+ */
9
+ export type ChannelKey = string;
10
+ /**
11
+ * Controls which channels of an iModel are permitted for write operations. An implementation of this interface is
12
+ * available via [[IModelDb.channels]].
13
+ * @see [Working With Channels]($docs/learning/backend/Channel.md) for details
14
+ * @beta
15
+ */
16
+ export interface ChannelControl {
17
+ /** Determine whether this [[IModelDb]] has any channels in it. */
18
+ get hasChannels(): boolean;
19
+ /** Add a new channel to the list of allowed channels of the [[IModelDb]] for this session.
20
+ * @param channelKey The key for the channel to become editable in this session.
21
+ */
22
+ addAllowedChannel(channelKey: ChannelKey): void;
23
+ /** Remove a channel from the list of allowed channels of the [[IModelDb]] for this session.
24
+ * @param channelKey The key of the channel that should no longer be editable in this session.
25
+ */
26
+ removeAllowedChannel(channelKey: ChannelKey): void;
27
+ /** Get the channelKey of the channel for an element by ElementId.
28
+ * @throws if the element does not exist
29
+ */
30
+ getChannelKey(elementId: Id64String): ChannelKey;
31
+ /** Insert a new Subject element that defines a new Channel in this iModel.
32
+ * @returns the ElementId of the new Subject element.
33
+ */
34
+ insertChannelSubject(args: {
35
+ /** The name of the new Subject element */
36
+ subjectName: string;
37
+ /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/
38
+ channelKey: ChannelKey;
39
+ /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */
40
+ parentSubjectId?: Id64String;
41
+ /** Optional description for new Subject. */
42
+ description?: string;
43
+ }): Id64String;
44
+ /** @internal */
45
+ verifyChannel(modelId: Id64String): void;
46
+ }
47
+ /** @internal */
48
+ export declare class ChannelAdmin implements ChannelControl {
49
+ private _iModel;
50
+ /** the name of the special "shared" channel holding information that is editable by any application. */
51
+ static readonly sharedChannel = "shared";
52
+ static readonly channelClassName = "bis:ChannelRootAspect";
53
+ private _allowedChannels;
54
+ private _allowedModels;
55
+ private _deniedModels;
56
+ private _hasChannels?;
57
+ constructor(_iModel: IModelDb);
58
+ addAllowedChannel(channelKey: ChannelKey): void;
59
+ removeAllowedChannel(channelKey: ChannelKey): void;
60
+ get hasChannels(): boolean;
61
+ getChannelKey(elementId: Id64String): ChannelKey;
62
+ verifyChannel(modelId: Id64String): void;
63
+ insertChannelSubject(args: {
64
+ subjectName: string;
65
+ channelKey: ChannelKey;
66
+ parentSubjectId?: Id64String;
67
+ description?: string;
68
+ }): Id64String;
69
+ }
70
70
  //# sourceMappingURL=ChannelControl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelControl.d.ts","sourceRoot":"","sources":["../../src/ChannelControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,UAAU,EAAkC,MAAM,qBAAqB,CAAC;AAG3F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,IAAI,WAAW,IAAI,OAAO,CAAC;IAC3B;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD;;OAEG;IACH,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IACnD;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC;IACjD;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE;QACzB,0CAA0C;QAC1C,WAAW,EAAE,MAAM,CAAC;QACpB,kGAAkG;QAClG,UAAU,EAAE,UAAU,CAAC;QACvB,oFAAoF;QACpF,eAAe,CAAC,EAAE,UAAU,CAAC;QAC7B,4CAA4C;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,UAAU,CAAC;IAEf,gBAAgB;IAChB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;CAC1C;AAED,gBAAgB;AAChB,qBAAa,YAAa,YAAW,cAAc;IAS9B,OAAO,CAAC,OAAO;IARlC,wGAAwG;IACxG,gBAAuB,aAAa,YAAY;IAChD,gBAAuB,gBAAgB,2BAA2B;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AAU,EAAE,UAAU,CAAC;QACvB,oFAAoF;QACpF,eAAe,CAAC,EAAE,UAAU,CAAC;QAC7B,4CAA4C;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,UAAU,CAAC;IAEf,gBAAgB;IAChB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;CAC1C;AAED,gBAAgB;AAChB,qBAAa,YAAa,YAAW,cAAc;IAS9B,OAAO,CAAC,OAAO;IARlC,wGAAwG;IACxG,gBAAuB,aAAa,YAAY;IAChD,gBAAuB,gBAAgB,2BAA2B;IAClE,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,aAAa,CAAqC;IAC1D,OAAO,CAAC,YAAY,CAAC,CAAU;gBAEJ,OAAO,EAAE,QAAQ;IAGrC,iBAAiB,CAAC,UAAU,EAAE,UAAU;IAIxC,oBAAoB,CAAC,UAAU,EAAE,UAAU;IAIlD,IAAW,WAAW,IAAI,OAAO,CAUhC;IACM,aAAa,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU;IAkBhD,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAiBxC,oBAAoB,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAC;QAAC,eAAe,CAAC,EAAE,UAAU,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU;CAUnJ"}
@@ -1,89 +1,89 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Elements
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ChannelAdmin = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- const Element_1 = require("./Element");
14
- /** @internal */
15
- class ChannelAdmin {
16
- constructor(_iModel) {
17
- this._iModel = _iModel;
18
- this._allowedChannels = new Set();
19
- this._allowedModels = new Set();
20
- this._deniedModels = new Map();
21
- this._allowedChannels.add(ChannelAdmin.sharedChannel);
22
- }
23
- addAllowedChannel(channelKey) {
24
- this._allowedChannels.add(channelKey);
25
- this._deniedModels.clear();
26
- }
27
- removeAllowedChannel(channelKey) {
28
- this._allowedChannels.delete(channelKey);
29
- this._allowedModels.clear();
30
- }
31
- get hasChannels() {
32
- if (undefined === this._hasChannels) {
33
- try {
34
- this._hasChannels = this._iModel.withStatement(`SELECT 1 FROM ${ChannelAdmin.channelClassName}`, (stmt) => stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW, false);
35
- }
36
- catch (e) {
37
- // iModel doesn't have channel class in its BIS schema
38
- this._hasChannels = false;
39
- }
40
- }
41
- return this._hasChannels;
42
- }
43
- getChannelKey(elementId) {
44
- if (!this.hasChannels || elementId === core_common_1.IModel.rootSubjectId)
45
- return ChannelAdmin.sharedChannel;
46
- const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {
47
- stmt.bindId(1, elementId);
48
- return core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;
49
- });
50
- if (channel !== undefined)
51
- return channel;
52
- const parentId = this._iModel.withPreparedSqliteStatement("SELECT ParentId,ModelId FROM bis_Element WHERE id=?", (stmt) => {
53
- stmt.bindId(1, elementId);
54
- if (core_bentley_1.DbResult.BE_SQLITE_ROW !== stmt.step())
55
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "Element does not exist");
56
- return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId
57
- });
58
- return this.getChannelKey(parentId);
59
- }
60
- verifyChannel(modelId) {
61
- // Note: indirect changes are permitted to change any channel
62
- if (!this.hasChannels || this._allowedModels.has(modelId) || this._iModel.nativeDb.isIndirectChanges())
63
- return;
64
- const deniedChannel = this._deniedModels.get(modelId);
65
- if (undefined !== deniedChannel)
66
- throw new core_common_1.IModelError(core_bentley_1.RepositoryStatus.ChannelConstraintViolation, `channel "${deniedChannel}" is not allowed`);
67
- const channel = this.getChannelKey(modelId);
68
- if (this._allowedChannels.has(channel)) {
69
- this._allowedModels.add(modelId);
70
- return;
71
- }
72
- this._deniedModels.set(modelId, channel);
73
- return this.verifyChannel(modelId);
74
- }
75
- insertChannelSubject(args) {
76
- if (args.parentSubjectId && ChannelAdmin.sharedChannel !== this.getChannelKey(args.parentSubjectId))
77
- throw new Error("channels may not nest");
78
- const subjectId = Element_1.Subject.insert(this._iModel, args.parentSubjectId ?? core_common_1.IModel.rootSubjectId, args.subjectName, args.description);
79
- const props = { classFullName: ChannelAdmin.channelClassName, element: { id: subjectId }, owner: args.channelKey };
80
- this._iModel.elements.insertAspect(props);
81
- this._hasChannels = true;
82
- return subjectId;
83
- }
84
- }
85
- exports.ChannelAdmin = ChannelAdmin;
86
- /** the name of the special "shared" channel holding information that is editable by any application. */
87
- ChannelAdmin.sharedChannel = "shared";
88
- ChannelAdmin.channelClassName = "bis:ChannelRootAspect";
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Elements
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ChannelAdmin = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const Element_1 = require("./Element");
14
+ /** @internal */
15
+ class ChannelAdmin {
16
+ constructor(_iModel) {
17
+ this._iModel = _iModel;
18
+ this._allowedChannels = new Set();
19
+ this._allowedModels = new Set();
20
+ this._deniedModels = new Map();
21
+ this._allowedChannels.add(ChannelAdmin.sharedChannel);
22
+ }
23
+ addAllowedChannel(channelKey) {
24
+ this._allowedChannels.add(channelKey);
25
+ this._deniedModels.clear();
26
+ }
27
+ removeAllowedChannel(channelKey) {
28
+ this._allowedChannels.delete(channelKey);
29
+ this._allowedModels.clear();
30
+ }
31
+ get hasChannels() {
32
+ if (undefined === this._hasChannels) {
33
+ try {
34
+ this._hasChannels = this._iModel.withStatement(`SELECT 1 FROM ${ChannelAdmin.channelClassName}`, (stmt) => stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW, false);
35
+ }
36
+ catch (e) {
37
+ // iModel doesn't have channel class in its BIS schema
38
+ this._hasChannels = false;
39
+ }
40
+ }
41
+ return this._hasChannels;
42
+ }
43
+ getChannelKey(elementId) {
44
+ if (!this.hasChannels || elementId === core_common_1.IModel.rootSubjectId)
45
+ return ChannelAdmin.sharedChannel;
46
+ const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {
47
+ stmt.bindId(1, elementId);
48
+ return core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;
49
+ });
50
+ if (channel !== undefined)
51
+ return channel;
52
+ const parentId = this._iModel.withPreparedSqliteStatement("SELECT ParentId,ModelId FROM bis_Element WHERE id=?", (stmt) => {
53
+ stmt.bindId(1, elementId);
54
+ if (core_bentley_1.DbResult.BE_SQLITE_ROW !== stmt.step())
55
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "Element does not exist");
56
+ return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId
57
+ });
58
+ return this.getChannelKey(parentId);
59
+ }
60
+ verifyChannel(modelId) {
61
+ // Note: indirect changes are permitted to change any channel
62
+ if (!this.hasChannels || this._allowedModels.has(modelId) || this._iModel.nativeDb.isIndirectChanges())
63
+ return;
64
+ const deniedChannel = this._deniedModels.get(modelId);
65
+ if (undefined !== deniedChannel)
66
+ throw new core_common_1.IModelError(core_bentley_1.RepositoryStatus.ChannelConstraintViolation, `channel "${deniedChannel}" is not allowed`);
67
+ const channel = this.getChannelKey(modelId);
68
+ if (this._allowedChannels.has(channel)) {
69
+ this._allowedModels.add(modelId);
70
+ return;
71
+ }
72
+ this._deniedModels.set(modelId, channel);
73
+ return this.verifyChannel(modelId);
74
+ }
75
+ insertChannelSubject(args) {
76
+ if (args.parentSubjectId && ChannelAdmin.sharedChannel !== this.getChannelKey(args.parentSubjectId))
77
+ throw new Error("channels may not nest");
78
+ const subjectId = Element_1.Subject.insert(this._iModel, args.parentSubjectId ?? core_common_1.IModel.rootSubjectId, args.subjectName, args.description);
79
+ const props = { classFullName: ChannelAdmin.channelClassName, element: { id: subjectId }, owner: args.channelKey };
80
+ this._iModel.elements.insertAspect(props);
81
+ this._hasChannels = true;
82
+ return subjectId;
83
+ }
84
+ }
85
+ /** the name of the special "shared" channel holding information that is editable by any application. */
86
+ ChannelAdmin.sharedChannel = "shared";
87
+ ChannelAdmin.channelClassName = "bis:ChannelRootAspect";
88
+ exports.ChannelAdmin = ChannelAdmin;
89
89
  //# sourceMappingURL=ChannelControl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelControl.js","sourceRoot":"","sources":["../../src/ChannelControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2F;AAC3F,oDAAiF;AACjF,uCAAoC;AA+CpC,gBAAgB;AAChB,MAAa,YAAY;IASvB,YAA2B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QALpC,qBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;QACzC,mBAAc,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,kBAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;QAIxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC;IACM,i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,OAAO,EAAE,OAAO,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IACM,oBAAoB,CAAC,IAAyG;QACnI,IAAI,IAAI,CAAC,eAAe,IAAI,YAAY,CAAC,aAAa,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC;YACjG,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE3C,MAAM,SAAS,GAAG,iBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,IAAI,oBAAM,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACjI,MAAM,KAAK,GAA2B,EAAE,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3I,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;;AA3EH,oCA4EC;AA3EC,wGAAwG;AACjF,0BAAa,GAAG,QAAQ,CAAC;AACzB,6BAAgB,GAAG,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { DbResult, Id64String, IModelStatus, RepositoryStatus } from \"@itwin/core-bentley\";\r\nimport { ChannelRootAspectProps, IModel, IModelError } from \"@itwin/core-common\";\r\nimport { Subject } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** The key for a channel. Used for \"allowed channels\" in [[ChannelControl]]\r\n * @beta\r\n */\r\nexport type ChannelKey = string;\r\n\r\n/**\r\n * Controls which channels of an iModel are permitted for write operations. An implementation of this interface is\r\n * available via [[IModelDb.channels]].\r\n * @see [Working With Channels]($docs/learning/backend/Channel.md) for details\r\n * @beta\r\n */\r\nexport interface ChannelControl {\r\n /** Determine whether this [[IModelDb]] has any channels in it. */\r\n get hasChannels(): boolean;\r\n /** Add a new channel to the list of allowed channels of the [[IModelDb]] for this session.\r\n * @param channelKey The key for the channel to become editable in this session.\r\n */\r\n addAllowedChannel(channelKey: ChannelKey): void;\r\n /** Remove a channel from the list of allowed channels of the [[IModelDb]] for this session.\r\n * @param channelKey The key of the channel that should no longer be editable in this session.\r\n */\r\n removeAllowedChannel(channelKey: ChannelKey): void;\r\n /** Get the channelKey of the channel for an element by ElementId.\r\n * @throws if the element does not exist\r\n */\r\n getChannelKey(elementId: Id64String): ChannelKey;\r\n /** Insert a new Subject element that defines a new Channel in this iModel.\r\n * @returns the ElementId of the new Subject element.\r\n */\r\n insertChannelSubject(args: {\r\n /** The name of the new Subject element */\r\n subjectName: string;\r\n /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/\r\n channelKey: ChannelKey;\r\n /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */\r\n parentSubjectId?: Id64String;\r\n /** Optional description for new Subject. */\r\n description?: string;\r\n }): Id64String;\r\n\r\n /** @internal */\r\n verifyChannel(modelId: Id64String): void;\r\n}\r\n\r\n/** @internal */\r\nexport class ChannelAdmin implements ChannelControl {\r\n /** the name of the special \"shared\" channel holding information that is editable by any application. */\r\n public static readonly sharedChannel = \"shared\";\r\n public static readonly channelClassName = \"bis:ChannelRootAspect\";\r\n private _allowedChannels = new Set<ChannelKey>();\r\n private _allowedModels = new Set<Id64String>();\r\n private _deniedModels = new Map<Id64String, ChannelKey>();\r\n private _hasChannels?: boolean;\r\n\r\n public constructor(private _iModel: IModelDb) {\r\n this._allowedChannels.add(ChannelAdmin.sharedChannel);\r\n }\r\n public addAllowedChannel(channelKey: ChannelKey) {\r\n this._allowedChannels.add(channelKey);\r\n this._deniedModels.clear();\r\n }\r\n public removeAllowedChannel(channelKey: ChannelKey) {\r\n this._allowedChannels.delete(channelKey);\r\n this._allowedModels.clear();\r\n }\r\n public get hasChannels(): boolean {\r\n if (undefined === this._hasChannels) {\r\n try {\r\n this._hasChannels = this._iModel.withStatement(`SELECT 1 FROM ${ChannelAdmin.channelClassName}`, (stmt) => stmt.step() === DbResult.BE_SQLITE_ROW, false);\r\n } catch (e) {\r\n // iModel doesn't have channel class in its BIS schema\r\n this._hasChannels = false;\r\n }\r\n }\r\n return this._hasChannels;\r\n }\r\n public getChannelKey(elementId: Id64String): ChannelKey {\r\n if (!this.hasChannels || elementId === IModel.rootSubjectId)\r\n return ChannelAdmin.sharedChannel;\r\n\r\n const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {\r\n stmt.bindId(1, elementId);\r\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;\r\n });\r\n if (channel !== undefined)\r\n return channel;\r\n const parentId = this._iModel.withPreparedSqliteStatement(\"SELECT ParentId,ModelId FROM bis_Element WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, elementId);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"Element does not exist\");\r\n return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId\r\n });\r\n return this.getChannelKey(parentId);\r\n }\r\n public verifyChannel(modelId: Id64String): void {\r\n // Note: indirect changes are permitted to change any channel\r\n if (!this.hasChannels || this._allowedModels.has(modelId) || this._iModel.nativeDb.isIndirectChanges())\r\n return;\r\n\r\n const deniedChannel = this._deniedModels.get(modelId);\r\n if (undefined !== deniedChannel)\r\n throw new IModelError(RepositoryStatus.ChannelConstraintViolation, `channel \"${deniedChannel}\" is not allowed`);\r\n\r\n const channel = this.getChannelKey(modelId);\r\n if (this._allowedChannels.has(channel)) {\r\n this._allowedModels.add(modelId);\r\n return;\r\n }\r\n this._deniedModels.set(modelId, channel);\r\n return this.verifyChannel(modelId);\r\n }\r\n public insertChannelSubject(args: { subjectName: string, channelKey: ChannelKey, parentSubjectId?: Id64String, description?: string }): Id64String {\r\n if (args.parentSubjectId && ChannelAdmin.sharedChannel !== this.getChannelKey(args.parentSubjectId))\r\n throw new Error(\"channels may not nest\");\r\n\r\n const subjectId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);\r\n const props: ChannelRootAspectProps = { classFullName: ChannelAdmin.channelClassName, element: { id: subjectId }, owner: args.channelKey };\r\n this._iModel.elements.insertAspect(props);\r\n this._hasChannels = true;\r\n return subjectId;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ChannelControl.js","sourceRoot":"","sources":["../../src/ChannelControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2F;AAC3F,oDAAiF;AACjF,uCAAoC;AA+CpC,gBAAgB;AAChB,MAAa,YAAY;IASvB,YAA2B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QALpC,qBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;QACzC,mBAAc,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,kBAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;QAIxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC;IACM,iBAAiB,CAAC,UAAsB;QAC7C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IACM,oBAAoB,CAAC,UAAsB;QAChD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,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AC,eAAe,CAAC;YACjG,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE3C,MAAM,SAAS,GAAG,iBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,IAAI,oBAAM,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACjI,MAAM,KAAK,GAA2B,EAAE,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3I,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;;AA1ED,wGAAwG;AACjF,0BAAa,GAAG,QAAQ,AAAX,CAAY;AACzB,6BAAgB,GAAG,uBAAuB,AAA1B,CAA2B;AAHvD,oCAAY","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { DbResult, Id64String, IModelStatus, RepositoryStatus } from \"@itwin/core-bentley\";\nimport { ChannelRootAspectProps, IModel, IModelError } from \"@itwin/core-common\";\nimport { Subject } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\n\n/** The key for a channel. Used for \"allowed channels\" in [[ChannelControl]]\n * @beta\n */\nexport type ChannelKey = string;\n\n/**\n * Controls which channels of an iModel are permitted for write operations. An implementation of this interface is\n * available via [[IModelDb.channels]].\n * @see [Working With Channels]($docs/learning/backend/Channel.md) for details\n * @beta\n */\nexport interface ChannelControl {\n /** Determine whether this [[IModelDb]] has any channels in it. */\n get hasChannels(): boolean;\n /** Add a new channel to the list of allowed channels of the [[IModelDb]] for this session.\n * @param channelKey The key for the channel to become editable in this session.\n */\n addAllowedChannel(channelKey: ChannelKey): void;\n /** Remove a channel from the list of allowed channels of the [[IModelDb]] for this session.\n * @param channelKey The key of the channel that should no longer be editable in this session.\n */\n removeAllowedChannel(channelKey: ChannelKey): void;\n /** Get the channelKey of the channel for an element by ElementId.\n * @throws if the element does not exist\n */\n getChannelKey(elementId: Id64String): ChannelKey;\n /** Insert a new Subject element that defines a new Channel in this iModel.\n * @returns the ElementId of the new Subject element.\n */\n insertChannelSubject(args: {\n /** The name of the new Subject element */\n subjectName: string;\n /** The channel key for the new [[Subject]]. This is the string to pass to [[addAllowedChannel]]*/\n channelKey: ChannelKey;\n /** the Id of the parent of the new Subject. Default is [[IModel.rootSubjectId]]. */\n parentSubjectId?: Id64String;\n /** Optional description for new Subject. */\n description?: string;\n }): Id64String;\n\n /** @internal */\n verifyChannel(modelId: Id64String): void;\n}\n\n/** @internal */\nexport class ChannelAdmin implements ChannelControl {\n /** the name of the special \"shared\" channel holding information that is editable by any application. */\n public static readonly sharedChannel = \"shared\";\n public static readonly channelClassName = \"bis:ChannelRootAspect\";\n private _allowedChannels = new Set<ChannelKey>();\n private _allowedModels = new Set<Id64String>();\n private _deniedModels = new Map<Id64String, ChannelKey>();\n private _hasChannels?: boolean;\n\n public constructor(private _iModel: IModelDb) {\n this._allowedChannels.add(ChannelAdmin.sharedChannel);\n }\n public addAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.add(channelKey);\n this._deniedModels.clear();\n }\n public removeAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.delete(channelKey);\n this._allowedModels.clear();\n }\n public get hasChannels(): boolean {\n if (undefined === this._hasChannels) {\n try {\n this._hasChannels = this._iModel.withStatement(`SELECT 1 FROM ${ChannelAdmin.channelClassName}`, (stmt) => stmt.step() === DbResult.BE_SQLITE_ROW, false);\n } catch (e) {\n // iModel doesn't have channel class in its BIS schema\n this._hasChannels = false;\n }\n }\n return this._hasChannels;\n }\n public getChannelKey(elementId: Id64String): ChannelKey {\n if (!this.hasChannels || elementId === IModel.rootSubjectId)\n return ChannelAdmin.sharedChannel;\n\n const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {\n stmt.bindId(1, elementId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;\n });\n if (channel !== undefined)\n return channel;\n const parentId = this._iModel.withPreparedSqliteStatement(\"SELECT ParentId,ModelId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, elementId);\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\n throw new IModelError(IModelStatus.NotFound, \"Element does not exist\");\n return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId\n });\n return this.getChannelKey(parentId);\n }\n public verifyChannel(modelId: Id64String): void {\n // Note: indirect changes are permitted to change any channel\n if (!this.hasChannels || this._allowedModels.has(modelId) || this._iModel.nativeDb.isIndirectChanges())\n return;\n\n const deniedChannel = this._deniedModels.get(modelId);\n if (undefined !== deniedChannel)\n throw new IModelError(RepositoryStatus.ChannelConstraintViolation, `channel \"${deniedChannel}\" is not allowed`);\n\n const channel = this.getChannelKey(modelId);\n if (this._allowedChannels.has(channel)) {\n this._allowedModels.add(modelId);\n return;\n }\n this._deniedModels.set(modelId, channel);\n return this.verifyChannel(modelId);\n }\n public insertChannelSubject(args: { subjectName: string, channelKey: ChannelKey, parentSubjectId?: Id64String, description?: string }): Id64String {\n if (args.parentSubjectId && ChannelAdmin.sharedChannel !== this.getChannelKey(args.parentSubjectId))\n throw new Error(\"channels may not nest\");\n\n const subjectId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);\n const props: ChannelRootAspectProps = { classFullName: ChannelAdmin.channelClassName, element: { id: subjectId }, owner: args.channelKey };\n this._iModel.elements.insertAspect(props);\n this._hasChannels = true;\n return subjectId;\n }\n}\n"]}