@itwin/core-backend 5.15.0-dev.9 → 5.15.0

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 (220) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/lib/cjs/BlobContainerService.d.ts +2 -0
  3. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  4. package/lib/cjs/BlobContainerService.js.map +1 -1
  5. package/lib/cjs/BriefcaseManager.d.ts +2 -1
  6. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  7. package/lib/cjs/BriefcaseManager.js +39 -9
  8. package/lib/cjs/BriefcaseManager.js.map +1 -1
  9. package/lib/cjs/ChangeUnifier.d.ts +82 -0
  10. package/lib/cjs/ChangeUnifier.d.ts.map +1 -0
  11. package/lib/cjs/ChangeUnifier.js +163 -0
  12. package/lib/cjs/ChangeUnifier.js.map +1 -0
  13. package/lib/cjs/ChangesetReader.d.ts +21 -2
  14. package/lib/cjs/ChangesetReader.d.ts.map +1 -1
  15. package/lib/cjs/ChangesetReader.js +37 -1
  16. package/lib/cjs/ChangesetReader.js.map +1 -1
  17. package/lib/cjs/CloudSqlite.d.ts +15 -0
  18. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  19. package/lib/cjs/CloudSqlite.js.map +1 -1
  20. package/lib/cjs/ECDb.d.ts +1 -0
  21. package/lib/cjs/ECDb.d.ts.map +1 -1
  22. package/lib/cjs/ECDb.js +4 -1
  23. package/lib/cjs/ECDb.js.map +1 -1
  24. package/lib/cjs/EditTxn.d.ts +61 -19
  25. package/lib/cjs/EditTxn.d.ts.map +1 -1
  26. package/lib/cjs/EditTxn.js +84 -29
  27. package/lib/cjs/EditTxn.js.map +1 -1
  28. package/lib/cjs/GeoCoordConfig.d.ts +1 -0
  29. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  30. package/lib/cjs/GeoCoordConfig.js +12 -8
  31. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  32. package/lib/cjs/IModelDb.d.ts +22 -9
  33. package/lib/cjs/IModelDb.d.ts.map +1 -1
  34. package/lib/cjs/IModelDb.js +54 -12
  35. package/lib/cjs/IModelDb.js.map +1 -1
  36. package/lib/cjs/NativeHost.d.ts.map +1 -1
  37. package/lib/cjs/NativeHost.js +5 -1
  38. package/lib/cjs/NativeHost.js.map +1 -1
  39. package/lib/cjs/Relationship.d.ts +28 -0
  40. package/lib/cjs/Relationship.d.ts.map +1 -1
  41. package/lib/cjs/Relationship.js +78 -0
  42. package/lib/cjs/Relationship.js.map +1 -1
  43. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  44. package/lib/cjs/SchemaSync.js +1 -0
  45. package/lib/cjs/SchemaSync.js.map +1 -1
  46. package/lib/cjs/TxnManager.d.ts +126 -89
  47. package/lib/cjs/TxnManager.d.ts.map +1 -1
  48. package/lib/cjs/TxnManager.js +114 -76
  49. package/lib/cjs/TxnManager.js.map +1 -1
  50. package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
  51. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  52. package/lib/cjs/ViewStore.d.ts.map +1 -1
  53. package/lib/cjs/ViewStore.js +62 -19
  54. package/lib/cjs/ViewStore.js.map +1 -1
  55. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
  56. package/lib/cjs/annotations/LeaderGeometry.js +3 -0
  57. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  58. package/lib/cjs/core-backend.d.ts +1 -0
  59. package/lib/cjs/core-backend.d.ts.map +1 -1
  60. package/lib/cjs/core-backend.js +1 -0
  61. package/lib/cjs/core-backend.js.map +1 -1
  62. package/lib/cjs/internal/BriefcaseUtils.d.ts +19 -0
  63. package/lib/cjs/internal/BriefcaseUtils.d.ts.map +1 -0
  64. package/lib/cjs/internal/BriefcaseUtils.js +65 -0
  65. package/lib/cjs/internal/BriefcaseUtils.js.map +1 -0
  66. package/lib/cjs/internal/QueryMetadataCache.d.ts +44 -0
  67. package/lib/cjs/internal/QueryMetadataCache.d.ts.map +1 -0
  68. package/lib/cjs/internal/QueryMetadataCache.js +107 -0
  69. package/lib/cjs/internal/QueryMetadataCache.js.map +1 -0
  70. package/lib/cjs/internal/Symbols.d.ts +9 -0
  71. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  72. package/lib/cjs/internal/Symbols.js +10 -1
  73. package/lib/cjs/internal/Symbols.js.map +1 -1
  74. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  75. package/lib/cjs/internal/workspace/WorkspaceImpl.js +20 -6
  76. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  77. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
  78. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  79. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  80. package/lib/cjs/workspace/SettingsEditor.d.ts +4 -3
  81. package/lib/cjs/workspace/SettingsEditor.d.ts.map +1 -1
  82. package/lib/cjs/workspace/SettingsEditor.js +7 -5
  83. package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
  84. package/lib/esm/BlobContainerService.d.ts +2 -0
  85. package/lib/esm/BlobContainerService.d.ts.map +1 -1
  86. package/lib/esm/BlobContainerService.js.map +1 -1
  87. package/lib/esm/BriefcaseManager.d.ts +2 -1
  88. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  89. package/lib/esm/BriefcaseManager.js +40 -10
  90. package/lib/esm/BriefcaseManager.js.map +1 -1
  91. package/lib/esm/ChangeUnifier.d.ts +82 -0
  92. package/lib/esm/ChangeUnifier.d.ts.map +1 -0
  93. package/lib/esm/ChangeUnifier.js +159 -0
  94. package/lib/esm/ChangeUnifier.js.map +1 -0
  95. package/lib/esm/ChangesetReader.d.ts +21 -2
  96. package/lib/esm/ChangesetReader.d.ts.map +1 -1
  97. package/lib/esm/ChangesetReader.js +38 -2
  98. package/lib/esm/ChangesetReader.js.map +1 -1
  99. package/lib/esm/CloudSqlite.d.ts +15 -0
  100. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  101. package/lib/esm/CloudSqlite.js.map +1 -1
  102. package/lib/esm/ECDb.d.ts +1 -0
  103. package/lib/esm/ECDb.d.ts.map +1 -1
  104. package/lib/esm/ECDb.js +4 -1
  105. package/lib/esm/ECDb.js.map +1 -1
  106. package/lib/esm/EditTxn.d.ts +61 -19
  107. package/lib/esm/EditTxn.d.ts.map +1 -1
  108. package/lib/esm/EditTxn.js +85 -30
  109. package/lib/esm/EditTxn.js.map +1 -1
  110. package/lib/esm/GeoCoordConfig.d.ts +1 -0
  111. package/lib/esm/GeoCoordConfig.d.ts.map +1 -1
  112. package/lib/esm/GeoCoordConfig.js +12 -8
  113. package/lib/esm/GeoCoordConfig.js.map +1 -1
  114. package/lib/esm/IModelDb.d.ts +22 -9
  115. package/lib/esm/IModelDb.d.ts.map +1 -1
  116. package/lib/esm/IModelDb.js +56 -14
  117. package/lib/esm/IModelDb.js.map +1 -1
  118. package/lib/esm/NativeHost.d.ts.map +1 -1
  119. package/lib/esm/NativeHost.js +5 -1
  120. package/lib/esm/NativeHost.js.map +1 -1
  121. package/lib/esm/Relationship.d.ts +28 -0
  122. package/lib/esm/Relationship.d.ts.map +1 -1
  123. package/lib/esm/Relationship.js +78 -0
  124. package/lib/esm/Relationship.js.map +1 -1
  125. package/lib/esm/SchemaSync.d.ts.map +1 -1
  126. package/lib/esm/SchemaSync.js +1 -0
  127. package/lib/esm/SchemaSync.js.map +1 -1
  128. package/lib/esm/TxnManager.d.ts +126 -89
  129. package/lib/esm/TxnManager.d.ts.map +1 -1
  130. package/lib/esm/TxnManager.js +116 -78
  131. package/lib/esm/TxnManager.js.map +1 -1
  132. package/lib/esm/ViewStateHydrator.d.ts.map +1 -1
  133. package/lib/esm/ViewStateHydrator.js.map +1 -1
  134. package/lib/esm/ViewStore.d.ts.map +1 -1
  135. package/lib/esm/ViewStore.js +62 -19
  136. package/lib/esm/ViewStore.js.map +1 -1
  137. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
  138. package/lib/esm/annotations/LeaderGeometry.js +3 -0
  139. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  140. package/lib/esm/core-backend.d.ts +1 -0
  141. package/lib/esm/core-backend.d.ts.map +1 -1
  142. package/lib/esm/core-backend.js +1 -0
  143. package/lib/esm/core-backend.js.map +1 -1
  144. package/lib/esm/internal/BriefcaseUtils.d.ts +19 -0
  145. package/lib/esm/internal/BriefcaseUtils.d.ts.map +1 -0
  146. package/lib/esm/internal/BriefcaseUtils.js +61 -0
  147. package/lib/esm/internal/BriefcaseUtils.js.map +1 -0
  148. package/lib/esm/internal/QueryMetadataCache.d.ts +44 -0
  149. package/lib/esm/internal/QueryMetadataCache.d.ts.map +1 -0
  150. package/lib/esm/internal/QueryMetadataCache.js +103 -0
  151. package/lib/esm/internal/QueryMetadataCache.js.map +1 -0
  152. package/lib/esm/internal/Symbols.d.ts +9 -0
  153. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  154. package/lib/esm/internal/Symbols.js +9 -0
  155. package/lib/esm/internal/Symbols.js.map +1 -1
  156. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  157. package/lib/esm/internal/workspace/WorkspaceImpl.js +20 -6
  158. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  159. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
  160. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  161. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  162. package/lib/esm/test/annotations/LeaderGeometry.test.js +15 -1
  163. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  164. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +144 -30
  165. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  166. package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts +2 -0
  167. package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts.map +1 -0
  168. package/lib/esm/test/ecdb/QueryMetadataCache.test.js +630 -0
  169. package/lib/esm/test/ecdb/QueryMetadataCache.test.js.map +1 -0
  170. package/lib/esm/test/element/DeleteDefinitionElements.test.js +403 -249
  171. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  172. package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts +2 -0
  173. package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts.map +1 -0
  174. package/lib/esm/test/element/RelationshipBatchLookup.test.js +202 -0
  175. package/lib/esm/test/element/RelationshipBatchLookup.test.js.map +1 -0
  176. package/lib/esm/test/hubaccess/BriefcaseManager.test.js +187 -1
  177. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  178. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts +2 -0
  179. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts.map +1 -0
  180. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js +142 -0
  181. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js.map +1 -0
  182. package/lib/esm/test/imodel/IModelGeolocation.test.js +8 -6
  183. package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -1
  184. package/lib/esm/test/imodel/IModelProps.test.d.ts +2 -0
  185. package/lib/esm/test/imodel/IModelProps.test.d.ts.map +1 -0
  186. package/lib/esm/test/imodel/IModelProps.test.js +411 -0
  187. package/lib/esm/test/imodel/IModelProps.test.js.map +1 -0
  188. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts +2 -0
  189. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts.map +1 -0
  190. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js +240 -0
  191. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js.map +1 -0
  192. package/lib/esm/test/schema/SchemaViewValidation.test.js +2 -8
  193. package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -1
  194. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts +2 -0
  195. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts.map +1 -0
  196. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js +159 -0
  197. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js.map +1 -0
  198. package/lib/esm/test/standalone/ChangeUnifier.test.d.ts +2 -0
  199. package/lib/esm/test/standalone/ChangeUnifier.test.d.ts.map +1 -0
  200. package/lib/esm/test/standalone/ChangeUnifier.test.js +732 -0
  201. package/lib/esm/test/standalone/ChangeUnifier.test.js.map +1 -0
  202. package/lib/esm/test/standalone/DeleteElements.test.js +962 -83
  203. package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
  204. package/lib/esm/test/standalone/EditTxn.test.js +72 -1
  205. package/lib/esm/test/standalone/EditTxn.test.js.map +1 -1
  206. package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts +2 -0
  207. package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts.map +1 -0
  208. package/lib/esm/test/standalone/GeoCoordConfig.test.js +158 -0
  209. package/lib/esm/test/standalone/GeoCoordConfig.test.js.map +1 -0
  210. package/lib/esm/test/standalone/ViewStoreDb.test.js +53 -0
  211. package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
  212. package/lib/esm/test/workspace/SettingsContainers.test.d.ts +2 -0
  213. package/lib/esm/test/workspace/SettingsContainers.test.d.ts.map +1 -0
  214. package/lib/esm/test/workspace/SettingsContainers.test.js +95 -0
  215. package/lib/esm/test/workspace/SettingsContainers.test.js.map +1 -0
  216. package/lib/esm/workspace/SettingsEditor.d.ts +4 -3
  217. package/lib/esm/workspace/SettingsEditor.d.ts.map +1 -1
  218. package/lib/esm/workspace/SettingsEditor.js +7 -5
  219. package/lib/esm/workspace/SettingsEditor.js.map +1 -1
  220. package/package.json +18 -18
