import { EnvironmentModuleEntryPointType } from '../manifest/environment-modules';
import { RpcChannel } from './rpc-channel';
import { RpcSeek, RpcSeekResult } from './seek/rpc-seek-model';
/**
 * History:
 *  Version: 0.1.0
 *  Date: 09/20/2018
 *     - New RP Public API model.
 *
 *  Version: 0.0.12
 *  Date: 07/17/2018
 *    [Update] AzureRequest.
 *     - AzureManager and AzureService need to communicate.
 *
 *  Version: 0.0.11
 *  Date: 07/10/2018
 *
 *    [Update] RpcCredSSPOperation
 *     - Restored disableTaskDelay parameter.
 *     - Added alertTitle parameter.
 *     - added alertId? parameter.
 *
 *  Version: 0.0.10
 *  Date: 07/10/2018
 *
 *    [Update] RpcCredSSPOperationType
 *     - Updated operation types for four operations.
 *
 *    [Update] RpcCredSSPOperation
 *     - Removed taskDelay parameter.
 *
 *  Version: 0.0.9
 *  Date: 05/18/2018
 *
 *    [Update] RpcInitData.
 *     - Added Development settings (consoleDebug, sideLoad, and experiments) to RpcInitData.
 *
 *  Version: 0.0.8
 *  Date: 05/18/2018
 *
 *    [Update] CredSSPRequest.
 *     - CredSSPManager and CredSSPManagerShellService need to communicate.
 *
 *  Version: 0.0.7
 *  Date: 04/27/2018
 *    [Update] RpcActivate for re-opening URL as an option.
 *     - moduleActivate has 'url' parameter to point re-activating inner URL.
 *
 *  Version: 0.0.6
 *  Date: 01/29/2018
 *
 *    [Add] OverlayOpen and OverlayClose
 *
 *  Version: 0.0.5
 *  Date: 12/11/2017
 *
 *    [Update] RpcInitData: accessibilityMode: boolean;
 *
 *  Version: 0.0.4
 *  Date: 10/25/2017
 *
 *    [Add] Added new RPC call.
 *
 *  Version: 0.0.3
 *  Date: 9/11/2017
 *
 *    [Updated] added assets and theme to RpcInitData
 *
 *  Version: 0.0.2
 *  Date: 9/11/2017
 *
 *    [Update] Add "reload" property to RpcShellNavigate
 *
 *  Version: 0.0.1
 *  Date: 8/23/2017
 *
 *    [Deleted] Deactivate
 *    [Updated] Open for RpcOpenResult
 *
 *  Version: 0.0.0
 *  Date: 8/14/2017
 *
 *    [Deleted] CanDeactivate
 *    [Deprecated] Deactivate
 *    [New Added] Deactivate2
 *
 */
/**
 * Version number of this RPC.
 */
export declare const rpcVersion = "0.1.0";
export declare const rpcCommandVersion = "0.1.0";
/**
 * Rpc servicing mode.
 */
export declare const enum RpcMode {
    Shell = 0,
    Module = 1
}
/**
 * Rpc relationship type.
 */
export declare const enum RpcRelationshipType {
    Parent = 0,
    Child = 1
}
/**
 * Rpc message packet type.
 */
export declare enum RpcMessagePacketType {
    Request = 0,
    Response = 1,
    Error = 2
}
/**
 * Rpc message event (original message).
 */
export interface RpcMessageEvent {
    data: RpcMessagePacket<any>;
    origin: string;
    source: Window;
}
/**
 * Rpc message data packet.
 */
export interface RpcMessagePacket<T> {
    srcName?: string;
    srcSubName?: string;
    srcDepth?: number;
    destName?: string;
    destSubName?: string;
    signature?: string;
    sequence?: number;
    type?: RpcMessagePacketType;
    command: string;
    version: string;
    data: T;
}
/**************************************************************************************************************************
 * Outbound commands set. (from shell to modules)
 **************************************************************************************************************************/
/**
 * Interface for messages that contain the remote RPC name that sent the message
 */
export interface RpcBaseData {
    sourceName?: string;
    sourceSubName?: string;
    sourceVersion?: string;
}
/**
 * Rpc init command data.
 */
export interface RpcInitData {
    entryPointType: EnvironmentModuleEntryPointType;
    entryPointName: string;
    locale: string;
    localeRegional: string;
    lib: MsftSme.MsftSmeExternalLibraries;
    sessionId: string;
    modules: any[];
    theme: string;
    sessionExpiration: number;
    performanceProfile: boolean;
    assets: MsftSme.MsftSmeAssets;
    moduleAssets: MsftSme.MsftSmeSharedAssets;
    accessibilityMode: boolean;
    consoleDebug: number;
    sideLoad: MsftSme.StringMap<MsftSme.SideLoad>;
    experiments: string[];
    connectivityLevel: string;
    shellVersion: string;
    gatewayApiVersion: string;
    gatewayPlatform: string;
}
/**
 * Rpc init result data.
 */
export interface RpcInitResult {
    version: string;
}
/**
 * The interface for the inbound init data with some extra information like remote name and other information
 */
export interface RpcInitDataInternal extends RpcInitData, RpcBaseData {
}
/**
 * Rpc open state.
 */
export declare enum RpcOpenState {
    /**
     * Opened.
     */
    Opened = 0,
    /**
     * Failed.
     */
    Failed = 1,
    /**
     * In progress.
     */
    InProgress = 2
}
/**
 * Rpc open command data.
 */
