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 (mentioned.id IS NOT NULL) AS \"mention_exists!\",\n viewer_event.id AS \"resolved_event_id?\",\n ARRAY(\n SELECT viewer_source.calendar_id\n FROM calendar_event_sources viewer_source\n JOIN calendars viewer_calendar\n ON viewer_calendar.id = viewer_source.calendar_id\n JOIN calendar_accounts viewer_account\n ON viewer_account.id = viewer_source.account_id\n WHERE viewer_source.event_id = viewer_event.id\n AND NOT viewer_calendar.is_deleted\n AND viewer_account.sync_status <> 'disabled'\n ORDER BY\n viewer_source.id = calendar_event_canonical_source_id(viewer_event.id) DESC,\n viewer_source.id\n ) AS \"viewer_calendar_ids?\",\n viewer_event.is_channel_shared AS \"is_channel_shared?\",\n viewer_event.is_snapshot AS \"is_snapshot?\",\n viewer_event.inbox_organizes AS \"inbox_organizes?\",\n viewer_event.inbox_attends AS \"inbox_attends?\",\n COALESCE(occurrence_override.title, viewer_event.title) AS \"title?\",\n -- A channel share is capped after its Macro call comes out,\n -- since the join line closes the description.\n CASE\n WHEN viewer_event.is_channel_shared\n THEN COALESCE(occurrence_override.description, viewer_event.description)\n ELSE left(\n COALESCE(occurrence_override.description, viewer_event.description),\n $5\n )\n END AS \"description?\",\n COALESCE(occurrence_override.location, viewer_event.location) AS \"location?\",\n viewer_event.organizer_email AS \"organizer_email?\",\n viewer_event.organizer_name AS \"organizer_name?\",\n viewer_event.recurrence_lines AS \"recurrence_lines?\",\n viewer_event.starts_at AS \"event_starts_at?\",\n viewer_event.ends_at AS \"event_ends_at?\",\n viewer_event.start_date AS \"event_start_date?\",\n viewer_event.end_date AS \"event_end_date?\",\n viewer_event.time_zone AS \"time_zone?\",\n viewer_event.updated_at AS \"updated_at?\",\n occurrence.occurrence_key AS \"occurrence_key?\",\n occurrence.starts_at AS \"occurrence_starts_at?\",\n occurrence.ends_at AS \"occurrence_ends_at?\",\n occurrence.start_date AS \"occurrence_start_date?\",\n occurrence.end_date AS \"occurrence_end_date?\",\n attendees.attendee_count AS \"attendee_count?\"\n FROM unnest($2::uuid[], $3::text[])\n WITH ORDINALITY AS requested(event_id, occurrence_key, ord)\n LEFT JOIN calendar_events mentioned\n ON mentioned.id = requested.event_id\n AND mentioned.status <> 'cancelled'\n LEFT JOIN LATERAL (\n SELECT resolved.*\n FROM (\n SELECT\n candidate.id,\n false AS is_channel_shared,\n (candidate.owner_id = $1) AS is_owned,\n (candidate.id = mentioned.id) AS is_mentioned,\n candidate.is_snapshot,\n -- The copy's own inbox decides how the requester\n -- holds it, as it decides their capabilities: an\n -- inbox they own that organizes it or is on it.\n COALESCE(\n lower(copy_inbox.email_address) = lower(candidate.organizer_email)\n OR EXISTS (\n SELECT 1\n FROM calendar_event_attendees organizer\n WHERE organizer.event_id = candidate.id\n AND organizer.is_organizer\n AND lower(organizer.email) = lower(copy_inbox.email_address)\n )\n -- A calendar the inbox can write organizes it,\n -- as Google names a secondary calendar.\n OR EXISTS (\n SELECT 1\n FROM calendar_accounts organizer_account\n JOIN calendars organizer_calendar\n ON organizer_calendar.account_id = organizer_account.id\n WHERE organizer_account.email_link_id = copy_inbox.id\n AND organizer_account.sync_status <> 'disabled'\n AND NOT organizer_calendar.is_deleted\n AND organizer_calendar.access_role IN ('owner', 'writer')\n AND lower(organizer_calendar.provider_calendar_id)\n = lower(candidate.organizer_email)\n ),\n false\n ) AS inbox_organizes,\n EXISTS (\n SELECT 1\n FROM calendar_event_attendees guest\n WHERE guest.event_id = candidate.id\n AND lower(guest.email) = lower(copy_inbox.email_address)\n ) AS inbox_attends,\n candidate.title,\n candidate.description,\n candidate.location,\n candidate.organizer_email,\n candidate.organizer_name,\n candidate.recurrence_lines,\n candidate.starts_at,\n candidate.ends_at,\n candidate.start_date,\n candidate.end_date,\n candidate.time_zone,\n candidate.updated_at\n FROM calendar_events candidate\n LEFT JOIN email_links copy_inbox\n ON copy_inbox.id = candidate.source_link_id\n AND copy_inbox.macro_id = $1\n WHERE calendar_meeting_uid(candidate.ical_uid)\n = calendar_meeting_uid(mentioned.ical_uid)\n AND candidate.status <> 'cancelled'\n AND (\n candidate.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = candidate.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n UNION ALL\n SELECT\n mentioned.id,\n true,\n false,\n true,\n false,\n false,\n false,\n mentioned.title,\n mentioned.description,\n mentioned.location,\n mentioned.organizer_email,\n mentioned.organizer_name,\n mentioned.recurrence_lines,\n mentioned.starts_at,\n mentioned.ends_at,\n mentioned.start_date,\n mentioned.end_date,\n mentioned.time_zone,\n mentioned.updated_at\n WHERE mentioned.visibility IN ('default', 'public')\n AND EXISTS (\n SELECT 1\n FROM entity_access grant_row\n JOIN comms_channel_participants participant\n ON participant.channel_id::text = grant_row.source_id\n AND participant.user_id = $1\n AND participant.left_at IS NULL\n WHERE grant_row.entity_id = mentioned.id\n AND grant_row.entity_type = 'calendar_event'\n AND grant_row.source_type = 'channel'\n )\n ) resolved\n ORDER BY\n resolved.is_channel_shared,\n resolved.is_owned DESC,\n resolved.is_mentioned DESC,\n resolved.updated_at DESC,\n resolved.id\n LIMIT 1\n ) viewer_event ON true\n LEFT JOIN LATERAL (\n SELECT\n instance.occurrence_key,\n instance.recurrence_id,\n instance.starts_at,\n instance.ends_at,\n instance.start_date,\n instance.end_date\n FROM calendar_event_occurrences instance\n CROSS JOIN LATERAL (\n SELECT COALESCE(\n instance.starts_at,\n instance.start_date::timestamp AT TIME ZONE 'UTC'\n ) AS at\n ) instance_start\n WHERE instance.event_id = viewer_event.id\n AND NOT instance.is_cancelled\n ORDER BY\n (instance.occurrence_key\n IS NOT DISTINCT FROM requested.occurrence_key) DESC,\n (instance_start.at >= $4) DESC,\n CASE WHEN instance_start.at >= $4 THEN instance_start.at END ASC,\n instance_start.at DESC,\n instance.occurrence_key\n LIMIT 1\n ) occurrence ON true\n -- An exception's content replaces the series content for the\n -- previewed occurrence alone, as it does in the event view.\n LEFT JOIN calendar_event_overrides occurrence_override\n ON occurrence_override.event_id = viewer_event.id\n AND occurrence_override.recurrence_id = occurrence.recurrence_id\n LEFT JOIN LATERAL (\n SELECT count(*) AS attendee_count\n FROM calendar_event_attendees attendee\n WHERE attendee.event_id = viewer_event.id\n ) attendees ON true\n ORDER BY requested.ord\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "mention_exists!",
"type_info": "Bool"
},
{
"ordinal": 1,
"name": "resolved_event_id?",
"type_info": "Uuid"
},
{
"ordinal": 2,
"name": "viewer_calendar_ids?",
"type_info": "UuidArray"
},
{
"ordinal": 3,
"name": "is_channel_shared?",
"type_info": "Bool"
},
{
"ordinal": 4,
"name": "is_snapshot?",
"type_info": "Bool"
},
{
"ordinal": 5,
"name": "inbox_organizes?",
"type_info": "Bool"
},
{
"ordinal": 6,
"name": "inbox_attends?",
"type_info": "Bool"
},
{
"ordinal": 7,
"name": "title?",
"type_info": "Text"
},
{
"ordinal": 8,
"name": "description?",
"type_info": "Text"
},
{
"ordinal": 9,
"name": "location?",
"type_info": "Text"
},
{
"ordinal": 10,
"name": "organizer_email?",
"type_info": "Text"
},
{
"ordinal": 11,
"name": "organizer_name?",
"type_info": "Text"
},
{
"ordinal": 12,
"name": "recurrence_lines?",
"type_info": "TextArray"
},
{
"ordinal": 13,
"name": "event_starts_at?",
"type_info": "Timestamptz"
},
{
"ordinal": 14,
"name": "event_ends_at?",
"type_info": "Timestamptz"
},
{
"ordinal": 15,
"name": "event_start_date?",
"type_info": "Date"
},
{
"ordinal": 16,
"name": "event_end_date?",
"type_info": "Date"
},
{
"ordinal": 17,
"name": "time_zone?",
"type_info": "Text"
},
{
"ordinal": 18,
"name": "updated_at?",
"type_info": "Timestamptz"
},
{
"ordinal": 19,
"name": "occurrence_key?",
"type_info": "Text"
},
{
"ordinal": 20,
"name": "occurrence_starts_at?",
"type_info": "Timestamptz"
},
{
"ordinal": 21,
"name": "occurrence_ends_at?",
"type_info": "Timestamptz"
},
{
"ordinal": 22,
"name": "occurrence_start_date?",
"type_info": "Date"
},
{
"ordinal": 23,
"name": "occurrence_end_date?",
"type_info": "Date"
},
{
"ordinal": 24,
"name": "attendee_count?",
"type_info": "Int8"
}
],
"parameters": {
"Left": [
"Text",
"UuidArray",
"TextArray",
"Timestamptz",
"Int4"
]
},
"nullable": [
null,
true,
null,
true,
true,
true,
true,
null,
null,
null,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
null
]
},
"hash": "fcf823f6c8653f971effeb18f04453a9158c71937ee6bcb77f45c7eba0b1f38b"
}