@@ -1 +1 @@
1
- {"version":3,"file":"NativeHost.d.ts","sourceRo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B,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAehE,mEAAmE;WAC/C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAM7C,iDAAiD;WACnC,yBAAyB,IAAI,0BAA0B;IAIrE;;;;OAIG;WACW,4BAA4B,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,0BAA0B,GAAG,IAAI;CAYjH"}
@@ -18,6 +18,7 @@ const IpcHost_1 = require("./IpcHost");
18
18
  const NativeAppStorage_1 = require("./NativeAppStorage");
19
19
  const CatalogDb_1 = require("./CatalogDb");
20
20
  const OnlineStatus_1 = require("./internal/OnlineStatus");
21
+ const BriefcaseUtils_1 = require("./internal/BriefcaseUtils");
21
22
  /**
22
23
  * Implementation of NativeAppFunctions
23
24
  */
@@ -65,7 +66,10 @@ class NativeAppHandler extends IpcHost_1.IpcHandler {
65
66
  return job !== undefined;
66
67
  }
67
68
  async deleteBriefcaseFiles(fileName) {
68
- await BriefcaseManager_1.BriefcaseManager.deleteBriefcaseFiles(fileName, await IModelHost_1.IModelHost.getAccessToken());
69
+ // fileName comes from the frontend. Only allow deleting files in the briefcase cache, or valid iModels.
70
+ const filePath = (0, BriefcaseUtils_1.checkFrontendBriefcaseDelete)(fileName, BriefcaseManager_1.BriefcaseManager.cacheDir);
71
+ if (undefined !== filePath)
72
+ await BriefcaseManager_1.BriefcaseManager.deleteBriefcaseFiles(filePath, await IModelHost_1.IModelHost.getAccessToken());
69
73
  }
