@itwin/core-backend 4.0.0-dev.52 → 4.0.0-dev.55

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 (223) 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/BackendLoggerCategory.d.ts +90 -91
  8. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  9. package/lib/cjs/BackendLoggerCategory.js +98 -99
  10. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  12. package/lib/cjs/BisCoreSchema.js +60 -60
  13. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  14. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  15. package/lib/cjs/BriefcaseManager.js +408 -408
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +153 -153
  18. package/lib/cjs/Category.js +243 -243
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  21. package/lib/cjs/ChangeSummaryManager.js +444 -444
  22. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  23. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  24. package/lib/cjs/ChangedElementsDb.js +165 -165
  25. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  26. package/lib/cjs/ChangedElementsManager.js +88 -88
  27. package/lib/cjs/ChannelControl.d.ts +69 -69
  28. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  29. package/lib/cjs/ChannelControl.js +88 -88
  30. package/lib/cjs/ChannelControl.js.map +1 -1
  31. package/lib/cjs/CheckpointManager.d.ts +121 -121
  32. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  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 -244
  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/CloudStorageBackend.d.ts +58 -58
  41. package/lib/cjs/CloudStorageBackend.js +170 -170
  42. package/lib/cjs/CodeService.d.ts +396 -396
  43. package/lib/cjs/CodeService.js +63 -63
  44. package/lib/cjs/CodeSpecs.d.ts +55 -55
  45. package/lib/cjs/CodeSpecs.js +124 -124
  46. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  47. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  48. package/lib/cjs/ConcurrentQuery.js +36 -36
  49. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  50. package/lib/cjs/CustomViewState3dCreator.js +82 -82
  51. package/lib/cjs/DevTools.d.ts +74 -73
  52. package/lib/cjs/DevTools.d.ts.map +1 -1
  53. package/lib/cjs/DevTools.js +156 -156
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.d.ts +106 -106
  56. package/lib/cjs/DisplayStyle.js +253 -253
  57. package/lib/cjs/DisplayStyle.js.map +1 -1
  58. package/lib/cjs/ECDb.d.ts +194 -194
  59. package/lib/cjs/ECDb.js +353 -353
  60. package/lib/cjs/ECDb.js.map +1 -1
  61. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  62. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  63. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  64. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  65. package/lib/cjs/ECSqlStatement.js +791 -791
  66. package/lib/cjs/Element.d.ts +1113 -1113
  67. package/lib/cjs/Element.js +1424 -1424
  68. package/lib/cjs/Element.js.map +1 -1
  69. package/lib/cjs/ElementAspect.d.ts +176 -176
  70. package/lib/cjs/ElementAspect.js +203 -203
  71. package/lib/cjs/ElementAspect.js.map +1 -1
  72. package/lib/cjs/ElementGraphics.d.ts +9 -9
  73. package/lib/cjs/ElementGraphics.js +41 -41
  74. package/lib/cjs/ElementGraphics.js.map +1 -1
  75. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  76. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  77. package/lib/cjs/ElementTreeWalker.js +409 -409
  78. package/lib/cjs/Entity.d.ts +106 -106
  79. package/lib/cjs/Entity.d.ts.map +1 -1
  80. package/lib/cjs/Entity.js +134 -134
  81. package/lib/cjs/Entity.js.map +1 -1
  82. package/lib/cjs/EntityReferences.d.ts +49 -49
  83. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  84. package/lib/cjs/EntityReferences.js +95 -95
  85. package/lib/cjs/ExportGraphics.d.ts +317 -317
  86. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  87. package/lib/cjs/ExportGraphics.js +208 -208
  88. package/lib/cjs/ExternalSource.d.ts +96 -96
  89. package/lib/cjs/ExternalSource.js +131 -131
  90. package/lib/cjs/ExternalSource.js.map +1 -1
  91. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  92. package/lib/cjs/GeoCoordConfig.js +85 -85
  93. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  94. package/lib/cjs/GeometrySummary.d.ts +4 -4
  95. package/lib/cjs/GeometrySummary.js +333 -333
  96. package/lib/cjs/GeometrySummary.js.map +1 -1
  97. package/lib/cjs/HubMock.d.ts +94 -94
  98. package/lib/cjs/HubMock.js +220 -220
  99. package/lib/cjs/HubMock.js.map +1 -1
  100. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  101. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  102. package/lib/cjs/IModelCloneContext.js +15 -15
  103. package/lib/cjs/IModelDb.d.ts +1216 -1216
  104. package/lib/cjs/IModelDb.d.ts.map +1 -1
  105. package/lib/cjs/IModelDb.js +2387 -2386
  106. package/lib/cjs/IModelDb.js.map +1 -1
  107. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  108. package/lib/cjs/IModelElementCloneContext.js +159 -159
  109. package/lib/cjs/IModelHost.d.ts +369 -369
  110. package/lib/cjs/IModelHost.js +488 -488
  111. package/lib/cjs/IModelHost.js.map +1 -1
  112. package/lib/cjs/IModelJsFs.d.ts +62 -62
  113. package/lib/cjs/IModelJsFs.js +139 -139
  114. package/lib/cjs/IpcHost.d.ts +104 -104
  115. package/lib/cjs/IpcHost.js +276 -276
  116. package/lib/cjs/IpcHost.js.map +1 -1
  117. package/lib/cjs/LineStyle.d.ts +311 -311
  118. package/lib/cjs/LineStyle.js +295 -295
  119. package/lib/cjs/LocalHub.d.ts +162 -162
  120. package/lib/cjs/LocalHub.d.ts.map +1 -1
  121. package/lib/cjs/LocalHub.js +579 -579
  122. package/lib/cjs/LocalHub.js.map +1 -1
  123. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  124. package/lib/cjs/LocalhostIpcHost.js +79 -79
  125. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  126. package/lib/cjs/Material.d.ts +131 -131
  127. package/lib/cjs/Material.js +180 -180
  128. package/lib/cjs/Material.js.map +1 -1
  129. package/lib/cjs/Model.d.ts +392 -392
  130. package/lib/cjs/Model.js +489 -489
  131. package/lib/cjs/Model.js.map +1 -1
  132. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  133. package/lib/cjs/NativeAppStorage.js +202 -202
  134. package/lib/cjs/NativeAppStorage.js.map +1 -1
  135. package/lib/cjs/NativeHost.d.ts +52 -52
  136. package/lib/cjs/NativeHost.js +160 -160
  137. package/lib/cjs/NativeHost.js.map +1 -1
  138. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  139. package/lib/cjs/NavigationRelationship.js +225 -225
  140. package/lib/cjs/NavigationRelationship.js.map +1 -1
  141. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  142. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  143. package/lib/cjs/PromiseMemoizer.js +101 -101
  144. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  145. package/lib/cjs/PropertyStore.d.ts +132 -132
  146. package/lib/cjs/PropertyStore.js +11 -11
  147. package/lib/cjs/Relationship.d.ts +416 -416
  148. package/lib/cjs/Relationship.js +494 -494
  149. package/lib/cjs/Relationship.js.map +1 -1
  150. package/lib/cjs/RpcBackend.d.ts +5 -5
  151. package/lib/cjs/RpcBackend.js +32 -32
  152. package/lib/cjs/SQLiteDb.d.ts +219 -219
  153. package/lib/cjs/SQLiteDb.js +212 -212
  154. package/lib/cjs/Schema.d.ts +55 -55
  155. package/lib/cjs/Schema.js +83 -83
  156. package/lib/cjs/Schema.js.map +1 -1
  157. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  158. package/lib/cjs/ServerBasedLocks.js +168 -168
  159. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  160. package/lib/cjs/SqliteStatement.d.ts +360 -360
  161. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  162. package/lib/cjs/SqliteStatement.js +586 -586
  163. package/lib/cjs/Texture.d.ts +58 -58
  164. package/lib/cjs/Texture.js +82 -82
  165. package/lib/cjs/Texture.js.map +1 -1
  166. package/lib/cjs/TileStorage.d.ts +18 -18
  167. package/lib/cjs/TileStorage.js +87 -87
  168. package/lib/cjs/TxnManager.d.ts +202 -202
  169. package/lib/cjs/TxnManager.d.ts.map +1 -1
  170. package/lib/cjs/TxnManager.js +356 -356
  171. package/lib/cjs/TxnManager.js.map +1 -1
  172. package/lib/cjs/ViewDefinition.d.ts +435 -435
  173. package/lib/cjs/ViewDefinition.js +646 -646
  174. package/lib/cjs/ViewDefinition.js.map +1 -1
  175. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  176. package/lib/cjs/ViewStateHydrator.js +103 -103
  177. package/lib/cjs/core-backend.d.ts +185 -185
  178. package/lib/cjs/core-backend.js +209 -205
  179. package/lib/cjs/core-backend.js.map +1 -1
  180. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  181. package/lib/cjs/domains/FunctionalElements.js +145 -145
  182. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  183. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  184. package/lib/cjs/domains/FunctionalSchema.js +39 -39
  185. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  186. package/lib/cjs/domains/GenericElements.js +263 -263
  187. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  188. package/lib/cjs/domains/GenericSchema.js +28 -28
  189. package/lib/cjs/rpc/multipart.d.ts +11 -11
  190. package/lib/cjs/rpc/multipart.js +71 -71
  191. package/lib/cjs/rpc/tracing.d.ts +28 -28
  192. package/lib/cjs/rpc/tracing.js +73 -73
  193. package/lib/cjs/rpc/tracing.js.map +1 -1
  194. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  195. package/lib/cjs/rpc/web/logging.js +43 -43
  196. package/lib/cjs/rpc/web/request.d.ts +6 -6
  197. package/lib/cjs/rpc/web/request.js +73 -73
  198. package/lib/cjs/rpc/web/response.d.ts +6 -6
  199. package/lib/cjs/rpc/web/response.js +105 -105
  200. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  201. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  202. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  203. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -293
  204. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  205. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  206. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  207. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  208. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  209. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -166
  210. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  211. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -42
  212. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  213. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  214. package/lib/cjs/workspace/Settings.d.ts +186 -186
  215. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  216. package/lib/cjs/workspace/Settings.js +154 -154
  217. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  218. package/lib/cjs/workspace/SettingsSchemas.js +190 -190
  219. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  220. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  221. package/lib/cjs/workspace/Workspace.js +537 -537
  222. package/lib/cjs/workspace/Workspace.js.map +1 -1
  223. package/package.json +12 -12
