@itwin/core-backend 4.0.0-dev.7 → 4.0.0-dev.72

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 (254) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js +41 -41
  5. package/lib/cjs/BackendHubAccess.js.map +1 -1
  6. package/lib/cjs/BackendLoggerCategory.d.ts +90 -91
  7. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.js +98 -99
  9. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  10. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  11. package/lib/cjs/BisCoreSchema.js +60 -60
  12. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  13. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  14. package/lib/cjs/BriefcaseManager.js +408 -414
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +153 -153
  17. package/lib/cjs/Category.js +243 -243
  18. package/lib/cjs/Category.js.map +1 -1
  19. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  20. package/lib/cjs/ChangeSummaryManager.js +444 -445
  21. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  22. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  23. package/lib/cjs/ChangedElementsDb.js +165 -165
  24. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  25. package/lib/cjs/ChangedElementsManager.js +88 -88
  26. package/lib/cjs/ChannelControl.d.ts +70 -0
  27. package/lib/cjs/ChannelControl.d.ts.map +1 -0
  28. package/lib/cjs/ChannelControl.js +89 -0
  29. package/lib/cjs/ChannelControl.js.map +1 -0
  30. package/lib/cjs/CheckpointManager.d.ts +121 -121
  31. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  32. package/lib/cjs/CheckpointManager.js +351 -349
  33. package/lib/cjs/CheckpointManager.js.map +1 -1
  34. package/lib/cjs/ClassRegistry.d.ts +79 -79
  35. package/lib/cjs/ClassRegistry.js +249 -245
  36. package/lib/cjs/ClassRegistry.js.map +1 -1
  37. package/lib/cjs/CloudSqlite.d.ts +355 -350
  38. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  39. package/lib/cjs/CloudSqlite.js +154 -153
  40. package/lib/cjs/CloudSqlite.js.map +1 -1
  41. package/lib/cjs/CodeService.d.ts +396 -396
  42. package/lib/cjs/CodeService.d.ts.map +1 -1
  43. package/lib/cjs/CodeService.js +63 -63
  44. package/lib/cjs/CodeService.js.map +1 -1
  45. package/lib/cjs/CodeSpecs.d.ts +55 -55
  46. package/lib/cjs/CodeSpecs.js +124 -124
  47. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  48. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  49. package/lib/cjs/ConcurrentQuery.js +36 -36
  50. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  51. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  52. package/lib/cjs/CustomViewState3dCreator.js +82 -81
  53. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  54. package/lib/cjs/DevTools.d.ts +74 -71
  55. package/lib/cjs/DevTools.d.ts.map +1 -1
  56. package/lib/cjs/DevTools.js +156 -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 +253 -256
  60. package/lib/cjs/DisplayStyle.js.map +1 -1
  61. package/lib/cjs/ECDb.d.ts +194 -191
  62. package/lib/cjs/ECDb.d.ts.map +1 -1
  63. package/lib/cjs/ECDb.js +353 -350
  64. package/lib/cjs/ECDb.js.map +1 -1
  65. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  66. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  67. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  68. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  69. package/lib/cjs/ECSqlStatement.js +791 -791
  70. package/lib/cjs/Element.d.ts +1113 -1109
  71. package/lib/cjs/Element.d.ts.map +1 -1
  72. package/lib/cjs/Element.js +1424 -1427
  73. package/lib/cjs/Element.js.map +1 -1
  74. package/lib/cjs/ElementAspect.d.ts +176 -179
  75. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  76. package/lib/cjs/ElementAspect.js +203 -211
  77. package/lib/cjs/ElementAspect.js.map +1 -1
  78. package/lib/cjs/ElementGraphics.d.ts +9 -9
  79. package/lib/cjs/ElementGraphics.js +41 -41
  80. package/lib/cjs/ElementGraphics.js.map +1 -1
  81. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  82. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  83. package/lib/cjs/ElementTreeWalker.js +409 -409
  84. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  85. package/lib/cjs/Entity.d.ts +106 -106
  86. package/lib/cjs/Entity.d.ts.map +1 -1
  87. package/lib/cjs/Entity.js +134 -134
  88. package/lib/cjs/Entity.js.map +1 -1
  89. package/lib/cjs/EntityReferences.d.ts +49 -49
  90. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  91. package/lib/cjs/EntityReferences.js +95 -95
  92. package/lib/cjs/ExportGraphics.d.ts +317 -317
  93. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  94. package/lib/cjs/ExportGraphics.js +208 -208
  95. package/lib/cjs/ExternalSource.d.ts +96 -96
  96. package/lib/cjs/ExternalSource.js +131 -131
  97. package/lib/cjs/ExternalSource.js.map +1 -1
  98. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  99. package/lib/cjs/GeoCoordConfig.js +85 -85
  100. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  101. package/lib/cjs/GeometrySummary.d.ts +4 -4
  102. package/lib/cjs/GeometrySummary.js +333 -333
  103. package/lib/cjs/GeometrySummary.js.map +1 -1
  104. package/lib/cjs/HubMock.d.ts +94 -94
  105. package/lib/cjs/HubMock.js +220 -222
  106. package/lib/cjs/HubMock.js.map +1 -1
  107. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  108. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  109. package/lib/cjs/IModelCloneContext.js +15 -15
  110. package/lib/cjs/IModelDb.d.ts +1216 -1196
  111. package/lib/cjs/IModelDb.d.ts.map +1 -1
  112. package/lib/cjs/IModelDb.js +2387 -2392
  113. package/lib/cjs/IModelDb.js.map +1 -1
  114. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  115. package/lib/cjs/IModelElementCloneContext.js +159 -159
  116. package/lib/cjs/IModelHost.d.ts +355 -369
  117. package/lib/cjs/IModelHost.d.ts.map +1 -1
  118. package/lib/cjs/IModelHost.js +472 -496
  119. package/lib/cjs/IModelHost.js.map +1 -1
  120. package/lib/cjs/IModelJsFs.d.ts +62 -62
  121. package/lib/cjs/IModelJsFs.js +139 -140
  122. package/lib/cjs/IModelJsFs.js.map +1 -1
  123. package/lib/cjs/IpcHost.d.ts +104 -104
  124. package/lib/cjs/IpcHost.js +276 -278
  125. package/lib/cjs/IpcHost.js.map +1 -1
  126. package/lib/cjs/LineStyle.d.ts +311 -311
  127. package/lib/cjs/LineStyle.js +295 -295
  128. package/lib/cjs/LocalHub.d.ts +162 -162
  129. package/lib/cjs/LocalHub.d.ts.map +1 -1
  130. package/lib/cjs/LocalHub.js +579 -584
  131. package/lib/cjs/LocalHub.js.map +1 -1
  132. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  133. package/lib/cjs/LocalhostIpcHost.js +79 -81
  134. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  135. package/lib/cjs/Material.d.ts +131 -131
  136. package/lib/cjs/Material.js +180 -181
  137. package/lib/cjs/Material.js.map +1 -1
  138. package/lib/cjs/Model.d.ts +392 -392
  139. package/lib/cjs/Model.d.ts.map +1 -1
  140. package/lib/cjs/Model.js +489 -485
  141. package/lib/cjs/Model.js.map +1 -1
  142. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  143. package/lib/cjs/NativeAppStorage.js +202 -202
  144. package/lib/cjs/NativeAppStorage.js.map +1 -1
  145. package/lib/cjs/NativeHost.d.ts +52 -52
  146. package/lib/cjs/NativeHost.js +160 -163
  147. package/lib/cjs/NativeHost.js.map +1 -1
  148. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  149. package/lib/cjs/NavigationRelationship.js +225 -225
  150. package/lib/cjs/NavigationRelationship.js.map +1 -1
  151. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  152. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  153. package/lib/cjs/PromiseMemoizer.js +101 -101
  154. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  155. package/lib/cjs/PropertyStore.d.ts +132 -132
  156. package/lib/cjs/PropertyStore.js +11 -11
  157. package/lib/cjs/Relationship.d.ts +416 -416
  158. package/lib/cjs/Relationship.js +494 -494
  159. package/lib/cjs/Relationship.js.map +1 -1
  160. package/lib/cjs/RpcBackend.d.ts +5 -5
  161. package/lib/cjs/RpcBackend.js +32 -32
  162. package/lib/cjs/SQLiteDb.d.ts +219 -219
  163. package/lib/cjs/SQLiteDb.js +212 -214
  164. package/lib/cjs/SQLiteDb.js.map +1 -1
  165. package/lib/cjs/Schema.d.ts +55 -55
  166. package/lib/cjs/Schema.js +83 -83
  167. package/lib/cjs/Schema.js.map +1 -1
  168. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  169. package/lib/cjs/ServerBasedLocks.js +168 -168
  170. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  171. package/lib/cjs/SqliteStatement.d.ts +360 -360
  172. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  173. package/lib/cjs/SqliteStatement.js +586 -586
  174. package/lib/cjs/Texture.d.ts +58 -58
  175. package/lib/cjs/Texture.js +82 -82
  176. package/lib/cjs/Texture.js.map +1 -1
  177. package/lib/cjs/TileStorage.d.ts +44 -18
  178. package/lib/cjs/TileStorage.d.ts.map +1 -1
  179. package/lib/cjs/TileStorage.js +109 -90
  180. package/lib/cjs/TileStorage.js.map +1 -1
  181. package/lib/cjs/TxnManager.d.ts +202 -202
  182. package/lib/cjs/TxnManager.d.ts.map +1 -1
  183. package/lib/cjs/TxnManager.js +356 -356
  184. package/lib/cjs/TxnManager.js.map +1 -1
  185. package/lib/cjs/ViewDefinition.d.ts +435 -439
  186. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  187. package/lib/cjs/ViewDefinition.js +646 -646
  188. package/lib/cjs/ViewDefinition.js.map +1 -1
  189. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  190. package/lib/cjs/ViewStateHydrator.js +103 -103
  191. package/lib/cjs/core-backend.d.ts +184 -184
  192. package/lib/cjs/core-backend.d.ts.map +1 -1
  193. package/lib/cjs/core-backend.js +208 -204
  194. package/lib/cjs/core-backend.js.map +1 -1
  195. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  196. package/lib/cjs/domains/FunctionalElements.js +145 -145
  197. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  198. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  199. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  200. package/lib/cjs/domains/FunctionalSchema.js +39 -40
  201. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  202. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  203. package/lib/cjs/domains/GenericElements.js +263 -263
  204. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  205. package/lib/cjs/domains/GenericSchema.js +28 -28
  206. package/lib/cjs/rpc/multipart.d.ts +11 -11
  207. package/lib/cjs/rpc/multipart.js +71 -71
  208. package/lib/cjs/rpc/tracing.d.ts +28 -28
  209. package/lib/cjs/rpc/tracing.js +73 -74
  210. package/lib/cjs/rpc/tracing.js.map +1 -1
  211. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  212. package/lib/cjs/rpc/web/logging.js +43 -43
  213. package/lib/cjs/rpc/web/request.d.ts +6 -6
  214. package/lib/cjs/rpc/web/request.js +73 -74
  215. package/lib/cjs/rpc/web/request.js.map +1 -1
  216. package/lib/cjs/rpc/web/response.d.ts +6 -6
  217. package/lib/cjs/rpc/web/response.js +105 -106
  218. package/lib/cjs/rpc/web/response.js.map +1 -1
  219. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  220. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  221. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  222. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -294
  223. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  224. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +20 -22
  225. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  226. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +187 -205
  227. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  228. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  229. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -168
  230. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  231. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  232. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -43
  233. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  234. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  235. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  236. package/lib/cjs/workspace/Settings.d.ts +186 -186
  237. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  238. package/lib/cjs/workspace/Settings.js +154 -155
  239. package/lib/cjs/workspace/Settings.js.map +1 -1
  240. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  241. package/lib/cjs/workspace/SettingsSchemas.js +190 -191
  242. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  243. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  244. package/lib/cjs/workspace/Workspace.js +537 -543
  245. package/lib/cjs/workspace/Workspace.js.map +1 -1
  246. package/package.json +22 -22
  247. package/lib/cjs/AliCloudStorageService.d.ts +0 -24
  248. package/lib/cjs/AliCloudStorageService.d.ts.map +0 -1
  249. package/lib/cjs/AliCloudStorageService.js +0 -72
  250. package/lib/cjs/AliCloudStorageService.js.map +0 -1
  251. package/lib/cjs/CloudStorageBackend.d.ts +0 -59
  252. package/lib/cjs/CloudStorageBackend.d.ts.map +0 -1
  253. package/lib/cjs/CloudStorageBackend.js +0 -174
  254. package/lib/cjs/CloudStorageBackend.js.map +0 -1
