import { IPluginMethodMap, IAgentContext, IKeyManager, IResolver, IDIDManager, ICredentialIssuer, ICredentialVerifier, ICredentialStatusVerifier, IDataStore, IDataStoreORM, TAgent, IAgentOptions } from '@veramo/core';
import { DataSource } from 'typeorm/data-source/DataSource.js';
import { BaseDataSourceOptions } from 'typeorm/data-source/BaseDataSourceOptions.js';
import { DataSourceOptions } from 'typeorm/data-source/DataSourceOptions.js';

/**
 * Allows to get a type agent context plugin methods based on provided or inferred types and at least one method for these plugin(s)
 * @param context Tje agent context to check against
 * @param requiredMethod One or more method the plugin provides, so we can check availability and thus plugin presence
 */
declare function contextHasPlugin<Plugins extends IPluginMethodMap>(context: IAgentContext<any>, requiredMethod: string | string[]): context is IAgentContext<Plugins>;
/**
 * The below methods are convenience methods to directly get the appropriate context after calling the respective method
 *
 * @param context
 */
declare function contextHasKeyManager(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IKeyManager>;
declare function contextHasDidManager(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IResolver & IDIDManager>;
declare function contextHasDidResolver(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IResolver>;
declare function contextHasCredentialIssuer(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialIssuer>;
declare function contextHasCredentialVerifier(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialVerifier>;
declare function contextHasCredentialStatusVerifier(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialStatusVerifier>;
declare function contextHasDataStore(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IDataStore>;
declare function contextHasDataStoreORM(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IDataStoreORM>;

declare class DataSources {
    get defaultDbType(): SupportedDatabaseType;
    set defaultDbType(value: SupportedDatabaseType);
    private dataSources;
    private configs;
    private _defaultDbType;
    private static singleton;
    static singleInstance(): DataSources;
    static newInstance(configs?: Map<string, DataSourceOptions>): DataSources;
    private constructor();
    addConfig(dbName: string, config: DataSourceOptions): this;
    deleteConfig(dbName: string): this;
    has(dbName: string): boolean;
    delete(dbName: string): this;
    getConfig(dbName: string): BaseDataSourceOptions;
    getDbNames(): string[];
    getDbConnection(dbName: string, allowAutomaticMigrations?: boolean): Promise<DataSource>;
}
type SupportedDatabaseType = 'postgres' | 'sqlite' | 'react-native';
type DateTimeType = 'timestamp' | 'datetime';
type DateType = 'date';
/**
 * Gets the database connection.
 *
 * Also makes sure that migrations are run (versioning for DB schema's), so we can properly update over time
 *
 * @param connectionName The database name
 * @param opts
 */
declare const getDbConnection: (connectionName: string, opts?: {
    config: BaseDataSourceOptions | any;
}) => Promise<DataSource>;
declare const dropDatabase: (dbName: string, opts?: {
    removeDataSource?: boolean;
}) => Promise<void>;
/**
 * Runs a migration down (drops DB schema)
 * @param dataSource
 */
declare const revertMigration: (dataSource: DataSource) => Promise<void>;
declare const resetDatabase: (dbName: string) => Promise<void>;

/**
 * Creates a Veramo agent from a config object containing an `/agent` pointer.
 * @param config - The configuration object
 *
 * @see {@link https://veramo.io/docs/veramo_agent/configuration_internals | Configuration Internals} for details on
 *   the configuration options.
 *
 * @beta - This API may change without a major version bump
 */
declare function createAgentFromConfig<T extends IPluginMethodMap>(config: object): Promise<TAgent<T>>;
/**
 * Helper function to create a new instance of the {@link Agent} class with correct type
 *
 * @remarks
 * Use {@link TAgent} to configure agent type (list of available methods) for autocomplete in IDE
 *
 * @example
 * ```typescript
 * import { createAgent, IResolver, IMessageHandler } from '@veramo/core'
 * import { AgentRestClient } from '@veramo/remote-client'
 * import { CredentialIssuer, ICredentialIssuer } from '@veramo/credential-w3c'
 * const agent = createAgent<IResolver & IMessageHandler & ICredentialIssuer>({
 *   plugins: [
 *     new CredentialIssuer(),
 *     new AgentRestClient({
 *       url: 'http://localhost:3002/agent',
 *       enabledMethods: [
 *         'resolveDid',
 *         'handleMessage',
 *       ],
 *     }),
 *   ],
 * })
 * ```
 * @param options - Agent configuration options
 * @returns configured agent
 * @public
 */
declare function createAgent<T extends IPluginMethodMap, C = Record<string, any>>(options: IAgentOptions & {
    context?: C;
}): Promise<TAgent<T> & {
    context?: C;
}>;
/**
 * Parses a yaml config file and returns a config object
 * @param filePath
 */
declare const getConfig: (filePath: string | Buffer | URL) => Promise<{
    version?: number;
    [x: string]: any;
}>;
declare function getAgent<T extends IPluginMethodMap>(fileName: string): Promise<TAgent<T>>;

/**
 * Creates objects from a configuration object and a set of pointers.
 *
 * Example:
 * ```ts
 * const { url } = createObjects({ "rpcUrl": "http://localhost:8545", }, { url: '/rpcUrl' })
 * ```
 *
 * The config can contain references (`$ref`) to other objects within using JSON pointers.
 * Example:
 * ```json
 * {
 *   "rpcUrl": "http://localhost:8545",
 *   "endpoint": {
 *     "url": {
 *       "$ref": "/rpcUrl"
 *     }
 *   }
 * }
 * ```
 *
 * The config object can also contain references to NPM modules using the `$require` property.
 * Example:
 * ```json
 * {
 *   "agent": {
 *     "$require": "@veramo/core#Agent",
 *     "$args": {
 *       "plugins": [
 *         { "$require": "@veramo/did-comm#DIDComm" },
 *       ]
 *     }
 *   }
 * }
 * ```
 *
 * Environment variables can also be specified using the `$env` property.
 *
 * @see Please see {@link https://veramo.io/docs/veramo_agent/configuration_internals | Configuration Internals} for
 *   more information.
 *
 * @param config - The configuration object
 * @param pointers - A map of JSON pointers to objects within that config that you wish to create
 *
 * @beta - This API may change without a major version bump
 */
declare function createObjects(config: object, pointers: Record<string, string>): Promise<Record<string, any>>;

/**
 * Accept a Type or a Promise of that Type.
 *
 * @internal
 */
type OrPromise<T> = T | Promise<T>;

declare const getDbType: (opts?: {
    defaultType: SupportedDatabaseType;
}) => SupportedDatabaseType;
declare const typeOrmDateTime: (opts?: {
    defaultType: SupportedDatabaseType;
}) => DateTimeType;
declare const typeormDate: (opts?: {
    defaultType: SupportedDatabaseType;
}) => DateType;

export { DataSources, type DateTimeType, type DateType, type OrPromise, type SupportedDatabaseType, contextHasCredentialIssuer, contextHasCredentialStatusVerifier, contextHasCredentialVerifier, contextHasDataStore, contextHasDataStoreORM, contextHasDidManager, contextHasDidResolver, contextHasKeyManager, contextHasPlugin, createAgent, createAgentFromConfig, createObjects, dropDatabase, getAgent, getConfig, getDbConnection, getDbType, resetDatabase, revertMigration, typeOrmDateTime, typeormDate };