@@ -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;IAClE,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,aAAa,CAAqC;IAC1D,OAAO,CAAC,YAAY,CAAC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ACtB,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,iBAAiB,CAAC,UAAsB;QAC7C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,C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I,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,UAAU,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IACD,IAAW,WAAW;QACpB,IAAI,SAAS,KAAK,IAAI,C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,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":["/*---------------------------------------------------------------------------------------------\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,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 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
@@ -1 +1 @@
1
- {"version":3,"file":"CheckpointManager.d.ts","sourceRoot":"","sources":["../../src/CheckpointManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,OAAO,EAAyB,UAAU,EAAgE,MAAM,qBAAqB,CAAC;AAC/I,OAAO,EACa,WAAW,EAAE,oBAAoB,EAAmD,YAAY,EAAE,aAAa,EAClI,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOlD;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,uBAAuB;IACvB,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAE9B,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;IAEzC,8IAA8I;IAC9I,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAElC,qHAAqH;IACrH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CACzC;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,yBAAyB;IACzB,QAAQ,IAAI;IACZ,sBAAsB;IACtB,KAAK,IAAI;CACV;AAED;;GAEG;AACH,oBAAY,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,cAAc,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,SAAS,EAAE,aAAa,CAAC;IAEzB;;;OAGG;IACH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