@@ -1,212 +1,204 @@
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 ElementAspects
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ExternalSourceAspect = exports.ChannelRootAspect = exports.ElementMultiAspect = exports.ElementUniqueAspect = exports.ElementAspect = void 0;
11
- const core_common_1 = require("@itwin/core-common");
12
- const Entity_1 = require("./Entity");
13
- const core_bentley_1 = require("@itwin/core-bentley");
14
- /** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.
15
- * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.
16
- * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.
17
- * @public
18
- */
19
- class ElementAspect extends Entity_1.Entity {
20
- /** @internal */
21
- constructor(props, iModel) {
22
- super(props, iModel);
23
- this.element = core_common_1.RelatedElement.fromJSON(props.element); // eslint-disable-line @typescript-eslint/no-non-null-assertion
24
- }
25
- /** @internal */
26
- static get className() { return "ElementAspect"; }
27
- /** @internal */
28
- toJSON() {
29
- const val = super.toJSON();
30
- val.element = this.element;
31
- return val;
32
- }
33
- /** Called before a new ElementAspect is inserted.
34
- * @note throw an exception to disallow the insert
35
- * @note If you override this method, you must call super.
36
- * @beta
37
- */
38
- static onInsert(_arg) { }
39
- /** Called after a new ElementAspect was inserted.
40
- * @note If you override this method, you must call super.
41
- * @beta
42
- */
43
- static onInserted(_arg) { }
44
- /** Called before an ElementAspect is updated.
45
- * @note throw an exception to disallow the update
46
- * @note If you override this method, you must call super.
47
- * @beta
48
- */
49
- static onUpdate(_arg) { }
50
- /** Called after an ElementAspect was updated.
51
- * @note If you override this method, you must call super.
52
- * @beta
53
- */
54
- static onUpdated(_arg) { }
55
- /** Called before an ElementAspect is deleted.
56
- * @note throw an exception to disallow the delete
57
- * @note If you override this method, you must call super.
58
- * @beta
59
- */
60
- static onDelete(_arg) { }
61
- /** Called after an ElementAspect was deleted.
62
- * @note If you override this method, you must call super.
63
- * @beta
64
- */
65
- static onDeleted(_arg) { }
66
- }
67
- exports.ElementAspect = ElementAspect;
68
- /** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.
69
- * @public
70
- */
71
- class ElementUniqueAspect extends ElementAspect {
72
- /** @internal */
73
- static get className() { return "ElementUniqueAspect"; }
74
- }
75
- exports.ElementUniqueAspect = ElementUniqueAspect;
76
- /** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.
77
- * @public
78
- */
79
- class ElementMultiAspect extends ElementAspect {
80
- /** @internal */
81
- static get className() { return "ElementMultiAspect"; }
82
- }
83
- exports.ElementMultiAspect = ElementMultiAspect;
84
- /** A ChannelRootAspect identifies an Element as the root of a *channel* which is a subset of the overall iModel hierarchy that is independently maintained.
85
- * @note The associated ECClass was added to the BisCore schema in version 1.0.10
86
- * @public
87
- */
88
- class ChannelRootAspect extends ElementUniqueAspect {
89
- /** @internal */
90
- constructor(props, iModel) {
91
- super(props, iModel);
92
- this.owner = props.owner;
93
- }
94
- /** @internal */
95
- static get className() { return "ChannelRootAspect"; }
96
- /** @internal */
97
- toJSON() {
98
- const val = super.toJSON();
99
- val.owner = this.owner;
100
- return val;
101
- }
102
- /** Insert a ChannelRootAspect on the specified element. */
103
- static insert(iModel, ownerId, ownerDescription) {
104
- const props = {
105
- classFullName: ChannelRootAspect.classFullName,
106
- element: { id: ownerId },
107
- owner: ownerDescription,
108
- };
109
- iModel.elements.insertAspect(props);
110
- }
111
- }
112
- exports.ChannelRootAspect = ChannelRootAspect;
113
- /** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.
114
- * @note The associated ECClass was added to the BisCore schema in version 1.0.2
115
- * @public
116
- */
117
- class ExternalSourceAspect extends ElementMultiAspect {
118
- /** @internal */
119
- constructor(props, iModel) {
120
- super(props, iModel);
121
- this.scope = core_common_1.RelatedElement.fromJSON(props.scope); // eslint-disable-line @typescript-eslint/no-non-null-assertion
122
- this.source = core_common_1.RelatedElement.fromJSON(props.source);
123
- this.identifier = props.identifier;
124
- this.kind = props.kind;
125
- this.checksum = props.checksum;
126
- this.version = props.version;
127
- this.jsonProperties = props.jsonProperties;
128
- }
129
- /** @internal */
130
- static get className() { return "ExternalSourceAspect"; }
131
- /** @deprecated in 3.x. findAllBySource */
132
- static findBySource(iModelDb, scope, kind, identifier) {
133
- const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;
134
- let elementId;
135
- let aspectId;
136
- iModelDb.withPreparedStatement(sql, (statement) => {
137
- statement.bindId("scope", scope);
138
- statement.bindString("kind", kind);
139
- statement.bindString("identifier", identifier);
140
- if (core_bentley_1.DbResult.BE_SQLITE_ROW === statement.step()) {
141
- elementId = statement.getValue(0).getId();
142
- aspectId = statement.getValue(1).getId();
143
- }
144
- });
145
- return { elementId, aspectId };
146
- }
147
- /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.
148
- * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.
149
- * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.
150
- * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.
151
- * Therefore, the result array could have more than one entry with the same elementId.
152
- * Aspects are never shared. Each aspect has its own unique ECInstanceId.
153
- * @param iModelDb The iModel to query
154
- * @param scope The scope of the ExternalSourceAspects to find
155
- * @param kind The kind of the ExternalSourceAspects to find
156
- * @param identifier The identifier of the ExternalSourceAspects to find
157
- * @returns the query results
158
- */
159
- static findAllBySource(iModelDb, scope, kind, identifier) {
160
- const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;
161
- const found = [];
162
- iModelDb.withPreparedStatement(sql, (statement) => {
163
- statement.bindId("scope", scope);
164
- statement.bindString("kind", kind);
165
- statement.bindString("identifier", identifier);
166
- while (core_bentley_1.DbResult.BE_SQLITE_ROW === statement.step()) {
167
- found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });
168
- }
169
- });
170
- return found;
171
- }
172
- /** @internal */
173
- toJSON() {
174
- const val = super.toJSON();
175
- val.scope = this.scope;
176
- val.source = this.source;
177
- val.identifier = this.identifier;
178
- val.kind = this.kind;
179
- val.checksum = this.checksum;
180
- val.version = this.version;
181
- val.jsonProperties = this.jsonProperties;
182
- return val;
183
- }
184
- /** @internal */
185
- collectReferenceConcreteIds(referenceIds) {
186
- super.collectReferenceConcreteIds(referenceIds);
187
- if (this.scope)
188
- referenceIds.addElement(this.scope.id);
189
- referenceIds.addElement(this.element.id);
190
- if (this.source)
191
- referenceIds.addElement(this.source.id);
192
- }
193
- }
194
- exports.ExternalSourceAspect = ExternalSourceAspect;
195
- /** @public */
196
- (function (ExternalSourceAspect) {
197
- /** Standard values for the `Kind` property of `ExternalSourceAspect`.
198
- * @public
199
- */
200
- let Kind;
201
- (function (Kind) {
202
- /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */
203
- Kind["Element"] = "Element";
204
- /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */
205
- Kind["Relationship"] = "Relationship";
206
- /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance
207
- * @see [[ExternalSourceAspect.scope]]
208
- */
209
- Kind["Scope"] = "Scope";
210
- })(Kind = ExternalSourceAspect.Kind || (ExternalSourceAspect.Kind = {}));
211
- })(ExternalSourceAspect = exports.ExternalSourceAspect || (exports.ExternalSourceAspect = {}));
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 ElementAspects
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ExternalSourceAspect = exports.ChannelRootAspect = exports.ElementMultiAspect = exports.ElementUniqueAspect = exports.ElementAspect = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const Entity_1 = require("./Entity");
13
+ const core_bentley_1 = require("@itwin/core-bentley");
14
+ /** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.
15
+ * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.
16
+ * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.
17
+ * @public
18
+ */
19
+ class ElementAspect extends Entity_1.Entity {
20
+ /** @internal */
21
+ static get className() { return "ElementAspect"; }
22
+ /** @internal */
23
+ constructor(props, iModel) {
24
+ super(props, iModel);
25
+ this.element = core_common_1.RelatedElement.fromJSON(props.element); // eslint-disable-line @typescript-eslint/no-non-null-assertion
26
+ }
27
+ /** @internal */
28
+ toJSON() {
29
+ const val = super.toJSON();
30
+ val.element = this.element;
31
+ return val;
32
+ }
33
+ /** Called before a new ElementAspect is inserted.
34
+ * @note throw an exception to disallow the insert
35
+ * @note If you override this method, you must call super.
36
+ * @beta
37
+ */
38
+ static onInsert(arg) {
39
+ arg.iModel.channels.verifyChannel(arg.model);
40
+ }
41
+ /** Called after a new ElementAspect was inserted.
42
+ * @note If you override this method, you must call super.
43
+ * @beta
44
+ */
45
+ static onInserted(_arg) { }
46
+ /** Called before an ElementAspect is updated.
47
+ * @note throw an exception to disallow the update
48
+ * @note If you override this method, you must call super.
49
+ * @beta
50
+ */
51
+ static onUpdate(arg) {
52
+ arg.iModel.channels.verifyChannel(arg.model);
53
+ }
54
+ /** Called after an ElementAspect was updated.
55
+ * @note If you override this method, you must call super.
56
+ * @beta
57
+ */
58
+ static onUpdated(_arg) { }
59
+ /** Called before an ElementAspect is deleted.
60
+ * @note throw an exception to disallow the delete
61
+ * @note If you override this method, you must call super.
62
+ * @beta
63
+ */
64
+ static onDelete(arg) {
65
+ arg.iModel.channels.verifyChannel(arg.model);
66
+ }
67
+ /** Called after an ElementAspect was deleted.
68
+ * @note If you override this method, you must call super.
69
+ * @beta
70
+ */
71
+ static onDeleted(_arg) { }
72
+ }
73
+ exports.ElementAspect = ElementAspect;
74
+ /** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.
75
+ * @public
76
+ */
77
+ class ElementUniqueAspect extends ElementAspect {
78
+ /** @internal */
79
+ static get className() { return "ElementUniqueAspect"; }
80
+ }
81
+ exports.ElementUniqueAspect = ElementUniqueAspect;
82
+ /** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.
83
+ * @public
84
+ */
85
+ class ElementMultiAspect extends ElementAspect {
86
+ /** @internal */
87
+ static get className() { return "ElementMultiAspect"; }
88
+ }
89
+ exports.ElementMultiAspect = ElementMultiAspect;
90
+ /**
91
+ * @public
92
+ */
93
+ class ChannelRootAspect extends ElementUniqueAspect {
94
+ /** @internal */
95
+ static get className() { return "ChannelRootAspect"; }
96
+ /** Insert a ChannelRootAspect on the specified element.
97
+ * @deprecated in 4.0 use [[ChannelControl.insertChannelSubject]]
98
+ */
99
+ static insert(iModel, ownerId, channelName) {
100
+ const props = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };
101
+ iModel.elements.insertAspect(props);
102
+ }
103
+ }
104
+ exports.ChannelRootAspect = ChannelRootAspect;
105
+ /** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.
106
+ * @note The associated ECClass was added to the BisCore schema in version 1.0.2
107
+ * @public
108
+ */
109
+ class ExternalSourceAspect extends ElementMultiAspect {
110
+ /** @internal */
111
+ static get className() { return "ExternalSourceAspect"; }
112
+ /** @internal */
113
+ constructor(props, iModel) {
114
+ super(props, iModel);
115
+ this.scope = core_common_1.RelatedElement.fromJSON(props.scope); // eslint-disable-line @typescript-eslint/no-non-null-assertion
116
+ this.source = core_common_1.RelatedElement.fromJSON(props.source);
117
+ this.identifier = props.identifier;
118
+ this.kind = props.kind;
119
+ this.checksum = props.checksum;
120
+ this.version = props.version;
121
+ this.jsonProperties = props.jsonProperties;
122
+ }
123
+ /** @deprecated in 3.x. findAllBySource */
124
+ static findBySource(iModelDb, scope, kind, identifier) {
125
+ const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;
126
+ let elementId;
127
+ let aspectId;
128
+ iModelDb.withPreparedStatement(sql, (statement) => {
129
+ statement.bindId("scope", scope);
130
+ statement.bindString("kind", kind);
131
+ statement.bindString("identifier", identifier);
132
+ if (core_bentley_1.DbResult.BE_SQLITE_ROW === statement.step()) {
133
+ elementId = statement.getValue(0).getId();
134
+ aspectId = statement.getValue(1).getId();
135
+ }
136
+ });
137
+ return { elementId, aspectId };
138
+ }
139
+ /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.
140
+ * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.
141
+ * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.
142
+ * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.
143
+ * Therefore, the result array could have more than one entry with the same elementId.
144
+ * Aspects are never shared. Each aspect has its own unique ECInstanceId.
145
+ * @param iModelDb The iModel to query
146
+ * @param scope The scope of the ExternalSourceAspects to find
147
+ * @param kind The kind of the ExternalSourceAspects to find
148
+ * @param identifier The identifier of the ExternalSourceAspects to find
149
+ * @returns the query results
150
+ */
151
+ static findAllBySource(iModelDb, scope, kind, identifier) {
152
+ const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;
153
+ const found = [];
154
+ iModelDb.withPreparedStatement(sql, (statement) => {
155
+ statement.bindId("scope", scope);
156
+ statement.bindString("kind", kind);
157
+ statement.bindString("identifier", identifier);
158
+ while (core_bentley_1.DbResult.BE_SQLITE_ROW === statement.step()) {
159
+ found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });
160
+ }
161
+ });
162
+ return found;
163
+ }
164
+ /** @internal */
165
+ toJSON() {
166
+ const val = super.toJSON();
167
+ val.scope = this.scope;
168
+ val.source = this.source;
169
+ val.identifier = this.identifier;
170
+ val.kind = this.kind;
171
+ val.checksum = this.checksum;
172
+ val.version = this.version;
173
+ val.jsonProperties = this.jsonProperties;
174
+ return val;
175
+ }
176
+ /** @internal */
177
+ collectReferenceConcreteIds(referenceIds) {
178
+ super.collectReferenceConcreteIds(referenceIds);
179
+ if (this.scope)
180
+ referenceIds.addElement(this.scope.id);
181
+ referenceIds.addElement(this.element.id);
182
+ if (this.source)
183
+ referenceIds.addElement(this.source.id);
184
+ }
185
+ }
186
+ exports.ExternalSourceAspect = ExternalSourceAspect;
187
+ /** @public */
188
+ (function (ExternalSourceAspect) {
189
+ /** Standard values for the `Kind` property of `ExternalSourceAspect`.
190
+ * @public
191
+ */
192
+ let Kind;
193
+ (function (Kind) {
194
+ /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */
195
+ Kind["Element"] = "Element";
196
+ /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */
197
+ Kind["Relationship"] = "Relationship";
198
+ /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance
199
+ * @see [[ExternalSourceAspect.scope]]
200
+ */
201
+ Kind["Scope"] = "Scope";
202
+ })(Kind = ExternalSourceAspect.Kind || (ExternalSourceAspect.Kind = {}));
203
+ })(ExternalSourceAspect = exports.ExternalSourceAspect || (exports.ExternalSourceAspect = {}));
212
204
  //# sourceMappingURL=ElementAspect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AAwB3D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAKvC,gBAAgB;IAChB,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IARD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAS1E,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAsB,IAAU,CAAC;IAE3D;;;OAGG;IACO,MAAM,CAAC,UAAU,CAA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AAM,EAA+B,CAAC;QACxD,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACjC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,gBAAgB;IACG,2BAA2B,CAAC,YAAgC;QAC7E,KAAK,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM;YACb,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAzGD,oDAyGC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public\r\n */\r\nexport class ElementAspect extends Entity {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(_arg: OnAspectIdArg): void { }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/** A ChannelRootAspect identifies an Element as the root of a *channel* which is a subset of the overall iModel hierarchy that is independently maintained.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\r\n * @public\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n\r\n /** The owner of the channel */\r\n public owner: string;\r\n\r\n /** @internal */\r\n constructor(props: ChannelRootAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.owner = props.owner;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ChannelRootAspectProps {\r\n const val = super.toJSON() as ChannelRootAspectProps;\r\n val.owner = this.owner;\r\n return val;\r\n }\r\n\r\n /** Insert a ChannelRootAspect on the specified element. */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, ownerDescription: string) {\r\n const props: ChannelRootAspectProps = {\r\n classFullName: ChannelRootAspect.classFullName,\r\n element: { id: ownerId },\r\n owner: ownerDescription,\r\n };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\r\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\r\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\r\n */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\r\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\r\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\r\n */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** @deprecated in 3.x. findAllBySource */\r\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n let elementId: Id64String | undefined;\r\n let aspectId: Id64String | undefined;\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n elementId = statement.getValue(0).getId();\r\n aspectId = statement.getValue(1).getId();\r\n }\r\n });\r\n return { elementId, aspectId };\r\n }\r\n\r\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\r\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\r\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\r\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\r\n * Therefore, the result array could have more than one entry with the same elementId.\r\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\r\n * @param iModelDb The iModel to query\r\n * @param scope The scope of the ExternalSourceAspects to find\r\n * @param kind The kind of the ExternalSourceAspects to find\r\n * @param identifier The identifier of the ExternalSourceAspects to find\r\n * @returns the query results\r\n */\r\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\r\n }\r\n });\r\n return found;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n\r\n /** @internal */\r\n protected override collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceConcreteIds(referenceIds);\r\n if (this.scope)\r\n referenceIds.addElement(this.scope.id);\r\n referenceIds.addElement(this.element.id);\r\n if (this.source)\r\n referenceIds.addElement(this.source.id);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AA0B3D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IACvC,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAG1E,gBAAgB;IAChB,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAqB;QAC7C,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACO,MAAM,CAAC,UAAU,CAAC,IAAsB,IAAU,CAAC;IAE7D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAqB;QAC7C,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACO,MAAM,CAAC,SAAS,CAAC,IAAsB,IAAU,CAAC;IAE5D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAkB;QA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AC,YAAgC;QAC7E,KAAK,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM;YACb,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAzGD,oDAyGC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n /** The model for the aspect affected by this event */\r\n model: Id64String;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public\r\n */\r\nexport class ElementAspect extends Entity {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(arg: OnAspectPropsArg): void {\r\n arg.iModel.channels.verifyChannel(arg.model);\r\n }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(arg: OnAspectPropsArg): void {\r\n arg.iModel.channels.verifyChannel(arg.model);\r\n }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(arg: OnAspectIdArg): void {\r\n arg.iModel.channels.verifyChannel(arg.model);\r\n }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n /** Insert a ChannelRootAspect on the specified element.\r\n * @deprecated in 4.0 use [[ChannelControl.insertChannelSubject]]\r\n */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\r\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\r\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\r\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\r\n */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\r\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\r\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\r\n */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** @deprecated in 3.x. findAllBySource */\r\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n let elementId: Id64String | undefined;\r\n let aspectId: Id64String | undefined;\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n elementId = statement.getValue(0).getId();\r\n aspectId = statement.getValue(1).getId();\r\n }\r\n });\r\n return { elementId, aspectId };\r\n }\r\n\r\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\r\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\r\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\r\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\r\n * Therefore, the result array could have more than one entry with the same elementId.\r\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\r\n * @param iModelDb The iModel to query\r\n * @param scope The scope of the ExternalSourceAspects to find\r\n * @param kind The kind of the ExternalSourceAspects to find\r\n * @param identifier The identifier of the ExternalSourceAspects to find\r\n * @returns the query results\r\n */\r\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\r\n }\r\n });\r\n return found;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n\r\n /** @internal */\r\n protected override collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceConcreteIds(referenceIds);\r\n if (this.scope)\r\n referenceIds.addElement(this.scope.id);\r\n referenceIds.addElement(this.element.id);\r\n if (this.source)\r\n referenceIds.addElement(this.source.id);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
