"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.RpcManager = void 0;
const RpcOperation_1 = require("./rpc/core/RpcOperation");
const RpcRegistry_1 = require("./rpc/core/RpcRegistry");
const RpcRoutingToken_1 = require("./rpc/core/RpcRoutingToken");
/** RPC interface management is concerned with coordination of access and configuration for RPC interfaces.
 * @beta
 */
class RpcManager {
    /** Initializes an RPC interface class.
     * @note This function must be called on the frontend and on the backend for each RPC interface class used by an application.
     */
    static initializeInterface(definition) {
        RpcRegistry_1.RpcRegistry.instance.initializeRpcInterface(definition);
    }
    /** Terminates an RPC interface class. */
    static terminateInterface(definition) {
        RpcRegistry_1.RpcRegistry.instance.terminateRpcInterface(definition);
    }
    /** Returns the RPC client instance for the frontend. */
    static getClientForInterface(definition, routing = RpcRoutingToken_1.RpcRoutingToken.default) {
        return RpcRegistry_1.RpcRegistry.instance.getClientForInterface(definition, routing);
    }
    /** Register the RPC implementation class for the backend. */
    static registerImpl(definition, implementation) {
        RpcRegistry_1.RpcRegistry.instance.registerImpl(definition, implementation);
    }
    /** Supply the instance of the RPC interface implementation class for the backend (optional). */
    static supplyImplInstance(definition, instance) {
        RpcRegistry_1.RpcRegistry.instance.supplyImplInstance(definition, instance);
    }
    /** Unregister the RPC implementation class for the backend. */
    static unregisterImpl(definition) {
        RpcRegistry_1.RpcRegistry.instance.unregisterImpl(definition);
    }
    /** Describes the RPC interfaces and endpoints that are currently available from the backend.
     * @note Some endpoints may be marked incompatible if the frontend expected a different interface declaration than the backend supplied. RPC operations against an incompatible interface will fail.
     */
    static async describeAvailableEndpoints() {
        return RpcRegistry_1.RpcRegistry.instance.describeAvailableEndpoints();
    }
    /** Configures RPC protocols that employ iModel-based routing infrastructure. */
    static setIModel(props) {
        RpcOperation_1.RpcOperation.fallbackToken = props;
    }
}
exports.RpcManager = RpcManager;
//# sourceMappingURL=RpcManager.js.map