@itwin/core-backend 3.4.3 → 3.4.4

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 (229) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  3. package/lib/cjs/AliCloudStorageService.js +71 -71
  4. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  5. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendHubAccess.js.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  9. package/lib/cjs/BackendLoggerCategory.js +99 -99
  10. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  12. package/lib/cjs/BisCoreSchema.js +60 -60
  13. package/lib/cjs/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.d.ts.map +1 -1
  22. package/lib/cjs/ChangeSummaryManager.js +445 -445
  23. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  24. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  25. package/lib/cjs/ChangedElementsDb.js +165 -165
  26. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  27. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  28. package/lib/cjs/ChangedElementsManager.js +88 -88
  29. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  30. package/lib/cjs/CheckpointManager.d.ts +120 -120
  31. package/lib/cjs/CheckpointManager.js +343 -343
  32. package/lib/cjs/CheckpointManager.js.map +1 -1
  33. package/lib/cjs/ClassRegistry.d.ts +79 -72
  34. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  35. package/lib/cjs/ClassRegistry.js +249 -243
  36. package/lib/cjs/ClassRegistry.js.map +1 -1
  37. package/lib/cjs/CloudSqlite.d.ts +349 -349
  38. package/lib/cjs/CloudSqlite.js +151 -151
  39. package/lib/cjs/CloudSqlite.js.map +1 -1
  40. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  41. package/lib/cjs/CloudStorageBackend.js +173 -173
  42. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  43. package/lib/cjs/CodeService.d.ts +396 -396
  44. package/lib/cjs/CodeService.js +63 -63
  45. package/lib/cjs/CodeService.js.map +1 -1
  46. package/lib/cjs/CodeSpecs.d.ts +50 -50
  47. package/lib/cjs/CodeSpecs.js +112 -112
  48. package/lib/cjs/CodeSpecs.js.map +1 -1
  49. package/lib/cjs/ConcurrentQuery.d.ts +11 -11
  50. package/lib/cjs/ConcurrentQuery.js +30 -30
  51. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  52. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  53. package/lib/cjs/CustomViewState3dCreator.js +81 -81
  54. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  55. package/lib/cjs/DevTools.d.ts +71 -71
  56. package/lib/cjs/DevTools.js +154 -154
  57. package/lib/cjs/DevTools.js.map +1 -1
  58. package/lib/cjs/DisplayStyle.d.ts +106 -106
  59. package/lib/cjs/DisplayStyle.js +256 -256
  60. package/lib/cjs/DisplayStyle.js.map +1 -1
  61. package/lib/cjs/ECDb.d.ts +191 -191
  62. package/lib/cjs/ECDb.js +350 -350
  63. package/lib/cjs/ECDb.js.map +1 -1
  64. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  65. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  66. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  67. package/lib/cjs/ECSqlStatement.d.ts +466 -466
  68. package/lib/cjs/ECSqlStatement.js +791 -791
  69. package/lib/cjs/ECSqlStatement.js.map +1 -1
  70. package/lib/cjs/Element.d.ts +1120 -1120
  71. package/lib/cjs/Element.js +1438 -1438
  72. package/lib/cjs/Element.js.map +1 -1
  73. package/lib/cjs/ElementAspect.d.ts +161 -158
  74. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  75. package/lib/cjs/ElementAspect.js +187 -186
  76. package/lib/cjs/ElementAspect.js.map +1 -1
  77. package/lib/cjs/ElementGraphics.d.ts +9 -9
  78. package/lib/cjs/ElementGraphics.js +41 -41
  79. package/lib/cjs/ElementGraphics.js.map +1 -1
  80. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  81. package/lib/cjs/ElementTreeWalker.js +409 -409
  82. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  83. package/lib/cjs/Entity.d.ts +106 -106
  84. package/lib/cjs/Entity.js +134 -134
  85. package/lib/cjs/Entity.js.map +1 -1
  86. package/lib/cjs/EntityReferences.d.ts +45 -45
  87. package/lib/cjs/EntityReferences.js +91 -91
  88. package/lib/cjs/EntityReferences.js.map +1 -1
  89. package/lib/cjs/ExportGraphics.d.ts +317 -317
  90. package/lib/cjs/ExportGraphics.js +208 -208
  91. package/lib/cjs/ExportGraphics.js.map +1 -1
  92. package/lib/cjs/ExternalSource.d.ts +96 -96
  93. package/lib/cjs/ExternalSource.js +131 -131
  94. package/lib/cjs/ExternalSource.js.map +1 -1
  95. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  96. package/lib/cjs/GeoCoordConfig.js +82 -82
  97. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  98. package/lib/cjs/GeometrySummary.d.ts +4 -4
  99. package/lib/cjs/GeometrySummary.js +380 -380
  100. package/lib/cjs/GeometrySummary.js.map +1 -1
  101. package/lib/cjs/HubMock.d.ts +93 -93
  102. package/lib/cjs/HubMock.js +190 -190
  103. package/lib/cjs/HubMock.js.map +1 -1
  104. package/lib/cjs/IModelCloneContext.d.ts +89 -89
  105. package/lib/cjs/IModelCloneContext.js +159 -159
  106. package/lib/cjs/IModelCloneContext.js.map +1 -1
  107. package/lib/cjs/IModelDb.d.ts +1180 -1180
  108. package/lib/cjs/IModelDb.js +2371 -2371
  109. package/lib/cjs/IModelDb.js.map +1 -1
  110. package/lib/cjs/IModelHost.d.ts +361 -361
  111. package/lib/cjs/IModelHost.js +489 -489
  112. package/lib/cjs/IModelHost.js.map +1 -1
  113. package/lib/cjs/IModelJsFs.d.ts +62 -62
  114. package/lib/cjs/IModelJsFs.js +140 -140
  115. package/lib/cjs/IModelJsFs.js.map +1 -1
  116. package/lib/cjs/IpcHost.d.ts +98 -98
  117. package/lib/cjs/IpcHost.js +234 -234
  118. package/lib/cjs/IpcHost.js.map +1 -1
  119. package/lib/cjs/LineStyle.d.ts +311 -311
  120. package/lib/cjs/LineStyle.js +295 -295
  121. package/lib/cjs/LineStyle.js.map +1 -1
  122. package/lib/cjs/LocalHub.d.ts +162 -162
  123. package/lib/cjs/LocalHub.js +587 -587
  124. package/lib/cjs/LocalHub.js.map +1 -1
  125. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  126. package/lib/cjs/LocalhostIpcHost.js +81 -81
  127. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  128. package/lib/cjs/Material.d.ts +103 -103
  129. package/lib/cjs/Material.js +147 -147
  130. package/lib/cjs/Material.js.map +1 -1
  131. package/lib/cjs/Model.d.ts +392 -392
  132. package/lib/cjs/Model.js +485 -485
  133. package/lib/cjs/Model.js.map +1 -1
  134. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  135. package/lib/cjs/NativeAppStorage.js +202 -202
  136. package/lib/cjs/NativeAppStorage.js.map +1 -1
  137. package/lib/cjs/NativeHost.d.ts +52 -52
  138. package/lib/cjs/NativeHost.js +168 -168
  139. package/lib/cjs/NativeHost.js.map +1 -1
  140. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  141. package/lib/cjs/NavigationRelationship.js +225 -225
  142. package/lib/cjs/NavigationRelationship.js.map +1 -1
  143. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  144. package/lib/cjs/PromiseMemoizer.js +101 -101
  145. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  146. package/lib/cjs/PropertyStore.d.ts +132 -132
  147. package/lib/cjs/PropertyStore.js +11 -11
  148. package/lib/cjs/PropertyStore.js.map +1 -1
  149. package/lib/cjs/Relationship.d.ts +416 -416
  150. package/lib/cjs/Relationship.js +494 -494
  151. package/lib/cjs/Relationship.js.map +1 -1
  152. package/lib/cjs/RpcBackend.d.ts +28 -28
  153. package/lib/cjs/RpcBackend.js +126 -126
  154. package/lib/cjs/RpcBackend.js.map +1 -1
  155. package/lib/cjs/SQLiteDb.d.ts +219 -219
  156. package/lib/cjs/SQLiteDb.js +214 -214
  157. package/lib/cjs/SQLiteDb.js.map +1 -1
  158. package/lib/cjs/Schema.d.ts +55 -55
  159. package/lib/cjs/Schema.js +83 -83
  160. package/lib/cjs/Schema.js.map +1 -1
  161. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  162. package/lib/cjs/ServerBasedLocks.js +168 -168
  163. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  164. package/lib/cjs/SqliteStatement.d.ts +283 -283
  165. package/lib/cjs/SqliteStatement.js +448 -448
  166. package/lib/cjs/SqliteStatement.js.map +1 -1
  167. package/lib/cjs/Texture.d.ts +58 -58
  168. package/lib/cjs/Texture.js +82 -82
  169. package/lib/cjs/Texture.js.map +1 -1
  170. package/lib/cjs/TileStorage.d.ts +18 -18
  171. package/lib/cjs/TileStorage.js +90 -90
  172. package/lib/cjs/TileStorage.js.map +1 -1
  173. package/lib/cjs/TxnManager.d.ts +202 -202
  174. package/lib/cjs/TxnManager.js +356 -356
  175. package/lib/cjs/TxnManager.js.map +1 -1
  176. package/lib/cjs/ViewDefinition.d.ts +439 -439
  177. package/lib/cjs/ViewDefinition.js +646 -646
  178. package/lib/cjs/ViewDefinition.js.map +1 -1
  179. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  180. package/lib/cjs/ViewStateHydrator.js +103 -103
  181. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  182. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  183. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  184. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  185. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  186. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  187. package/lib/cjs/core-backend.d.ts +183 -183
  188. package/lib/cjs/core-backend.js +203 -203
  189. package/lib/cjs/core-backend.js.map +1 -1
  190. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  191. package/lib/cjs/domains/FunctionalElements.js +145 -145
  192. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  193. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  194. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  195. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  196. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  197. package/lib/cjs/domains/GenericElements.js +263 -263
  198. package/lib/cjs/domains/GenericElements.js.map +1 -1
  199. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  200. package/lib/cjs/domains/GenericSchema.js +28 -28
  201. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  202. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  203. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  204. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  205. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +46 -46
  206. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +287 -287
  207. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  208. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  209. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  210. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  211. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  212. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  213. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  214. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  215. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  216. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  217. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  218. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  219. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  220. package/lib/cjs/workspace/Settings.d.ts +186 -186
  221. package/lib/cjs/workspace/Settings.js +155 -155
  222. package/lib/cjs/workspace/Settings.js.map +1 -1
  223. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  224. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  225. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  226. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  227. package/lib/cjs/workspace/Workspace.js +543 -543
  228. package/lib/cjs/workspace/Workspace.js.map +1 -1
  229. package/package.json +12 -12
@@ -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