/// <reference types="mongodb" />
/// <reference types="express" />
/// <reference types="node" />
declare namespace Plugins {
    import { Settings, PluginService } from "@dataden/sdk";
    import { AxiosResponse } from "axios";
    import * as express from "express";
    namespace Db {
        const DATABASES: {
            CORE: string;
            PLUGIN_PREFIX: string;
        };
        const COLLECTIONS: {
            [x: string]: {
                PLUGINS: string;
                USERS: string;
            };
        };
        function getClient(): Promise<any>;
        interface PagingPosition {
            page: number;
        }
        interface PagingResult<T> {
            page: number;
            pages: number;
            data: T[];
        }
        namespace Plugins {
            import { MongoClient } from "mongodb";
            import * as Sdk from "@dataden/sdk";
            type Collection = "syncs" | "settings" | "auth" | string;
            interface DbPath {
                pluginId: string;
                instanceName: string;
            }
            const DATABASES: {
                CORE: string;
                PLUGIN_PREFIX: string;
            };
            const COLLECTIONS: {
                [x: string]: {
                    PLUGINS: string;
                    USERS: string;
                };
            };
            function getClient(): Promise<any>;
            interface PagingPosition {
                page: number;
            }
            interface PagingResult<T> {
                page: number;
                pages: number;
                data: T[];
            }
            type DataRow = Sdk.DataRow;
            const Data: {
                append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
            };
            interface PluginBase {
                id: string;
                location: string;
                version?: number;
                local: boolean;
            }
            type PluginInstallRequest = PluginBase;
            interface PluginInstance {
                name: string;
            }
            interface Plugin extends PluginBase {
                instances: PluginInstance[];
            }
            const Installed: {
                list: (client: MongoClient) => Promise<Plugin[]>;
                get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
                upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
            };
            type Settings = Sdk.Settings;
            const Settings: {
                get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
                set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
            };
            type SyncItem = {
                type: "loader";
                name: string;
                syncInfo: Sdk.SyncInfo;
            };
            type Sync = {
                date: string;
                items: SyncItem[];
            };
            const Syncs: {
                last: (client: MongoClient, path: DbPath) => Promise<Sync>;
                upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
            };
            type AuthState = Sdk.PluginAuth.AuthState;
            // TODO: encrypt this data in the database
            const Auth: {
                get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
                set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
            };
        }
        // DTOS
        interface User {
            username: string;
            passwordHash: string;
            resetRequired: boolean;
        }
        // Helers
        function hashPassword(plainText: any): string;
        // Access
        const Users: {
            get: (client: MongoClient, username: any) => Promise<User>;
            upsert: (client: MongoClient, update: User) => Promise<import("mongodb").UpdateWriteOpResult>;
            ensureDefaultUserSeeded: (client: MongoClient) => Promise<"seeded" | "ok">;
            validate: (client: MongoClient, username: any, password: any) => Promise<false | User>;
        };
    }
    type Collection = "syncs" | "settings" | "auth" | string;
    interface DbPath {
        pluginId: string;
        instanceName: string;
    }
    const DATABASES: {
        CORE: string;
        PLUGIN_PREFIX: string;
    };
    const COLLECTIONS: {
        [x: string]: {
            PLUGINS: string;
            USERS: string;
        };
    };
    function getClient(): Promise<any>;
    interface PagingPosition {
        page: number;
    }
    interface PagingResult<T> {
        page: number;
        pages: number;
        data: T[];
    }
    type DataRow = Sdk.DataRow;
    const Data: {
        append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
        replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
        fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
    };
    interface PluginBase {
        id: string;
        location: string;
        version?: number;
        local: boolean;
    }
    type PluginInstallRequest = PluginBase;
    interface PluginInstance {
        name: string;
    }
    interface Plugin extends PluginBase {
        instances: PluginInstance[];
    }
    const Installed: {
        list: (client: MongoClient) => Promise<Plugin[]>;
        get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
        upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
    };
    type Settings$0 = Sdk.Settings$0;
    const Settings: {
        get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
        set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
    };
    type SyncItem = {
        type: "loader";
        name: string;
        syncInfo: Sdk.SyncInfo;
    };
    type Sync = {
        date: string;
        items: SyncItem[];
    };
    const Syncs: {
        last: (client: MongoClient, path: DbPath) => Promise<Sync>;
        upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
    };
    type AuthState = Sdk.PluginAuth.AuthState;
    // TODO: encrypt this data in the database
    const Auth: {
        get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
        set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
    };
    interface CorePlugin {
        id: string;
        name: string;
        description: string;
        source: string;
        local: boolean;
    }
    interface RegistryPlugin extends CorePlugin {
        version: number;
        verified: boolean;
        local: false;
    }
    interface LocalPlugin extends CorePlugin {
        local: true;
    }
    type RegistryPluginList = RegistryPlugin[];
    interface Registry {
        list: RegistryPluginList;
    }
    type PluginServiceDefinition = {
        plugin: Plugin;
        service: PluginService;
    };
    namespace Db {
        const DATABASES: {
            CORE: string;
            PLUGIN_PREFIX: string;
        };
        const COLLECTIONS: {
            [x: string]: {
                PLUGINS: string;
                USERS: string;
            };
        };
        function getClient(): Promise<any>;
        interface PagingPosition {
            page: number;
        }
        interface PagingResult<T> {
            page: number;
            pages: number;
            data: T[];
        }
        namespace Plugins {
            type Collection = "syncs" | "settings" | "auth" | string;
            interface DbPath {
                pluginId: string;
                instanceName: string;
            }
            const DATABASES: {
                CORE: string;
                PLUGIN_PREFIX: string;
            };
            const COLLECTIONS: {
                [x: string]: {
                    PLUGINS: string;
                    USERS: string;
                };
            };
            function getClient(): Promise<any>;
            interface PagingPosition {
                page: number;
            }
            interface PagingResult<T> {
                page: number;
                pages: number;
                data: T[];
            }
            type DataRow = Sdk.DataRow;
            const Data: {
                append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
            };
            interface PluginBase {
                id: string;
                location: string;
                version?: number;
                local: boolean;
            }
            type PluginInstallRequest = PluginBase;
            interface PluginInstance {
                name: string;
            }
            interface Plugin extends PluginBase {
                instances: PluginInstance[];
            }
            const Installed: {
                list: (client: MongoClient) => Promise<Plugin[]>;
                get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
                upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
            };
            type Settings = Sdk.Settings;
            const Settings: {
                get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
                set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
            };
            type SyncItem = {
                type: "loader";
                name: string;
                syncInfo: Sdk.SyncInfo;
            };
            type Sync = {
                date: string;
                items: SyncItem[];
            };
            const Syncs: {
                last: (client: MongoClient, path: DbPath) => Promise<Sync>;
                upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
            };
            type AuthState = Sdk.PluginAuth.AuthState;
            // TODO: encrypt this data in the database
            const Auth: {
                get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
                set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
            };
        }
        // DTOS
        interface User {
            username: string;
            passwordHash: string;
            resetRequired: boolean;
        }
        // Helers
        function hashPassword(plainText: any): string;
        // Access
        const Users: {
            get: (client: MongoClient, username: any) => Promise<User>;
            upsert: (client: MongoClient, update: User) => Promise<import("mongodb").UpdateWriteOpResult>;
            ensureDefaultUserSeeded: (client: MongoClient) => Promise<"seeded" | "ok">;
            validate: (client: MongoClient, username: any, password: any) => Promise<false | User>;
        };
    }
    class PluginConflictError extends Error {
        constructor();
    }
    class InstallPluginError extends Error {
    }
    function installPlugin(registryPlugin: RegistryPlugin | LocalPlugin): Promise<Db.Plugins.Plugin>;
    function uninstallPlugin(pluginId: string): void;
    function loadPluginServiceDefinitions(): Promise<PluginServiceDefinition[]>;
    function loadPluginServiceDefinitionById(pluginId: string): Promise<PluginServiceDefinition | null>;
    function getRegistry(): Promise<AxiosResponse<Registry>>;
    function init(app: express.Application): void;
    interface AuthenticatedEndpointOptions {
        permitWhenPasswordResetIsRequired?: boolean;
    }
    function authenticatedEndpoint({ permitWhenPasswordResetIsRequired }?: AuthenticatedEndpointOptions): <P, ResBody, ReqBody, ReqQuery>(request: express.Request<P, ResBody, ReqBody, ReqQuery>, response: express.Response<ResBody>, next: express.NextFunction) => void;
    namespace Common {
        interface PluginParams {
            pluginId: string;
        }
        interface PluginInstanceParams extends PluginParams {
            instanceId: string;
        }
    }
    type MaybeError<T> = T | string;
    // Other
    namespace GetPlugins {
        const path = "/v1.0/plugins";
        type Response = Db.Plugins.Plugin[];
    }
    namespace PostInstallPlugin {
        const path = "/v1.0/plugins/install";
        type Body = RegistryPlugin | LocalPlugin;
        type Response = Db.Plugins.Plugin | string;
    }
    namespace Reload {
        const path = "/v1.0/plugins/reload";
    }
    // Management
    namespace GetPlugin {
        const path = "/v1.0/plugins/:pluginId";
        const getPath: (params: RouteParams) => string;
        type RouteParams = Common.PluginParams;
        type Response = Db.Plugins.Plugin;
    }
    namespace PutPlugin {
        const path = "/v1.0/plugins/:pluginId";
        const getPath: (params: RouteParams) => string;
        type RouteParams = Common.PluginParams;
        type Body = Db.Plugins.Plugin;
        type Response = Db.Plugins.Plugin | string;
    }
    namespace GetPluginInstanceSettings {
        const path = "/v1.0/plugins/:pluginId/:instanceId/settings";
        const getPath: (params: RouteParams) => string;
        type RouteParams = Common.PluginInstanceParams;
        type Response = Settings;
    }
    namespace PutPluginInstanceSettings {
        const path = "/v1.0/plugins/:pluginId/:instanceId/settings";
        const getPath: (params: RouteParams) => string;
        type RouteParams = Common.PluginInstanceParams;
        type Body = Settings;
        type Response = void;
    }
}
declare namespace Registry {
    type Collection = "syncs" | "settings" | "auth" | string;
    interface DbPath {
        pluginId: string;
        instanceName: string;
    }
    const DATABASES: {
        CORE: string;
        PLUGIN_PREFIX: string;
    };
    const COLLECTIONS: {
        [x: string]: {
            PLUGINS: string;
            USERS: string;
        };
    };
    function getClient(): Promise<any>;
    interface PagingPosition {
        page: number;
    }
    interface PagingResult<T> {
        page: number;
        pages: number;
        data: T[];
    }
    type DataRow = Sdk.DataRow;
    const Data: {
        append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
        replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
        fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
    };
    interface PluginBase {
        id: string;
        location: string;
        version?: number;
        local: boolean;
    }
    type PluginInstallRequest = PluginBase;
    interface PluginInstance {
        name: string;
    }
    interface Plugin extends PluginBase {
        instances: PluginInstance[];
    }
    const Installed: {
        list: (client: MongoClient) => Promise<Plugin[]>;
        get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
        upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
    };
    type Settings = Sdk.Settings;
    const Settings: {
        get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
        set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
    };
    type SyncItem = {
        type: "loader";
        name: string;
        syncInfo: Sdk.SyncInfo;
    };
    type Sync = {
        date: string;
        items: SyncItem[];
    };
    const Syncs: {
        last: (client: MongoClient, path: DbPath) => Promise<Sync>;
        upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
    };
    type AuthState = Sdk.PluginAuth.AuthState;
    // TODO: encrypt this data in the database
    const Auth: {
        get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
        set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
    };
    interface CorePlugin {
        id: string;
        name: string;
        description: string;
        source: string;
        local: boolean;
    }
    interface RegistryPlugin extends CorePlugin {
        version: number;
        verified: boolean;
        local: false;
    }
    interface LocalPlugin extends CorePlugin {
        local: true;
    }
    type RegistryPluginList = RegistryPlugin[];
    interface Registry {
        list: RegistryPluginList;
    }
    type PluginServiceDefinition = {
        plugin: Plugin;
        service: PluginService;
    };
    namespace Db {
        const DATABASES: {
            CORE: string;
            PLUGIN_PREFIX: string;
        };
        const COLLECTIONS: {
            [x: string]: {
                PLUGINS: string;
                USERS: string;
            };
        };
        function getClient(): Promise<any>;
        interface PagingPosition {
            page: number;
        }
        interface PagingResult<T> {
            page: number;
            pages: number;
            data: T[];
        }
        namespace Plugins {
            type Collection = "syncs" | "settings" | "auth" | string;
            interface DbPath {
                pluginId: string;
                instanceName: string;
            }
            const DATABASES: {
                CORE: string;
                PLUGIN_PREFIX: string;
            };
            const COLLECTIONS: {
                [x: string]: {
                    PLUGINS: string;
                    USERS: string;
                };
            };
            function getClient(): Promise<any>;
            interface PagingPosition {
                page: number;
            }
            interface PagingResult<T> {
                page: number;
                pages: number;
                data: T[];
            }
            type DataRow = Sdk.DataRow;
            const Data: {
                append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
            };
            interface PluginBase {
                id: string;
                location: string;
                version?: number;
                local: boolean;
            }
            type PluginInstallRequest = PluginBase;
            interface PluginInstance {
                name: string;
            }
            interface Plugin extends PluginBase {
                instances: PluginInstance[];
            }
            const Installed: {
                list: (client: MongoClient) => Promise<Plugin[]>;
                get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
                upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
            };
            type Settings = Sdk.Settings;
            const Settings: {
                get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
                set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
            };
            type SyncItem = {
                type: "loader";
                name: string;
                syncInfo: Sdk.SyncInfo;
            };
            type Sync = {
                date: string;
                items: SyncItem[];
            };
            const Syncs: {
                last: (client: MongoClient, path: DbPath) => Promise<Sync>;
                upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
            };
            type AuthState = Sdk.PluginAuth.AuthState;
            // TODO: encrypt this data in the database
            const Auth: {
                get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
                set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
            };
        }
        // DTOS
        interface User {
            username: string;
            passwordHash: string;
            resetRequired: boolean;
        }
        // Helers
        function hashPassword(plainText: any): string;
        // Access
        const Users: {
            get: (client: MongoClient, username: any) => Promise<User>;
            upsert: (client: MongoClient, update: User) => Promise<import("mongodb").UpdateWriteOpResult>;
            ensureDefaultUserSeeded: (client: MongoClient) => Promise<"seeded" | "ok">;
            validate: (client: MongoClient, username: any, password: any) => Promise<false | User>;
        };
    }
    class PluginConflictError extends Error {
        constructor();
    }
    class InstallPluginError extends Error {
    }
    function installPlugin(registryPlugin: RegistryPlugin | LocalPlugin): Promise<Db.Plugins.Plugin>;
    function uninstallPlugin(pluginId: string): void;
    function loadPluginServiceDefinitions(): Promise<PluginServiceDefinition[]>;
    function loadPluginServiceDefinitionById(pluginId: string): Promise<PluginServiceDefinition | null>;
    function getRegistry(): Promise<AxiosResponse<Registry>>;
    namespace GetRegistry {
        const path = "/v1.0/registry";
        type Response = Registry;
    }
}
declare namespace Data {
    namespace Db {
        const DATABASES: {
            CORE: string;
            PLUGIN_PREFIX: string;
        };
        const COLLECTIONS: {
            [x: string]: {
                PLUGINS: string;
                USERS: string;
            };
        };
        function getClient(): Promise<any>;
        interface PagingPosition {
            page: number;
        }
        interface PagingResult<T> {
            page: number;
            pages: number;
            data: T[];
        }
        namespace Plugins {
            type Collection = "syncs" | "settings" | "auth" | string;
            interface DbPath {
                pluginId: string;
                instanceName: string;
            }
            const DATABASES: {
                CORE: string;
                PLUGIN_PREFIX: string;
            };
            const COLLECTIONS: {
                [x: string]: {
                    PLUGINS: string;
                    USERS: string;
                };
            };
            function getClient(): Promise<any>;
            interface PagingPosition {
                page: number;
            }
            interface PagingResult<T> {
                page: number;
                pages: number;
                data: T[];
            }
            type DataRow = Sdk.DataRow;
            const Data: {
                append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
            };
            interface PluginBase {
                id: string;
                location: string;
                version?: number;
                local: boolean;
            }
            type PluginInstallRequest = PluginBase;
            interface PluginInstance {
                name: string;
            }
            interface Plugin extends PluginBase {
                instances: PluginInstance[];
            }
            const Installed: {
                list: (client: MongoClient) => Promise<Plugin[]>;
                get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
                upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
            };
            type Settings = Sdk.Settings;
            const Settings: {
                get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
                set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
            };
            type SyncItem = {
                type: "loader";
                name: string;
                syncInfo: Sdk.SyncInfo;
            };
            type Sync = {
                date: string;
                items: SyncItem[];
            };
            const Syncs: {
                last: (client: MongoClient, path: DbPath) => Promise<Sync>;
                upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
            };
            type AuthState = Sdk.PluginAuth.AuthState;
            // TODO: encrypt this data in the database
            const Auth: {
                get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
                set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
            };
        }
        // DTOS
        interface User {
            username: string;
            passwordHash: string;
            resetRequired: boolean;
        }
        // Helers
        function hashPassword(plainText: any): string;
        // Access
        const Users: {
            get: (client: MongoClient, username: any) => Promise<User>;
            upsert: (client: MongoClient, update: User) => Promise<import("mongodb").UpdateWriteOpResult>;
            ensureDefaultUserSeeded: (client: MongoClient) => Promise<"seeded" | "ok">;
            validate: (client: MongoClient, username: any, password: any) => Promise<false | User>;
        };
    }
    namespace Scheduler {
        type Collection = "syncs" | "settings" | "auth" | string;
        interface DbPath {
            pluginId: string;
            instanceName: string;
        }
        const DATABASES: {
            CORE: string;
            PLUGIN_PREFIX: string;
        };
        const COLLECTIONS: {
            [x: string]: {
                PLUGINS: string;
                USERS: string;
            };
        };
        function getClient(): Promise<any>;
        interface PagingPosition {
            page: number;
        }
        interface PagingResult<T> {
            page: number;
            pages: number;
            data: T[];
        }
        type DataRow = Sdk.DataRow;
        const Data: {
            append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
            replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
            fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
        };
        interface PluginBase {
            id: string;
            location: string;
            version?: number;
            local: boolean;
        }
        type PluginInstallRequest = PluginBase;
        interface PluginInstance {
            name: string;
        }
        interface Plugin extends PluginBase {
            instances: PluginInstance[];
        }
        const Installed: {
            list: (client: MongoClient) => Promise<Plugin[]>;
            get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
            upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
        };
        type Settings = Sdk.Settings;
        const Settings: {
            get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
            set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
        };
        type SyncItem = {
            type: "loader";
            name: string;
            syncInfo: Sdk.SyncInfo;
        };
        type Sync = {
            date: string;
            items: SyncItem[];
        };
        const Syncs: {
            last: (client: MongoClient, path: DbPath) => Promise<Sync>;
            upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
        };
        type AuthState = Sdk.PluginAuth.AuthState;
        // TODO: encrypt this data in the database
        const Auth: {
            get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
            set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
        };
        interface CorePlugin {
            id: string;
            name: string;
            description: string;
            source: string;
            local: boolean;
        }
        interface RegistryPlugin extends CorePlugin {
            version: number;
            verified: boolean;
            local: false;
        }
        interface LocalPlugin extends CorePlugin {
            local: true;
        }
        type RegistryPluginList = RegistryPlugin[];
        interface Registry {
            list: RegistryPluginList;
        }
        type PluginServiceDefinition = {
            plugin: Plugin;
            service: PluginService;
        };
        namespace Db {
            const DATABASES: {
                CORE: string;
                PLUGIN_PREFIX: string;
            };
            const COLLECTIONS: {
                [x: string]: {
                    PLUGINS: string;
                    USERS: string;
                };
            };
            function getClient(): Promise<any>;
            interface PagingPosition {
                page: number;
            }
            interface PagingResult<T> {
                page: number;
                pages: number;
                data: T[];
            }
            namespace Plugins {
                type Collection = "syncs" | "settings" | "auth" | string;
                interface DbPath {
                    pluginId: string;
                    instanceName: string;
                }
                const DATABASES: {
                    CORE: string;
                    PLUGIN_PREFIX: string;
                };
                const COLLECTIONS: {
                    [x: string]: {
                        PLUGINS: string;
                        USERS: string;
                    };
                };
                function getClient(): Promise<any>;
                interface PagingPosition {
                    page: number;
                }
                interface PagingResult<T> {
                    page: number;
                    pages: number;
                    data: T[];
                }
                type DataRow = Sdk.DataRow;
                const Data: {
                    append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                    replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                    fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
                };
                interface PluginBase {
                    id: string;
                    location: string;
                    version?: number;
                    local: boolean;
                }
                type PluginInstallRequest = PluginBase;
                interface PluginInstance {
                    name: string;
                }
                interface Plugin extends PluginBase {
                    instances: PluginInstance[];
                }
                const Installed: {
                    list: (client: MongoClient) => Promise<Plugin[]>;
                    get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
                    upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
                };
                type Settings = Sdk.Settings;
                const Settings: {
                    get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
                    set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
                };
                type SyncItem = {
                    type: "loader";
                    name: string;
                    syncInfo: Sdk.SyncInfo;
                };
                type Sync = {
                    date: string;
                    items: SyncItem[];
                };
                const Syncs: {
                    last: (client: MongoClient, path: DbPath) => Promise<Sync>;
                    upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
                };
                type AuthState = Sdk.PluginAuth.AuthState;
                const Auth: {
                    get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
                    set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
                };
            }
            // DTOS
            interface User {
                username: string;
                passwordHash: string;
                resetRequired: boolean;
            }
            // Helers
            function hashPassword(plainText: any): string;
            // Access
            const Users: {
                get: (client: MongoClient, username: any) => Promise<User>;
                upsert: (client: MongoClient, update: User) => Promise<import("mongodb").UpdateWriteOpResult>;
                ensureDefaultUserSeeded: (client: MongoClient) => Promise<"seeded" | "ok">;
                validate: (client: MongoClient, username: any, password: any) => Promise<false | User>;
            };
        }
        class PluginConflictError extends Error {
            constructor();
        }
        class InstallPluginError extends Error {
        }
        function installPlugin(registryPlugin: RegistryPlugin | LocalPlugin): Promise<Db.Plugins.Plugin>;
        function uninstallPlugin(pluginId: string): void;
        function loadPluginServiceDefinitions(): Promise<PluginServiceDefinition[]>;
        function loadPluginServiceDefinitionById(pluginId: string): Promise<PluginServiceDefinition | null>;
        function getRegistry(): Promise<AxiosResponse<Registry>>;
        type PluginServiceStatusType = "OK" | "Not Started" | "Not Configured" | "Authentication Required" | "Error";
        interface PluginServiceStatus {
            running: boolean;
            status: PluginServiceStatusType;
        }
        interface PluginService extends PluginServiceStatus {
            definition: PluginServiceDefinition;
            instance: PluginInstance;
            interval?: NodeJS.Timeout;
        }
    }
    namespace GetStatus {
        const path = "/v1.0/status";
        type ResponseItem = {
            plugin: Db.Plugins.Plugin;
            pluginInstance: Db.Plugins.PluginInstance;
            lastSync: Db.Plugins.Sync;
            status: Scheduler.PluginServiceStatus;
        };
        type Response = ResponseItem[];
    }
}
declare namespace Console {
    namespace Logging {
        import * as winston from "winston";
        import { SdkLogger } from "@dataden/sdk";
        // https://github.com/winstonjs/winston
        type Logger = winston.Logger;
        const getLogger: () => Logger;
        const getScoped: (scope: string, extraContext?: Record<string, string>) => Logger;
        function getPluginLogger(plugin: string): SdkLogger;
        type LogInfo = winston.Logform.TransformableInfo & {
            formattedMessage: string;
        };
        type ListenCallback = (infos: LogInfo[]) => void;
        function listen(callback: ListenCallback): () => void;
    }
    namespace ConsoleSocket {
        const path = "/v1.0/console";
        type ResponseItem = Logging.LogInfo;
        type Response = ResponseItem[];
    }
}
declare namespace Auth {
    namespace Db {
        const DATABASES: {
            CORE: string;
            PLUGIN_PREFIX: string;
        };
        const COLLECTIONS: {
            [x: string]: {
                PLUGINS: string;
                USERS: string;
            };
        };
        function getClient(): Promise<any>;
        interface PagingPosition {
            page: number;
        }
        interface PagingResult<T> {
            page: number;
            pages: number;
            data: T[];
        }
        namespace Plugins {
            type Collection = "syncs" | "settings" | "auth" | string;
            interface DbPath {
                pluginId: string;
                instanceName: string;
            }
            const DATABASES: {
                CORE: string;
                PLUGIN_PREFIX: string;
            };
            const COLLECTIONS: {
                [x: string]: {
                    PLUGINS: string;
                    USERS: string;
                };
            };
            function getClient(): Promise<any>;
            interface PagingPosition {
                page: number;
            }
            interface PagingResult<T> {
                page: number;
                pages: number;
                data: T[];
            }
            type DataRow = Sdk.DataRow;
            const Data: {
                append: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                replace: (client: MongoClient, path: DbPath, dataSetName: string, rows: DataRow[]) => Promise<void>;
                fetch: (client: MongoClient, path: DbPath, dataSetName: string, position?: PagingPosition, pageSize?: number) => Promise<PagingResult<DataRow>>;
            };
            interface PluginBase {
                id: string;
                location: string;
                version?: number;
                local: boolean;
            }
            type PluginInstallRequest = PluginBase;
            interface PluginInstance {
                name: string;
            }
            interface Plugin extends PluginBase {
                instances: PluginInstance[];
            }
            const Installed: {
                list: (client: MongoClient) => Promise<Plugin[]>;
                get: (client: MongoClient, pluginId: string) => Promise<Plugin>;
                upsert: (client: MongoClient, plugin: PluginInstallRequest | Plugin) => Promise<Plugin>;
            };
            type Settings = Sdk.Settings;
            const Settings: {
                get: (client: MongoClient, path: DbPath) => Promise<Settings | null>;
                set: (client: MongoClient, path: DbPath, settings: Settings) => Promise<void>;
            };
            type SyncItem = {
                type: "loader";
                name: string;
                syncInfo: Sdk.SyncInfo;
            };
            type Sync = {
                date: string;
                items: SyncItem[];
            };
            const Syncs: {
                last: (client: MongoClient, path: DbPath) => Promise<Sync>;
                upsert: (client: MongoClient, path: DbPath, sync: Sync) => Promise<void>;
            };
            type AuthState = Sdk.PluginAuth.AuthState;
            // TODO: encrypt this data in the database
            const Auth: {
                get: (client: MongoClient, path: DbPath) => Promise<AuthState | null>;
                set: (client: MongoClient, path: DbPath, authState: AuthState) => Promise<void>;
            };
        }
        // DTOS
        interface User {
            username: string;
            passwordHash: string;
            resetRequired: boolean;
        }
        // Helers
        function hashPassword(plainText: any): string;
        // Access
        const Users: {
            get: (client: MongoClient, username: any) => Promise<User>;
            upsert: (client: MongoClient, update: User) => Promise<import("mongodb").UpdateWriteOpResult>;
            ensureDefaultUserSeeded: (client: MongoClient) => Promise<"seeded" | "ok">;
            validate: (client: MongoClient, username: any, password: any) => Promise<false | User>;
        };
    }
    namespace PostLogin {
        const path = "/v1.0/login";
        interface Body {
            username: string;
            password: string;
        }
        type Response = Omit<Db.User, "passwordHash">;
    }
    namespace PostProfile {
        const path = "/v1.0/profile";
        type Body = {
            password: string;
        };
    }
    namespace GetProfile {
        const path = "/v1.0/profile";
        type Response = Omit<Db.User, "passwordHash">;
    }
    namespace PostLogout {
        const path = "/v1.0/logout";
    }
}
declare namespace PluginAuth {
    function init(app: express.Application): void;
    interface AuthenticatedEndpointOptions {
        permitWhenPasswordResetIsRequired?: boolean;
    }
    function authenticatedEndpoint({ permitWhenPasswordResetIsRequired }?: AuthenticatedEndpointOptions): <P, ResBody, ReqBody, ReqQuery>(request: express.Request<P, ResBody, ReqBody, ReqQuery>, response: express.Response<ResBody>, next: express.NextFunction) => void;
    namespace Common {
        interface PluginParams {
            pluginId: string;
        }
        interface PluginInstanceParams extends PluginParams {
            instanceId: string;
        }
    }
    type MaybeError<T> = T | string;
    namespace PostPluginAuthInteraction {
        const path = "/v1.0/plugins/:pluginId/:instanceId/auth-interaction";
        const getPath: (params: RouteParams) => string;
        type RouteParams = Common.PluginInstanceParams;
        type Body = {
            redirectUri: string;
        };
        type Response = {
            uri: string;
        };
    }
    namespace PostPluginAuthInteractionResult {
        const path = "/v1.0/plugins/:pluginId/:instanceId/auth-interaction-result";
        const getPath: (params: RouteParams) => string;
        type RouteParams = Common.PluginInstanceParams;
        type OAuthResult = {
            code: string;
            scope: string;
            state: Record<string, string> & {
                pluginId: string;
                instanceName: string;
            };
        };
        type Body = {
            redirectUri: string;
            code: string;
            scope: string;
            state: Record<string, string>;
        };
    }
}
export { Plugins, Registry, Data, Console, Auth, PluginAuth };
