/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module RpcInterface
 */
import { RpcConfiguration } from "./RpcConfiguration";
import { RpcRequestStatus, RpcResponseCacheControl } from "./RpcConstants";
import { RpcInvocation } from "./RpcInvocation";
import { RpcSerializedValue } from "./RpcMarshaling";
import { RpcProtocol } from "./RpcProtocol";
import { RpcRequest } from "./RpcRequest";
/* eslint-disable @typescript-eslint/no-deprecated */
class SessionConfiguration extends RpcConfiguration {
    interfaces = () => [];
    get protocol() { return SessionProtocol.instance; }
}
class SessionProtocol extends RpcProtocol {
    static instance = new SessionProtocol();
    requestType = RpcRequest;
    supportsStatusCategory = true;
    constructor() { super(new SessionConfiguration()); }
}
/** @internal */
export class RpcSessionInvocation extends RpcInvocation {
    static create(request) {
        const serializedRequest = {
            id: request.context.id,
            applicationId: request.context.applicationId,
            applicationVersion: request.context.applicationVersion,
            sessionId: request.context.sessionId,
            authorization: "",
            operation: {
                interfaceDefinition: request.definition.interfaceName,
                interfaceVersion: request.definition.interfaceVersion,
                operationName: request.operation,
            },
            method: request.operation,
            path: "",
            parameters: RpcSerializedValue.create(),
            parametersOverride: request.parameters,
            caching: RpcResponseCacheControl.None,
            protocolVersion: parseInt(request.context.protocolVersion, 10),
        };
        return new RpcSessionInvocation(SessionProtocol.instance, serializedRequest);
    }
    get rejected() {
        return this.status === RpcRequestStatus.Rejected;
    }
}
//# sourceMappingURL=RpcSessionInvocation.js.map