/// <reference types="node" />
/// <reference types="node" />
import { AceBaseStorageSettings } from 'acebase';
import { AceBaseServerEmailSettings } from './email';
import { Server } from 'http';
import type { AceBaseServer } from '../server';
export type AceBaseServerHttpsSettings = {
    enabled?: boolean;
    keyPath?: string;
    certPath?: string;
    pfxPath?: string;
    passphrase?: string;
} & ({
    keyPath: string;
    certPath: string;
} | {
    pfxPath: string;
    passphrase: string;
} | {});
export declare class AceBaseServerHttpsConfig {
    enabled: boolean;
    key?: Buffer;
    cert?: Buffer;
    pfx?: Buffer;
    passphrase?: string;
    constructor(settings: AceBaseServerHttpsSettings);
}
export type AuthAccessDefault = 'deny' | 'allow' | 'auth';
export declare const AUTH_ACCESS_DEFAULT: {
    [key: string]: AuthAccessDefault;
};
export declare class AceBaseServerAuthenticationSettings {
    /**
     * Whether to enable authorization. Without authorization the entire db can be read and written to by anyone (not recommended 🤷🏼‍♂️)
     */
    readonly enabled: boolean;
    /**
     * Whether new users creation is allowed for anyone, or just the admin
     */
    readonly allowUserSignup: boolean;
    /**
     * How many new users can sign up per hour per IP address. not implemented yet
     */
    readonly newUserRateLimit: number;
    /**
     * How many minutes before access tokens expire. 0 for no expiration. (not implemented yet)
     */
    readonly tokensExpire: number;
    /**
     * When the server runs for the first time, what defaults to use to generate the rules.json file with. Options are: 'auth' (only authenticated access to db, default), 'deny' (deny access to anyone except admin user), 'allow' (allow access to anyone)
     */
    readonly defaultAccessRule: AuthAccessDefault;
    /**
     * When the server runs for the first time, what password to use for the admin user. If not supplied, a generated password will be used and shown ONCE in the console output.
     */
    readonly defaultAdminPassword?: string;
    /**
     * Whether to use a separate database for auth and logging. 'v2' will store data in auth.db, which is NOT TESTED YET!
     */
    readonly separateDb: boolean | 'v2';
    constructor(settings: Partial<AceBaseServerAuthenticationSettings>);
}
/**
 * TODO: Use AceBaseTransactionLogSettings from acebase
 */
export declare class AceBaseServerTransactionSettings {
    /**
     * Whether to enable transaction logging
     */
    log: boolean;
    /**
     * Max age in days to keep transactions in the log file
     */
    maxAge: number;
    /**
     * Whether database write operations should not wait until transaction has been logged
     */
    noWait: boolean;
    constructor(settings: Partial<AceBaseServerTransactionSettings>);
}
export interface IPCClientSettings {
    /**
     * IPC Server host to connect to. Default is `"localhost"`
     */
    host?: string;
    /**
     * IPC Server port number
     */
    port: number;
    /**
     * Whether to use a secure connection to the server. Strongly recommended if `host` is not `"localhost"`. Default is `false`
     */
    ssl?: boolean;
    /**
     * Token used in the IPC Server configuration (optional). The server will refuse connections using the wrong token.
     */
    token?: string;
    /**
     * Determines the role of this IPC client. Only 1 process can be assigned the 'master' role, all other processes must use the role 'worker'
     */
    role: 'master' | 'worker';
}
export type AceBaseServerSettings = Partial<{
    /**
     * Level of messages logged to console
    */
    logLevel: 'verbose' | 'log' | 'warn' | 'error';
    /**
     * ip or hostname to start the server on
    */
    host: string;
    /**
     * port number the server will be listening
     */
    port: number;
    /**
     * target directory path to store/open the database. Default is '.'
     */
    path: string;
    /**
     * Whether to use secure sockets layer (ssl)
     */
    https: AceBaseServerHttpsSettings;
    /**
     * Provide your own server for AceBase to use
     */
    server: Server;
    /**
     * Root path for the AceBase routes
     */
    rootPath: string;
    /**
     * settings that define if and how authentication is used
     */
    authentication: Partial<AceBaseServerAuthenticationSettings>;
    /**
     * maximum size to allow for posted data, eg for updating nodes. Default is '10mb'
     */
    maxPayloadSize: string;
    /**
     * Value to use for Access-Control-Allow-Origin CORS header. Default is '*'
     */
    allowOrigin: string;
    /**
     * Email settings that enable AceBaseServer to send e-mails, eg for welcoming new users, to reset passwords, notify of new sign ins etc
     */
    email: AceBaseServerEmailSettings;
    /**
     * Transaction logging settings. Warning: BETA stage, do NOT use in production yet
     */
    transactions: Partial<AceBaseServerTransactionSettings>;
    /**
     * IPC settings for pm2 or cloud-based clusters. BETA stage, see https://github.com/appy-one/acebase-ipc-server
     */
    ipc: IPCClientSettings | 'socket';
    /**
     * Allows overriding of default storage settings used by the database. ALPHA stage
     */
    storage: AceBaseStorageSettings;
    /**
     * You can turn this on if you are a sponsor. See https://github.com/appy-one/acebase/discussions/100 for more info
     */
    sponsor: boolean;
    /**
     * Whether to use colors in the console logs output
     * @default true
     */
    logColors: boolean;
    /**
     * Callback that runs before the server adds middleware and routes.
     * Use this callback to add custom middleware for logging purposes, header processing etc before the server's own.
     */
    preMiddleware?: (server: AceBaseServer) => Promise<void>;
    /**
     * Callback that runs after the server has added its middleware, before any routes are added.
     * Use this callback to add custom middleware for logging purposes, header processing etc before the server's own.
     */
    postMiddleware?: (server: AceBaseServer) => Promise<void>;
    /**
     * Init callback that runs after all middleware (except 404 handler) has been added, before the server starts listening to incoming calls.
     * Use this callback to extend the server with custom routes, add data validation rules, wait for external events, etc.
     * @param server Instance of the `AceBaseServer`
     */
    init?: (server: AceBaseServer) => Promise<void>;
}>;
export declare class AceBaseServerConfig {
    readonly logLevel: 'verbose' | 'log' | 'warn' | 'error';
    readonly host: string;
    readonly port: number;
    readonly path: string;
    readonly maxPayloadSize: string;
    readonly allowOrigin: string;
    readonly https: AceBaseServerHttpsConfig;
    readonly server?: Server;
    readonly rootPath: string;
    readonly auth: AceBaseServerAuthenticationSettings;
    readonly email: AceBaseServerEmailSettings;
    readonly transactions: AceBaseServerTransactionSettings;
    readonly ipc: AceBaseServerSettings['ipc'];
    readonly storage?: AceBaseStorageSettings;
    readonly sponsor: boolean;
    readonly logColors: boolean;
    readonly preMiddleware?: AceBaseServerSettings['preMiddleware'];
    readonly postMiddleware?: AceBaseServerSettings['postMiddleware'];
    readonly init?: AceBaseServerSettings['init'];
    constructor(settings: AceBaseServerSettings);
}
//# sourceMappingURL=index.d.ts.map