@itwin/core-common
Version:
iTwin.js components common to frontend and backend
68 lines • 3.88 kB
TypeScript
/** @packageDocumentation
* @module RpcInterface
*/
import { IModelRpcProps } from "../../IModel";
import { RpcInterface, RpcInterfaceDefinition } from "../../RpcInterface";
import { RpcResponseCacheControl } from "./RpcConstants";
import { RpcRequestCallback_T, RpcRequestInitialRetryIntervalSupplier_T, RpcRequestTokenSupplier_T, RpcResponseCachingCallback_T } from "./RpcRequest";
/** The policy for an RPC operation.
* @internal
*/
export declare class RpcOperationPolicy {
/** Supplies the IModelRpcProps for an operation request. */
token: RpcRequestTokenSupplier_T;
/** Supplies the initial retry interval for an operation request. */
retryInterval: RpcRequestInitialRetryIntervalSupplier_T;
/** Called before every operation request on the frontend is sent. */
requestCallback: RpcRequestCallback_T;
/** Called after every operation request on the frontend is sent. */
sentCallback: RpcRequestCallback_T;
/**
* Determines if caching is permitted for an operation response.
* @note Not all RPC protocols support caching.
*/
allowResponseCaching: RpcResponseCachingCallback_T;
/** Forces RpcConfiguration.strictMode for this operation. */
forceStrictMode: boolean;
/** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */
allowTokenMismatch: boolean;
/** Whether to compress the operation response with one of the client's supported encodings. */
allowResponseCompression: boolean;
}
/** An RPC operation descriptor.
* @internal
*/
export declare class RpcOperation {
/** A fallback token to use for RPC requests that do not semantically depend on an iModel. */
static fallbackToken: IModelRpcProps | undefined;
/** Looks up an RPC operation by name. */
static lookup(target: string | RpcInterfaceDefinition, operationName: string): RpcOperation;
/** Iterates the operations of an RPC interface definition. */
static forEach(definition: RpcInterfaceDefinition, callback: (operation: RpcOperation) => void): void;
/** The RPC interface definition for this operation. */
readonly interfaceDefinition: RpcInterfaceDefinition;
/** The name of this operation. */
readonly operationName: string;
/** The version of this operation. */
get interfaceVersion(): string;
/** The policy for this operation. */
policy: RpcOperationPolicy;
/** @internal */
constructor(definition: RpcInterfaceDefinition, operation: string, policy: RpcOperationPolicy);
/** @internal */
static computeOperationName(identifier: string): string;
}
/** @internal */
export type RpcOperationPolicyProps = Partial<RpcOperationPolicy>;
/** @internal */
export declare namespace RpcOperation {
/** Decorator for setting the policy for an RPC operation function. */
function setPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps): <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => void;
/** Convenience decorator for setting an RPC operation policy that allows response caching. */
function allowResponseCaching(control?: RpcResponseCacheControl): <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => void;
/** Convenience decorator for setting an RPC operation policy that supplies the IModelRpcProps for an operation. */
function setRoutingProps(handler: RpcRequestTokenSupplier_T): <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => void;
/** Decorator for setting the default policy for an RPC interface definition class. */
function setDefaultPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps): <T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) => void;
}
//# sourceMappingURL=RpcOperation.d.ts.map