/** * Slack file references — turn whatever an agent was handed (a file id, a * file permalink, a download URL, a message link) into the ids Slack's API * needs. * * Kept in step with the Cloud copy in * `crewly-services/auth/src/slack-file-ref.ts`; both sides parse * the same links. * * @module services/slack/slack-file-ref */ /** What a reference names. */ export interface SlackFileRef { /** Slack file id (`F…`), when the reference names one. */ fileId?: string; /** Uploader's Slack user id, from `/files//` permalinks. */ uploaderUserId?: string; /** Slack team id embedded in `files-pri` / `files-tmb` / `slack-files.com` URLs. */ slackTeamId?: string; /** Workspace host of a permalink (`acme.slack.com`). */ workspaceHost?: string; /** Channel of a message link (`/archives//p`). */ channelId?: string; /** Message ts of a message link (`1696771234.567890`). */ messageTs?: string; /** Thread parent ts of a message link (`?thread_ts=`). */ threadTs?: string; } /** * Parse a file reference. * * Accepted: * - `F0123ABCD` (a bare file id) * - `https://.slack.com/files///` (file permalink) * - `https://files.slack.com/files-pri/-/` (+ `/download/`) * - `https://files.slack.com/files-tmb/--/` * - `https://slack-files.com/--` (public permalink) * - `https://.slack.com/archives//p[?thread_ts=…]` (a message carrying files) * - any of the above wrapped Slack-style as `` * * @param input - What the agent passed * @returns The parsed reference, or null when it is not a Slack file reference */ export declare function parseSlackFileRef(input: string): SlackFileRef | null; /** * Slack file and message links in a piece of text (deduplicated, in order). * * @param text - Message text * @returns Links that {@link parseSlackFileRef} accepts */ export declare function findSlackFileLinks(text: string): string[]; /** Hosts a Slack file download may be served from (redirects included). */ export declare function isSlackDownloadHost(host: string): boolean; /** * Whether a file is text (so it can be handed back as a string). * * @param mimetype - Slack mimetype * @param name - File name * @returns True for text-like files */ export declare function isTextFile(mimetype: string | undefined, name: string | undefined): boolean; /** Exposed for tests. */ export declare const SLACK_ID_PATTERNS: { readonly FILE_ID: RegExp; readonly USER_ID: RegExp; readonly TEAM_ID: RegExp; readonly CHANNEL_ID: RegExp; }; //# sourceMappingURL=slack-file-ref.d.ts.map