2026-04-29 04:12:42 +05:30
|
|
|
type MentionKeyInput = {
|
|
|
|
|
id: number;
|
|
|
|
|
document_type?: string | null;
|
2026-05-26 21:52:04 +05:30
|
|
|
connector_type?: string | null;
|
2026-05-26 21:11:53 +05:30
|
|
|
kind?: "doc" | "folder" | "connector";
|
2026-04-29 04:12:42 +05:30
|
|
|
};
|
|
|
|
|
|
2026-05-09 22:15:51 -07:00
|
|
|
/**
|
|
|
|
|
* Build a stable dedup key for a mention chip.
|
|
|
|
|
*
|
2026-05-26 21:52:04 +05:30
|
|
|
* Each mention kind keys off its real identity fields:
|
|
|
|
|
* docs by document type, folders by folder id, and connectors by
|
|
|
|
|
* connector type + account id.
|
2026-05-09 22:15:51 -07:00
|
|
|
*/
|
2026-04-29 04:12:42 +05:30
|
|
|
export function getMentionDocKey(doc: MentionKeyInput): string {
|
2026-05-09 22:15:51 -07:00
|
|
|
const kind = doc.kind ?? "doc";
|
2026-05-26 21:52:04 +05:30
|
|
|
if (kind === "folder") return `folder:${doc.id}`;
|
|
|
|
|
if (kind === "connector") return `connector:${doc.connector_type ?? "UNKNOWN"}:${doc.id}`;
|
|
|
|
|
return `doc:${doc.document_type ?? "UNKNOWN"}:${doc.id}`;
|
2026-04-29 04:12:42 +05:30
|
|
|
}
|