@itwin/core-backend 4.0.0-dev.52 → 4.0.0-dev.55

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 (223) hide show
  1. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  2. package/lib/cjs/AliCloudStorageService.js +71 -71
  3. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  5. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendLoggerCategory.d.ts +90 -91
  8. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  9. package/lib/cjs/BackendLoggerCategory.js +98 -99
  10. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  12. package/lib/cjs/BisCoreSchema.js +60 -60
  13. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  14. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  15. package/lib/cjs/BriefcaseManager.js +408 -408
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +153 -153
  18. package/lib/cjs/Category.js +243 -243
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  21. package/lib/cjs/ChangeSummaryManager.js +444 -444
  22. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  23. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  24. package/lib/cjs/ChangedElementsDb.js +165 -165
  25. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  26. package/lib/cjs/ChangedElementsManager.js +88 -88
  27. package/lib/cjs/ChannelControl.d.ts +69 -69
  28. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  29. package/lib/cjs/ChannelControl.js +88 -88
  30. package/lib/cjs/ChannelControl.js.map +1 -1
  31. package/lib/cjs/CheckpointManager.d.ts +121 -121
  32. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  33. package/lib/cjs/CheckpointManager.js +351 -351
  34. package/lib/cjs/CheckpointManager.js.map +1 -1
  35. package/lib/cjs/ClassRegistry.d.ts +79 -79
  36. package/lib/cjs/ClassRegistry.js +249 -244
  37. package/lib/cjs/ClassRegistry.js.map +1 -1
  38. package/lib/cjs/CloudSqlite.d.ts +355 -355
  39. package/lib/cjs/CloudSqlite.js +154 -154
  40. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  41. package/lib/cjs/CloudStorageBackend.js +170 -170
  42. package/lib/cjs/CodeService.d.ts +396 -396
  43. package/lib/cjs/CodeService.js +63 -63
  44. package/lib/cjs/CodeSpecs.d.ts +55 -55
  45. package/lib/cjs/CodeSpecs.js +124 -124
  46. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  47. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  48. package/lib/cjs/ConcurrentQuery.js +36 -36
  49. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  50. package/lib/cjs/CustomViewState3dCreator.js +82 -82
  51. package/lib/cjs/DevTools.d.ts +74 -73
  52. package/lib/cjs/DevTools.d.ts.map +1 -1
  53. package/lib/cjs/DevTools.js +156 -156
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.d.ts +106 -106
  56. package/lib/cjs/DisplayStyle.js +253 -253
  57. package/lib/cjs/DisplayStyle.js.map +1 -1
  58. package/lib/cjs/ECDb.d.ts +194 -194
  59. package/lib/cjs/ECDb.js +353 -353
  60. package/lib/cjs/ECDb.js.map +1 -1
  61. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  62. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  63. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  64. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  65. package/lib/cjs/ECSqlStatement.js +791 -791
  66. package/lib/cjs/Element.d.ts +1113 -1113
  67. package/lib/cjs/Element.js +1424 -1424
  68. package/lib/cjs/Element.js.map +1 -1
  69. package/lib/cjs/ElementAspect.d.ts +176 -176
  70. package/lib/cjs/ElementAspect.js +203 -203
  71. package/lib/cjs/ElementAspect.js.map +1 -1
  72. package/lib/cjs/ElementGraphics.d.ts +9 -9
  73. package/lib/cjs/ElementGraphics.js +41 -41
  74. package/lib/cjs/ElementGraphics.js.map +1 -1
  75. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  76. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  77. package/lib/cjs/ElementTreeWalker.js +409 -409
  78. package/lib/cjs/Entity.d.ts +106 -106
  79. package/lib/cjs/Entity.d.ts.map +1 -1
  80. package/lib/cjs/Entity.js +134 -134
  81. package/lib/cjs/Entity.js.map +1 -1
  82. package/lib/cjs/EntityReferences.d.ts +49 -49
  83. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  84. package/lib/cjs/EntityReferences.js +95 -95
  85. package/lib/cjs/ExportGraphics.d.ts +317 -317
  86. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  87. package/lib/cjs/ExportGraphics.js +208 -208
  88. package/lib/cjs/ExternalSource.d.ts +96 -96
  89. package/lib/cjs/ExternalSource.js +131 -131
  90. package/lib/cjs/ExternalSource.js.map +1 -1
  91. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  92. package/lib/cjs/GeoCoordConfig.js +85 -85
  93. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  94. package/lib/cjs/GeometrySummary.d.ts +4 -4
  95. package/lib/cjs/GeometrySummary.js +333 -333
  96. package/lib/cjs/GeometrySummary.js.map +1 -1
  97. package/lib/cjs/HubMock.d.ts +94 -94
  98. package/lib/cjs/HubMock.js +220 -220
  99. package/lib/cjs/HubMock.js.map +1 -1
  100. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  101. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  102. package/lib/cjs/IModelCloneContext.js +15 -15
  103. package/lib/cjs/IModelDb.d.ts +1216 -1216
  104. package/lib/cjs/IModelDb.d.ts.map +1 -1
  105. package/lib/cjs/IModelDb.js +2387 -2386
  106. package/lib/cjs/IModelDb.js.map +1 -1
  107. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  108. package/lib/cjs/IModelElementCloneContext.js +159 -159
  109. package/lib/cjs/IModelHost.d.ts +369 -369
  110. package/lib/cjs/IModelHost.js +488 -488
  111. package/lib/cjs/IModelHost.js.map +1 -1
  112. package/lib/cjs/IModelJsFs.d.ts +62 -62
  113. package/lib/cjs/IModelJsFs.js +139 -139
  114. package/lib/cjs/IpcHost.d.ts +104 -104
  115. package/lib/cjs/IpcHost.js +276 -276
  116. package/lib/cjs/IpcHost.js.map +1 -1
  117. package/lib/cjs/LineStyle.d.ts +311 -311
  118. package/lib/cjs/LineStyle.js +295 -295
  119. package/lib/cjs/LocalHub.d.ts +162 -162
  120. package/lib/cjs/LocalHub.d.ts.map +1 -1
  121. package/lib/cjs/LocalHub.js +579 -579
  122. package/lib/cjs/LocalHub.js.map +1 -1
  123. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  124. package/lib/cjs/LocalhostIpcHost.js +79 -79
  125. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  126. package/lib/cjs/Material.d.ts +131 -131
  127. package/lib/cjs/Material.js +180 -180
  128. package/lib/cjs/Material.js.map +1 -1
  129. package/lib/cjs/Model.d.ts +392 -392
  130. package/lib/cjs/Model.js +489 -489
  131. package/lib/cjs/Model.js.map +1 -1
  132. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  133. package/lib/cjs/NativeAppStorage.js +202 -202
  134. package/lib/cjs/NativeAppStorage.js.map +1 -1
  135. package/lib/cjs/NativeHost.d.ts +52 -52
  136. package/lib/cjs/NativeHost.js +160 -160
  137. package/lib/cjs/NativeHost.js.map +1 -1
  138. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  139. package/lib/cjs/NavigationRelationship.js +225 -225
  140. package/lib/cjs/NavigationRelationship.js.map +1 -1
  141. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  142. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  143. package/lib/cjs/PromiseMemoizer.js +101 -101
  144. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  145. package/lib/cjs/PropertyStore.d.ts +132 -132
  146. package/lib/cjs/PropertyStore.js +11 -11
  147. package/lib/cjs/Relationship.d.ts +416 -416
  148. package/lib/cjs/Relationship.js +494 -494
  149. package/lib/cjs/Relationship.js.map +1 -1
  150. package/lib/cjs/RpcBackend.d.ts +5 -5
  151. package/lib/cjs/RpcBackend.js +32 -32
  152. package/lib/cjs/SQLiteDb.d.ts +219 -219
  153. package/lib/cjs/SQLiteDb.js +212 -212
  154. package/lib/cjs/Schema.d.ts +55 -55
  155. package/lib/cjs/Schema.js +83 -83
  156. package/lib/cjs/Schema.js.map +1 -1
  157. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  158. package/lib/cjs/ServerBasedLocks.js +168 -168
  159. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  160. package/lib/cjs/SqliteStatement.d.ts +360 -360
  161. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  162. package/lib/cjs/SqliteStatement.js +586 -586
  163. package/lib/cjs/Texture.d.ts +58 -58
  164. package/lib/cjs/Texture.js +82 -82
  165. package/lib/cjs/Texture.js.map +1 -1
  166. package/lib/cjs/TileStorage.d.ts +18 -18
  167. package/lib/cjs/TileStorage.js +87 -87
  168. package/lib/cjs/TxnManager.d.ts +202 -202
  169. package/lib/cjs/TxnManager.d.ts.map +1 -1
  170. package/lib/cjs/TxnManager.js +356 -356
  171. package/lib/cjs/TxnManager.js.map +1 -1
  172. package/lib/cjs/ViewDefinition.d.ts +435 -435
  173. package/lib/cjs/ViewDefinition.js +646 -646
  174. package/lib/cjs/ViewDefinition.js.map +1 -1
  175. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  176. package/lib/cjs/ViewStateHydrator.js +103 -103
  177. package/lib/cjs/core-backend.d.ts +185 -185
  178. package/lib/cjs/core-backend.js +209 -205
  179. package/lib/cjs/core-backend.js.map +1 -1
  180. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  181. package/lib/cjs/domains/FunctionalElements.js +145 -145
  182. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  183. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  184. package/lib/cjs/domains/FunctionalSchema.js +39 -39
  185. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  186. package/lib/cjs/domains/GenericElements.js +263 -263
  187. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  188. package/lib/cjs/domains/GenericSchema.js +28 -28
  189. package/lib/cjs/rpc/multipart.d.ts +11 -11
  190. package/lib/cjs/rpc/multipart.js +71 -71
  191. package/lib/cjs/rpc/tracing.d.ts +28 -28
  192. package/lib/cjs/rpc/tracing.js +73 -73
  193. package/lib/cjs/rpc/tracing.js.map +1 -1
  194. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  195. package/lib/cjs/rpc/web/logging.js +43 -43
  196. package/lib/cjs/rpc/web/request.d.ts +6 -6
  197. package/lib/cjs/rpc/web/request.js +73 -73
  198. package/lib/cjs/rpc/web/response.d.ts +6 -6
  199. package/lib/cjs/rpc/web/response.js +105 -105
  200. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  201. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  202. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  203. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -293
  204. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  205. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  206. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  207. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  208. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  209. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -166
  210. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  211. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -42
  212. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  213. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  214. package/lib/cjs/workspace/Settings.d.ts +186 -186
  215. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  216. package/lib/cjs/workspace/Settings.js +154 -154
  217. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  218. package/lib/cjs/workspace/SettingsSchemas.js +190 -190
  219. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  220. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  221. package/lib/cjs/workspace/Workspace.js +537 -537
  222. package/lib/cjs/workspace/Workspace.js.map +1 -1
  223. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"IModelTileRpcImpl.js","sourceRoot":"","sources":["../../../src/rpc-impl/IModelTileRpcImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAyF;AACzF,oDAI4B;AAC5B,oEAAiE;AACjE,0CAAuC;AACvC,8CAA2C;AAC3C,wDAAuE;AACvE,4CAA0C;AAC1C,+DAA4D;AAQ5D,SAAS,sBAAsB,CAAC,KAAuB;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;IAC/B,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QACvB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE;KACjC,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;AACvB,CAAC;AAED,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,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACjG,OAAO,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AA5DD,8CA4DC;AAED,gBAAgB;AACT,KAAK,UAAU,yBAAyB,CAAC,UAA0B,EAAE,UAAgC;IAC1G,MAAM,MAAM,GAAG,mBAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,KAAK,GAA4B,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAEjF,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;QAC9B,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,UAAU,EAAE;YACxC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;YAC5B,0BAA0B,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC3D;QAED,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;KAC3E;AACH,CAAC;AAbD,8DAaC","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 RpcInterface\r\n */\r\n\r\nimport type { TransferConfig } from \"@itwin/object-storage-core\";\r\nimport { AccessToken, assert, BeDuration, Id64Array, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageTileCache, ElementGraphicsRequestProps, IModelRpcProps,\r\n IModelTileRpcInterface, IModelTileTreeProps, RpcInterface, RpcInvocation, RpcManager, RpcPendingResponse, TileContentIdentifier,\r\n TileContentSource, TileTreeContentIds, TileVersionInfo,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { IModelHost } from \"../IModelHost\";\r\nimport { PromiseMemoizer, QueryablePromise } from \"../PromiseMemoizer\";\r\nimport { RpcTrace } from \"../rpc/tracing\";\r\nimport { RpcBriefcaseUtility } from \"./RpcBriefcaseUtility\";\r\n\r\ninterface TileRequestProps {\r\n accessToken?: AccessToken;\r\n tokenProps: IModelRpcProps;\r\n treeId: string;\r\n}\r\n\r\nfunction generateTileRequestKey(props: TileRequestProps): string {\r\n const token = props.tokenProps;\r\n return `${JSON.stringify({\r\n key: token.key,\r\n iTwinId: token.iTwinId,\r\n iModelId: token.iModelId,\r\n changesetId: token.changeset?.id,\r\n })}:${props.treeId}`;\r\n}\r\n\r\nabstract class TileRequestMemoizer<Result, Props extends TileRequestProps> extends PromiseMemoizer<Result> {\r\n private readonly _loggerCategory = BackendLoggerCategory.IModelTileRequestRpc;\r\n protected abstract get _operationName(): string;\r\n protected abstract addMetadata(metadata: any, props: Props): void;\r\n protected abstract stringify(props: Props): string;\r\n protected abstract get _timeoutMilliseconds(): number;\r\n\r\n private makeMetadata(props: Props): any {\r\n const meta = { ...props.tokenProps };\r\n this.addMetadata(meta, props);\r\n return meta;\r\n }\r\n\r\n protected constructor(memoizeFn: (props: Props) => Promise<Result>, generateKeyFn: (props: Props) => string) {\r\n super(memoizeFn, generateKeyFn);\r\n }\r\n\r\n public override memoize(props: Props): QueryablePromise<Result> {\r\n return super.memoize(props);\r\n }\r\n\r\n public override deleteMemoized(props: Props) {\r\n super.deleteMemoized(props);\r\n }\r\n\r\n private log(status: string, props: Props): void {\r\n const descr = `${this._operationName}(${this.stringify(props)})`;\r\n Logger.logTrace(this._loggerCategory, `Backend ${status} ${descr}`, () => this.makeMetadata(props));\r\n }\r\n\r\n protected async perform(props: Props): Promise<Result> {\r\n this.log(\"received\", props);\r\n\r\n const tileQP = this.memoize(props);\r\n\r\n await BeDuration.race(this._timeoutMilliseconds, tileQP.promise).catch(() => { });\r\n // Note: Rejections must be caught so that the memoization entry can be deleted\r\n\r\n if (tileQP.isPending) {\r\n this.log(\"issuing pending status for\", props);\r\n throw new RpcPendingResponse(); // eslint-disable-line deprecation/deprecation\r\n }\r\n\r\n this.deleteMemoized(props);\r\n\r\n if (tileQP.isFulfilled) {\r\n this.log(\"completed\", props);\r\n assert(undefined !== tileQP.result);\r\n return tileQP.result;\r\n }\r\n\r\n assert(tileQP.isRejected);\r\n this.log(\"rejected\", props);\r\n throw tileQP.error; // eslint-disable-line no-throw-literal\r\n }\r\n}\r\n\r\nasync function getTileTreeProps(props: TileRequestProps): Promise<IModelTileTreeProps> {\r\n assert(undefined !== props.accessToken);\r\n const db = await RpcBriefcaseUtility.findOpenIModel(props.accessToken, props.tokenProps);\r\n return db.tiles.requestTileTreeProps(props.treeId);\r\n}\r\n\r\nclass RequestTileTreePropsMemoizer extends TileRequestMemoizer<IModelTileTreeProps, TileRequestProps> {\r\n protected get _timeoutMilliseconds() { return IModelHost.tileTreeRequestTimeout; }\r\n protected get _operationName() { return \"requestTileTreeProps\"; }\r\n protected stringify(props: TileRequestProps): string { return props.treeId; }\r\n protected addMetadata(meta: any, props: TileRequestProps): void {\r\n meta.treeId = props.treeId;\r\n }\r\n\r\n private static _instance?: RequestTileTreePropsMemoizer;\r\n\r\n private constructor() {\r\n super(getTileTreeProps, generateTileRequestKey);\r\n IModelHost.onBeforeShutdown.addOnce(() => {\r\n this.dispose();\r\n RequestTileTreePropsMemoizer._instance = undefined;\r\n });\r\n }\r\n\r\n public static async perform(props: TileRequestProps): Promise<IModelTileTreeProps> {\r\n if (undefined === this._instance)\r\n this._instance = new RequestTileTreePropsMemoizer();\r\n\r\n return this._instance.perform(props);\r\n }\r\n}\r\n\r\ninterface TileContentRequestProps extends TileRequestProps {\r\n contentId: string;\r\n guid?: string;\r\n}\r\n\r\nasync function getTileContent(props: TileContentRequestProps): Promise<TileContentSource> {\r\n assert(undefined !== props.accessToken);\r\n const db = await RpcBriefcaseUtility.findOpenIModel(props.accessToken, props.tokenProps);\r\n const tile = await db.tiles.requestTileContent(props.treeId, props.contentId);\r\n\r\n // ###TODO: Verify the guid supplied by the front-end matches the guid stored in the model?\r\n if (IModelHost.usingExternalTileCache) {\r\n await IModelHost.tileStorage?.uploadTile(db.iModelId, db.changeset.id, props.treeId, props.contentId, tile.content, props.guid, {\r\n backendName: IModelHost.applicationId,\r\n tileGenerationTime: tile.elapsedSeconds.toString(),\r\n tileSize: tile.content.byteLength.toString(),\r\n });\r\n\r\n return TileContentSource.ExternalCache;\r\n }\r\n\r\n return TileContentSource.Backend;\r\n}\r\n\r\nfunction generateTileContentKey(props: TileContentRequestProps): string {\r\n return `${generateTileRequestKey(props)}:${props.contentId}`;\r\n}\r\n\r\nclass RequestTileContentMemoizer extends TileRequestMemoizer<TileContentSource, TileContentRequestProps> {\r\n protected get _timeoutMilliseconds() { return IModelHost.tileContentRequestTimeout; }\r\n protected get _operationName() { return \"requestTileContent\"; }\r\n protected stringify(props: TileContentRequestProps): string { return `${props.treeId}:${props.contentId}`; }\r\n protected addMetadata(meta: any, props: TileContentRequestProps): void {\r\n meta.treeId = props.treeId;\r\n meta.contentId = props.contentId;\r\n }\r\n\r\n private static _instance?: RequestTileContentMemoizer;\r\n\r\n private constructor() {\r\n super(getTileContent, generateTileContentKey);\r\n IModelHost.onBeforeShutdown.addOnce(() => {\r\n this.dispose();\r\n RequestTileContentMemoizer._instance = undefined;\r\n });\r\n }\r\n\r\n public static get instance() {\r\n if (undefined === this._instance)\r\n this._instance = new RequestTileContentMemoizer();\r\n\r\n return this._instance;\r\n }\r\n\r\n public static async perform(props: TileContentRequestProps): Promise<TileContentSource> {\r\n return this.instance.perform(props);\r\n }\r\n}\r\n\r\nfunction currentActivity() {\r\n return RpcTrace.expectCurrentActivity; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** @internal */\r\nexport class IModelTileRpcImpl extends RpcInterface implements IModelTileRpcInterface { // eslint-disable-line deprecation/deprecation\r\n public static register() { RpcManager.registerImpl(IModelTileRpcInterface, IModelTileRpcImpl); }\r\n\r\n public async requestTileTreeProps(tokenProps: IModelRpcProps, treeId: string): Promise<IModelTileTreeProps> {\r\n return RequestTileTreePropsMemoizer.perform({ accessToken: currentActivity().accessToken, tokenProps, treeId });\r\n }\r\n\r\n public async purgeTileTrees(tokenProps: IModelRpcProps, modelIds: Id64Array | undefined): Promise<void> {\r\n // `undefined` gets forwarded as `null`...\r\n if (null === modelIds)\r\n modelIds = undefined;\r\n\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return db.nativeDb.purgeTileTrees(modelIds);\r\n }\r\n\r\n public async generateTileContent(tokenProps: IModelRpcProps, treeId: string, contentId: string, guid: string | undefined): Promise<TileContentSource> {\r\n return RequestTileContentMemoizer.perform({ accessToken: currentActivity().accessToken, tokenProps, treeId, contentId, guid });\r\n }\r\n\r\n public async retrieveTileContent(tokenProps: IModelRpcProps, key: TileContentIdentifier): Promise<Uint8Array> {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return db.tiles.getTileContent(key.treeId, key.contentId);\r\n }\r\n\r\n public async getTileCacheConfig(tokenProps: IModelRpcProps): Promise<TransferConfig | undefined> {\r\n if (IModelHost.tileStorage === undefined)\r\n return undefined;\r\n const iModelId = tokenProps.iModelId ?? (await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps)).iModelId;\r\n return IModelHost.tileStorage.getDownloadConfig(iModelId);\r\n }\r\n\r\n /* eslint-disable deprecation/deprecation */\r\n public async getTileCacheContainerUrl(_tokenProps: IModelRpcProps, id: CloudStorageContainerDescriptor): Promise<CloudStorageContainerUrl> {\r\n const invocation = RpcInvocation.current(this);\r\n\r\n if (!IModelHost.usingExternalTileCache) {\r\n return CloudStorageContainerUrl.empty();\r\n }\r\n\r\n const expiry = CloudStorageTileCache.getCache().supplyExpiryForContainerUrl(id);\r\n const clientIp = (IModelHost.restrictTileUrlsByClientIp && invocation.request.ip) ? invocation.request.ip : undefined;\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n return IModelHost.tileCacheService!.obtainContainerUrl(id, expiry, clientIp);\r\n }\r\n\r\n public async isUsingExternalTileCache(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IModelHost.tileCacheService !== undefined;\r\n }\r\n /* eslint-enable deprecation/deprecation */\r\n\r\n public async queryVersionInfo(): Promise<TileVersionInfo> {\r\n return IModelHost.platform.getTileVersionInfo();\r\n }\r\n\r\n /** @internal */\r\n public async requestElementGraphics(rpcProps: IModelRpcProps, request: ElementGraphicsRequestProps): Promise<Uint8Array | undefined> {\r\n const iModel = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, rpcProps);\r\n return iModel.generateElementGraphics(request);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport async function cancelTileContentRequests(tokenProps: IModelRpcProps, contentIds: TileTreeContentIds[]): Promise<void> {\r\n const iModel = IModelDb.findByKey(tokenProps.key);\r\n const props: TileContentRequestProps = { tokenProps, treeId: \"\", contentId: \"\" };\r\n\r\n for (const entry of contentIds) {\r\n props.treeId = entry.treeId;\r\n for (const contentId of entry.contentIds) {\r\n props.contentId = contentId;\r\n RequestTileContentMemoizer.instance.deleteMemoized(props);\r\n }\r\n\r\n iModel.nativeDb.cancelTileContentRequests(entry.treeId, entry.contentIds);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelTileRpcImpl.js","sourceRoot":"","sources":["../../../src/rpc-impl/IModelTileRpcImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAyF;AACzF,oDAI4B;AAC5B,oEAAiE;AACjE,0CAAuC;AACvC,8CAA2C;AAC3C,wDAAuE;AACvE,4CAA0C;AAC1C,+DAA4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M,EAAE,QAAQ,CAAC,CAAC;IAC/E,CAAC;IAEM,KAAK,CAAC,wBAAwB;QACnC,OAAO,uBAAU,CAAC,gBAAgB,KAAK,SAAS,CAAC;IACnD,CAAC;IACD,2CAA2C;IAEpC,KAAK,CAAC,gBAAgB;QAC3B,OAAO,uBAAU,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IAClD,CAAC;IAED,gBAAgB;IACT,KAAK,CAAC,sBAAsB,CAAC,QAAwB,EAAE,OAAoC;QAChG,MAAM,MAAM,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACjG,OAAO,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AA5DD,8CA4DC;AAED,gBAAgB;AACT,KAAK,UAAU,yBAAyB,CAAC,UAA0B,EAAE,UAAgC;IAC1G,MAAM,MAAM,GAAG,mBAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,KAAK,GAA4B,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAEjF,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;QAC9B,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,UAAU,EAAE;YACxC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;YAC5B,0BAA0B,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC3D;QAED,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;KAC3E;AACH,CAAC;AAbD,8DAaC","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 RpcInterface\r\n */\r\n\r\nimport type { TransferConfig } from \"@itwin/object-storage-core\";\r\nimport { AccessToken, assert, BeDuration, Id64Array, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageTileCache, ElementGraphicsRequestProps, IModelRpcProps,\r\n IModelTileRpcInterface, IModelTileTreeProps, RpcInterface, RpcInvocation, RpcManager, RpcPendingResponse, TileContentIdentifier,\r\n TileContentSource, TileTreeContentIds, TileVersionInfo,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { IModelHost } from \"../IModelHost\";\r\nimport { PromiseMemoizer, QueryablePromise } from \"../PromiseMemoizer\";\r\nimport { RpcTrace } from \"../rpc/tracing\";\r\nimport { RpcBriefcaseUtility } from \"./RpcBriefcaseUtility\";\r\n\r\ninterface TileRequestProps {\r\n accessToken?: AccessToken;\r\n tokenProps: IModelRpcProps;\r\n treeId: string;\r\n}\r\n\r\nfunction generateTileRequestKey(props: TileRequestProps): string {\r\n const token = props.tokenProps;\r\n return `${JSON.stringify({\r\n key: token.key,\r\n iTwinId: token.iTwinId,\r\n iModelId: token.iModelId,\r\n changesetId: token.changeset?.id,\r\n })}:${props.treeId}`;\r\n}\r\n\r\nabstract class TileRequestMemoizer<Result, Props extends TileRequestProps> extends PromiseMemoizer<Result> {\r\n private readonly _loggerCategory = BackendLoggerCategory.IModelTileRequestRpc;\r\n protected abstract get _operationName(): string;\r\n protected abstract addMetadata(metadata: any, props: Props): void;\r\n protected abstract stringify(props: Props): string;\r\n protected abstract get _timeoutMilliseconds(): number;\r\n\r\n private makeMetadata(props: Props): any {\r\n const meta = { ...props.tokenProps };\r\n this.addMetadata(meta, props);\r\n return meta;\r\n }\r\n\r\n protected constructor(memoizeFn: (props: Props) => Promise<Result>, generateKeyFn: (props: Props) => string) {\r\n super(memoizeFn, generateKeyFn);\r\n }\r\n\r\n public override memoize(props: Props): QueryablePromise<Result> {\r\n return super.memoize(props);\r\n }\r\n\r\n public override deleteMemoized(props: Props) {\r\n super.deleteMemoized(props);\r\n }\r\n\r\n private log(status: string, props: Props): void {\r\n const descr = `${this._operationName}(${this.stringify(props)})`;\r\n Logger.logTrace(this._loggerCategory, `Backend ${status} ${descr}`, () => this.makeMetadata(props));\r\n }\r\n\r\n protected async perform(props: Props): Promise<Result> {\r\n this.log(\"received\", props);\r\n\r\n const tileQP = this.memoize(props);\r\n\r\n await BeDuration.race(this._timeoutMilliseconds, tileQP.promise).catch(() => { });\r\n // Note: Rejections must be caught so that the memoization entry can be deleted\r\n\r\n if (tileQP.isPending) {\r\n this.log(\"issuing pending status for\", props);\r\n throw new RpcPendingResponse(); // eslint-disable-line deprecation/deprecation\r\n }\r\n\r\n this.deleteMemoized(props);\r\n\r\n if (tileQP.isFulfilled) {\r\n this.log(\"completed\", props);\r\n assert(undefined !== tileQP.result);\r\n return tileQP.result;\r\n }\r\n\r\n assert(tileQP.isRejected);\r\n this.log(\"rejected\", props);\r\n throw tileQP.error; // eslint-disable-line no-throw-literal\r\n }\r\n}\r\n\r\nasync function getTileTreeProps(props: TileRequestProps): Promise<IModelTileTreeProps> {\r\n assert(undefined !== props.accessToken);\r\n const db = await RpcBriefcaseUtility.findOpenIModel(props.accessToken, props.tokenProps);\r\n return db.tiles.requestTileTreeProps(props.treeId);\r\n}\r\n\r\nclass RequestTileTreePropsMemoizer extends TileRequestMemoizer<IModelTileTreeProps, TileRequestProps> {\r\n protected get _timeoutMilliseconds() { return IModelHost.tileTreeRequestTimeout; }\r\n protected get _operationName() { return \"requestTileTreeProps\"; }\r\n protected stringify(props: TileRequestProps): string { return props.treeId; }\r\n protected addMetadata(meta: any, props: TileRequestProps): void {\r\n meta.treeId = props.treeId;\r\n }\r\n\r\n private static _instance?: RequestTileTreePropsMemoizer;\r\n\r\n private constructor() {\r\n super(getTileTreeProps, generateTileRequestKey);\r\n IModelHost.onBeforeShutdown.addOnce(() => {\r\n this.dispose();\r\n RequestTileTreePropsMemoizer._instance = undefined;\r\n });\r\n }\r\n\r\n public static async perform(props: TileRequestProps): Promise<IModelTileTreeProps> {\r\n if (undefined === this._instance)\r\n this._instance = new RequestTileTreePropsMemoizer();\r\n\r\n return this._instance.perform(props);\r\n }\r\n}\r\n\r\ninterface TileContentRequestProps extends TileRequestProps {\r\n contentId: string;\r\n guid?: string;\r\n}\r\n\r\nasync function getTileContent(props: TileContentRequestProps): Promise<TileContentSource> {\r\n assert(undefined !== props.accessToken);\r\n const db = await RpcBriefcaseUtility.findOpenIModel(props.accessToken, props.tokenProps);\r\n const tile = await db.tiles.requestTileContent(props.treeId, props.contentId);\r\n\r\n // ###TODO: Verify the guid supplied by the front-end matches the guid stored in the model?\r\n if (IModelHost.usingExternalTileCache) {\r\n await IModelHost.tileStorage?.uploadTile(db.iModelId, db.changeset.id, props.treeId, props.contentId, tile.content, props.guid, {\r\n backendName: IModelHost.applicationId,\r\n tileGenerationTime: tile.elapsedSeconds.toString(),\r\n tileSize: tile.content.byteLength.toString(),\r\n });\r\n\r\n return TileContentSource.ExternalCache;\r\n }\r\n\r\n return TileContentSource.Backend;\r\n}\r\n\r\nfunction generateTileContentKey(props: TileContentRequestProps): string {\r\n return `${generateTileRequestKey(props)}:${props.contentId}`;\r\n}\r\n\r\nclass RequestTileContentMemoizer extends TileRequestMemoizer<TileContentSource, TileContentRequestProps> {\r\n protected get _timeoutMilliseconds() { return IModelHost.tileContentRequestTimeout; }\r\n protected get _operationName() { return \"requestTileContent\"; }\r\n protected stringify(props: TileContentRequestProps): string { return `${props.treeId}:${props.contentId}`; }\r\n protected addMetadata(meta: any, props: TileContentRequestProps): void {\r\n meta.treeId = props.treeId;\r\n meta.contentId = props.contentId;\r\n }\r\n\r\n private static _instance?: RequestTileContentMemoizer;\r\n\r\n private constructor() {\r\n super(getTileContent, generateTileContentKey);\r\n IModelHost.onBeforeShutdown.addOnce(() => {\r\n this.dispose();\r\n RequestTileContentMemoizer._instance = undefined;\r\n });\r\n }\r\n\r\n public static get instance() {\r\n if (undefined === this._instance)\r\n this._instance = new RequestTileContentMemoizer();\r\n\r\n return this._instance;\r\n }\r\n\r\n public static async perform(props: TileContentRequestProps): Promise<TileContentSource> {\r\n return this.instance.perform(props);\r\n }\r\n}\r\n\r\nfunction currentActivity() {\r\n return RpcTrace.expectCurrentActivity; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** @internal */\r\nexport class IModelTileRpcImpl extends RpcInterface implements IModelTileRpcInterface { // eslint-disable-line deprecation/deprecation\r\n public static register() { RpcManager.registerImpl(IModelTileRpcInterface, IModelTileRpcImpl); }\r\n\r\n public async requestTileTreeProps(tokenProps: IModelRpcProps, treeId: string): Promise<IModelTileTreeProps> {\r\n return RequestTileTreePropsMemoizer.perform({ accessToken: currentActivity().accessToken, tokenProps, treeId });\r\n }\r\n\r\n public async purgeTileTrees(tokenProps: IModelRpcProps, modelIds: Id64Array | undefined): Promise<void> {\r\n // `undefined` gets forwarded as `null`...\r\n if (null === modelIds)\r\n modelIds = undefined;\r\n\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return db.nativeDb.purgeTileTrees(modelIds);\r\n }\r\n\r\n public async generateTileContent(tokenProps: IModelRpcProps, treeId: string, contentId: string, guid: string | undefined): Promise<TileContentSource> {\r\n return RequestTileContentMemoizer.perform({ accessToken: currentActivity().accessToken, tokenProps, treeId, contentId, guid });\r\n }\r\n\r\n public async retrieveTileContent(tokenProps: IModelRpcProps, key: TileContentIdentifier): Promise<Uint8Array> {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return db.tiles.getTileContent(key.treeId, key.contentId);\r\n }\r\n\r\n public async getTileCacheConfig(tokenProps: IModelRpcProps): Promise<TransferConfig | undefined> {\r\n if (IModelHost.tileStorage === undefined)\r\n return undefined;\r\n const iModelId = tokenProps.iModelId ?? (await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps)).iModelId;\r\n return IModelHost.tileStorage.getDownloadConfig(iModelId);\r\n }\r\n\r\n /* eslint-disable deprecation/deprecation */\r\n public async getTileCacheContainerUrl(_tokenProps: IModelRpcProps, id: CloudStorageContainerDescriptor): Promise<CloudStorageContainerUrl> {\r\n const invocation = RpcInvocation.current(this);\r\n\r\n if (!IModelHost.usingExternalTileCache) {\r\n return CloudStorageContainerUrl.empty();\r\n }\r\n\r\n const expiry = CloudStorageTileCache.getCache().supplyExpiryForContainerUrl(id);\r\n const clientIp = (IModelHost.restrictTileUrlsByClientIp && invocation.request.ip) ? invocation.request.ip : undefined;\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n return IModelHost.tileCacheService!.obtainContainerUrl(id, expiry, clientIp);\r\n }\r\n\r\n public async isUsingExternalTileCache(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IModelHost.tileCacheService !== undefined;\r\n }\r\n /* eslint-enable deprecation/deprecation */\r\n\r\n public async queryVersionInfo(): Promise<TileVersionInfo> {\r\n return IModelHost.platform.getTileVersionInfo();\r\n }\r\n\r\n /** @internal */\r\n public async requestElementGraphics(rpcProps: IModelRpcProps, request: ElementGraphicsRequestProps): Promise<Uint8Array | undefined> {\r\n const iModel = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, rpcProps);\r\n return iModel.generateElementGraphics(request);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport async function cancelTileContentRequests(tokenProps: IModelRpcProps, contentIds: TileTreeContentIds[]): Promise<void> {\r\n const iModel = IModelDb.findByKey(tokenProps.key);\r\n const props: TileContentRequestProps = { tokenProps, treeId: \"\", contentId: \"\" };\r\n\r\n for (const entry of contentIds) {\r\n props.treeId = entry.treeId;\r\n for (const contentId of entry.contentIds) {\r\n props.contentId = contentId;\r\n RequestTileContentMemoizer.instance.deleteMemoized(props);\r\n }\r\n\r\n iModel.nativeDb.cancelTileContentRequests(entry.treeId, entry.contentIds);\r\n }\r\n}\r\n"]}
