@itwin/core-common
Version:
iTwin.js components common to frontend and backend
91 lines • 3.97 kB
TypeScript
/** @packageDocumentation
* @module RpcInterface
*/
import { BackendReadable, BackendWritable } from "../../internal/BackendTypes";
import { RpcConfiguration } from "../core/RpcConfiguration";
import { RpcContentType, RpcRequestStatus } from "../core/RpcConstants";
import { RpcOperation } from "../core/RpcOperation";
import { RpcProtocol } from "../core/RpcProtocol";
import { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from "./OpenAPI";
import { WebAppRpcRequest } from "./WebAppRpcRequest";
/** An HTTP server request object.
* @public
* @deprecated in 3.6 - might be removed in next major version. The RPC system will be significantly refactored (or replaced) in the future.
*/
export interface HttpServerRequest extends BackendReadable {
aborted: boolean;
httpVersion: string;
httpVersionMajor: number;
httpVersionMinor: number;
complete: boolean;
connection: any;
headers: {
[header: string]: string | string[] | undefined;
};
rawHeaders: string[];
trailers: {
[key: string]: string | undefined;
};
trailersDistinct: NodeJS.Dict<string[]>;
rawTrailers: string[];
setTimeout(msecs: number, callback: () => void): void;
setTimeout(msecs: number, callback: () => void): this;
url?: string;
statusCode?: number;
statusMessage?: string;
socket: any;
destroy(error?: Error): this;
body: string | Buffer;
path: string;
method: string;
ip?: string;
header: (field: string) => string | undefined;
headersDistinct: NodeJS.Dict<string[]>;
}
/** An HTTP server response object.
* @public
* @deprecated in 3.6 - might be removed in next major version. The RPC system will be significantly refactored (or replaced) in the future.
*/
export interface HttpServerResponse extends BackendWritable {
send(body?: any): HttpServerResponse;
status(code: number): HttpServerResponse;
set(field: string, value: string): void;
}
/** The HTTP application protocol.
* @internal
*/
export declare abstract class WebAppRpcProtocol extends RpcProtocol {
preserveStreams: boolean;
/** Convenience handler for an RPC operation get request for an HTTP server. */
handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
/** Convenience handler for an RPC operation post request for an HTTP server. */
handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
/** Convenience handler for an OpenAPI description request for an HTTP server. */
handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse): void;
/** Converts an HTTP content type value to an RPC content type value. */
static computeContentType(httpType: string | null | undefined): RpcContentType;
/** The OpenAPI-compatible info object for this protocol. */
abstract info: OpenAPIInfo;
/** An optional prefix for RPC operation URI paths. */
pathPrefix: string;
/** The RPC request class for this protocol. */
readonly requestType: typeof WebAppRpcRequest;
/** Supplies the status corresponding to a protocol-specific code value. */
getStatus(code: number): RpcRequestStatus;
/** Supplies the protocol-specific code corresponding to a status value. */
getCode(status: RpcRequestStatus): number;
supportsStatusCategory: boolean;
/** Whether an HTTP status code indicates a request timeout. */
isTimeout(code: number): boolean;
/** An OpenAPI-compatible description of this protocol.
* @internal
*/
get openAPIDescription(): RpcOpenAPIDescription;
/** Returns the OpenAPI-compatible URI path parameters for an RPC operation.
* @internal
*/
abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];
/** Constructs an HTTP protocol. */
constructor(configuration: RpcConfiguration);
}
//# sourceMappingURL=WebAppRpcProtocol.d.ts.map