@itwin/core-common
Version:
iTwin.js components common to frontend and backend
92 lines • 3.21 kB
TypeScript
/** @packageDocumentation
* @module RpcInterface
*/
import { AccessToken, GuidString } from "@itwin/core-bentley";
import { RpcInterface } from "../../RpcInterface";
import { SessionProps } from "../../SessionProps";
import { RpcRequestStatus } from "./RpcConstants";
import { RpcOperation } from "./RpcOperation";
import { RpcProtocol, RpcRequestFulfillment, SerializedRpcRequest } from "./RpcProtocol";
/** The properties of an RpcActivity.
* @public
* @extensions
*/
export interface RpcActivity extends SessionProps {
/** Used for logging to correlate an Rpc activity between frontend and backend */
readonly activityId: GuidString;
/** access token for authorization */
readonly accessToken: AccessToken;
/** the name of the current rpc method */
readonly rpcMethod?: string;
readonly user?: string;
}
/** Serialized format for sending the request across the RPC layer
* @public
*/
export interface SerializedRpcActivity {
id: string;
applicationId: string;
applicationVersion: string;
sessionId: string;
authorization: string;
user?: string;
csrfToken?: {
headerName: string;
headerValue: string;
};
}
/** @internal */
export type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;
/** An RPC operation invocation in response to a request.
* @internal
*/
export declare class RpcInvocation {
static runActivity: RpcActivityRun;
private _threw;
private _pending;
private _notFound;
private _noContent;
private _timeIn;
private _timeOut;
/** The protocol for this invocation. */
readonly protocol: RpcProtocol;
/** The received request. */
readonly request: SerializedRpcRequest;
/** The operation of the request. */
readonly operation: RpcOperation;
/** The implementation response. */
readonly result: Promise<any>;
/** The fulfillment for this request. */
readonly fulfillment: Promise<RpcRequestFulfillment>;
/** The status for this request. */
get status(): RpcRequestStatus;
/** The elapsed time for this invocation. */
get elapsed(): number;
/**
* The invocation for the current RPC operation.
* @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.
*/
static current(rpcImpl: RpcInterface): RpcInvocation;
/** Constructs an invocation. */
constructor(protocol: RpcProtocol, request: SerializedRpcRequest);
private handleUnknownOperation;
static sanitizeForLog(activity?: RpcActivity): {
ActivityId: string;
SessionId: string;
ApplicationId: string;
ApplicationVersion: string;
rpcMethod: string | undefined;
} | undefined;
private resolve;
private applyPolicies;
private static compareTokens;
private reject;
private fulfillResolved;
private fulfillRejected;
private supportsNoContent;
private supportsStatusCategory;
private fulfill;
private lookupOperationFunction;
private transformResponseStatus;
}
//# sourceMappingURL=RpcInvocation.d.ts.map