/** * Slack Integration for WORKWAY * * Weniger, aber besser: Extends BaseAPIClient for shared HTTP logic. * * @example * ```typescript * import { Slack } from '@workwayco/integrations/slack'; * * const slack = new Slack({ accessToken: tokens.slack.access_token }); * * // List channels * const channels = await slack.listChannels({ limit: 20 }); * * // Get messages from a channel * const messages = await slack.getMessages({ channel: 'C123456' }); * * // Send a message * const sent = await slack.sendMessage({ * channel: 'C123456', * text: 'Hello from WORKWAY!' * }); * ``` */ import { ActionResult } from '@workwayco/sdk'; import { BaseAPIClient } from '../core/index.js'; /** * Slack channel object */ export interface SlackChannel { id: string; name: string; is_channel: boolean; is_group: boolean; is_im: boolean; is_mpim: boolean; is_private: boolean; is_archived: boolean; is_member: boolean; topic?: { value: string; }; purpose?: { value: string; }; num_members?: number; } /** * Slack message object */ export interface SlackMessage { type: string; ts: string; user?: string; bot_id?: string; subtype?: string; text: string; thread_ts?: string; reply_count?: number; reactions?: Array<{ name: string; count: number; users: string[]; }>; attachments?: Array<{ id: number; fallback?: string; title?: string; text?: string; image_url?: string; }>; files?: Array<{ id: string; name: string; mimetype: string; size: number; url_private?: string; }>; } /** * Slack user object */ export interface SlackUser { id: string; name: string; real_name?: string; profile?: { email?: string; display_name?: string; image_72?: string; }; } /** * Slack integration configuration */ export interface SlackConfig { /** OAuth access token (bot or user) */ accessToken: string; /** Optional: Override API endpoint (for testing) */ apiUrl?: string; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; } /** * Options for listing channels */ export interface ListChannelsOptions { /** Maximum number of channels to return (default: 100, max: 1000) */ limit?: number; /** Pagination cursor */ cursor?: string; /** Include archived channels (default: false) */ excludeArchived?: boolean; /** Filter by channel type: 'public', 'private', 'mpim', 'im' */ types?: string; } /** * Options for getting messages */ export interface GetMessagesOptions { /** Channel ID */ channel: string; /** Number of messages to fetch (default: 20, max: 1000) */ limit?: number; /** Pagination cursor */ cursor?: string; /** * Only messages after this time. Accepts: * - Duration string: "1h", "24h", "7d" (hours/days ago) * - Date object: new Date('2024-01-01') * - Unix seconds string: "1699900000" (raw Slack format) */ since?: string | Date; /** Only messages after this timestamp (raw Slack format - prefer 'since') */ oldest?: string; /** Only messages before this timestamp */ latest?: string; /** Include all metadata about channels/messages (default: false) */ inclusive?: boolean; /** * Filter to human messages only (excludes bots, system messages, joins/leaves) * Zuhandenheit: You think "get what people said" not "filter by bot_id and type" */ humanOnly?: boolean; } /** * Options for sending a message */ export interface SendMessageOptions { /** Channel ID to send to */ channel: string; /** Message text (supports Slack markdown) */ text: string; /** Thread timestamp to reply to (for threading) */ thread_ts?: string; /** Send as reply and also to channel (default: false) */ reply_broadcast?: boolean; /** Unfurl links (default: true) */ unfurl_links?: boolean; /** Unfurl media (default: true) */ unfurl_media?: boolean; /** Parse mode: 'full', 'none' (default: 'full') */ parse?: 'full' | 'none'; } /** * Options for getting user info */ export interface GetUserOptions { /** User ID */ user: string; } /** * Slack Integration * * Weniger, aber besser: Extends BaseAPIClient for shared HTTP logic. */ export declare class Slack extends BaseAPIClient { constructor(config: SlackConfig); /** * List channels the bot/user has access to * * @returns ActionResult with list of channels */ listChannels(options?: ListChannelsOptions): Promise>; /** * Get messages from a channel * * @example * ```typescript * // Get last 24 hours of messages (Zuhandenheit - tool recedes) * const messages = await slack.getMessages({ * channel: 'C123456', * since: '24h' * }); * * // Get last 7 days * const weekMessages = await slack.getMessages({ * channel: 'C123456', * since: '7d' * }); * * // Get since specific date * const messages = await slack.getMessages({ * channel: 'C123456', * since: new Date('2024-01-01') * }); * ``` * * @returns ActionResult with list of messages */ getMessages(options: GetMessagesOptions): Promise>; /** * Get a single message by timestamp * * @returns ActionResult with message data and StandardMessage format */ getMessage(channel: string, ts: string): Promise>; /** * Send a message to a channel * * @returns ActionResult with sent message info */ sendMessage(options: SendMessageOptions): Promise>; /** * Get user information * * @returns ActionResult with user data */ getUser(options: GetUserOptions): Promise>; /** * Search messages across channels * * @returns ActionResult with matching messages */ searchMessages(query: string, options?: { count?: number; sort?: 'score' | 'timestamp'; }): Promise>; /** * Parse human-friendly 'since' value into Slack's timestamp format * * Zuhandenheit: The developer thinks "get last 24 hours" not * "convert milliseconds to seconds and format as string" * * @param since - Duration string ("1h", "24h", "7d"), Date, or raw timestamp * @returns Slack timestamp string (Unix seconds) */ private parseSince; /** * Get capabilities for Slack actions */ private getCapabilities; /** * Convert Slack message to StandardMessage format */ private toStandardMessage; /** * Create IntegrationError from Slack API error */ private createSlackError; } //# sourceMappingURL=index.d.ts.map