import type { Knex } from '@nangohq/database';
import type { ConnectSessionInput, DBEndUser, DBEnvironment, DBTeam, EndUser, StoredConnection } from '@nangohq/types';
import type { Result } from '@nangohq/utils';
export declare const EndUserMapper: {
    to: (endUser: EndUser) => DBEndUser;
    from: (dbEndUser: DBEndUser) => EndUser;
};
type EndUserErrorCode = 'not_found' | 'creation_failed' | 'update_failed';
export declare class EndUserError extends Error {
    code: EndUserErrorCode;
    payload?: Record<string, unknown>;
    constructor({ code, message, payload }: {
        code: EndUserErrorCode;
        message: string;
        payload?: Record<string, unknown>;
    });
}
export declare function createEndUser(db: Knex, { endUserId, email, displayName, organization, accountId, environmentId }: Pick<EndUser, 'endUserId' | 'email' | 'displayName' | 'organization' | 'accountId' | 'environmentId'>): Promise<Result<EndUser, EndUserError>>;
export declare function getEndUser(db: Knex, props: {
    endUserId: string;
    accountId: number;
    environmentId: number;
} | {
    id: number;
    accountId: number;
    environmentId: number;
}): Promise<Result<EndUser, EndUserError>>;
export declare function updateEndUser(db: Knex, { endUserId, accountId, environmentId, email, displayName, organization }: Pick<EndUser, 'endUserId' | 'email' | 'displayName' | 'organization' | 'accountId' | 'environmentId'>): Promise<Result<EndUser, EndUserError>>;
export declare function deleteEndUser(db: Knex, { endUserId, accountId, environmentId }: {
    endUserId: string;
    accountId: number;
    environmentId: number;
}): Promise<Result<void, EndUserError>>;
export declare function linkConnection(db: Knex, { endUserId, connection }: {
    endUserId: number;
    connection: Pick<StoredConnection, 'id'>;
}): Promise<void>;
export declare function unlinkConnection(db: Knex, { connection }: {
    connection: Pick<StoredConnection, 'id'>;
}): Promise<void>;
export declare function getEndUserByConnectionId(db: Knex, props: {
    connectionId: number;
}): Promise<Result<EndUser, EndUserError>>;
export declare function upsertEndUser(db: Knex, { account, environment, endUserPayload, organization }: {
    account: DBTeam;
    environment: DBEnvironment;
    endUserPayload: ConnectSessionInput['end_user'];
    organization?: ConnectSessionInput['organization'];
}): Promise<Result<EndUser, EndUserError>>;
export {};