@@ -1,37 +1,37 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- import { AccessToken } from "@itwin/core-bentley";
5
- import { BriefcaseProps, IModelConnectionProps, IModelRpcOpenProps, IModelRpcProps, RpcActivity, SyncMode } from "@itwin/core-common";
6
- import { IModelDb } from "../IModelDb";
7
- /** @internal */
8
- export interface DownloadAndOpenArgs {
9
- activity: RpcActivity;
10
- tokenProps: IModelRpcOpenProps;
11
- syncMode: SyncMode;
12
- fileNameResolvers?: ((arg: BriefcaseProps) => string)[];
13
- timeout?: number;
14
- forceDownload?: boolean;
15
- }
16
- /**
17
- * Utility to open the iModel for RPC interfaces
18
- * @internal
19
- */
20
- export declare class RpcBriefcaseUtility {
21
- private static downloadAndOpen;
22
- private static _briefcasePromise;
23
- private static openBriefcase;
24
- /** find a previously opened iModel for RPC.
25
- * @param accessToken necessary (only) for V2 checkpoints to refresh access token in daemon if it has expired. We use the accessToken of the current RPC request
26
- * to refresh the daemon, even though it will be used for all authorized users.
27
- * @param the IModelRpcProps to locate the opened iModel.
28
- */
29
- static findOpenIModel(accessToken: AccessToken, iModel: IModelRpcProps): Promise<IModelDb>;
30
- /**
31
- * Download and open a checkpoint or briefcase, ensuring the operation completes within a default timeout. If the time to open exceeds the timeout period,
32
- * a RpcPendingResponse exception is thrown
33
- */
34
- static open(args: DownloadAndOpenArgs): Promise<IModelDb>;
35
- static openWithTimeout(activity: RpcActivity, tokenProps: IModelRpcOpenProps, syncMode: SyncMode, timeout?: number): Promise<IModelConnectionProps>;
36
- }
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { AccessToken } from "@itwin/core-bentley";
5
+ import { BriefcaseProps, IModelConnectionProps, IModelRpcOpenProps, IModelRpcProps, RpcActivity, SyncMode } from "@itwin/core-common";
6
+ import { IModelDb } from "../IModelDb";
7
+ /** @internal */
8
+ export interface DownloadAndOpenArgs {
9
+ activity: RpcActivity;
10
+ tokenProps: IModelRpcOpenProps;
11
+ syncMode: SyncMode;
12
+ fileNameResolvers?: ((arg: BriefcaseProps) => string)[];
13
+ timeout?: number;
14
+ forceDownload?: boolean;
15
+ }
16
+ /**
17
+ * Utility to open the iModel for RPC interfaces
18
+ * @internal
19
+ */
20
+ export declare class RpcBriefcaseUtility {
21
+ private static downloadAndOpen;
22
+ private static _briefcasePromise;
23
+ private static openBriefcase;
24
+ /** find a previously opened iModel for RPC.
25
+ * @param accessToken necessary (only) for V2 checkpoints to refresh access token in daemon if it has expired. We use the accessToken of the current RPC request
26
+ * to refresh the daemon, even though it will be used for all authorized users.
27
+ * @param the IModelRpcProps to locate the opened iModel.
28
+ */
29
+ static findOpenIModel(accessToken: AccessToken, iModel: IModelRpcProps): Promise<IModelDb>;
30
+ /**
31
+ * Download and open a checkpoint or briefcase, ensuring the operation completes within a default timeout. If the time to open exceeds the timeout period,
32
+ * a RpcPendingResponse exception is thrown
33
+ */
34
+ static open(args: DownloadAndOpenArgs): Promise<IModelDb>;
35
+ static openWithTimeout(activity: RpcActivity, tokenProps: IModelRpcOpenProps, syncMode: SyncMode, timeout?: number): Promise<IModelConnectionProps>;
36
+ }
37
37
  //# sourceMappingURL=RpcBriefcaseUtility.d.ts.map
