@itwin/core-backend 4.0.0-dev.46 → 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 +11 -11
@@ -1,495 +1,495 @@
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 Relationships
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Relationships = exports.ModelSelectorRefersToModels = exports.ElementDrivesElement = exports.ExternalSourceGroupGroupsSources = exports.GroupImpartsToMembers = exports.DefinitionGroupGroupsDefinitions = exports.ElementGroupsMembers = exports.SynchronizationConfigSpecifiesRootSources = exports.SynchronizationConfigProcessesSources = exports.GraphicalElement3dRepresentsElement = exports.DrawingGraphicRepresentsElement = exports.ElementRefersToElements = exports.Relationship = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- const Entity_1 = require("./Entity");
14
- /** Base class for all link table ECRelationships
15
- * @public
16
- */
17
- class Relationship extends Entity_1.Entity {
18
- /** @internal */
19
- constructor(props, iModel) {
20
- super(props, iModel);
21
- this.sourceId = core_bentley_1.Id64.fromJSON(props.sourceId);
22
- this.targetId = core_bentley_1.Id64.fromJSON(props.targetId);
23
- }
24
- /** @internal */
25
- static get className() { return "Relationship"; }
26
- /** @internal */
27
- toJSON() {
28
- const val = super.toJSON();
29
- val.sourceId = this.sourceId;
30
- val.targetId = this.targetId;
31
- return val;
32
- }
33
- /**
34
- * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.
35
- * This callback is invoked after the input element has been processed by upstream relationships.
36
- * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.
37
- * @param _props The ElementDrivesElement relationship instance.
38
- * @param _iModel The iModel
39
- */
40
- static onRootChanged(_props, _iModel) { }
41
- /**
42
- * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.
43
- * A subclass of ElementDrivesElement can re-implement this static method to take some action.
44
- * @param _props The deleted ElementDrivesElement relationship instance.
45
- * @param _iModel The iModel
46
- */
47
- static onDeletedDependency(_props, _iModel) { }
48
- /** Insert this Relationship into the iModel. */
49
- insert() { return this.id = this.iModel.relationships.insertInstance(this.toJSON()); }
50
- /** Update this Relationship in the iModel. */
51
- update() { this.iModel.relationships.updateInstance(this.toJSON()); }
52
- /** Delete this Relationship from the iModel. */
53
- delete() { this.iModel.relationships.deleteInstance(this.toJSON()); }
54
- static getInstance(iModel, criteria) { return iModel.relationships.getInstance(this.classFullName, criteria); }
55
- }
56
- exports.Relationship = Relationship;
57
- /** A Relationship where one Element refers to another Element
58
- * @public
59
- */
60
- class ElementRefersToElements extends Relationship {
61
- /** @internal */
62
- static get className() { return "ElementRefersToElements"; }
63
- /** Create an instance of the Relationship.
64
- * @param iModel The iModel that will contain the relationship
65
- * @param sourceId The sourceId of the relationship, that is, the driver element
66
- * @param targetId The targetId of the relationship, that is, the driven element
67
- * @return an instance of the specified class.
68
- */
69
- static create(iModel, sourceId, targetId) {
70
- return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName });
71
- }
72
- /** Insert a new instance of the Relationship.
73
- * @param iModel The iModel that will contain the relationship
74
- * @param sourceId The sourceId of the relationship, that is, the driver element
75
- * @param targetId The targetId of the relationship, that is, the driven element
76
- * @return The Id of the inserted Relationship.
77
- */
78
- static insert(iModel, sourceId, targetId) {
79
- const relationship = this.create(iModel, sourceId, targetId);
80
- return iModel.relationships.insertInstance(relationship.toJSON());
81
- }
82
- /** @internal */
83
- collectReferenceConcreteIds(referenceIds) {
84
- super.collectReferenceConcreteIds(referenceIds);
85
- referenceIds.addElement(this.sourceId);
86
- referenceIds.addElement(this.targetId);
87
- }
88
- }
89
- exports.ElementRefersToElements = ElementRefersToElements;
90
- /** Relates a [[DrawingGraphic]] to the [[Element]] that it represents
91
- * @public
92
- */
93
- class DrawingGraphicRepresentsElement extends ElementRefersToElements {
94
- /** @internal */
95
- static get className() { return "DrawingGraphicRepresentsElement"; }
96
- }
97
- exports.DrawingGraphicRepresentsElement = DrawingGraphicRepresentsElement;
98
- /** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents
99
- * @public
100
- */
101
- class GraphicalElement3dRepresentsElement extends ElementRefersToElements {
102
- /** @internal */
103
- static get className() { return "GraphicalElement3dRepresentsElement"; }
104
- }
105
- exports.GraphicalElement3dRepresentsElement = GraphicalElement3dRepresentsElement;
106
- /** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.
107
- * Each relationship instance represents an external source processed by the synchronization configuration.
108
- * @note The associated ECClass was added to the BisCore schema in version 1.0.13
109
- * @beta
110
- */
111
- class SynchronizationConfigProcessesSources extends ElementRefersToElements {
112
- /** @internal */
113
- static get className() { return "SynchronizationConfigProcessesSources"; }
114
- }
115
- exports.SynchronizationConfigProcessesSources = SynchronizationConfigProcessesSources;
116
- /** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.
117
- * @note The associated ECClass was added to the BisCore schema in version 1.0.13
118
- * @beta
119
- */
120
- class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {
121
- /** @internal */
122
- static get className() { return "SynchronizationConfigSpecifiesRootSources"; }
123
- }
124
- exports.SynchronizationConfigSpecifiesRootSources = SynchronizationConfigSpecifiesRootSources;
125
- /** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.
126
- * @public
127
- */
128
- class ElementGroupsMembers extends ElementRefersToElements {
129
- constructor(props, iModel) {
130
- super(props, iModel);
131
- this.memberPriority = props.memberPriority;
132
- }
133
- /** @internal */
134
- static get className() { return "ElementGroupsMembers"; }
135
- static create(iModel, sourceId, targetId, memberPriority = 0) {
136
- const props = { sourceId, targetId, memberPriority, classFullName: this.classFullName };
137
- return iModel.relationships.createInstance(props);
138
- }
139
- }
140
- exports.ElementGroupsMembers = ElementGroupsMembers;
141
- /** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.
142
- * @note The associated ECClass was added to the BisCore schema in version 1.0.10
143
- * @public
144
- */
145
- class DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {
146
- /** @internal */
147
- static get className() { return "DefinitionGroupGroupsDefinitions"; }
148
- }
149
- exports.DefinitionGroupGroupsDefinitions = DefinitionGroupGroupsDefinitions;
150
- /** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.
151
- * Implies that properties of the group should be considered as properties of its members.
152
- * @note The associated ECClass was added to the BisCore schema in version 1.0.11
153
- * @public
154
- */
155
- class GroupImpartsToMembers extends ElementGroupsMembers {
156
- /** @internal */
157
- static get className() { return "GroupImpartsToMembers"; }
158
- }
159
- exports.GroupImpartsToMembers = GroupImpartsToMembers;
160
- /** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.
161
- * @note The associated ECClass was added to the BisCore schema in version 1.0.13
162
- * @beta
163
- */
164
- class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {
165
- /** @internal */
166
- static get className() { return "ExternalSourceGroupGroupsSources"; }
167
- }
168
- exports.ExternalSourceGroupGroupsSources = ExternalSourceGroupGroupsSources;
169
- /** A Relationship indicating that one Element *drives* another Element.
170
- * An ElementDrivesElement relationship defines a one-way "driving" relationship from the source to the target.
171
- * When the source of an ElementDrivesElement relationship changes, the ElementDrivesElement itself can get a callback, and both the source and target elements can get callbacks.
172
- * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.
173
- *
174
- * # Defining dependencies
175
- * Create an ElementDrivesElement relationship to specify that the source element drives the target element.
176
- * For example, to specify that element e1 drives element e2, create a relationship between them like this:
177
- * ```ts
178
- * const ede = ElementDrivesElement.create(iModel, e1id, e2id);
179
- * ede.insert();
180
- * ```
181
- * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.
182
- *
183
- * # Defining dependency graphs
184
- * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.
185
- * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.
186
- *
187
- * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:
188
- * ```ts
189
- * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);
190
- * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);
191
- * ede12.insert();
192
- * ede23.insert();
193
- * ```
194
- * Those two relationships create this graph:
195
- * ```
196
- * e1 --> e2 --> e3
197
- * ```
198
- * Where the "-->" is meant to represent a driving relationship.
199
- *
200
- * The order in which you create the relationships does not matter.
201
- * The graph indicates that e3 depends on e2 and e2 depends on e1.
202
- *
203
- * An ElementDrivesElement relationship is between one source element and one target element.
204
- * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.
205
- * Thus, you can define many:many relationships.
206
- * For example:
207
- * ```ts
208
- * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);
209
- * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);
210
- * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);
211
- * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);
212
- * ede12.insert();
213
- * ede112.insert();
214
- * ede23.insert();
215
- * ede231.insert();
216
- * ```
217
- * Creates this graph:
218
- * ```
219
- * e1 e3
220
- * \ /
221
- * e2
222
- * / \
223
- * e11 e31
224
- * ```
225
- * e2 depends on both e1 and e11. e2 then drives e3 and e31.
226
- *
227
- * In an ElementDrivesElement dependency graph, the relationships are the "edges" and the Elements are the "nodes".
228
- * The following terms are used when referring to the elements (nodes) in a dependency graph:
229
- * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.
230
- * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.
231
- *
232
- * # Subgraph Processing
233
- * When changes are made, only the part of the overall graph that is affected will be processed. So, for example,
234
- * suppose we have this graph:
235
- * ```
236
- * e1 --> e2 --> e3
237
- * ```
238
- * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.
239
- *
240
- * If only e2 changes, then the subgraph to be processed is just:
241
- * ```
242
- * e2 --> e3
243
- * ```
244
- * If only e3 changes, then the subgraph consists of e3 by itself.
245
- *
246
- * Returning to the second example above, suppose we have this graph:
247
- * ```
248
- * e1 e3
249
- * \ /
250
- * e2
251
- * / \
252
- * e11 e31
253
- * ```
254
- * If e1 is changed, the affected subgraph is:
255
- * ```
256
- * e1 e3
257
- * \ /
258
- * e2
259
- * \
260
- * e31
261
- * ```
262
- * If e2 is changed, the affected subgraph is:
263
- * ```
264
- * e3
265
- * /
266
- * e2
267
- * \
268
- * e31
269
- * ```
270
- * # Callbacks
271
- * Once the affected subgraph to process is found, it propagates changes through it by making callbacks.
272
- * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.
273
- *
274
- * ## ElementDrivesElement Callbacks
275
- * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):
276
- * * onRootChanged
277
- * * onDeletedDependency
278
- *
279
- * Note that these are static methods. Their default implementations do nothing.
280
- * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.
281
- * The subclass should then implement the callbacks that it would like to act on.
282
- *
283
- * A ElementDrivesElement subclass callback is expected to make changes to the output element only!
284
- *
285
- * ## Element Callbacks
286
- * The following callbacks are invoked on Element classes (nodes):
287
- * * Element.onBeforeOutputsHandled
288
- * * Element.onAllInputsHandled
289
- *
290
- * ## Order
291
- * Callbacks are invoked by BriefcaseDb.saveChanges.
292
- * They are invoked in dependency (topological) order: driving elements first, then driven elements.
293
- *
294
- * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,
295
- * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.
296
- * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be
297
- * invoked only once.
298
- *
299
- * For example, suppose we have a graph:
300
- * ```
301
- * e1 --> e2 --> e3
302
- * ```
303
- *
304
- * Suppose that e1 is directly modified. No callbacks are made at that time.
305
- * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:
306
- * 1. Element.onBeforeOutputsHandled e1
307
- * 1. ElementDrivesElement.onRootChanged e1->e2
308
- * 1. Element.onAllInputsHandled e2
309
- * 1. ElementDrivesElement.onRootChanged e2->e3
310
- * 1. Element.onAllInputsHandled e3
311
- *
312
- * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.
313
- * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.
314
- *
315
- * Returning to the second example above, suppose we have this graph:
316
- * ```
317
- * e1 e3
318
- * \ /
319
- * e2
320
- * / \
321
- * e11 e31
322
- * ```
323
- * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:
324
- * ```
325
- * e1 e3
326
- * \ /
327
- * e2
328
- * \
329
- * e31
330
- * ```
331
- * The callbacks are:
332
- * 1. Element.onBeforeOutputsHandled e1
333
- * 1. ElementDrivesElement.onRootChanged e1->e2
334
- * 1. Element.onAllInputsHandled e2
335
- * 1. ElementDrivesElement.onRootChanged e2->e3
336
- * 1. Element.onAllInputsHandled e3
337
- * 1. ElementDrivesElement.onRootChanged e2->e31
338
- * 1. Element.onAllInputsHandled e31
339
- *
340
- * (The ElementDrivesElement.)
341
- *
342
- * #Errors
343
- * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships
344
- * involved in a cycle will have their status set to 1, indicating a failure.
345
- *
346
- * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.
347
- * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing failure in that edge.
348
- *
349
- * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.
350
- *
351
- * @beta
352
- */
353
- class ElementDrivesElement extends Relationship {
354
- /** @internal */
355
- constructor(props, iModel) {
356
- super(props, iModel);
357
- this.status = props.status;
358
- this.priority = props.priority;
359
- }
360
- /** @internal */
361
- static get className() { return "ElementDrivesElement"; }
362
- static create(iModel, sourceId, targetId, priority = 0) {
363
- const props = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };
364
- return iModel.relationships.createInstance(props);
365
- }
366
- toJSON() {
367
- const props = super.toJSON();
368
- props.status = this.status;
369
- props.priority = this.priority;
370
- return props;
371
- }
372
- /** @internal */
373
- collectReferenceConcreteIds(referenceIds) {
374
- super.collectReferenceConcreteIds(referenceIds);
375
- referenceIds.addElement(this.sourceId);
376
- referenceIds.addElement(this.targetId);
377
- }
378
- }
379
- exports.ElementDrivesElement = ElementDrivesElement;
380
- /** The third (and last) possible link-table relationship base class in an iModel.
381
- * Has no external use, but is included for completeness of the [Entity.collectReferenceConcreteIds]($backend)
382
- * implementations for link-table relationships. Generating the types of the source and target automatically would require
383
- * coupling this package with ecschema-metadata which we do not want to do.
384
- * @internal
385
- */
386
- class ModelSelectorRefersToModels extends Relationship {
387
- /** @internal */
388
- static get className() { return "ModelSelectorRefersToModels"; }
389
- /** @internal */
390
- collectReferenceConcreteIds(referenceIds) {
391
- super.collectReferenceConcreteIds(referenceIds);
392
- referenceIds.addElement(this.sourceId);
393
- referenceIds.addModel(this.targetId);
394
- }
395
- }
396
- exports.ModelSelectorRefersToModels = ModelSelectorRefersToModels;
397
- /** Manages [[Relationship]]s.
398
- * @public
399
- */
400
- class Relationships {
401
- /** @internal */
402
- constructor(iModel) { this._iModel = iModel; }
403
- /** Create a new instance of a Relationship.
404
- * @param props The properties of the new Relationship.
405
- * @throws [[IModelError]] if there is a problem creating the Relationship.
406
- */
407
- createInstance(props) { return this._iModel.constructEntity(props); }
408
- /** Check classFullName to ensure it is a link table relationship class. */
409
- checkRelationshipClass(classFullName) {
410
- if (!this._iModel.nativeDb.isLinkTableRelationship(classFullName.replace(".", ":"))) {
411
- throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);
412
- }
413
- }
414
- /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.
415
- * @param props The properties of the new relationship.
416
- * @returns The Id of the newly inserted relationship.
417
- * @note The id property of the props object is set as a side effect of this function.
418
- */
419
- insertInstance(props) {
420
- this.checkRelationshipClass(props.classFullName);
421
- return props.id = this._iModel.nativeDb.insertLinkTableRelationship(props);
422
- }
423
- /** Update the properties of an existing relationship instance in the iModel.
424
- * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.
425
- */
426
- updateInstance(props) {
427
- this._iModel.nativeDb.updateLinkTableRelationship(props);
428
- }
429
- /** Delete an Relationship instance from this iModel. */
430
- deleteInstance(props) {
431
- this._iModel.nativeDb.deleteLinkTableRelationship(props);
432
- }
433
- /** Get the props of a Relationship instance
434
- * @param relClassFullName The full class name of the relationship in the form of "schema:class"
435
- * @param criteria Either the relationship instanceId or the source and target Ids
436
- * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.
437
- * @see tryGetInstanceProps
438
- */
439
- getInstanceProps(relClassFullName, criteria) {
440
- const relationshipProps = this.tryGetInstanceProps(relClassFullName, criteria);
441
- if (undefined === relationshipProps) {
442
- throw new core_common_1.IModelError(core_common_1.IModelStatus.NotFound, "Relationship not found");
443
- }
444
- return relationshipProps;
445
- }
446
- /** Get the props of a Relationship instance
447
- * @param relClassFullName The full class name of the relationship in the form of "schema:class"
448
- * @param criteria Either the relationship instanceId or the source and target Ids
449
- * @returns The RelationshipProps or `undefined` if the relationship is not found.
450
- * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.
451
- * @see getInstanceProps
452
- */
453
- tryGetInstanceProps(relClassFullName, criteria) {
454
- let props;
455
- if (typeof criteria === "string") {
456
- props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (stmt) => {
457
- stmt.bindId(1, criteria);
458
- return core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() : undefined;
459
- });
460
- }
461
- else {
462
- props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (stmt) => {
463
- stmt.bindId(1, criteria.sourceId);
464
- stmt.bindId(2, criteria.targetId);
465
- return core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() : undefined;
466
- });
467
- }
468
- if (undefined !== props) {
469
- props.classFullName = props.className.replace(".", ":");
470
- }
471
- return props;
472
- }
473
- /** Get a Relationship instance
474
- * @param relClassFullName The full class name of the relationship in the form of "schema:class"
475
- * @param criteria Either the relationship instanceId or the source and target Ids
476
- * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.
477
- * @see tryGetInstance
478
- */
479
- getInstance(relClassSqlName, criteria) {
480
- return this._iModel.constructEntity(this.getInstanceProps(relClassSqlName, criteria));
481
- }
482
- /** Get a Relationship instance
483
- * @param relClassFullName The full class name of the relationship in the form of "schema:class"
484
- * @param criteria Either the relationship instanceId or the source and target Ids
485
- * @returns The relationship or `undefined` if the relationship is not found.
486
- * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.
487
- * @see getInstance
488
- */
489
- tryGetInstance(relClassFullName, criteria) {
490
- const relationshipProps = this.tryGetInstanceProps(relClassFullName, criteria);
491
- return undefined !== relationshipProps ? this._iModel.constructEntity(relationshipProps) : undefined;
492
- }
493
- }
494
- exports.Relationships = Relationships;
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 Relationships
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Relationships = exports.ModelSelectorRefersToModels = exports.ElementDrivesElement = exports.ExternalSourceGroupGroupsSources = exports.GroupImpartsToMembers = exports.DefinitionGroupGroupsDefinitions = exports.ElementGroupsMembers = exports.SynchronizationConfigSpecifiesRootSources = exports.SynchronizationConfigProcessesSources = exports.GraphicalElement3dRepresentsElement = exports.DrawingGraphicRepresentsElement = exports.ElementRefersToElements = exports.Relationship = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const Entity_1 = require("./Entity");
14
+ /** Base class for all link table ECRelationships
15
+ * @public
16
+ */
17
+ class Relationship extends Entity_1.Entity {
18
+ /** @internal */
19
+ constructor(props, iModel) {
20
+ super(props, iModel);
21
+ this.sourceId = core_bentley_1.Id64.fromJSON(props.sourceId);
22
+ this.targetId = core_bentley_1.Id64.fromJSON(props.targetId);
23
+ }
24
+ /** @internal */
25
+ static get className() { return "Relationship"; }
26
+ /** @internal */
27
+ toJSON() {
28
+ const val = super.toJSON();
29
+ val.sourceId = this.sourceId;
30
+ val.targetId = this.targetId;
31
+ return val;
32
+ }
33
+ /**
34
+ * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.
35
+ * This callback is invoked after the input element has been processed by upstream relationships.
36
+ * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.
37
+ * @param _props The ElementDrivesElement relationship instance.
38
+ * @param _iModel The iModel
39
+ */
40
+ static onRootChanged(_props, _iModel) { }
41
+ /**
42
+ * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.
43
+ * A subclass of ElementDrivesElement can re-implement this static method to take some action.
44
+ * @param _props The deleted ElementDrivesElement relationship instance.
45
+ * @param _iModel The iModel
46
+ */
47
+ static onDeletedDependency(_props, _iModel) { }
48
+ /** Insert this Relationship into the iModel. */
49
+ insert() { return this.id = this.iModel.relationships.insertInstance(this.toJSON()); }
50
+ /** Update this Relationship in the iModel. */
51
+ update() { this.iModel.relationships.updateInstance(this.toJSON()); }
52
+ /** Delete this Relationship from the iModel. */
53
+ delete() { this.iModel.relationships.deleteInstance(this.toJSON()); }
54
+ static getInstance(iModel, criteria) { return iModel.relationships.getInstance(this.classFullName, criteria); }
55
+ }
56
+ exports.Relationship = Relationship;
57
+ /** A Relationship where one Element refers to another Element
58
+ * @public
59
+ */
60
+ class ElementRefersToElements extends Relationship {
61
+ /** @internal */
62
+ static get className() { return "ElementRefersToElements"; }
63
+ /** Create an instance of the Relationship.
64
+ * @param iModel The iModel that will contain the relationship
65
+ * @param sourceId The sourceId of the relationship, that is, the driver element
66
+ * @param targetId The targetId of the relationship, that is, the driven element
67
+ * @return an instance of the specified class.
68
+ */
69
+ static create(iModel, sourceId, targetId) {
70
+ return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName });
71
+ }
72
+ /** Insert a new instance of the Relationship.
73
+ * @param iModel The iModel that will contain the relationship
74
+ * @param sourceId The sourceId of the relationship, that is, the driver element
75
+ * @param targetId The targetId of the relationship, that is, the driven element
76
+ * @return The Id of the inserted Relationship.
77
+ */
78
+ static insert(iModel, sourceId, targetId) {
79
+ const relationship = this.create(iModel, sourceId, targetId);
80
+ return iModel.relationships.insertInstance(relationship.toJSON());
81
+ }
82
+ /** @internal */
83
+ collectReferenceConcreteIds(referenceIds) {
84
+ super.collectReferenceConcreteIds(referenceIds);
85
+ referenceIds.addElement(this.sourceId);
86
+ referenceIds.addElement(this.targetId);
87
+ }
88
+ }
89
+ exports.ElementRefersToElements = ElementRefersToElements;
90
+ /** Relates a [[DrawingGraphic]] to the [[Element]] that it represents
91
+ * @public
92
+ */
93
+ class DrawingGraphicRepresentsElement extends ElementRefersToElements {
94
+ /** @internal */
95
+ static get className() { return "DrawingGraphicRepresentsElement"; }
96
+ }
97
+ exports.DrawingGraphicRepresentsElement = DrawingGraphicRepresentsElement;
98
+ /** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents
99
+ * @public
100
+ */
101
+ class GraphicalElement3dRepresentsElement extends ElementRefersToElements {
102
+ /** @internal */
103
+ static get className() { return "GraphicalElement3dRepresentsElement"; }
104
+ }
105
+ exports.GraphicalElement3dRepresentsElement = GraphicalElement3dRepresentsElement;
106
+ /** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.
107
+ * Each relationship instance represents an external source processed by the synchronization configuration.
108
+ * @note The associated ECClass was added to the BisCore schema in version 1.0.13
109
+ * @beta
110
+ */
111
+ class SynchronizationConfigProcessesSources extends ElementRefersToElements {
112
+ /** @internal */
113
+ static get className() { return "SynchronizationConfigProcessesSources"; }
114
+ }
115
+ exports.SynchronizationConfigProcessesSources = SynchronizationConfigProcessesSources;
116
+ /** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.
117
+ * @note The associated ECClass was added to the BisCore schema in version 1.0.13
118
+ * @beta
119
+ */
120
+ class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {
121
+ /** @internal */
122
+ static get className() { return "SynchronizationConfigSpecifiesRootSources"; }
123
+ }
124
+ exports.SynchronizationConfigSpecifiesRootSources = SynchronizationConfigSpecifiesRootSources;
125
+ /** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.
126
+ * @public
127
+ */
128
+ class ElementGroupsMembers extends ElementRefersToElements {
129
+ constructor(props, iModel) {
130
+ super(props, iModel);
131
+ this.memberPriority = props.memberPriority;
132
+ }
133
+ /** @internal */
134
+ static get className() { return "ElementGroupsMembers"; }
135
+ static create(iModel, sourceId, targetId, memberPriority = 0) {
136
+ const props = { sourceId, targetId, memberPriority, classFullName: this.classFullName };
137
+ return iModel.relationships.createInstance(props);
138
+ }
139
+ }
140
+ exports.ElementGroupsMembers = ElementGroupsMembers;
141
+ /** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.
142
+ * @note The associated ECClass was added to the BisCore schema in version 1.0.10
143
+ * @public
144
+ */
145
+ class DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {
146
+ /** @internal */
147
+ static get className() { return "DefinitionGroupGroupsDefinitions"; }
148
+ }
149
+ exports.DefinitionGroupGroupsDefinitions = DefinitionGroupGroupsDefinitions;
150
+ /** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.
151
+ * Implies that properties of the group should be considered as properties of its members.
152
+ * @note The associated ECClass was added to the BisCore schema in version 1.0.11
153
+ * @public
154
+ */
155
+ class GroupImpartsToMembers extends ElementGroupsMembers {
156
+ /** @internal */
157
+ static get className() { return "GroupImpartsToMembers"; }
158
+ }
159
+ exports.GroupImpartsToMembers = GroupImpartsToMembers;
160
+ /** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.
161
+ * @note The associated ECClass was added to the BisCore schema in version 1.0.13
162
+ * @beta
163
+ */
164
+ class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {
165
+ /** @internal */
166
+ static get className() { return "ExternalSourceGroupGroupsSources"; }
167
+ }
168
+ exports.ExternalSourceGroupGroupsSources = ExternalSourceGroupGroupsSources;
169
+ /** A Relationship indicating that one Element *drives* another Element.
170
+ * An ElementDrivesElement relationship defines a one-way "driving" relationship from the source to the target.
171
+ * When the source of an ElementDrivesElement relationship changes, the ElementDrivesElement itself can get a callback, and both the source and target elements can get callbacks.
172
+ * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.
173
+ *
174
+ * # Defining dependencies
175
+ * Create an ElementDrivesElement relationship to specify that the source element drives the target element.
176
+ * For example, to specify that element e1 drives element e2, create a relationship between them like this:
177
+ * ```ts
178
+ * const ede = ElementDrivesElement.create(iModel, e1id, e2id);
179
+ * ede.insert();
180
+ * ```
181
+ * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.
182
+ *
183
+ * # Defining dependency graphs
184
+ * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.
185
+ * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.
186
+ *
187
+ * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:
188
+ * ```ts
189
+ * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);
190
+ * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);
191
+ * ede12.insert();
192
+ * ede23.insert();
193
+ * ```
194
+ * Those two relationships create this graph:
195
+ * ```
196
+ * e1 --> e2 --> e3
197
+ * ```
198
+ * Where the "-->" is meant to represent a driving relationship.
199
+ *
200
+ * The order in which you create the relationships does not matter.
201
+ * The graph indicates that e3 depends on e2 and e2 depends on e1.
202
+ *
203
+ * An ElementDrivesElement relationship is between one source element and one target element.
204
+ * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.
205
+ * Thus, you can define many:many relationships.
206
+ * For example:
207
+ * ```ts
208
+ * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);
209
+ * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);
210
+ * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);
211
+ * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);
212
+ * ede12.insert();
213
+ * ede112.insert();
214
+ * ede23.insert();
215
+ * ede231.insert();
216
+ * ```
217
+ * Creates this graph:
218
+ * ```
219
+ * e1 e3
220
+ * \ /
221
+ * e2
222
+ * / \
223
+ * e11 e31
224
+ * ```
225
+ * e2 depends on both e1 and e11. e2 then drives e3 and e31.
226
+ *
227
+ * In an ElementDrivesElement dependency graph, the relationships are the "edges" and the Elements are the "nodes".
228
+ * The following terms are used when referring to the elements (nodes) in a dependency graph:
229
+ * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.
230
+ * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.
231
+ *
232
+ * # Subgraph Processing
233
+ * When changes are made, only the part of the overall graph that is affected will be processed. So, for example,
234
+ * suppose we have this graph:
235
+ * ```
236
+ * e1 --> e2 --> e3
237
+ * ```
238
+ * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.
239
+ *
240
+ * If only e2 changes, then the subgraph to be processed is just:
241
+ * ```
242
+ * e2 --> e3
243
+ * ```
244
+ * If only e3 changes, then the subgraph consists of e3 by itself.
245
+ *
246
+ * Returning to the second example above, suppose we have this graph:
247
+ * ```
248
+ * e1 e3
249
+ * \ /
250
+ * e2
251
+ * / \
252
+ * e11 e31
253
+ * ```
254
+ * If e1 is changed, the affected subgraph is:
255
+ * ```
256
+ * e1 e3
257
+ * \ /
258
+ * e2
259
+ * \
260
+ * e31
261
+ * ```
262
+ * If e2 is changed, the affected subgraph is:
263
+ * ```
264
+ * e3
265
+ * /
266
+ * e2
267
+ * \
268
+ * e31
269
+ * ```
270
+ * # Callbacks
271
+ * Once the affected subgraph to process is found, it propagates changes through it by making callbacks.
272
+ * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.
273
+ *
274
+ * ## ElementDrivesElement Callbacks
275
+ * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):
276
+ * * onRootChanged
277
+ * * onDeletedDependency
278
+ *
279
+ * Note that these are static methods. Their default implementations do nothing.
280
+ * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.
281
+ * The subclass should then implement the callbacks that it would like to act on.
282
+ *
283
+ * A ElementDrivesElement subclass callback is expected to make changes to the output element only!
284
+ *
285
+ * ## Element Callbacks
286
+ * The following callbacks are invoked on Element classes (nodes):
287
+ * * Element.onBeforeOutputsHandled
288
+ * * Element.onAllInputsHandled
289
+ *
290
+ * ## Order
291
+ * Callbacks are invoked by BriefcaseDb.saveChanges.
292
+ * They are invoked in dependency (topological) order: driving elements first, then driven elements.
293
+ *
294
+ * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,
295
+ * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.
296
+ * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be
297
+ * invoked only once.
298
+ *
299
+ * For example, suppose we have a graph:
300
+ * ```
301
+ * e1 --> e2 --> e3
302
+ * ```
303
+ *
304
+ * Suppose that e1 is directly modified. No callbacks are made at that time.
305
+ * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:
306
+ * 1. Element.onBeforeOutputsHandled e1
307
+ * 1. ElementDrivesElement.onRootChanged e1->e2
308
+ * 1. Element.onAllInputsHandled e2
309
+ * 1. ElementDrivesElement.onRootChanged e2->e3
310
+ * 1. Element.onAllInputsHandled e3
311
+ *
312
+ * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.
313
+ * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.
314
+ *
315
+ * Returning to the second example above, suppose we have this graph:
316
+ * ```
317
+ * e1 e3
318
+ * \ /
319
+ * e2
320
+ * / \
321
+ * e11 e31
322
+ * ```
323
+ * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:
324
+ * ```
325
+ * e1 e3
326
+ * \ /
327
+ * e2
328
+ * \
329
+ * e31
330
+ * ```
331
+ * The callbacks are:
332
+ * 1. Element.onBeforeOutputsHandled e1
333
+ * 1. ElementDrivesElement.onRootChanged e1->e2
334
+ * 1. Element.onAllInputsHandled e2
335
+ * 1. ElementDrivesElement.onRootChanged e2->e3
336
+ * 1. Element.onAllInputsHandled e3
337
+ * 1. ElementDrivesElement.onRootChanged e2->e31
338
+ * 1. Element.onAllInputsHandled e31
339
+ *
340
+ * (The ElementDrivesElement.)
341
+ *
342
+ * #Errors
343
+ * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships
344
+ * involved in a cycle will have their status set to 1, indicating a failure.
345
+ *
346
+ * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.
347
+ * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing failure in that edge.
348
+ *
349
+ * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.
350
+ *
351
+ * @beta
352
+ */
353
+ class ElementDrivesElement extends Relationship {
354
+ /** @internal */
355
+ constructor(props, iModel) {
356
+ super(props, iModel);
357
+ this.status = props.status;
358
+ this.priority = props.priority;
359
+ }
360
+ /** @internal */
361
+ static get className() { return "ElementDrivesElement"; }
362
+ static create(iModel, sourceId, targetId, priority = 0) {
363
+ const props = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };
364
+ return iModel.relationships.createInstance(props);
365
+ }
366
+ toJSON() {
367
+ const props = super.toJSON();
368
+ props.status = this.status;
369
+ props.priority = this.priority;
370
+ return props;
371
+ }
372
+ /** @internal */
373
+ collectReferenceConcreteIds(referenceIds) {
374
+ super.collectReferenceConcreteIds(referenceIds);
375
+ referenceIds.addElement(this.sourceId);
376
+ referenceIds.addElement(this.targetId);
377
+ }
378
+ }
379
+ exports.ElementDrivesElement = ElementDrivesElement;
380
+ /** The third (and last) possible link-table relationship base class in an iModel.
381
+ * Has no external use, but is included for completeness of the [Entity.collectReferenceConcreteIds]($backend)
382
+ * implementations for link-table relationships. Generating the types of the source and target automatically would require
383
+ * coupling this package with ecschema-metadata which we do not want to do.
384
+ * @internal
385
+ */
386
+ class ModelSelectorRefersToModels extends Relationship {
387
+ /** @internal */
388
+ static get className() { return "ModelSelectorRefersToModels"; }
389
+ /** @internal */
390
+ collectReferenceConcreteIds(referenceIds) {
391
+ super.collectReferenceConcreteIds(referenceIds);
392
+ referenceIds.addElement(this.sourceId);
393
+ referenceIds.addModel(this.targetId);
394
+ }
395
+ }
396
+ exports.ModelSelectorRefersToModels = ModelSelectorRefersToModels;
397
+ /** Manages [[Relationship]]s.
398
+ * @public
399
+ */
400
+ class Relationships {
401
+ /** @internal */
402
+ constructor(iModel) { this._iModel = iModel; }
403
+ /** Create a new instance of a Relationship.
404
+ * @param props The properties of the new Relationship.
405
+ * @throws [[IModelError]] if there is a problem creating the Relationship.
406
+ */
407
+ createInstance(props) { return this._iModel.constructEntity(props); }
408
+ /** Check classFullName to ensure it is a link table relationship class. */
409
+ checkRelationshipClass(classFullName) {
410
+ if (!this._iModel.nativeDb.isLinkTableRelationship(classFullName.replace(".", ":"))) {
411
+ throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);
412
+ }
413
+ }
414
+ /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.
415
+ * @param props The properties of the new relationship.
416
+ * @returns The Id of the newly inserted relationship.
417
+ * @note The id property of the props object is set as a side effect of this function.
418
+ */
419
+ insertInstance(props) {
420
+ this.checkRelationshipClass(props.classFullName);
421
+ return props.id = this._iModel.nativeDb.insertLinkTableRelationship(props);
422
+ }
423
+ /** Update the properties of an existing relationship instance in the iModel.
424
+ * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.
425
+ */
426
+ updateInstance(props) {
427
+ this._iModel.nativeDb.updateLinkTableRelationship(props);
428
+ }
429
+ /** Delete an Relationship instance from this iModel. */
430
+ deleteInstance(props) {
431
+ this._iModel.nativeDb.deleteLinkTableRelationship(props);
432
+ }
433
+ /** Get the props of a Relationship instance
434
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
435
+ * @param criteria Either the relationship instanceId or the source and target Ids
436
+ * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.
437
+ * @see tryGetInstanceProps
438
+ */
439
+ getInstanceProps(relClassFullName, criteria) {
440
+ const relationshipProps = this.tryGetInstanceProps(relClassFullName, criteria);
441
+ if (undefined === relationshipProps) {
442
+ throw new core_common_1.IModelError(core_common_1.IModelStatus.NotFound, "Relationship not found");
443
+ }
444
+ return relationshipProps;
445
+ }
446
+ /** Get the props of a Relationship instance
447
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
448
+ * @param criteria Either the relationship instanceId or the source and target Ids
449
+ * @returns The RelationshipProps or `undefined` if the relationship is not found.
450
+ * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.
451
+ * @see getInstanceProps
452
+ */
453
+ tryGetInstanceProps(relClassFullName, criteria) {
454
+ let props;
455
+ if (typeof criteria === "string") {
456
+ props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (stmt) => {
457
+ stmt.bindId(1, criteria);
458
+ return core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() : undefined;
459
+ });
460
+ }
461
+ else {
462
+ props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (stmt) => {
463
+ stmt.bindId(1, criteria.sourceId);
464
+ stmt.bindId(2, criteria.targetId);
465
+ return core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() : undefined;
466
+ });
467
+ }
468
+ if (undefined !== props) {
469
+ props.classFullName = props.className.replace(".", ":");
470
+ }
471
+ return props;
472
+ }
473
+ /** Get a Relationship instance
474
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
475
+ * @param criteria Either the relationship instanceId or the source and target Ids
476
+ * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.
477
+ * @see tryGetInstance
478
+ */
479
+ getInstance(relClassSqlName, criteria) {
480
+ return this._iModel.constructEntity(this.getInstanceProps(relClassSqlName, criteria));
481
+ }
482
+ /** Get a Relationship instance
483
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
484
+ * @param criteria Either the relationship instanceId or the source and target Ids
485
+ * @returns The relationship or `undefined` if the relationship is not found.
486
+ * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.
487
+ * @see getInstance
488
+ */
489
+ tryGetInstance(relClassFullName, criteria) {
490
+ const relationshipProps = this.tryGetInstanceProps(relClassFullName, criteria);
491
+ return undefined !== relationshipProps ? this._iModel.constructEntity(relationshipProps) : undefined;
492
+ }
493
+ }
494
+ exports.Relationships = Relationships;
495
495
  //# sourceMappingURL=Relationship.js.map