@itwin/core-backend 3.4.0-dev.48 → 3.4.0-dev.50

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