@itwin/core-backend 4.0.0-dev.44 → 4.0.0-dev.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  2. package/lib/cjs/AliCloudStorageService.js +71 -71
  3. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  5. package/lib/cjs/BackendHubAccess.js +41 -41
  6. package/lib/cjs/BackendHubAccess.js.map +1 -1
  7. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  8. package/lib/cjs/BackendLoggerCategory.js +99 -99
  9. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  10. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  11. package/lib/cjs/BisCoreSchema.js +60 -60
  12. package/lib/cjs/BisCoreSchema.js.map +1 -1
  13. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  14. package/lib/cjs/BriefcaseManager.js +408 -408
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +153 -153
  17. package/lib/cjs/Category.js +243 -243
  18. package/lib/cjs/Category.js.map +1 -1
  19. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  20. package/lib/cjs/ChangeSummaryManager.js +446 -446
  21. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  22. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  23. package/lib/cjs/ChangedElementsDb.js +165 -165
  24. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  25. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  26. package/lib/cjs/ChangedElementsManager.js +88 -88
  27. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  28. package/lib/cjs/ChannelControl.d.ts +70 -0
  29. package/lib/cjs/ChannelControl.d.ts.map +1 -0
  30. package/lib/cjs/ChannelControl.js +89 -0
  31. package/lib/cjs/ChannelControl.js.map +1 -0
  32. package/lib/cjs/CheckpointManager.d.ts +121 -121
  33. package/lib/cjs/CheckpointManager.js +351 -351
  34. package/lib/cjs/CheckpointManager.js.map +1 -1
  35. package/lib/cjs/ClassRegistry.d.ts +79 -79
  36. package/lib/cjs/ClassRegistry.js +249 -249
  37. package/lib/cjs/ClassRegistry.js.map +1 -1
  38. package/lib/cjs/CloudSqlite.d.ts +355 -355
  39. package/lib/cjs/CloudSqlite.js +154 -154
  40. package/lib/cjs/CloudSqlite.js.map +1 -1
  41. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  42. package/lib/cjs/CloudStorageBackend.js +170 -170
  43. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  44. package/lib/cjs/CodeService.d.ts +396 -396
  45. package/lib/cjs/CodeService.js +63 -63
  46. package/lib/cjs/CodeService.js.map +1 -1
  47. package/lib/cjs/CodeSpecs.d.ts +55 -55
  48. package/lib/cjs/CodeSpecs.js +124 -124
  49. package/lib/cjs/CodeSpecs.js.map +1 -1
  50. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  51. package/lib/cjs/ConcurrentQuery.js +36 -36
  52. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  53. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  54. package/lib/cjs/CustomViewState3dCreator.js +81 -81
  55. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  56. package/lib/cjs/DevTools.d.ts +73 -73
  57. package/lib/cjs/DevTools.js +156 -156
  58. package/lib/cjs/DevTools.js.map +1 -1
  59. package/lib/cjs/DisplayStyle.d.ts +106 -106
  60. package/lib/cjs/DisplayStyle.js +253 -253
  61. package/lib/cjs/DisplayStyle.js.map +1 -1
  62. package/lib/cjs/ECDb.d.ts +191 -191
  63. package/lib/cjs/ECDb.js +348 -348
  64. package/lib/cjs/ECDb.js.map +1 -1
  65. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  66. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  67. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  68. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  69. package/lib/cjs/ECSqlStatement.js +791 -791
  70. package/lib/cjs/ECSqlStatement.js.map +1 -1
  71. package/lib/cjs/Element.d.ts +1113 -1109
  72. package/lib/cjs/Element.d.ts.map +1 -1
  73. package/lib/cjs/Element.js +1424 -1419
  74. package/lib/cjs/Element.js.map +1 -1
  75. package/lib/cjs/ElementAspect.d.ts +176 -179
  76. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  77. package/lib/cjs/ElementAspect.js +203 -211
  78. package/lib/cjs/ElementAspect.js.map +1 -1
  79. package/lib/cjs/ElementGraphics.d.ts +9 -9
  80. package/lib/cjs/ElementGraphics.js +41 -41
  81. package/lib/cjs/ElementGraphics.js.map +1 -1
  82. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  83. package/lib/cjs/ElementTreeWalker.js +409 -409
  84. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  85. package/lib/cjs/Entity.d.ts +106 -106
  86. package/lib/cjs/Entity.js +134 -134
  87. package/lib/cjs/Entity.js.map +1 -1
  88. package/lib/cjs/EntityReferences.d.ts +49 -49
  89. package/lib/cjs/EntityReferences.js +95 -95
  90. package/lib/cjs/EntityReferences.js.map +1 -1
  91. package/lib/cjs/ExportGraphics.d.ts +317 -317
  92. package/lib/cjs/ExportGraphics.js +208 -208
  93. package/lib/cjs/ExportGraphics.js.map +1 -1
  94. package/lib/cjs/ExternalSource.d.ts +96 -96
  95. package/lib/cjs/ExternalSource.js +131 -131
  96. package/lib/cjs/ExternalSource.js.map +1 -1
  97. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  98. package/lib/cjs/GeoCoordConfig.js +85 -85
  99. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  100. package/lib/cjs/GeometrySummary.d.ts +4 -4
  101. package/lib/cjs/GeometrySummary.js +380 -380
  102. package/lib/cjs/GeometrySummary.js.map +1 -1
  103. package/lib/cjs/HubMock.d.ts +94 -94
  104. package/lib/cjs/HubMock.js +220 -220
  105. package/lib/cjs/HubMock.js.map +1 -1
  106. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  107. package/lib/cjs/IModelCloneContext.js +15 -15
  108. package/lib/cjs/IModelCloneContext.js.map +1 -1
  109. package/lib/cjs/IModelDb.d.ts +1213 -1210
  110. package/lib/cjs/IModelDb.d.ts.map +1 -1
  111. package/lib/cjs/IModelDb.js +2380 -2377
  112. package/lib/cjs/IModelDb.js.map +1 -1
  113. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  114. package/lib/cjs/IModelElementCloneContext.js +159 -159
  115. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  116. package/lib/cjs/IModelHost.d.ts +369 -369
  117. package/lib/cjs/IModelHost.js +488 -488
  118. package/lib/cjs/IModelHost.js.map +1 -1
  119. package/lib/cjs/IModelJsFs.d.ts +62 -62
  120. package/lib/cjs/IModelJsFs.js +139 -139
  121. package/lib/cjs/IModelJsFs.js.map +1 -1
  122. package/lib/cjs/IpcHost.d.ts +104 -104
  123. package/lib/cjs/IpcHost.js +276 -276
  124. package/lib/cjs/IpcHost.js.map +1 -1
  125. package/lib/cjs/LineStyle.d.ts +311 -311
  126. package/lib/cjs/LineStyle.js +295 -295
  127. package/lib/cjs/LineStyle.js.map +1 -1
  128. package/lib/cjs/LocalHub.d.ts +162 -162
  129. package/lib/cjs/LocalHub.js +580 -580
  130. package/lib/cjs/LocalHub.js.map +1 -1
  131. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  132. package/lib/cjs/LocalhostIpcHost.js +79 -79
  133. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  134. package/lib/cjs/Material.d.ts +131 -131
  135. package/lib/cjs/Material.js +180 -180
  136. package/lib/cjs/Material.js.map +1 -1
  137. package/lib/cjs/Model.d.ts +392 -392
  138. package/lib/cjs/Model.d.ts.map +1 -1
  139. package/lib/cjs/Model.js +489 -485
  140. package/lib/cjs/Model.js.map +1 -1
  141. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  142. package/lib/cjs/NativeAppStorage.js +202 -202
  143. package/lib/cjs/NativeAppStorage.js.map +1 -1
  144. package/lib/cjs/NativeHost.d.ts +52 -52
  145. package/lib/cjs/NativeHost.js +160 -160
  146. package/lib/cjs/NativeHost.js.map +1 -1
  147. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  148. package/lib/cjs/NavigationRelationship.js +225 -225
  149. package/lib/cjs/NavigationRelationship.js.map +1 -1
  150. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  151. package/lib/cjs/PromiseMemoizer.js +101 -101
  152. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  153. package/lib/cjs/PropertyStore.d.ts +132 -132
  154. package/lib/cjs/PropertyStore.js +11 -11
  155. package/lib/cjs/PropertyStore.js.map +1 -1
  156. package/lib/cjs/Relationship.d.ts +416 -416
  157. package/lib/cjs/Relationship.js +494 -494
  158. package/lib/cjs/Relationship.js.map +1 -1
  159. package/lib/cjs/RpcBackend.d.ts +5 -5
  160. package/lib/cjs/RpcBackend.js +32 -32
  161. package/lib/cjs/RpcBackend.js.map +1 -1
  162. package/lib/cjs/SQLiteDb.d.ts +219 -219
  163. package/lib/cjs/SQLiteDb.js +212 -212
  164. package/lib/cjs/SQLiteDb.js.map +1 -1
  165. package/lib/cjs/Schema.d.ts +55 -55
  166. package/lib/cjs/Schema.js +83 -83
  167. package/lib/cjs/Schema.js.map +1 -1
  168. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  169. package/lib/cjs/ServerBasedLocks.js +168 -168
  170. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  171. package/lib/cjs/SqliteStatement.d.ts +360 -360
  172. package/lib/cjs/SqliteStatement.js +586 -586
  173. package/lib/cjs/SqliteStatement.js.map +1 -1
  174. package/lib/cjs/Texture.d.ts +58 -58
  175. package/lib/cjs/Texture.js +82 -82
  176. package/lib/cjs/Texture.js.map +1 -1
  177. package/lib/cjs/TileStorage.d.ts +18 -18
  178. package/lib/cjs/TileStorage.js +87 -87
  179. package/lib/cjs/TileStorage.js.map +1 -1
  180. package/lib/cjs/TxnManager.d.ts +202 -202
  181. package/lib/cjs/TxnManager.js +356 -356
  182. package/lib/cjs/TxnManager.js.map +1 -1
  183. package/lib/cjs/ViewDefinition.d.ts +435 -435
  184. package/lib/cjs/ViewDefinition.js +646 -646
  185. package/lib/cjs/ViewDefinition.js.map +1 -1
  186. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  187. package/lib/cjs/ViewStateHydrator.js +103 -103
  188. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  189. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  190. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  191. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  192. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  193. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  194. package/lib/cjs/core-backend.d.ts +185 -184
  195. package/lib/cjs/core-backend.d.ts.map +1 -1
  196. package/lib/cjs/core-backend.js +205 -204
  197. package/lib/cjs/core-backend.js.map +1 -1
  198. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  199. package/lib/cjs/domains/FunctionalElements.js +145 -145
  200. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  201. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  202. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  203. package/lib/cjs/domains/FunctionalSchema.js +39 -40
  204. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  205. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  206. package/lib/cjs/domains/GenericElements.js +263 -263
  207. package/lib/cjs/domains/GenericElements.js.map +1 -1
  208. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  209. package/lib/cjs/domains/GenericSchema.js +28 -28
  210. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  211. package/lib/cjs/rpc/multipart.d.ts +11 -11
  212. package/lib/cjs/rpc/multipart.js +71 -71
  213. package/lib/cjs/rpc/multipart.js.map +1 -1
  214. package/lib/cjs/rpc/tracing.d.ts +28 -28
  215. package/lib/cjs/rpc/tracing.js +73 -73
  216. package/lib/cjs/rpc/tracing.js.map +1 -1
  217. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  218. package/lib/cjs/rpc/web/logging.js +43 -43
  219. package/lib/cjs/rpc/web/logging.js.map +1 -1
  220. package/lib/cjs/rpc/web/request.d.ts +6 -6
  221. package/lib/cjs/rpc/web/request.js +73 -73
  222. package/lib/cjs/rpc/web/request.js.map +1 -1
  223. package/lib/cjs/rpc/web/response.d.ts +6 -6
  224. package/lib/cjs/rpc/web/response.js +105 -105
  225. package/lib/cjs/rpc/web/response.js.map +1 -1
  226. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  227. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  228. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  229. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  230. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -293
  231. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  232. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  233. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  234. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  235. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  236. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -166
  237. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  238. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  239. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -42
  240. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  241. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  242. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  243. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  244. package/lib/cjs/workspace/Settings.d.ts +186 -186
  245. package/lib/cjs/workspace/Settings.js +154 -154
  246. package/lib/cjs/workspace/Settings.js.map +1 -1
  247. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  248. package/lib/cjs/workspace/SettingsSchemas.js +190 -190
  249. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  250. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  251. package/lib/cjs/workspace/Workspace.js +537 -537
  252. package/lib/cjs/workspace/Workspace.js.map +1 -1
  253. package/package.json +13 -13
