/**
 * Slack-specific types and constants for the Socket Mode ingestor.
 *
 * @see https://docs.slack.dev/apis/events-api/using-socket-mode
 */
// ── Payload helpers ─────────────────────────────────────────────────────
/**
 * Extract the Slack event type from an envelope payload.
 * For `events_api` envelopes, the event type is at `payload.event.type`.
 * For `slash_commands`, we use the command name.
 * For `interactive`, we use the interaction type.
 */
export function extractSlackEventType(envelope) {
    const payload = envelope.payload;
    if (!payload)
        return envelope.type;
    switch (envelope.type) {
        case 'events_api': {
            const event = payload.event;
            return typeof event?.type === 'string' ? event.type : 'events_api';
        }
        case 'slash_commands':
            return typeof payload.command === 'string' ? payload.command : 'slash_command';
        case 'interactive':
            return typeof payload.type === 'string' ? payload.type : 'interactive';
        default:
            return envelope.type;
    }
}
/**
 * Extract a channel ID from a Slack envelope payload.
 * Checks `payload.event.channel`, `payload.channel_id`, and `payload.channel.id`.
 */
export function extractSlackChannelId(envelope) {
    const payload = envelope.payload;
    if (!payload)
        return undefined;
    // events_api: event.channel
    const event = payload.event;
    if (typeof event?.channel === 'string')
        return event.channel;
    // slash_commands / interactive: channel_id
    if (typeof payload.channel_id === 'string')
        return payload.channel_id;
    // interactive: channel.id
    const channel = payload.channel;
    if (typeof channel?.id === 'string')
        return channel.id;
    return undefined;
}
/**
 * Extract a user ID from a Slack envelope payload.
 * Checks `payload.event.user`, `payload.user_id`, and `payload.user.id`.
 */
export function extractSlackUserId(envelope) {
    const payload = envelope.payload;
    if (!payload)
        return undefined;
    // events_api: event.user
    const event = payload.event;
    if (typeof event?.user === 'string')
        return event.user;
    // slash_commands / interactive: user_id
    if (typeof payload.user_id === 'string')
        return payload.user_id;
    // interactive: user.id
    const user = payload.user;
    if (typeof user?.id === 'string')
        return user.id;
    return undefined;
}
//# sourceMappingURL=types.js.map