Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n f.entity_type as \"entity_type!\",\n f.entity_id as \"entity_id!\",\n f.sort_order as \"sort_order!\",\n f.created_at as \"created_at!\",\n d.\"fileType\" as \"file_type?\",\n dt.sub_type::text as \"document_sub_type?\",\n ch.channel_type::text as \"channel_type?\",\n cm.parent_entity_id as \"channel_id?\"\n FROM favorite f\n -- The comms tables key on uuid while favorite.entity_id is text.\n -- Compare in uuid (casting the favorite side) so their\n -- primary-key indexes are usable; casting the table side to text\n -- forced a full scan of each table on every listing. The regex\n -- guard keeps non-uuid entity_ids from failing the cast: they\n -- yield NULL and simply don't hydrate.\n CROSS JOIN LATERAL (\n SELECT CASE\n WHEN f.entity_id ~ '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'\n THEN f.entity_id::uuid\n END AS entity_uuid\n ) fid\n LEFT JOIN \"Document\" d ON f.entity_type = 'document' AND d.id = f.entity_id\n LEFT JOIN document_sub_type dt ON f.entity_type = 'document' AND dt.document_id = f.entity_id\n LEFT JOIN \"Chat\" c ON f.entity_type = 'chat' AND c.id = f.entity_id\n LEFT JOIN \"Project\" p ON f.entity_type = 'project' AND p.id = f.entity_id\n LEFT JOIN comms_channels ch ON f.entity_type = 'channel' AND ch.id = fid.entity_uuid\n LEFT JOIN comms_messages cm ON f.entity_type = 'channel_message' AND cm.id = fid.entity_uuid AND cm.parent_entity_type = 'channel'\n -- Agent sessions are hard-deleted, so the row's absence is the\n -- deletion check that `deletedAt` is for the item tables.\n LEFT JOIN agent_session ags ON f.entity_type = 'agent_session' AND ags.id = fid.entity_uuid\n WHERE f.user_id = $1\n AND ($2::text[] IS NULL OR f.entity_type = ANY($2))\n AND ($3::text[] IS NULL OR f.entity_id = ANY($3))\n AND (f.entity_type <> 'document' OR (d.id IS NOT NULL AND d.\"deletedAt\" IS NULL))\n AND (f.entity_type <> 'chat' OR (c.id IS NOT NULL AND c.\"deletedAt\" IS NULL))\n AND (f.entity_type <> 'project' OR (p.id IS NOT NULL AND p.\"deletedAt\" IS NULL))\n AND (f.entity_type <> 'agent_session' OR ags.id IS NOT NULL)\n ORDER BY f.sort_order ASC, f.created_at ASC\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "entity_type!",
"type_info": "Text"
},
{
"ordinal": 1,
"name": "entity_id!",
"type_info": "Text"
},
{
"ordinal": 2,
"name": "sort_order!",
"type_info": "Float8"
},
{
"ordinal": 3,
"name": "created_at!",
"type_info": "Timestamptz"
},
{
"ordinal": 4,
"name": "file_type?",
"type_info": "Text"
},
{
"ordinal": 5,
"name": "document_sub_type?",
"type_info": "Text"
},
{
"ordinal": 6,
"name": "channel_type?",
"type_info": "Text"
},
{
"ordinal": 7,
"name": "channel_id?",
"type_info": "Text"
}
],
"parameters": {
"Left": [
"Text",
"TextArray",
"TextArray"
]
},
"nullable": [
false,
false,
false,
false,
true,
null,
null,
false
]
},
"hash": "7c3b46360c39e26a6d6b76614ddad6342ae962f12417a75b6a760153b8119659"
}