export interface RpcOpenData {
    /**
     * The path to open inside of module.
     */
    path: string;
}
/**
 * The interface for the inbound open data with some extra information like remote name and other information
 */
export interface RpcOpenDataInternal extends RpcOpenData, RpcBaseData {
}
/**
 * Rpc result data from open command.
 */
export interface RpcOpenResult {
    /**
     * The open result state.
     */
    state: RpcOpenState;
    /**
     * Waited and holding time.
     */
    waitedTime: number;
    /**
     * Error reason message if any.
     */
    error?: string;
}
/**
 * Rpc activate command data.
 */
export interface RpcActivateData {
    /**
     * The activate url.
     */
    url: string;
}
/**
 * The interface for the activate data.
 */
export interface RpcActivateDataInternal extends RpcActivateData, RpcBaseData {
}
/**
 * Rpc deactivate state.
 */
export declare enum RpcDeactivateState {
    /**
     * Deactivated.
     */
    Deactivated = 0,
    /**
     * Cancelled.
     */
    Cancelled = 1,
    /**
     * In progress.
     */
    InProgress = 2
}
export interface RpcDeactivateResult {
    /**
     * Rpc deactivate state.
     */
    state: RpcDeactivateState;
    /**
     * Waited and holding time.
     */
    waitedTime: number;
}
/**
 * Rpc shutdown command data.
 */
export interface RpcShutdownData extends RpcBaseData {
    /**
     * Shutdown is forced.
     */
    force: boolean;
}
/**
 * Rpc shutdown result.
 */
export interface RpcShutdownResult {
    /**
     * Indicate if it can shutdown now.
     */
    canShutdown: boolean;
}
export interface RpcPingData {
    /**
     * The name of ping request.
     */
    name: string;
}
export interface RpcPingResult extends RpcPingData {
}
/**
 * Rpc commands that Shell initiates to communicate a module (tool).
 */
export declare enum RpcOutboundCommands {
    Init = 100,
    Open = 101,
    Activate = 102,
    Deactivate2 = 103,
    Shutdown = 104,
    Ping = 105
}
/**************************************************************************************************************************
 * Inbound commands set.
 **************************************************************************************************************************/
/**
 * Rpc commands that a Module (tool) initiates to communicate Shell.
 */
export declare enum RpcInboundCommands {
    Failed = 201
}
/**************************************************************************************************************************
 * Handlers for each rpc request.
 **************************************************************************************************************************/
/**
 * Rpc command handlers that a module (tool) handles.
 */
export interface RpcOutboundHandlers {
    InitHandler: (data: RpcInitDataInternal) => Promise<RpcInitResult>;
    OpenHandler: (data: RpcOpenDataInternal) => Promise<RpcOpenResult>;
    ActivateHandler: (data: RpcActivateDataInternal) => Promise<void>;
    Deactivate2Handler: (data: RpcBaseData) => Promise<RpcDeactivateResult>;
    ShutdownHandler: (data: RpcShutdownData) => Promise<RpcShutdownResult>;
    PingHandler: (data: RpcPingData) => Promise<RpcPingResult>;
}
/**
 * Rpc command handlers that Shell handles.
 */
export interface RpcInboundHandlers {
    FailedHandler: (data: RpcBaseData) => Promise<void>;
    SeekHandler: (data: RpcSeek) => Promise<RpcSeekResult>;
}
/**
 * Type of the callback that handles messages with extra information
 * as defined by RpcBaseData
 */
export declare type CommandCallBackType = (data: RpcBaseData) => Promise<any>;
/**
 * The type of RpcBase object.
 */
export declare enum RpcType {
    Channel = 0,
    Inbound = 1,
    Outbound = 2
}
/**
 * Rpc base class.
 */
export declare abstract class RpcBase {
    rpcChannel: RpcChannel;
    name: string;
    origin: string;
    type: RpcType;
    /**
     * Suffix of command to handler mapping.
     */
    static handlerSuffix: string;
    /**
     * the window/iFrame object.
     */
    window: Window;
    /**
     * command collection to handle.
     */
    commandCollection: Map<string, CommandCallBackType>;
    /**
     * The sub name created dynamically when Outbound/Inbound communication is established.
     */
    subName: string;
    /**
     * The depth of frame.
     */
    depth: number;
    /**
     * The version of remote module.
     */
    version?: string;
    /**
     * Convert from handler name to command name.
     *
     * @param handlerName the handler name.
     * @return the command name.
     */
    static handlerToCommandName(handlerName: any): string;
    /**
     * Convert from command name to handler name.
     *
     * @param commandName the command name.
     * @return the handler name.
     */
    static commandToHandlerName(commandName: any): string;
    /**
     * Initializes a new instance of the RpcBase class.
     *
     * @param rpcChannel the rpc channel object..
     * @param name the public name of Shell or Module (tool).
     * @param origin the origin url to start Shell or Module (tool).
     */
    constructor(rpcChannel: RpcChannel, name: string, origin: string, type: RpcType);
    /**
     * Handle the command with data object.
     *
     * @param command the command name.
     * @param sourceVersion the version string.
     * @param sourceName the name of the remote rpc that sent the request.
     * @param sourceSubName the sub name of the remote rpc that sent the request.
     * @param data the data object.
     * @return Promise<any> the promise object.
     */
    handle(command: string, sourceVersion: string, sourceName: string, sourceSubName: string, data: any): Promise<any>;
    /**
     * Register the handler to the command.
     *
     * @param command the command name.
     * @param handler the handler function.
     */
    register(command: string, handler: CommandCallBackType): void;
}
