import { KyselyDB, KyselyTransaction } from "../../../database/types/kysely.types";
import { IntegrationConnection, InsertableIntegrationConnection, UpdatableIntegrationConnection } from "../../../database/types/entity.types";
type ExpectedTokens = Partial<Pick<IntegrationConnection, 'accessToken' | 'refreshToken'>>;
export declare class IntegrationConnectionRepo {
    private readonly db;
    constructor(db: KyselyDB);
    findById(connectionId: string, trx?: KyselyTransaction): Promise<IntegrationConnection | undefined>;
    findByIntegrationAndUser(integrationId: string, userId: string, trx?: KyselyTransaction): Promise<IntegrationConnection | undefined>;
    upsert(connection: InsertableIntegrationConnection, trx?: KyselyTransaction): Promise<IntegrationConnection>;
    upsertWorkspaceConnection(input: {
        integrationId: string;
        userId: string;
        workspaceId: string;
        accessToken: string;
        refreshToken?: string | null;
        tokenExpiresAt?: Date | null;
        scopes?: string | null;
    }, trx?: KyselyTransaction): Promise<IntegrationConnection>;
    update(connectionId: string, data: UpdatableIntegrationConnection, trx?: KyselyTransaction): Promise<IntegrationConnection>;
    deleteByIntegrationAndUser(integrationId: string, userId: string, trx?: KyselyTransaction): Promise<boolean>;
    findByUserAndWorkspace(userId: string, workspaceId: string, trx?: KyselyTransaction): Promise<{
        createdAt: Date;
        metadata: import("@docmost/db/types/db").JsonValue;
        providerUserId: string;
        integrationId: string;
        invalidatedAt: Date;
        type: string;
    }[]>;
    findExpiringTokens(expiresBeforeMs: number, limit: number): Promise<IntegrationConnection[]>;
    updateIfTokensMatch(connectionId: string, expected: ExpectedTokens, data: UpdatableIntegrationConnection, trx?: KyselyTransaction): Promise<boolean>;
    invalidate(connectionId: string, expected?: ExpectedTokens, trx?: KyselyTransaction): Promise<void>;
    deleteByIntegration(integrationId: string, trx?: KyselyTransaction): Promise<void>;
    deleteUserConnections(userId: string, trx?: KyselyTransaction): Promise<void>;
    findWorkspaceConnection(integrationId: string, trx?: KyselyTransaction): Promise<IntegrationConnection | undefined>;
    findUserLink(integrationId: string, providerUserId: string, trx?: KyselyTransaction): Promise<IntegrationConnection | undefined>;
    findUserLinkByUserId(integrationId: string, userId: string, trx?: KyselyTransaction): Promise<IntegrationConnection | undefined>;
    deleteUserLink(integrationId: string, userId: string, trx?: KyselyTransaction): Promise<void>;
    upsertUserLink(input: {
        integrationId: string;
        workspaceId: string;
        userId: string;
        providerUserId: string;
        metadata: Record<string, unknown>;
    }, trx?: KyselyTransaction): Promise<IntegrationConnection>;
    private mergedMetadata;
}
export {};
