import type { NangoConnection } from '../../models/Connection.js';
import type { ServiceResponse } from '../../models/Generic.js';
import type { LogContextGetter } from '@nangohq/logs';
import type { Orchestrator } from '../../clients/orchestrator.js';
import type { DBSlackNotification } from '@nangohq/types';
interface NotificationResponse {
    id: number;
    isOpen: boolean;
    connectionCount: number;
    slack_timestamp?: string;
    admin_slack_timestamp?: string;
}
export declare const generateSlackConnectionId: (accountUUID: string, environmentName: string) => string;
/**
 * _nango_slack_notifications
 * @desc persistence layer for slack notifications and the connection list
 * to be able to trigger or resolve notifications
 *
 *  index:
 *      - open
 *      - environment_id
 *      - name
 */
export declare class SlackService {
    private orchestrator;
    private logContextGetter;
    private actionName;
    private adminConnectionId;
    private integrationKey;
    private nangoAdminUUID;
    private env;
    constructor({ orchestrator, logContextGetter }: {
        orchestrator: Orchestrator;
        logContextGetter: LogContextGetter;
    });
    /**
     * Get Nango Admin Connection
     * @desc get the admin connection information to be able to send a duplicate
     * notification to the Nango admin account
     */
    private getNangoAdminConnection;
    /**
     * Send Duplicate Notification to Nango Admins
     * @desc append the account and environment information to the notification content,
     * add the payload timestamp if available and send the notification to the Nango Admins
     * and with the action response update the slack timestamp to the notification
     * record. This is so future notifications can be sent as updates to the original
     */
    private sendDuplicateNotificationToNangoAdmins;
    /**
     * Update Notification with Timestamp
     * @desc used to keep the slack_timestamp up to date to be able to
     * send updates to the original notification
     */
    private updateNotificationWithTimestamp;
    /**
     * Update Notification with Admin Timestamp
     * @desc used to keep the admin_slack_timestamp up to date to be able to
     * send updates to the original notification
     */
    private updateNotificationWithAdminTimestamp;
    /**
     * Report Failure
     * @desc
     *      1) if slack notifications are enabled and the name is not itself (to avoid an infinite loop)
     *      add the connection to the notification list, grab the connection information
     *      of the admin slack notification action and send the notification to the slack channel
     *      by triggering the action.
     *      2) Update the notification record with the slack timestamp
     *      so future notifications can be sent as updates to the original.
     *      3) Send a duplicate notification to the Nango Admins
     *      4) Add an activity log entry for the notification to the admin account
     */
    reportFailure(nangoConnection: NangoConnection, name: string, type: string, originalActivityLogId: string, environment_id: number, provider: string): Promise<void>;
    /**
     * Report Resolution
     * @desc
     *      1) if there are no more connections that are failing then send
     *      a resolution notification to the slack channel, otherwise update the message
     *      with the decremented connection count.
     *      2) Send a duplicate notification to the Nango Admins
     *      3) Add an activity log entry for the notification to the admin account
     *
     */
    reportResolution(nangoConnection: NangoConnection, syncName: string, type: string, originalActivityLogId: string | null, environment_id: number, provider: string, slack_timestamp: string, admin_slack_timestamp: string, connectionCount: number): Promise<void>;
    /**
     * Has Open Notification
     * @desc Check if there is an open notification for the given name
     * and environment id and if so return the necessary information to be able
     * to update the notification.
     */
    hasOpenNotification(nangoConnection: NangoConnection, name: string, type: string, trx?: import("knex").Knex<any, any[]>): Promise<DBSlackNotification | null>;
    /**
     * Create Notification
     * @desc create a new notification for the given name and environment id
     * and return the id of the created notification.
     */
    createNotification(nangoConnection: NangoConnection, name: string, type: string, trx?: import("knex").Knex<any, any[]>): Promise<Pick<DBSlackNotification, 'id'> | null>;
    /**
     * Add Failing Connection
     * @desc check if there is an open notification for the given name and environment id
     * and if so add the connection id to the connection list.
     */
    addFailingConnection(nangoConnection: NangoConnection, name: string, type: string): Promise<ServiceResponse<NotificationResponse>>;
    /**
     * Remove Failing Connection
     * @desc check if there is an open notification for the given name and environment id
     * and if so remove the connection id from the connection list and report
     * resolution to the slack channel.
     */
    removeFailingConnection({ connection: nangoConnection, name, type, originalActivityLogId, environment_id, provider }: {
        connection: NangoConnection;
        name: string;
        type: string;
        originalActivityLogId: string | null;
        environment_id: number;
        provider: string;
    }): Promise<void>;
    closeAllOpenNotificationsForEnv(environment_id: number): Promise<void>;
    private getLogUrl;
    private getPageUrl;
    private getMessage;
    closeOpenNotificationForConnection({ connectionId, environmentId }: {
        connectionId: number;
        environmentId: number;
    }): Promise<void>;
}
export {};