@@ -1,167 +1,167 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.RpcBriefcaseUtility = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- const BackendLoggerCategory_1 = require("../BackendLoggerCategory");
14
- const BriefcaseManager_1 = require("../BriefcaseManager");
15
- const CheckpointManager_1 = require("../CheckpointManager");
16
- const IModelDb_1 = require("../IModelDb");
17
- const IModelHost_1 = require("../IModelHost");
18
- const IModelJsFs_1 = require("../IModelJsFs");
19
- const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
20
- /**
21
- * Utility to open the iModel for RPC interfaces
22
- * @internal
23
- */
24
- class RpcBriefcaseUtility {
25
- static async downloadAndOpen(args) {
26
- const { activity, tokenProps } = args;
27
- const accessToken = activity.accessToken;
28
- (0, core_bentley_1.assert)(undefined !== tokenProps.iModelId);
29
- const iModelId = tokenProps.iModelId;
30
- let myBriefcaseIds;
31
- if (args.syncMode === core_common_1.SyncMode.PullOnly) {
32
- myBriefcaseIds = [0]; // PullOnly means briefcaseId 0
33
- }
34
- else {
35
- // check with iModelHub and see if we already have acquired any briefcaseIds
36
- myBriefcaseIds = await IModelHost_1.IModelHost.hubAccess.getMyBriefcaseIds({ accessToken, iModelId });
37
- }
38
- const resolvers = args.fileNameResolvers ?? [(arg) => BriefcaseManager_1.BriefcaseManager.getFileName(arg)];
39
- // see if we can open any of the briefcaseIds we already acquired from iModelHub
40
- if (resolvers) {
41
- for (const resolver of resolvers) {
42
- for (const briefcaseId of myBriefcaseIds) {
43
- const fileName = resolver({ briefcaseId, iModelId });
44
- if (IModelJsFs_1.IModelJsFs.existsSync(fileName)) {
45
- const briefcaseDb = IModelDb_1.BriefcaseDb.findByFilename(fileName);
46
- if (briefcaseDb !== undefined)
47
- return briefcaseDb;
48
- try {
49
- if (args.forceDownload)
50
- throw new Error(); // causes delete below
51
- const db = await IModelDb_1.BriefcaseDb.open({ fileName });
52
- if (db.changeset.id !== tokenProps.changeset?.id) {
53
- (0, core_bentley_1.assert)(undefined !== tokenProps.changeset);
54
- const toIndex = tokenProps.changeset?.index ??
55
- (await IModelHost_1.IModelHost.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version: core_common_1.IModelVersion.asOfChangeSet(tokenProps.changeset.id) })).index;
56
- await BriefcaseManager_1.BriefcaseManager.pullAndApplyChangesets(db, { accessToken, toIndex });
57
- }
58
- return db;
59
- }
60
- catch (error) {
61
- if (!(error.errorNumber === core_bentley_1.IModelStatus.AlreadyOpen))
62
- // somehow we have this briefcaseId and the file exists, but we can't open it. Delete it.
63
- await BriefcaseManager_1.BriefcaseManager.deleteBriefcaseFiles(fileName, accessToken);
64
- }
65
- }
66
- }
67
- }
68
- }
69
- // no local briefcase available. Download one and open it.
70
- (0, core_bentley_1.assert)(undefined !== tokenProps.iTwinId);
71
- const request = {
72
- accessToken,
73
- iTwinId: tokenProps.iTwinId,
74
- iModelId,
75
- briefcaseId: args.syncMode === core_common_1.SyncMode.PullOnly ? 0 : undefined, // if briefcaseId is undefined, we'll acquire a new one.
76
- };
77
- const props = await BriefcaseManager_1.BriefcaseManager.downloadBriefcase(request);
78
- return IModelDb_1.BriefcaseDb.open(props);
79
- }
80
- static async openBriefcase(args) {
81
- if (this._briefcasePromise)
82
- return this._briefcasePromise;
83
- try {
84
- this._briefcasePromise = this.downloadAndOpen(args); // save the fact that we're working on downloading so if we timeout, we'll reuse this request.
85
- return await this._briefcasePromise;
86
- }
87
- finally {
88
- this._briefcasePromise = undefined; // the download and open is now done
89
- }
90
- }
91
- /** find a previously opened iModel for RPC.
92
- * @param accessToken necessary (only) for V2 checkpoints to refresh access token in daemon if it has expired. We use the accessToken of the current RPC request
93
- * to refresh the daemon, even though it will be used for all authorized users.
94
- * @param the IModelRpcProps to locate the opened iModel.
95
- */
96
- static async findOpenIModel(accessToken, iModel) {
97
- const iModelDb = IModelDb_1.IModelDb.findByKey(iModel.key);
98
- // call refreshContainerSas, just in case this is a V2 checkpoint whose sasToken is about to expire.
99
- await iModelDb.refreshContainerSas(accessToken);
100
- return iModelDb;
101
- }
102
- /**
103
- * Download and open a checkpoint or briefcase, ensuring the operation completes within a default timeout. If the time to open exceeds the timeout period,
104
- * a RpcPendingResponse exception is thrown
105
- */
106
- static async open(args) {
107
- const { activity, tokenProps, syncMode } = args;
108
- core_bentley_1.Logger.logTrace(loggerCategory, "RpcBriefcaseUtility.open", () => ({ ...tokenProps }));
109
- const timeout = args.timeout ?? 1000;
110
- if (syncMode === core_common_1.SyncMode.PullOnly || syncMode === core_common_1.SyncMode.PullAndPush) {
111
- const briefcaseDb = await core_bentley_1.BeDuration.race(timeout, this.openBriefcase(args));
112
- if (briefcaseDb === undefined) {
113
- core_bentley_1.Logger.logTrace(loggerCategory, "Open briefcase - pending", () => ({ ...tokenProps }));
114
- throw new core_common_1.RpcPendingResponse(); // eslint-disable-line deprecation/deprecation
115
- }
116
- // note: usage is logged in the function BriefcaseManager.downloadNewBriefcaseAndOpen
117
- return briefcaseDb;
118
- }
119
- (0, core_bentley_1.assert)(undefined !== tokenProps.iModelId);
120
- (0, core_bentley_1.assert)(undefined !== tokenProps.iTwinId);
121
- (0, core_bentley_1.assert)(undefined !== tokenProps.changeset);
122
- const checkpoint = {
123
- iModelId: tokenProps.iModelId,
124
- iTwinId: tokenProps.iTwinId,
125
- changeset: tokenProps.changeset,
126
- accessToken: activity.accessToken,
127
- };
128
- // opening a checkpoint, readonly.
129
- let db;
130
- // first check if it's already open
131
- db = IModelDb_1.SnapshotDb.tryFindByKey(CheckpointManager_1.CheckpointManager.getKey(checkpoint));
132
- if (db) {
133
- core_bentley_1.Logger.logTrace(loggerCategory, "Checkpoint was already open", () => ({ ...tokenProps }));
134
- BriefcaseManager_1.BriefcaseManager.logUsage(db);
135
- return db;
136
- }
137
- try {
138
- // now try V2 checkpoint
139
- db = await IModelDb_1.SnapshotDb.openCheckpointV2(checkpoint);
140
- core_bentley_1.Logger.logTrace(loggerCategory, "using V2 checkpoint briefcase", () => ({ ...tokenProps }));
141
- }
142
- catch (e) {
143
- core_bentley_1.Logger.logTrace(loggerCategory, "unable to open V2 checkpoint - falling back to V1 checkpoint", () => ({ error: core_bentley_1.BentleyError.getErrorProps(e), ...tokenProps }));
144
- // this isn't a v2 checkpoint. Set up a race between the specified timeout period and the open. Throw an RpcPendingResponse exception if the timeout happens first.
145
- const request = {
146
- checkpoint,
147
- localFile: CheckpointManager_1.V1CheckpointManager.getFileName(checkpoint),
148
- aliasFiles: [],
149
- };
150
- db = await core_bentley_1.BeDuration.race(timeout, CheckpointManager_1.V1CheckpointManager.getCheckpointDb(request));
151
- if (db === undefined) {
152
- core_bentley_1.Logger.logTrace(loggerCategory, "Open V1 checkpoint - pending", () => ({ ...tokenProps }));
153
- throw new core_common_1.RpcPendingResponse(); // eslint-disable-line deprecation/deprecation
154
- }
155
- core_bentley_1.Logger.logTrace(loggerCategory, "Opened V1 checkpoint", () => ({ ...tokenProps }));
156
- }
157
- BriefcaseManager_1.BriefcaseManager.logUsage(db, activity);
158
- return db;
159
- }
160
- static async openWithTimeout(activity, tokenProps, syncMode, timeout = 1000) {
161
- if (tokenProps.iModelId)
162
- await IModelHost_1.IModelHost.tileStorage?.initialize(tokenProps.iModelId);
163
- return (await this.open({ activity, tokenProps, syncMode, timeout })).toJSON();
164
- }
165
- }
166
- exports.RpcBriefcaseUtility = RpcBriefcaseUtility;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.RpcBriefcaseUtility = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const BackendLoggerCategory_1 = require("../BackendLoggerCategory");
14
+ const BriefcaseManager_1 = require("../BriefcaseManager");
15
+ const CheckpointManager_1 = require("../CheckpointManager");
16
+ const IModelDb_1 = require("../IModelDb");
17
+ const IModelHost_1 = require("../IModelHost");
18
+ const IModelJsFs_1 = require("../IModelJsFs");
19
+ const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
20
+ /**
21
+ * Utility to open the iModel for RPC interfaces
22
+ * @internal
23
+ */
24
+ class RpcBriefcaseUtility {
25
+ static async downloadAndOpen(args) {
26
+ const { activity, tokenProps } = args;
27
+ const accessToken = activity.accessToken;
28
+ (0, core_bentley_1.assert)(undefined !== tokenProps.iModelId);
29
+ const iModelId = tokenProps.iModelId;
30
+ let myBriefcaseIds;
31
+ if (args.syncMode === core_common_1.SyncMode.PullOnly) {
32
+ myBriefcaseIds = [0]; // PullOnly means briefcaseId 0
33
+ }
34
+ else {
35
+ // check with iModelHub and see if we already have acquired any briefcaseIds
36
+ myBriefcaseIds = await IModelHost_1.IModelHost.hubAccess.getMyBriefcaseIds({ accessToken, iModelId });
37
+ }
38
+ const resolvers = args.fileNameResolvers ?? [(arg) => BriefcaseManager_1.BriefcaseManager.getFileName(arg)];
39
+ // see if we can open any of the briefcaseIds we already acquired from iModelHub
40
+ if (resolvers) {
41
+ for (const resolver of resolvers) {
42
+ for (const briefcaseId of myBriefcaseIds) {
43
+ const fileName = resolver({ briefcaseId, iModelId });
44
+ if (IModelJsFs_1.IModelJsFs.existsSync(fileName)) {
45
+ const briefcaseDb = IModelDb_1.BriefcaseDb.findByFilename(fileName);
46
+ if (briefcaseDb !== undefined)
47
+ return briefcaseDb;
48
+ try {
49
+ if (args.forceDownload)
50
+ throw new Error(); // causes delete below
51
+ const db = await IModelDb_1.BriefcaseDb.open({ fileName });
52
+ if (db.changeset.id !== tokenProps.changeset?.id) {
53
+ (0, core_bentley_1.assert)(undefined !== tokenProps.changeset);
54
+ const toIndex = tokenProps.changeset?.index ??
55
+ (await IModelHost_1.IModelHost.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version: core_common_1.IModelVersion.asOfChangeSet(tokenProps.changeset.id) })).index;
56
+ await BriefcaseManager_1.BriefcaseManager.pullAndApplyChangesets(db, { accessToken, toIndex });
57
+ }
58
+ return db;
59
+ }
60
+ catch (error) {
61
+ if (!(error.errorNumber === core_bentley_1.IModelStatus.AlreadyOpen))
62
+ // somehow we have this briefcaseId and the file exists, but we can't open it. Delete it.
63
+ await BriefcaseManager_1.BriefcaseManager.deleteBriefcaseFiles(fileName, accessToken);
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ // no local briefcase available. Download one and open it.
70
+ (0, core_bentley_1.assert)(undefined !== tokenProps.iTwinId);
71
+ const request = {
72
+ accessToken,
73
+ iTwinId: tokenProps.iTwinId,
74
+ iModelId,
75
+ briefcaseId: args.syncMode === core_common_1.SyncMode.PullOnly ? 0 : undefined, // if briefcaseId is undefined, we'll acquire a new one.
76
+ };
77
+ const props = await BriefcaseManager_1.BriefcaseManager.downloadBriefcase(request);
78
+ return IModelDb_1.BriefcaseDb.open(props);
79
+ }
80
+ static async openBriefcase(args) {
81
+ if (this._briefcasePromise)
82
+ return this._briefcasePromise;
83
+ try {
84
+ this._briefcasePromise = this.downloadAndOpen(args); // save the fact that we're working on downloading so if we timeout, we'll reuse this request.
85
+ return await this._briefcasePromise;
86
+ }
87
+ finally {
88
+ this._briefcasePromise = undefined; // the download and open is now done
89
+ }
90
+ }
91
+ /** find a previously opened iModel for RPC.
92
+ * @param accessToken necessary (only) for V2 checkpoints to refresh access token in daemon if it has expired. We use the accessToken of the current RPC request
93
+ * to refresh the daemon, even though it will be used for all authorized users.
94
+ * @param the IModelRpcProps to locate the opened iModel.
95
+ */
96
+ static async findOpenIModel(accessToken, iModel) {
97
+ const iModelDb = IModelDb_1.IModelDb.findByKey(iModel.key);
98
+ // call refreshContainerSas, just in case this is a V2 checkpoint whose sasToken is about to expire.
99
+ await iModelDb.refreshContainerSas(accessToken);
100
+ return iModelDb;
101
+ }
102
+ /**
103
+ * Download and open a checkpoint or briefcase, ensuring the operation completes within a default timeout. If the time to open exceeds the timeout period,
104
+ * a RpcPendingResponse exception is thrown
105
+ */
106
+ static async open(args) {
107
+ const { activity, tokenProps, syncMode } = args;
108
+ core_bentley_1.Logger.logTrace(loggerCategory, "RpcBriefcaseUtility.open", () => ({ ...tokenProps }));
109
+ const timeout = args.timeout ?? 1000;
110
+ if (syncMode === core_common_1.SyncMode.PullOnly || syncMode === core_common_1.SyncMode.PullAndPush) {
111
+ const briefcaseDb = await core_bentley_1.BeDuration.race(timeout, this.openBriefcase(args));
112
+ if (briefcaseDb === undefined) {
113
+ core_bentley_1.Logger.logTrace(loggerCategory, "Open briefcase - pending", () => ({ ...tokenProps }));
114
+ throw new core_common_1.RpcPendingResponse(); // eslint-disable-line deprecation/deprecation
115
+ }
116
+ // note: usage is logged in the function BriefcaseManager.downloadNewBriefcaseAndOpen
117
+ return briefcaseDb;
118
+ }
119
+ (0, core_bentley_1.assert)(undefined !== tokenProps.iModelId);
120
+ (0, core_bentley_1.assert)(undefined !== tokenProps.iTwinId);
121
+ (0, core_bentley_1.assert)(undefined !== tokenProps.changeset);
122
+ const checkpoint = {
123
+ iModelId: tokenProps.iModelId,
124
+ iTwinId: tokenProps.iTwinId,
125
+ changeset: tokenProps.changeset,
126
+ accessToken: activity.accessToken,
127
+ };
128
+ // opening a checkpoint, readonly.
129
+ let db;
130
+ // first check if it's already open
131
+ db = IModelDb_1.SnapshotDb.tryFindByKey(CheckpointManager_1.CheckpointManager.getKey(checkpoint));
132
+ if (db) {
133
+ core_bentley_1.Logger.logTrace(loggerCategory, "Checkpoint was already open", () => ({ ...tokenProps }));
134
+ BriefcaseManager_1.BriefcaseManager.logUsage(db);
135
+ return db;
136
+ }
137
+ try {
138
+ // now try V2 checkpoint
139
+ db = await IModelDb_1.SnapshotDb.openCheckpointV2(checkpoint);
140
+ core_bentley_1.Logger.logTrace(loggerCategory, "using V2 checkpoint briefcase", () => ({ ...tokenProps }));
141
+ }
142
+ catch (e) {
143
+ core_bentley_1.Logger.logTrace(loggerCategory, "unable to open V2 checkpoint - falling back to V1 checkpoint", () => ({ error: core_bentley_1.BentleyError.getErrorProps(e), ...tokenProps }));
144
+ // this isn't a v2 checkpoint. Set up a race between the specified timeout period and the open. Throw an RpcPendingResponse exception if the timeout happens first.
145
+ const request = {
146
+ checkpoint,
147
+ localFile: CheckpointManager_1.V1CheckpointManager.getFileName(checkpoint),
148
+ aliasFiles: [],
149
+ };
150
+ db = await core_bentley_1.BeDuration.race(timeout, CheckpointManager_1.V1CheckpointManager.getCheckpointDb(request));
151
+ if (db === undefined) {
152
+ core_bentley_1.Logger.logTrace(loggerCategory, "Open V1 checkpoint - pending", () => ({ ...tokenProps }));
153
+ throw new core_common_1.RpcPendingResponse(); // eslint-disable-line deprecation/deprecation
154
+ }
155
+ core_bentley_1.Logger.logTrace(loggerCategory, "Opened V1 checkpoint", () => ({ ...tokenProps }));
156
+ }
157
+ BriefcaseManager_1.BriefcaseManager.logUsage(db, activity);
158
+ return db;
159
+ }
160
+ static async openWithTimeout(activity, tokenProps, syncMode, timeout = 1000) {
161
+ if (tokenProps.iModelId)
162
+ await IModelHost_1.IModelHost.tileStorage?.initialize(tokenProps.iModelId);
163
+ return (await this.open({ activity, tokenProps, syncMode, timeout })).toJSON();
164
+ }
165
+ }
166
+ exports.RpcBriefcaseUtility = RpcBriefcaseUtility;
167
167
  //# sourceMappingURL=RpcBriefcaseUtility.js.map
@@ -1,17 +1,17 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- import { IModelConnectionProps, IModelRpcProps, RpcInterface, SnapshotIModelRpcInterface, SnapshotOpenOptions } from "@itwin/core-common";
5
- /** The backend implementation of SnapshotIModelRpcInterface.
6
- * @internal
7
- */
8
- export declare class SnapshotIModelRpcImpl extends RpcInterface implements SnapshotIModelRpcInterface {
9
- static register(): void;
10
- /** Ask the backend to open a snapshot iModel from a file name that is resolved by the backend. */
11
- openFile(filePath: string, opts?: SnapshotOpenOptions): Promise<IModelConnectionProps>;
12
- /** Ask the backend to open a snapshot iModel from a key that is resolved by the backend. */
13
- openRemote(fileKey: string, opts?: SnapshotOpenOptions): Promise<IModelConnectionProps>;
14
- /** Ask the backend to close a snapshot iModel. */
15
- close(tokenProps: IModelRpcProps): Promise<boolean>;
16
- }
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { IModelConnectionProps, IModelRpcProps, RpcInterface, SnapshotIModelRpcInterface, SnapshotOpenOptions } from "@itwin/core-common";
5
+ /** The backend implementation of SnapshotIModelRpcInterface.
6
+ * @internal
7
+ */
8
+ export declare class SnapshotIModelRpcImpl extends RpcInterface implements SnapshotIModelRpcInterface {
9
+ static register(): void;
10
+ /** Ask the backend to open a snapshot iModel from a file name that is resolved by the backend. */
11
+ openFile(filePath: string, opts?: SnapshotOpenOptions): Promise<IModelConnectionProps>;
12
+ /** Ask the backend to open a snapshot iModel from a key that is resolved by the backend. */
13
+ openRemote(fileKey: string, opts?: SnapshotOpenOptions): Promise<IModelConnectionProps>;
14
+ /** Ask the backend to close a snapshot iModel. */
15
+ close(tokenProps: IModelRpcProps): Promise<boolean>;
16
+ }
17
17
  //# sourceMappingURL=SnapshotIModelRpcImpl.d.ts.map
@@ -1,43 +1,43 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.SnapshotIModelRpcImpl = void 0;
11
- const core_common_1 = require("@itwin/core-common");
12
- const IModelDb_1 = require("../IModelDb");
13
- const IModelHost_1 = require("../IModelHost");
14
- /** The backend implementation of SnapshotIModelRpcInterface.
15
- * @internal
16
- */
17
- class SnapshotIModelRpcImpl extends core_common_1.RpcInterface {
18
- static register() { core_common_1.RpcManager.registerImpl(core_common_1.SnapshotIModelRpcInterface, SnapshotIModelRpcImpl); }
19
- /** Ask the backend to open a snapshot iModel from a file name that is resolved by the backend. */
20
- async openFile(filePath, opts) {
21
- let resolvedFileName = filePath;
22
- if (IModelHost_1.IModelHost.snapshotFileNameResolver) {
23
- resolvedFileName = IModelHost_1.IModelHost.snapshotFileNameResolver.tryResolveFileName(filePath);
24
- if (undefined === resolvedFileName)
25
- throw new core_common_1.IModelNotFoundResponse();
26
- }
27
- return IModelDb_1.SnapshotDb.openFile(resolvedFileName, opts).getConnectionProps();
28
- }
29
- /** Ask the backend to open a snapshot iModel from a key that is resolved by the backend. */
30
- async openRemote(fileKey, opts) {
31
- const resolvedFileName = IModelHost_1.IModelHost.snapshotFileNameResolver?.resolveKey(fileKey);
32
- if (undefined === resolvedFileName)
33
- throw new core_common_1.IModelNotFoundResponse();
34
- return IModelDb_1.SnapshotDb.openFile(resolvedFileName, { key: fileKey, ...opts }).getConnectionProps();
35
- }
36
- /** Ask the backend to close a snapshot iModel. */
37
- async close(tokenProps) {
38
- IModelDb_1.SnapshotDb.findByKey(tokenProps.key).close();
39
- return true;
40
- }
41
- }
42
- exports.SnapshotIModelRpcImpl = SnapshotIModelRpcImpl;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SnapshotIModelRpcImpl = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const IModelDb_1 = require("../IModelDb");
13
+ const IModelHost_1 = require("../IModelHost");
14
+ /** The backend implementation of SnapshotIModelRpcInterface.
15
+ * @internal
16
+ */
17
+ class SnapshotIModelRpcImpl extends core_common_1.RpcInterface {
18
+ static register() { core_common_1.RpcManager.registerImpl(core_common_1.SnapshotIModelRpcInterface, SnapshotIModelRpcImpl); }
19
+ /** Ask the backend to open a snapshot iModel from a file name that is resolved by the backend. */
20
+ async openFile(filePath, opts) {
21
+ let resolvedFileName = filePath;
22
+ if (IModelHost_1.IModelHost.snapshotFileNameResolver) {
23
+ resolvedFileName = IModelHost_1.IModelHost.snapshotFileNameResolver.tryResolveFileName(filePath);
24
+ if (undefined === resolvedFileName)
25
+ throw new core_common_1.IModelNotFoundResponse();
26
+ }
27
+ return IModelDb_1.SnapshotDb.openFile(resolvedFileName, opts).getConnectionProps();
28
+ }
29
+ /** Ask the backend to open a snapshot iModel from a key that is resolved by the backend. */
30
+ async openRemote(fileKey, opts) {
31
+ const resolvedFileName = IModelHost_1.IModelHost.snapshotFileNameResolver?.resolveKey(fileKey);
32
+ if (undefined === resolvedFileName)
33
+ throw new core_common_1.IModelNotFoundResponse();
34
+ return IModelDb_1.SnapshotDb.openFile(resolvedFileName, { key: fileKey, ...opts }).getConnectionProps();
35
+ }
36
+ /** Ask the backend to close a snapshot iModel. */
37
+ async close(tokenProps) {
38
+ IModelDb_1.SnapshotDb.findByKey(tokenProps.key).close();
39
+ return true;
40
+ }
41
+ }
42
+ exports.SnapshotIModelRpcImpl = SnapshotIModelRpcImpl;
43
43
  //# sourceMappingURL=SnapshotIModelRpcImpl.js.map