@itwin/core-frontend 4.5.0-dev.7 → 4.5.0-dev.9
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.
- package/CHANGELOG.md +33 -1
- package/lib/cjs/CheckpointConnection.d.ts +7 -7
- package/lib/cjs/CheckpointConnection.d.ts.map +1 -1
- package/lib/cjs/CheckpointConnection.js +31 -23
- package/lib/cjs/CheckpointConnection.js.map +1 -1
- package/lib/esm/CheckpointConnection.d.ts +7 -7
- package/lib/esm/CheckpointConnection.d.ts.map +1 -1
- package/lib/esm/CheckpointConnection.js +31 -23
- package/lib/esm/CheckpointConnection.js.map +1 -1
- package/package.json +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
# Change Log - @itwin/core-frontend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 12 Feb 2024 19:26:22 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.4.0
|
|
6
|
+
Mon, 12 Feb 2024 18:15:58 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Add SQ_KM to UNIT_DATA
|
|
11
|
+
- Add support to create an EcefLocation class directly from a transformation matrix
|
|
12
|
+
- Added support for recoloring geometry intersecting a clip volume
|
|
13
|
+
- Bump @itwin/object-storage-core
|
|
14
|
+
- Add textures to reality mesh stats
|
|
15
|
+
- Promote APIs required to implement a MapLayerFormat to beta
|
|
16
|
+
- Fix status code when invalid credentials are provided for an ArcGIS service.
|
|
17
|
+
- Fixed an issue preventing tiles published by some specific ArcGIS MapServer to be correctly displayed in the view.
|
|
18
|
+
- Fix Map Feature Info for ArcGIS map services when reprojection is needed.
|
|
19
|
+
- Enable Kerberos authentication for map-layers
|
|
20
|
+
- Custom query parameters can now be configured on map layers objects.
|
|
21
|
+
- Expose `ParticleCollectionBuilder` for extensions
|
|
22
|
+
- Improved ArcGIS feature info coordinates reprojection outside project extent.
|
|
23
|
+
- Improved content type detection for 3D Tiles tilesets.
|
|
24
|
+
- Updated realitydata url to new reality-management API url. Added tests for new url.
|
|
25
|
+
- Add support for glTF 2.0 EXT_mesh_gpu_instancing and fix incorrectly computed glTF bounding boxes.
|
|
26
|
+
- Add support for transparent gradients in thematic display and analysis styles.
|
|
27
|
+
- Added Viewport.onSceneInvalidated event raised when Viewport.invalidateScene is called.
|
|
28
|
+
- Fix SpatialModelState.isRealityModel returning false for reality models that don't store a tileset URL.
|
|
29
|
+
- When assigning to SpatialViewState.modelSelector, notify tile tree references of the change.
|
|
30
|
+
- Enable display of all subcategories for non-scene decorations.
|
|
31
|
+
- Add RealityTileTree.batchTableProperties for accessing per-feature properties from 3D Tiles 1.0 tilesets.
|
|
32
|
+
- Add DisplayStyleState iterator over context reality models.
|
|
33
|
+
- Fix incorrect transparency for text rendered as raster glyphs.
|
|
34
|
+
- Remove maximum depth constraint for reality tile trees.
|
|
35
|
+
- Clone view attachments when cloning a sheet or drawing view.
|
|
4
36
|
|
|
5
37
|
## 4.3.3
|
|
6
38
|
Wed, 03 Jan 2024 19:28:38 GMT
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
* @module IModelConnection
|
|
3
3
|
*/
|
|
4
4
|
import { GuidString } from "@itwin/core-bentley";
|
|
5
|
-
import { IModelVersion } from "@itwin/core-common";
|
|
5
|
+
import { IModelConnectionProps, IModelVersion } from "@itwin/core-common";
|
|
6
6
|
import { IModelConnection } from "./IModelConnection";
|
|
7
7
|
/**
|
|
8
|
-
* An IModelConnection to a
|
|
9
|
-
*
|
|
10
|
-
* at servicing requests at the same time. For this reason, this type of connection may only be used with Checkpoint iModels that are
|
|
11
|
-
* guaranteed to be the same on every backend. Obviously Checkpoint iModels only allow readonly access.
|
|
8
|
+
* An IModelConnection to a Checkpoint of an iModel.
|
|
9
|
+
* @see [CheckpointConnection]($docs/learning/frontend/IModelConnection)
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
12
|
export declare class CheckpointConnection extends IModelConnection {
|
|
13
|
+
private readonly _fromIpc;
|
|
15
14
|
/** The Guid that identifies the iTwin that owns this iModel. */
|
|
16
15
|
get iTwinId(): GuidString;
|
|
17
16
|
/** The Guid that identifies this iModel. */
|
|
@@ -19,12 +18,13 @@ export declare class CheckpointConnection extends IModelConnection {
|
|
|
19
18
|
/** Returns `true` if [[close]] has already been called. */
|
|
20
19
|
get isClosed(): boolean;
|
|
21
20
|
protected _isClosed?: boolean;
|
|
21
|
+
protected constructor(props: IModelConnectionProps, fromIpc: boolean);
|
|
22
22
|
/** Type guard for instanceof [[CheckpointConnection]] */
|
|
23
23
|
isCheckpointConnection(): this is CheckpointConnection;
|
|
24
24
|
/**
|
|
25
|
-
* Open a readonly IModelConnection to an iModel
|
|
25
|
+
* Open a readonly IModelConnection to a Checkpoint of an iModel.
|
|
26
26
|
*/
|
|
27
|
-
static openRemote(iTwinId:
|
|
27
|
+
static openRemote(iTwinId: GuidString, iModelId: GuidString, version?: IModelVersion): Promise<CheckpointConnection>;
|
|
28
28
|
private static callOpen;
|
|
29
29
|
private _reopenConnectionHandler;
|
|
30
30
|
/** Close this CheckpointConnection */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckpointConnection.d.ts","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA+B,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckpointConnection.d.ts","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA+B,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACL,qBAAqB,EAA2D,aAAa,EAE9F,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC,gEAAgE;IAChE,IAAoB,OAAO,IAAI,UAAU,CAA2B;IACpE,4CAA4C;IAC5C,IAAoB,QAAQ,IAAI,UAAU,CAA4B;IAEtE,2DAA2D;IAC3D,IAAW,QAAQ,IAAI,OAAO,CAA0C;IACxE,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE9B,SAAS,aAAa,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO;IAKpE,yDAAyD;IACzC,sBAAsB,IAAI,IAAI,IAAI,oBAAoB;IAEtE;;OAEG;WACiB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,gBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC;mBAuBrH,QAAQ;IA+C7B,OAAO,CAAC,wBAAwB,CAwB9B;IAEF,sCAAsC;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
|
|
@@ -14,17 +14,22 @@ const FrontendLoggerCategory_1 = require("./common/FrontendLoggerCategory");
|
|
|
14
14
|
const IModelApp_1 = require("./IModelApp");
|
|
15
15
|
const IModelConnection_1 = require("./IModelConnection");
|
|
16
16
|
const IModelRoutingContext_1 = require("./IModelRoutingContext");
|
|
17
|
+
const IpcApp_1 = require("./IpcApp");
|
|
17
18
|
const loggerCategory = FrontendLoggerCategory_1.FrontendLoggerCategory.IModelConnection;
|
|
18
19
|
/**
|
|
19
|
-
* An IModelConnection to a
|
|
20
|
-
*
|
|
21
|
-
* at servicing requests at the same time. For this reason, this type of connection may only be used with Checkpoint iModels that are
|
|
22
|
-
* guaranteed to be the same on every backend. Obviously Checkpoint iModels only allow readonly access.
|
|
20
|
+
* An IModelConnection to a Checkpoint of an iModel.
|
|
21
|
+
* @see [CheckpointConnection]($docs/learning/frontend/IModelConnection)
|
|
23
22
|
* @public
|
|
24
23
|
*/
|
|
25
24
|
class CheckpointConnection extends IModelConnection_1.IModelConnection {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
/** The Guid that identifies the iTwin that owns this iModel. */
|
|
26
|
+
get iTwinId() { return super.iTwinId; }
|
|
27
|
+
/** The Guid that identifies this iModel. */
|
|
28
|
+
get iModelId() { return super.iModelId; }
|
|
29
|
+
/** Returns `true` if [[close]] has already been called. */
|
|
30
|
+
get isClosed() { return this._isClosed ? true : false; }
|
|
31
|
+
constructor(props, fromIpc) {
|
|
32
|
+
super(props);
|
|
28
33
|
this._reopenConnectionHandler = async (request, response, resubmit, reject) => {
|
|
29
34
|
if (!response.hasOwnProperty("isIModelNotFoundResponse"))
|
|
30
35
|
return;
|
|
@@ -47,30 +52,30 @@ class CheckpointConnection extends IModelConnection_1.IModelConnection {
|
|
|
47
52
|
request.parameters[0] = this.getRpcProps(); // Modify the token of the original request before resubmitting it.
|
|
48
53
|
resubmit();
|
|
49
54
|
};
|
|
55
|
+
this._fromIpc = fromIpc;
|
|
50
56
|
}
|
|
51
|
-
/** The Guid that identifies the iTwin that owns this iModel. */
|
|
52
|
-
get iTwinId() { return super.iTwinId; }
|
|
53
|
-
/** The Guid that identifies this iModel. */
|
|
54
|
-
get iModelId() { return super.iModelId; }
|
|
55
|
-
/** Returns `true` if [[close]] has already been called. */
|
|
56
|
-
get isClosed() { return this._isClosed ? true : false; }
|
|
57
57
|
/** Type guard for instanceof [[CheckpointConnection]] */
|
|
58
58
|
isCheckpointConnection() { return true; }
|
|
59
59
|
/**
|
|
60
|
-
* Open a readonly IModelConnection to an iModel
|
|
60
|
+
* Open a readonly IModelConnection to a Checkpoint of an iModel.
|
|
61
61
|
*/
|
|
62
62
|
static async openRemote(iTwinId, iModelId, version = core_common_1.IModelVersion.latest()) {
|
|
63
|
-
const routingContext = IModelRoutingContext_1.IModelRoutingContext.current || IModelRoutingContext_1.IModelRoutingContext.default;
|
|
64
|
-
const accessToken = await IModelApp_1.IModelApp.getAccessToken();
|
|
65
63
|
if (undefined === IModelApp_1.IModelApp.hubAccess)
|
|
66
|
-
throw new Error("Missing an implementation of
|
|
64
|
+
throw new Error("Missing an implementation of IModelApp.hubAccess");
|
|
65
|
+
const accessToken = await IModelApp_1.IModelApp.getAccessToken();
|
|
67
66
|
const changeset = await IModelApp_1.IModelApp.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version });
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
let connection;
|
|
68
|
+
const iModelProps = { iTwinId, iModelId, changeset };
|
|
69
|
+
if (IpcApp_1.IpcApp.isValid) {
|
|
70
|
+
connection = new this(await IpcApp_1.IpcApp.appFunctionIpc.openCheckpoint(iModelProps), true);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const routingContext = IModelRoutingContext_1.IModelRoutingContext.current || IModelRoutingContext_1.IModelRoutingContext.default;
|
|
74
|
+
connection = new this(await this.callOpen(iModelProps, routingContext), false);
|
|
75
|
+
core_common_1.RpcManager.setIModel(connection);
|
|
76
|
+
connection.routingContext = routingContext;
|
|
77
|
+
core_common_1.RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);
|
|
78
|
+
}
|
|
74
79
|
IModelConnection_1.IModelConnection.onOpen.raiseEvent(connection);
|
|
75
80
|
return connection;
|
|
76
81
|
}
|
|
@@ -118,7 +123,10 @@ class CheckpointConnection extends IModelConnection_1.IModelConnection {
|
|
|
118
123
|
if (this.isClosed)
|
|
119
124
|
return;
|
|
120
125
|
this.beforeClose();
|
|
121
|
-
|
|
126
|
+
if (this._fromIpc)
|
|
127
|
+
await IpcApp_1.IpcApp.appFunctionIpc.closeIModel(this._fileKey);
|
|
128
|
+
else
|
|
129
|
+
core_common_1.RpcRequest.notFoundHandlers.removeListener(this._reopenConnectionHandler);
|
|
122
130
|
this._isClosed = true;
|
|
123
131
|
}
|
|
124
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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C,wBAAwB,CAAC,CAAC;QAC1E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AAvHD,oDAuHC","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 IModelConnection\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelConnectionProps, IModelError, IModelReadRpcInterface, IModelRpcOpenProps, IModelVersion, RpcManager, RpcNotFoundResponse, RpcOperation,\r\n RpcRequest, RpcRequestEvent,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IModelRoutingContext } from \"./IModelRoutingContext\";\r\n\r\nconst loggerCategory = FrontendLoggerCategory.IModelConnection;\r\n\r\n/**\r\n * An IModelConnection to a checkpoint of an iModel, hosted on a remote backend over RPC.\r\n * Due to the nature of RPC requests, the backend servicing this connection may change over time, and there may even be more than one backend\r\n * at servicing requests at the same time. For this reason, this type of connection may only be used with Checkpoint iModels that are\r\n * guaranteed to be the same on every backend. Obviously Checkpoint iModels only allow readonly access.\r\n * @public\r\n */\r\nexport class CheckpointConnection extends IModelConnection {\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; }\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed ? true : false; }\r\n protected _isClosed?: boolean;\r\n\r\n /** Type guard for instanceof [[CheckpointConnection]] */\r\n public override isCheckpointConnection(): this is CheckpointConnection { return true; }\r\n\r\n /**\r\n * Open a readonly IModelConnection to an iModel over RPC.\r\n */\r\n public static async openRemote(iTwinId: string, iModelId: string, version: IModelVersion = IModelVersion.latest()): Promise<CheckpointConnection> {\r\n const routingContext = IModelRoutingContext.current || IModelRoutingContext.default;\r\n const accessToken = await IModelApp.getAccessToken();\r\n\r\n if (undefined === IModelApp.hubAccess)\r\n throw new Error(\"Missing an implementation of FrontendHubAccess on IModelApp, it is required to open a remote iModel Connection. Please provide an implementation to the IModelApp.startup using IModelAppOptions.hubAccess.\");\r\n\r\n const changeset = await IModelApp.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version });\r\n\r\n const iModelRpcProps: IModelRpcOpenProps = { iTwinId, iModelId, changeset };\r\n const openResponse = await this.callOpen(iModelRpcProps, routingContext);\r\n\r\n const connection = new this(openResponse);\r\n RpcManager.setIModel(connection);\r\n connection.routingContext = routingContext;\r\n RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n private static async callOpen(iModelToken: IModelRpcOpenProps, routingContext: IModelRoutingContext): Promise<IModelConnectionProps> {\r\n // Try opening the iModel repeatedly accommodating any pending responses from the backend.\r\n // Waits for an increasing amount of time (but within a range) before checking on the pending request again.\r\n const connectionRetryIntervalRange = { min: 100, max: 5000 }; // in milliseconds\r\n let connectionRetryInterval = Math.min(connectionRetryIntervalRange.min, IModelConnection.connectionTimeout);\r\n\r\n const openForReadOperation = RpcOperation.lookup(IModelReadRpcInterface, \"getConnectionProps\");\r\n if (!openForReadOperation)\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelReadRpcInterface.getConnectionProps() is not available\");\r\n openForReadOperation.policy.retryInterval = () => connectionRetryInterval;\r\n\r\n Logger.logTrace(loggerCategory, `IModelConnection.open`, iModelToken);\r\n const startTime = Date.now();\r\n\r\n const removeListener = RpcRequest.events.addListener((type: RpcRequestEvent, request: RpcRequest) => { // eslint-disable-line deprecation/deprecation\r\n if (type !== RpcRequestEvent.PendingUpdateReceived) // eslint-disable-line deprecation/deprecation\r\n return;\r\n if (!(openForReadOperation && request.operation === openForReadOperation))\r\n return;\r\n\r\n Logger.logTrace(loggerCategory, \"Received pending open notification in IModelConnection.open\", iModelToken);\r\n\r\n const connectionTimeElapsed = Date.now() - startTime;\r\n if (connectionTimeElapsed > IModelConnection.connectionTimeout) {\r\n Logger.logError(loggerCategory, `Timed out opening connection in IModelConnection.open (took longer than ${IModelConnection.connectionTimeout} milliseconds)`, iModelToken);\r\n throw new IModelError(BentleyStatus.ERROR, \"Opening a connection was timed out\"); // NEEDS_WORK: More specific error status\r\n }\r\n\r\n connectionRetryInterval = Math.min(connectionRetryIntervalRange.max, connectionRetryInterval * 2, IModelConnection.connectionTimeout - connectionTimeElapsed);\r\n if (request.retryInterval !== connectionRetryInterval) {\r\n request.retryInterval = connectionRetryInterval;\r\n Logger.logTrace(loggerCategory, `Adjusted open connection retry interval to ${request.retryInterval} milliseconds in IModelConnection.open`, iModelToken);\r\n }\r\n });\r\n\r\n const openPromise = IModelReadRpcInterface.getClientForRouting(routingContext.token).getConnectionProps(iModelToken);\r\n let openResponse: IModelConnectionProps;\r\n try {\r\n openResponse = await openPromise;\r\n } finally {\r\n Logger.logTrace(loggerCategory, \"Completed open request in IModelConnection.open\", iModelToken);\r\n removeListener();\r\n }\r\n\r\n return openResponse;\r\n }\r\n\r\n private _reopenConnectionHandler = async (request: RpcRequest<RpcNotFoundResponse>, response: any, resubmit: () => void, reject: (reason: any) => void) => { // eslint-disable-line deprecation/deprecation\r\n if (!response.hasOwnProperty(\"isIModelNotFoundResponse\"))\r\n return;\r\n\r\n const iModelRpcProps = request.parameters[0];\r\n if (this._fileKey !== iModelRpcProps.key)\r\n return; // The handler is called for a different connection than this\r\n\r\n Logger.logTrace(loggerCategory, \"Attempting to reopen connection\", () => iModelRpcProps);\r\n\r\n try {\r\n const openResponse = await CheckpointConnection.callOpen(iModelRpcProps, this.routingContext);\r\n // The new/reopened connection may have a new rpcKey and/or changesetId, but the other IModelRpcTokenProps should be the same\r\n this._fileKey = openResponse.key;\r\n this.changeset = openResponse.changeset!;\r\n\r\n } catch (error) {\r\n reject(BentleyError.getErrorMessage(error));\r\n } finally {\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"Resubmitting original request after reopening connection\", iModelRpcProps);\r\n request.parameters[0] = this.getRpcProps(); // Modify the token of the original request before resubmitting it.\r\n resubmit();\r\n };\r\n\r\n /** Close this CheckpointConnection */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n this.beforeClose();\r\n RpcRequest.notFoundHandlers.removeListener(this._reopenConnectionHandler);\r\n this._isClosed = true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CheckpointConnection.js","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAsF;AACtF,oDAG4B;AAC5B,4EAAyE;AACzE,2CAAwC;AACxC,yDAAsD;AACtD,iEAA8D;AAC9D,qCAAkC;AAElC,MAAM,cAAc,GAAG,+CAAsB,CAAC,gBAAgB,CAAC;AAE/D;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,mCAAgB;IAGxD,gEAAgE;IAChE,IAAoB,OAAO,KAAiB,OAAO,KAAK,CAAC,OAAQ,CAAC,CAAC,CAAC;IACpE,4CAA4C;IAC5C,IAAoB,QAAQ,KAAiB,OAAO,KAAK,CAAC,QAAS,CAAC,CAAC,CAAC;IAEtE,2DAA2D;IAC3D,IAAW,QAAQ,KAAc,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAGxE,YAAsB,KAA4B,EAAE,OAAgB;QAClE,KAAK,CAAC,KAAK,CAAC,CAAC;QAgFP,6BAAwB,GAAG,KAAK,EAAE,OAAwC,EAAE,QAAa,EAAE,QAAoB,EAAE,MAA6B,EAAE,EAA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AO,CAAC,aAAa,KAAK,uBAAuB,EAAE;gBACrD,OAAO,CAAC,aAAa,GAAG,uBAAuB,CAAC;gBAChD,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,8CAA8C,OAAO,CAAC,aAAa,wCAAwC,EAAE,WAAW,CAAC,CAAC;aAC3J;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,oCAAsB,CAAC,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACrH,IAAI,YAAmC,CAAC;QACxC,IAAI;YACF,YAAY,GAAG,MAAM,WAAW,CAAC;SAClC;gBAAS;YACR,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,iDAAiD,EAAE,WAAW,CAAC,CAAC;YAChG,cAAc,EAAE,CAAC;SAClB;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IA4BD,sCAAsC;IAC/B,KAAK,CAAC,KAAK;QAChB,IAAI,IAAI,CAAC,QAAQ;YACf,OAAO;QAET,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ;YACf,MAAM,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;YAEvD,wBAAU,CAAC,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAE5E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AApID,oDAoIC","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 IModelConnection\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelConnectionProps, IModelError, IModelReadRpcInterface, IModelRpcOpenProps, IModelVersion, RpcManager, RpcNotFoundResponse, RpcOperation,\r\n RpcRequest, RpcRequestEvent,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IModelRoutingContext } from \"./IModelRoutingContext\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nconst loggerCategory = FrontendLoggerCategory.IModelConnection;\r\n\r\n/**\r\n * An IModelConnection to a Checkpoint of an iModel.\r\n * @see [CheckpointConnection]($docs/learning/frontend/IModelConnection)\r\n * @public\r\n */\r\nexport class CheckpointConnection extends IModelConnection {\r\n private readonly _fromIpc: boolean;\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; }\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed ? true : false; }\r\n protected _isClosed?: boolean;\r\n\r\n protected constructor(props: IModelConnectionProps, fromIpc: boolean) {\r\n super(props);\r\n this._fromIpc = fromIpc;\r\n }\r\n\r\n /** Type guard for instanceof [[CheckpointConnection]] */\r\n public override isCheckpointConnection(): this is CheckpointConnection { return true; }\r\n\r\n /**\r\n * Open a readonly IModelConnection to a Checkpoint of an iModel.\r\n */\r\n public static async openRemote(iTwinId: GuidString, iModelId: GuidString, version = IModelVersion.latest()): Promise<CheckpointConnection> {\r\n if (undefined === IModelApp.hubAccess)\r\n throw new Error(\"Missing an implementation of IModelApp.hubAccess\");\r\n\r\n const accessToken = await IModelApp.getAccessToken();\r\n const changeset = await IModelApp.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version });\r\n\r\n let connection: CheckpointConnection;\r\n const iModelProps = { iTwinId, iModelId, changeset };\r\n if (IpcApp.isValid) {\r\n connection = new this(await IpcApp.appFunctionIpc.openCheckpoint(iModelProps), true);\r\n } else {\r\n const routingContext = IModelRoutingContext.current || IModelRoutingContext.default;\r\n connection = new this(await this.callOpen(iModelProps, routingContext), false);\r\n RpcManager.setIModel(connection);\r\n connection.routingContext = routingContext;\r\n RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);\r\n }\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n private static async callOpen(iModelToken: IModelRpcOpenProps, routingContext: IModelRoutingContext): Promise<IModelConnectionProps> {\r\n // Try opening the iModel repeatedly accommodating any pending responses from the backend.\r\n // Waits for an increasing amount of time (but within a range) before checking on the pending request again.\r\n const connectionRetryIntervalRange = { min: 100, max: 5000 }; // in milliseconds\r\n let connectionRetryInterval = Math.min(connectionRetryIntervalRange.min, IModelConnection.connectionTimeout);\r\n\r\n const openForReadOperation = RpcOperation.lookup(IModelReadRpcInterface, \"getConnectionProps\");\r\n if (!openForReadOperation)\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelReadRpcInterface.getConnectionProps() is not available\");\r\n openForReadOperation.policy.retryInterval = () => connectionRetryInterval;\r\n\r\n Logger.logTrace(loggerCategory, `IModelConnection.open`, iModelToken);\r\n const startTime = Date.now();\r\n\r\n const removeListener = RpcRequest.events.addListener((type: RpcRequestEvent, request: RpcRequest) => { // eslint-disable-line deprecation/deprecation\r\n if (type !== RpcRequestEvent.PendingUpdateReceived) // eslint-disable-line deprecation/deprecation\r\n return;\r\n if (!(openForReadOperation && request.operation === openForReadOperation))\r\n return;\r\n\r\n Logger.logTrace(loggerCategory, \"Received pending open notification in IModelConnection.open\", iModelToken);\r\n\r\n const connectionTimeElapsed = Date.now() - startTime;\r\n if (connectionTimeElapsed > IModelConnection.connectionTimeout) {\r\n Logger.logError(loggerCategory, `Timed out opening connection in IModelConnection.open (took longer than ${IModelConnection.connectionTimeout} milliseconds)`, iModelToken);\r\n throw new IModelError(BentleyStatus.ERROR, \"Opening a connection was timed out\"); // NEEDS_WORK: More specific error status\r\n }\r\n\r\n connectionRetryInterval = Math.min(connectionRetryIntervalRange.max, connectionRetryInterval * 2, IModelConnection.connectionTimeout - connectionTimeElapsed);\r\n if (request.retryInterval !== connectionRetryInterval) {\r\n request.retryInterval = connectionRetryInterval;\r\n Logger.logTrace(loggerCategory, `Adjusted open connection retry interval to ${request.retryInterval} milliseconds in IModelConnection.open`, iModelToken);\r\n }\r\n });\r\n\r\n const openPromise = IModelReadRpcInterface.getClientForRouting(routingContext.token).getConnectionProps(iModelToken);\r\n let openResponse: IModelConnectionProps;\r\n try {\r\n openResponse = await openPromise;\r\n } finally {\r\n Logger.logTrace(loggerCategory, \"Completed open request in IModelConnection.open\", iModelToken);\r\n removeListener();\r\n }\r\n\r\n return openResponse;\r\n }\r\n\r\n private _reopenConnectionHandler = async (request: RpcRequest<RpcNotFoundResponse>, response: any, resubmit: () => void, reject: (reason: any) => void) => { // eslint-disable-line deprecation/deprecation\r\n if (!response.hasOwnProperty(\"isIModelNotFoundResponse\"))\r\n return;\r\n\r\n const iModelRpcProps = request.parameters[0];\r\n if (this._fileKey !== iModelRpcProps.key)\r\n return; // The handler is called for a different connection than this\r\n\r\n Logger.logTrace(loggerCategory, \"Attempting to reopen connection\", () => iModelRpcProps);\r\n\r\n try {\r\n const openResponse = await CheckpointConnection.callOpen(iModelRpcProps, this.routingContext);\r\n // The new/reopened connection may have a new rpcKey and/or changesetId, but the other IModelRpcTokenProps should be the same\r\n this._fileKey = openResponse.key;\r\n this.changeset = openResponse.changeset!;\r\n\r\n } catch (error) {\r\n reject(BentleyError.getErrorMessage(error));\r\n } finally {\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"Resubmitting original request after reopening connection\", iModelRpcProps);\r\n request.parameters[0] = this.getRpcProps(); // Modify the token of the original request before resubmitting it.\r\n resubmit();\r\n };\r\n\r\n /** Close this CheckpointConnection */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n this.beforeClose();\r\n if (this._fromIpc)\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n else\r\n RpcRequest.notFoundHandlers.removeListener(this._reopenConnectionHandler);\r\n\r\n this._isClosed = true;\r\n }\r\n}\r\n"]}
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
* @module IModelConnection
|
|
3
3
|
*/
|
|
4
4
|
import { GuidString } from "@itwin/core-bentley";
|
|
5
|
-
import { IModelVersion } from "@itwin/core-common";
|
|
5
|
+
import { IModelConnectionProps, IModelVersion } from "@itwin/core-common";
|
|
6
6
|
import { IModelConnection } from "./IModelConnection";
|
|
7
7
|
/**
|
|
8
|
-
* An IModelConnection to a
|
|
9
|
-
*
|
|
10
|
-
* at servicing requests at the same time. For this reason, this type of connection may only be used with Checkpoint iModels that are
|
|
11
|
-
* guaranteed to be the same on every backend. Obviously Checkpoint iModels only allow readonly access.
|
|
8
|
+
* An IModelConnection to a Checkpoint of an iModel.
|
|
9
|
+
* @see [CheckpointConnection]($docs/learning/frontend/IModelConnection)
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
12
|
export declare class CheckpointConnection extends IModelConnection {
|
|
13
|
+
private readonly _fromIpc;
|
|
15
14
|
/** The Guid that identifies the iTwin that owns this iModel. */
|
|
16
15
|
get iTwinId(): GuidString;
|
|
17
16
|
/** The Guid that identifies this iModel. */
|
|
@@ -19,12 +18,13 @@ export declare class CheckpointConnection extends IModelConnection {
|
|
|
19
18
|
/** Returns `true` if [[close]] has already been called. */
|
|
20
19
|
get isClosed(): boolean;
|
|
21
20
|
protected _isClosed?: boolean;
|
|
21
|
+
protected constructor(props: IModelConnectionProps, fromIpc: boolean);
|
|
22
22
|
/** Type guard for instanceof [[CheckpointConnection]] */
|
|
23
23
|
isCheckpointConnection(): this is CheckpointConnection;
|
|
24
24
|
/**
|
|
25
|
-
* Open a readonly IModelConnection to an iModel
|
|
25
|
+
* Open a readonly IModelConnection to a Checkpoint of an iModel.
|
|
26
26
|
*/
|
|
27
|
-
static openRemote(iTwinId:
|
|
27
|
+
static openRemote(iTwinId: GuidString, iModelId: GuidString, version?: IModelVersion): Promise<CheckpointConnection>;
|
|
28
28
|
private static callOpen;
|
|
29
29
|
private _reopenConnectionHandler;
|
|
30
30
|
/** Close this CheckpointConnection */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckpointConnection.d.ts","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA+B,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckpointConnection.d.ts","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA+B,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACL,qBAAqB,EAA2D,aAAa,EAE9F,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC,gEAAgE;IAChE,IAAoB,OAAO,IAAI,UAAU,CAA2B;IACpE,4CAA4C;IAC5C,IAAoB,QAAQ,IAAI,UAAU,CAA4B;IAEtE,2DAA2D;IAC3D,IAAW,QAAQ,IAAI,OAAO,CAA0C;IACxE,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE9B,SAAS,aAAa,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO;IAKpE,yDAAyD;IACzC,sBAAsB,IAAI,IAAI,IAAI,oBAAoB;IAEtE;;OAEG;WACiB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,gBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC;mBAuBrH,QAAQ;IA+C7B,OAAO,CAAC,wBAAwB,CAwB9B;IAEF,sCAAsC;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
|
|
@@ -11,17 +11,22 @@ import { FrontendLoggerCategory } from "./common/FrontendLoggerCategory";
|
|
|
11
11
|
import { IModelApp } from "./IModelApp";
|
|
12
12
|
import { IModelConnection } from "./IModelConnection";
|
|
13
13
|
import { IModelRoutingContext } from "./IModelRoutingContext";
|
|
14
|
+
import { IpcApp } from "./IpcApp";
|
|
14
15
|
const loggerCategory = FrontendLoggerCategory.IModelConnection;
|
|
15
16
|
/**
|
|
16
|
-
* An IModelConnection to a
|
|
17
|
-
*
|
|
18
|
-
* at servicing requests at the same time. For this reason, this type of connection may only be used with Checkpoint iModels that are
|
|
19
|
-
* guaranteed to be the same on every backend. Obviously Checkpoint iModels only allow readonly access.
|
|
17
|
+
* An IModelConnection to a Checkpoint of an iModel.
|
|
18
|
+
* @see [CheckpointConnection]($docs/learning/frontend/IModelConnection)
|
|
20
19
|
* @public
|
|
21
20
|
*/
|
|
22
21
|
export class CheckpointConnection extends IModelConnection {
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
/** The Guid that identifies the iTwin that owns this iModel. */
|
|
23
|
+
get iTwinId() { return super.iTwinId; }
|
|
24
|
+
/** The Guid that identifies this iModel. */
|
|
25
|
+
get iModelId() { return super.iModelId; }
|
|
26
|
+
/** Returns `true` if [[close]] has already been called. */
|
|
27
|
+
get isClosed() { return this._isClosed ? true : false; }
|
|
28
|
+
constructor(props, fromIpc) {
|
|
29
|
+
super(props);
|
|
25
30
|
this._reopenConnectionHandler = async (request, response, resubmit, reject) => {
|
|
26
31
|
if (!response.hasOwnProperty("isIModelNotFoundResponse"))
|
|
27
32
|
return;
|
|
@@ -44,30 +49,30 @@ export class CheckpointConnection extends IModelConnection {
|
|
|
44
49
|
request.parameters[0] = this.getRpcProps(); // Modify the token of the original request before resubmitting it.
|
|
45
50
|
resubmit();
|
|
46
51
|
};
|
|
52
|
+
this._fromIpc = fromIpc;
|
|
47
53
|
}
|
|
48
|
-
/** The Guid that identifies the iTwin that owns this iModel. */
|
|
49
|
-
get iTwinId() { return super.iTwinId; }
|
|
50
|
-
/** The Guid that identifies this iModel. */
|
|
51
|
-
get iModelId() { return super.iModelId; }
|
|
52
|
-
/** Returns `true` if [[close]] has already been called. */
|
|
53
|
-
get isClosed() { return this._isClosed ? true : false; }
|
|
54
54
|
/** Type guard for instanceof [[CheckpointConnection]] */
|
|
55
55
|
isCheckpointConnection() { return true; }
|
|
56
56
|
/**
|
|
57
|
-
* Open a readonly IModelConnection to an iModel
|
|
57
|
+
* Open a readonly IModelConnection to a Checkpoint of an iModel.
|
|
58
58
|
*/
|
|
59
59
|
static async openRemote(iTwinId, iModelId, version = IModelVersion.latest()) {
|
|
60
|
-
const routingContext = IModelRoutingContext.current || IModelRoutingContext.default;
|
|
61
|
-
const accessToken = await IModelApp.getAccessToken();
|
|
62
60
|
if (undefined === IModelApp.hubAccess)
|
|
63
|
-
throw new Error("Missing an implementation of
|
|
61
|
+
throw new Error("Missing an implementation of IModelApp.hubAccess");
|
|
62
|
+
const accessToken = await IModelApp.getAccessToken();
|
|
64
63
|
const changeset = await IModelApp.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version });
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
let connection;
|
|
65
|
+
const iModelProps = { iTwinId, iModelId, changeset };
|
|
66
|
+
if (IpcApp.isValid) {
|
|
67
|
+
connection = new this(await IpcApp.appFunctionIpc.openCheckpoint(iModelProps), true);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const routingContext = IModelRoutingContext.current || IModelRoutingContext.default;
|
|
71
|
+
connection = new this(await this.callOpen(iModelProps, routingContext), false);
|
|
72
|
+
RpcManager.setIModel(connection);
|
|
73
|
+
connection.routingContext = routingContext;
|
|
74
|
+
RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);
|
|
75
|
+
}
|
|
71
76
|
IModelConnection.onOpen.raiseEvent(connection);
|
|
72
77
|
return connection;
|
|
73
78
|
}
|
|
@@ -115,7 +120,10 @@ export class CheckpointConnection extends IModelConnection {
|
|
|
115
120
|
if (this.isClosed)
|
|
116
121
|
return;
|
|
117
122
|
this.beforeClose();
|
|
118
|
-
|
|
123
|
+
if (this._fromIpc)
|
|
124
|
+
await IpcApp.appFunctionIpc.closeIModel(this._fileKey);
|
|
125
|
+
else
|
|
126
|
+
RpcRequest.notFoundHandlers.removeListener(this._reopenConnectionHandler);
|
|
119
127
|
this._isClosed = true;
|
|
120
128
|
}
|
|
121
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckpointConnection.js","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACkB,WAAW,EAAE,sBAAsB,EAAsB,aAAa,EAAE,UAAU,EAAuB,YAAY,EAC5I,UAAU,EAAE,eAAe,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,cAAc,GAAG,sBAAsB,CAAC,gBAAgB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAA1D;;QAoFU,6BAAwB,GAAG,KAAK,EAAE,OAAwC,EAAE,QAAa,EAAE,QAAoB,EAAE,MAA6B,EAAE,EAAE;YACxJ,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,0BAA0B,CAAC;gBACtD,OAAO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OAAO,CAAC,aAAa,KAAK,uBAAuB,EAAE;gBACrD,OAAO,CAAC,aAAa,GAAG,uBAAuB,CAAC;gBAChD,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,8CAA8C,OAAO,CAAC,aAAa,wCAAwC,EAAE,WAAW,CAAC,CAAC;aAC3J;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACrH,IAAI,YAAmC,CAAC;QACxC,IAAI;YACF,YAAY,GAAG,MAAM,WAAW,CAAC;SAClC;gBAAS;YACR,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,iDAAiD,EAAE,WAAW,CAAC,CAAC;YAChG,cAAc,EAAE,CAAC;SAClB;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IA4BD,sCAAsC;IAC/B,KAAK,CAAC,KAAK;QAChB,IAAI,IAAI,CAAC,QAAQ;YACf,OAAO;QAET,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,UAAU,CAAC,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC1E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF","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 IModelConnection\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelConnectionProps, IModelError, IModelReadRpcInterface, IModelRpcOpenProps, IModelVersion, RpcManager, RpcNotFoundResponse, RpcOperation,\r\n RpcRequest, RpcRequestEvent,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IModelRoutingContext } from \"./IModelRoutingContext\";\r\n\r\nconst loggerCategory = FrontendLoggerCategory.IModelConnection;\r\n\r\n/**\r\n * An IModelConnection to a checkpoint of an iModel, hosted on a remote backend over RPC.\r\n * Due to the nature of RPC requests, the backend servicing this connection may change over time, and there may even be more than one backend\r\n * at servicing requests at the same time. For this reason, this type of connection may only be used with Checkpoint iModels that are\r\n * guaranteed to be the same on every backend. Obviously Checkpoint iModels only allow readonly access.\r\n * @public\r\n */\r\nexport class CheckpointConnection extends IModelConnection {\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; }\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed ? true : false; }\r\n protected _isClosed?: boolean;\r\n\r\n /** Type guard for instanceof [[CheckpointConnection]] */\r\n public override isCheckpointConnection(): this is CheckpointConnection { return true; }\r\n\r\n /**\r\n * Open a readonly IModelConnection to an iModel over RPC.\r\n */\r\n public static async openRemote(iTwinId: string, iModelId: string, version: IModelVersion = IModelVersion.latest()): Promise<CheckpointConnection> {\r\n const routingContext = IModelRoutingContext.current || IModelRoutingContext.default;\r\n const accessToken = await IModelApp.getAccessToken();\r\n\r\n if (undefined === IModelApp.hubAccess)\r\n throw new Error(\"Missing an implementation of FrontendHubAccess on IModelApp, it is required to open a remote iModel Connection. Please provide an implementation to the IModelApp.startup using IModelAppOptions.hubAccess.\");\r\n\r\n const changeset = await IModelApp.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version });\r\n\r\n const iModelRpcProps: IModelRpcOpenProps = { iTwinId, iModelId, changeset };\r\n const openResponse = await this.callOpen(iModelRpcProps, routingContext);\r\n\r\n const connection = new this(openResponse);\r\n RpcManager.setIModel(connection);\r\n connection.routingContext = routingContext;\r\n RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n private static async callOpen(iModelToken: IModelRpcOpenProps, routingContext: IModelRoutingContext): Promise<IModelConnectionProps> {\r\n // Try opening the iModel repeatedly accommodating any pending responses from the backend.\r\n // Waits for an increasing amount of time (but within a range) before checking on the pending request again.\r\n const connectionRetryIntervalRange = { min: 100, max: 5000 }; // in milliseconds\r\n let connectionRetryInterval = Math.min(connectionRetryIntervalRange.min, IModelConnection.connectionTimeout);\r\n\r\n const openForReadOperation = RpcOperation.lookup(IModelReadRpcInterface, \"getConnectionProps\");\r\n if (!openForReadOperation)\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelReadRpcInterface.getConnectionProps() is not available\");\r\n openForReadOperation.policy.retryInterval = () => connectionRetryInterval;\r\n\r\n Logger.logTrace(loggerCategory, `IModelConnection.open`, iModelToken);\r\n const startTime = Date.now();\r\n\r\n const removeListener = RpcRequest.events.addListener((type: RpcRequestEvent, request: RpcRequest) => { // eslint-disable-line deprecation/deprecation\r\n if (type !== RpcRequestEvent.PendingUpdateReceived) // eslint-disable-line deprecation/deprecation\r\n return;\r\n if (!(openForReadOperation && request.operation === openForReadOperation))\r\n return;\r\n\r\n Logger.logTrace(loggerCategory, \"Received pending open notification in IModelConnection.open\", iModelToken);\r\n\r\n const connectionTimeElapsed = Date.now() - startTime;\r\n if (connectionTimeElapsed > IModelConnection.connectionTimeout) {\r\n Logger.logError(loggerCategory, `Timed out opening connection in IModelConnection.open (took longer than ${IModelConnection.connectionTimeout} milliseconds)`, iModelToken);\r\n throw new IModelError(BentleyStatus.ERROR, \"Opening a connection was timed out\"); // NEEDS_WORK: More specific error status\r\n }\r\n\r\n connectionRetryInterval = Math.min(connectionRetryIntervalRange.max, connectionRetryInterval * 2, IModelConnection.connectionTimeout - connectionTimeElapsed);\r\n if (request.retryInterval !== connectionRetryInterval) {\r\n request.retryInterval = connectionRetryInterval;\r\n Logger.logTrace(loggerCategory, `Adjusted open connection retry interval to ${request.retryInterval} milliseconds in IModelConnection.open`, iModelToken);\r\n }\r\n });\r\n\r\n const openPromise = IModelReadRpcInterface.getClientForRouting(routingContext.token).getConnectionProps(iModelToken);\r\n let openResponse: IModelConnectionProps;\r\n try {\r\n openResponse = await openPromise;\r\n } finally {\r\n Logger.logTrace(loggerCategory, \"Completed open request in IModelConnection.open\", iModelToken);\r\n removeListener();\r\n }\r\n\r\n return openResponse;\r\n }\r\n\r\n private _reopenConnectionHandler = async (request: RpcRequest<RpcNotFoundResponse>, response: any, resubmit: () => void, reject: (reason: any) => void) => { // eslint-disable-line deprecation/deprecation\r\n if (!response.hasOwnProperty(\"isIModelNotFoundResponse\"))\r\n return;\r\n\r\n const iModelRpcProps = request.parameters[0];\r\n if (this._fileKey !== iModelRpcProps.key)\r\n return; // The handler is called for a different connection than this\r\n\r\n Logger.logTrace(loggerCategory, \"Attempting to reopen connection\", () => iModelRpcProps);\r\n\r\n try {\r\n const openResponse = await CheckpointConnection.callOpen(iModelRpcProps, this.routingContext);\r\n // The new/reopened connection may have a new rpcKey and/or changesetId, but the other IModelRpcTokenProps should be the same\r\n this._fileKey = openResponse.key;\r\n this.changeset = openResponse.changeset!;\r\n\r\n } catch (error) {\r\n reject(BentleyError.getErrorMessage(error));\r\n } finally {\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"Resubmitting original request after reopening connection\", iModelRpcProps);\r\n request.parameters[0] = this.getRpcProps(); // Modify the token of the original request before resubmitting it.\r\n resubmit();\r\n };\r\n\r\n /** Close this CheckpointConnection */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n this.beforeClose();\r\n RpcRequest.notFoundHandlers.removeListener(this._reopenConnectionHandler);\r\n this._isClosed = true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CheckpointConnection.js","sourceRoot":"","sources":["../../src/CheckpointConnection.ts"],"names":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,CAAC;aAC3J;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACrH,IAAI,YAAmC,CAAC;QACxC,IAAI;YACF,YAAY,GAAG,MAAM,WAAW,CAAC;SAClC;gBAAS;YACR,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,iDAAiD,EAAE,WAAW,CAAC,CAAC;YAChG,cAAc,EAAE,CAAC;SAClB;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IA4BD,sCAAsC;IAC/B,KAAK,CAAC,KAAK;QAChB,IAAI,IAAI,CAAC,QAAQ;YACf,OAAO;QAET,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ;YACf,MAAM,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;YAEvD,UAAU,CAAC,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAE5E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF","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 IModelConnection\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelConnectionProps, IModelError, IModelReadRpcInterface, IModelRpcOpenProps, IModelVersion, RpcManager, RpcNotFoundResponse, RpcOperation,\r\n RpcRequest, RpcRequestEvent,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IModelRoutingContext } from \"./IModelRoutingContext\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nconst loggerCategory = FrontendLoggerCategory.IModelConnection;\r\n\r\n/**\r\n * An IModelConnection to a Checkpoint of an iModel.\r\n * @see [CheckpointConnection]($docs/learning/frontend/IModelConnection)\r\n * @public\r\n */\r\nexport class CheckpointConnection extends IModelConnection {\r\n private readonly _fromIpc: boolean;\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; }\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed ? true : false; }\r\n protected _isClosed?: boolean;\r\n\r\n protected constructor(props: IModelConnectionProps, fromIpc: boolean) {\r\n super(props);\r\n this._fromIpc = fromIpc;\r\n }\r\n\r\n /** Type guard for instanceof [[CheckpointConnection]] */\r\n public override isCheckpointConnection(): this is CheckpointConnection { return true; }\r\n\r\n /**\r\n * Open a readonly IModelConnection to a Checkpoint of an iModel.\r\n */\r\n public static async openRemote(iTwinId: GuidString, iModelId: GuidString, version = IModelVersion.latest()): Promise<CheckpointConnection> {\r\n if (undefined === IModelApp.hubAccess)\r\n throw new Error(\"Missing an implementation of IModelApp.hubAccess\");\r\n\r\n const accessToken = await IModelApp.getAccessToken();\r\n const changeset = await IModelApp.hubAccess.getChangesetFromVersion({ accessToken, iModelId, version });\r\n\r\n let connection: CheckpointConnection;\r\n const iModelProps = { iTwinId, iModelId, changeset };\r\n if (IpcApp.isValid) {\r\n connection = new this(await IpcApp.appFunctionIpc.openCheckpoint(iModelProps), true);\r\n } else {\r\n const routingContext = IModelRoutingContext.current || IModelRoutingContext.default;\r\n connection = new this(await this.callOpen(iModelProps, routingContext), false);\r\n RpcManager.setIModel(connection);\r\n connection.routingContext = routingContext;\r\n RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);\r\n }\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n private static async callOpen(iModelToken: IModelRpcOpenProps, routingContext: IModelRoutingContext): Promise<IModelConnectionProps> {\r\n // Try opening the iModel repeatedly accommodating any pending responses from the backend.\r\n // Waits for an increasing amount of time (but within a range) before checking on the pending request again.\r\n const connectionRetryIntervalRange = { min: 100, max: 5000 }; // in milliseconds\r\n let connectionRetryInterval = Math.min(connectionRetryIntervalRange.min, IModelConnection.connectionTimeout);\r\n\r\n const openForReadOperation = RpcOperation.lookup(IModelReadRpcInterface, \"getConnectionProps\");\r\n if (!openForReadOperation)\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelReadRpcInterface.getConnectionProps() is not available\");\r\n openForReadOperation.policy.retryInterval = () => connectionRetryInterval;\r\n\r\n Logger.logTrace(loggerCategory, `IModelConnection.open`, iModelToken);\r\n const startTime = Date.now();\r\n\r\n const removeListener = RpcRequest.events.addListener((type: RpcRequestEvent, request: RpcRequest) => { // eslint-disable-line deprecation/deprecation\r\n if (type !== RpcRequestEvent.PendingUpdateReceived) // eslint-disable-line deprecation/deprecation\r\n return;\r\n if (!(openForReadOperation && request.operation === openForReadOperation))\r\n return;\r\n\r\n Logger.logTrace(loggerCategory, \"Received pending open notification in IModelConnection.open\", iModelToken);\r\n\r\n const connectionTimeElapsed = Date.now() - startTime;\r\n if (connectionTimeElapsed > IModelConnection.connectionTimeout) {\r\n Logger.logError(loggerCategory, `Timed out opening connection in IModelConnection.open (took longer than ${IModelConnection.connectionTimeout} milliseconds)`, iModelToken);\r\n throw new IModelError(BentleyStatus.ERROR, \"Opening a connection was timed out\"); // NEEDS_WORK: More specific error status\r\n }\r\n\r\n connectionRetryInterval = Math.min(connectionRetryIntervalRange.max, connectionRetryInterval * 2, IModelConnection.connectionTimeout - connectionTimeElapsed);\r\n if (request.retryInterval !== connectionRetryInterval) {\r\n request.retryInterval = connectionRetryInterval;\r\n Logger.logTrace(loggerCategory, `Adjusted open connection retry interval to ${request.retryInterval} milliseconds in IModelConnection.open`, iModelToken);\r\n }\r\n });\r\n\r\n const openPromise = IModelReadRpcInterface.getClientForRouting(routingContext.token).getConnectionProps(iModelToken);\r\n let openResponse: IModelConnectionProps;\r\n try {\r\n openResponse = await openPromise;\r\n } finally {\r\n Logger.logTrace(loggerCategory, \"Completed open request in IModelConnection.open\", iModelToken);\r\n removeListener();\r\n }\r\n\r\n return openResponse;\r\n }\r\n\r\n private _reopenConnectionHandler = async (request: RpcRequest<RpcNotFoundResponse>, response: any, resubmit: () => void, reject: (reason: any) => void) => { // eslint-disable-line deprecation/deprecation\r\n if (!response.hasOwnProperty(\"isIModelNotFoundResponse\"))\r\n return;\r\n\r\n const iModelRpcProps = request.parameters[0];\r\n if (this._fileKey !== iModelRpcProps.key)\r\n return; // The handler is called for a different connection than this\r\n\r\n Logger.logTrace(loggerCategory, \"Attempting to reopen connection\", () => iModelRpcProps);\r\n\r\n try {\r\n const openResponse = await CheckpointConnection.callOpen(iModelRpcProps, this.routingContext);\r\n // The new/reopened connection may have a new rpcKey and/or changesetId, but the other IModelRpcTokenProps should be the same\r\n this._fileKey = openResponse.key;\r\n this.changeset = openResponse.changeset!;\r\n\r\n } catch (error) {\r\n reject(BentleyError.getErrorMessage(error));\r\n } finally {\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"Resubmitting original request after reopening connection\", iModelRpcProps);\r\n request.parameters[0] = this.getRpcProps(); // Modify the token of the original request before resubmitting it.\r\n resubmit();\r\n };\r\n\r\n /** Close this CheckpointConnection */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n this.beforeClose();\r\n if (this._fromIpc)\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n else\r\n RpcRequest.notFoundHandlers.removeListener(this._reopenConnectionHandler);\r\n\r\n this._isClosed = true;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-frontend",
|
|
3
|
-
"version": "4.5.0-dev.
|
|
3
|
+
"version": "4.5.0-dev.9",
|
|
4
4
|
"description": "iTwin.js frontend components",
|
|
5
5
|
"main": "lib/cjs/core-frontend.js",
|
|
6
6
|
"module": "lib/esm/core-frontend.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"url": "http://www.bentley.com"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/appui-abstract": "^4.5.0-dev.
|
|
27
|
-
"@itwin/core-bentley": "^4.5.0-dev.
|
|
28
|
-
"@itwin/core-common": "^4.5.0-dev.
|
|
29
|
-
"@itwin/core-geometry": "^4.5.0-dev.
|
|
30
|
-
"@itwin/core-orbitgt": "^4.5.0-dev.
|
|
31
|
-
"@itwin/core-quantity": "^4.5.0-dev.
|
|
26
|
+
"@itwin/appui-abstract": "^4.5.0-dev.9",
|
|
27
|
+
"@itwin/core-bentley": "^4.5.0-dev.9",
|
|
28
|
+
"@itwin/core-common": "^4.5.0-dev.9",
|
|
29
|
+
"@itwin/core-geometry": "^4.5.0-dev.9",
|
|
30
|
+
"@itwin/core-orbitgt": "^4.5.0-dev.9",
|
|
31
|
+
"@itwin/core-quantity": "^4.5.0-dev.9"
|
|
32
32
|
},
|
|
33
33
|
"//devDependencies": [
|
|
34
34
|
"NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"typescript": "~5.0.2",
|
|
56
56
|
"typemoq": "^2.1.0",
|
|
57
57
|
"webpack": "^5.76.0",
|
|
58
|
-
"@itwin/
|
|
59
|
-
"@itwin/
|
|
60
|
-
"@itwin/
|
|
61
|
-
"@itwin/core-
|
|
62
|
-
"@itwin/core-
|
|
63
|
-
"@itwin/core-
|
|
64
|
-
"@itwin/core-
|
|
65
|
-
"@itwin/certa": "4.5.0-dev.
|
|
58
|
+
"@itwin/build-tools": "4.5.0-dev.9",
|
|
59
|
+
"@itwin/appui-abstract": "4.5.0-dev.9",
|
|
60
|
+
"@itwin/core-bentley": "4.5.0-dev.9",
|
|
61
|
+
"@itwin/core-common": "4.5.0-dev.9",
|
|
62
|
+
"@itwin/core-geometry": "4.5.0-dev.9",
|
|
63
|
+
"@itwin/core-quantity": "4.5.0-dev.9",
|
|
64
|
+
"@itwin/core-orbitgt": "4.5.0-dev.9",
|
|
65
|
+
"@itwin/certa": "4.5.0-dev.9"
|
|
66
66
|
},
|
|
67
67
|
"//dependencies": [
|
|
68
68
|
"NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"@loaders.gl/draco": "^3.1.6",
|
|
76
76
|
"fuse.js": "^3.3.0",
|
|
77
77
|
"wms-capabilities": "0.4.0",
|
|
78
|
-
"@itwin/core-i18n": "4.5.0-dev.
|
|
79
|
-
"@itwin/core-telemetry": "4.5.0-dev.
|
|
80
|
-
"@itwin/webgl-compatibility": "4.5.0-dev.
|
|
78
|
+
"@itwin/core-i18n": "4.5.0-dev.9",
|
|
79
|
+
"@itwin/core-telemetry": "4.5.0-dev.9",
|
|
80
|
+
"@itwin/webgl-compatibility": "4.5.0-dev.9"
|
|
81
81
|
},
|
|
82
82
|
"nyc": {
|
|
83
83
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|