@@ -1,10 +1,10 @@
1
- /** @packageDocumentation
2
- * @module Tiles
3
- */
4
- import { ElementGraphicsRequestProps } from "@itwin/core-common";
5
- import { IModelDb } from "./IModelDb";
6
- /** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
7
- * @internal
8
- */
9
- export declare function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined>;
1
+ /** @packageDocumentation
2
+ * @module Tiles
3
+ */
4
+ import { ElementGraphicsRequestProps } from "@itwin/core-common";
5
+ import { IModelDb } from "./IModelDb";
6
+ /** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
7
+ * @internal
8
+ */
9
+ export declare function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined>;
10
10
  //# sourceMappingURL=ElementGraphics.d.ts.map
@@ -1,42 +1,42 @@
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 Tiles
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.generateElementGraphics = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- /** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
14
- * @internal
15
- */
16
- async function generateElementGraphics(request, iModel) {
17
- const result = await iModel.nativeDb.generateElementGraphics(request); // ###TODO update package versions in addon
18
- let error;
19
- switch (result.status) {
20
- case 2 /* NoGeometry */:
21
- case 1 /* Canceled */:
22
- return undefined;
23
- case 0 /* Success */:
24
- return result.content;
25
- case 3 /* InvalidJson */:
26
- error = "Invalid JSON";
27
- break;
28
- case 4 /* UnknownMajorFormatVersion */:
29
- error = "Unknown major format version";
30
- break;
31
- case 5 /* ElementNotFound */:
32
- error = `Element Id ${request.elementId} not found`;
33
- break;
34
- case 6 /* DuplicateRequestId */:
35
- error = `Duplicate request Id "${request.id}"`;
36
- break;
37
- }
38
- (0, core_bentley_1.assert)(undefined !== error);
39
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, error);
40
- }
41
- exports.generateElementGraphics = generateElementGraphics;
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 Tiles
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.generateElementGraphics = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ /** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
14
+ * @internal
15
+ */
16
+ async function generateElementGraphics(request, iModel) {
17
+ const result = await iModel.nativeDb.generateElementGraphics(request); // ###TODO update package versions in addon
18
+ let error;
19
+ switch (result.status) {
20
+ case 2 /* ElementGraphicsStatus.NoGeometry */:
21
+ case 1 /* ElementGraphicsStatus.Canceled */:
22
+ return undefined;
23
+ case 0 /* ElementGraphicsStatus.Success */:
24
+ return result.content;
25
+ case 3 /* ElementGraphicsStatus.InvalidJson */:
26
+ error = "Invalid JSON";
27
+ break;
28
+ case 4 /* ElementGraphicsStatus.UnknownMajorFormatVersion */:
29
+ error = "Unknown major format version";
30
+ break;
31
+ case 5 /* ElementGraphicsStatus.ElementNotFound */:
32
+ error = `Element Id ${request.elementId} not found`;
33
+ break;
34
+ case 6 /* ElementGraphicsStatus.DuplicateRequestId */:
35
+ error = `Duplicate request Id "${request.id}"`;
36
+ break;
37
+ }
38
+ (0, core_bentley_1.assert)(undefined !== error);
39
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, error);
40
+ }
41
+ exports.generateElementGraphics = generateElementGraphics;
42
42
  //# sourceMappingURL=ElementGraphics.js.map