70
74
  async getCachedBriefcases(iModelId) {
71
75
  return BriefcaseManager_1.BriefcaseManager.getCachedBriefcases(iModelId);
@@ -1 +1 @@
1
- {"version":3,"file":"NativeHost.js","sourceRoot":"","sources":["../../src/NativeHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA4B;AAC5B,sDAAgG;AAChG,oDAG4B;AAC5B,yDAA8E;AAC9E,2DAAkF;AAClF,6CAA0C;AAC1C,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;QAClC,CAAC;IACH,CAAC;IAED,mEAAmE;IAC5D,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,6BAA6B,CAAC,KAAK,EAAE,CAAC;QAC3C,MAAM,iBAAO,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED,iDAAiD;IAC1C,MAAM,CAAC,yBAAyB;QACrC,OAAO,IAAI,CAAC,aAAa,IAAI,wCAA0B,CAAC,MAAM,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,4BAA4B,CAAC,YAA0B,EAAE,MAAkC;QACvG,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;YAC5B,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACtD,IAAI,8BAAe,CAAC,kBAAkB,IAAI,8BAAe,CAAC,oBAAoB,EAAE,CAAC;gBAC/E,2FAA2F;gBAC3F,6FAA6F;gBAC7F,qFAAqF;gBACrF,IAAA,8BAAe,EAAC,MAAM,KAAK,wCAA0B,CAAC,MAAM,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;;AA3EH,gCA4EC","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 NativeApp\r\n */\r\n\r\nimport { join } from \"path\";\r\nimport { AccessToken, assert, BeEvent, GuidString, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseProps, InternetConnectivityStatus, LocalBriefcaseProps, NativeAppFunctions, nativeAppIpcStrings, NativeAppNotifications,\r\n OverriddenBy, RequestNewBriefcaseProps, StorageValue,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseManager, RequestNewBriefcaseArg } from \"./BriefcaseManager\";\r\nimport { Downloads, ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IpcHandler, IpcHost, IpcHostOpts, throttleProgressCallback } from \"./IpcHost\";\r\nimport { NativeAppStorage } from \"./NativeAppStorage\";\r\nimport { CatalogIModelHandler } from \"./CatalogDb\";\r\nimport { setOnlineStatus } from \"./internal/OnlineStatus\";\r\n\r\n/**\r\n * Implementation of NativeAppFunctions\r\n */\r\nclass NativeAppHandler extends IpcHandler implements NativeAppFunctions {\r\n public get channelName() { return nativeAppIpcStrings.channelName; }\r\n\r\n public async getAccessToken(): Promise<AccessToken | undefined> {\r\n return IModelHost.authorizationClient?.getAccessToken();\r\n }\r\n\r\n public async checkInternetConnectivity(): Promise<InternetConnectivityStatus> {\r\n return NativeHost.checkInternetConnectivity();\r\n }\r\n public async overrideInternetConnectivity(by: OverriddenBy, status: InternetConnectivityStatus): Promise<void> {\r\n NativeHost.overrideInternetConnectivity(by, status);\r\n }\r\n public async acquireNewBriefcaseId(iModelId: GuidString): Promise<number> {\r\n return BriefcaseManager.acquireNewBriefcaseId({ iModelId });\r\n }\r\n public async getBriefcaseFileName(props: BriefcaseProps): Promise<string> {\r\n return BriefcaseManager.getFileName(props);\r\n }\r\n public async downloadBriefcase(request: RequestNewBriefcaseProps, reportProgress: boolean, progressInterval?: number): Promise<LocalBriefcaseProps> {\r\n const args: RequestNewBriefcaseArg = {\r\n ...request,\r\n accessToken: await this.getAccessToken(),\r\n onProgress: (_a: number, _b: number) => checkAbort(),\r\n };\r\n\r\n const checkAbort = () => {\r\n assert(undefined !== args.fileName);\r\n const job = Downloads.isInProgress(args.fileName);\r\n return (job && (job.request as any).abort === 1) ? ProgressStatus.Abort : ProgressStatus.Continue;\r\n };\r\n\r\n if (reportProgress) {\r\n const progressCallback: ProgressFunction = (loaded, total) => {\r\n IpcHost.send(`nativeApp.progress-${request.iModelId}`, { loaded, total });\r\n return checkAbort();\r\n };\r\n args.onProgress = throttleProgressCallback(progressCallback, checkAbort, progressInterval);\r\n }\r\n\r\n return BriefcaseManager.downloadBriefcase(args);\r\n }\r\n\r\n public async requestCancelDownloadBriefcase(fileName: string): Promise<boolean> {\r\n const job = Downloads.isInProgress(fileName);\r\n if (job)\r\n (job.request as any).abort = 1;\r\n return job !== undefined;\r\n }\r\n\r\n public async deleteBriefcaseFiles(fileName: string): Promise<void> {\r\n await BriefcaseManager.deleteBriefcaseFiles(fileName, await IModelHost.getAccessToken());\r\n }\r\n\r\n public async getCachedBriefcases(iModelId?: GuidString): Promise<LocalBriefcaseProps[]> {\r\n return BriefcaseManager.getCachedBriefcases(iModelId);\r\n }\r\n\r\n public async storageMgrOpen(storageId: string): Promise<string> {\r\n return NativeAppStorage.open(storageId).id;\r\n }\r\n\r\n public async storageMgrClose(storageId: string, deleteIt: boolean): Promise<void> {\r\n NativeAppStorage.find(storageId).close(deleteIt);\r\n }\r\n\r\n public async storageMgrNames(): Promise<string[]> {\r\n return NativeAppStorage.getStorageNames();\r\n }\r\n\r\n public async storageGetValueType(storageId: string, key: string): Promise<\"number\" | \"string\" | \"boolean\" | \"Uint8Array\" | \"null\" | undefined> {\r\n return NativeAppStorage.find(storageId).getValueType(key);\r\n }\r\n\r\n public async storageGet(storageId: string, key: string): Promise<StorageValue | undefined> {\r\n return NativeAppStorage.find(storageId).getData(key);\r\n }\r\n\r\n public async storageSet(storageId: string, key: string, value: StorageValue): Promise<void> {\r\n NativeAppStorage.find(storageId).setData(key, value);\r\n }\r\n\r\n public async storageRemove(storageId: string, key: string): Promise<void> {\r\n NativeAppStorage.find(storageId).removeData(key);\r\n }\r\n\r\n public async storageKeys(storageId: string): Promise<string[]> {\r\n return NativeAppStorage.find(storageId).getKeys();\r\n }\r\n\r\n public async storageRemoveAll(storageId: string): Promise<void> {\r\n NativeAppStorage.find(storageId).removeAll();\r\n }\r\n}\r\n\r\n/** Options for [[NativeHost.startup]]\r\n * @public\r\n */\r\nexport interface NativeHostOpts extends IpcHostOpts {\r\n nativeHost?: {\r\n /** Application name. Used, for example, to name the settings file. If not supplied, defaults to \"iTwinApp\". */\r\n applicationName?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Backend for desktop/mobile native applications\r\n * @public\r\n */\r\nexport class NativeHost {\r\n private static _reachability?: InternetConnectivityStatus;\r\n private static _applicationName: string;\r\n private constructor() { } // no instances - static methods only\r\n\r\n /** Event called when the internet connectivity changes, if known. */\r\n public static readonly onInternetConnectivityChanged = new BeEvent<(status: InternetConnectivityStatus) => void>();\r\n\r\n private static _appSettingsCacheDir?: string;\r\n\r\n /** Get the local cache folder for application settings */\r\n public static get appSettingsCacheDir(): string {\r\n return this._appSettingsCacheDir ??= join(IModelHost.cacheDir, \"appSettings\");\r\n }\r\n\r\n /** Send a notification to the NativeApp connected to this NativeHost. */\r\n public static notifyNativeFrontend<T extends keyof NativeAppNotifications>(methodName: T, ...args: Parameters<NativeAppNotifications[T]>) {\r\n return IpcHost.send(nativeAppIpcStrings.notifyChannel, methodName, ...args);\r\n }\r\n\r\n private static _isValid = false;\r\n public static get isValid(): boolean { return this._isValid; }\r\n public static get applicationName() { return this._applicationName; }\r\n /** Get the settings store for this NativeHost. */\r\n public static get settingsStore() {\r\n return NativeAppStorage.open(this.applicationName);\r\n }\r\n\r\n /**\r\n * Start the backend of a native app.\r\n * @note this method calls [[IpcHost.startup]] internally.\r\n */\r\n public static async startup(opt?: NativeHostOpts): Promise<void> {\r\n if (!this.isValid) {\r\n this._isValid = true;\r\n this.onInternetConnectivityChanged.addListener((status: InternetConnectivityStatus) =>\r\n NativeHost.notifyNativeFrontend(\"notifyInternetConnectivityChanged\", status));\r\n this._applicationName = opt?.nativeHost?.applicationName ?? \"iTwinApp\";\r\n }\r\n\r\n await IpcHost.startup(opt);\r\n if (IpcHost.isValid) { // for tests, we use NativeHost but don't have a frontend\r\n NativeAppHandler.register();\r\n CatalogIModelHandler.register();\r\n }\r\n }\r\n\r\n /** Shutdown native app backend. Also calls [[IpcHost.shutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n this._isValid = false;\r\n this.onInternetConnectivityChanged.clear();\r\n await IpcHost.shutdown();\r\n }\r\n\r\n /** get current value of internet connectivity */\r\n public static checkInternetConnectivity(): InternetConnectivityStatus {\r\n return this._reachability ?? InternetConnectivityStatus.Online;\r\n }\r\n\r\n /**\r\n * Override internet connectivity state\r\n * @param _overridenBy who overrode the value.\r\n * @internal\r\n */\r\n public static overrideInternetConnectivity(_overridenBy: OverriddenBy, status: InternetConnectivityStatus): void {\r\n if (this._reachability !== status) {\r\n this._reachability = status;\r\n this.onInternetConnectivityChanged.raiseEvent(status);\r\n if (ProcessDetector.isMobileAppBackend || ProcessDetector.isElectronAppBackend) {\r\n // Merely referencing NativeHost from a non-native backend causes a runtime exception (even\r\n // inside an if statement that checks that the backend is a mobile backend). This allows code\r\n // that needs to check connectivity to do so without referencing NativeHost directly.\r\n setOnlineStatus(status === InternetConnectivityStatus.Online);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"NativeHost.js","sourceRoot":"","sources":["../../src/NativeHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA4B;AAC5B,sDAAgG;AAChG,oDAG4B;AAC5B,yDAA8E;AAC9E,2DAAkF;AAClF,6CAA0C;AAC1C,uCAAuF;AACvF,yDAAsD;AACtD,2CAAmD;AACnD,0DAA0D;AAC1D,8DAAyE;AAEzE;;GAEG;AACH,MAAM,gBAAiB,SAAQ,oBAAU;IACvC,IAAW,WAAW,KAAK,OAAO,iCAAmB,CAAC,WAAW,CAAC,CAAC,CAAC;IAE7D,KAAK,CAAC,cAAc;QACzB,OAAO,uBAAU,CAAC,mBAAmB,EAAE,cAAc,EAAE,CAAC;IAC1D,CAAC;IAEM,KAAK,CAAC,yBAAyB;QACpC,OAAO,UAAU,CAAC,yBAAyB,EAAE,CAAC;IAChD,CAAC;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,CAAC;IAC3B,CAAC;IAED,iDAAiD;IAC1C,MAAM,CAAC,yBAAyB;QACrC,OAAO,IAAI,CAAC,aAAa,IAAI,wCAA0B,CAAC,MAAM,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,4BAA4B,CAAC,YAA0B,EAAE,MAAkC;QACvG,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;YAC5B,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACtD,IAAI,8BAAe,CAAC,kBAAkB,IAAI,8BAAe,CAAC,oBAAoB,EAAE,CAAC;gBAC/E,2FAA2F;gBAC3F,6FAA6F;gBAC7F,qFAAqF;gBACrF,IAAA,8BAAe,EAAC,MAAM,KAAK,wCAA0B,CAAC,MAAM,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;;AA3EH,gCA4EC","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 NativeApp\r\n */\r\n\r\nimport { join } from \"path\";\r\nimport { AccessToken, assert, BeEvent, GuidString, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseProps, InternetConnectivityStatus, LocalBriefcaseProps, NativeAppFunctions, nativeAppIpcStrings, NativeAppNotifications,\r\n OverriddenBy, RequestNewBriefcaseProps, StorageValue,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseManager, RequestNewBriefcaseArg } from \"./BriefcaseManager\";\r\nimport { Downloads, ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IpcHandler, IpcHost, IpcHostOpts, throttleProgressCallback } from \"./IpcHost\";\r\nimport { NativeAppStorage } from \"./NativeAppStorage\";\r\nimport { CatalogIModelHandler } from \"./CatalogDb\";\r\nimport { setOnlineStatus } from \"./internal/OnlineStatus\";\r\nimport { checkFrontendBriefcaseDelete } from \"./internal/BriefcaseUtils\";\r\n\r\n/**\r\n * Implementation of NativeAppFunctions\r\n */\r\nclass NativeAppHandler extends IpcHandler implements NativeAppFunctions {\r\n public get channelName() { return nativeAppIpcStrings.channelName; }\r\n\r\n public async getAccessToken(): Promise<AccessToken | undefined> {\r\n return IModelHost.authorizationClient?.getAccessToken();\r\n }\r\n\r\n public async checkInternetConnectivity(): Promise<InternetConnectivityStatus> {\r\n return NativeHost.checkInternetConnectivity();\r\n }\r\n public async overrideInternetConnectivity(by: OverriddenBy, status: InternetConnectivityStatus): Promise<void> {\r\n NativeHost.overrideInternetConnectivity(by, status);\r\n }\r\n public async acquireNewBriefcaseId(iModelId: GuidString): Promise<number> {\r\n return BriefcaseManager.acquireNewBriefcaseId({ iModelId });\r\n }\r\n public async getBriefcaseFileName(props: BriefcaseProps): Promise<string> {\r\n return BriefcaseManager.getFileName(props);\r\n }\r\n public async downloadBriefcase(request: RequestNewBriefcaseProps, reportProgress: boolean, progressInterval?: number): Promise<LocalBriefcaseProps> {\r\n const args: RequestNewBriefcaseArg = {\r\n ...request,\r\n accessToken: await this.getAccessToken(),\r\n onProgress: (_a: number, _b: number) => checkAbort(),\r\n };\r\n\r\n const checkAbort = () => {\r\n assert(undefined !== args.fileName);\r\n const job = Downloads.isInProgress(args.fileName);\r\n return (job && (job.request as any).abort === 1) ? ProgressStatus.Abort : ProgressStatus.Continue;\r\n };\r\n\r\n if (reportProgress) {\r\n const progressCallback: ProgressFunction = (loaded, total) => {\r\n IpcHost.send(`nativeApp.progress-${request.iModelId}`, { loaded, total });\r\n return checkAbort();\r\n };\r\n args.onProgress = throttleProgressCallback(progressCallback, checkAbort, progressInterval);\r\n }\r\n\r\n return BriefcaseManager.downloadBriefcase(args);\r\n }\r\n\r\n public async requestCancelDownloadBriefcase(fileName: string): Promise<boolean> {\r\n const job = Downloads.isInProgress(fileName);\r\n if (job)\r\n (job.request as any).abort = 1;\r\n return job !== undefined;\r\n }\r\n\r\n public async deleteBriefcaseFiles(fileName: string): Promise<void> {\r\n // fileName comes from the frontend. Only allow deleting files in the briefcase cache, or valid iModels.\r\n const filePath = checkFrontendBriefcaseDelete(fileName, BriefcaseManager.cacheDir);\r\n if (undefined !== filePath)\r\n await BriefcaseManager.deleteBriefcaseFiles(filePath, await IModelHost.getAccessToken());\r\n }\r\n\r\n public async getCachedBriefcases(iModelId?: GuidString): Promise<LocalBriefcaseProps[]> {\r\n return BriefcaseManager.getCachedBriefcases(iModelId);\r\n }\r\n\r\n public async storageMgrOpen(storageId: string): Promise<string> {\r\n return NativeAppStorage.open(storageId).id;\r\n }\r\n\r\n public async storageMgrClose(storageId: string, deleteIt: boolean): Promise<void> {\r\n NativeAppStorage.find(storageId).close(deleteIt);\r\n }\r\n\r\n public async storageMgrNames(): Promise<string[]> {\r\n return NativeAppStorage.getStorageNames();\r\n }\r\n\r\n public async storageGetValueType(storageId: string, key: string): Promise<\"number\" | \"string\" | \"boolean\" | \"Uint8Array\" | \"null\" | undefined> {\r\n return NativeAppStorage.find(storageId).getValueType(key);\r\n }\r\n\r\n public async storageGet(storageId: string, key: string): Promise<StorageValue | undefined> {\r\n return NativeAppStorage.find(storageId).getData(key);\r\n }\r\n\r\n public async storageSet(storageId: string, key: string, value: StorageValue): Promise<void> {\r\n NativeAppStorage.find(storageId).setData(key, value);\r\n }\r\n\r\n public async storageRemove(storageId: string, key: string): Promise<void> {\r\n NativeAppStorage.find(storageId).removeData(key);\r\n }\r\n\r\n public async storageKeys(storageId: string): Promise<string[]> {\r\n return NativeAppStorage.find(storageId).getKeys();\r\n }\r\n\r\n public async storageRemoveAll(storageId: string): Promise<void> {\r\n NativeAppStorage.find(storageId).removeAll();\r\n }\r\n}\r\n\r\n/** Options for [[NativeHost.startup]]\r\n * @public\r\n */\r\nexport interface NativeHostOpts extends IpcHostOpts {\r\n nativeHost?: {\r\n /** Application name. Used, for example, to name the settings file. If not supplied, defaults to \"iTwinApp\". */\r\n applicationName?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Backend for desktop/mobile native applications\r\n * @public\r\n */\r\nexport class NativeHost {\r\n private static _reachability?: InternetConnectivityStatus;\r\n private static _applicationName: string;\r\n private constructor() { } // no instances - static methods only\r\n\r\n /** Event called when the internet connectivity changes, if known. */\r\n public static readonly onInternetConnectivityChanged = new BeEvent<(status: InternetConnectivityStatus) => void>();\r\n\r\n private static _appSettingsCacheDir?: string;\r\n\r\n /** Get the local cache folder for application settings */\r\n public static get appSettingsCacheDir(): string {\r\n return this._appSettingsCacheDir ??= join(IModelHost.cacheDir, \"appSettings\");\r\n }\r\n\r\n /** Send a notification to the NativeApp connected to this NativeHost. */\r\n public static notifyNativeFrontend<T extends keyof NativeAppNotifications>(methodName: T, ...args: Parameters<NativeAppNotifications[T]>) {\r\n return IpcHost.send(nativeAppIpcStrings.notifyChannel, methodName, ...args);\r\n }\r\n\r\n private static _isValid = false;\r\n public static get isValid(): boolean { return this._isValid; }\r\n public static get applicationName() { return this._applicationName; }\r\n /** Get the settings store for this NativeHost. */\r\n public static get settingsStore() {\r\n return NativeAppStorage.open(this.applicationName);\r\n }\r\n\r\n /**\r\n * Start the backend of a native app.\r\n * @note this method calls [[IpcHost.startup]] internally.\r\n */\r\n public static async startup(opt?: NativeHostOpts): Promise<void> {\r\n if (!this.isValid) {\r\n this._isValid = true;\r\n this.onInternetConnectivityChanged.addListener((status: InternetConnectivityStatus) =>\r\n NativeHost.notifyNativeFrontend(\"notifyInternetConnectivityChanged\", status));\r\n this._applicationName = opt?.nativeHost?.applicationName ?? \"iTwinApp\";\r\n }\r\n\r\n await IpcHost.startup(opt);\r\n if (IpcHost.isValid) { // for tests, we use NativeHost but don't have a frontend\r\n NativeAppHandler.register();\r\n CatalogIModelHandler.register();\r\n }\r\n }\r\n\r\n /** Shutdown native app backend. Also calls [[IpcHost.shutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n this._isValid = false;\r\n this.onInternetConnectivityChanged.clear();\r\n await IpcHost.shutdown();\r\n }\r\n\r\n /** get current value of internet connectivity */\r\n public static checkInternetConnectivity(): InternetConnectivityStatus {\r\n return this._reachability ?? InternetConnectivityStatus.Online;\r\n }\r\n\r\n /**\r\n * Override internet connectivity state\r\n * @param _overridenBy who overrode the value.\r\n * @internal\r\n */\r\n public static overrideInternetConnectivity(_overridenBy: OverriddenBy, status: InternetConnectivityStatus): void {\r\n if (this._reachability !== status) {\r\n this._reachability = status;\r\n this.onInternetConnectivityChanged.raiseEvent(status);\r\n if (ProcessDetector.isMobileAppBackend || ProcessDetector.isElectronAppBackend) {\r\n // Merely referencing NativeHost from a non-native backend causes a runtime exception (even\r\n // inside an if statement that checks that the backend is a mobile backend). This allows code\r\n // that needs to check connectivity to do so without referencing NativeHost directly.\r\n setOnlineStatus(status === InternetConnectivityStatus.Online);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -470,5 +470,33 @@ export declare class Relationships {
470
470
  * @see getInstance
471
471
  */
472
472
  tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined;
473
+ /** Get the props of multiple Relationship instances of the same class using batched queries.
474
+ * This produces the same results as calling [[tryGetInstanceProps]] for each entry in `criteria`, but executes at most two queries regardless of the number of entries.
475
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
476
+ * @param criteria The relationships to look up. Each entry is either a relationship instanceId or the source and target Ids. Entries of both kinds may be mixed.
477
+ * @param options.usePrimaryConn If `true` (the default), the queries run on the primary connection so that unsaved changes are visible, matching [[tryGetInstanceProps]].
478
+ * If `false`, they run on a concurrent query connection, which does not see unsaved changes.
479
+ * @returns An array with the same length and order as `criteria`. Each entry holds the RelationshipProps matching the corresponding criterion, or `undefined` if no such relationship was found.
480
+ * @see tryGetInstanceProps
481
+ * @see queryInstances
482
+ * @beta
483
+ */
484
+ queryInstancesProps<T extends RelationshipProps>(relClassFullName: string, criteria: ReadonlyArray<Id64String | SourceAndTarget>, options?: {
485
+ usePrimaryConn?: boolean;
486
+ }): Promise<Array<T | undefined>>;
487
+ /** Get multiple Relationship instances of the same class using batched queries.
488
+ * This produces the same results as calling [[tryGetInstance]] for each entry in `criteria`, but executes at most two queries regardless of the number of entries.
489
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
490
+ * @param criteria The relationships to look up. Each entry is either a relationship instanceId or the source and target Ids. Entries of both kinds may be mixed.
491
+ * @param options.usePrimaryConn If `true` (the default), the queries run on the primary connection so that unsaved changes are visible, matching [[tryGetInstance]].
492
+ * If `false`, they run on a concurrent query connection, which does not see unsaved changes.
493
+ * @returns An array with the same length and order as `criteria`. Each entry holds the relationship matching the corresponding criterion, or `undefined` if no such relationship was found.
494
+ * @see tryGetInstance
495
+ * @see queryInstancesProps
496
+ * @beta
497
+ */
498
+ queryInstances<T extends Relationship>(relClassFullName: string, criteria: ReadonlyArray<Id64String | SourceAndTarget>, options?: {
499
+ usePrimaryConn?: boolean;
500
+ }): Promise<Array<T | undefined>>;
473
501
  }
474
502
  //# sourceMappingURL=Relationship.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Relationship.d.ts","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAkB,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAA4C,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtI,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;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,EAAE,QAAQ,EAAE,UAAU,GAAG,eAAe,GAAG,CAAC,GAAG,SAAS;IAwBxI;;;;;OAKG;IACI,WAAW,CAAC,CAAC,SAAS,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,eAAe,GAAG,CAAC;IAI9G;;;;;;OAMG;IACI,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,eAAe,GAAG,CAAC,GAAG,SAAS;IAK9H;;;;;;;;;;OAUG;IACU,mBAAmB,CAAC,CAAC,SAAS,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,UAAU,GAAG,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAyDrN;;;;;;;;;;OAUG;IACU,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,UAAU,GAAG,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CAI5M"}
@@ -532,6 +532,84 @@ class Relationships {
532
532
  const relationshipProps = this.tryGetInstanceProps(relClassFullName, criteria);
533
533
  return undefined !== relationshipProps ? this._iModel.constructEntity(relationshipProps) : undefined;
534
534
  }
535
+ /** Get the props of multiple Relationship instances of the same class using batched queries.
536
+ * This produces the same results as calling [[tryGetInstanceProps]] for each entry in `criteria`, but executes at most two queries regardless of the number of entries.
537
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
538
+ * @param criteria The relationships to look up. Each entry is either a relationship instanceId or the source and target Ids. Entries of both kinds may be mixed.
539
+ * @param options.usePrimaryConn If `true` (the default), the queries run on the primary connection so that unsaved changes are visible, matching [[tryGetInstanceProps]].
540
+ * If `false`, they run on a concurrent query connection, which does not see unsaved changes.
541
+ * @returns An array with the same length and order as `criteria`. Each entry holds the RelationshipProps matching the corresponding criterion, or `undefined` if no such relationship was found.
542
+ * @see tryGetInstanceProps
543
+ * @see queryInstances
544
+ * @beta
545
+ */
546
+ async queryInstancesProps(relClassFullName, criteria, options) {
547
+ const pairKey = (pair) => `${pair.sourceId}|${pair.targetId}`;
548
+ const ids = new Set();
549
+ const pairs = new Map();
550
+ for (const criterion of criteria) {
551
+ if (typeof criterion === "string") {
552
+ if (core_bentley_1.Id64.isValidId64(criterion))
553
+ ids.add(criterion);
554
+ }
555
+ else if (core_bentley_1.Id64.isValidId64(criterion.sourceId) && core_bentley_1.Id64.isValidId64(criterion.targetId)) {
556
+ pairs.set(pairKey(criterion), [criterion.sourceId, criterion.targetId]);
557
+ }
558
+ }
559
+ // Each query joins the requested values (as an IdSet or json_each virtual table) to the relationship class. CROSS JOIN makes SQLite iterate
560
+ // the requested values and look up each one by index, so only the requested relationships are read, regardless of the size of the class.
561
+ const propsById = new Map();
562
+ const propsByPair = new Map();
563
+ const queries = [];
564
+ if (ids.size > 0) {
565
+ queries.push({
566
+ ecsql: `SELECT r.* FROM IdSet(?) p CROSS JOIN ${relClassFullName} r WHERE r.ECInstanceId = p.id`,
567
+ params: new core_common_1.QueryBinder().bindIdSet(1, ids),
568
+ onProps: (props) => propsById.set(props.id, props),
569
+ });
570
+ }
571
+ if (pairs.size > 0) {
572
+ // json_each yields the ids as hex strings; HexToId converts them to the integer ids stored in the table.
573
+ queries.push({
574
+ ecsql: `SELECT r.* FROM json1.json_each(?) p CROSS JOIN ${relClassFullName} r WHERE r.SourceECInstanceId = HexToId(json_extract(p.[value], '$[0]')) AND r.TargetECInstanceId = HexToId(json_extract(p.[value], '$[1]'))`,
575
+ params: new core_common_1.QueryBinder().bindString(1, JSON.stringify([...pairs.values()])),
576
+ onProps: (props) => {
577
+ // A polymorphic query may find more than one relationship for the same pair; keep the first, like tryGetInstanceProps.
578
+ const key = pairKey(props);
579
+ if (!propsByPair.has(key))
580
+ propsByPair.set(key, props);
581
+ },
582
+ });
583
+ }
584
+ if (queries.length > 0) {
585
+ // Convert rows the same way as tryGetInstanceProps, so that both produce identical props.
586
+ const ecClass = (0, ECSqlInstanceReshaper_1.getRuntimeClass)(this._iModel, relClassFullName);
587
+ const usePrimaryConn = options?.usePrimaryConn ?? true;
588
+ await Promise.all(queries.map(async (query) => {
589
+ for await (const row of this._iModel.createQueryReader(query.ecsql, query.params, { rowFormat: core_common_1.QueryRowFormat.UseECSqlPropertyNames, usePrimaryConn })) {
590
+ const props = (0, ECSqlInstanceReshaper_1.reshapeInstanceRow)(row.toRow(), ecClass, this._iModel);
591
+ props.classFullName = props.className.replace(".", ":");
592
+ query.onProps(props);
593
+ }
594
+ }));
595
+ }
596
+ return criteria.map((criterion) => typeof criterion === "string" ? propsById.get(criterion) : propsByPair.get(pairKey(criterion)));
597
+ }
598
+ /** Get multiple Relationship instances of the same class using batched queries.
599
+ * This produces the same results as calling [[tryGetInstance]] for each entry in `criteria`, but executes at most two queries regardless of the number of entries.
600
+ * @param relClassFullName The full class name of the relationship in the form of "schema:class"
601
+ * @param criteria The relationships to look up. Each entry is either a relationship instanceId or the source and target Ids. Entries of both kinds may be mixed.
602
+ * @param options.usePrimaryConn If `true` (the default), the queries run on the primary connection so that unsaved changes are visible, matching [[tryGetInstance]].
603
+ * If `false`, they run on a concurrent query connection, which does not see unsaved changes.
604
+ * @returns An array with the same length and order as `criteria`. Each entry holds the relationship matching the corresponding criterion, or `undefined` if no such relationship was found.
605
+ * @see tryGetInstance
606
+ * @see queryInstancesProps
607
+ * @beta
608
+ */
609
+ async queryInstances(relClassFullName, criteria, options) {
610
+ const allProps = await this.queryInstancesProps(relClassFullName, criteria, options);
611
+ return allProps.map((props) => undefined !== props ? this._iModel.constructEntity(props) : undefined);
612
+ }
535
613
  }
536
614
  exports.Relationships = Relationships;
537
615
  //# sourceMappingURL=Relationship.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Relationship.js","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAAsI;AACtI,qCAAkC;AAClC,uCAAoC;AAEpC,gDAA6D;AAC7D,4EAAuF;AACvF,gEAA6D;AAgB7D;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IAC/B,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAa;IACrB,QAAQ,CAAa;IAErC,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAuB,CAAC;QAChD,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACa,KAAK,CAAC,WAAW;QAC/B,IAAI,IAAI,CAAC,SAAS,IAAI,qCAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5E,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,qCAAiB,CAAC,C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,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAyB,gBAAwB,EAAE,QAAsC;QAC5G,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,CAAoB,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAClG,OAAO,SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,CAAC;CACF;AAvHD,sCAuHC","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 Relationships\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { EntityReferenceSet, IModelError, QueryBinder, QueryRowFormat, RelationshipProps, SourceAndTarget } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\r\nimport { getRuntimeClass, reshapeInstanceRow } from \"./internal/ECSqlInstanceReshaper\";\r\nimport { RelationshipClass } from \"@itwin/ecschema-metadata\";\r\n\r\nexport type { SourceAndTarget, RelationshipProps } from \"@itwin/core-common\"; // for backwards compatibility\r\n\r\n/** Argument for relationship dependency callbacks.\r\n * @beta\r\n */\r\nexport interface OnDependencyArg {\r\n /** The iModel for the relationship affected by this method. */\r\n iModel: IModelDb;\r\n /** The ElementDrivesElement relationship instance affected by this method. */\r\n props: RelationshipProps;\r\n /** The transaction for indirect processing. */\r\n indirectEditTxn: EditTxn;\r\n}\r\n\r\n/** Base class for all link table ECRelationships\r\n * @public\r\n */\r\nexport class Relationship extends Entity {\r\n public static override get className(): string { return \"Relationship\"; }\r\n public readonly sourceId: Id64String;\r\n public readonly targetId: Id64String;\r\n\r\n protected constructor(props: RelationshipProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.sourceId = Id64.fromJSON(props.sourceId);\r\n this.targetId = Id64.fromJSON(props.targetId);\r\n }\r\n\r\n public override toJSON(): RelationshipProps {\r\n const val = super.toJSON() as RelationshipProps;\r\n val.sourceId = this.sourceId;\r\n val.targetId = this.targetId;\r\n return val;\r\n }\r\n\r\n /** Query metadata for this relationship class from the iModel's schema. Returns cached metadata if available.\r\n * @deprecated in 5.10.0 - will not be removed until after 2027-06-03. Obtain a `SchemaView` via `iModel.getSchemaView()` and call `view.findClass(relationship.classFullName)` to retrieve a `SchemaView.Class`. The returned type differs from `RelationshipClass` and offers a synchronous, snapshot-style API.\r\n */\r\n public override async getMetaData(): Promise<RelationshipClass> {\r\n if (this._metadata && RelationshipClass.isRelationshipClass(this._metadata)) {\r\n return this._metadata;\r\n }\r\n\r\n const relationship = await this.iModel.schemaContext.getSchemaItem(this.schemaItemKey, RelationshipClass);\r\n if (relationship !== undefined) {\r\n this._metadata = relationship;\r\n return this._metadata;\r\n } else {\r\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\r\n }\r\n }\r\n\r\n /**\r\n * 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.\r\n * This callback is invoked after the input element has been processed by upstream relationships.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\r\n * @beta\r\n */\r\n public static onRootChangedArg(arg: OnDependencyArg): void {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.onRootChanged(arg.props, arg.iModel);\r\n }\r\n\r\n /**\r\n * 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.\r\n * This callback is invoked after the input element has been processed by upstream relationships.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\r\n * @param _props The ElementDrivesElement relationship instance.\r\n * @param _iModel The iModel\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use onRootChangedArg instead.\r\n */\r\n public static onRootChanged(_props: RelationshipProps, _iModel: IModelDb): void { }\r\n\r\n /**\r\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\r\n * @beta\r\n */\r\n public static onDeletedDependencyArg(arg: OnDependencyArg): void {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.onDeletedDependency(arg.props, arg.iModel);\r\n }\r\n\r\n /**\r\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\r\n * @param _props The deleted ElementDrivesElement relationship instance.\r\n * @param _iModel The iModel\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use onDeletedDependencyArg instead.\r\n */\r\n public static onDeletedDependency(_props: RelationshipProps, _iModel: IModelDb): void { }\r\n\r\n /**\r\n * Insert this Relationship into the iModel using the supplied EditTxn.\r\n * @beta\r\n */\r\n public insert(txn: EditTxn): Id64String;\r\n /**\r\n * Insert this Relationship into the iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use Relationship.insert(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public insert(): Id64String;\r\n public insert(txn?: EditTxn): Id64String { return this.id = (txn ?? this.iModel[_implicitTxn]).insertRelationship(this.toJSON()); }\r\n\r\n /**\r\n * Update this Relationship in the iModel using the supplied EditTxn.\r\n * @beta\r\n */\r\n public update(txn: EditTxn): void;\r\n /**\r\n * Update this Relationship in the iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use Relationship.update(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public update(): void;\r\n public update(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).updateRelationship(this.toJSON()); }\r\n\r\n /**\r\n * Delete this Relationship from the iModel using the supplied EditTxn.\r\n * @beta\r\n */\r\n public delete(txn: EditTxn): void;\r\n /**\r\n * Delete this Relationship from the iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use Relationship.delete(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public delete(): void;\r\n public delete(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).deleteRelationship(this.toJSON()); }\r\n\r\n public static getInstance<T extends Relationship>(iModel: IModelDb, criteria: Id64String | SourceAndTarget): T { return iModel.relationships.getInstance(this.classFullName, criteria); }\r\n}\r\n\r\n/** A Relationship where one Element refers to another Element\r\n * @public\r\n */\r\nexport class ElementRefersToElements extends Relationship {\r\n public static override get className(): string { return \"ElementRefersToElements\"; }\r\n /** Create an instance of the Relationship.\r\n * @param iModel The iModel that will contain the relationship\r\n * @param sourceId The sourceId of the relationship, that is, the driver element\r\n * @param targetId The targetId of the relationship, that is, the driven element\r\n * @return an instance of the specified class.\r\n */\r\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): T {\r\n return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName }) as T;\r\n }\r\n\r\n /** Insert a new instance of the Relationship using an explicit transaction.\r\n * @param txn The EditTxn used to perform the insert.\r\n * @param sourceId The sourceId of the relationship, that is, the driver element\r\n * @param targetId The targetId of the relationship, that is, the driven element\r\n * @return The Id of the inserted Relationship.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, sourceId: Id64String, targetId: Id64String): Id64String;\r\n /** Insert a new instance of the Relationship.\r\n * @param iModel The iModel that will contain the relationship.\r\n * @param sourceId The sourceId of the relationship, that is, the driver element.\r\n * @param targetId The targetId of the relationship, that is, the driven element.\r\n * @return The Id of the inserted Relationship.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use ElementRefersToElements.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public static insert(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): Id64String;\r\n public static insert(txnOrIModel: EditTxn | IModelDb, sourceId: Id64String, targetId: Id64String): Id64String {\r\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\r\n const relationship = this.create(txn.iModel, sourceId, targetId);\r\n return txn.insertRelationship(relationship.toJSON());\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n referenceIds.addElement(this.sourceId);\r\n referenceIds.addElement(this.targetId);\r\n }\r\n}\r\n\r\n/** Relates a [[DrawingGraphic]] to the [[Element]] that it represents\r\n * @public\r\n */\r\nexport class DrawingGraphicRepresentsElement extends ElementRefersToElements {\r\n public static override get className(): string { return \"DrawingGraphicRepresentsElement\"; }\r\n}\r\n\r\n/** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents\r\n * @public\r\n */\r\nexport class GraphicalElement3dRepresentsElement extends ElementRefersToElements {\r\n public static override get className(): string { return \"GraphicalElement3dRepresentsElement\"; }\r\n}\r\n\r\n/** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.\r\n * Each relationship instance represents an external source processed by the synchronization configuration.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigProcessesSources extends ElementRefersToElements {\r\n public static override get className(): string { return \"SynchronizationConfigProcessesSources\"; }\r\n}\r\n\r\n/** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {\r\n public static override get className(): string { return \"SynchronizationConfigSpecifiesRootSources\"; }\r\n}\r\n\r\n/** Properties that are common to all types of link table ECRelationships\r\n * @public\r\n */\r\nexport interface ElementGroupsMembersProps extends RelationshipProps {\r\n memberPriority: number;\r\n}\r\n\r\n/** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.\r\n * @public\r\n */\r\nexport class ElementGroupsMembers extends ElementRefersToElements {\r\n public static override get className(): string { return \"ElementGroupsMembers\"; }\r\n public memberPriority: number;\r\n\r\n constructor(props: ElementGroupsMembersProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.memberPriority = props.memberPriority;\r\n }\r\n\r\n public static override create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, memberPriority: number = 0): T {\r\n const props: ElementGroupsMembersProps = { sourceId, targetId, memberPriority, classFullName: this.classFullName };\r\n return iModel.relationships.createInstance(props) as T;\r\n }\r\n}\r\n\r\n/** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.\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 DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {\r\n public static override get className(): string { return \"DefinitionGroupGroupsDefinitions\"; }\r\n}\r\n\r\n/** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.\r\n * Implies that properties of the group should be considered as properties of its members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.11\r\n * @public\r\n */\r\nexport class GroupImpartsToMembers extends ElementGroupsMembers {\r\n public static override get className(): string { return \"GroupImpartsToMembers\"; }\r\n}\r\n\r\n/** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {\r\n public static override get className(): string { return \"ExternalSourceGroupGroupsSources\"; }\r\n}\r\n\r\n/** Properties that are common to all types of ElementDrivesElements\r\n * @beta\r\n */\r\nexport interface ElementDrivesElementProps extends RelationshipProps {\r\n status: number;\r\n priority: number;\r\n}\r\n\r\n/** A Relationship indicating that one Element *drives* another Element.\r\n * An ElementDrivesElement relationship defines a one-way \"driving\" relationship from the source to the target.\r\n * 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.\r\n * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.\r\n *\r\n * # Defining dependencies\r\n * Create an ElementDrivesElement relationship to specify that the source element drives the target element.\r\n * For example, to specify that element e1 drives element e2, create a relationship between them like this:\r\n * ```ts\r\n * const ede = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * ede.insert();\r\n * ```\r\n * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.\r\n *\r\n * # Defining dependency graphs\r\n * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.\r\n * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.\r\n *\r\n * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:\r\n * ```ts\r\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\r\n * ede12.insert();\r\n * ede23.insert();\r\n * ```\r\n * Those two relationships create this graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n * Where the \"-->\" is meant to represent a driving relationship.\r\n *\r\n * The order in which you create the relationships does not matter.\r\n * The graph indicates that e3 depends on e2 and e2 depends on e1.\r\n *\r\n * An ElementDrivesElement relationship is between one source element and one target element.\r\n * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.\r\n * Thus, you can define many:many relationships.\r\n * For example:\r\n * ```ts\r\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);\r\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\r\n * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);\r\n * ede12.insert();\r\n * ede112.insert();\r\n * ede23.insert();\r\n * ede231.insert();\r\n * ```\r\n * Creates this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * e2 depends on both e1 and e11. e2 then drives e3 and e31.\r\n *\r\n * In an ElementDrivesElement dependency graph, the relationships are the \"edges\" and the Elements are the \"nodes\".\r\n * The following terms are used when referring to the elements (nodes) in a dependency graph:\r\n * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.\r\n * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.\r\n *\r\n * # Subgraph Processing\r\n * When changes are made, only the part of the overall graph that is affected will be processed. So, for example,\r\n * suppose we have this graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.\r\n *\r\n * If only e2 changes, then the subgraph to be processed is just:\r\n * ```\r\n * e2 --> e3\r\n * ```\r\n * If only e3 changes, then the subgraph consists of e3 by itself.\r\n *\r\n * Returning to the second example above, suppose we have this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * If e1 is changed, the affected subgraph is:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * If e2 is changed, the affected subgraph is:\r\n * ```\r\n * e3\r\n * /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * # Callbacks\r\n * Once the affected subgraph to process is found, it propagates changes through it by making callbacks.\r\n * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.\r\n *\r\n * ## ElementDrivesElement Callbacks\r\n * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):\r\n * * onRootChanged\r\n * * onDeletedDependency\r\n *\r\n * Note that these are static methods. Their default implementations do nothing.\r\n * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.\r\n * The subclass should then implement the callbacks that it would like to act on.\r\n *\r\n * A ElementDrivesElement subclass callback is expected to make changes to the output element only!\r\n *\r\n * ## Element Callbacks\r\n * The following callbacks are invoked on Element classes (nodes):\r\n * * Element.onBeforeOutputsHandled\r\n * * Element.onAllInputsHandled\r\n *\r\n * ## Order\r\n * Callbacks are invoked by BriefcaseDb.saveChanges.\r\n * They are invoked in dependency (topological) order: driving elements first, then driven elements.\r\n *\r\n * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,\r\n * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.\r\n * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be\r\n * invoked only once.\r\n *\r\n * For example, suppose we have a graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n *\r\n * Suppose that e1 is directly modified. No callbacks are made at that time.\r\n * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:\r\n * 1. Element.onBeforeOutputsHandled e1\r\n * 1. ElementDrivesElement.onRootChanged e1->e2\r\n * 1. Element.onAllInputsHandled e2\r\n * 1. ElementDrivesElement.onRootChanged e2->e3\r\n * 1. Element.onAllInputsHandled e3\r\n *\r\n * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.\r\n * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.\r\n *\r\n * Returning to the second example above, suppose we have this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * The callbacks are:\r\n * 1. Element.onBeforeOutputsHandled e1\r\n * 1. ElementDrivesElement.onRootChanged e1->e2\r\n * 1. Element.onAllInputsHandled e2\r\n * 1. ElementDrivesElement.onRootChanged e2->e3\r\n * 1. Element.onAllInputsHandled e3\r\n * 1. ElementDrivesElement.onRootChanged e2->e31\r\n * 1. Element.onAllInputsHandled e31\r\n *\r\n * (The ElementDrivesElement.)\r\n *\r\n * #Errors\r\n * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships\r\n * involved in a cycle will have their status set to 1, indicating a failure.\r\n *\r\n * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.\r\n * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing failure in that edge.\r\n *\r\n * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.\r\n *\r\n * @beta\r\n */\r\nexport class ElementDrivesElement extends Relationship {\r\n public static override get className(): string { return \"ElementDrivesElement\"; }\r\n /** Relationship status\r\n * * 0 indicates no errors. Set after a successful evaluation.\r\n * * 1 indicates that this driving relationship could not be evaluated. The callback itself can set this to indicate that it failed to process the input changes. Also, it is set if the relationship is part of a circular dependency.\r\n * * 0x80 The app or callback can set this to indicate to not propagate changes through this relationship.\r\n */\r\n public status: number;\r\n /** Affects the order in which relationships are processed in the case where two relationships have the same output. */\r\n public priority: number;\r\n\r\n protected constructor(props: ElementDrivesElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.status = props.status;\r\n this.priority = props.priority;\r\n }\r\n\r\n public static create<T extends ElementDrivesElement>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, priority: number = 0): T {\r\n const props: ElementDrivesElementProps = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };\r\n return iModel.relationships.createInstance(props) as T;\r\n }\r\n\r\n public override toJSON(): ElementDrivesElementProps {\r\n const props = super.toJSON() as ElementDrivesElementProps;\r\n props.status = this.status;\r\n props.priority = this.priority;\r\n return props;\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n referenceIds.addElement(this.sourceId);\r\n referenceIds.addElement(this.targetId);\r\n }\r\n}\r\n\r\n/** The third (and last) possible link-table relationship base class in an iModel.\r\n * Has no external use, but is included for completeness of the [Entity.collectReferenceIds]($backend)\r\n * implementations for link-table relationships. Generating the types of the source and target automatically would require\r\n * coupling this package with ecschema-metadata which we do not want to do.\r\n * @internal\r\n */\r\nexport class ModelSelectorRefersToModels extends Relationship {\r\n public static override get className(): string { return \"ModelSelectorRefersToModels\"; }\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n referenceIds.addElement(this.sourceId);\r\n referenceIds.addModel(this.targetId);\r\n }\r\n}\r\n\r\n/** Manages [[Relationship]]s.\r\n * @public\r\n */\r\nexport class Relationships {\r\n private _iModel: IModelDb;\r\n\r\n /** @internal */\r\n public constructor(iModel: IModelDb) { this._iModel = iModel; }\r\n\r\n /** Create a new instance of a Relationship.\r\n * @param props The properties of the new Relationship.\r\n * @throws [[IModelError]] if there is a problem creating the Relationship.\r\n */\r\n public createInstance(props: RelationshipProps): Relationship { return this._iModel.constructEntity<Relationship>(props); }\r\n\r\n /** Check classFullName to ensure it is a link table relationship class. */\r\n private checkRelationshipClass(classFullName: string) {\r\n if (!this._iModel[_nativeDb].isLinkTableRelationship(classFullName.replace(\".\", \":\"))) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\r\n }\r\n }\r\n\r\n /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.\r\n * @param props The properties of the new relationship.\r\n * @returns The Id of the newly inserted relationship.\r\n * @note The id property of the props object is set as a side effect of this function.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.insertRelationship instead.\r\n */\r\n public insertInstance(props: RelationshipProps): Id64String {\r\n return this._iModel[_implicitTxn].insertRelationship(props);\r\n }\r\n\r\n /** Update the properties of an existing relationship instance in the iModel.\r\n * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.updateRelationship instead.\r\n */\r\n public updateInstance(props: RelationshipProps): void {\r\n this._iModel[_implicitTxn].updateRelationship(props);\r\n }\r\n\r\n /** Delete an Relationship instance from this iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.deleteRelationship instead.\r\n */\r\n public deleteInstance(props: RelationshipProps): void {\r\n this._iModel[_implicitTxn].deleteRelationship(props);\r\n }\r\n\r\n /** Delete multiple Relationship instances from this iModel.\r\n * @param props The properties of the relationship instances to delete.\r\n * @remarks This method handles bulk deletion of relationships and supports mixed collections containing instances from different relationship classes.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.deleteRelationships instead.\r\n */\r\n public deleteInstances(props: ReadonlyArray<RelationshipProps>): void {\r\n this._iModel[_implicitTxn].deleteRelationships(props);\r\n }\r\n\r\n /** Get the props of a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\r\n * @see tryGetInstanceProps\r\n */\r\n public getInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T {\r\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\r\n if (undefined === relationshipProps) {\r\n throw new IModelError(IModelStatus.NotFound, \"Relationship not found\");\r\n }\r\n return relationshipProps;\r\n }\r\n\r\n /** Get the props of a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @returns The RelationshipProps or `undefined` if the relationship is not found.\r\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\r\n * @see getInstanceProps\r\n */\r\n public tryGetInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\r\n // `SELECT *` targets a caller-supplied relationship class, so its shape can't be decomposed ahead of\r\n // time. Query using the non-deprecated UseECSqlPropertyNames format and reshape the row into the\r\n // legacy UseJsPropertyNames shape using ECSchema metadata (see ECSqlInstanceReshaper for why a naive,\r\n // non-schema-aware rename isn't safe here).\r\n const ecClass = getRuntimeClass(this._iModel, relClassFullName);\r\n let props: T | undefined;\r\n if (typeof criteria === \"string\") {\r\n props = this._iModel.withQueryReader(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (reader): T | undefined => {\r\n return reader.step() ? reshapeInstanceRow(reader.current.toRow(), ecClass, this._iModel) as T : undefined;\r\n }, new QueryBinder().bindId(1, criteria), { rowFormat: QueryRowFormat.UseECSqlPropertyNames });\r\n } else {\r\n props = this._iModel.withQueryReader(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (reader): T | undefined => {\r\n return reader.step() ? reshapeInstanceRow(reader.current.toRow(), ecClass, this._iModel) as T : undefined;\r\n }, new QueryBinder().bindId(1, criteria.sourceId).bindId(2, criteria.targetId), { rowFormat: QueryRowFormat.UseECSqlPropertyNames });\r\n }\r\n if (undefined !== props) {\r\n // convert `className` (from `SELECT *`'s ECClassId) into `classFullName`, as required by `EntityProps`\r\n const reshapedProps = props as T & { className?: string };\r\n reshapedProps.classFullName = (reshapedProps.className as string).replace(\".\", \":\");\r\n }\r\n return props;\r\n }\r\n\r\n /** Get a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\r\n * @see tryGetInstance\r\n */\r\n public getInstance<T extends Relationship>(relClassSqlName: string, criteria: Id64String | SourceAndTarget): T {\r\n return this._iModel.constructEntity<T>(this.getInstanceProps(relClassSqlName, criteria));\r\n }\r\n\r\n /** Get a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @returns The relationship or `undefined` if the relationship is not found.\r\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\r\n * @see getInstance\r\n */\r\n public tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\r\n const relationshipProps = this.tryGetInstanceProps<RelationshipProps>(relClassFullName, criteria);\r\n return undefined !== relationshipProps ? this._iModel.constructEntity<T>(relationshipProps) : undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Relationship.js","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAAsI;AACtI,qCAAkC;AAClC,uCAAoC;AAEpC,gDAA6D;AAC7D,4EAAuF;AACvF,gEAA6D;AAgB7D;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IAC/B,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAa;IACrB,QAAQ,CAAa;IAErC,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAuB,CAAC;QAChD,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACa,KAAK,CAAC,WAAW;QAC/B,IAAI,IAAI,CAAC,SAAS,IAAI,qCAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5E,OAAO,IAAI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K,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3G,CAAC;CACF;AA3MD,sCA2MC","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 Relationships\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { EntityReferenceSet, IModelError, QueryBinder, QueryRowFormat, RelationshipProps, SourceAndTarget } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\r\nimport { getRuntimeClass, reshapeInstanceRow } from \"./internal/ECSqlInstanceReshaper\";\r\nimport { RelationshipClass } from \"@itwin/ecschema-metadata\";\r\n\r\nexport type { SourceAndTarget, RelationshipProps } from \"@itwin/core-common\"; // for backwards compatibility\r\n\r\n/** Argument for relationship dependency callbacks.\r\n * @beta\r\n */\r\nexport interface OnDependencyArg {\r\n /** The iModel for the relationship affected by this method. */\r\n iModel: IModelDb;\r\n /** The ElementDrivesElement relationship instance affected by this method. */\r\n props: RelationshipProps;\r\n /** The transaction for indirect processing. */\r\n indirectEditTxn: EditTxn;\r\n}\r\n\r\n/** Base class for all link table ECRelationships\r\n * @public\r\n */\r\nexport class Relationship extends Entity {\r\n public static override get className(): string { return \"Relationship\"; }\r\n public readonly sourceId: Id64String;\r\n public readonly targetId: Id64String;\r\n\r\n protected constructor(props: RelationshipProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.sourceId = Id64.fromJSON(props.sourceId);\r\n this.targetId = Id64.fromJSON(props.targetId);\r\n }\r\n\r\n public override toJSON(): RelationshipProps {\r\n const val = super.toJSON() as RelationshipProps;\r\n val.sourceId = this.sourceId;\r\n val.targetId = this.targetId;\r\n return val;\r\n }\r\n\r\n /** Query metadata for this relationship class from the iModel's schema. Returns cached metadata if available.\r\n * @deprecated in 5.10.0 - will not be removed until after 2027-06-03. Obtain a `SchemaView` via `iModel.getSchemaView()` and call `view.findClass(relationship.classFullName)` to retrieve a `SchemaView.Class`. The returned type differs from `RelationshipClass` and offers a synchronous, snapshot-style API.\r\n */\r\n public override async getMetaData(): Promise<RelationshipClass> {\r\n if (this._metadata && RelationshipClass.isRelationshipClass(this._metadata)) {\r\n return this._metadata;\r\n }\r\n\r\n const relationship = await this.iModel.schemaContext.getSchemaItem(this.schemaItemKey, RelationshipClass);\r\n if (relationship !== undefined) {\r\n this._metadata = relationship;\r\n return this._metadata;\r\n } else {\r\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\r\n }\r\n }\r\n\r\n /**\r\n * 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.\r\n * This callback is invoked after the input element has been processed by upstream relationships.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\r\n * @beta\r\n */\r\n public static onRootChangedArg(arg: OnDependencyArg): void {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.onRootChanged(arg.props, arg.iModel);\r\n }\r\n\r\n /**\r\n * 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.\r\n * This callback is invoked after the input element has been processed by upstream relationships.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\r\n * @param _props The ElementDrivesElement relationship instance.\r\n * @param _iModel The iModel\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use onRootChangedArg instead.\r\n */\r\n public static onRootChanged(_props: RelationshipProps, _iModel: IModelDb): void { }\r\n\r\n /**\r\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\r\n * @beta\r\n */\r\n public static onDeletedDependencyArg(arg: OnDependencyArg): void {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.onDeletedDependency(arg.props, arg.iModel);\r\n }\r\n\r\n /**\r\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\r\n * @param _props The deleted ElementDrivesElement relationship instance.\r\n * @param _iModel The iModel\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use onDeletedDependencyArg instead.\r\n */\r\n public static onDeletedDependency(_props: RelationshipProps, _iModel: IModelDb): void { }\r\n\r\n /**\r\n * Insert this Relationship into the iModel using the supplied EditTxn.\r\n * @beta\r\n */\r\n public insert(txn: EditTxn): Id64String;\r\n /**\r\n * Insert this Relationship into the iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use Relationship.insert(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public insert(): Id64String;\r\n public insert(txn?: EditTxn): Id64String { return this.id = (txn ?? this.iModel[_implicitTxn]).insertRelationship(this.toJSON()); }\r\n\r\n /**\r\n * Update this Relationship in the iModel using the supplied EditTxn.\r\n * @beta\r\n */\r\n public update(txn: EditTxn): void;\r\n /**\r\n * Update this Relationship in the iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use Relationship.update(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public update(): void;\r\n public update(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).updateRelationship(this.toJSON()); }\r\n\r\n /**\r\n * Delete this Relationship from the iModel using the supplied EditTxn.\r\n * @beta\r\n */\r\n public delete(txn: EditTxn): void;\r\n /**\r\n * Delete this Relationship from the iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use Relationship.delete(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public delete(): void;\r\n public delete(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).deleteRelationship(this.toJSON()); }\r\n\r\n public static getInstance<T extends Relationship>(iModel: IModelDb, criteria: Id64String | SourceAndTarget): T { return iModel.relationships.getInstance(this.classFullName, criteria); }\r\n}\r\n\r\n/** A Relationship where one Element refers to another Element\r\n * @public\r\n */\r\nexport class ElementRefersToElements extends Relationship {\r\n public static override get className(): string { return \"ElementRefersToElements\"; }\r\n /** Create an instance of the Relationship.\r\n * @param iModel The iModel that will contain the relationship\r\n * @param sourceId The sourceId of the relationship, that is, the driver element\r\n * @param targetId The targetId of the relationship, that is, the driven element\r\n * @return an instance of the specified class.\r\n */\r\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): T {\r\n return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName }) as T;\r\n }\r\n\r\n /** Insert a new instance of the Relationship using an explicit transaction.\r\n * @param txn The EditTxn used to perform the insert.\r\n * @param sourceId The sourceId of the relationship, that is, the driver element\r\n * @param targetId The targetId of the relationship, that is, the driven element\r\n * @return The Id of the inserted Relationship.\r\n * @beta\r\n */\r\n public static insert(txn: EditTxn, sourceId: Id64String, targetId: Id64String): Id64String;\r\n /** Insert a new instance of the Relationship.\r\n * @param iModel The iModel that will contain the relationship.\r\n * @param sourceId The sourceId of the relationship, that is, the driver element.\r\n * @param targetId The targetId of the relationship, that is, the driven element.\r\n * @return The Id of the inserted Relationship.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use ElementRefersToElements.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\r\n */\r\n public static insert(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): Id64String;\r\n public static insert(txnOrIModel: EditTxn | IModelDb, sourceId: Id64String, targetId: Id64String): Id64String {\r\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\r\n const relationship = this.create(txn.iModel, sourceId, targetId);\r\n return txn.insertRelationship(relationship.toJSON());\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n referenceIds.addElement(this.sourceId);\r\n referenceIds.addElement(this.targetId);\r\n }\r\n}\r\n\r\n/** Relates a [[DrawingGraphic]] to the [[Element]] that it represents\r\n * @public\r\n */\r\nexport class DrawingGraphicRepresentsElement extends ElementRefersToElements {\r\n public static override get className(): string { return \"DrawingGraphicRepresentsElement\"; }\r\n}\r\n\r\n/** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents\r\n * @public\r\n */\r\nexport class GraphicalElement3dRepresentsElement extends ElementRefersToElements {\r\n public static override get className(): string { return \"GraphicalElement3dRepresentsElement\"; }\r\n}\r\n\r\n/** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.\r\n * Each relationship instance represents an external source processed by the synchronization configuration.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigProcessesSources extends ElementRefersToElements {\r\n public static override get className(): string { return \"SynchronizationConfigProcessesSources\"; }\r\n}\r\n\r\n/** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {\r\n public static override get className(): string { return \"SynchronizationConfigSpecifiesRootSources\"; }\r\n}\r\n\r\n/** Properties that are common to all types of link table ECRelationships\r\n * @public\r\n */\r\nexport interface ElementGroupsMembersProps extends RelationshipProps {\r\n memberPriority: number;\r\n}\r\n\r\n/** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.\r\n * @public\r\n */\r\nexport class ElementGroupsMembers extends ElementRefersToElements {\r\n public static override get className(): string { return \"ElementGroupsMembers\"; }\r\n public memberPriority: number;\r\n\r\n constructor(props: ElementGroupsMembersProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.memberPriority = props.memberPriority;\r\n }\r\n\r\n public static override create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, memberPriority: number = 0): T {\r\n const props: ElementGroupsMembersProps = { sourceId, targetId, memberPriority, classFullName: this.classFullName };\r\n return iModel.relationships.createInstance(props) as T;\r\n }\r\n}\r\n\r\n/** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.\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 DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {\r\n public static override get className(): string { return \"DefinitionGroupGroupsDefinitions\"; }\r\n}\r\n\r\n/** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.\r\n * Implies that properties of the group should be considered as properties of its members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.11\r\n * @public\r\n */\r\nexport class GroupImpartsToMembers extends ElementGroupsMembers {\r\n public static override get className(): string { return \"GroupImpartsToMembers\"; }\r\n}\r\n\r\n/** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {\r\n public static override get className(): string { return \"ExternalSourceGroupGroupsSources\"; }\r\n}\r\n\r\n/** Properties that are common to all types of ElementDrivesElements\r\n * @beta\r\n */\r\nexport interface ElementDrivesElementProps extends RelationshipProps {\r\n status: number;\r\n priority: number;\r\n}\r\n\r\n/** A Relationship indicating that one Element *drives* another Element.\r\n * An ElementDrivesElement relationship defines a one-way \"driving\" relationship from the source to the target.\r\n * 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.\r\n * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.\r\n *\r\n * # Defining dependencies\r\n * Create an ElementDrivesElement relationship to specify that the source element drives the target element.\r\n * For example, to specify that element e1 drives element e2, create a relationship between them like this:\r\n * ```ts\r\n * const ede = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * ede.insert();\r\n * ```\r\n * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.\r\n *\r\n * # Defining dependency graphs\r\n * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.\r\n * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.\r\n *\r\n * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:\r\n * ```ts\r\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\r\n * ede12.insert();\r\n * ede23.insert();\r\n * ```\r\n * Those two relationships create this graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n * Where the \"-->\" is meant to represent a driving relationship.\r\n *\r\n * The order in which you create the relationships does not matter.\r\n * The graph indicates that e3 depends on e2 and e2 depends on e1.\r\n *\r\n * An ElementDrivesElement relationship is between one source element and one target element.\r\n * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.\r\n * Thus, you can define many:many relationships.\r\n * For example:\r\n * ```ts\r\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);\r\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\r\n * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);\r\n * ede12.insert();\r\n * ede112.insert();\r\n * ede23.insert();\r\n * ede231.insert();\r\n * ```\r\n * Creates this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * e2 depends on both e1 and e11. e2 then drives e3 and e31.\r\n *\r\n * In an ElementDrivesElement dependency graph, the relationships are the \"edges\" and the Elements are the \"nodes\".\r\n * The following terms are used when referring to the elements (nodes) in a dependency graph:\r\n * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.\r\n * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.\r\n *\r\n * # Subgraph Processing\r\n * When changes are made, only the part of the overall graph that is affected will be processed. So, for example,\r\n * suppose we have this graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.\r\n *\r\n * If only e2 changes, then the subgraph to be processed is just:\r\n * ```\r\n * e2 --> e3\r\n * ```\r\n * If only e3 changes, then the subgraph consists of e3 by itself.\r\n *\r\n * Returning to the second example above, suppose we have this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * If e1 is changed, the affected subgraph is:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * If e2 is changed, the affected subgraph is:\r\n * ```\r\n * e3\r\n * /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * # Callbacks\r\n * Once the affected subgraph to process is found, it propagates changes through it by making callbacks.\r\n * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.\r\n *\r\n * ## ElementDrivesElement Callbacks\r\n * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):\r\n * * onRootChanged\r\n * * onDeletedDependency\r\n *\r\n * Note that these are static methods. Their default implementations do nothing.\r\n * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.\r\n * The subclass should then implement the callbacks that it would like to act on.\r\n *\r\n * A ElementDrivesElement subclass callback is expected to make changes to the output element only!\r\n *\r\n * ## Element Callbacks\r\n * The following callbacks are invoked on Element classes (nodes):\r\n * * Element.onBeforeOutputsHandled\r\n * * Element.onAllInputsHandled\r\n *\r\n * ## Order\r\n * Callbacks are invoked by BriefcaseDb.saveChanges.\r\n * They are invoked in dependency (topological) order: driving elements first, then driven elements.\r\n *\r\n * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,\r\n * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.\r\n * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be\r\n * invoked only once.\r\n *\r\n * For example, suppose we have a graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n *\r\n * Suppose that e1 is directly modified. No callbacks are made at that time.\r\n * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:\r\n * 1. Element.onBeforeOutputsHandled e1\r\n * 1. ElementDrivesElement.onRootChanged e1->e2\r\n * 1. Element.onAllInputsHandled e2\r\n * 1. ElementDrivesElement.onRootChanged e2->e3\r\n * 1. Element.onAllInputsHandled e3\r\n *\r\n * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.\r\n * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.\r\n *\r\n * Returning to the second example above, suppose we have this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * The callbacks are:\r\n * 1. Element.onBeforeOutputsHandled e1\r\n * 1. ElementDrivesElement.onRootChanged e1->e2\r\n * 1. Element.onAllInputsHandled e2\r\n * 1. ElementDrivesElement.onRootChanged e2->e3\r\n * 1. Element.onAllInputsHandled e3\r\n * 1. ElementDrivesElement.onRootChanged e2->e31\r\n * 1. Element.onAllInputsHandled e31\r\n *\r\n * (The ElementDrivesElement.)\r\n *\r\n * #Errors\r\n * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships\r\n * involved in a cycle will have their status set to 1, indicating a failure.\r\n *\r\n * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.\r\n * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing failure in that edge.\r\n *\r\n * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.\r\n *\r\n * @beta\r\n */\r\nexport class ElementDrivesElement extends Relationship {\r\n public static override get className(): string { return \"ElementDrivesElement\"; }\r\n /** Relationship status\r\n * * 0 indicates no errors. Set after a successful evaluation.\r\n * * 1 indicates that this driving relationship could not be evaluated. The callback itself can set this to indicate that it failed to process the input changes. Also, it is set if the relationship is part of a circular dependency.\r\n * * 0x80 The app or callback can set this to indicate to not propagate changes through this relationship.\r\n */\r\n public status: number;\r\n /** Affects the order in which relationships are processed in the case where two relationships have the same output. */\r\n public priority: number;\r\n\r\n protected constructor(props: ElementDrivesElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.status = props.status;\r\n this.priority = props.priority;\r\n }\r\n\r\n public static create<T extends ElementDrivesElement>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, priority: number = 0): T {\r\n const props: ElementDrivesElementProps = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };\r\n return iModel.relationships.createInstance(props) as T;\r\n }\r\n\r\n public override toJSON(): ElementDrivesElementProps {\r\n const props = super.toJSON() as ElementDrivesElementProps;\r\n props.status = this.status;\r\n props.priority = this.priority;\r\n return props;\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n referenceIds.addElement(this.sourceId);\r\n referenceIds.addElement(this.targetId);\r\n }\r\n}\r\n\r\n/** The third (and last) possible link-table relationship base class in an iModel.\r\n * Has no external use, but is included for completeness of the [Entity.collectReferenceIds]($backend)\r\n * implementations for link-table relationships. Generating the types of the source and target automatically would require\r\n * coupling this package with ecschema-metadata which we do not want to do.\r\n * @internal\r\n */\r\nexport class ModelSelectorRefersToModels extends Relationship {\r\n public static override get className(): string { return \"ModelSelectorRefersToModels\"; }\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n referenceIds.addElement(this.sourceId);\r\n referenceIds.addModel(this.targetId);\r\n }\r\n}\r\n\r\n/** Manages [[Relationship]]s.\r\n * @public\r\n */\r\nexport class Relationships {\r\n private _iModel: IModelDb;\r\n\r\n /** @internal */\r\n public constructor(iModel: IModelDb) { this._iModel = iModel; }\r\n\r\n /** Create a new instance of a Relationship.\r\n * @param props The properties of the new Relationship.\r\n * @throws [[IModelError]] if there is a problem creating the Relationship.\r\n */\r\n public createInstance(props: RelationshipProps): Relationship { return this._iModel.constructEntity<Relationship>(props); }\r\n\r\n /** Check classFullName to ensure it is a link table relationship class. */\r\n private checkRelationshipClass(classFullName: string) {\r\n if (!this._iModel[_nativeDb].isLinkTableRelationship(classFullName.replace(\".\", \":\"))) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\r\n }\r\n }\r\n\r\n /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.\r\n * @param props The properties of the new relationship.\r\n * @returns The Id of the newly inserted relationship.\r\n * @note The id property of the props object is set as a side effect of this function.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.insertRelationship instead.\r\n */\r\n public insertInstance(props: RelationshipProps): Id64String {\r\n return this._iModel[_implicitTxn].insertRelationship(props);\r\n }\r\n\r\n /** Update the properties of an existing relationship instance in the iModel.\r\n * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.updateRelationship instead.\r\n */\r\n public updateInstance(props: RelationshipProps): void {\r\n this._iModel[_implicitTxn].updateRelationship(props);\r\n }\r\n\r\n /** Delete an Relationship instance from this iModel.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.deleteRelationship instead.\r\n */\r\n public deleteInstance(props: RelationshipProps): void {\r\n this._iModel[_implicitTxn].deleteRelationship(props);\r\n }\r\n\r\n /** Delete multiple Relationship instances from this iModel.\r\n * @param props The properties of the relationship instances to delete.\r\n * @remarks This method handles bulk deletion of relationships and supports mixed collections containing instances from different relationship classes.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use EditTxn.deleteRelationships instead.\r\n */\r\n public deleteInstances(props: ReadonlyArray<RelationshipProps>): void {\r\n this._iModel[_implicitTxn].deleteRelationships(props);\r\n }\r\n\r\n /** Get the props of a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\r\n * @see tryGetInstanceProps\r\n */\r\n public getInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T {\r\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\r\n if (undefined === relationshipProps) {\r\n throw new IModelError(IModelStatus.NotFound, \"Relationship not found\");\r\n }\r\n return relationshipProps;\r\n }\r\n\r\n /** Get the props of a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @returns The RelationshipProps or `undefined` if the relationship is not found.\r\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\r\n * @see getInstanceProps\r\n */\r\n public tryGetInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\r\n // `SELECT *` targets a caller-supplied relationship class, so its shape can't be decomposed ahead of\r\n // time. Query using the non-deprecated UseECSqlPropertyNames format and reshape the row into the\r\n // legacy UseJsPropertyNames shape using ECSchema metadata (see ECSqlInstanceReshaper for why a naive,\r\n // non-schema-aware rename isn't safe here).\r\n const ecClass = getRuntimeClass(this._iModel, relClassFullName);\r\n let props: T | undefined;\r\n if (typeof criteria === \"string\") {\r\n props = this._iModel.withQueryReader(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (reader): T | undefined => {\r\n return reader.step() ? reshapeInstanceRow(reader.current.toRow(), ecClass, this._iModel) as T : undefined;\r\n }, new QueryBinder().bindId(1, criteria), { rowFormat: QueryRowFormat.UseECSqlPropertyNames });\r\n } else {\r\n props = this._iModel.withQueryReader(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (reader): T | undefined => {\r\n return reader.step() ? reshapeInstanceRow(reader.current.toRow(), ecClass, this._iModel) as T : undefined;\r\n }, new QueryBinder().bindId(1, criteria.sourceId).bindId(2, criteria.targetId), { rowFormat: QueryRowFormat.UseECSqlPropertyNames });\r\n }\r\n if (undefined !== props) {\r\n // convert `className` (from `SELECT *`'s ECClassId) into `classFullName`, as required by `EntityProps`\r\n const reshapedProps = props as T & { className?: string };\r\n reshapedProps.classFullName = (reshapedProps.className as string).replace(\".\", \":\");\r\n }\r\n return props;\r\n }\r\n\r\n /** Get a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\r\n * @see tryGetInstance\r\n */\r\n public getInstance<T extends Relationship>(relClassSqlName: string, criteria: Id64String | SourceAndTarget): T {\r\n return this._iModel.constructEntity<T>(this.getInstanceProps(relClassSqlName, criteria));\r\n }\r\n\r\n /** Get a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @returns The relationship or `undefined` if the relationship is not found.\r\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\r\n * @see getInstance\r\n */\r\n public tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\r\n const relationshipProps = this.tryGetInstanceProps<RelationshipProps>(relClassFullName, criteria);\r\n return undefined !== relationshipProps ? this._iModel.constructEntity<T>(relationshipProps) : undefined;\r\n }\r\n\r\n /** Get the props of multiple Relationship instances of the same class using batched queries.\r\n * This produces the same results as calling [[tryGetInstanceProps]] for each entry in `criteria`, but executes at most two queries regardless of the number of entries.\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria The relationships to look up. Each entry is either a relationship instanceId or the source and target Ids. Entries of both kinds may be mixed.\r\n * @param options.usePrimaryConn If `true` (the default), the queries run on the primary connection so that unsaved changes are visible, matching [[tryGetInstanceProps]].\r\n * If `false`, they run on a concurrent query connection, which does not see unsaved changes.\r\n * @returns An array with the same length and order as `criteria`. Each entry holds the RelationshipProps matching the corresponding criterion, or `undefined` if no such relationship was found.\r\n * @see tryGetInstanceProps\r\n * @see queryInstances\r\n * @beta\r\n */\r\n public async queryInstancesProps<T extends RelationshipProps>(relClassFullName: string, criteria: ReadonlyArray<Id64String | SourceAndTarget>, options?: { usePrimaryConn?: boolean }): Promise<Array<T | undefined>> {\r\n const pairKey = (pair: SourceAndTarget) => `${pair.sourceId}|${pair.targetId}`;\r\n\r\n const ids = new Set<Id64String>();\r\n const pairs = new Map<string, [Id64String, Id64String]>();\r\n for (const criterion of criteria) {\r\n if (typeof criterion === \"string\") {\r\n if (Id64.isValidId64(criterion))\r\n ids.add(criterion);\r\n } else if (Id64.isValidId64(criterion.sourceId) && Id64.isValidId64(criterion.targetId)) {\r\n pairs.set(pairKey(criterion), [criterion.sourceId, criterion.targetId]);\r\n }\r\n }\r\n\r\n // Each query joins the requested values (as an IdSet or json_each virtual table) to the relationship class. CROSS JOIN makes SQLite iterate\r\n // the requested values and look up each one by index, so only the requested relationships are read, regardless of the size of the class.\r\n const propsById = new Map<Id64String, T>();\r\n const propsByPair = new Map<string, T>();\r\n const queries: Array<{ ecsql: string, params: QueryBinder, onProps: (props: T) => void }> = [];\r\n if (ids.size > 0) {\r\n queries.push({\r\n ecsql: `SELECT r.* FROM IdSet(?) p CROSS JOIN ${relClassFullName} r WHERE r.ECInstanceId = p.id`,\r\n params: new QueryBinder().bindIdSet(1, ids),\r\n onProps: (props) => propsById.set(props.id as Id64String, props),\r\n });\r\n }\r\n\r\n if (pairs.size > 0) {\r\n // json_each yields the ids as hex strings; HexToId converts them to the integer ids stored in the table.\r\n queries.push({\r\n ecsql: `SELECT r.* FROM json1.json_each(?) p CROSS JOIN ${relClassFullName} r WHERE r.SourceECInstanceId = HexToId(json_extract(p.[value], '$[0]')) AND r.TargetECInstanceId = HexToId(json_extract(p.[value], '$[1]'))`,\r\n params: new QueryBinder().bindString(1, JSON.stringify([...pairs.values()])),\r\n onProps: (props) => {\r\n // A polymorphic query may find more than one relationship for the same pair; keep the first, like tryGetInstanceProps.\r\n const key = pairKey(props);\r\n if (!propsByPair.has(key))\r\n propsByPair.set(key, props);\r\n },\r\n });\r\n }\r\n\r\n if (queries.length > 0) {\r\n // Convert rows the same way as tryGetInstanceProps, so that both produce identical props.\r\n const ecClass = getRuntimeClass(this._iModel, relClassFullName);\r\n const usePrimaryConn = options?.usePrimaryConn ?? true;\r\n await Promise.all(queries.map(async (query) => {\r\n for await (const row of this._iModel.createQueryReader(query.ecsql, query.params, { rowFormat: QueryRowFormat.UseECSqlPropertyNames, usePrimaryConn })) {\r\n const props = reshapeInstanceRow(row.toRow(), ecClass, this._iModel) as T & { className: string };\r\n props.classFullName = props.className.replace(\".\", \":\");\r\n query.onProps(props);\r\n }\r\n }));\r\n }\r\n\r\n return criteria.map((criterion) => typeof criterion === \"string\" ? propsById.get(criterion) : propsByPair.get(pairKey(criterion)));\r\n }\r\n\r\n /** Get multiple Relationship instances of the same class using batched queries.\r\n * This produces the same results as calling [[tryGetInstance]] for each entry in `criteria`, but executes at most two queries regardless of the number of entries.\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria The relationships to look up. Each entry is either a relationship instanceId or the source and target Ids. Entries of both kinds may be mixed.\r\n * @param options.usePrimaryConn If `true` (the default), the queries run on the primary connection so that unsaved changes are visible, matching [[tryGetInstance]].\r\n * If `false`, they run on a concurrent query connection, which does not see unsaved changes.\r\n * @returns An array with the same length and order as `criteria`. Each entry holds the relationship matching the corresponding criterion, or `undefined` if no such relationship was found.\r\n * @see tryGetInstance\r\n * @see queryInstancesProps\r\n * @beta\r\n */\r\n public async queryInstances<T extends Relationship>(relClassFullName: string, criteria: ReadonlyArray<Id64String | SourceAndTarget>, options?: { usePrimaryConn?: boolean }): Promise<Array<T | undefined>> {\r\n const allProps = await this.queryInstancesProps<RelationshipProps>(relClassFullName, criteria, options);\r\n return allProps.map((props) => undefined !== props ? this._iModel.constructEntity<T>(props) : undefined);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaSync.d.ts","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAiD,UAAU,EAAQ,UAAU,EAAwB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClJ,OAAO,EAAoB,IAAI,EAA2D,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEpI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5D,gBAAgB;AAChB,yBAAiB,UAAU,CAAC;IAmB1B,0EAA0E;IAC1E,UAAiB,0BAA0B;QACzC,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;QACpC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;QAC/B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;KAC/B;IAED,oFAAoF;IACpF,UAAiB,eAAgB,SAAQ,0BAA0B;QACjE,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;KAChC;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M,CAAC;KACtB;IAED;;;;;;;;;OASG;IACH,SAAsB,eAAe,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CASnG;IAED,wDAAwD;IACxD,UAAiB,uBAAuB;QACtC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;QAC3B,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;KACzD;IAED,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,WAAW,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC;oBACzE,KAAK,EAAE,WAAW,CAAC,oBAAoB;QAInD,MAAM;QAGb;;;;SAIC;eACmB,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,cAAc;QAIlE,uFAAuF;eACnE,kBAAkB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC;KAK3G;CACF"}
@@ -376,6 +376,7 @@ var SchemaSync;
376
376
  const status = briefcase[Symbols_1._nativeDb].cancelTo(txnBeforeInit, true);
377
377
  if (status !== core_bentley_1.IModelStatus.Success)
378
378
  core_bentley_1.Logger.logError("SchemaSync", `Failed to roll back schema sync initialization after the container upload failed: ${core_bentley_1.IModelStatus[status] ?? status}`);
379
+ briefcase.clearCaches();
379
380
  }
380
381
  throw error;
381
382
  }