"use strict";
/*---------------------------------------------------------------------------------------------
* 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.RpcSessionInvocation = void 0;
const RpcConfiguration_1 = require("./RpcConfiguration");
const RpcConstants_1 = require("./RpcConstants");
const RpcInvocation_1 = require("./RpcInvocation");
const RpcMarshaling_1 = require("./RpcMarshaling");
const RpcProtocol_1 = require("./RpcProtocol");
const RpcRequest_1 = require("./RpcRequest");
/* eslint-disable @typescript-eslint/no-deprecated */
class SessionConfiguration extends RpcConfiguration_1.RpcConfiguration {
    constructor() {
        super(...arguments);
        this.interfaces = () => [];
    }
    get protocol() { return SessionProtocol.instance; }
}
class SessionProtocol extends RpcProtocol_1.RpcProtocol {
    constructor() {
        super(new SessionConfiguration());
        this.requestType = RpcRequest_1.RpcRequest;
        this.supportsStatusCategory = true;
    }
}
SessionProtocol.instance = new SessionProtocol();
/** @internal */
class RpcSessionInvocation extends RpcInvocation_1.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: RpcMarshaling_1.RpcSerializedValue.create(),
            parametersOverride: request.parameters,
            caching: RpcConstants_1.RpcResponseCacheControl.None,
            protocolVersion: parseInt(request.context.protocolVersion, 10),
        };
        return new RpcSessionInvocation(SessionProtocol.instance, serializedRequest);
    }
    get rejected() {
        return this.status === RpcConstants_1.RpcRequestStatus.Rejected;
    }
}
exports.RpcSessionInvocation = RpcSessionInvocation;
//# sourceMappingURL=RpcSessionInvocation.js.map