import { StandardError } from "../../../types";
export type IncomingTransportInfo = {
    port?: number;
    transportID: AvailableTransports;
    lastClient: string;
    origin: string;
};
export type RouterHeader = {
    channel: string;
    origin: string;
    incomingTransportInfo: IncomingTransportInfo;
    lastClient: string;
    type: string;
    topic?: string;
    subscribeID?: string;
    queryID?: string;
    handleOnServer?: boolean;
    originMetadata: ConnectionMetadata;
    timeout?: number;
};
export interface RouterResponse<T> {
    data: T;
    header: RouterHeader;
}
export interface RouterMessage<T = any> extends RouterResponse<T> {
    options: {
        suppressWarnings: boolean;
    };
    originatedHere(): boolean;
}
export type RouterTransportSettings = {
    FinsembleTransport?: {
        serverAddress?: string;
    };
};
export type RouterConfig = {
    windowName: string;
    transportSettings?: RouterTransportSettings;
    /**
     * Only required for shared worker
     */
    routerDomainRoot?: string;
    /**
     * Which transport to enable. Use Startup/RouterConfig.getRecommendedTransport() Set this to "FinsembleTransport" when in freestanding mode.
     */
    transportName: string;
};
/**
 * Call this to unsubscribe to a prior listener call.
 */
export type RouterListenerUnsubscribe = () => void;
export type SendToRouter = {
    header: {
        origin: string;
        type: string;
        [key: string]: any;
    };
};
export type TransmitMessage<T = any> = SendToRouter & {
    header: {
        type: "transmit";
        channel: string;
    };
    data: T;
    options?: {
        suppressWarnings: boolean;
    };
};
export type TransmitMessageFromService<T = any> = RouterMessage<T> & TransmitMessage<T>;
export type ListenerResponse<T = any> = TransmitMessageFromService<T> & {
    originatedHere: () => void;
};
export type ListenerCallback<T = any> = (err: null | string, response: ListenerResponse<T>) => void;
export interface QueryMessage<T = any> extends SendToRouter {
    header: {
        origin: string;
        type: "query";
        queryID: string;
        channel: string;
        logWhenNoResponder: boolean;
        error?: string | null;
        timeout: number;
    };
    data: T;
}
export type QueryMessageFromService<T = any> = RouterMessage<T> & QueryMessage<T>;
/**
 * Q = type of query (sent by client call to query() )
 * R = type of response (returned by server call to sendQueryResponse() )
 */
export type ResponderMessage<Q = any, R = any> = QueryMessageFromService<Q> & {
    sendQueryResponse(error: StandardError, data?: R): any;
    originatedHere: () => void;
};
export type QueryResponseMessage<T = any> = SendToRouter & {
    header: {
        type: "queryResponse";
        queryID: string;
        error?: string | null;
    };
    data?: T;
};
export type QueryResponseFromService<T = any> = RouterMessage<T> & QueryResponseMessage<T>;
export type QueryResponse<T = any> = {
    data?: T;
    header: RouterHeader;
};
export type QueryResponseCallback<T = any> = (err: null | string, response: QueryResponse<T>) => void;
export type StandardQueryResponse<T = any> = {
    err?: null | string;
    response: QueryResponse<T>;
};
export interface RemoveResponderMessage extends SendToRouter {
    header: {
        origin: string;
        type: "removeResponder";
        channel: string;
    };
}
/** Section: subscribe() / addPubSubResponder() / removePubSubResponder() */
export interface SubscribeMessage extends SendToRouter {
    header: {
        origin: string;
        type: "subscribe";
        subscribeID: string;
        topic: string;
        error?: string | null;
    };
}
export type SubscribeMessageFromService = RouterMessage & SubscribeMessage;
export type SubscribeHookMessage<T = any> = SubscribeMessageFromService & {
    sendNotifyToSubscriber: (err: string | null, data?: T) => void;
};
export type SubscriberResponse<T = any> = SendToRouter & {
    header: {
        topic: string;
        subscribeID: string;
        error?: string | null;
    };
    data: T;
    originatedHere: () => boolean;
};
export interface UnsubscribeMessage extends SendToRouter {
    header: {
        origin: string;
        type: "unsubscribe";
        subscribeID: string;
        topic: string;
    };
}
export type UnsubscribeMessageFromService = RouterMessage & UnsubscribeMessage;
export type UnsubscribeHookMessage = UnsubscribeMessageFromService & {
    removeSubscriber: () => void;
};
export interface PublishMessage<T = any> extends SendToRouter {
    header: {
        origin: string;
        type: "publish";
        topic: string;
    };
    data: T;
}
export type PublishMessageFromService<T = any> = RouterMessage<T> & PublishMessage<T>;
export type PublishHookMessage<T = any> = PublishMessageFromService & {
    sendNotifyToAllSubscribers: (err: string | null, data: T) => void;
};
export type NotifyMessage<T = any> = SendToRouter & {
    header: {
        type: "notify";
        subscribeID: string;
        topic: string;
        error?: string;
    };
    data: T;
};
export type NotifyMessageFromService<T = any> = RouterMessage & NotifyMessage<T>;
export type NotifyCallback<T = any> = (err: StandardError, response: SubscriberResponse<T>) => void;
export type SubscribeCallback<T = any> = (err: null | string, data: SubscribeHookMessage<T>) => void;
export type UnsubscribeCallback = (err: null | string, data: UnsubscribeHookMessage) => void;
export type PublishCallback<T = any> = (err: null | string, data: PublishHookMessage<T>) => void;
export type IPCTransportInfo = {
    name: string;
    transportID: "IPCBus";
};
export type SharedWorkerTransportInfo = {
    port: number;
    transportID: "SharedWorker";
};
export type IACTransportInfo = {
    client: string;
    transportID: "FinsembleTransport";
};
export type AvailableTransports = IPCTransportInfo["transportID"] | SharedWorkerTransportInfo["transportID"] | IACTransportInfo["transportID"];
export type TransportInfo = {
    transportID: AvailableTransports;
    port?: number;
    name?: string;
    client?: string;
};
/**
 * Metadata associated with the remote router client. This data is added to the header for all outbound packets so
 * that receiving apps have information about the sending app. Currently, this information is _deduced_ from the
 * `origin` field and is therefore not appropriate for high security applications. In future revisions, this information
 * will be provided by the WindowService via a back-channel which will make it more secure.
 *
 * This object is attached to outbound router message headers. Don't put anything large in this object.
 */
export type ConnectionMetadata = {
    routerConnectionId: string;
    transportInfo: TransportInfo;
    windowName: string;
    appId: string | null;
    webContentsName: string | null;
};
//# sourceMappingURL=types.d.ts.map