import type { SlackAccessor } from '../../../accessor/slack.ts'; import { type FileEvent, type JsonValue, type PathSpec } from '../../../types.ts'; /** * Map one Slack Events API delivery onto mount paths. * * The consumer runs the transport (an HTTP endpoint for the Events API or a * Socket Mode websocket), unwraps the `event_callback` envelope and passes the * inner event's `type` with its body. * * Every path this returns is rebuilt with the same functions `readdir` names * directories with, which is the reason this lives beside the backend rather * than in the consumer: a channel is `__` through `makeIdName`, a * DM is the *user's* name through `dmDirname`, and the day is bucketed in UTC. * Slack shows local time, so a consumer reimplementing the last rule would name * tomorrow's directory for a fifth of the day and never see an error, because a * notify on a path the mount does not serve evicts nothing. * * Resolution is the reason this holds state. An event names a channel by id * only, and the directory carries the name, so the id has to be resolved * through `conversations.info` (plus `users.info` for a DM, whose directory is * named after the other person). That is one or two API calls the first time a * conversation is seen and none after, against a Slack tier that allows roughly * 50 a minute; a stateless mapper would spend a call per message. A rename * drops the entry rather than patching it, since the whole subtree moved and * the answer is a re-inventory anyway. * * Three kinds of event map to something coarser than a file, and honestly so. A * listing change (a channel created, renamed or archived; a user's profile * edited) is UNKNOWN on the container directory, because the entry names * themselves changed. A shared file is UNKNOWN on that day's `files` directory, * because the rendered filename comes from `fileBlobName` over metadata the * notification does not carry, and the accompanying `message` event already * refreshes `chat.jsonl`. * * Two file events are unmapped, and neither is unmappable. A file blob is * addressed by the day it was *shared*, and neither event carries a * conversation or that day: `file_change` sends only `file_id`, `file_deleted` * sends `file_id` and the deletion's own `event_ts`. Asking Slack does not * recover it either, since `files.info` on a deleted file answers with the * `file_deleted` error. What does recover it is this mount's own index, which * stores each blob's Slack id as `IndexEntry.id`, so a reverse lookup names the * exact path; and a file the index has never seen is one nothing has cached, so * there is nothing to invalidate. The hook simply is not handed the index * today. Until it is, both ride the index TTL, which bounds the staleness * rather than removing it. * * `channel_shared` / `channel_unshared` are a third that looks like a gap and * is not: they change only the Slack Connect flags on the channel object, never * its `name` or `id`, which are the two things the directory is spelled from. * * Mirrors Python `SlackEventHook` (`core/slack/watch/hook.py`). */ export declare class SlackEventHook { private readonly accessor; private readonly dirs; private readonly users; constructor(accessor: SlackAccessor); /** Display name for a user id, memoized. */ private userName; /** Directory a conversation id maps to, memoized. */ private resolve; /** Mount-relative day directory for a conversation and ts. */ private dayDir; /** One UPDATE per day directory the stamps land in. */ private transcripts; /** One UPDATE on the transcript a conversation and ts name. */ private transcript; /** Map a shared file onto that day's attachment directory. */ private fileShared; toEvents(root: PathSpec, eventType: string, payload: JsonValue): Promise; } //# sourceMappingURL=hook.d.ts.map