import { Octokit } from '@octokit/rest';

declare enum CortexProtocolMessageType {
    Context = "context",
    Fetch = "fetch"
}
interface IPluginMessage {
    type: CortexProtocolMessageType;
}
declare enum PluginContextLocation {
    Entity = "ENTITY",
    Global = "GLOBAL"
}
interface ProxyFetchRequestMessage extends IPluginMessage {
    init?: RequestInit;
    input: RequestInfo;
    type: CortexProtocolMessageType.Fetch;
}
interface GetContextRequestMessage extends IPluginMessage {
    type: CortexProtocolMessageType.Context;
}
type PluginMessage = ProxyFetchRequestMessage | GetContextRequestMessage;
declare function postCortexMessage<T>(message: PluginMessage): Promise<T>;

declare enum CortexUserRoleType {
    BASIC = "BASIC",
    CUSTOM = "CUSTOM"
}
declare enum CortexBasicUserRole {
    MANAGER = "MANAGER",
    OWNER = "OWNER",
    USER = "USER",
    VIEWER = "VIEWER"
}
interface CortexUserBasicRole {
    role: CortexBasicUserRole;
    type: CortexUserRoleType.BASIC;
}
interface CortexUserCustomRole {
    name: string;
    tag: string;
    type: CortexUserRoleType.CUSTOM;
}
type CortexUserRole = CortexUserBasicRole | CortexUserCustomRole;
interface CortexUser {
    email: string;
    name: string;
    roles?: CortexUserRole[];
}
interface CortexCatalogEntityIcon {
    kind: string;
    tag: string;
    url: string;
}
interface CortexEmailOwner {
    description: string | null;
    email: string;
}
interface PluginEntityOwnership {
    emails: CortexEmailOwner[];
}
interface CortexCatalogEntity {
    definition: any | null;
    description: string | null;
    groups: string[] | null;
    name: string | null;
    ownership: PluginEntityOwnership;
    tag: string;
    type: string;
}
interface CortexService extends CortexCatalogEntity {
    type: 'service';
}
interface CortexResource extends CortexCatalogEntity {
    type: string;
}
interface CortexDomain extends CortexCatalogEntity {
    type: 'domain';
}
interface CortexContextResponse {
    apiBaseUrl: string;
    entity: CortexDomain | CortexResource | CortexService | null;
    location: PluginContextLocation;
    user: CortexUser;
}

interface CortexFetchResponse {
    body: string | undefined;
    headers: Record<string, string>;
    ok: boolean;
    redirected: boolean;
    status: number;
    statusText: string;
    trailer: Record<string, string>;
    type: ResponseType;
    url: string;
}
interface ICortexApi {
    getContext: () => Promise<CortexContextResponse>;
    proxyFetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
}
declare const CortexApi: ICortexApi;

declare const plugin: (octokit: Octokit, { CortexApi }: {
    CortexApi: ICortexApi;
}) => void;

export { CortexApi, CortexBasicUserRole, CortexCatalogEntity, CortexCatalogEntityIcon, CortexContextResponse, CortexDomain, CortexEmailOwner, CortexFetchResponse, CortexProtocolMessageType, CortexResource, CortexService, CortexUser, CortexUserBasicRole, CortexUserCustomRole, CortexUserRole, CortexUserRoleType, GetContextRequestMessage, ICortexApi, IPluginMessage, PluginContextLocation, PluginEntityOwnership, ProxyFetchRequestMessage, plugin as octokitPlugin, postCortexMessage };