@@ -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":["../../src/ChangedElementsManager.ts"],"names":[],"mappings":";;;AAMA,yDAAsD;AACtD,2DAAwD;AACxD,6CAA0C;AAQ1C,qDAAqD;AACrD,gBAAgB;AAChB,MAAa,sBAAsB;IAI1B,MAAM,CAAC,0BAA0B,CAAC,QAAoB,IAAY,OAAO,mCAAgB,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExI,8BAA8B;IACtB,MAAM,CAAC,oBAAoB,CAAC,QAAoB;QACtD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ;YAClD,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;YACpD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OA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,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":["/*---------------------------------------------------------------------------------------------\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;AAQ1C,qDAAqD;AACrD,gBAAgB;AAChB,MAAa,sBAAsB;IAI1B,MAAM,CAAC,0BAA0B,CAAC,QAAoB,IAAY,OAAO,mCAAgB,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExI,8BAA8B;IACtB,MAAM,CAAC,oBAAoB,CAAC,QAAoB;QACtD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ;YAClD,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;YACpD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;YAC7B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AC,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"]}
@@ -0,0 +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
+ }
70
+ //# sourceMappingURL=ChannelControl.d.ts.map
@@ -0,0 +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;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"}
@@ -0,0 +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";
89
+ //# sourceMappingURL=ChannelControl.js.map
@@ -0,0 +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,qBAAg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Aa,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACjC,OAAO;SACR;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,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":["/*---------------------------------------------------------------------------------------------\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"]}
@@ -1,122 +1,122 @@
1
- /** @packageDocumentation
2
- * @module iModels
3
- */
4
- import { BeEvent, GuidString } from "@itwin/core-bentley";
5
- import { ChangesetId, ChangesetIdWithIndex, LocalDirName, LocalFileName } from "@itwin/core-common";
6
- import { CloudSqlite } from "./CloudSqlite";
7
- import { SnapshotDb, TokenArg } from "./IModelDb";
8
- /**
9
- * Properties of a checkpoint
10
- * @public
11
- */
12
- export interface CheckpointProps extends TokenArg {
13
- readonly expectV2?: boolean;
14
- /** iTwin that the iModel belongs to */
15
- readonly iTwinId: GuidString;
16
- /** Id of the iModel */
17
- readonly iModelId: GuidString;
18
- /** changeset for the checkpoint */
19
- readonly changeset: ChangesetIdWithIndex;
20
- /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */
21
- readonly allowPreceding?: boolean;
22
- /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */
23
- readonly reattachSafetySeconds?: number;
24
- }
25
- /** Return value from [[ProgressFunction]].
26
- * @public
27
- */
28
- export declare enum ProgressStatus {
29
- /** Continue download. */
30
- Continue = 0,
31
- /** Abort download. */
32
- Abort = 1
33
- }
34
- /** Called to show progress during a download. If this function returns non-zero, the download is aborted.
35
- * @public
36
- */
37
- export declare type ProgressFunction = (loaded: number, total: number) => ProgressStatus;
38
- /** The parameters that specify a request to download a checkpoint file from iModelHub.
39
- * @internal
40
- */
41
- export interface DownloadRequest {
42
- /** name of local file to hold the downloaded data. */
43
- localFile: LocalFileName;
44
- /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names,
45
- * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name.
46
- * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes.
47
- */
48
- readonly aliasFiles?: ReadonlyArray<string>;
49
- /** Properties of the checkpoint to be downloaded */
50
- readonly checkpoint: CheckpointProps;
51
- /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this
52
- * function returns a non-zero value, the download is aborted.
53
- */
54
- readonly onProgress?: ProgressFunction;
55
- }
56
- /** @internal */
57
- export interface DownloadJob {
58
- request: DownloadRequest;
59
- promise?: Promise<any>;
60
- }
61
- /** @internal */
62
- export declare class Downloads {
63
- private static _active;
64
- private static process;
65
- static isInProgress(pathName: LocalFileName): DownloadJob | undefined;
66
- static download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>): Promise<any>;
67
- }
68
- /**
69
- * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them.
70
- * @internal
71
- */
72
- export declare class V2CheckpointManager {
73
- static readonly cloudCacheName = "v2Checkpoints";
74
- private static _cloudCache?;
75
- private static containers;
76
- static getFolder(): LocalDirName;
77
- static cleanup(): void;
78
- static getFileName(checkpoint: CheckpointProps): LocalFileName;
79
- private static get cloudCache();
80
- /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */
81
- private static toCloudContainerProps;
82
- private static getContainer;
83
- static attach(checkpoint: CheckpointProps): Promise<{
84
- dbName: string;
85
- container: CloudSqlite.CloudContainer;
86
- }>;
87
- private static performDownload;
88
- /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline.
89
- * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will
90
- * be the same as the requested changesetId or the most recent checkpoint before it.)
91
- */
92
- static downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId>;
93
- }
94
- /** Utility class to deal with downloading V1 checkpoints from iModelHub.
95
- * @internal
96
- */
97
- export declare class V1CheckpointManager {
98
- static getFolder(iModelId: GuidString): LocalDirName;
99
- static getFileName(checkpoint: CheckpointProps): LocalFileName;
100
- static getCheckpointDb(request: DownloadRequest): Promise<SnapshotDb>;
101
- /** Download a V1 checkpoint */
102
- static downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId>;
103
- private static downloadAndOpen;
104
- private static performDownload;
105
- }
106
- /** @internal */
107
- export declare class CheckpointManager {
108
- static readonly onDownloadV1: BeEvent<(job: DownloadJob) => void>;
109
- static readonly onDownloadV2: BeEvent<(job: DownloadJob) => void>;
110
- static getKey(checkpoint: CheckpointProps): string;
111
- private static doDownload;
112
- static updateToRequestedVersion(request: DownloadRequest): Promise<void>;
113
- /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */
114
- static downloadCheckpoint(request: DownloadRequest): Promise<void>;
115
- /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */
116
- static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb): void;
117
- /** @returns true if the file is the checkpoint requested */
118
- static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean;
119
- /** try to open an existing local file to satisfy a download request */
120
- static tryOpenLocalFile(request: DownloadRequest): SnapshotDb | undefined;
121
- }
1
+ /** @packageDocumentation
2
+ * @module iModels
3
+ */
4
+ import { BeEvent, GuidString } from "@itwin/core-bentley";
5
+ import { ChangesetId, ChangesetIdWithIndex, LocalDirName, LocalFileName } from "@itwin/core-common";
6
+ import { CloudSqlite } from "./CloudSqlite";
7
+ import { SnapshotDb, TokenArg } from "./IModelDb";
8
+ /**
9
+ * Properties of a checkpoint
10
+ * @public
11
+ */
12
+ export interface CheckpointProps extends TokenArg {
13
+ readonly expectV2?: boolean;
14
+ /** iTwin that the iModel belongs to */
15
+ readonly iTwinId: GuidString;
16
+ /** Id of the iModel */
17
+ readonly iModelId: GuidString;
18
+ /** changeset for the checkpoint */
19
+ readonly changeset: ChangesetIdWithIndex;
20
+ /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */
21
+ readonly allowPreceding?: boolean;
22
+ /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */
23
+ readonly reattachSafetySeconds?: number;
24
+ }
25
+ /** Return value from [[ProgressFunction]].
26
+ * @public
27
+ */
28
+ export declare enum ProgressStatus {
29
+ /** Continue download. */
30
+ Continue = 0,
31
+ /** Abort download. */
32
+ Abort = 1
33
+ }
34
+ /** Called to show progress during a download. If this function returns non-zero, the download is aborted.
35
+ * @public
36
+ */
37
+ export declare type ProgressFunction = (loaded: number, total: number) => ProgressStatus;
38
+ /** The parameters that specify a request to download a checkpoint file from iModelHub.
39
+ * @internal
40
+ */
41
+ export interface DownloadRequest {
42
+ /** name of local file to hold the downloaded data. */
43
+ localFile: LocalFileName;
44
+ /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names,
45
+ * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name.
46
+ * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes.
47
+ */
48
+ readonly aliasFiles?: ReadonlyArray<string>;
49
+ /** Properties of the checkpoint to be downloaded */
50
+ readonly checkpoint: CheckpointProps;
51
+ /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this
52
+ * function returns a non-zero value, the download is aborted.
53
+ */
54
+ readonly onProgress?: ProgressFunction;
55
+ }
56
+ /** @internal */
57
+ export interface DownloadJob {
58
+ request: DownloadRequest;
59
+ promise?: Promise<any>;
60
+ }
61
+ /** @internal */
62
+ export declare class Downloads {
63
+ private static _active;
64
+ private static process;
65
+ static isInProgress(pathName: LocalFileName): DownloadJob | undefined;
66
+ static download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>): Promise<any>;
67
+ }
68
+ /**
69
+ * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them.
70
+ * @internal
71
+ */
72
+ export declare class V2CheckpointManager {
73
+ static readonly cloudCacheName = "v2Checkpoints";
74
+ private static _cloudCache?;
75
+ private static containers;
76
+ static getFolder(): LocalDirName;
77
+ static cleanup(): void;
78
+ static getFileName(checkpoint: CheckpointProps): LocalFileName;
79
+ private static get cloudCache();
80
+ /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */
81
+ private static toCloudContainerProps;
82
+ private static getContainer;
83
+ static attach(checkpoint: CheckpointProps): Promise<{
84
+ dbName: string;
85
+ container: CloudSqlite.CloudContainer;
86
+ }>;
87
+ private static performDownload;
88
+ /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline.
89
+ * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will
90
+ * be the same as the requested changesetId or the most recent checkpoint before it.)
91
+ */
92
+ static downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId>;
93
+ }
94
+ /** Utility class to deal with downloading V1 checkpoints from iModelHub.
95
+ * @internal
96
+ */
97
+ export declare class V1CheckpointManager {
98
+ static getFolder(iModelId: GuidString): LocalDirName;
99
+ static getFileName(checkpoint: CheckpointProps): LocalFileName;
100
+ static getCheckpointDb(request: DownloadRequest): Promise<SnapshotDb>;
101
+ /** Download a V1 checkpoint */
102
+ static downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId>;
103
+ private static downloadAndOpen;
104
+ private static performDownload;
105
+ }
106
+ /** @internal */
107
+ export declare class CheckpointManager {
108
+ static readonly onDownloadV1: BeEvent<(job: DownloadJob) => void>;
109
+ static readonly onDownloadV2: BeEvent<(job: DownloadJob) => void>;
110
+ static getKey(checkpoint: CheckpointProps): string;
111
+ private static doDownload;
112
+ static updateToRequestedVersion(request: DownloadRequest): Promise<void>;
113
+ /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */
114
+ static downloadCheckpoint(request: DownloadRequest): Promise<void>;
115
+ /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */
116
+ static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb): void;
117
+ /** @returns true if the file is the checkpoint requested */
118
+ static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean;
119
+ /** try to open an existing local file to satisfy a download request */
120
+ static tryOpenLocalFile(request: DownloadRequest): SnapshotDb | undefined;
121
+ }
122
122
  //# sourceMappingURL=CheckpointManager.d.ts.map