Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(calendar_events): keep per-copy event content on each source (#6211)

gbirman35d5f439c325
diff --git a/.sqlx/query-0523298143e4bd07530dd043ca9ab5db805a5f383023b5d60bb0fa1f0291b870.json b/.sqlx/query-0523298143e4bd07530dd043ca9ab5db805a5f383023b5d60bb0fa1f0291b870.json
new file mode 100644
index 0000000000..b8fca9e0ab
--- /dev/null
+++ b/.sqlx/query-0523298143e4bd07530dd043ca9ab5db805a5f383023b5d60bb0fa1f0291b870.json
@@ -0,0 +1,90 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n event.id AS event_id,\n event.owner_id,\n source.is_read_only,\n source.provider_event_id AS \"provider_event_id!\",\n source.provider_recurring_event_id,\n source.account_id AS \"account_id!\",\n source.calendar_id AS \"calendar_id!\",\n calendar.provider_calendar_id,\n account.email_link_id,\n link.fusionauth_user_id,\n link.email_address,\n link.provider::text AS \"provider!\"\n FROM calendar_events event\n JOIN calendar_event_sources source\n ON source.event_id = event.id\n AND source.source_kind = 'google'\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n JOIN email_links link ON link.id = account.email_link_id\n WHERE event.id = $1\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n AND CASE\n WHEN $3::uuid IS NULL\n THEN source.id = calendar_event_canonical_source_id(event.id)\n ELSE source.calendar_id = $3\n END\n AND (\n event.owner_id = $2\n OR EXISTS (\n SELECT 1\n FROM macro_user_links delegation\n WHERE delegation.link_id = event.source_link_id\n AND delegation.primary_macro_id = $2\n )\n )\n ORDER BY\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.id DESC\n LIMIT 1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "event_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "owner_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 2,
+ "name": "is_read_only",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 3,
+ "name": "provider_event_id!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "provider_recurring_event_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "account_id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 6,
+ "name": "calendar_id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 7,
+ "name": "provider_calendar_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 8,
+ "name": "email_link_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 9,
+ "name": "fusionauth_user_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 10,
+ "name": "email_address",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 11,
+ "name": "provider!",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ true,
+ true,
+ true,
+ true,
+ false,
+ false,
+ false,
+ false,
+ null
+ ]
+ },
+ "hash": "0523298143e4bd07530dd043ca9ab5db805a5f383023b5d60bb0fa1f0291b870"
+}
diff --git a/.sqlx/query-0592c52f309fdf95dc4c0dc10dc132f717713056f6f2ff273d387f7dea9f5bfa.json b/.sqlx/query-0592c52f309fdf95dc4c0dc10dc132f717713056f6f2ff273d387f7dea9f5bfa.json
deleted file mode 100644
index 3322916104..0000000000
--- a/.sqlx/query-0592c52f309fdf95dc4c0dc10dc132f717713056f6f2ff273d387f7dea9f5bfa.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n event.id AS event_id,\n event.owner_id,\n event.is_read_only,\n source.provider_event_id AS \"provider_event_id!\",\n source.provider_recurring_event_id,\n source.account_id AS \"account_id!\",\n source.calendar_id AS \"calendar_id!\",\n calendar.provider_calendar_id,\n account.email_link_id,\n link.fusionauth_user_id,\n link.email_address,\n link.provider::text AS \"provider!\"\n FROM calendar_events event\n JOIN calendar_event_sources source\n ON source.event_id = event.id\n AND source.source_kind = 'google'\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n JOIN email_links link ON link.id = account.email_link_id\n WHERE event.id = $1\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n AND (\n event.owner_id = $2\n OR EXISTS (\n SELECT 1\n FROM macro_user_links delegation\n WHERE delegation.link_id = event.source_link_id\n AND delegation.primary_macro_id = $2\n )\n )\n ORDER BY\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.last_seen_at DESC,\n source.id DESC\n LIMIT 1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "event_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "owner_id",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "is_read_only",
- "type_info": "Bool"
- },
- {
- "ordinal": 3,
- "name": "provider_event_id!",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "provider_recurring_event_id",
- "type_info": "Text"
- },
- {
- "ordinal": 5,
- "name": "account_id!",
- "type_info": "Uuid"
- },
- {
- "ordinal": 6,
- "name": "calendar_id!",
- "type_info": "Uuid"
- },
- {
- "ordinal": 7,
- "name": "provider_calendar_id",
- "type_info": "Text"
- },
- {
- "ordinal": 8,
- "name": "email_link_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 9,
- "name": "fusionauth_user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 10,
- "name": "email_address",
- "type_info": "Varchar"
- },
- {
- "ordinal": 11,
- "name": "provider!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Text"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- true,
- true,
- true,
- true,
- false,
- false,
- false,
- false,
- null
- ]
- },
- "hash": "0592c52f309fdf95dc4c0dc10dc132f717713056f6f2ff273d387f7dea9f5bfa"
-}
diff --git a/.sqlx/query-0633d329a1ddc5ec20545d0e14849b94ccbca2358b796ea1472194dc001401b8.json b/.sqlx/query-0633d329a1ddc5ec20545d0e14849b94ccbca2358b796ea1472194dc001401b8.json
new file mode 100644
index 0000000000..4f53668fc0
--- /dev/null
+++ b/.sqlx/query-0633d329a1ddc5ec20545d0e14849b94ccbca2358b796ea1472194dc001401b8.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT event.id AS \"id!\"\n FROM calendar_events event\n WHERE event.id IN (\n SELECT source.event_id\n FROM calendar_event_sources source\n WHERE source.account_id = $1\n GROUP BY source.event_id\n HAVING count(*) > 1\n )\n AND event.content_source_id\n IS DISTINCT FROM calendar_event_canonical_source_id(event.id)\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "0633d329a1ddc5ec20545d0e14849b94ccbca2358b796ea1472194dc001401b8"
+}
diff --git a/.sqlx/query-9304a6dcea9284db39e8eeea9bfcb5a7b75861da2ef70c36726b8ba3f91f3a07.json b/.sqlx/query-0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a.json
similarity index 51%
rename from .sqlx/query-9304a6dcea9284db39e8eeea9bfcb5a7b75861da2ef70c36726b8ba3f91f3a07.json
rename to .sqlx/query-0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a.json
index 4ec826dd09..f128517c09 100644
--- a/.sqlx/query-9304a6dcea9284db39e8eeea9bfcb5a7b75861da2ef70c36726b8ba3f91f3a07.json
+++ b/.sqlx/query-0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n occurrence.event_id,\n canonical_source.calendar_id AS \"canonical_calendar_id?\",\n occurrence.occurrence_key,\n occurrence.recurrence_id,\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 occurrence.is_cancelled,\n event.owner_id,\n event.ical_uid,\n event.title,\n event.description,\n event.location,\n event.status,\n event.visibility,\n event.transparency,\n event.event_type,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.organizer_email,\n event.organizer_name,\n event.creator_email,\n event.creator_name,\n event.conference_url,\n event.conference_provider,\n event.sequence,\n event.is_read_only,\n event.reminders_use_default,\n event.reminder_overrides,\n event.created_at,\n event.updated_at\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n LEFT JOIN LATERAL (\n SELECT source.calendar_id\n FROM calendar_event_sources source\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n WHERE source.event_id = event.id\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n ORDER BY\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.last_seen_at DESC,\n source.id DESC\n LIMIT 1\n ) canonical_source ON true\n WHERE occurrence.owner_id IN (\n SELECT $1::text\n UNION\n SELECT link.child_macro_id\n FROM macro_user_links link\n WHERE link.primary_macro_id = $1\n )\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND (\n event.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = event.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n AND (\n $6::timestamptz IS NULL\n OR (\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ),\n occurrence.event_id,\n occurrence.occurrence_key\n ) > ($6, $7, $8)\n )\n ORDER BY\n COALESCE(occurrence.starts_at, occurrence.start_date::timestamp AT TIME ZONE 'UTC'),\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $9\n ",
+ "query": "\n SELECT\n occurrence.event_id,\n occurrence.occurrence_key,\n occurrence.recurrence_id,\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 occurrence.is_cancelled,\n event.owner_id,\n event.ical_uid,\n event.title,\n event.description,\n event.location,\n event.status,\n event.visibility,\n event.transparency,\n event.event_type,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.organizer_email,\n event.organizer_name,\n event.creator_email,\n event.creator_name,\n event.conference_url,\n event.conference_provider,\n event.sequence,\n event.is_read_only,\n event.reminders_use_default,\n event.reminder_overrides,\n event.created_at,\n event.updated_at\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n WHERE occurrence.owner_id IN (\n SELECT $1::text\n UNION\n SELECT link.child_macro_id\n FROM macro_user_links link\n WHERE link.primary_macro_id = $1\n )\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND (\n event.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = event.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n AND (\n $6::timestamptz IS NULL\n OR (\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ),\n occurrence.event_id,\n occurrence.occurrence_key\n ) > ($6, $7, $8)\n )\n ORDER BY\n COALESCE(occurrence.starts_at, occurrence.start_date::timestamp AT TIME ZONE 'UTC'),\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $9\n ",
"describe": {
"columns": [
{
@@ -10,176 +10,171 @@
},
{
"ordinal": 1,
- "name": "canonical_calendar_id?",
- "type_info": "Uuid"
- },
- {
- "ordinal": 2,
"name": "occurrence_key",
"type_info": "Text"
},
{
- "ordinal": 3,
+ "ordinal": 2,
"name": "recurrence_id",
"type_info": "Text"
},
{
- "ordinal": 4,
+ "ordinal": 3,
"name": "occurrence_starts_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 5,
+ "ordinal": 4,
"name": "occurrence_ends_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 6,
+ "ordinal": 5,
"name": "occurrence_start_date",
"type_info": "Date"
},
{
- "ordinal": 7,
+ "ordinal": 6,
"name": "occurrence_end_date",
"type_info": "Date"
},
{
- "ordinal": 8,
+ "ordinal": 7,
"name": "is_cancelled",
"type_info": "Bool"
},
{
- "ordinal": 9,
+ "ordinal": 8,
"name": "owner_id",
"type_info": "Text"
},
{
- "ordinal": 10,
+ "ordinal": 9,
"name": "ical_uid",
"type_info": "Text"
},
{
- "ordinal": 11,
+ "ordinal": 10,
"name": "title",
"type_info": "Text"
},
{
- "ordinal": 12,
+ "ordinal": 11,
"name": "description",
"type_info": "Text"
},
{
- "ordinal": 13,
+ "ordinal": 12,
"name": "location",
"type_info": "Text"
},
{
- "ordinal": 14,
+ "ordinal": 13,
"name": "status",
"type_info": "Text"
},
{
- "ordinal": 15,
+ "ordinal": 14,
"name": "visibility",
"type_info": "Text"
},
{
- "ordinal": 16,
+ "ordinal": 15,
"name": "transparency",
"type_info": "Text"
},
{
- "ordinal": 17,
+ "ordinal": 16,
"name": "event_type",
"type_info": "Text"
},
{
- "ordinal": 18,
+ "ordinal": 17,
"name": "starts_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 19,
+ "ordinal": 18,
"name": "ends_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 20,
+ "ordinal": 19,
"name": "start_date",
"type_info": "Date"
},
{
- "ordinal": 21,
+ "ordinal": 20,
"name": "end_date",
"type_info": "Date"
},
{
- "ordinal": 22,
+ "ordinal": 21,
"name": "time_zone",
"type_info": "Text"
},
{
- "ordinal": 23,
+ "ordinal": 22,
"name": "recurrence_lines",
"type_info": "TextArray"
},
{
- "ordinal": 24,
+ "ordinal": 23,
"name": "organizer_email",
"type_info": "Text"
},
{
- "ordinal": 25,
+ "ordinal": 24,
"name": "organizer_name",
"type_info": "Text"
},
{
- "ordinal": 26,
+ "ordinal": 25,
"name": "creator_email",
"type_info": "Text"
},
{
- "ordinal": 27,
+ "ordinal": 26,
"name": "creator_name",
"type_info": "Text"
},
{
- "ordinal": 28,
+ "ordinal": 27,
"name": "conference_url",
"type_info": "Text"
},
{
- "ordinal": 29,
+ "ordinal": 28,
"name": "conference_provider",
"type_info": "Text"
},
{
- "ordinal": 30,
+ "ordinal": 29,
"name": "sequence",
"type_info": "Int4"
},
{
- "ordinal": 31,
+ "ordinal": 30,
"name": "is_read_only",
"type_info": "Bool"
},
{
- "ordinal": 32,
+ "ordinal": 31,
"name": "reminders_use_default",
"type_info": "Bool"
},
{
- "ordinal": 33,
+ "ordinal": 32,
"name": "reminder_overrides",
"type_info": "Jsonb"
},
{
- "ordinal": 34,
+ "ordinal": 33,
"name": "created_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 35,
+ "ordinal": 34,
"name": "updated_at",
"type_info": "Timestamptz"
}
@@ -199,7 +194,6 @@
},
"nullable": [
false,
- true,
false,
true,
true,
@@ -236,5 +230,5 @@
false
]
},
- "hash": "9304a6dcea9284db39e8eeea9bfcb5a7b75861da2ef70c36726b8ba3f91f3a07"
+ "hash": "0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a"
}
diff --git a/.sqlx/query-0ba9ccf44bdfdbcb9a2e0a781043bbcd88c79c4947bc58e86bc401c033d9cdbe.json b/.sqlx/query-0c310e49cba7db8b6aceb244ab484db1a47e6dde177e066467e17e005db5c3ea.json
similarity index 54%
rename from .sqlx/query-0ba9ccf44bdfdbcb9a2e0a781043bbcd88c79c4947bc58e86bc401c033d9cdbe.json
rename to .sqlx/query-0c310e49cba7db8b6aceb244ab484db1a47e6dde177e066467e17e005db5c3ea.json
index ba84bc78a7..beb71ac2bc 100644
--- a/.sqlx/query-0ba9ccf44bdfdbcb9a2e0a781043bbcd88c79c4947bc58e86bc401c033d9cdbe.json
+++ b/.sqlx/query-0c310e49cba7db8b6aceb244ab484db1a47e6dde177e066467e17e005db5c3ea.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n DELETE FROM calendar_event_reminder_firings firing\n USING calendar_event_sources source\n WHERE source.event_id = firing.event_id\n AND source.calendar_id = $1\n AND (\n SELECT canonical.calendar_id\n FROM calendar_event_sources canonical\n WHERE canonical.event_id = firing.event_id\n ORDER BY\n canonical.source_sequence DESC,\n canonical.source_updated_at DESC,\n canonical.last_seen_at DESC,\n canonical.id DESC\n LIMIT 1\n ) = $1\n ",
+ "query": "\n DELETE FROM calendar_event_reminder_firings firing\n USING calendar_event_sources source\n WHERE source.event_id = firing.event_id\n AND source.calendar_id = $1\n AND (\n SELECT canonical.calendar_id\n FROM calendar_event_sources canonical\n WHERE canonical.id = calendar_event_canonical_source_id(firing.event_id)\n ) = $1\n ",
"describe": {
"columns": [],
"parameters": {
@@ -10,5 +10,5 @@
},
"nullable": []
},
- "hash": "0ba9ccf44bdfdbcb9a2e0a781043bbcd88c79c4947bc58e86bc401c033d9cdbe"
+ "hash": "0c310e49cba7db8b6aceb244ab484db1a47e6dde177e066467e17e005db5c3ea"
}
diff --git a/.sqlx/query-9f159ad721926ca7018cae3cdda9b9699bacb7dca55c37cbc701dd4b7be2f4e8.json b/.sqlx/query-12224ddeda06d9c7da1b983d2cfe87ed67cc2d1ec694af1a562e625f5f426776.json
similarity index 79%
rename from .sqlx/query-9f159ad721926ca7018cae3cdda9b9699bacb7dca55c37cbc701dd4b7be2f4e8.json
rename to .sqlx/query-12224ddeda06d9c7da1b983d2cfe87ed67cc2d1ec694af1a562e625f5f426776.json
index 202179e5f9..2ec219d9fd 100644
--- a/.sqlx/query-9f159ad721926ca7018cae3cdda9b9699bacb7dca55c37cbc701dd4b7be2f4e8.json
+++ b/.sqlx/query-12224ddeda06d9c7da1b983d2cfe87ed67cc2d1ec694af1a562e625f5f426776.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n event.id AS \"id!\",\n event.owner_id AS \"owner_id!\",\n event.source_link_id AS \"source_link_id!\",\n event.ical_uid AS \"ical_uid!\",\n event.title AS \"title!\",\n event.status AS \"status!\",\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n (cardinality(event.recurrence_lines) > 0) AS \"is_recurring!\",\n event.organizer_email,\n event.created_at AS \"created_at!\",\n event.updated_at AS \"updated_at!\",\n COALESCE(\n (\n SELECT array_agg(lower(attendee.email) ORDER BY lower(attendee.email))\n FROM calendar_event_attendees attendee\n WHERE attendee.event_id = event.id\n ),\n '{}'\n ) AS \"attendee_emails!\"\n FROM calendar_events event\n WHERE event.id = $1\n ",
+ "query": "\n SELECT\n event.id AS \"id!\",\n event.owner_id AS \"owner_id!\",\n event.source_link_id AS \"source_link_id!\",\n event.ical_uid AS \"ical_uid!\",\n event.title AS \"title!\",\n event.status AS \"status!\",\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n (cardinality(event.recurrence_lines) > 0) AS \"is_recurring!\",\n event.organizer_email,\n event.created_at AS \"created_at!\",\n event.updated_at AS \"updated_at!\",\n COALESCE(\n (\n SELECT array_agg(lower(attendee.email) ORDER BY lower(attendee.email))\n FROM calendar_event_attendees attendee\n WHERE attendee.event_id = event.id\n ),\n '{}'\n ) AS \"attendee_emails!\",\n COALESCE(\n (\n SELECT array_agg(DISTINCT source.title ORDER BY source.title)\n FROM calendar_event_sources source\n WHERE source.event_id = event.id\n AND source.title <> ''\n ),\n '{}'\n ) AS \"source_titles!\"\n FROM calendar_events event\n WHERE event.id = $1\n ",
"describe": {
"columns": [
{
@@ -77,6 +77,11 @@
"ordinal": 14,
"name": "attendee_emails!",
"type_info": "TextArray"
+ },
+ {
+ "ordinal": 15,
+ "name": "source_titles!",
+ "type_info": "TextArray"
}
],
"parameters": {
@@ -99,8 +104,9 @@
true,
false,
false,
+ null,
null
]
},
- "hash": "9f159ad721926ca7018cae3cdda9b9699bacb7dca55c37cbc701dd4b7be2f4e8"
+ "hash": "12224ddeda06d9c7da1b983d2cfe87ed67cc2d1ec694af1a562e625f5f426776"
}
diff --git a/.sqlx/query-14ad26177f96192b0004726d0572b02133f44f00fc66b58ba291f8738d7abc0e.json b/.sqlx/query-14ad26177f96192b0004726d0572b02133f44f00fc66b58ba291f8738d7abc0e.json
deleted file mode 100644
index 146e90e8ce..0000000000
--- a/.sqlx/query-14ad26177f96192b0004726d0572b02133f44f00fc66b58ba291f8738d7abc0e.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE calendar_events\n SET title = $2,\n description = $3,\n location = $4,\n status = $5,\n visibility = $6,\n transparency = $7,\n event_type = $28,\n starts_at = $8,\n ends_at = $9,\n start_date = $10,\n end_date = $11,\n time_zone = $12,\n recurrence_lines = $13,\n organizer_email = $14,\n organizer_name = $15,\n creator_email = $26,\n creator_name = $27,\n conference_url = $16,\n conference_provider = $25,\n sequence = $17,\n is_read_only = $18,\n canonical_source_kind = $19,\n canonical_source_updated_at = $20,\n reminders_use_default = $23,\n reminder_overrides = $24,\n created_at = $21,\n updated_at = GREATEST(calendar_events.updated_at, $22)\n WHERE id = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Date",
- "Date",
- "Text",
- "TextArray",
- "Text",
- "Text",
- "Text",
- "Int4",
- "Bool",
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Timestamptz",
- "Bool",
- "Jsonb",
- "Text",
- "Text",
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "14ad26177f96192b0004726d0572b02133f44f00fc66b58ba291f8738d7abc0e"
-}
diff --git a/.sqlx/query-21ff1136b1a1f1ca264f4a651d6d84da2800b4109928023c81f7bfd2bb9e5749.json b/.sqlx/query-21ff1136b1a1f1ca264f4a651d6d84da2800b4109928023c81f7bfd2bb9e5749.json
new file mode 100644
index 0000000000..a900455795
--- /dev/null
+++ b/.sqlx/query-21ff1136b1a1f1ca264f4a651d6d84da2800b4109928023c81f7bfd2bb9e5749.json
@@ -0,0 +1,44 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO calendar_event_sources (\n id, event_id, source_link_id, source_kind, account_id, calendar_id,\n provider_event_id, provider_recurring_event_id,\n provider_etag, raw_payload, source_sequence,\n source_updated_at, normalized_payload,\n title, description, location, event_type, visibility, transparency,\n is_read_only, reminders_use_default, reminder_overrides,\n creator_email, creator_name\n )\n VALUES (\n $1, $2, $3, 'google', $4, $5, $6, $7, $8, $9,\n $10, $11, $12,\n $13, $14, $15, $16, $17, $18,\n $19, $20, $21,\n $22, $23\n )\n ON CONFLICT (account_id, calendar_id, provider_event_id)\n WHERE source_kind = 'google'\n DO UPDATE SET\n event_id = EXCLUDED.event_id,\n provider_recurring_event_id = EXCLUDED.provider_recurring_event_id,\n provider_etag = EXCLUDED.provider_etag,\n raw_payload = EXCLUDED.raw_payload,\n source_sequence = EXCLUDED.source_sequence,\n source_updated_at = EXCLUDED.source_updated_at,\n normalized_payload = EXCLUDED.normalized_payload,\n title = EXCLUDED.title,\n description = EXCLUDED.description,\n location = EXCLUDED.location,\n event_type = EXCLUDED.event_type,\n visibility = EXCLUDED.visibility,\n transparency = EXCLUDED.transparency,\n is_read_only = EXCLUDED.is_read_only,\n reminders_use_default = EXCLUDED.reminders_use_default,\n reminder_overrides = EXCLUDED.reminder_overrides,\n creator_email = EXCLUDED.creator_email,\n creator_name = EXCLUDED.creator_name,\n last_seen_at = now()\n WHERE\n EXCLUDED.source_sequence > calendar_event_sources.source_sequence\n OR (\n EXCLUDED.source_sequence = calendar_event_sources.source_sequence\n AND EXCLUDED.source_updated_at >= calendar_event_sources.source_updated_at\n )\n RETURNING id\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Uuid",
+ "Uuid",
+ "Uuid",
+ "Uuid",
+ "Text",
+ "Text",
+ "Text",
+ "Jsonb",
+ "Int4",
+ "Timestamptz",
+ "Jsonb",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Bool",
+ "Bool",
+ "Jsonb",
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "21ff1136b1a1f1ca264f4a651d6d84da2800b4109928023c81f7bfd2bb9e5749"
+}
diff --git a/.sqlx/query-424b96f762d77b564a23ec262d928cc4744f3cca9278e2b1ace20d074bed0bc4.json b/.sqlx/query-424b96f762d77b564a23ec262d928cc4744f3cca9278e2b1ace20d074bed0bc4.json
new file mode 100644
index 0000000000..762f4f67f9
--- /dev/null
+++ b/.sqlx/query-424b96f762d77b564a23ec262d928cc4744f3cca9278e2b1ace20d074bed0bc4.json
@@ -0,0 +1,27 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE calendar_events\n SET status = $2,\n starts_at = $3,\n ends_at = $4,\n start_date = $5,\n end_date = $6,\n time_zone = $7,\n recurrence_lines = $8,\n organizer_email = $9,\n organizer_name = $10,\n conference_url = $11,\n conference_provider = $12,\n schedule_source_id = $13,\n schedule_updated_at = $14,\n updated_at = GREATEST(calendar_events.updated_at, $14)\n WHERE id = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Date",
+ "Date",
+ "Text",
+ "TextArray",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Uuid",
+ "Timestamptz"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "424b96f762d77b564a23ec262d928cc4744f3cca9278e2b1ace20d074bed0bc4"
+}
diff --git a/.sqlx/query-4321de7517ff3342e7ec70975b7a7c59f8c8ff85b1c0e5eb2a90932a68b46c9a.json b/.sqlx/query-4321de7517ff3342e7ec70975b7a7c59f8c8ff85b1c0e5eb2a90932a68b46c9a.json
new file mode 100644
index 0000000000..0cf417bc26
--- /dev/null
+++ b/.sqlx/query-4321de7517ff3342e7ec70975b7a7c59f8c8ff85b1c0e5eb2a90932a68b46c9a.json
@@ -0,0 +1,36 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT event_id, normalized_payload, source_sequence\n FROM calendar_event_sources\n WHERE source_kind = 'google'\n AND account_id = $1\n AND calendar_id = $2\n AND provider_event_id = $3\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "event_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "normalized_payload",
+ "type_info": "Jsonb"
+ },
+ {
+ "ordinal": 2,
+ "name": "source_sequence",
+ "type_info": "Int4"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Uuid",
+ "Text"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false
+ ]
+ },
+ "hash": "4321de7517ff3342e7ec70975b7a7c59f8c8ff85b1c0e5eb2a90932a68b46c9a"
+}
diff --git a/.sqlx/query-4a06ad42fcddd9cbefe1d087bba871552c8dbb81f8350feac05fa5a02c10e21c.json b/.sqlx/query-4a06ad42fcddd9cbefe1d087bba871552c8dbb81f8350feac05fa5a02c10e21c.json
new file mode 100644
index 0000000000..613507f1aa
--- /dev/null
+++ b/.sqlx/query-4a06ad42fcddd9cbefe1d087bba871552c8dbb81f8350feac05fa5a02c10e21c.json
@@ -0,0 +1,87 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n owner_id AS \"owner_id!\",\n event_id AS \"event_id!\",\n ical_uid AS \"ical_uid!\",\n occurrence_key AS \"occurrence_key!\",\n title AS \"title!\",\n visibility AS \"visibility!\",\n time_zone,\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 FROM (\n SELECT DISTINCT ON (event.owner_id, event.ical_uid, occurrence.occurrence_key)\n event.owner_id,\n occurrence.event_id,\n event.ical_uid,\n occurrence.occurrence_key,\n source.title,\n source.visibility,\n event.time_zone,\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 COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ) AS occurrence_ordering\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n JOIN calendar_event_sources source ON source.event_id = event.id\n JOIN calendars calendar\n ON calendar.id = source.calendar_id\n AND calendar.is_primary\n AND NOT calendar.is_deleted\n JOIN calendar_accounts account\n ON account.id = source.account_id\n AND account.sync_status <> 'disabled'\n WHERE occurrence.owner_id IN (\n SELECT teammate.user_id\n FROM team_user membership\n JOIN team_user teammate ON teammate.team_id = membership.team_id\n WHERE membership.user_id = $1\n AND teammate.user_id <> $1\n )\n AND source.event_type = 'out_of_office'\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n ORDER BY\n event.owner_id,\n event.ical_uid,\n occurrence.occurrence_key,\n occurrence.event_id,\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.id DESC\n ) occurrence\n ORDER BY\n occurrence.occurrence_ordering,\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $6\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "owner_id!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "event_id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 2,
+ "name": "ical_uid!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "occurrence_key!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "title!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "visibility!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 6,
+ "name": "time_zone",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 7,
+ "name": "occurrence_starts_at?",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 8,
+ "name": "occurrence_ends_at?",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 9,
+ "name": "occurrence_start_date?",
+ "type_info": "Date"
+ },
+ {
+ "ordinal": 10,
+ "name": "occurrence_end_date?",
+ "type_info": "Date"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Date",
+ "Date",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true,
+ true,
+ true,
+ true,
+ true
+ ]
+ },
+ "hash": "4a06ad42fcddd9cbefe1d087bba871552c8dbb81f8350feac05fa5a02c10e21c"
+}
diff --git a/.sqlx/query-4d119454360426cdf88d2df06f194193029a754d47241203f405298052185c46.json b/.sqlx/query-4d119454360426cdf88d2df06f194193029a754d47241203f405298052185c46.json
deleted file mode 100644
index 848298e39e..0000000000
--- a/.sqlx/query-4d119454360426cdf88d2df06f194193029a754d47241203f405298052185c46.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT event_id, normalized_payload\n FROM calendar_event_sources\n WHERE source_kind = 'google'\n AND account_id = $1\n AND calendar_id = $2\n AND provider_event_id = $3\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "event_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "normalized_payload",
- "type_info": "Jsonb"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Uuid",
- "Text"
- ]
- },
- "nullable": [
- false,
- false
- ]
- },
- "hash": "4d119454360426cdf88d2df06f194193029a754d47241203f405298052185c46"
-}
diff --git a/.sqlx/query-533df398c05e2767367446f5dbb9f3987220791f5f32397dd8b5775c5d4b8ad3.json b/.sqlx/query-533df398c05e2767367446f5dbb9f3987220791f5f32397dd8b5775c5d4b8ad3.json
new file mode 100644
index 0000000000..01b672ed89
--- /dev/null
+++ b/.sqlx/query-533df398c05e2767367446f5dbb9f3987220791f5f32397dd8b5775c5d4b8ad3.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE calendar_events\n SET status = $2,\n starts_at = $3,\n ends_at = $4,\n start_date = $5,\n end_date = $6,\n time_zone = $7,\n recurrence_lines = $8,\n schedule_source_id = $9,\n schedule_updated_at = $10,\n updated_at = GREATEST(calendar_events.updated_at, $10)\n WHERE id = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Date",
+ "Date",
+ "Text",
+ "TextArray",
+ "Uuid",
+ "Timestamptz"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "533df398c05e2767367446f5dbb9f3987220791f5f32397dd8b5775c5d4b8ad3"
+}
diff --git a/.sqlx/query-5964c92792dd1df7ff62f6ea9ca9f0d3921fa7f9bf47d8b691858df35722a820.json b/.sqlx/query-5964c92792dd1df7ff62f6ea9ca9f0d3921fa7f9bf47d8b691858df35722a820.json
new file mode 100644
index 0000000000..0f50760cfd
--- /dev/null
+++ b/.sqlx/query-5964c92792dd1df7ff62f6ea9ca9f0d3921fa7f9bf47d8b691858df35722a820.json
@@ -0,0 +1,51 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO calendar_events (\n id, owner_id, source_link_id, ical_uid, title, description, location,\n status, visibility, transparency, event_type,\n starts_at, ends_at, start_date, end_date, time_zone,\n recurrence_lines, organizer_email, organizer_name,\n creator_email, creator_name,\n conference_url, conference_provider, sequence, is_read_only,\n canonical_source_kind,\n reminders_use_default, reminder_overrides,\n created_at, updated_at, schedule_updated_at\n )\n VALUES (\n $1, $2, $3, $4, $5, $6, $7,\n $8, $9, $10, $30,\n $11, $12, $13, $14, $15,\n $16, $17, $18,\n $28, $29,\n $19, $27, $20, $21, $22,\n $25, $26,\n $23, $24, $24\n )\n ON CONFLICT (owner_id, source_link_id, ical_uid) DO NOTHING\n RETURNING id\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Uuid",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Date",
+ "Date",
+ "Text",
+ "TextArray",
+ "Text",
+ "Text",
+ "Text",
+ "Int4",
+ "Bool",
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Bool",
+ "Jsonb",
+ "Text",
+ "Text",
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "5964c92792dd1df7ff62f6ea9ca9f0d3921fa7f9bf47d8b691858df35722a820"
+}
diff --git a/.sqlx/query-5d684a90e538f05eb71cb4ec127da7f8698082e6a36f7e53dd3ec09900fd5684.json b/.sqlx/query-5d684a90e538f05eb71cb4ec127da7f8698082e6a36f7e53dd3ec09900fd5684.json
new file mode 100644
index 0000000000..f2c5350ba1
--- /dev/null
+++ b/.sqlx/query-5d684a90e538f05eb71cb4ec127da7f8698082e6a36f7e53dd3ec09900fd5684.json
@@ -0,0 +1,14 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE calendar_event_sources source\n SET is_read_only = live.is_read_only,\n normalized_payload = jsonb_set(\n source.normalized_payload,\n '{event,isReadOnly}',\n to_jsonb(live.is_read_only)\n )\n FROM (\n SELECT\n calendar.id AS calendar_id,\n NOT COALESCE(calendar.access_role IN ('owner', 'writer'), false)\n AS is_read_only\n FROM calendars calendar\n WHERE calendar.account_id = $1\n ) live\n WHERE source.calendar_id = live.calendar_id\n AND source.is_read_only IS DISTINCT FROM live.is_read_only\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "5d684a90e538f05eb71cb4ec127da7f8698082e6a36f7e53dd3ec09900fd5684"
+}
diff --git a/.sqlx/query-67eae087e054d9ee6b69e62afc257ca564634573b6755705471f760ca6a5d7cc.json b/.sqlx/query-67eae087e054d9ee6b69e62afc257ca564634573b6755705471f760ca6a5d7cc.json
deleted file mode 100644
index 476922371c..0000000000
--- a/.sqlx/query-67eae087e054d9ee6b69e62afc257ca564634573b6755705471f760ca6a5d7cc.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO calendar_event_sources (\n id, event_id, source_link_id, source_kind, account_id, calendar_id,\n provider_event_id, provider_recurring_event_id,\n provider_etag, raw_payload, source_sequence,\n source_updated_at, normalized_payload\n )\n VALUES (\n $1, $2, $3, 'google', $4, $5, $6, $7, $8, $9,\n $10, $11, $12\n )\n ON CONFLICT (account_id, calendar_id, provider_event_id)\n WHERE source_kind = 'google'\n DO UPDATE SET\n event_id = EXCLUDED.event_id,\n provider_recurring_event_id = EXCLUDED.provider_recurring_event_id,\n provider_etag = EXCLUDED.provider_etag,\n raw_payload = EXCLUDED.raw_payload,\n source_sequence = EXCLUDED.source_sequence,\n source_updated_at = EXCLUDED.source_updated_at,\n normalized_payload = EXCLUDED.normalized_payload,\n last_seen_at = now()\n WHERE\n EXCLUDED.source_sequence > calendar_event_sources.source_sequence\n OR (\n EXCLUDED.source_sequence = calendar_event_sources.source_sequence\n AND EXCLUDED.source_updated_at >= calendar_event_sources.source_updated_at\n )\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Uuid",
- "Uuid",
- "Uuid",
- "Uuid",
- "Text",
- "Text",
- "Text",
- "Jsonb",
- "Int4",
- "Timestamptz",
- "Jsonb"
- ]
- },
- "nullable": []
- },
- "hash": "67eae087e054d9ee6b69e62afc257ca564634573b6755705471f760ca6a5d7cc"
-}
diff --git a/.sqlx/query-6d25203568e8d3b2465b5305f9eed99f0d33a0e834a34f1618267626cba12cd6.json b/.sqlx/query-6d25203568e8d3b2465b5305f9eed99f0d33a0e834a34f1618267626cba12cd6.json
deleted file mode 100644
index 6d3e030973..0000000000
--- a/.sqlx/query-6d25203568e8d3b2465b5305f9eed99f0d33a0e834a34f1618267626cba12cd6.json
+++ /dev/null
@@ -1,87 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n owner_id AS \"owner_id!\",\n event_id AS \"event_id!\",\n ical_uid AS \"ical_uid!\",\n occurrence_key AS \"occurrence_key!\",\n title AS \"title!\",\n visibility AS \"visibility!\",\n time_zone,\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 FROM (\n SELECT DISTINCT ON (event.owner_id, event.ical_uid, occurrence.occurrence_key)\n event.owner_id,\n occurrence.event_id,\n event.ical_uid,\n occurrence.occurrence_key,\n event.title,\n event.visibility,\n event.time_zone,\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 COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ) AS occurrence_ordering\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n WHERE occurrence.owner_id IN (\n SELECT teammate.user_id\n FROM team_user membership\n JOIN team_user teammate ON teammate.team_id = membership.team_id\n WHERE membership.user_id = $1\n AND teammate.user_id <> $1\n )\n AND event.event_type = 'out_of_office'\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND EXISTS (\n SELECT 1\n FROM calendar_event_sources source\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n WHERE source.event_id = event.id\n AND calendar.is_primary\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n )\n AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n ORDER BY\n event.owner_id,\n event.ical_uid,\n occurrence.occurrence_key,\n occurrence.event_id\n ) occurrence\n ORDER BY\n occurrence.occurrence_ordering,\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $6\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "owner_id!",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "event_id!",
- "type_info": "Uuid"
- },
- {
- "ordinal": 2,
- "name": "ical_uid!",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "occurrence_key!",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "title!",
- "type_info": "Text"
- },
- {
- "ordinal": 5,
- "name": "visibility!",
- "type_info": "Text"
- },
- {
- "ordinal": 6,
- "name": "time_zone",
- "type_info": "Text"
- },
- {
- "ordinal": 7,
- "name": "occurrence_starts_at?",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "occurrence_ends_at?",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 9,
- "name": "occurrence_start_date?",
- "type_info": "Date"
- },
- {
- "ordinal": 10,
- "name": "occurrence_end_date?",
- "type_info": "Date"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Date",
- "Date",
- "Int8"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- false,
- true,
- true,
- true,
- true,
- true
- ]
- },
- "hash": "6d25203568e8d3b2465b5305f9eed99f0d33a0e834a34f1618267626cba12cd6"
-}
diff --git a/.sqlx/query-76f024f53145b7aaebc22382820fccaacafd9247a97a6e95391615d488f40bdf.json b/.sqlx/query-76f024f53145b7aaebc22382820fccaacafd9247a97a6e95391615d488f40bdf.json
new file mode 100644
index 0000000000..499aea49f8
--- /dev/null
+++ b/.sqlx/query-76f024f53145b7aaebc22382820fccaacafd9247a97a6e95391615d488f40bdf.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE calendar_events event\n SET is_read_only = source.is_read_only\n FROM calendar_event_sources source\n WHERE source.id = event.content_source_id\n AND source.account_id = $1\n AND event.is_read_only IS DISTINCT FROM source.is_read_only\n RETURNING event.id, event.owner_id\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "owner_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false
+ ]
+ },
+ "hash": "76f024f53145b7aaebc22382820fccaacafd9247a97a6e95391615d488f40bdf"
+}
diff --git a/.sqlx/query-c1fc681e3b5e5883ea7e639711d1aae33e91c21a723cd6abffad2a1fd5f75c9d.json b/.sqlx/query-95c2bc70d05599917f88ff7c62d3bd9da4db949fa1607d9b06af52900766d3ff.json
similarity index 53%
rename from .sqlx/query-c1fc681e3b5e5883ea7e639711d1aae33e91c21a723cd6abffad2a1fd5f75c9d.json
rename to .sqlx/query-95c2bc70d05599917f88ff7c62d3bd9da4db949fa1607d9b06af52900766d3ff.json
index 4419d34703..7949d848e5 100644
--- a/.sqlx/query-c1fc681e3b5e5883ea7e639711d1aae33e91c21a723cd6abffad2a1fd5f75c9d.json
+++ b/.sqlx/query-95c2bc70d05599917f88ff7c62d3bd9da4db949fa1607d9b06af52900766d3ff.json
@@ -1,17 +1,17 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT source_kind, source_updated_at, normalized_payload, calendar_id\n FROM calendar_event_sources\n WHERE event_id = $1\n ORDER BY\n source_sequence DESC,\n source_updated_at DESC,\n last_seen_at DESC,\n id DESC\n LIMIT 1\n ",
+ "query": "\n SELECT\n source.id,\n source.source_kind,\n source.normalized_payload,\n source.calendar_id\n FROM calendar_event_sources source\n WHERE source.id = calendar_event_canonical_source_id($1)\n ",
"describe": {
"columns": [
{
"ordinal": 0,
- "name": "source_kind",
- "type_info": "Text"
+ "name": "id",
+ "type_info": "Uuid"
},
{
"ordinal": 1,
- "name": "source_updated_at",
- "type_info": "Timestamptz"
+ "name": "source_kind",
+ "type_info": "Text"
},
{
"ordinal": 2,
@@ -36,5 +36,5 @@
true
]
},
- "hash": "c1fc681e3b5e5883ea7e639711d1aae33e91c21a723cd6abffad2a1fd5f75c9d"
+ "hash": "95c2bc70d05599917f88ff7c62d3bd9da4db949fa1607d9b06af52900766d3ff"
}
diff --git a/.sqlx/query-9a69869bd06416fd5dbda614a51766d3bdb3bcd999bbab1095f7387ffd0bd76e.json b/.sqlx/query-9a69869bd06416fd5dbda614a51766d3bdb3bcd999bbab1095f7387ffd0bd76e.json
new file mode 100644
index 0000000000..2cf234c23b
--- /dev/null
+++ b/.sqlx/query-9a69869bd06416fd5dbda614a51766d3bdb3bcd999bbab1095f7387ffd0bd76e.json
@@ -0,0 +1,30 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE calendar_events\n SET content_source_id = $17,\n title = $2,\n description = $3,\n location = $4,\n visibility = $5,\n transparency = $6,\n event_type = $7,\n creator_email = $8,\n creator_name = $9,\n sequence = $10,\n is_read_only = $11,\n canonical_source_kind = $12,\n reminders_use_default = $13,\n reminder_overrides = $14,\n created_at = $15,\n updated_at = GREATEST(calendar_events.updated_at, $16)\n WHERE id = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Int4",
+ "Bool",
+ "Text",
+ "Bool",
+ "Jsonb",
+ "Timestamptz",
+ "Timestamptz",
+ "Uuid"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "9a69869bd06416fd5dbda614a51766d3bdb3bcd999bbab1095f7387ffd0bd76e"
+}
diff --git a/.sqlx/query-9cf4fa61648a752ae37a6efbc6ded75464d023236f4eb55d658a1c910e98f467.json b/.sqlx/query-9cf4fa61648a752ae37a6efbc6ded75464d023236f4eb55d658a1c910e98f467.json
new file mode 100644
index 0000000000..19be140c5b
--- /dev/null
+++ b/.sqlx/query-9cf4fa61648a752ae37a6efbc6ded75464d023236f4eb55d658a1c910e98f467.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT source.id, source.calendar_id AS \"calendar_id!\"\n FROM calendar_event_sources source\n WHERE source.id = calendar_event_canonical_source_id($1)\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "calendar_id!",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ true
+ ]
+ },
+ "hash": "9cf4fa61648a752ae37a6efbc6ded75464d023236f4eb55d658a1c910e98f467"
+}
diff --git a/.sqlx/query-688f06e254bf86ce99c0cfe72061f31776da34a6d2fea1c80c648911bb91d591.json b/.sqlx/query-9d0054d1834583b3fdde883f832643cadcd273e88dacf348c2f25f60ec154fca.json
similarity index 69%
rename from .sqlx/query-688f06e254bf86ce99c0cfe72061f31776da34a6d2fea1c80c648911bb91d591.json
rename to .sqlx/query-9d0054d1834583b3fdde883f832643cadcd273e88dacf348c2f25f60ec154fca.json
index 3bc6a92ff2..3bc9eac97b 100644
--- a/.sqlx/query-688f06e254bf86ce99c0cfe72061f31776da34a6d2fea1c80c648911bb91d591.json
+++ b/.sqlx/query-9d0054d1834583b3fdde883f832643cadcd273e88dacf348c2f25f60ec154fca.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO calendar_event_reminder_firings (\n event_id, occurrence_key, minutes_before, fire_at\n )\n SELECT DISTINCT\n occurrence.event_id,\n occurrence.occurrence_key,\n offsets.minutes,\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE $2\n ) - make_interval(mins => offsets.minutes)\n FROM calendar_event_sources source\n JOIN calendar_events event ON event.id = source.event_id\n JOIN calendar_event_occurrences occurrence ON occurrence.event_id = event.id\n CROSS JOIN LATERAL (\n SELECT (reminder.value ->> 'minutes')::int AS minutes\n FROM jsonb_array_elements(\n CASE\n -- Status-style events never resolve the calendar\n -- defaults, mirroring EventType::uses_calendar_default_reminders.\n WHEN event.reminders_use_default\n AND event.event_type IN ('default', 'from_gmail')\n THEN $3::jsonb\n WHEN event.reminders_use_default THEN '[]'::jsonb\n ELSE event.reminder_overrides\n END\n ) AS reminder(value)\n WHERE reminder.value ->> 'method' = 'popup'\n AND (reminder.value ->> 'minutes')::int >= 0\n ) offsets\n WHERE source.calendar_id = $1\n AND (\n SELECT canonical.calendar_id\n FROM calendar_event_sources canonical\n WHERE canonical.event_id = event.id\n ORDER BY\n canonical.source_sequence DESC,\n canonical.source_updated_at DESC,\n canonical.last_seen_at DESC,\n canonical.id DESC\n LIMIT 1\n ) = $1\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE $2\n ) - make_interval(mins => offsets.minutes) > now() - interval '1 day'\n ON CONFLICT (event_id, occurrence_key, minutes_before) DO NOTHING\n ",
+ "query": "\n INSERT INTO calendar_event_reminder_firings (\n event_id, occurrence_key, minutes_before, fire_at\n )\n SELECT DISTINCT\n occurrence.event_id,\n occurrence.occurrence_key,\n offsets.minutes,\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE $2\n ) - make_interval(mins => offsets.minutes)\n FROM calendar_event_sources source\n JOIN calendar_events event ON event.id = source.event_id\n JOIN calendar_event_occurrences occurrence ON occurrence.event_id = event.id\n CROSS JOIN LATERAL (\n SELECT (reminder.value ->> 'minutes')::int AS minutes\n FROM jsonb_array_elements(\n CASE\n -- Status-style events never resolve the calendar\n -- defaults, mirroring EventType::uses_calendar_default_reminders.\n WHEN event.reminders_use_default\n AND event.event_type IN ('default', 'from_gmail')\n THEN $3::jsonb\n WHEN event.reminders_use_default THEN '[]'::jsonb\n ELSE event.reminder_overrides\n END\n ) AS reminder(value)\n WHERE reminder.value ->> 'method' = 'popup'\n AND (reminder.value ->> 'minutes')::int >= 0\n ) offsets\n WHERE source.calendar_id = $1\n AND (\n SELECT canonical.calendar_id\n FROM calendar_event_sources canonical\n WHERE canonical.id = calendar_event_canonical_source_id(event.id)\n ) = $1\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE $2\n ) - make_interval(mins => offsets.minutes) > now() - interval '1 day'\n ON CONFLICT (event_id, occurrence_key, minutes_before) DO NOTHING\n ",
"describe": {
"columns": [],
"parameters": {
@@ -12,5 +12,5 @@
},
"nullable": []
},
- "hash": "688f06e254bf86ce99c0cfe72061f31776da34a6d2fea1c80c648911bb91d591"
+ "hash": "9d0054d1834583b3fdde883f832643cadcd273e88dacf348c2f25f60ec154fca"
}
diff --git a/.sqlx/query-b36c119013aeae33ffcc6a71d8900b07604ade59b1f59fc8d5c30b1ef5fd25a3.json b/.sqlx/query-b36c119013aeae33ffcc6a71d8900b07604ade59b1f59fc8d5c30b1ef5fd25a3.json
new file mode 100644
index 0000000000..96e89cad0a
--- /dev/null
+++ b/.sqlx/query-b36c119013aeae33ffcc6a71d8900b07604ade59b1f59fc8d5c30b1ef5fd25a3.json
@@ -0,0 +1,94 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n source.event_id,\n source.calendar_id AS \"calendar_id!\",\n source.title,\n source.description,\n source.location,\n source.event_type,\n source.visibility,\n source.transparency,\n source.is_read_only,\n source.reminders_use_default,\n source.reminder_overrides,\n source.creator_email,\n source.creator_name\n FROM calendar_event_sources source\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n WHERE source.event_id = ANY($1)\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n ORDER BY\n source.event_id,\n calendar.is_primary DESC,\n (calendar.access_role IN ('owner', 'writer')) DESC NULLS LAST,\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.id DESC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "event_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "calendar_id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 2,
+ "name": "title",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "description",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "location",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "event_type",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 6,
+ "name": "visibility",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 7,
+ "name": "transparency",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 8,
+ "name": "is_read_only",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 9,
+ "name": "reminders_use_default",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 10,
+ "name": "reminder_overrides",
+ "type_info": "Jsonb"
+ },
+ {
+ "ordinal": 11,
+ "name": "creator_email",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 12,
+ "name": "creator_name",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ false,
+ true,
+ false,
+ true,
+ true,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true,
+ true
+ ]
+ },
+ "hash": "b36c119013aeae33ffcc6a71d8900b07604ade59b1f59fc8d5c30b1ef5fd25a3"
+}
diff --git a/.sqlx/query-b513d6d6e7098981035344f69cb5aa642b91337af089b4322e41aedf2423bb71.json b/.sqlx/query-b513d6d6e7098981035344f69cb5aa642b91337af089b4322e41aedf2423bb71.json
new file mode 100644
index 0000000000..8eb6743424
--- /dev/null
+++ b/.sqlx/query-b513d6d6e7098981035344f69cb5aa642b91337af089b4322e41aedf2423bb71.json
@@ -0,0 +1,74 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n event.owner_id,\n event.title,\n event.time_zone AS \"event_time_zone?\",\n occurrence.starts_at,\n occurrence.ends_at,\n occurrence.start_date,\n occurrence.end_date,\n canonical_calendar.time_zone AS \"calendar_time_zone?\",\n CASE WHEN EXISTS (\n SELECT 1\n FROM calendar_event_overrides override\n WHERE override.event_id = event.id\n AND override.recurrence_id = occurrence.recurrence_id\n AND override.attendees_overridden\n )\n THEN EXISTS (\n SELECT 1\n FROM calendar_event_override_attendees attendee\n JOIN email_links owner_inbox\n ON owner_inbox.macro_id = event.owner_id\n AND lower(owner_inbox.email_address::text) = attendee.email\n WHERE attendee.event_id = event.id\n AND attendee.recurrence_id = occurrence.recurrence_id\n AND attendee.response_status = 'declined'\n )\n ELSE EXISTS (\n SELECT 1\n FROM calendar_event_attendees attendee\n JOIN email_links owner_inbox\n ON owner_inbox.macro_id = event.owner_id\n AND lower(owner_inbox.email_address::text) = attendee.email\n WHERE attendee.event_id = event.id\n AND attendee.response_status = 'declined'\n )\n END AS \"declined!\"\n FROM calendar_event_reminder_firings firing\n JOIN calendar_events event ON event.id = firing.event_id\n JOIN calendar_event_occurrences occurrence\n ON occurrence.event_id = firing.event_id\n AND occurrence.occurrence_key = firing.occurrence_key\n JOIN calendar_event_sources canonical_source\n ON canonical_source.id = calendar_event_canonical_source_id(event.id)\n JOIN calendars canonical_calendar\n ON canonical_calendar.id = canonical_source.calendar_id\n WHERE firing.event_id = $1\n AND firing.occurrence_key = $2\n AND firing.minutes_before = $3\n AND firing.fire_at = $4\n AND firing.fire_at > $5\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "owner_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "title",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 2,
+ "name": "event_time_zone?",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "starts_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 4,
+ "name": "ends_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 5,
+ "name": "start_date",
+ "type_info": "Date"
+ },
+ {
+ "ordinal": 6,
+ "name": "end_date",
+ "type_info": "Date"
+ },
+ {
+ "ordinal": 7,
+ "name": "calendar_time_zone?",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 8,
+ "name": "declined!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Int4",
+ "Timestamptz",
+ "Timestamptz"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ null
+ ]
+ },
+ "hash": "b513d6d6e7098981035344f69cb5aa642b91337af089b4322e41aedf2423bb71"
+}
diff --git a/.sqlx/query-c0ba4a4e05265b6ab06b1f0c3bd4fec7daa320c01f004e2e60c89c82b0a1d0a9.json b/.sqlx/query-c0ba4a4e05265b6ab06b1f0c3bd4fec7daa320c01f004e2e60c89c82b0a1d0a9.json
new file mode 100644
index 0000000000..36f4cac73a
--- /dev/null
+++ b/.sqlx/query-c0ba4a4e05265b6ab06b1f0c3bd4fec7daa320c01f004e2e60c89c82b0a1d0a9.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "SELECT schedule_source_id, schedule_updated_at FROM calendar_events WHERE id = $1",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "schedule_source_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "schedule_updated_at",
+ "type_info": "Timestamptz"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ true,
+ false
+ ]
+ },
+ "hash": "c0ba4a4e05265b6ab06b1f0c3bd4fec7daa320c01f004e2e60c89c82b0a1d0a9"
+}
diff --git a/.sqlx/query-dcb72c6cdb8e4cff572a124af818f4e777c5171c7e5e67808e6fd5a6c0f4599e.json b/.sqlx/query-dcb72c6cdb8e4cff572a124af818f4e777c5171c7e5e67808e6fd5a6c0f4599e.json
deleted file mode 100644
index 7dcdf0a09d..0000000000
--- a/.sqlx/query-dcb72c6cdb8e4cff572a124af818f4e777c5171c7e5e67808e6fd5a6c0f4599e.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO calendar_events (\n id, owner_id, source_link_id, ical_uid, title, description, location,\n status, visibility, transparency, event_type,\n starts_at, ends_at, start_date, end_date, time_zone,\n recurrence_lines, organizer_email, organizer_name,\n creator_email, creator_name,\n conference_url, conference_provider, sequence, is_read_only,\n canonical_source_kind,\n canonical_source_updated_at,\n reminders_use_default, reminder_overrides,\n created_at, updated_at\n )\n VALUES (\n $1, $2, $3, $4, $5, $6, $7,\n $8, $9, $10, $30,\n $11, $12, $13, $14, $15,\n $16, $17, $18,\n $28, $29,\n $19, $27, $20, $21, $22, $24,\n $25, $26,\n $23, $24\n )\n ON CONFLICT (owner_id, source_link_id, ical_uid) DO UPDATE SET\n title = EXCLUDED.title,\n description = EXCLUDED.description,\n location = EXCLUDED.location,\n status = EXCLUDED.status,\n visibility = EXCLUDED.visibility,\n transparency = EXCLUDED.transparency,\n event_type = EXCLUDED.event_type,\n starts_at = EXCLUDED.starts_at,\n ends_at = EXCLUDED.ends_at,\n start_date = EXCLUDED.start_date,\n end_date = EXCLUDED.end_date,\n time_zone = EXCLUDED.time_zone,\n recurrence_lines = EXCLUDED.recurrence_lines,\n organizer_email = EXCLUDED.organizer_email,\n organizer_name = EXCLUDED.organizer_name,\n creator_email = EXCLUDED.creator_email,\n creator_name = EXCLUDED.creator_name,\n conference_url = EXCLUDED.conference_url,\n conference_provider = EXCLUDED.conference_provider,\n sequence = EXCLUDED.sequence,\n is_read_only = EXCLUDED.is_read_only,\n canonical_source_kind = EXCLUDED.canonical_source_kind,\n canonical_source_updated_at = EXCLUDED.canonical_source_updated_at,\n reminders_use_default = EXCLUDED.reminders_use_default,\n reminder_overrides = EXCLUDED.reminder_overrides,\n updated_at = GREATEST(calendar_events.updated_at, EXCLUDED.updated_at)\n WHERE\n EXCLUDED.sequence > calendar_events.sequence\n OR (\n EXCLUDED.sequence = calendar_events.sequence\n AND EXCLUDED.canonical_source_updated_at\n >= calendar_events.canonical_source_updated_at\n )\n -- `xmax = 0` distinguishes the INSERT from the DO UPDATE: a\n -- freshly inserted row carries no updating transaction id.\n RETURNING id, (xmax = 0) AS \"inserted!\"\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "inserted!",
- "type_info": "Bool"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Uuid",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Date",
- "Date",
- "Text",
- "TextArray",
- "Text",
- "Text",
- "Text",
- "Int4",
- "Bool",
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Bool",
- "Jsonb",
- "Text",
- "Text",
- "Text",
- "Text"
- ]
- },
- "nullable": [
- false,
- null
- ]
- },
- "hash": "dcb72c6cdb8e4cff572a124af818f4e777c5171c7e5e67808e6fd5a6c0f4599e"
-}
diff --git a/.sqlx/query-dd4f3ff26fd5c8c3f30f135559175d052a10ea7ef88c811c0dec8508bfc5d09a.json b/.sqlx/query-dd4f3ff26fd5c8c3f30f135559175d052a10ea7ef88c811c0dec8508bfc5d09a.json
deleted file mode 100644
index 74443f25d7..0000000000
--- a/.sqlx/query-dd4f3ff26fd5c8c3f30f135559175d052a10ea7ef88c811c0dec8508bfc5d09a.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n event.owner_id,\n event.title,\n event.time_zone AS \"event_time_zone?\",\n occurrence.starts_at,\n occurrence.ends_at,\n occurrence.start_date,\n occurrence.end_date,\n canonical_source.calendar_time_zone AS \"calendar_time_zone?\",\n CASE WHEN EXISTS (\n SELECT 1\n FROM calendar_event_overrides override\n WHERE override.event_id = event.id\n AND override.recurrence_id = occurrence.recurrence_id\n AND override.attendees_overridden\n )\n THEN EXISTS (\n SELECT 1\n FROM calendar_event_override_attendees attendee\n JOIN email_links owner_inbox\n ON owner_inbox.macro_id = event.owner_id\n AND lower(owner_inbox.email_address::text) = attendee.email\n WHERE attendee.event_id = event.id\n AND attendee.recurrence_id = occurrence.recurrence_id\n AND attendee.response_status = 'declined'\n )\n ELSE EXISTS (\n SELECT 1\n FROM calendar_event_attendees attendee\n JOIN email_links owner_inbox\n ON owner_inbox.macro_id = event.owner_id\n AND lower(owner_inbox.email_address::text) = attendee.email\n WHERE attendee.event_id = event.id\n AND attendee.response_status = 'declined'\n )\n END AS \"declined!\"\n FROM calendar_event_reminder_firings firing\n JOIN calendar_events event ON event.id = firing.event_id\n JOIN calendar_event_occurrences occurrence\n ON occurrence.event_id = firing.event_id\n AND occurrence.occurrence_key = firing.occurrence_key\n JOIN LATERAL (\n SELECT calendar.time_zone AS calendar_time_zone\n FROM calendar_event_sources source\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n WHERE source.event_id = event.id\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n ORDER BY\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.last_seen_at DESC,\n source.id DESC\n LIMIT 1\n ) canonical_source ON true\n WHERE firing.event_id = $1\n AND firing.occurrence_key = $2\n AND firing.minutes_before = $3\n AND firing.fire_at = $4\n AND firing.fire_at > $5\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "owner_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "title",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "event_time_zone?",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "starts_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 4,
- "name": "ends_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 5,
- "name": "start_date",
- "type_info": "Date"
- },
- {
- "ordinal": 6,
- "name": "end_date",
- "type_info": "Date"
- },
- {
- "ordinal": 7,
- "name": "calendar_time_zone?",
- "type_info": "Text"
- },
- {
- "ordinal": 8,
- "name": "declined!",
- "type_info": "Bool"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Int4",
- "Timestamptz",
- "Timestamptz"
- ]
- },
- "nullable": [
- false,
- false,
- true,
- true,
- true,
- true,
- true,
- true,
- null
- ]
- },
- "hash": "dd4f3ff26fd5c8c3f30f135559175d052a10ea7ef88c811c0dec8508bfc5d09a"
-}
diff --git a/.sqlx/query-df102eca4b34620401aebc5c8d69fc85c2e9883678a2a1232d236ab5d2eaa378.json b/.sqlx/query-df102eca4b34620401aebc5c8d69fc85c2e9883678a2a1232d236ab5d2eaa378.json
new file mode 100644
index 0000000000..a1545f1dcd
--- /dev/null
+++ b/.sqlx/query-df102eca4b34620401aebc5c8d69fc85c2e9883678a2a1232d236ab5d2eaa378.json
@@ -0,0 +1,40 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT status, event_type, reminders_use_default, reminder_overrides\n FROM calendar_events\n WHERE id = $1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "status",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "event_type",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 2,
+ "name": "reminders_use_default",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 3,
+ "name": "reminder_overrides",
+ "type_info": "Jsonb"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ false
+ ]
+ },
+ "hash": "df102eca4b34620401aebc5c8d69fc85c2e9883678a2a1232d236ab5d2eaa378"
+}
diff --git a/apps/docs/AI/mcp/tools/delete-calendar-event.mdx b/apps/docs/AI/mcp/tools/delete-calendar-event.mdx
index 087e704f8c..721b5c5fee 100644
--- a/apps/docs/AI/mcp/tools/delete-calendar-event.mdx
+++ b/apps/docs/AI/mcp/tools/delete-calendar-event.mdx
@@ -14,5 +14,6 @@ For recurring events, `scope` controls how much is removed: "all" (default) remo
| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `eventId` | string | Yes | The event's id, from ListCalendarEvents or CreateCalendarEvent. |
+| `calendarId` | string | No | The `calendarId` of the copy to delete, from the `copies` of its ListCalendarEvents entry, for an event synced from more than one calendar. Omit to delete the event's primary copy. |
| `scope` | `"all"` \| `"this_event"` \| `"this_and_following"` | No | How much of a recurring series a deletion removes. |
| `recurrenceId` | string | No | The `recurrenceId` of the targeted occurrence, from its ListCalendarEvents entry. Required for "this_event" and "this_and_following". |
diff --git a/apps/docs/AI/mcp/tools/update-calendar-event.mdx b/apps/docs/AI/mcp/tools/update-calendar-event.mdx
index f21df23220..1a05aea2d4 100644
--- a/apps/docs/AI/mcp/tools/update-calendar-event.mdx
+++ b/apps/docs/AI/mcp/tools/update-calendar-event.mdx
@@ -18,6 +18,7 @@ Passing `attendees` replaces the full attendee list — include everyone who sho
| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `eventId` | string | Yes | The event's id, from ListCalendarEvents or CreateCalendarEvent. |
+| `calendarId` | string | No | The `calendarId` of the copy to update, from the `copies` of its ListCalendarEvents entry, for an event synced from more than one calendar. Omit to update the event's primary copy. |
| `scope` | `"all"` \| `"this_event"` | Yes | How much of a recurring series an update applies to. |
| `recurrenceId` | string | No | The `recurrenceId` of the targeted occurrence, from its ListCalendarEvents entry. Required for "this_event"; omit for "all". |
| `title` | string | No | Replacement title. Omit to keep the current title. |
diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts
index bb00fb5938..45b64347c1 100644
--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts
+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts
@@ -1393,6 +1393,7 @@ export const DeleteBotResponse = z.object({
export const DeleteCalendarEvent = z.object({
eventId: z.string().uuid(),
+ calendarId: z.union([z.string().uuid(), z.null()]).optional(),
scope: z
.any()
.superRefine((x, ctx) => {
@@ -1826,6 +1827,15 @@ export const ListCalendarEventsResponse = z.object({
conferenceUrl: z.union([z.string(), z.null()]).optional(),
isReadOnly: z.boolean(),
calendarId: z.union([z.string().uuid(), z.null()]).optional(),
+ copies: z
+ .array(
+ z.object({
+ calendarId: z.string().uuid(),
+ title: z.string(),
+ isReadOnly: z.boolean(),
+ })
+ )
+ .optional(),
})
),
truncated: z.boolean(),
@@ -4433,6 +4443,7 @@ export const TextEditorCodeExecutionResponse = z.object({
export const UpdateCalendarEvent = z.object({
eventId: z.string().uuid(),
+ calendarId: z.union([z.string().uuid(), z.null()]).optional(),
scope: z.any().superRefine((x, ctx) => {
const schemas = [z.literal('all'), z.literal('this_event')];
const errors = schemas.reduce<z.ZodError[]>(
diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
index 2dc088e479..454d9ee6c6 100644
--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
@@ -2339,6 +2339,10 @@ export interface DeleteCalendarEvent {
* The event's id, from ListCalendarEvents or CreateCalendarEvent.
*/
eventId: string;
+ /**
+ * The `calendarId` of the copy to delete, from the `copies` of its ListCalendarEvents entry, for an event synced from more than one calendar. Omit to delete the event's primary copy.
+ */
+ calendarId?: string | null;
scope?: DeletionScopeInput;
/**
* The `recurrenceId` of the targeted occurrence, from its ListCalendarEvents entry. Required for "this_event" and "this_and_following".
@@ -3083,6 +3087,29 @@ export interface CalendarEventListItem {
* Calendar the event belongs to, when known.
*/
calendarId?: string | null;
+ /**
+ * Every calendar carrying a copy of this event when there is more than
+ * one, primary first. Pass a copy's `calendarId` to UpdateCalendarEvent
+ * or DeleteCalendarEvent to address that copy instead of the primary.
+ */
+ copies?: CalendarEventCopyItem[];
+}
+/**
+ * One calendar's copy of an event synced from several calendars.
+ */
+export interface CalendarEventCopyItem {
+ /**
+ * Calendar holding this copy.
+ */
+ calendarId: string;
+ /**
+ * The copy's own title.
+ */
+ title: string;
+ /**
+ * Whether that calendar prohibits modifying the copy.
+ */
+ isReadOnly: boolean;
}
/**
* List the calendars the user can see across their connected inboxes, with each calendar's `calendarId`, display name, owning inbox address, and whether it is primary and writable.
@@ -5240,6 +5267,10 @@ export interface UpdateCalendarEvent {
* The event's id, from ListCalendarEvents or CreateCalendarEvent.
*/
eventId: string;
+ /**
+ * The `calendarId` of the copy to update, from the `copies` of its ListCalendarEvents entry, for an event synced from more than one calendar. Omit to update the event's primary copy.
+ */
+ calendarId?: string | null;
scope: UpdateScopeInput;
/**
* The `recurrenceId` of the targeted occurrence, from its ListCalendarEvents entry. Required for "this_event"; omit for "all".
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts
index 9c51d003db..5711914229 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts
@@ -14,6 +14,7 @@ import type { CalendarEventDescription } from './calendarEventDescription';
import type { CalendarEventLocation } from './calendarEventLocation';
import type { CalendarEventOrganizerEmail } from './calendarEventOrganizerEmail';
import type { CalendarEventOrganizerName } from './calendarEventOrganizerName';
+import type { CalendarEventSourceContent } from './calendarEventSourceContent';
import type { EventReminders } from './eventReminders';
import type { EventStatus } from './eventStatus';
import type { EventTime } from './eventTime';
@@ -23,6 +24,9 @@ import type { EventVisibility } from './eventVisibility';
/**
* A stable, first-class Macro calendar event entity.
+
+Content fields hold the canonical source's values: the account's primary
+calendar copy when one is synced, else the freshest remaining copy.
*/
export interface CalendarEvent {
/** Attendees, keyed by email during persistence. */
@@ -52,7 +56,7 @@ equal. */
icalUid: string;
/** Macro entity identifier. */
id: string;
- /** Whether the current user can edit the canonical source. */
+ /** Whether the canonical source's calendar prohibits editing it. */
isReadOnly: boolean;
/** Optional physical or virtual location label. */
location?: CalendarEventLocation;
@@ -73,6 +77,11 @@ compare equal. */
* @minimum 0
*/
sequence: number;
+ /** Content of every active copy of this event, canonical first: the
+primary calendar's copy, then the freshest. A client picks the copy
+whose calendar it is showing and falls back to the first. Populated
+only on the read path, so stored projections omit it. */
+ sources?: CalendarEventSourceContent[];
/** Event status. */
status: EventStatus;
/** Timed or all-day shape. */
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContent.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContent.ts
new file mode 100644
index 0000000000..503c482bbf
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContent.ts
@@ -0,0 +1,48 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { CalendarEventSourceContentCreatorEmail } from './calendarEventSourceContentCreatorEmail';
+import type { CalendarEventSourceContentCreatorName } from './calendarEventSourceContentCreatorName';
+import type { CalendarEventSourceContentDescription } from './calendarEventSourceContentDescription';
+import type { CalendarEventSourceContentLocation } from './calendarEventSourceContentLocation';
+import type { EventReminders } from './eventReminders';
+import type { EventTransparency } from './eventTransparency';
+import type { EventType } from './eventType';
+import type { EventVisibility } from './eventVisibility';
+
+/**
+ * The content one provider copy of an event carries.
+
+Google keeps these fields per calendar copy: a shared calendar's copy of a
+member's event can have its own title, type, reminders, and access role.
+The entity holds its canonical source's values. Every other copy's values
+are read from here so a client can show the copy that belongs to the
+calendar being viewed.
+ */
+export interface CalendarEventSourceContent {
+ /** Calendar this copy lives on. */
+ calendarId: string;
+ /** Provider-reported creator email. */
+ creatorEmail?: CalendarEventSourceContentCreatorEmail;
+ /** Provider-reported creator display name. */
+ creatorName?: CalendarEventSourceContentCreatorName;
+ /** Optional event body. */
+ description?: CalendarEventSourceContentDescription;
+ /** Provider event type. */
+ eventType: EventType;
+ /** Whether the calendar's access role prohibits editing this copy. */
+ isReadOnly: boolean;
+ /** Optional physical or virtual location label. */
+ location?: CalendarEventSourceContentLocation;
+ /** Reminder configuration of this copy. */
+ reminders: EventReminders;
+ /** Display title. */
+ title: string;
+ /** Availability behavior. */
+ transparency: EventTransparency;
+ /** Event visibility. */
+ visibility: EventVisibility;
+}
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentCreatorEmail.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentCreatorEmail.ts
new file mode 100644
index 0000000000..592a61c7c1
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentCreatorEmail.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator email.
+ */
+export type CalendarEventSourceContentCreatorEmail = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentCreatorName.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentCreatorName.ts
new file mode 100644
index 0000000000..c89133ddd0
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentCreatorName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator display name.
+ */
+export type CalendarEventSourceContentCreatorName = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentDescription.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentDescription.ts
new file mode 100644
index 0000000000..a00dc6d6d2
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentDescription.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Optional event body.
+ */
+export type CalendarEventSourceContentDescription = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentLocation.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentLocation.ts
new file mode 100644
index 0000000000..336801d5e0
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventSourceContentLocation.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Optional physical or virtual location label.
+ */
+export type CalendarEventSourceContentLocation = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/deleteCalendarEventParams.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/deleteCalendarEventParams.ts
index c014a40e12..a60878e047 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/deleteCalendarEventParams.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/deleteCalendarEventParams.ts
@@ -7,6 +7,11 @@
import type { CalendarDeletionScopeParam } from './calendarDeletionScopeParam';
export type DeleteCalendarEventParams = {
+ /**
+ * Calendar whose copy of the event is deleted, for an event synced from
+more than one calendar. Omit to delete the canonical copy.
+ */
+ calendarId?: string;
/**
* Deletion scope; defaults to the entire event or series.
*/
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts
index 00b45ceae1..dc306ea669 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts
@@ -158,6 +158,11 @@ export * from './calendarEventDescription';
export * from './calendarEventLocation';
export * from './calendarEventOrganizerEmail';
export * from './calendarEventOrganizerName';
+export * from './calendarEventSourceContent';
+export * from './calendarEventSourceContentCreatorEmail';
+export * from './calendarEventSourceContentCreatorName';
+export * from './calendarEventSourceContentDescription';
+export * from './calendarEventSourceContentLocation';
export * from './calendarMutationApiError';
export * from './calendarMutationErrorCode';
export * from './calendarRsvpScopeParam';
@@ -294,6 +299,7 @@ export * from './refreshEmailEventOneOfThree';
export * from './refreshEmailEventOneOfThreeEvent';
export * from './resyncResponse';
export * from './rsvpCalendarEventRequest';
+export * from './rsvpCalendarEventRequestCalendarId';
export * from './rsvpCalendarEventRequestRecurrenceId';
export * from './rsvpCalendarEventRequestScope';
export * from './sendMessageRequest';
@@ -323,6 +329,7 @@ export * from './unblockSenderRequest';
export * from './unresolvedSignatureImagesError';
export * from './updateCalendarEventRequest';
export * from './updateCalendarEventRequestAttendees';
+export * from './updateCalendarEventRequestCalendarId';
export * from './updateCalendarEventRequestConference';
export * from './updateCalendarEventRequestDescription';
export * from './updateCalendarEventRequestLocation';
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequest.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequest.ts
index e3f2cfc4a0..716fb4c546 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequest.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequest.ts
@@ -6,6 +6,7 @@
*/
import type { AttendeeResponseStatus } from './attendeeResponseStatus';
+import type { RsvpCalendarEventRequestCalendarId } from './rsvpCalendarEventRequestCalendarId';
import type { RsvpCalendarEventRequestRecurrenceId } from './rsvpCalendarEventRequestRecurrenceId';
import type { RsvpCalendarEventRequestScope } from './rsvpCalendarEventRequestScope';
@@ -13,6 +14,9 @@ import type { RsvpCalendarEventRequestScope } from './rsvpCalendarEventRequestSc
* Request body setting the requester's RSVP on an event.
*/
export interface RsvpCalendarEventRequest {
+ /** Calendar whose copy of the event is answered, for an event synced
+from more than one calendar. Omit to answer on the canonical copy. */
+ calendarId?: RsvpCalendarEventRequestCalendarId;
/** Original-start key of the occurrence the response targets. */
recurrenceId?: RsvpCalendarEventRequestRecurrenceId;
/** The response to record for the connected account. */
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequestCalendarId.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequestCalendarId.ts
new file mode 100644
index 0000000000..026fdbbf6c
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/rsvpCalendarEventRequestCalendarId.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Calendar whose copy of the event is answered, for an event synced
+from more than one calendar. Omit to answer on the canonical copy.
+ */
+export type RsvpCalendarEventRequestCalendarId = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts
index f0b9dc488d..324d8e6a55 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { UpdateCalendarEventRequestAttendees } from './updateCalendarEventRequestAttendees';
+import type { UpdateCalendarEventRequestCalendarId } from './updateCalendarEventRequestCalendarId';
import type { UpdateCalendarEventRequestConference } from './updateCalendarEventRequestConference';
import type { UpdateCalendarEventRequestDescription } from './updateCalendarEventRequestDescription';
import type { UpdateCalendarEventRequestLocation } from './updateCalendarEventRequestLocation';
@@ -24,6 +25,9 @@ import type { UpdateCalendarEventRequestVisibility } from './updateCalendarEvent
export interface UpdateCalendarEventRequest {
/** Replacement attendee list. */
attendees?: UpdateCalendarEventRequestAttendees;
+ /** Calendar whose copy of the event is patched, for an event synced from
+more than one calendar. Omit to patch the canonical copy. */
+ calendarId?: UpdateCalendarEventRequestCalendarId;
conference?: UpdateCalendarEventRequestConference;
/** Replacement description; an empty string clears it. */
description?: UpdateCalendarEventRequestDescription;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestCalendarId.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestCalendarId.ts
new file mode 100644
index 0000000000..979a1ed89b
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestCalendarId.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Calendar whose copy of the event is patched, for an event synced from
+more than one calendar. Omit to patch the canonical copy.
+ */
+export type UpdateCalendarEventRequestCalendarId = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/openapi.json b/apps/web/src/lib/service-clients/service-email/openapi.json
index 3e4dd3f746..5166b29ae5 100644
--- a/apps/web/src/lib/service-clients/service-email/openapi.json
+++ b/apps/web/src/lib/service-clients/service-email/openapi.json
@@ -130,6 +130,16 @@
"format": "uuid"
}
},
+ {
+ "name": "calendarId",
+ "in": "query",
+ "description": "Calendar whose copy of the event is deleted, for an event synced from\nmore than one calendar. Omit to delete the canonical copy.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "uuid"
+ }
+ },
{
"name": "scope",
"in": "query",
@@ -4505,7 +4515,7 @@
},
"CalendarEvent": {
"type": "object",
- "description": "A stable, first-class Macro calendar event entity.",
+ "description": "A stable, first-class Macro calendar event entity.\n\nContent fields hold the canonical source's values: the account's primary\ncalendar copy when one is synced, else the freshest remaining copy.",
"required": [
"id",
"ownerId",
@@ -4582,7 +4592,7 @@
},
"isReadOnly": {
"type": "boolean",
- "description": "Whether the current user can edit the canonical source."
+ "description": "Whether the canonical source's calendar prohibits editing it."
},
"location": {
"type": ["string", "null"],
@@ -4617,6 +4627,13 @@
"description": "Provider/iCalendar sequence number.",
"minimum": 0
},
+ "sources": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CalendarEventSourceContent"
+ },
+ "description": "Content of every active copy of this event, canonical first: the\nprimary calendar's copy, then the freshest. A client picks the copy\nwhose calendar it is showing and falls back to the first. Populated\nonly on the read path, so stored projections omit it."
+ },
"status": {
"$ref": "#/components/schemas/EventStatus",
"description": "Event status."
@@ -4644,6 +4661,66 @@
}
}
},
+ "CalendarEventSourceContent": {
+ "type": "object",
+ "description": "The content one provider copy of an event carries.\n\nGoogle keeps these fields per calendar copy: a shared calendar's copy of a\nmember's event can have its own title, type, reminders, and access role.\nThe entity holds its canonical source's values. Every other copy's values\nare read from here so a client can show the copy that belongs to the\ncalendar being viewed.",
+ "required": [
+ "calendarId",
+ "title",
+ "eventType",
+ "visibility",
+ "transparency",
+ "isReadOnly",
+ "reminders"
+ ],
+ "properties": {
+ "calendarId": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Calendar this copy lives on."
+ },
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
+ "description": {
+ "type": ["string", "null"],
+ "description": "Optional event body."
+ },
+ "eventType": {
+ "$ref": "#/components/schemas/EventType",
+ "description": "Provider event type."
+ },
+ "isReadOnly": {
+ "type": "boolean",
+ "description": "Whether the calendar's access role prohibits editing this copy."
+ },
+ "location": {
+ "type": ["string", "null"],
+ "description": "Optional physical or virtual location label."
+ },
+ "reminders": {
+ "$ref": "#/components/schemas/EventReminders",
+ "description": "Reminder configuration of this copy."
+ },
+ "title": {
+ "type": "string",
+ "description": "Display title."
+ },
+ "transparency": {
+ "$ref": "#/components/schemas/EventTransparency",
+ "description": "Availability behavior."
+ },
+ "visibility": {
+ "$ref": "#/components/schemas/EventVisibility",
+ "description": "Event visibility."
+ }
+ }
+ },
"CalendarMutationApiError": {
"type": "object",
"description": "HTTP error body returned by calendar mutation endpoints.",
@@ -5922,6 +5999,11 @@
"description": "Request body setting the requester's RSVP on an event.",
"required": ["response"],
"properties": {
+ "calendarId": {
+ "type": ["string", "null"],
+ "format": "uuid",
+ "description": "Calendar whose copy of the event is answered, for an event synced\nfrom more than one calendar. Omit to answer on the canonical copy."
+ },
"recurrenceId": {
"type": ["string", "null"],
"description": "Original-start key of the occurrence the response targets."
@@ -6205,6 +6287,11 @@
},
"description": "Replacement attendee list."
},
+ "calendarId": {
+ "type": ["string", "null"],
+ "format": "uuid",
+ "description": "Calendar whose copy of the event is patched, for an event synced from\nmore than one calendar. Omit to patch the canonical copy."
+ },
"conference": {
"oneOf": [
{
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts
index 46b5e7547a..392b66b274 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts
@@ -14,6 +14,7 @@ import type { CalendarEventDescription } from './calendarEventDescription';
import type { CalendarEventLocation } from './calendarEventLocation';
import type { CalendarEventOrganizerEmail } from './calendarEventOrganizerEmail';
import type { CalendarEventOrganizerName } from './calendarEventOrganizerName';
+import type { CalendarEventSourceContent } from './calendarEventSourceContent';
import type { EventReminders } from './eventReminders';
import type { EventStatus } from './eventStatus';
import type { EventTime } from './eventTime';
@@ -23,6 +24,9 @@ import type { EventVisibility } from './eventVisibility';
/**
* A stable, first-class Macro calendar event entity.
+
+Content fields hold the canonical source's values: the account's primary
+calendar copy when one is synced, else the freshest remaining copy.
*/
export interface CalendarEvent {
/** Attendees, keyed by email during persistence. */
@@ -52,7 +56,7 @@ equal. */
icalUid: string;
/** Macro entity identifier. */
id: string;
- /** Whether the current user can edit the canonical source. */
+ /** Whether the canonical source's calendar prohibits editing it. */
isReadOnly: boolean;
/** Optional physical or virtual location label. */
location?: CalendarEventLocation;
@@ -73,6 +77,11 @@ compare equal. */
* @minimum 0
*/
sequence: number;
+ /** Content of every active copy of this event, canonical first: the
+primary calendar's copy, then the freshest. A client picks the copy
+whose calendar it is showing and falls back to the first. Populated
+only on the read path, so stored projections omit it. */
+ sources?: CalendarEventSourceContent[];
/** Event status. */
status: EventStatus;
/** Timed or all-day shape. */
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContent.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContent.ts
new file mode 100644
index 0000000000..abee5549b6
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContent.ts
@@ -0,0 +1,48 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { CalendarEventSourceContentCreatorEmail } from './calendarEventSourceContentCreatorEmail';
+import type { CalendarEventSourceContentCreatorName } from './calendarEventSourceContentCreatorName';
+import type { CalendarEventSourceContentDescription } from './calendarEventSourceContentDescription';
+import type { CalendarEventSourceContentLocation } from './calendarEventSourceContentLocation';
+import type { EventReminders } from './eventReminders';
+import type { EventTransparency } from './eventTransparency';
+import type { EventType } from './eventType';
+import type { EventVisibility } from './eventVisibility';
+
+/**
+ * The content one provider copy of an event carries.
+
+Google keeps these fields per calendar copy: a shared calendar's copy of a
+member's event can have its own title, type, reminders, and access role.
+The entity holds its canonical source's values. Every other copy's values
+are read from here so a client can show the copy that belongs to the
+calendar being viewed.
+ */
+export interface CalendarEventSourceContent {
+ /** Calendar this copy lives on. */
+ calendarId: string;
+ /** Provider-reported creator email. */
+ creatorEmail?: CalendarEventSourceContentCreatorEmail;
+ /** Provider-reported creator display name. */
+ creatorName?: CalendarEventSourceContentCreatorName;
+ /** Optional event body. */
+ description?: CalendarEventSourceContentDescription;
+ /** Provider event type. */
+ eventType: EventType;
+ /** Whether the calendar's access role prohibits editing this copy. */
+ isReadOnly: boolean;
+ /** Optional physical or virtual location label. */
+ location?: CalendarEventSourceContentLocation;
+ /** Reminder configuration of this copy. */
+ reminders: EventReminders;
+ /** Display title. */
+ title: string;
+ /** Availability behavior. */
+ transparency: EventTransparency;
+ /** Event visibility. */
+ visibility: EventVisibility;
+}
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentCreatorEmail.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentCreatorEmail.ts
new file mode 100644
index 0000000000..13db71cedd
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentCreatorEmail.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator email.
+ */
+export type CalendarEventSourceContentCreatorEmail = string | null;
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentCreatorName.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentCreatorName.ts
new file mode 100644
index 0000000000..eb6f0a66e4
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentCreatorName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator display name.
+ */
+export type CalendarEventSourceContentCreatorName = string | null;
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentDescription.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentDescription.ts
new file mode 100644
index 0000000000..c31527ee4f
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentDescription.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Optional event body.
+ */
+export type CalendarEventSourceContentDescription = string | null;
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentLocation.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentLocation.ts
new file mode 100644
index 0000000000..4375b036b8
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventSourceContentLocation.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Optional physical or virtual location label.
+ */
+export type CalendarEventSourceContentLocation = string | null;
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts
index a237ecff64..a8635610d0 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts
@@ -191,6 +191,11 @@ export * from './calendarEventFiltersStartsBefore';
export * from './calendarEventLocation';
export * from './calendarEventOrganizerEmail';
export * from './calendarEventOrganizerName';
+export * from './calendarEventSourceContent';
+export * from './calendarEventSourceContentCreatorEmail';
+export * from './calendarEventSourceContentCreatorName';
+export * from './calendarEventSourceContentDescription';
+export * from './calendarEventSourceContentLocation';
export * from './calendarMentionEvent';
export * from './calendarMentionEventLocation';
export * from './calendarMentionEventOccurrenceKey';
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/zod.ts b/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
index 61dba9d24f..a0e2267a7d 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
@@ -1154,6 +1154,8 @@ export const listOccurrencesResponseItemsItemEventRemindersOverridesItemMinutesM
export const listOccurrencesResponseItemsItemEventSequenceMin = 0;
+export const listOccurrencesResponseItemsItemEventSourcesItemRemindersOverridesItemMinutesMin = 0;
+
export const listOccurrencesResponse = zod
.object({
hasMore: zod.boolean(),
@@ -1255,7 +1257,7 @@ export const listOccurrencesResponse = zod
isReadOnly: zod
.boolean()
.describe(
- 'Whether the current user can edit the canonical source.'
+ "Whether the canonical source's calendar prohibits editing it."
),
location: zod
.string()
@@ -1317,6 +1319,101 @@ export const listOccurrencesResponse = zod
.number()
.min(listOccurrencesResponseItemsItemEventSequenceMin)
.describe('Provider\/iCalendar sequence number.'),
+ sources: zod
+ .array(
+ zod
+ .object({
+ calendarId: zod
+ .uuid()
+ .describe('Calendar this copy lives on.'),
+ creatorEmail: zod
+ .string()
+ .nullish()
+ .describe('Provider-reported creator email.'),
+ creatorName: zod
+ .string()
+ .nullish()
+ .describe('Provider-reported creator display name.'),
+ description: zod
+ .string()
+ .nullish()
+ .describe('Optional event body.'),
+ eventType: zod
+ .enum([
+ 'default',
+ 'out_of_office',
+ 'focus_time',
+ 'working_location',
+ 'birthday',
+ 'from_gmail',
+ ])
+ .describe(
+ "Google's event type: ordinary meetings versus the status-style entries\n(working location, out of office, focus time, birthdays) Google renders\nand notifies differently. Immutable at the provider after creation."
+ ),
+ isReadOnly: zod
+ .boolean()
+ .describe(
+ "Whether the calendar's access role prohibits editing this copy."
+ ),
+ location: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Optional physical or virtual location label.'
+ ),
+ reminders: zod
+ .object({
+ overrides: zod
+ .array(
+ zod
+ .object({
+ method: zod
+ .string()
+ .describe(
+ 'Provider method, stored verbatim; only `popup` fires Macro\nnotifications.'
+ ),
+ minutes: zod
+ .number()
+ .min(
+ listOccurrencesResponseItemsItemEventSourcesItemRemindersOverridesItemMinutesMin
+ )
+ .describe(
+ 'Minutes before the event start.'
+ ),
+ })
+ .describe(
+ "One reminder: how it alerts and how many minutes before the event start\n(before midnight in the calendar's zone for all-day events) it fires."
+ )
+ )
+ .optional()
+ .describe(
+ 'Explicit reminders replacing the defaults when `use_default` is off.'
+ ),
+ useDefault: zod
+ .boolean()
+ .describe(
+ "Whether the calendar's default reminders apply."
+ ),
+ })
+ .describe(
+ "Per-user reminder configuration for an event, mirroring Google's model:\neither the calendar's default reminders apply, or the explicit overrides\nreplace them entirely."
+ ),
+ title: zod.string().describe('Display title.'),
+ transparency: zod
+ .enum(['opaque', 'transparent'])
+ .describe('Whether an event blocks availability.'),
+ visibility: zod
+ .enum(['default', 'public', 'private', 'confidential'])
+ .describe('Visibility of event details.'),
+ })
+ .describe(
+ "The content one provider copy of an event carries.\n\nGoogle keeps these fields per calendar copy: a shared calendar's copy of a\nmember's event can have its own title, type, reminders, and access role.\nThe entity holds its canonical source's values. Every other copy's values\nare read from here so a client can show the copy that belongs to the\ncalendar being viewed."
+ )
+ )
+ .optional()
+ .describe(
+ "Content of every active copy of this event, canonical first: the\nprimary calendar's copy, then the freshest. A client picks the copy\nwhose calendar it is showing and falls back to the first. Populated\nonly on the read path, so stored projections omit it."
+ ),
status: zod
.enum(['confirmed', 'tentative', 'cancelled'])
.describe('Canonical event status.'),
@@ -1365,7 +1462,9 @@ export const listOccurrencesResponse = zod
.enum(['default', 'public', 'private', 'confidential'])
.describe('Visibility of event details.'),
})
- .describe('A stable, first-class Macro calendar event entity.'),
+ .describe(
+ "A stable, first-class Macro calendar event entity.\n\nContent fields hold the canonical source's values: the account's primary\ncalendar copy when one is synced, else the freshest remaining copy."
+ ),
occurrence: zod
.object({
eventId: zod.uuid().describe('Owning event entity.'),
diff --git a/apps/web/src/lib/service-clients/service-storage/openapi.json b/apps/web/src/lib/service-clients/service-storage/openapi.json
index 3f64f2a747..9ace1dd09d 100644
--- a/apps/web/src/lib/service-clients/service-storage/openapi.json
+++ b/apps/web/src/lib/service-clients/service-storage/openapi.json
@@ -14478,7 +14478,7 @@
},
"CalendarEvent": {
"type": "object",
- "description": "A stable, first-class Macro calendar event entity.",
+ "description": "A stable, first-class Macro calendar event entity.\n\nContent fields hold the canonical source's values: the account's primary\ncalendar copy when one is synced, else the freshest remaining copy.",
"required": [
"id",
"ownerId",
@@ -14555,7 +14555,7 @@
},
"isReadOnly": {
"type": "boolean",
- "description": "Whether the current user can edit the canonical source."
+ "description": "Whether the canonical source's calendar prohibits editing it."
},
"location": {
"type": ["string", "null"],
@@ -14590,6 +14590,13 @@
"description": "Provider/iCalendar sequence number.",
"minimum": 0
},
+ "sources": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CalendarEventSourceContent"
+ },
+ "description": "Content of every active copy of this event, canonical first: the\nprimary calendar's copy, then the freshest. A client picks the copy\nwhose calendar it is showing and falls back to the first. Populated\nonly on the read path, so stored projections omit it."
+ },
"status": {
"$ref": "#/components/schemas/EventStatus",
"description": "Event status."
@@ -14661,6 +14668,66 @@
}
}
},
+ "CalendarEventSourceContent": {
+ "type": "object",
+ "description": "The content one provider copy of an event carries.\n\nGoogle keeps these fields per calendar copy: a shared calendar's copy of a\nmember's event can have its own title, type, reminders, and access role.\nThe entity holds its canonical source's values. Every other copy's values\nare read from here so a client can show the copy that belongs to the\ncalendar being viewed.",
+ "required": [
+ "calendarId",
+ "title",
+ "eventType",
+ "visibility",
+ "transparency",
+ "isReadOnly",
+ "reminders"
+ ],
+ "properties": {
+ "calendarId": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Calendar this copy lives on."
+ },
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
+ "description": {
+ "type": ["string", "null"],
+ "description": "Optional event body."
+ },
+ "eventType": {
+ "$ref": "#/components/schemas/EventType",
+ "description": "Provider event type."
+ },
+ "isReadOnly": {
+ "type": "boolean",
+ "description": "Whether the calendar's access role prohibits editing this copy."
+ },
+ "location": {
+ "type": ["string", "null"],
+ "description": "Optional physical or virtual location label."
+ },
+ "reminders": {
+ "$ref": "#/components/schemas/EventReminders",
+ "description": "Reminder configuration of this copy."
+ },
+ "title": {
+ "type": "string",
+ "description": "Display title."
+ },
+ "transparency": {
+ "$ref": "#/components/schemas/EventTransparency",
+ "description": "Availability behavior."
+ },
+ "visibility": {
+ "$ref": "#/components/schemas/EventVisibility",
+ "description": "Event visibility."
+ }
+ }
+ },
"CalendarMentionEvent": {
"type": "object",
"description": "Meeting-level fields shown in a calendar event mention preview, taken from\nthe requester's own projection of the meeting.",
diff --git a/crates/calendar_events/src/domain/models.rs b/crates/calendar_events/src/domain/models.rs
index 60260f949a..5d5ca6f8ec 100644
--- a/crates/calendar_events/src/domain/models.rs
+++ b/crates/calendar_events/src/domain/models.rs
@@ -527,7 +527,45 @@ impl EventReminders {
}
}
+/// The content one provider copy of an event carries.
+///
+/// Google keeps these fields per calendar copy: a shared calendar's copy of a
+/// member's event can have its own title, type, reminders, and access role.
+/// The entity holds its canonical source's values. Every other copy's values
+/// are read from here so a client can show the copy that belongs to the
+/// calendar being viewed.
+#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct CalendarEventSourceContent {
+ /// Calendar this copy lives on.
+ pub calendar_id: Uuid,
+ /// Display title.
+ pub title: String,
+ /// Optional event body.
+ pub description: Option<String>,
+ /// Optional physical or virtual location label.
+ pub location: Option<String>,
+ /// Provider event type.
+ pub event_type: EventType,
+ /// Event visibility.
+ pub visibility: EventVisibility,
+ /// Availability behavior.
+ pub transparency: EventTransparency,
+ /// Whether the calendar's access role prohibits editing this copy.
+ pub is_read_only: bool,
+ /// Reminder configuration of this copy.
+ pub reminders: EventReminders,
+ /// Provider-reported creator email.
+ pub creator_email: Option<String>,
+ /// Provider-reported creator display name.
+ pub creator_name: Option<String>,
+}
+
/// A stable, first-class Macro calendar event entity.
+///
+/// Content fields hold the canonical source's values: the account's primary
+/// calendar copy when one is synced, else the freshest remaining copy.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
@@ -542,6 +580,12 @@ pub struct CalendarEvent {
/// projections stored before calendars were attributed.
#[serde(default)]
pub calendar_id: Option<Uuid>,
+ /// Content of every active copy of this event, canonical first: the
+ /// primary calendar's copy, then the freshest. A client picks the copy
+ /// whose calendar it is showing and falls back to the first. Populated
+ /// only on the read path, so stored projections omit it.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub sources: Vec<CalendarEventSourceContent>,
/// Display title.
pub title: String,
/// Optional event body.
@@ -584,7 +628,7 @@ pub struct CalendarEvent {
pub conference_provider: Option<ConferenceProvider>,
/// Provider/iCalendar sequence number.
pub sequence: u32,
- /// Whether the current user can edit the canonical source.
+ /// Whether the canonical source's calendar prohibits editing it.
pub is_read_only: bool,
/// Attendees, keyed by email during persistence.
pub attendees: Vec<CalendarAttendee>,
@@ -1023,9 +1067,10 @@ pub struct CalendarLinkTokenIdentity {
pub struct CalendarEventMutationTarget {
/// Macro entity identifier.
pub event_id: Uuid,
- /// Whether the canonical source prohibits mutation.
+ /// Whether the addressed copy's calendar prohibits mutation.
pub is_read_only: bool,
- /// Google event identifier of the best-ranked provider source.
+ /// Google event identifier of the addressed provider copy: the one on
+ /// the requested calendar, else the canonical source.
pub provider_event_id: String,
/// Recurring master identifier when the stored source is an instance.
pub provider_recurring_event_id: Option<String>,
diff --git a/crates/calendar_events/src/domain/models/test.rs b/crates/calendar_events/src/domain/models/test.rs
index ededc81132..fb24161900 100644
--- a/crates/calendar_events/src/domain/models/test.rs
+++ b/crates/calendar_events/src/domain/models/test.rs
@@ -148,6 +148,7 @@ fn default_reminders_stay_out_of_serialized_projections() {
owner_id: "macro|[email protected]".to_string(),
ical_uid: "[email protected]".to_string(),
calendar_id: None,
+ sources: Vec::new(),
title: "Projection".to_string(),
description: None,
location: None,
@@ -184,6 +185,7 @@ fn default_reminders_stay_out_of_serialized_projections() {
assert!(serialized.get("creatorEmail").is_none());
assert!(serialized.get("creatorName").is_none());
assert!(serialized.get("eventType").is_none());
+ assert!(serialized.get("sources").is_none());
let legacy: CalendarEvent = serde_json::from_value(serialized).unwrap();
assert_eq!(legacy.reminders, EventReminders::default());
assert_eq!(legacy.event_type, EventType::Default);
diff --git a/crates/calendar_events/src/domain/mutations.rs b/crates/calendar_events/src/domain/mutations.rs
index 318d23cbac..83cc8408f7 100644
--- a/crates/calendar_events/src/domain/mutations.rs
+++ b/crates/calendar_events/src/domain/mutations.rs
@@ -128,9 +128,10 @@ where
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
) -> Result<CalendarEventMutationTarget, CalendarMutationError> {
self.repository
- .get_event_mutation_target(requester_id, event_id)
+ .get_event_mutation_target(requester_id, event_id, calendar_id)
.await
.map_err(internal)?
.ok_or(CalendarMutationError::NotFound)
@@ -235,6 +236,7 @@ where
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
mut patch: CalendarEventPatch,
scope: CalendarUpdateScope,
) -> Result<CalendarEvent, CalendarMutationError> {
@@ -261,7 +263,9 @@ where
.to_string(),
));
}
- let target = self.resolve_mutation_target(requester_id, event_id).await?;
+ let target = self
+ .resolve_mutation_target(requester_id, event_id, calendar_id)
+ .await?;
if target.is_read_only {
return Err(CalendarMutationError::ReadOnly);
}
@@ -353,9 +357,12 @@ where
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
scope: CalendarDeletionScope,
) -> Result<(), CalendarMutationError> {
- let target = self.resolve_mutation_target(requester_id, event_id).await?;
+ let target = self
+ .resolve_mutation_target(requester_id, event_id, calendar_id)
+ .await?;
if target.is_read_only {
return Err(CalendarMutationError::ReadOnly);
}
@@ -426,10 +433,13 @@ where
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
response: AttendeeResponseStatus,
scope: CalendarRsvpScope,
) -> Result<CalendarEvent, CalendarMutationError> {
- let target = self.resolve_mutation_target(requester_id, event_id).await?;
+ let target = self
+ .resolve_mutation_target(requester_id, event_id, calendar_id)
+ .await?;
if target.is_read_only {
return Err(CalendarMutationError::ReadOnly);
}
diff --git a/crates/calendar_events/src/domain/mutations/test.rs b/crates/calendar_events/src/domain/mutations/test.rs
index 484334432a..c1f2dbc7a0 100644
--- a/crates/calendar_events/src/domain/mutations/test.rs
+++ b/crates/calendar_events/src/domain/mutations/test.rs
@@ -79,6 +79,7 @@ fn echo_upsert(target_owner: &str) -> CalendarEventUpsert {
owner_id: target_owner.to_string(),
ical_uid: "[email protected]".to_string(),
calendar_id: Some(Uuid::now_v7()),
+ sources: Vec::new(),
title: "Echo".to_string(),
description: None,
location: None,
@@ -314,6 +315,7 @@ impl CalendarRepository for FakeRepo {
&self,
_requester_id: &str,
_event_id: Uuid,
+ _calendar_id: Option<Uuid>,
) -> Result<Option<CalendarEventMutationTarget>, rootcause::Report> {
if self.fail_owned_inboxes {
return Err(rootcause::report!("owned inboxes unavailable"));
@@ -1014,7 +1016,7 @@ async fn deleting_a_series_publishes_deleted_per_removed_event() {
FakeTokens::ok(),
broker.clone(),
)
- .delete_event("macro|user", master, CalendarDeletionScope::All)
+ .delete_event("macro|user", master, None, CalendarDeletionScope::All)
.await
.unwrap();
@@ -1390,6 +1392,7 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch::default(),
CalendarUpdateScope::All,
)
@@ -1412,6 +1415,7 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
patch.clone(),
CalendarUpdateScope::All,
)
@@ -1432,6 +1436,7 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
patch.clone(),
CalendarUpdateScope::All,
)
@@ -1452,6 +1457,7 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
patch,
CalendarUpdateScope::All,
)
@@ -1534,6 +1540,7 @@ async fn updating_attendees_carries_retained_guests_rsvp_through_to_the_provider
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
attendees: Some(vec![
CalendarAttendeeInput {
@@ -1592,6 +1599,7 @@ async fn occurrence_scoped_attendee_update_prefers_the_occurrence_rsvp_over_the_
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
attendees: Some(vec![CalendarAttendeeInput {
email: "[email protected]".to_string(),
@@ -1631,6 +1639,7 @@ async fn update_on_a_provider_deleted_event_retires_the_stale_source() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
title: Some("Renamed".to_string()),
..CalendarEventPatch::default()
@@ -1659,6 +1668,7 @@ async fn occurrence_scoped_update_patches_the_instance_not_the_master() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
time: Some(timed_time()),
..CalendarEventPatch::default()
@@ -1693,6 +1703,7 @@ async fn occurrence_scoped_update_rejects_recurrence_changes() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
recurrence_lines: Some(vec!["RRULE:FREQ=WEEKLY".to_string()]),
..CalendarEventPatch::default()
@@ -1729,6 +1740,7 @@ async fn occurrence_scoped_update_on_a_vanished_occurrence_persists_the_refresh_
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
time: Some(timed_time()),
..CalendarEventPatch::default()
@@ -1767,6 +1779,7 @@ async fn occurrence_scoped_update_on_a_vanished_series_retires_the_source() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
title: Some("Renamed".to_string()),
..CalendarEventPatch::default()
@@ -1793,7 +1806,12 @@ async fn delete_pushes_to_the_provider_then_retires_the_local_source() {
let calls = provider.calls.clone();
service(repo, provider, FakeTokens::ok())
- .delete_event("macro|user", Uuid::now_v7(), CalendarDeletionScope::All)
+ .delete_event(
+ "macro|user",
+ Uuid::now_v7(),
+ None,
+ CalendarDeletionScope::All,
+ )
.await
.unwrap();
@@ -1816,6 +1834,7 @@ async fn rsvp_surfaces_attendance_and_persists_the_echo() {
.respond_to_event(
"macro|user",
Uuid::now_v7(),
+ None,
AttendeeResponseStatus::Accepted,
CalendarRsvpScope::All,
)
@@ -1834,6 +1853,7 @@ async fn rsvp_surfaces_attendance_and_persists_the_echo() {
.respond_to_event(
"macro|user",
Uuid::now_v7(),
+ None,
AttendeeResponseStatus::Declined,
CalendarRsvpScope::ThisEvent {
recurrence_id: "2026-08-14T22:00:00+00:00".to_string(),
@@ -1867,6 +1887,7 @@ async fn rsvp_addresses_the_requester_inbox_not_the_source_calendar() {
.respond_to_event(
"macro|user",
Uuid::now_v7(),
+ None,
AttendeeResponseStatus::Accepted,
CalendarRsvpScope::All,
)
@@ -1901,6 +1922,7 @@ async fn rsvp_through_a_delegated_inbox_never_hands_the_subject_email_to_the_pro
.respond_to_event(
"macro|user",
Uuid::now_v7(),
+ None,
AttendeeResponseStatus::Accepted,
CalendarRsvpScope::All,
)
@@ -1935,6 +1957,7 @@ async fn rsvp_through_a_delegated_inbox_without_an_own_inbox_is_not_attendee_bef
.respond_to_event(
"macro|user",
Uuid::now_v7(),
+ None,
AttendeeResponseStatus::Accepted,
CalendarRsvpScope::All,
)
@@ -1963,6 +1986,7 @@ async fn rsvp_echo_marks_actor_inboxes_as_self() {
.respond_to_event(
"macro|user",
Uuid::now_v7(),
+ None,
AttendeeResponseStatus::Accepted,
CalendarRsvpScope::All,
)
@@ -1985,7 +2009,12 @@ async fn token_and_provider_failures_map_to_typed_errors() {
);
assert!(matches!(
reauth
- .delete_event("macro|user", Uuid::now_v7(), CalendarDeletionScope::All)
+ .delete_event(
+ "macro|user",
+ Uuid::now_v7(),
+ None,
+ CalendarDeletionScope::All
+ )
.await,
Err(CalendarMutationError::ReauthRequired(_))
));
@@ -2002,7 +2031,12 @@ async fn token_and_provider_failures_map_to_typed_errors() {
);
assert!(matches!(
transient
- .delete_event("macro|user", Uuid::now_v7(), CalendarDeletionScope::All)
+ .delete_event(
+ "macro|user",
+ Uuid::now_v7(),
+ None,
+ CalendarDeletionScope::All
+ )
.await,
Err(CalendarMutationError::Retryable(_))
));
@@ -2019,7 +2053,12 @@ async fn token_and_provider_failures_map_to_typed_errors() {
);
assert!(matches!(
permanent
- .delete_event("macro|user", Uuid::now_v7(), CalendarDeletionScope::All)
+ .delete_event(
+ "macro|user",
+ Uuid::now_v7(),
+ None,
+ CalendarDeletionScope::All
+ )
.await,
Err(CalendarMutationError::ProviderRejected(_))
));
@@ -2067,6 +2106,7 @@ async fn scoped_deletions_reshape_or_retire_the_series() {
svc.delete_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarDeletionScope::ThisEvent {
recurrence_id: "2026-08-10T09:00:00+00:00".to_string(),
},
@@ -2088,6 +2128,7 @@ async fn scoped_deletions_reshape_or_retire_the_series() {
svc.delete_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarDeletionScope::ThisAndFollowing {
recurrence_id: "2026-08-12T09:00:00+00:00".to_string(),
},
@@ -2114,6 +2155,7 @@ async fn truncation_that_empties_the_series_retires_the_local_source() {
svc.delete_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarDeletionScope::ThisAndFollowing {
recurrence_id: "2026-08-04T09:00:00+00:00".to_string(),
},
@@ -2142,6 +2184,7 @@ async fn conference_changes_reach_the_provider_for_any_conference() {
.update_event(
"macro|user",
Uuid::now_v7(),
+ None,
CalendarEventPatch {
conference: Some(change),
..CalendarEventPatch::default()
diff --git a/crates/calendar_events/src/domain/ports.rs b/crates/calendar_events/src/domain/ports.rs
index 436d41421e..e2250f44a7 100644
--- a/crates/calendar_events/src/domain/ports.rs
+++ b/crates/calendar_events/src/domain/ports.rs
@@ -516,13 +516,16 @@ pub trait CalendarRepository: Send + Sync + 'static {
calendar_ids: Vec<Uuid>,
) -> impl Future<Output = Result<Vec<RetiredCalendarEvent>, Report>> + Send;
- /// Resolve an event visible to the requester to its best Google source
- /// and the connected inbox that can mutate it. `None` covers both an
- /// unknown event and one the requester cannot see.
+ /// Resolve an event visible to the requester to the Google source a
+ /// mutation must address — the copy on `calendar_id` when one is named,
+ /// else the canonical source — and the connected inbox that can mutate
+ /// it. `None` covers an unknown event, one the requester cannot see, and
+ /// a calendar that holds no copy of it.
fn get_event_mutation_target(
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
) -> impl Future<Output = Result<Option<CalendarEventMutationTarget>, Report>> + Send;
/// The stored attendees of a canonical event. Used to carry each retained
@@ -622,11 +625,14 @@ pub trait CalendarMutationService: Send + Sync + 'static {
) -> impl Future<Output = Result<Vec<VisibleCalendar>, CalendarMutationError>> + Send;
/// Patch an event at its provider — the whole event or series, or one
- /// occurrence of a recurring series — and persist the echo.
+ /// occurrence of a recurring series — and persist the echo. `calendar_id`
+ /// selects which copy of a multi-calendar event is patched. `None`
+ /// addresses the canonical source.
fn update_event(
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
patch: CalendarEventPatch,
scope: CalendarUpdateScope,
) -> impl Future<Output = Result<CalendarEvent, CalendarMutationError>> + Send;
@@ -637,6 +643,7 @@ pub trait CalendarMutationService: Send + Sync + 'static {
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
scope: CalendarDeletionScope,
) -> impl Future<Output = Result<(), CalendarMutationError>> + Send;
@@ -646,6 +653,7 @@ pub trait CalendarMutationService: Send + Sync + 'static {
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
response: AttendeeResponseStatus,
scope: CalendarRsvpScope,
) -> impl Future<Output = Result<CalendarEvent, CalendarMutationError>> + Send;
diff --git a/crates/calendar_events/src/domain/service/test.rs b/crates/calendar_events/src/domain/service/test.rs
index 2885410b07..ac20d062d5 100644
--- a/crates/calendar_events/src/domain/service/test.rs
+++ b/crates/calendar_events/src/domain/service/test.rs
@@ -105,6 +105,7 @@ impl CalendarRepository for FakeRepo {
&self,
_requester_id: &str,
_event_id: Uuid,
+ _calendar_id: Option<Uuid>,
) -> Result<Option<CalendarEventMutationTarget>, Report> {
unreachable!("mutation lookups are not exercised by sync tests")
}
@@ -225,6 +226,7 @@ fn valid_upsert() -> CalendarEventUpsert {
owner_id: "macro|[email protected]".to_string(),
ical_uid: "[email protected]".to_string(),
calendar_id: None,
+ sources: Vec::new(),
title: "Meeting".to_string(),
description: None,
location: None,
diff --git a/crates/calendar_events/src/inbound/mutation_router.rs b/crates/calendar_events/src/inbound/mutation_router.rs
index 03c90cdf98..4464748ea2 100644
--- a/crates/calendar_events/src/inbound/mutation_router.rs
+++ b/crates/calendar_events/src/inbound/mutation_router.rs
@@ -152,6 +152,9 @@ pub struct CreateCalendarEventRequest {
#[derive(Debug, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateCalendarEventRequest {
+ /// Calendar whose copy of the event is patched, for an event synced from
+ /// more than one calendar. Omit to patch the canonical copy.
+ pub calendar_id: Option<Uuid>,
/// Replacement title; an empty string clears it.
pub title: Option<String>,
/// Replacement description; an empty string clears it.
@@ -226,6 +229,9 @@ pub enum CalendarDeletionScopeParam {
#[into_params(parameter_in = Query)]
#[serde(rename_all = "camelCase")]
pub struct DeleteCalendarEventQuery {
+ /// Calendar whose copy of the event is deleted, for an event synced from
+ /// more than one calendar. Omit to delete the canonical copy.
+ pub calendar_id: Option<Uuid>,
/// Deletion scope; defaults to the entire event or series.
#[serde(default)]
pub scope: CalendarDeletionScopeParam,
@@ -251,6 +257,9 @@ pub enum CalendarRsvpScopeParam {
#[derive(Debug, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct RsvpCalendarEventRequest {
+ /// Calendar whose copy of the event is answered, for an event synced
+ /// from more than one calendar. Omit to answer on the canonical copy.
+ pub calendar_id: Option<Uuid>,
/// The response to record for the connected account.
pub response: AttendeeResponseStatus,
/// How much of a recurring series the response covers. Omit to let
@@ -543,6 +552,7 @@ where
.update_event(
user.authorization.user.macro_user_id.as_ref(),
event_id,
+ request.calendar_id,
patch,
scope,
)
@@ -600,6 +610,7 @@ where
.delete_event(
user.authorization.user.macro_user_id.as_ref(),
event_id,
+ query.calendar_id,
scope,
)
.await?;
@@ -650,6 +661,7 @@ where
.respond_to_event(
user.authorization.user.macro_user_id.as_ref(),
event_id,
+ request.calendar_id,
request.response,
scope,
)
diff --git a/crates/calendar_events/src/inbound/toolset/delete_calendar_event.rs b/crates/calendar_events/src/inbound/toolset/delete_calendar_event.rs
index 70f9c31152..964266e054 100644
--- a/crates/calendar_events/src/inbound/toolset/delete_calendar_event.rs
+++ b/crates/calendar_events/src/inbound/toolset/delete_calendar_event.rs
@@ -56,6 +56,15 @@ pub struct DeleteCalendarEvent {
#[schemars(description = "The event's id, from ListCalendarEvents or CreateCalendarEvent.")]
pub event_id: uuid::Uuid,
+ /// Calendar whose copy of the event is deleted.
+ #[schemars(
+ description = "The `calendarId` of the copy to delete, from the `copies` of its \
+ ListCalendarEvents entry, for an event synced from more than one \
+ calendar. Omit to delete the event's primary copy."
+ )]
+ #[serde(default)]
+ pub calendar_id: Option<uuid::Uuid>,
+
/// Deletion scope.
#[schemars(
description = "How much of a recurring series to remove: \"all\" (default), \
@@ -123,7 +132,7 @@ where
service_context
.mutations
- .delete_event(&requester_id, self.event_id, scope)
+ .delete_event(&requester_id, self.event_id, self.calendar_id, scope)
.await
.map_err(|error| mutation_tool_error("delete the calendar event", error))?;
diff --git a/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs b/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs
index d97ff4472d..af3caf4f5b 100644
--- a/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs
+++ b/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs
@@ -73,6 +73,23 @@ pub struct CalendarEventListItem {
pub is_read_only: bool,
/// Calendar the event belongs to, when known.
pub calendar_id: Option<uuid::Uuid>,
+ /// Every calendar carrying a copy of this event when there is more than
+ /// one, primary first. Pass a copy's `calendarId` to UpdateCalendarEvent
+ /// or DeleteCalendarEvent to address that copy instead of the primary.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub copies: Vec<CalendarEventCopyItem>,
+}
+
+/// One calendar's copy of an event synced from several calendars.
+#[derive(Debug, Serialize, JsonSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct CalendarEventCopyItem {
+ /// Calendar holding this copy.
+ pub calendar_id: uuid::Uuid,
+ /// The copy's own title.
+ pub title: String,
+ /// Whether that calendar prohibits modifying the copy.
+ pub is_read_only: bool,
}
/// Response from the ListCalendarEvents tool.
@@ -232,6 +249,19 @@ where
conference_url: event.conference_url.clone(),
is_read_only: event.is_read_only,
calendar_id: event.calendar_id,
+ copies: if event.sources.len() > 1 {
+ event
+ .sources
+ .iter()
+ .map(|copy| CalendarEventCopyItem {
+ calendar_id: copy.calendar_id,
+ title: copy.title.clone(),
+ is_read_only: copy.is_read_only,
+ })
+ .collect()
+ } else {
+ Vec::new()
+ },
}
})
.collect();
diff --git a/crates/calendar_events/src/inbound/toolset/test.rs b/crates/calendar_events/src/inbound/toolset/test.rs
index 9e3ac8798e..15b14be918 100644
--- a/crates/calendar_events/src/inbound/toolset/test.rs
+++ b/crates/calendar_events/src/inbound/toolset/test.rs
@@ -75,6 +75,7 @@ fn sample_event(recurrence_lines: Vec<String>) -> crate::domain::models::Calenda
owner_id: "macro|[email protected]".to_string(),
ical_uid: "uid-1".to_string(),
calendar_id: Some(Uuid::from_u128(9)),
+ sources: Vec::new(),
title: "Standup".to_string(),
description: Some("Daily sync".to_string()),
location: Some("Room 1".to_string()),
@@ -177,6 +178,7 @@ impl CalendarMutationService for MockMutations {
&self,
_requester_id: &str,
event_id: Uuid,
+ _calendar_id: Option<Uuid>,
patch: CalendarEventPatch,
scope: CalendarUpdateScope,
) -> Result<crate::domain::models::CalendarEvent, CalendarMutationError> {
@@ -188,6 +190,7 @@ impl CalendarMutationService for MockMutations {
&self,
_requester_id: &str,
event_id: Uuid,
+ _calendar_id: Option<Uuid>,
scope: CalendarDeletionScope,
) -> Result<(), CalendarMutationError> {
self.deleted.lock().unwrap().push((event_id, scope));
@@ -198,6 +201,7 @@ impl CalendarMutationService for MockMutations {
&self,
_requester_id: &str,
event_id: Uuid,
+ _calendar_id: Option<Uuid>,
response: AttendeeResponseStatus,
scope: CalendarRsvpScope,
) -> Result<crate::domain::models::CalendarEvent, CalendarMutationError> {
@@ -506,6 +510,7 @@ async fn update_converts_input_into_a_domain_patch() {
let tool = UpdateCalendarEvent {
event_id,
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: None,
title: Some("Renamed".to_string()),
@@ -546,6 +551,7 @@ async fn update_maps_out_of_office_settings_into_the_patch() {
let tool = UpdateCalendarEvent {
event_id,
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: None,
title: None,
@@ -583,6 +589,7 @@ async fn update_passes_the_selected_occurrence_scope() {
let tool = UpdateCalendarEvent {
event_id,
+ calendar_id: None,
scope: UpdateScopeInput::ThisEvent,
recurrence_id: Some("2026-08-18T20:00:00+00:00".to_string()),
title: None,
@@ -618,6 +625,7 @@ async fn scoped_update_requires_a_recurrence_id() {
let tool = UpdateCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: UpdateScopeInput::ThisEvent,
recurrence_id: None,
title: Some("Renamed".to_string()),
@@ -645,6 +653,7 @@ async fn series_update_rejects_a_stray_recurrence_id() {
let tool = UpdateCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: Some("2026-08-18T20:00:00+00:00".to_string()),
title: Some("Renamed".to_string()),
@@ -669,6 +678,7 @@ async fn update_carries_reminders_into_the_patch() {
let tool = UpdateCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: None,
title: None,
@@ -713,6 +723,7 @@ async fn rsvp_alone_answers_without_patching() {
let tool = UpdateCalendarEvent {
event_id,
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: None,
title: None,
@@ -746,6 +757,7 @@ async fn rsvp_follows_the_occurrence_scope_of_the_call() {
let tool = UpdateCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: UpdateScopeInput::ThisEvent,
recurrence_id: Some("2026-08-18T20:00:00+00:00".to_string()),
title: None,
@@ -780,6 +792,7 @@ async fn update_answers_after_applying_the_patch() {
let tool = UpdateCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: None,
title: None,
@@ -808,6 +821,7 @@ async fn update_without_a_change_or_an_rsvp_is_rejected() {
let tool = UpdateCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: UpdateScopeInput::All,
recurrence_id: None,
title: None,
@@ -833,6 +847,7 @@ async fn scoped_deletion_requires_a_recurrence_id() {
let tool = DeleteCalendarEvent {
event_id: Uuid::from_u128(11),
+ calendar_id: None,
scope: DeletionScopeInput::ThisEvent,
recurrence_id: None,
};
@@ -848,6 +863,7 @@ async fn deletion_passes_the_selected_scope() {
let tool = DeleteCalendarEvent {
event_id,
+ calendar_id: None,
scope: DeletionScopeInput::ThisAndFollowing,
recurrence_id: Some("2026-08-20T17:00:00+00:00".to_string()),
};
diff --git a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs
index 47a4c0ba9c..29b656fce8 100644
--- a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs
+++ b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs
@@ -103,6 +103,15 @@ pub struct UpdateCalendarEvent {
#[schemars(description = "The event's id, from ListCalendarEvents or CreateCalendarEvent.")]
pub event_id: uuid::Uuid,
+ /// Calendar whose copy of the event is updated.
+ #[schemars(
+ description = "The `calendarId` of the copy to update, from the `copies` of its \
+ ListCalendarEvents entry, for an event synced from more than one \
+ calendar. Omit to update the event's primary copy."
+ )]
+ #[serde(default)]
+ pub calendar_id: Option<uuid::Uuid>,
+
/// Update scope.
#[schemars(
description = "How much of a recurring series to change: \"this_event\" edits one \
@@ -290,7 +299,13 @@ where
Some(
service_context
.mutations
- .update_event(&requester_id, self.event_id, patch, scope.clone())
+ .update_event(
+ &requester_id,
+ self.event_id,
+ self.calendar_id,
+ patch,
+ scope.clone(),
+ )
.await
.map_err(|error| mutation_tool_error("update the calendar event", error))?,
)
@@ -306,7 +321,13 @@ where
};
service_context
.mutations
- .respond_to_event(&requester_id, self.event_id, rsvp.into(), rsvp_scope)
+ .respond_to_event(
+ &requester_id,
+ self.event_id,
+ self.calendar_id,
+ rsvp.into(),
+ rsvp_scope,
+ )
.await
.map_err(|error| {
let action = if patched.is_some() {
diff --git a/crates/calendar_events/src/outbound/email_service_mutations.rs b/crates/calendar_events/src/outbound/email_service_mutations.rs
index e40ff3296d..f022fb11e9 100644
--- a/crates/calendar_events/src/outbound/email_service_mutations.rs
+++ b/crates/calendar_events/src/outbound/email_service_mutations.rs
@@ -176,7 +176,11 @@ fn create_body(
}
/// Wire body for an event patch, matching `UpdateCalendarEventRequest`.
-fn update_body(patch: &CalendarEventPatch, scope: &CalendarUpdateScope) -> serde_json::Value {
+fn update_body(
+ calendar_id: Option<Uuid>,
+ patch: &CalendarEventPatch,
+ scope: &CalendarUpdateScope,
+) -> serde_json::Value {
let (scope_name, recurrence_id) = match scope {
CalendarUpdateScope::All => ("all", None),
CalendarUpdateScope::ThisEvent { recurrence_id } => {
@@ -184,6 +188,7 @@ fn update_body(patch: &CalendarEventPatch, scope: &CalendarUpdateScope) -> serde
}
};
serde_json::json!({
+ "calendarId": calendar_id,
"title": patch.title,
"description": patch.description,
"location": patch.location,
@@ -218,8 +223,11 @@ fn attendees_body(
}
/// Wire query for a deletion scope, matching `DeleteCalendarEventQuery`.
-fn delete_query(scope: &CalendarDeletionScope) -> Vec<(&'static str, String)> {
- match scope {
+fn delete_query(
+ calendar_id: Option<Uuid>,
+ scope: &CalendarDeletionScope,
+) -> Vec<(&'static str, String)> {
+ let mut query = match scope {
CalendarDeletionScope::All => vec![("scope", "all".to_string())],
CalendarDeletionScope::ThisEvent { recurrence_id } => vec![
("scope", "this_event".to_string()),
@@ -229,17 +237,27 @@ fn delete_query(scope: &CalendarDeletionScope) -> Vec<(&'static str, String)> {
("scope", "this_and_following".to_string()),
("recurrenceId", recurrence_id.clone()),
],
+ };
+ if let Some(calendar_id) = calendar_id {
+ query.push(("calendarId", calendar_id.to_string()));
}
+ query
}
/// Wire body for an RSVP, matching `RsvpCalendarEventRequest`.
-fn rsvp_body(response: AttendeeResponseStatus, scope: &CalendarRsvpScope) -> serde_json::Value {
+fn rsvp_body(
+ calendar_id: Option<Uuid>,
+ response: AttendeeResponseStatus,
+ scope: &CalendarRsvpScope,
+) -> serde_json::Value {
match scope {
CalendarRsvpScope::All => serde_json::json!({
+ "calendarId": calendar_id,
"response": response,
"scope": "all",
}),
CalendarRsvpScope::ThisEvent { recurrence_id } => serde_json::json!({
+ "calendarId": calendar_id,
"response": response,
"scope": "this_event",
"recurrenceId": recurrence_id,
@@ -285,6 +303,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
patch: CalendarEventPatch,
scope: CalendarUpdateScope,
) -> Result<CalendarEvent, CalendarMutationError> {
@@ -294,7 +313,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {
&format!("/calendar/events/{event_id}"),
requester_id,
)
- .json(&update_body(&patch, &scope)),
+ .json(&update_body(calendar_id, &patch, &scope)),
)
.await
}
@@ -304,6 +323,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
scope: CalendarDeletionScope,
) -> Result<(), CalendarMutationError> {
self.send(
@@ -312,7 +332,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {
&format!("/calendar/events/{event_id}"),
requester_id,
)
- .query(&delete_query(&scope)),
+ .query(&delete_query(calendar_id, &scope)),
)
.await
.map(|_| ())
@@ -323,6 +343,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
response: AttendeeResponseStatus,
scope: CalendarRsvpScope,
) -> Result<CalendarEvent, CalendarMutationError> {
@@ -332,7 +353,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {
&format!("/calendar/events/{event_id}/rsvp"),
requester_id,
)
- .json(&rsvp_body(response, &scope)),
+ .json(&rsvp_body(calendar_id, response, &scope)),
)
.await
}
diff --git a/crates/calendar_events/src/outbound/email_service_mutations/test.rs b/crates/calendar_events/src/outbound/email_service_mutations/test.rs
index f2d431285d..d3bf57a558 100644
--- a/crates/calendar_events/src/outbound/email_service_mutations/test.rs
+++ b/crates/calendar_events/src/outbound/email_service_mutations/test.rs
@@ -92,7 +92,7 @@ fn out_of_office_survives_the_update_wire_contract() {
..Default::default()
};
let request: UpdateCalendarEventRequest =
- serde_json::from_value(update_body(&patch, &CalendarUpdateScope::All)).unwrap();
+ serde_json::from_value(update_body(None, &patch, &CalendarUpdateScope::All)).unwrap();
assert_eq!(
request
@@ -116,7 +116,7 @@ fn update_body_matches_the_router_request() {
..Default::default()
};
let request: UpdateCalendarEventRequest =
- serde_json::from_value(update_body(&patch, &CalendarUpdateScope::All)).unwrap();
+ serde_json::from_value(update_body(None, &patch, &CalendarUpdateScope::All)).unwrap();
assert_eq!(request.title.as_deref(), Some("Renamed"));
assert_eq!(request.description.as_deref(), Some(""));
@@ -141,6 +141,7 @@ fn update_body_carries_the_occurrence_scope() {
..Default::default()
};
let request: UpdateCalendarEventRequest = serde_json::from_value(update_body(
+ None,
&patch,
&CalendarUpdateScope::ThisEvent {
recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),
@@ -175,7 +176,7 @@ fn delete_query_matches_the_router_query() {
Some("k-2"),
),
] {
- let pairs = delete_query(&scope);
+ let pairs = delete_query(None, &scope);
let map: serde_json::Map<String, serde_json::Value> = pairs
.into_iter()
.map(|(key, value)| (key.to_string(), serde_json::Value::String(value)))
@@ -189,6 +190,7 @@ fn delete_query_matches_the_router_query() {
#[test]
fn rsvp_body_matches_the_router_request() {
let body = rsvp_body(
+ None,
AttendeeResponseStatus::Accepted,
&CalendarRsvpScope::ThisEvent {
recurrence_id: "k-1".to_string(),
diff --git a/crates/calendar_events/src/outbound/google.rs b/crates/calendar_events/src/outbound/google.rs
index 5516f20039..78ad961f3d 100644
--- a/crates/calendar_events/src/outbound/google.rs
+++ b/crates/calendar_events/src/outbound/google.rs
@@ -1792,6 +1792,7 @@ fn map_upsert(
owner_id: target.owner_id.clone(),
ical_uid: master.ical_uid.clone(),
calendar_id: Some(target.calendar_id),
+ sources: Vec::new(),
title: master.summary.clone().unwrap_or_default(),
description: master.description.clone(),
location: master.location.clone(),
diff --git a/crates/calendar_events/src/outbound/pg.rs b/crates/calendar_events/src/outbound/pg.rs
index 7329894220..9e71503e38 100644
--- a/crates/calendar_events/src/outbound/pg.rs
+++ b/crates/calendar_events/src/outbound/pg.rs
@@ -1,6 +1,6 @@
//! PostgreSQL implementation of the calendar repository port.
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet};
use chrono::{DateTime, NaiveDate, Utc};
use futures::try_join;
@@ -15,14 +15,15 @@ use crate::domain::{
CalendarBackfillClaim, CalendarBackfillFailureDisposition, CalendarBackfillFailureOutcome,
CalendarBackfillJob, CalendarBackfillJobKey, CalendarBackfillKind, CalendarCreationTarget,
CalendarEvent, CalendarEventMutationTarget, CalendarEventOverride, CalendarEventSource,
- CalendarEventUpsert, CalendarGrantIntent, CalendarLinkTokenIdentity, CalendarMentionEvent,
- CalendarMentionPreview, CalendarMentionRequestItem, CalendarOccurrence,
- CalendarOccurrenceCursor, CalendarReminderFiring, CalendarSyncStatus, CalendarWatchRelease,
- ConferenceProvider, DisconnectedGoogleCalendar, DueCalendarReminder, EventReminderOverride,
- EventReminders, EventStart, EventStatus, EventTime, EventTransparency, EventType,
- EventVisibility, GOOGLE_CALENDAR_SCOPES, GoogleCalendarSyncSnapshot, GoogleScopeSet,
- GoogleWatchChannel, OccurrenceRange, ProviderCalendar, StoredGoogleCalendar,
- TeamOutOfOffice, VisibleCalendar, is_system_calendar,
+ CalendarEventSourceContent, CalendarEventUpsert, CalendarGrantIntent,
+ CalendarLinkTokenIdentity, CalendarMentionEvent, CalendarMentionPreview,
+ CalendarMentionRequestItem, CalendarOccurrence, CalendarOccurrenceCursor,
+ CalendarReminderFiring, CalendarSyncStatus, CalendarWatchRelease, ConferenceProvider,
+ DisconnectedGoogleCalendar, DueCalendarReminder, EventReminderOverride, EventReminders,
+ EventStart, EventStatus, EventTime, EventTransparency, EventType, EventVisibility,
+ GOOGLE_CALENDAR_SCOPES, GoogleCalendarSyncSnapshot, GoogleScopeSet, GoogleWatchChannel,
+ OccurrenceRange, ProviderCalendar, StoredGoogleCalendar, TeamOutOfOffice, VisibleCalendar,
+ is_system_calendar,
},
ports::{
CalendarBackfillRepository, CalendarEventChange, CalendarEventWrite,
@@ -276,7 +277,6 @@ struct StoredCalendarRow {
struct OccurrenceJoinRow {
event_id: Uuid,
- canonical_calendar_id: Option<Uuid>,
occurrence_key: String,
recurrence_id: Option<String>,
occurrence_starts_at: Option<DateTime<Utc>>,
@@ -639,6 +639,7 @@ impl CalendarRepository for PgCalendarRepository {
write: CalendarEventWrite,
) -> Result<CalendarEventWriteOutcome, Report> {
let mut tx = self.pool.begin().await.map_err(report)?;
+ let user_mutation = matches!(write, CalendarEventWrite::UserMutation(_));
let upsert = match write {
CalendarEventWrite::GoogleBackfill {
key,
@@ -676,7 +677,7 @@ impl CalendarRepository for PgCalendarRepository {
// path entirely so rebuilds cost reads, not occurrence churn.
let existing = sqlx::query!(
r#"
- SELECT event_id, normalized_payload
+ SELECT event_id, normalized_payload, source_sequence
FROM calendar_event_sources
WHERE source_kind = 'google'
AND account_id = $1
@@ -690,7 +691,7 @@ impl CalendarRepository for PgCalendarRepository {
.fetch_optional(&mut *tx)
.await
.map_err(report)?;
- if let Some(row) = existing {
+ if let Some(row) = &existing {
let incoming =
serde_json::to_value(StoredSourceProjection::from(&upsert)).map_err(report)?;
if canonical_projection(&row.normalized_payload) == canonical_projection(&incoming) {
@@ -703,13 +704,17 @@ impl CalendarRepository for PgCalendarRepository {
}
}
+ let incoming_sequence = db_sequence(upsert.event.sequence)?;
+ let copy_advanced = existing
+ .as_ref()
+ .is_none_or(|row| incoming_sequence > row.source_sequence);
let (starts_at, ends_at, start_date, end_date, time_zone) = split_time(&upsert.event.time);
- let proposed_id = upsert.event.id;
- // Google is the authoritative source when the same RFC UID was first
- // discovered in email. Email can still create/update entities that do
- // not yet have a Google source.
- let applied = sqlx::query!(
+ // The entity row is created by whichever source arrives first and
+ // carries that source's content until a better-ranked source claims
+ // it below. An existing row is left alone here: its content belongs
+ // to its canonical source, not to whichever copy synced last.
+ let inserted = sqlx::query_scalar!(
r#"
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title, description, location,
@@ -719,9 +724,8 @@ impl CalendarRepository for PgCalendarRepository {
creator_email, creator_name,
conference_url, conference_provider, sequence, is_read_only,
canonical_source_kind,
- canonical_source_updated_at,
reminders_use_default, reminder_overrides,
- created_at, updated_at
+ created_at, updated_at, schedule_updated_at
)
VALUES (
$1, $2, $3, $4, $5, $6, $7,
@@ -729,49 +733,14 @@ impl CalendarRepository for PgCalendarRepository {
$11, $12, $13, $14, $15,
$16, $17, $18,
$28, $29,
- $19, $27, $20, $21, $22, $24,
+ $19, $27, $20, $21, $22,
$25, $26,
- $23, $24
+ $23, $24, $24
)
- ON CONFLICT (owner_id, source_link_id, ical_uid) DO UPDATE SET
- title = EXCLUDED.title,
- description = EXCLUDED.description,
- location = EXCLUDED.location,
- status = EXCLUDED.status,
- visibility = EXCLUDED.visibility,
- transparency = EXCLUDED.transparency,
- event_type = EXCLUDED.event_type,
- starts_at = EXCLUDED.starts_at,
- ends_at = EXCLUDED.ends_at,
- start_date = EXCLUDED.start_date,
- end_date = EXCLUDED.end_date,
- time_zone = EXCLUDED.time_zone,
- recurrence_lines = EXCLUDED.recurrence_lines,
- organizer_email = EXCLUDED.organizer_email,
- organizer_name = EXCLUDED.organizer_name,
- creator_email = EXCLUDED.creator_email,
- creator_name = EXCLUDED.creator_name,
- conference_url = EXCLUDED.conference_url,
- conference_provider = EXCLUDED.conference_provider,
- sequence = EXCLUDED.sequence,
- is_read_only = EXCLUDED.is_read_only,
- canonical_source_kind = EXCLUDED.canonical_source_kind,
- canonical_source_updated_at = EXCLUDED.canonical_source_updated_at,
- reminders_use_default = EXCLUDED.reminders_use_default,
- reminder_overrides = EXCLUDED.reminder_overrides,
- updated_at = GREATEST(calendar_events.updated_at, EXCLUDED.updated_at)
- WHERE
- EXCLUDED.sequence > calendar_events.sequence
- OR (
- EXCLUDED.sequence = calendar_events.sequence
- AND EXCLUDED.canonical_source_updated_at
- >= calendar_events.canonical_source_updated_at
- )
- -- `xmax = 0` distinguishes the INSERT from the DO UPDATE: a
- -- freshly inserted row carries no updating transaction id.
- RETURNING id, (xmax = 0) AS "inserted!"
+ ON CONFLICT (owner_id, source_link_id, ical_uid) DO NOTHING
+ RETURNING id
"#,
- proposed_id,
+ upsert.event.id,
&upsert.event.owner_id,
source_link_id,
&upsert.event.ical_uid,
@@ -790,7 +759,7 @@ impl CalendarRepository for PgCalendarRepository {
upsert.event.organizer_email.as_deref(),
upsert.event.organizer_name.as_deref(),
upsert.event.conference_url.as_deref(),
- db_sequence(upsert.event.sequence)?,
+ incoming_sequence,
upsert.event.is_read_only,
source_kind,
upsert.event.created_at,
@@ -808,19 +777,8 @@ impl CalendarRepository for PgCalendarRepository {
.fetch_optional(&mut *tx)
.await
.map_err(report)?;
-
- // No returned row means the sequence guard rejected the write as
- // stale: the source is still recorded below, but the canonical row and
- // its projections are untouched.
- let (event_id, change) = match &applied {
- Some(row) => (
- row.id,
- if row.inserted {
- CalendarEventChange::Created
- } else {
- CalendarEventChange::Updated
- },
- ),
+ let (event_id, inserted) = match inserted {
+ Some(id) => (id, true),
None => (
sqlx::query_scalar!(
"SELECT id FROM calendar_events WHERE owner_id = $1 AND source_link_id = $2 AND ical_uid = $3",
@@ -831,33 +789,56 @@ impl CalendarRepository for PgCalendarRepository {
.fetch_one(&mut *tx)
.await
.map_err(report)?,
- CalendarEventChange::Unchanged,
+ false,
),
};
- persist_source(&mut tx, event_id, &upsert).await?;
-
- // Only the source selected as canonical replaces projections and
- // attendees. Lower-sequence/stale sources are still recorded above.
- if applied.is_some() {
- replace_attendees(&mut tx, event_id, &upsert.event.attendees).await?;
- replace_overrides(&mut tx, event_id, &upsert.overrides).await?;
- replace_occurrences(
- &mut tx,
+ // The source row carries this copy's own content under its own
+ // freshness guard. A stale copy changes nothing at all.
+ let Some(source_id) = persist_source(&mut tx, event_id, &upsert).await? else {
+ tx.commit().await.map_err(report)?;
+ return Ok(CalendarEventWriteOutcome {
event_id,
- &upsert.event.owner_id,
- &upsert.occurrences,
- )
- .await?;
- let calendar =
- fetch_calendar_reminder_context(&mut tx, Some(source.calendar_id)).await?;
- rebuild_event_reminder_firings(
+ owner_id: upsert.event.owner_id.clone(),
+ change: CalendarEventChange::Unchanged,
+ });
+ };
+
+ // Content always follows the canonical copy. The schedule follows
+ // whichever copy last wrote it: the canonical copy takes it when that
+ // copy is new to Macro, advanced its own sequence, or is at least as
+ // fresh as the write it replaces, a user edit through another copy
+ // lands when it is at least that fresh, and the copy that wrote the
+ // schedule keeps writing it until then.
+ let canonical = canonical_source(&mut tx, event_id).await?;
+ let schedule = schedule_owner(&mut tx, event_id).await?;
+ let projection = StoredSourceProjection::from(&upsert);
+ let is_canonical =
+ canonical.as_ref().map(|canonical| canonical.source_id) == Some(source_id);
+ let owns_schedule = schedule.source_id == Some(source_id);
+ let writes_schedule = if is_canonical {
+ owns_schedule || copy_advanced || upsert.event.updated_at >= schedule.updated_at
+ } else if user_mutation {
+ upsert.event.updated_at >= schedule.updated_at
+ } else {
+ owns_schedule
+ };
+ if is_canonical {
+ apply_content_projection(&mut tx, event_id, source_id, &projection, source_kind)
+ .await?;
+ }
+ if writes_schedule {
+ if is_canonical {
+ apply_schedule_projection(&mut tx, event_id, source_id, &projection).await?;
+ } else {
+ apply_time_projection(&mut tx, event_id, source_id, &projection).await?;
+ }
+ }
+ if is_canonical || writes_schedule {
+ rebuild_entity_reminder_firings(
&mut tx,
event_id,
- upsert.event.status,
- upsert.event.event_type,
- &upsert.event.reminders,
- calendar.as_ref(),
+ canonical.map(|canonical| canonical.calendar_id),
)
.await?;
}
@@ -866,7 +847,11 @@ impl CalendarRepository for PgCalendarRepository {
Ok(CalendarEventWriteOutcome {
event_id,
owner_id: upsert.event.owner_id.clone(),
- change,
+ change: if inserted {
+ CalendarEventChange::Created
+ } else {
+ CalendarEventChange::Updated
+ },
})
}
@@ -886,7 +871,6 @@ impl CalendarRepository for PgCalendarRepository {
r#"
SELECT
occurrence.event_id,
- canonical_source.calendar_id AS "canonical_calendar_id?",
occurrence.occurrence_key,
occurrence.recurrence_id,
occurrence.starts_at AS occurrence_starts_at,
@@ -923,21 +907,6 @@ impl CalendarRepository for PgCalendarRepository {
event.updated_at
FROM calendar_event_occurrences occurrence
JOIN calendar_events event ON event.id = occurrence.event_id
- LEFT JOIN LATERAL (
- SELECT source.calendar_id
- FROM calendar_event_sources source
- JOIN calendars calendar ON calendar.id = source.calendar_id
- JOIN calendar_accounts account ON account.id = source.account_id
- WHERE source.event_id = event.id
- AND NOT calendar.is_deleted
- AND account.sync_status <> 'disabled'
- ORDER BY
- source.source_sequence DESC,
- source.source_updated_at DESC,
- source.last_seen_at DESC,
- source.id DESC
- LIMIT 1
- ) canonical_source ON true
WHERE occurrence.owner_id IN (
SELECT $1::text
UNION
@@ -991,9 +960,10 @@ impl CalendarRepository for PgCalendarRepository {
.await
.map_err(report)?;
let event_ids: Vec<_> = rows.iter().map(|row| row.event_id).collect();
- let (attendees, override_attendees) = try_join!(
+ let (attendees, override_attendees, source_contents) = try_join!(
fetch_attendees(&self.pool, &event_ids),
fetch_override_attendees(&self.pool, &event_ids),
+ fetch_source_contents(&self.pool, &event_ids),
)?;
rows.into_iter()
.map(|row| {
@@ -1011,7 +981,8 @@ impl CalendarRepository for PgCalendarRepository {
.or_else(|| attendees.get(&event_id))
.cloned()
.unwrap_or_default();
- let event = event_from_join(row, effective)?;
+ let sources = source_contents.get(&event_id).cloned().unwrap_or_default();
+ let event = event_from_join(row, effective, sources)?;
Ok((event, occurrence))
})
.collect()
@@ -1024,10 +995,12 @@ impl CalendarRepository for PgCalendarRepository {
range: OccurrenceRange,
limit: u16,
) -> Result<Vec<TeamOutOfOffice>, Report> {
- // The primary-calendar source guard keeps this to the teammate's own
- // status: an out-of-office event on a calendar they merely subscribe
- // to belongs to that calendar's owner, not to them. DISTINCT ON
- // collapses the same provider event synced through more than one of
+ // Type, title, and visibility come from the teammate's primary
+ // calendar copy, so a shared calendar's re-import of the event (which
+ // flattens the type and brackets the title) neither hides their status
+ // nor renames it, and an out-of-office event on a calendar they merely
+ // subscribe to belongs to that calendar's owner, not to them. DISTINCT
+ // ON collapses the same provider event synced through more than one of
// the teammate's inboxes before the limit, so duplicates never eat
// page slots or skew the caller's truncation detection.
let rows = sqlx::query!(
@@ -1050,8 +1023,8 @@ impl CalendarRepository for PgCalendarRepository {
occurrence.event_id,
event.ical_uid,
occurrence.occurrence_key,
- event.title,
- event.visibility,
+ source.title,
+ source.visibility,
event.time_zone,
occurrence.starts_at AS occurrence_starts_at,
occurrence.ends_at AS occurrence_ends_at,
@@ -1063,6 +1036,14 @@ impl CalendarRepository for PgCalendarRepository {
) AS occurrence_ordering
FROM calendar_event_occurrences occurrence
JOIN calendar_events event ON event.id = occurrence.event_id
+ JOIN calendar_event_sources source ON source.event_id = event.id
+ JOIN calendars calendar
+ ON calendar.id = source.calendar_id
+ AND calendar.is_primary
+ AND NOT calendar.is_deleted
+ JOIN calendar_accounts account
+ ON account.id = source.account_id
+ AND account.sync_status <> 'disabled'
WHERE occurrence.owner_id IN (
SELECT teammate.user_id
FROM team_user membership
@@ -1070,19 +1051,9 @@ impl CalendarRepository for PgCalendarRepository {
WHERE membership.user_id = $1
AND teammate.user_id <> $1
)
- AND event.event_type = 'out_of_office'
+ AND source.event_type = 'out_of_office'
AND event.status <> 'cancelled'
AND NOT occurrence.is_cancelled
- AND EXISTS (
- SELECT 1
- FROM calendar_event_sources source
- JOIN calendars calendar ON calendar.id = source.calendar_id
- JOIN calendar_accounts account ON account.id = source.account_id
- WHERE source.event_id = event.id
- AND calendar.is_primary
- AND NOT calendar.is_deleted
- AND account.sync_status <> 'disabled'
- )
AND (
occurrence.timed_span && tstzrange($2, $3, '[)')
OR occurrence.day_span && daterange($4, $5, '[)')
@@ -1091,7 +1062,10 @@ impl CalendarRepository for PgCalendarRepository {
event.owner_id,
event.ical_uid,
occurrence.occurrence_key,
- occurrence.event_id
+ occurrence.event_id,
+ source.source_sequence DESC,
+ source.source_updated_at DESC,
+ source.id DESC
) occurrence
ORDER BY
occurrence.occurrence_ordering,
@@ -1629,6 +1603,92 @@ impl CalendarRepository for PgCalendarRepository {
.await
.map_err(report)?;
+ // A copy's read-only flag mirrors its calendar's access role as of the
+ // event's last sync, and Google only resends events that changed, so a
+ // role change on the calendar list would otherwise leave every copy on
+ // that calendar stale. Refresh the copies from their calendars' live
+ // roles, including the stored projection a restore would replay, and
+ // the entities that mirror them.
+ sqlx::query!(
+ r#"
+ UPDATE calendar_event_sources source
+ SET is_read_only = live.is_read_only,
+ normalized_payload = jsonb_set(
+ source.normalized_payload,
+ '{event,isReadOnly}',
+ to_jsonb(live.is_read_only)
+ )
+ FROM (
+ SELECT
+ calendar.id AS calendar_id,
+ NOT COALESCE(calendar.access_role IN ('owner', 'writer'), false)
+ AS is_read_only
+ FROM calendars calendar
+ WHERE calendar.account_id = $1
+ ) live
+ WHERE source.calendar_id = live.calendar_id
+ AND source.is_read_only IS DISTINCT FROM live.is_read_only
+ "#,
+ account_id,
+ )
+ .execute(&mut *tx)
+ .await
+ .map_err(report)?;
+ let refreshed_events = sqlx::query!(
+ r#"
+ UPDATE calendar_events event
+ SET is_read_only = source.is_read_only
+ FROM calendar_event_sources source
+ WHERE source.id = event.content_source_id
+ AND source.account_id = $1
+ AND event.is_read_only IS DISTINCT FROM source.is_read_only
+ RETURNING event.id, event.owner_id
+ "#,
+ account_id,
+ )
+ .fetch_all(&mut *tx)
+ .await
+ .map_err(report)?;
+
+ // A calendar's access role or primary flag can change without any of
+ // its events changing, which moves the canonical copy without a source
+ // write. Re-project the entities whose content still mirrors another copy.
+ let reranked_event_ids = sqlx::query_scalar!(
+ r#"
+ SELECT event.id AS "id!"
+ FROM calendar_events event
+ WHERE event.id IN (
+ SELECT source.event_id
+ FROM calendar_event_sources source
+ WHERE source.account_id = $1
+ GROUP BY source.event_id
+ HAVING count(*) > 1
+ )
+ AND event.content_source_id
+ IS DISTINCT FROM calendar_event_canonical_source_id(event.id)
+ "#,
+ account_id,
+ )
+ .fetch_all(&mut *tx)
+ .await
+ .map_err(report)?;
+ for event_id in reranked_event_ids {
+ if let Some(outcome) = restore_best_source_or_delete(&mut tx, event_id).await? {
+ retired.push(outcome);
+ }
+ }
+ retired.extend(
+ refreshed_events
+ .into_iter()
+ .map(|row| RetiredCalendarEvent {
+ event_id: row.id,
+ owner_id: row.owner_id,
+ deleted: false,
+ }),
+ );
+ let mut announced = HashSet::new();
+ retired.retain(|outcome| announced.insert(outcome.event_id));
+
tx.commit().await.map_err(report)?;
Ok(retired)
}
@@ -1638,15 +1698,17 @@ impl CalendarRepository for PgCalendarRepository {
&self,
requester_id: &str,
event_id: Uuid,
+ calendar_id: Option<Uuid>,
) -> Result<Option<CalendarEventMutationTarget>, Report> {
- // Rank Google sources exactly like source restoration so mutations
- // address the same provider copy reads are projected from.
+ // Without a calendar, address the canonical copy the entity is
+ // projected from. With one, address that calendar's copy, whose own
+ // access role decides whether it can be edited.
let row = sqlx::query!(
r#"
SELECT
event.id AS event_id,
event.owner_id,
- event.is_read_only,
+ source.is_read_only,
source.provider_event_id AS "provider_event_id!",
source.provider_recurring_event_id,
source.account_id AS "account_id!",
@@ -1666,6 +1728,11 @@ impl CalendarRepository for PgCalendarRepository {
WHERE event.id = $1
AND NOT calendar.is_deleted
AND account.sync_status <> 'disabled'
+ AND CASE
+ WHEN $3::uuid IS NULL
+ THEN source.id = calendar_event_canonical_source_id(event.id)
+ ELSE source.calendar_id = $3
+ END
AND (
event.owner_id = $2
OR EXISTS (
@@ -1678,12 +1745,12 @@ impl CalendarRepository for PgCalendarRepository {
ORDER BY
source.source_sequence DESC,
source.source_updated_at DESC,
- source.last_seen_at DESC,
source.id DESC
LIMIT 1
"#,
event_id,
requester_id,
+ calendar_id,
)
.fetch_optional(&self.pool)
.await
@@ -2730,25 +2797,35 @@ async fn retry_failed_backfills_tx(
Ok(jobs)
}
+/// Record one provider copy with its own content. Returns the source row's
+/// id when the write landed, or `None` when the per-source freshness guard
+/// rejected it as stale.
async fn persist_source(
tx: &mut Transaction<'_, Postgres>,
event_id: Uuid,
upsert: &CalendarEventUpsert,
-) -> Result<(), Report> {
+) -> Result<Option<Uuid>, Report> {
let normalized_payload =
serde_json::to_value(StoredSourceProjection::from(upsert)).map_err(report)?;
let CalendarEventSource::Google(source) = &upsert.source;
- sqlx::query!(
+ let event = &upsert.event;
+ sqlx::query_scalar!(
r#"
INSERT INTO calendar_event_sources (
id, event_id, source_link_id, source_kind, account_id, calendar_id,
provider_event_id, provider_recurring_event_id,
provider_etag, raw_payload, source_sequence,
- source_updated_at, normalized_payload
+ source_updated_at, normalized_payload,
+ title, description, location, event_type, visibility, transparency,
+ is_read_only, reminders_use_default, reminder_overrides,
+ creator_email, creator_name
)
VALUES (
$1, $2, $3, 'google', $4, $5, $6, $7, $8, $9,
- $10, $11, $12
+ $10, $11, $12,
+ $13, $14, $15, $16, $17, $18,
+ $19, $20, $21,
+ $22, $23
)
ON CONFLICT (account_id, calendar_id, provider_event_id)
WHERE source_kind = 'google'
@@ -2760,6 +2837,17 @@ async fn persist_source(
source_sequence = EXCLUDED.source_sequence,
source_updated_at = EXCLUDED.source_updated_at,
normalized_payload = EXCLUDED.normalized_payload,
+ title = EXCLUDED.title,
+ description = EXCLUDED.description,
+ location = EXCLUDED.location,
+ event_type = EXCLUDED.event_type,
+ visibility = EXCLUDED.visibility,
+ transparency = EXCLUDED.transparency,
+ is_read_only = EXCLUDED.is_read_only,
+ reminders_use_default = EXCLUDED.reminders_use_default,
+ reminder_overrides = EXCLUDED.reminder_overrides,
+ creator_email = EXCLUDED.creator_email,
+ creator_name = EXCLUDED.creator_name,
last_seen_at = now()
WHERE
EXCLUDED.source_sequence > calendar_event_sources.source_sequence
@@ -2767,6 +2855,7 @@ async fn persist_source(
EXCLUDED.source_sequence = calendar_event_sources.source_sequence
AND EXCLUDED.source_updated_at >= calendar_event_sources.source_updated_at
)
+ RETURNING id
"#,
Uuid::now_v7(),
event_id,
@@ -2777,119 +2866,167 @@ async fn persist_source(
source.provider_recurring_event_id.as_deref(),
source.provider_etag.as_deref(),
&source.raw_payload,
- db_sequence(upsert.event.sequence)?,
- upsert.event.updated_at,
+ db_sequence(event.sequence)?,
+ event.updated_at,
&normalized_payload,
+ &event.title,
+ event.description.as_deref(),
+ event.location.as_deref(),
+ event.event_type.as_str(),
+ event.visibility.as_str(),
+ event.transparency.as_str(),
+ event.is_read_only,
+ event.reminders.use_default,
+ serde_json::to_value(&event.reminders.overrides).map_err(report)?,
+ event.creator_email.as_deref(),
+ event.creator_name.as_deref(),
)
- .execute(&mut **tx)
+ .fetch_optional(&mut **tx)
.await
- .map_err(report)?;
- Ok(())
+ .map_err(report)
}
-/// Rewrite an event from its next-best remaining source, or delete it when no
-/// source is left, reporting which happened.
-///
-/// `None` means the row was already gone before this call.
-async fn restore_best_source_or_delete(
+/// The copy whose content the entity carries.
+struct CanonicalSource {
+ source_id: Uuid,
+ calendar_id: Uuid,
+}
+
+/// The source whose content the entity carries, ranked by
+/// `calendar_event_canonical_source_id`: the primary calendar's copy, else a
+/// copy the grant can write, else the freshest, on a live calendar of an
+/// enabled account. Every ranking site goes through that function so the
+/// entity, the mutation target, the reminder schedule, and the listing agree.
+async fn canonical_source(
tx: &mut Transaction<'_, Postgres>,
event_id: Uuid,
-) -> Result<Option<RetiredCalendarEvent>, Report> {
- let identity = sqlx::query!(
+) -> Result<Option<CanonicalSource>, Report> {
+ let row = sqlx::query!(
r#"
- SELECT source_link_id, ical_uid, owner_id
- FROM calendar_events
- WHERE id = $1
+ SELECT source.id, source.calendar_id AS "calendar_id!"
+ FROM calendar_event_sources source
+ WHERE source.id = calendar_event_canonical_source_id($1)
"#,
event_id,
)
.fetch_optional(&mut **tx)
.await
.map_err(report)?;
- let Some(identity) = identity else {
- return Ok(None);
- };
- let reconciliation_lock =
- event_reconciliation_lock(identity.source_link_id, &identity.ical_uid);
- sqlx::query_scalar!(
- r#"SELECT 1 AS "locked!" FROM pg_advisory_xact_lock($1)"#,
- reconciliation_lock,
+ Ok(row.map(|row| CanonicalSource {
+ source_id: row.id,
+ calendar_id: row.calendar_id,
+ }))
+}
+
+/// The copy that last wrote the entity's schedule and that write's provider
+/// stamp. The copy is absent when it has since been retired.
+struct ScheduleOwner {
+ source_id: Option<Uuid>,
+ updated_at: DateTime<Utc>,
+}
+
+async fn schedule_owner(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+) -> Result<ScheduleOwner, Report> {
+ let row = sqlx::query!(
+ r#"SELECT schedule_source_id, schedule_updated_at FROM calendar_events WHERE id = $1"#,
+ event_id,
)
.fetch_one(&mut **tx)
.await
.map_err(report)?;
+ Ok(ScheduleOwner {
+ source_id: row.schedule_source_id,
+ updated_at: row.schedule_updated_at,
+ })
+}
- let source = sqlx::query!(
+/// Rewrite the entity's copy-specific content from its canonical copy and
+/// record which copy it now mirrors.
+async fn apply_content_projection(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+ source_id: Uuid,
+ projection: &StoredSourceProjection,
+ source_kind: &str,
+) -> Result<(), Report> {
+ sqlx::query!(
r#"
- SELECT source_kind, source_updated_at, normalized_payload, calendar_id
- FROM calendar_event_sources
- WHERE event_id = $1
- ORDER BY
- source_sequence DESC,
- source_updated_at DESC,
- last_seen_at DESC,
- id DESC
- LIMIT 1
+ UPDATE calendar_events
+ SET content_source_id = $17,
+ title = $2,
+ description = $3,
+ location = $4,
+ visibility = $5,
+ transparency = $6,
+ event_type = $7,
+ creator_email = $8,
+ creator_name = $9,
+ sequence = $10,
+ is_read_only = $11,
+ canonical_source_kind = $12,
+ reminders_use_default = $13,
+ reminder_overrides = $14,
+ created_at = $15,
+ updated_at = GREATEST(calendar_events.updated_at, $16)
+ WHERE id = $1
"#,
event_id,
+ &projection.event.title,
+ projection.event.description.as_deref(),
+ projection.event.location.as_deref(),
+ projection.event.visibility.as_str(),
+ projection.event.transparency.as_str(),
+ projection.event.event_type.as_str(),
+ projection.event.creator_email.as_deref(),
+ projection.event.creator_name.as_deref(),
+ db_sequence(projection.event.sequence)?,
+ projection.event.is_read_only,
+ source_kind,
+ projection.event.reminders.use_default,
+ serde_json::to_value(&projection.event.reminders.overrides).map_err(report)?,
+ projection.event.created_at,
+ projection.event.updated_at,
+ source_id,
)
- .fetch_optional(&mut **tx)
+ .execute(&mut **tx)
.await
.map_err(report)?;
- let Some(source) = source else {
- sqlx::query!("DELETE FROM calendar_events WHERE id = $1", event_id)
- .execute(&mut **tx)
- .await
- .map_err(report)?;
- return Ok(Some(RetiredCalendarEvent {
- event_id,
- owner_id: identity.owner_id,
- deleted: true,
- }));
- };
+ Ok(())
+}
- let projection: StoredSourceProjection =
- serde_json::from_value(source.normalized_payload).map_err(report)?;
+/// Rewrite the whole schedule the canonical copy owns: status, time,
+/// recurrence, organizer, conference, attendees, overrides, and occurrences.
+/// Records the copy as the schedule's writer with its provider stamp.
+async fn apply_schedule_projection(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+ source_id: Uuid,
+ projection: &StoredSourceProjection,
+) -> Result<(), Report> {
let (starts_at, ends_at, start_date, end_date, time_zone) = split_time(&projection.event.time);
sqlx::query!(
r#"
UPDATE calendar_events
- SET title = $2,
- description = $3,
- location = $4,
- status = $5,
- visibility = $6,
- transparency = $7,
- event_type = $28,
- starts_at = $8,
- ends_at = $9,
- start_date = $10,
- end_date = $11,
- time_zone = $12,
- recurrence_lines = $13,
- organizer_email = $14,
- organizer_name = $15,
- creator_email = $26,
- creator_name = $27,
- conference_url = $16,
- conference_provider = $25,
- sequence = $17,
- is_read_only = $18,
- canonical_source_kind = $19,
- canonical_source_updated_at = $20,
- reminders_use_default = $23,
- reminder_overrides = $24,
- created_at = $21,
- updated_at = GREATEST(calendar_events.updated_at, $22)
+ SET status = $2,
+ starts_at = $3,
+ ends_at = $4,
+ start_date = $5,
+ end_date = $6,
+ time_zone = $7,
+ recurrence_lines = $8,
+ organizer_email = $9,
+ organizer_name = $10,
+ conference_url = $11,
+ conference_provider = $12,
+ schedule_source_id = $13,
+ schedule_updated_at = $14,
+ updated_at = GREATEST(calendar_events.updated_at, $14)
WHERE id = $1
"#,
event_id,
- &projection.event.title,
- projection.event.description.as_deref(),
- projection.event.location.as_deref(),
projection.event.status.as_str(),
- projection.event.visibility.as_str(),
- projection.event.transparency.as_str(),
starts_at,
ends_at,
start_date,
@@ -2899,21 +3036,12 @@ async fn restore_best_source_or_delete(
projection.event.organizer_email.as_deref(),
projection.event.organizer_name.as_deref(),
projection.event.conference_url.as_deref(),
- db_sequence(projection.event.sequence)?,
- projection.event.is_read_only,
- &source.source_kind,
- source.source_updated_at,
- projection.event.created_at,
- projection.event.updated_at,
- projection.event.reminders.use_default,
- serde_json::to_value(&projection.event.reminders.overrides).map_err(report)?,
projection
.event
.conference_provider
.map(ConferenceProvider::as_str),
- projection.event.creator_email.as_deref(),
- projection.event.creator_name.as_deref(),
- projection.event.event_type.as_str(),
+ source_id,
+ projection.event.updated_at,
)
.execute(&mut **tx)
.await
@@ -2926,16 +3054,190 @@ async fn restore_best_source_or_delete(
&projection.event.owner_id,
&projection.occurrences,
)
- .await?;
- let calendar = fetch_calendar_reminder_context(tx, source.calendar_id).await?;
+ .await
+}
+
+/// Rewrite the time shape a non-canonical copy carries for the meeting:
+/// status, time, recurrence, overrides, and occurrences. Attendees,
+/// organizer, and conference stay the canonical copy's. Records the copy as
+/// the schedule's writer with its provider stamp.
+async fn apply_time_projection(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+ source_id: Uuid,
+ projection: &StoredSourceProjection,
+) -> Result<(), Report> {
+ let (starts_at, ends_at, start_date, end_date, time_zone) = split_time(&projection.event.time);
+ sqlx::query!(
+ r#"
+ UPDATE calendar_events
+ SET status = $2,
+ starts_at = $3,
+ ends_at = $4,
+ start_date = $5,
+ end_date = $6,
+ time_zone = $7,
+ recurrence_lines = $8,
+ schedule_source_id = $9,
+ schedule_updated_at = $10,
+ updated_at = GREATEST(calendar_events.updated_at, $10)
+ WHERE id = $1
+ "#,
+ event_id,
+ projection.event.status.as_str(),
+ starts_at,
+ ends_at,
+ start_date,
+ end_date,
+ time_zone,
+ &projection.event.recurrence_lines,
+ source_id,
+ projection.event.updated_at,
+ )
+ .execute(&mut **tx)
+ .await
+ .map_err(report)?;
+ replace_overrides(tx, event_id, &projection.overrides).await?;
+ replace_occurrences(
+ tx,
+ event_id,
+ &projection.event.owner_id,
+ &projection.occurrences,
+ )
+ .await
+}
+
+/// Rebuild the entity's reminder firings from the content and occurrences it
+/// now carries, resolving calendar defaults against the canonical copy's
+/// calendar, so alerts follow the canonical copy's settings whichever copy
+/// last moved the schedule.
+async fn rebuild_entity_reminder_firings(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+ canonical_calendar_id: Option<Uuid>,
+) -> Result<(), Report> {
+ let entity = sqlx::query!(
+ r#"
+ SELECT status, event_type, reminders_use_default, reminder_overrides
+ FROM calendar_events
+ WHERE id = $1
+ "#,
+ event_id,
+ )
+ .fetch_one(&mut **tx)
+ .await
+ .map_err(report)?;
+ let reminders = EventReminders {
+ use_default: entity.reminders_use_default,
+ overrides: serde_json::from_value(entity.reminder_overrides)
+ .inspect_err(|e| {
+ tracing::error!(error = ?e, %event_id, "malformed event reminder_overrides json");
+ })
+ .unwrap_or_default(),
+ };
+ let calendar = fetch_calendar_reminder_context(tx, canonical_calendar_id).await?;
rebuild_event_reminder_firings(
tx,
event_id,
- projection.event.status,
- projection.event.event_type,
- &projection.event.reminders,
+ event_status(&entity.status),
+ event_type(&entity.event_type),
+ &reminders,
calendar.as_ref(),
)
+ .await
+}
+
+/// Rewrite the entity from the copy that inherits it after a retirement.
+/// Content always follows it. The schedule follows it unless another
+/// surviving copy wrote a fresher one, which is how a user's edit made
+/// through a copy outlives the retirement of an unrelated third copy.
+async fn apply_canonical_projection(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+ source_id: Uuid,
+ projection: &StoredSourceProjection,
+ source_kind: &str,
+ calendar_id: Option<Uuid>,
+) -> Result<(), Report> {
+ apply_content_projection(tx, event_id, source_id, projection, source_kind).await?;
+ let schedule = schedule_owner(tx, event_id).await?;
+ if schedule.source_id.is_none_or(|owner| owner == source_id)
+ || projection.event.updated_at >= schedule.updated_at
+ {
+ apply_schedule_projection(tx, event_id, source_id, projection).await?;
+ }
+ rebuild_entity_reminder_firings(tx, event_id, calendar_id).await
+}
+
+/// Rewrite an event from its next-best remaining source, or delete it when no
+/// source on a live calendar is left, reporting which happened.
+///
+/// `None` means the row was already gone before this call.
+async fn restore_best_source_or_delete(
+ tx: &mut Transaction<'_, Postgres>,
+ event_id: Uuid,
+) -> Result<Option<RetiredCalendarEvent>, Report> {
+ let identity = sqlx::query!(
+ r#"
+ SELECT source_link_id, ical_uid, owner_id
+ FROM calendar_events
+ WHERE id = $1
+ "#,
+ event_id,
+ )
+ .fetch_optional(&mut **tx)
+ .await
+ .map_err(report)?;
+ let Some(identity) = identity else {
+ return Ok(None);
+ };
+ let reconciliation_lock =
+ event_reconciliation_lock(identity.source_link_id, &identity.ical_uid);
+ sqlx::query_scalar!(
+ r#"SELECT 1 AS "locked!" FROM pg_advisory_xact_lock($1)"#,
+ reconciliation_lock,
+ )
+ .fetch_one(&mut **tx)
+ .await
+ .map_err(report)?;
+
+ let source = sqlx::query!(
+ r#"
+ SELECT
+ source.id,
+ source.source_kind,
+ source.normalized_payload,
+ source.calendar_id
+ FROM calendar_event_sources source
+ WHERE source.id = calendar_event_canonical_source_id($1)
+ "#,
+ event_id,
+ )
+ .fetch_optional(&mut **tx)
+ .await
+ .map_err(report)?;
+ let Some(source) = source else {
+ sqlx::query!("DELETE FROM calendar_events WHERE id = $1", event_id)
+ .execute(&mut **tx)
+ .await
+ .map_err(report)?;
+ return Ok(Some(RetiredCalendarEvent {
+ event_id,
+ owner_id: identity.owner_id,
+ deleted: true,
+ }));
+ };
+
+ let projection: StoredSourceProjection =
+ serde_json::from_value(source.normalized_payload).map_err(report)?;
+ apply_canonical_projection(
+ tx,
+ event_id,
+ source.id,
+ &projection,
+ &source.source_kind,
+ source.calendar_id,
+ )
.await?;
Ok(Some(RetiredCalendarEvent {
event_id,
@@ -3256,10 +3558,10 @@ async fn rebuild_event_reminder_firings(
/// Rebuild the firing schedule for every event whose canonical source lives
/// on one calendar, after its default reminders or time zone changed.
/// Set-based because a defaults change fans out to every `useDefault` event
-/// on the calendar. Both statements rank sources exactly like
-/// `restore_best_source_or_delete` and the read path: an event that also
-/// holds a secondary source on this calendar keeps the schedule its
-/// canonical calendar derived.
+/// on the calendar. Both statements key on the canonical copy, so an event
+/// that also holds a secondary copy on this calendar keeps the schedule its
+/// canonical calendar derived and a shared calendar's defaults never reach a
+/// member's own event.
async fn rebuild_calendar_reminder_firings(
tx: &mut Transaction<'_, Postgres>,
calendar_id: Uuid,
@@ -3275,13 +3577,7 @@ async fn rebuild_calendar_reminder_firings(
AND (
SELECT canonical.calendar_id
FROM calendar_event_sources canonical
- WHERE canonical.event_id = firing.event_id
- ORDER BY
- canonical.source_sequence DESC,
- canonical.source_updated_at DESC,
- canonical.last_seen_at DESC,
- canonical.id DESC
- LIMIT 1
+ WHERE canonical.id = calendar_event_canonical_source_id(firing.event_id)
) = $1
"#,
calendar_id,
@@ -3326,13 +3622,7 @@ async fn rebuild_calendar_reminder_firings(
AND (
SELECT canonical.calendar_id
FROM calendar_event_sources canonical
- WHERE canonical.event_id = event.id
- ORDER BY
- canonical.source_sequence DESC,
- canonical.source_updated_at DESC,
- canonical.last_seen_at DESC,
- canonical.id DESC
- LIMIT 1
+ WHERE canonical.id = calendar_event_canonical_source_id(event.id)
) = $1
AND event.status <> 'cancelled'
AND NOT occurrence.is_cancelled
@@ -3352,6 +3642,81 @@ async fn rebuild_calendar_reminder_firings(
Ok(())
}
+/// Every active copy of each event in canonical order, the same keys
+/// `calendar_event_canonical_source_id` ranks by: the primary calendar's
+/// copy, then writable copies, then the freshest. Copies on deleted calendars
+/// or disabled accounts are omitted, mirroring what the calendar list shows.
+async fn fetch_source_contents(
+ pool: &PgPool,
+ event_ids: &[Uuid],
+) -> Result<HashMap<Uuid, Vec<CalendarEventSourceContent>>, Report> {
+ if event_ids.is_empty() {
+ return Ok(HashMap::new());
+ }
+ let rows = sqlx::query!(
+ r#"
+ SELECT
+ source.event_id,
+ source.calendar_id AS "calendar_id!",
+ source.title,
+ source.description,
+ source.location,
+ source.event_type,
+ source.visibility,
+ source.transparency,
+ source.is_read_only,
+ source.reminders_use_default,
+ source.reminder_overrides,
+ source.creator_email,
+ source.creator_name
+ FROM calendar_event_sources source
+ JOIN calendars calendar ON calendar.id = source.calendar_id
+ JOIN calendar_accounts account ON account.id = source.account_id
+ WHERE source.event_id = ANY($1)
+ AND NOT calendar.is_deleted
+ AND account.sync_status <> 'disabled'
+ ORDER BY
+ source.event_id,
+ calendar.is_primary DESC,
+ (calendar.access_role IN ('owner', 'writer')) DESC NULLS LAST,
+ source.source_sequence DESC,
+ source.source_updated_at DESC,
+ source.id DESC
+ "#,
+ event_ids,
+ )
+ .fetch_all(pool)
+ .await
+ .map_err(report)?;
+ let mut grouped: HashMap<Uuid, Vec<CalendarEventSourceContent>> = HashMap::new();
+ for row in rows {
+ grouped
+ .entry(row.event_id)
+ .or_default()
+ .push(CalendarEventSourceContent {
+ calendar_id: row.calendar_id,
+ title: row.title,
+ description: row.description,
+ location: row.location,
+ event_type: event_type(&row.event_type),
+ visibility: event_visibility(&row.visibility),
+ transparency: event_transparency(&row.transparency),
+ is_read_only: row.is_read_only,
+ reminders: EventReminders {
+ use_default: row.reminders_use_default,
+ overrides: serde_json::from_value(row.reminder_overrides)
+ .inspect_err(|e| {
+ tracing::error!(error = ?e, event_id = %row.event_id, calendar_id = %row.calendar_id, "malformed source reminder_overrides json");
+ })
+ .unwrap_or_default(),
+ },
+ creator_email: row.creator_email,
+ creator_name: row.creator_name,
+ });
+ }
+ Ok(grouped)
+}
+
async fn fetch_attendees(
pool: &PgPool,
event_ids: &[Uuid],
@@ -3547,12 +3912,14 @@ fn mention_preview_from_row(row: MentionPreviewRow) -> Result<CalendarMentionPre
fn event_from_join(
row: OccurrenceJoinRow,
attendees: Vec<CalendarAttendee>,
+ sources: Vec<CalendarEventSourceContent>,
) -> Result<CalendarEvent, Report> {
Ok(CalendarEvent {
id: row.event_id,
owner_id: row.owner_id,
ical_uid: row.ical_uid,
- calendar_id: row.canonical_calendar_id,
+ calendar_id: sources.first().map(|source| source.calendar_id),
+ sources,
title: row.title,
description: row.description,
location: row.location,
@@ -3765,8 +4132,10 @@ impl CalendarReminderDispatchRepo for PgCalendarRepository {
// Matching the firing row exactly — including `fire_at` — is what
// makes a stale message safe: a moved event replaced its schedule
// rows, and this then finds nothing rather than alerting at a time
- // that no longer exists. The canonical-source lateral mirrors the
- // read path so a deleted calendar or disabled account stops alerts.
+ // that no longer exists. Joining the canonical copy through
+ // `calendar_event_canonical_source_id` skips deleted calendars and
+ // disabled accounts like the read path, so losing the calendar that
+ // owns the schedule stops its alerts.
// The grace bound is re-applied here because firing rows outlive the
// sweep window: a Deliver message that sat in the queue past the
// grace must drop, not alert hours late.
@@ -3781,7 +4150,7 @@ impl CalendarReminderDispatchRepo for PgCalendarRepository {
occurrence.ends_at,
occurrence.start_date,
occurrence.end_date,
- canonical_source.calendar_time_zone AS "calendar_time_zone?",
+ canonical_calendar.time_zone AS "calendar_time_zone?",
CASE WHEN EXISTS (
SELECT 1
FROM calendar_event_overrides override
@@ -3814,21 +4183,10 @@ impl CalendarReminderDispatchRepo for PgCalendarRepository {
JOIN calendar_event_occurrences occurrence
ON occurrence.event_id = firing.event_id
AND occurrence.occurrence_key = firing.occurrence_key
- JOIN LATERAL (
- SELECT calendar.time_zone AS calendar_time_zone
- FROM calendar_event_sources source
- JOIN calendars calendar ON calendar.id = source.calendar_id
- JOIN calendar_accounts account ON account.id = source.account_id
- WHERE source.event_id = event.id
- AND NOT calendar.is_deleted
- AND account.sync_status <> 'disabled'
- ORDER BY
- source.source_sequence DESC,
- source.source_updated_at DESC,
- source.last_seen_at DESC,
- source.id DESC
- LIMIT 1
- ) canonical_source ON true
+ JOIN calendar_event_sources canonical_source
+ ON canonical_source.id = calendar_event_canonical_source_id(event.id)
+ JOIN calendars canonical_calendar
+ ON canonical_calendar.id = canonical_source.calendar_id
WHERE firing.event_id = $1
AND firing.occurrence_key = $2
AND firing.minutes_before = $3
diff --git a/crates/calendar_events/src/outbound/pg/test.rs b/crates/calendar_events/src/outbound/pg/test.rs
index 2b17d0b0e9..4c6e0c5f63 100644
--- a/crates/calendar_events/src/outbound/pg/test.rs
+++ b/crates/calendar_events/src/outbound/pg/test.rs
@@ -125,6 +125,7 @@ fn timed_upsert(
owner_id: owner_id.to_string(),
ical_uid: uid.to_string(),
calendar_id: Some(calendar_id),
+ sources: Vec::new(),
title: title.to_string(),
description: None,
location: None,
@@ -873,7 +874,7 @@ async fn canonical_precedence_uses_the_selected_source_clock(pool: PgPool) {
let canonical = sqlx::query!(
r#"
- SELECT title, canonical_source_updated_at, updated_at
+ SELECT title, schedule_updated_at, updated_at
FROM calendar_events
WHERE id = $1
"#,
@@ -883,7 +884,7 @@ async fn canonical_precedence_uses_the_selected_source_clock(pool: PgPool) {
.await
.unwrap();
assert_eq!(canonical.title, "Later sequence, earlier clock");
- assert_eq!(canonical.canonical_source_updated_at, winning_clock);
+ assert_eq!(canonical.schedule_updated_at, winning_clock);
assert_eq!(canonical.updated_at, later_clock);
}
@@ -2503,7 +2504,7 @@ async fn mutation_target_resolves_only_for_visible_requesters(pool: PgPool) {
.unwrap();
let target = repo
- .get_event_mutation_target(owner_id, event_id)
+ .get_event_mutation_target(owner_id, event_id, None)
.await
.unwrap()
.expect("owner sees the mutation target");
@@ -2527,7 +2528,7 @@ async fn mutation_target_resolves_only_for_visible_requesters(pool: PgPool) {
);
let delegated = repo
- .get_event_mutation_target(delegate_id, event_id)
+ .get_event_mutation_target(delegate_id, event_id, None)
.await
.unwrap()
.expect("delegate sees the mutation target");
@@ -2538,7 +2539,7 @@ async fn mutation_target_resolves_only_for_visible_requesters(pool: PgPool) {
);
let hidden = repo
- .get_event_mutation_target(stranger_id, event_id)
+ .get_event_mutation_target(stranger_id, event_id, None)
.await
.unwrap();
assert!(hidden.is_none(), "stranger cannot see the mutation target");
@@ -2837,6 +2838,7 @@ fn reminder_upsert(
owner_id: owner_id.to_string(),
ical_uid: uid.to_string(),
calendar_id: Some(calendar_id),
+ sources: Vec::new(),
title: "Reminder subject".to_string(),
description: None,
location: None,
@@ -4299,3 +4301,1741 @@ async fn team_out_of_office_deduplicates_before_the_limit(pool: PgPool) {
.any(|row| row.ical_uid == "[email protected]")
);
}
+
+/// A shared calendar an account subscribes to, on which Google's
+/// vacation-calendar script re-imports members' out-of-office events under
+/// the same UID with a bracketed title and the type flattened to `default`.
+async fn insert_shared_calendar(
+ repo: &PgCalendarRepository,
+ account_id: Uuid,
+ access_role: &str,
+ default_reminders: &[u32],
+) -> Uuid {
+ repo.upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "[email protected]".to_string(),
+ name: "Macro Vacation".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some(access_role.to_string()),
+ is_primary: false,
+ is_selected: true,
+ default_reminders: default_reminders
+ .iter()
+ .map(|minutes| EventReminderOverride {
+ method: REMINDER_METHOD_POPUP.to_string(),
+ minutes: *minutes,
+ })
+ .collect(),
+ },
+ )
+ .await
+ .unwrap()
+}
+
+/// The member's own out-of-office event on their primary calendar, carrying
+/// distinctive values for every per-copy field so a copy that overwrites one
+/// is caught: editable, busy, private, with an explicit 30-minute reminder,
+/// created by the member.
+fn member_primary_upsert(
+ owner_id: &str,
+ link_id: Uuid,
+ provider: (Uuid, Uuid),
+ uid: &str,
+ starts_at: DateTime<Utc>,
+) -> CalendarEventUpsert {
+ let mut upsert = reminder_upsert(
+ owner_id,
+ link_id,
+ provider,
+ uid,
+ starts_at,
+ popup_reminders(&[30]),
+ );
+ upsert.event.title = "OOO".to_string();
+ upsert.event.event_type = EventType::OutOfOffice;
+ upsert.event.is_read_only = false;
+ upsert.event.transparency = EventTransparency::Opaque;
+ upsert.event.visibility = EventVisibility::Private;
+ upsert.event.creator_email = Some("[email protected]".to_string());
+ upsert.event.creator_name = Some("Teo".to_string());
+ upsert
+}
+
+/// The shared calendar's re-imported copy of the member's event: the same
+/// provider event id, the same sequence, a provider `updated` stamp one hour
+/// newer than the member's own copy, and every per-copy field reframed the
+/// way Google records a copy — bracketed title, `default` type, reader
+/// access, marked free, default visibility, its own reminder, the script's
+/// creator.
+fn shared_copy_upsert(
+ owner_id: &str,
+ link_id: Uuid,
+ provider: (Uuid, Uuid),
+ uid: &str,
+ starts_at: DateTime<Utc>,
+) -> CalendarEventUpsert {
+ let (account_id, calendar_id) = provider;
+ let mut upsert = reminder_upsert(
+ owner_id,
+ link_id,
+ provider,
+ uid,
+ starts_at,
+ popup_reminders(&[5]),
+ );
+ upsert.event.title = "[teo] OOO".to_string();
+ upsert.event.event_type = EventType::Default;
+ upsert.event.is_read_only = true;
+ upsert.event.transparency = EventTransparency::Transparent;
+ upsert.event.visibility = EventVisibility::Default;
+ upsert.event.creator_email = Some("[email protected]".to_string());
+ upsert.event.creator_name = Some("Vacation script".to_string());
+ upsert.event.updated_at += Duration::hours(1);
+ upsert.source = CalendarEventSource::Google(GoogleEventSource {
+ email_link_id: link_id,
+ account_id,
+ calendar_id,
+ provider_event_id: format!("provider-{uid}"),
+ provider_recurring_event_id: None,
+ provider_etag: None,
+ raw_payload: serde_json::json!({}),
+ });
+ upsert
+}
+
+struct EntityContent {
+ title: String,
+ event_type: String,
+ is_read_only: bool,
+ transparency: String,
+ visibility: String,
+ reminders_use_default: bool,
+ reminder_overrides: serde_json::Value,
+ creator_email: Option<String>,
+ sequence: i32,
+ schedule_updated_at: DateTime<Utc>,
+}
+
+async fn entity_content(pool: &PgPool, event_id: Uuid) -> EntityContent {
+ sqlx::query_as!(
+ EntityContent,
+ r#"
+ SELECT title, event_type, is_read_only, transparency, visibility,
+ reminders_use_default, reminder_overrides, creator_email,
+ sequence, schedule_updated_at
+ FROM calendar_events WHERE id = $1
+ "#,
+ event_id,
+ )
+ .fetch_one(pool)
+ .await
+ .unwrap()
+}
+
+/// Assert the entity carries the [`member_primary_upsert`] values rather than
+/// a shared copy's.
+fn assert_primary_content(content: &EntityContent) {
+ assert_eq!(content.title, "OOO", "title");
+ assert_eq!(content.event_type, "out_of_office", "event_type");
+ assert!(!content.is_read_only, "is_read_only");
+ assert_eq!(content.transparency, "opaque", "transparency");
+ assert_eq!(content.visibility, "private", "visibility");
+ assert!(!content.reminders_use_default, "reminders_use_default");
+ assert_eq!(
+ content.reminder_overrides,
+ serde_json::json!([{ "method": REMINDER_METHOD_POPUP, "minutes": 30 }]),
+ "reminder_overrides",
+ );
+ assert_eq!(content.creator_email.as_deref(), Some("[email protected]"));
+}
+
+fn range_around(starts_at: DateTime<Utc>) -> OccurrenceRange {
+ let range_start = starts_at - Duration::days(1);
+ let range_end = starts_at + Duration::days(1);
+ OccurrenceRange {
+ starts_at: range_start,
+ ends_at: range_end,
+ start_date: range_start.date_naive(),
+ end_date: range_end.date_naive(),
+ }
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn shared_calendar_copy_records_its_content_without_touching_the_primary_entity(
+ pool: PgPool,
+) {
+ let member = "macro|[email protected]";
+ let viewer = "macro|[email protected]";
+ insert_team(&pool, member, &[member, viewer]).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ // The member's own copy syncs first. The shared copy arrives an hour
+ // later with the same sequence and a newer provider stamp.
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ let outcome = repo
+ .upsert_event(CalendarEventWrite::Fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ )))
+ .await
+ .unwrap();
+ assert_eq!(
+ outcome.event_id, event_id,
+ "both copies attach to one entity"
+ );
+ assert_eq!(
+ outcome.change,
+ CalendarEventChange::Updated,
+ "a new copy is a change readers must refetch"
+ );
+
+ assert_primary_content(&entity_content(&pool, event_id).await);
+
+ // The listing carries both copies, the primary first, and attributes the
+ // event to the primary calendar.
+ let rows = repo
+ .list_occurrences(member, range_around(starts_at), None, 10)
+ .await
+ .unwrap();
+ let (event, _) = rows.first().expect("the merged event lists once");
+ assert_eq!(rows.len(), 1);
+ assert_eq!(event.calendar_id, Some(primary_calendar_id));
+ assert_eq!(event.title, "OOO");
+ assert_eq!(event.event_type, EventType::OutOfOffice);
+ let copies: Vec<_> = event
+ .sources
+ .iter()
+ .map(|source| {
+ (
+ source.calendar_id,
+ source.title.as_str(),
+ source.event_type,
+ source.is_read_only,
+ source.transparency,
+ source.reminders.popup_minutes(&[]),
+ source.creator_email.as_deref(),
+ )
+ })
+ .collect();
+ assert_eq!(
+ copies,
+ vec![
+ (
+ primary_calendar_id,
+ "OOO",
+ EventType::OutOfOffice,
+ false,
+ EventTransparency::Opaque,
+ vec![30],
+ ),
+ (
+ shared_calendar_id,
+ "[teo] OOO",
+ EventType::Default,
+ true,
+ EventTransparency::Transparent,
+ vec![5],
+ ),
+ ]
+ );
+
+ // The team overlay reads the member's own type and title.
+ let team = repo
+ .list_team_out_of_office(viewer, range_around(starts_at), 100)
+ .await
+ .unwrap();
+ assert_eq!(
+ team.iter()
+ .map(|row| (row.owner_id.as_str(), row.title.as_deref()))
+ .collect::<Vec<_>>(),
+ vec![(member, Some("OOO"))]
+ );
+
+ // Reminders fire once, per the member's own 30-minute setting.
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ vec![(
+ starts_at.to_rfc3339(),
+ 30,
+ starts_at - Duration::minutes(30)
+ )]
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_late_primary_sync_reclaims_the_entity_from_a_shared_copy(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let viewer = "macro|[email protected]";
+ insert_team(&pool, member, &[member, viewer]).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ // The shared copy backfills first, so the entity starts life as the copy.
+ let event_id = repo
+ .upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ let seeded = entity_content(&pool, event_id).await;
+ assert_eq!(
+ (seeded.title.as_str(), seeded.event_type.as_str()),
+ ("[teo] OOO", "default")
+ );
+ assert!(
+ repo.list_team_out_of_office(viewer, range_around(starts_at), 100)
+ .await
+ .unwrap()
+ .is_empty(),
+ "a copy on a subscribed calendar is not the member's own status"
+ );
+
+ // The member's primary copy syncs later with an older provider stamp. It
+ // loses the freshness comparison but owns the entity outright.
+ let outcome = repo
+ .upsert_event(CalendarEventWrite::Fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ )))
+ .await
+ .unwrap();
+ assert_eq!(outcome.event_id, event_id);
+ assert_eq!(outcome.change, CalendarEventChange::Updated);
+
+ let content = entity_content(&pool, event_id).await;
+ assert_primary_content(&content);
+ assert_eq!(
+ content.schedule_updated_at,
+ starts_at - Duration::days(1),
+ "the schedule stamp follows the primary copy"
+ );
+ let rows = repo
+ .list_occurrences(member, range_around(starts_at), None, 10)
+ .await
+ .unwrap();
+ assert_eq!(rows[0].0.calendar_id, Some(primary_calendar_id));
+ assert_eq!(
+ rows[0]
+ .0
+ .sources
+ .iter()
+ .map(|source| source.calendar_id)
+ .collect::<Vec<_>>(),
+ vec![primary_calendar_id, shared_calendar_id]
+ );
+ assert_eq!(
+ repo.list_team_out_of_office(viewer, range_around(starts_at), 100)
+ .await
+ .unwrap()
+ .len(),
+ 1
+ );
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ vec![(
+ starts_at.to_rfc3339(),
+ 30,
+ starts_at - Duration::minutes(30)
+ )]
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn an_hourly_shared_copy_reimport_never_reclaims_the_entity(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // Every import carries the original's sequence and a later provider
+ // `updated`.
+ let mut copy = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ );
+ for _ in 0..3 {
+ copy.event.updated_at += Duration::hours(1);
+ repo.upsert_event_fixture(copy.clone()).await.unwrap();
+ assert_primary_content(&entity_content(&pool, event_id).await);
+ }
+ let copy_title = sqlx::query_scalar!(
+ r#"SELECT title FROM calendar_event_sources WHERE event_id = $1 AND calendar_id = $2"#,
+ event_id,
+ shared_calendar_id,
+ )
+ .fetch_one(&pool)
+ .await
+ .unwrap();
+ assert_eq!(
+ copy_title, "[teo] OOO",
+ "the copy's own row keeps its content"
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_primary_edit_propagates_over_a_fresher_shared_copy(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // The member renames their event and drops the reminder; the echo carries
+ // a higher sequence than the copy and rewrites the entity.
+ let mut edited = member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ );
+ edited.event.sequence = 1;
+ edited.event.title = "Out of office".to_string();
+ edited.event.reminders = EventReminders::default();
+ edited.event.updated_at += Duration::hours(2);
+ repo.upsert_event(CalendarEventWrite::UserMutation(edited))
+ .await
+ .unwrap();
+
+ let content = entity_content(&pool, event_id).await;
+ assert_eq!(content.title, "Out of office");
+ assert_eq!(content.sequence, 1);
+ assert!(content.reminders_use_default);
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ Vec::new(),
+ "an out-of-office event following calendar defaults schedules nothing"
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn mutation_target_addresses_the_primary_by_default_and_the_named_calendar_copy(
+ pool: PgPool,
+) {
+ let member = "macro|[email protected]";
+ insert_user(&pool, member).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = grant_and_provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ repo.upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ let event_id = repo
+ .upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ let default_target = repo
+ .get_event_mutation_target(member, event_id, None)
+ .await
+ .unwrap()
+ .expect("owner sees the mutation target");
+ assert_eq!(default_target.calendar_id, primary_calendar_id);
+ assert_eq!(default_target.provider_calendar_id, "primary");
+ assert!(!default_target.is_read_only);
+
+ let copy_target = repo
+ .get_event_mutation_target(member, event_id, Some(shared_calendar_id))
+ .await
+ .unwrap()
+ .expect("the shared copy is addressable by its calendar");
+ assert_eq!(copy_target.calendar_id, shared_calendar_id);
+ assert_eq!(
+ copy_target.provider_calendar_id,
+ );
+ assert!(
+ copy_target.is_read_only,
+ "the copy's own access role decides"
+ );
+
+ let elsewhere = repo
+ .get_event_mutation_target(member, event_id, Some(Uuid::now_v7()))
+ .await
+ .unwrap();
+ assert!(
+ elsewhere.is_none(),
+ "a calendar without a copy of the event is not a target"
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn calendar_default_reminder_changes_follow_the_primary_calendar(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[5]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ // A regular meeting following calendar defaults on the member's primary,
+ // then the shared calendar's copy with a newer stamp.
+ let event_id = repo
+ .upsert_event_fixture(reminder_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ EventReminders::default(),
+ ))
+ .await
+ .unwrap();
+ let mut copy = reminder_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ EventReminders::default(),
+ );
+ copy.event.updated_at += Duration::hours(1);
+ repo.upsert_event_fixture(copy).await.unwrap();
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ Vec::new(),
+ "the primary calendar has no default reminders"
+ );
+
+ // Changing the shared calendar's defaults must not reach an event it
+ // merely holds a copy of.
+ insert_shared_calendar(&repo, account_id, "reader", &[15]).await;
+ assert_eq!(scheduled_firings(&pool, event_id).await, Vec::new());
+
+ // Changing the primary calendar's defaults must.
+ repo.upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "primary".to_string(),
+ name: "Primary".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("owner".to_string()),
+ is_primary: true,
+ is_selected: true,
+ default_reminders: vec![EventReminderOverride {
+ method: REMINDER_METHOD_POPUP.to_string(),
+ minutes: 10,
+ }],
+ },
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ vec![(
+ starts_at.to_rfc3339(),
+ 10,
+ starts_at - Duration::minutes(10)
+ )]
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn retiring_the_primary_copy_promotes_the_shared_copy(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ let retired = repo
+ .remove_google_source(account_id, primary_calendar_id, &format!("provider-{uid}"))
+ .await
+ .unwrap();
+ assert_eq!(
+ retired,
+ vec![RetiredCalendarEvent {
+ event_id,
+ owner_id: member.to_string(),
+ deleted: false,
+ }]
+ );
+ let content = entity_content(&pool, event_id).await;
+ assert_eq!(
+ (
+ content.title.as_str(),
+ content.event_type.as_str(),
+ content.is_read_only
+ ),
+ ("[teo] OOO", "default", true),
+ "the surviving copy becomes canonical"
+ );
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ vec![(starts_at.to_rfc3339(), 5, starts_at - Duration::minutes(5))],
+ "the schedule follows the surviving copy's reminders"
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_user_edit_through_the_shared_copy_moves_the_schedule_but_keeps_primary_content(
+ pool: PgPool,
+) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "writer", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // The member drags the event while viewing the shared calendar. Google
+ // confirms the move on that copy; the entity's schedule must follow it
+ // even though the copy is not canonical.
+ let moved_start = starts_at + Duration::hours(2);
+ let mut echo = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ moved_start,
+ );
+ echo.event.sequence = 1;
+ echo.event.updated_at = starts_at + Duration::hours(1);
+ let outcome = repo
+ .upsert_event(CalendarEventWrite::UserMutation(echo))
+ .await
+ .unwrap();
+ assert_eq!(outcome.change, CalendarEventChange::Updated);
+
+ let content = entity_content(&pool, event_id).await;
+ assert_primary_content(&content);
+ let rows = repo
+ .list_occurrences(member, range_around(moved_start), None, 10)
+ .await
+ .unwrap();
+ let (event, occurrence) = rows.first().expect("the moved occurrence lists");
+ assert_eq!(rows.len(), 1);
+ assert_eq!(
+ occurrence.time,
+ EventTime::Timed {
+ starts_at: moved_start,
+ ends_at: moved_start + Duration::hours(1),
+ time_zone: None,
+ }
+ );
+ assert_eq!(
+ event.title, "OOO",
+ "content still comes from the primary copy"
+ );
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ vec![(
+ moved_start.to_rfc3339(),
+ 30,
+ moved_start - Duration::minutes(30)
+ )],
+ "reminders follow the new time with the primary copy's offset"
+ );
+
+ // A plain sync of the shared copy with the same schedule stays a
+ // non-canonical write and leaves everything alone.
+ let mut resync = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ moved_start,
+ );
+ resync.event.sequence = 1;
+ resync.event.updated_at = starts_at + Duration::hours(2);
+ repo.upsert_event_fixture(resync).await.unwrap();
+ assert_primary_content(&entity_content(&pool, event_id).await);
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn canonical_selection_skips_copies_on_deleted_calendars(pool: PgPool) {
+ let member = "macro|[email protected]";
+ insert_user(&pool, member).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = grant_and_provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // The primary calendar disappears while its source row still exists.
+ // Reads already ignore it, so writes must too: the next shared-copy sync
+ // promotes the live copy instead of freezing the entity on the dead one.
+ sqlx::query!(
+ "UPDATE calendars SET is_deleted = true WHERE id = $1",
+ primary_calendar_id,
+ )
+ .execute(&pool)
+ .await
+ .unwrap();
+ let mut resync = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ );
+ resync.event.updated_at += Duration::hours(1);
+ repo.upsert_event_fixture(resync).await.unwrap();
+
+ let content = entity_content(&pool, event_id).await;
+ assert_eq!(
+ (
+ content.title.as_str(),
+ content.event_type.as_str(),
+ content.is_read_only
+ ),
+ ("[teo] OOO", "default", true)
+ );
+ let target = repo
+ .get_event_mutation_target(member, event_id, None)
+ .await
+ .unwrap()
+ .expect("the live copy is the mutation target");
+ assert_eq!(target.calendar_id, shared_calendar_id);
+ let rows = repo
+ .list_occurrences(member, range_around(starts_at), None, 10)
+ .await
+ .unwrap();
+ assert_eq!(rows[0].0.calendar_id, Some(shared_calendar_id));
+ assert_eq!(
+ rows[0]
+ .0
+ .sources
+ .iter()
+ .map(|source| source.calendar_id)
+ .collect::<Vec<_>>(),
+ vec![shared_calendar_id]
+ );
+
+ // Retiring the shared copy now finds no live source and removes the entity
+ // rather than resurrecting the deleted calendar's copy.
+ let retired = repo
+ .remove_google_source(account_id, shared_calendar_id, &format!("provider-{uid}"))
+ .await
+ .unwrap();
+ assert_eq!(
+ retired,
+ vec![RetiredCalendarEvent {
+ event_id,
+ owner_id: member.to_string(),
+ deleted: true,
+ }]
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn an_older_canonical_resync_cannot_undo_a_user_edit_made_through_another_copy(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "writer", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // The member moves the event through the shared calendar; Google stamps
+ // that copy an hour after the primary's last update.
+ let moved_start = starts_at + Duration::hours(2);
+ let mut echo = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ moved_start,
+ );
+ echo.event.sequence = 1;
+ echo.event.updated_at = starts_at + Duration::hours(1);
+ repo.upsert_event(CalendarEventWrite::UserMutation(echo))
+ .await
+ .unwrap();
+
+ // The primary copy syncs a change that is older than the edit and keeps
+ // its own sequence — a description Google recorded before the move. Its
+ // content lands, its stale schedule does not.
+ let mut stale_primary = member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ );
+ stale_primary.event.description = Some("Dentist, then lunch".to_string());
+ stale_primary.event.updated_at = starts_at + Duration::minutes(30);
+ repo.upsert_event_fixture(stale_primary).await.unwrap();
+
+ let rows = repo
+ .list_occurrences(member, range_around(moved_start), None, 10)
+ .await
+ .unwrap();
+ let (event, occurrence) = rows.first().expect("the moved occurrence lists");
+ assert_eq!(rows.len(), 1);
+ assert_eq!(
+ occurrence.time,
+ EventTime::Timed {
+ starts_at: moved_start,
+ ends_at: moved_start + Duration::hours(1),
+ time_zone: None,
+ },
+ "an older canonical state leaves the user's move in place"
+ );
+ assert_eq!(event.description.as_deref(), Some("Dentist, then lunch"));
+ assert_eq!(
+ scheduled_firings(&pool, event_id).await,
+ vec![(
+ moved_start.to_rfc3339(),
+ 30,
+ moved_start - Duration::minutes(30)
+ )]
+ );
+
+ // The primary copy itself changes, advancing its sequence. Its provider
+ // stamp is still older than the edit's, but a change to the canonical copy
+ // owns the schedule again regardless of the clock.
+ let mut fresh_primary = member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ moved_start + Duration::hours(1),
+ );
+ fresh_primary.event.sequence = 1;
+ fresh_primary.event.updated_at = starts_at + Duration::minutes(45);
+ repo.upsert_event_fixture(fresh_primary).await.unwrap();
+ let rows = repo
+ .list_occurrences(member, range_around(moved_start), None, 10)
+ .await
+ .unwrap();
+ assert_eq!(
+ rows[0].1.time,
+ EventTime::Timed {
+ starts_at: moved_start + Duration::hours(1),
+ ends_at: moved_start + Duration::hours(2),
+ time_zone: None,
+ }
+ );
+}
+
+/// The member's own copy with the guests and conference only the primary
+/// carries, so a copy that drops either is caught.
+fn member_primary_meeting(
+ owner_id: &str,
+ link_id: Uuid,
+ provider: (Uuid, Uuid),
+ uid: &str,
+ starts_at: DateTime<Utc>,
+) -> CalendarEventUpsert {
+ let mut upsert = member_primary_upsert(owner_id, link_id, provider, uid, starts_at);
+ upsert.event.event_type = EventType::Default;
+ upsert.event.attendees = vec![reminder_attendee("[email protected]", false, false)];
+ upsert.event.conference_url = Some("https://meet.google.com/abc-defg-hij".to_string());
+ upsert.event.conference_provider = Some(ConferenceProvider::GoogleMeet);
+ upsert
+}
+
+async fn listed_event(
+ repo: &PgCalendarRepository,
+ member: &str,
+ around: DateTime<Utc>,
+) -> (CalendarEvent, CalendarOccurrence) {
+ let rows = repo
+ .list_occurrences(member, range_around(around), None, 10)
+ .await
+ .unwrap();
+ assert_eq!(rows.len(), 1, "one occurrence lists");
+ rows.into_iter().next().unwrap()
+}
+
+fn timed(starts_at: DateTime<Utc>) -> EventTime {
+ EventTime::Timed {
+ starts_at,
+ ends_at: starts_at + Duration::hours(1),
+ time_zone: None,
+ }
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_primary_copy_arriving_after_a_shared_copy_takes_the_schedule(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ // The shared copy seeds the entity with a flattened schedule and a newer
+ // provider stamp. The primary copy arrives afterwards with an older stamp,
+ // guests, a conference, and a different time.
+ let event_id = repo
+ .upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ let primary_start = starts_at + Duration::hours(1);
+ repo.upsert_event_fixture(member_primary_meeting(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ primary_start,
+ ))
+ .await
+ .unwrap();
+
+ let (event, occurrence) = listed_event(&repo, member, primary_start).await;
+ assert_eq!(event.id, event_id);
+ assert_eq!(occurrence.time, timed(primary_start));
+ assert_eq!(event.attendees.len(), 1);
+ assert_eq!(
+ event.conference_url.as_deref(),
+ Some("https://meet.google.com/abc-defg-hij")
+ );
+ assert_eq!(event.calendar_id, Some(primary_calendar_id));
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_user_edit_through_the_shared_copy_keeps_the_primary_guests_and_conference(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "writer", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ repo.upsert_event_fixture(member_primary_meeting(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ let moved_start = starts_at + Duration::hours(2);
+ let mut echo = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ moved_start,
+ );
+ echo.event.sequence = 1;
+ echo.event.updated_at = starts_at + Duration::hours(1);
+ repo.upsert_event(CalendarEventWrite::UserMutation(echo))
+ .await
+ .unwrap();
+
+ let (event, occurrence) = listed_event(&repo, member, moved_start).await;
+ assert_eq!(occurrence.time, timed(moved_start));
+ assert_eq!(
+ event.attendees.len(),
+ 1,
+ "the copy's empty guest list does not replace the primary's"
+ );
+ assert_eq!(
+ event.conference_url.as_deref(),
+ Some("https://meet.google.com/abc-defg-hij")
+ );
+ assert_eq!(event.title, "OOO");
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn echoes_landing_out_of_order_keep_the_newer_schedule(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "writer", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ repo.upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // Two edits race: one through the shared copy stamped T1, one through the
+ // primary stamped T2. Google applied them in that order, but the primary's
+ // echo persists first.
+ let later_start = starts_at + Duration::hours(3);
+ let mut primary_echo = member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ later_start,
+ );
+ primary_echo.event.sequence = 1;
+ primary_echo.event.updated_at = starts_at + Duration::hours(2);
+ repo.upsert_event(CalendarEventWrite::UserMutation(primary_echo))
+ .await
+ .unwrap();
+ let mut shared_echo = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at + Duration::hours(2),
+ );
+ shared_echo.event.sequence = 1;
+ shared_echo.event.updated_at = starts_at + Duration::hours(1);
+ repo.upsert_event(CalendarEventWrite::UserMutation(shared_echo))
+ .await
+ .unwrap();
+
+ let (_, occurrence) = listed_event(&repo, member, later_start).await;
+ assert_eq!(
+ occurrence.time,
+ timed(later_start),
+ "the older echo does not roll the schedule back"
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn the_copy_that_wrote_the_schedule_keeps_writing_it(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "writer", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+
+ // The member moves the shared copy, then the script that maintains that
+ // calendar moves it back. The shared copy wrote the schedule, so its own
+ // later sync follows through, while the primary's content stays.
+ let moved_start = starts_at + Duration::hours(2);
+ let mut echo = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ moved_start,
+ );
+ echo.event.sequence = 1;
+ echo.event.updated_at = starts_at + Duration::hours(1);
+ repo.upsert_event(CalendarEventWrite::UserMutation(echo))
+ .await
+ .unwrap();
+ let mut reset = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ );
+ reset.event.sequence = 1;
+ reset.event.updated_at = starts_at + Duration::hours(2);
+ repo.upsert_event_fixture(reset).await.unwrap();
+
+ let (event, occurrence) = listed_event(&repo, member, starts_at).await;
+ assert_eq!(event.id, event_id);
+ assert_eq!(occurrence.time, timed(starts_at));
+ assert_primary_content(&entity_content(&pool, event_id).await);
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_writable_copy_outranks_a_fresher_reader_copy_without_a_primary(pool: PgPool) {
+ let member = "macro|[email protected]";
+ insert_user(&pool, member).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, _primary_calendar_id) = grant_and_provider_ids(&repo, link_id).await;
+ let secondary_calendar_id = repo
+ .upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "secondary".to_string(),
+ name: "Projects".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("owner".to_string()),
+ is_primary: false,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ },
+ )
+ .await
+ .unwrap();
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let mut own_copy = reminder_upsert(
+ member,
+ link_id,
+ (account_id, secondary_calendar_id),
+ uid,
+ starts_at,
+ EventReminders::default(),
+ );
+ own_copy.event.title = "Planning".to_string();
+ own_copy.event.is_read_only = false;
+ let event_id = repo.upsert_event_fixture(own_copy).await.unwrap();
+ let mut reader_copy = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ );
+ reader_copy.event.title = "[teo] Planning".to_string();
+ repo.upsert_event_fixture(reader_copy).await.unwrap();
+
+ let content = entity_content(&pool, event_id).await;
+ assert_eq!(content.title, "Planning");
+ assert!(!content.is_read_only, "the writable copy is canonical");
+ let target = repo
+ .get_event_mutation_target(member, event_id, None)
+ .await
+ .unwrap()
+ .expect("owner sees the mutation target");
+ assert_eq!(target.calendar_id, secondary_calendar_id);
+ assert!(!target.is_read_only);
+ let (event, _) = listed_event(&repo, member, starts_at).await;
+ assert_eq!(event.calendar_id, Some(secondary_calendar_id));
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_writable_copy_outranks_a_fresher_copy_whose_calendar_role_is_unknown(pool: PgPool) {
+ let member = "macro|[email protected]";
+ insert_user(&pool, member).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, _primary_calendar_id) = grant_and_provider_ids(&repo, link_id).await;
+ let secondary_calendar_id = repo
+ .upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "secondary".to_string(),
+ name: "Projects".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("owner".to_string()),
+ is_primary: false,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ },
+ )
+ .await
+ .unwrap();
+ let unknown_role_calendar_id = repo
+ .upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "[email protected]".to_string(),
+ name: "Macro Vacation".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: None,
+ is_primary: false,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ },
+ )
+ .await
+ .unwrap();
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let mut own_copy = reminder_upsert(
+ member,
+ link_id,
+ (account_id, secondary_calendar_id),
+ uid,
+ starts_at,
+ EventReminders::default(),
+ );
+ own_copy.event.title = "Planning".to_string();
+ own_copy.event.is_read_only = false;
+ let event_id = repo.upsert_event_fixture(own_copy).await.unwrap();
+ let mut unknown_role_copy = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, unknown_role_calendar_id),
+ uid,
+ starts_at,
+ );
+ unknown_role_copy.event.title = "[teo] Planning".to_string();
+ repo.upsert_event_fixture(unknown_role_copy).await.unwrap();
+
+ let content = entity_content(&pool, event_id).await;
+ assert_eq!(content.title, "Planning");
+ assert!(!content.is_read_only, "the writable copy is canonical");
+ let target = repo
+ .get_event_mutation_target(member, event_id, None)
+ .await
+ .unwrap()
+ .expect("owner sees the mutation target");
+ assert_eq!(target.calendar_id, secondary_calendar_id);
+ let (event, _) = listed_event(&repo, member, starts_at).await;
+ assert_eq!(event.calendar_id, Some(secondary_calendar_id));
+ assert_eq!(
+ event
+ .sources
+ .iter()
+ .map(|copy| copy.calendar_id)
+ .collect::<Vec<_>>(),
+ vec![secondary_calendar_id, unknown_role_calendar_id]
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_calendar_role_change_moves_the_entity_to_the_new_canonical_copy_on_reconcile(
+ pool: PgPool,
+) {
+ let member = "macro|[email protected]";
+ insert_user(&pool, member).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let enabled = repo
+ .apply_google_grant(
+ link_id,
+ complete_grant(),
+ CalendarGrantIntent::CalendarRequested,
+ )
+ .await
+ .unwrap();
+ let google_job = enabled
+ .jobs
+ .into_iter()
+ .find(|job| job.kind == CalendarBackfillKind::GoogleCalendar)
+ .unwrap();
+ let key = CalendarBackfillJobKey {
+ job_id: google_job.id,
+ email_link_id: link_id,
+ };
+ let CalendarBackfillClaim::Claimed { lease_token, .. } =
+ repo.claim_google_backfill(key).await.unwrap()
+ else {
+ panic!("Google job should be claimable");
+ };
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let secondary_calendar_id = repo
+ .upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "secondary".to_string(),
+ name: "Projects".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("owner".to_string()),
+ is_primary: false,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ },
+ )
+ .await
+ .unwrap();
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let dropped_calendar_id = repo
+ .upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "[email protected]".to_string(),
+ name: "Team".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("reader".to_string()),
+ is_primary: false,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ },
+ )
+ .await
+ .unwrap();
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let mut own_copy = reminder_upsert(
+ member,
+ link_id,
+ (account_id, secondary_calendar_id),
+ uid,
+ starts_at,
+ EventReminders::default(),
+ );
+ own_copy.event.title = "Planning".to_string();
+ own_copy.event.is_read_only = false;
+ let event_id = repo.upsert_event_fixture(own_copy).await.unwrap();
+ let mut reader_copy = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ );
+ reader_copy.event.title = "[teo] Planning".to_string();
+ repo.upsert_event_fixture(reader_copy).await.unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, dropped_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ assert_eq!(entity_content(&pool, event_id).await.title, "Planning");
+
+ sqlx::query!(
+ "UPDATE calendars SET access_role = 'writer' WHERE id = $1",
+ shared_calendar_id,
+ )
+ .execute(&pool)
+ .await
+ .unwrap();
+ let announced = repo
+ .reconcile_google_calendar_list(
+ key,
+ lease_token,
+ account_id,
+ vec![
+ primary_calendar_id,
+ secondary_calendar_id,
+ shared_calendar_id,
+ ],
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ announced
+ .iter()
+ .map(|outcome| (outcome.event_id, outcome.deleted))
+ .collect::<Vec<_>>(),
+ vec![(event_id, false)],
+ "losing a copy and unlocking another announce the event once"
+ );
+
+ let content = entity_content(&pool, event_id).await;
+ assert_eq!(
+ content.title, "[teo] Planning",
+ "the fresher copy is canonical once its calendar is writable"
+ );
+ assert!(
+ !content.is_read_only,
+ "the copy's read-only flag follows the calendar's new role"
+ );
+ let mirrors_canonical = sqlx::query_scalar!(
+ r#"
+ SELECT content_source_id = calendar_event_canonical_source_id(id) AS "mirrors!"
+ FROM calendar_events
+ WHERE id = $1
+ "#,
+ event_id,
+ )
+ .fetch_one(&pool)
+ .await
+ .unwrap();
+ assert!(mirrors_canonical);
+ let target = repo
+ .get_event_mutation_target(member, event_id, None)
+ .await
+ .unwrap()
+ .expect("owner sees the mutation target");
+ assert_eq!(target.calendar_id, shared_calendar_id);
+ assert!(!target.is_read_only);
+ let (event, _) = listed_event(&repo, member, starts_at).await;
+ assert_eq!(event.calendar_id, Some(shared_calendar_id));
+ assert_eq!(
+ event
+ .sources
+ .iter()
+ .map(|copy| (copy.calendar_id, copy.is_read_only))
+ .collect::<Vec<_>>(),
+ vec![(shared_calendar_id, false), (secondary_calendar_id, false)]
+ );
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_calendar_role_change_refreshes_the_read_only_flag_of_its_only_copy(pool: PgPool) {
+ let member = "macro|[email protected]";
+ insert_user(&pool, member).await;
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let enabled = repo
+ .apply_google_grant(
+ link_id,
+ complete_grant(),
+ CalendarGrantIntent::CalendarRequested,
+ )
+ .await
+ .unwrap();
+ let google_job = enabled
+ .jobs
+ .into_iter()
+ .find(|job| job.kind == CalendarBackfillKind::GoogleCalendar)
+ .unwrap();
+ let key = CalendarBackfillJobKey {
+ job_id: google_job.id,
+ email_link_id: link_id,
+ };
+ let CalendarBackfillClaim::Claimed { lease_token, .. } =
+ repo.claim_google_backfill(key).await.unwrap()
+ else {
+ panic!("Google job should be claimable");
+ };
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "reader", &[]).await;
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+ let event_id = repo
+ .upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ assert!(entity_content(&pool, event_id).await.is_read_only);
+
+ sqlx::query!(
+ "UPDATE calendars SET access_role = 'writer' WHERE id = $1",
+ shared_calendar_id,
+ )
+ .execute(&pool)
+ .await
+ .unwrap();
+ let announced = repo
+ .reconcile_google_calendar_list(
+ key,
+ lease_token,
+ account_id,
+ vec![primary_calendar_id, shared_calendar_id],
+ )
+ .await
+ .unwrap();
+
+ assert!(!entity_content(&pool, event_id).await.is_read_only);
+ assert_eq!(
+ announced
+ .iter()
+ .map(|outcome| (outcome.event_id, outcome.deleted))
+ .collect::<Vec<_>>(),
+ vec![(event_id, false)],
+ "the unlocked event announces itself so search and clients refresh"
+ );
+ let target = repo
+ .get_event_mutation_target(member, event_id, None)
+ .await
+ .unwrap()
+ .expect("owner sees the mutation target");
+ assert_eq!(target.calendar_id, shared_calendar_id);
+ assert!(!target.is_read_only);
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn retiring_an_unrelated_copy_keeps_a_fresher_schedule_written_through_another(pool: PgPool) {
+ let member = "macro|[email protected]";
+ let link_id = insert_link(&pool, member).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account_id, primary_calendar_id) = provider_ids(&repo, link_id).await;
+ let shared_calendar_id = insert_shared_calendar(&repo, account_id, "writer", &[]).await;
+ let third_calendar_id = repo
+ .upsert_calendar_fixture(
+ account_id,
+ ProviderCalendar {
+ provider_calendar_id: "[email protected]".to_string(),
+ name: "Team".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("reader".to_string()),
+ is_primary: false,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ },
+ )
+ .await
+ .unwrap();
+ let uid = "[email protected]";
+ let starts_at = (Utc::now() + Duration::hours(3)).trunc_subsecs(0);
+
+ let event_id = repo
+ .upsert_event_fixture(member_primary_upsert(
+ member,
+ link_id,
+ (account_id, primary_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ repo.upsert_event_fixture(shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ starts_at,
+ ))
+ .await
+ .unwrap();
+ let mut third = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, third_calendar_id),
+ uid,
+ starts_at,
+ );
+ third.source = CalendarEventSource::Google(GoogleEventSource {
+ email_link_id: link_id,
+ account_id,
+ calendar_id: third_calendar_id,
+ provider_event_id: format!("third-{uid}"),
+ provider_recurring_event_id: None,
+ provider_etag: None,
+ raw_payload: serde_json::json!({}),
+ });
+ repo.upsert_event_fixture(third).await.unwrap();
+
+ let moved_start = starts_at + Duration::hours(2);
+ let mut echo = shared_copy_upsert(
+ member,
+ link_id,
+ (account_id, shared_calendar_id),
+ uid,
+ moved_start,
+ );
+ echo.event.sequence = 1;
+ echo.event.updated_at = starts_at + Duration::hours(1);
+ repo.upsert_event(CalendarEventWrite::UserMutation(echo))
+ .await
+ .unwrap();
+
+ // Retiring the third copy re-derives the entity from the primary. The
+ // shared copy that wrote the schedule survives with a fresher stamp, so
+ // the move stays while the content is the primary's.
+ repo.remove_google_source(account_id, third_calendar_id, &format!("third-{uid}"))
+ .await
+ .unwrap();
+ let (event, occurrence) = listed_event(&repo, member, moved_start).await;
+ assert_eq!(event.id, event_id);
+ assert_eq!(occurrence.time, timed(moved_start));
+ assert_primary_content(&entity_content(&pool, event_id).await);
+}
diff --git a/crates/macro_db_client/migrations/20260904164106_calendar_event_source_content.sql b/crates/macro_db_client/migrations/20260904164106_calendar_event_source_content.sql
new file mode 100644
index 0000000000..6caaf816e6
--- /dev/null
+++ b/crates/macro_db_client/migrations/20260904164106_calendar_event_source_content.sql
@@ -0,0 +1,225 @@
+-- Per-copy event content moves onto calendar_event_sources.
+--
+-- Google keeps several fields per calendar copy of one event (summary,
+-- description, location, eventType, visibility, transparency, reminders,
+-- creator, and the calendar's access role), so two sources of one entity are
+-- not interchangeable. The entity row keeps identity, time, recurrence,
+-- organizer, attendees, and conference, plus a denormalized copy of its
+-- canonical source's content — the primary calendar's copy when the account
+-- syncs one, else the freshest remaining source. Reads that need another
+-- copy's content take it from the source row.
+
+ALTER TABLE calendar_event_sources
+ ADD COLUMN title text NOT NULL DEFAULT '',
+ ADD COLUMN description text,
+ ADD COLUMN location text,
+ ADD COLUMN event_type text NOT NULL DEFAULT 'default'
+ CHECK (event_type IN (
+ 'default', 'out_of_office', 'focus_time', 'working_location',
+ 'birthday', 'from_gmail'
+ )),
+ ADD COLUMN visibility text NOT NULL DEFAULT 'default'
+ CHECK (visibility IN ('default', 'public', 'private', 'confidential')),
+ ADD COLUMN transparency text NOT NULL DEFAULT 'opaque'
+ CHECK (transparency IN ('opaque', 'transparent')),
+ ADD COLUMN is_read_only boolean NOT NULL DEFAULT false,
+ ADD COLUMN reminders_use_default boolean NOT NULL DEFAULT true,
+ ADD COLUMN reminder_overrides jsonb NOT NULL DEFAULT '[]'::jsonb,
+ ADD COLUMN creator_email text,
+ ADD COLUMN creator_name text;
+
+-- Ranks one event's copies and returns the canonical one: the primary
+-- calendar's copy, else a copy the grant can write, else the freshest, on a
+-- live calendar of an enabled account. Every ranking site calls this so the
+-- entity content, the mutation target, the reminder schedule, and the
+-- listing order agree on which copy is canonical.
+CREATE FUNCTION calendar_event_canonical_source_id(target_event_id uuid)
+RETURNS uuid
+LANGUAGE sql
+STABLE
+AS $$
+ SELECT source.id
+ FROM calendar_event_sources source
+ JOIN calendars calendar ON calendar.id = source.calendar_id
+ JOIN calendar_accounts account ON account.id = source.account_id
+ WHERE source.event_id = target_event_id
+ AND NOT calendar.is_deleted
+ AND account.sync_status <> 'disabled'
+ ORDER BY
+ calendar.is_primary DESC,
+ (calendar.access_role IN ('owner', 'writer')) DESC NULLS LAST,
+ source.source_sequence DESC,
+ source.source_updated_at DESC,
+ source.id DESC
+ LIMIT 1
+$$;
+
+-- Which copy last wrote the entity's schedule (status, time, recurrence,
+-- occurrences, and for the canonical copy also attendees, organizer, and
+-- conference) and that write's provider update stamp. The canonical copy
+-- takes the schedule when it is new to Macro, advanced its own sequence, or
+-- is at least this fresh, a user edit through another copy lands when it is
+-- at least this fresh, and the writing copy keeps writing it until then.
+-- Retiring the writing copy hands the schedule back to the canonical one.
+-- content_source_id names the copy whose content the entity mirrors, so a
+-- ranking change that happens without a source write (a calendar's role or
+-- primary flag changing) can be detected and the entity re-projected.
+ALTER TABLE calendar_events
+ ADD COLUMN content_source_id uuid
+ REFERENCES calendar_event_sources(id) ON DELETE SET NULL,
+ ADD COLUMN schedule_source_id uuid
+ REFERENCES calendar_event_sources(id) ON DELETE SET NULL,
+ ADD COLUMN schedule_updated_at timestamptz NOT NULL DEFAULT now();
+
+UPDATE calendar_events SET schedule_updated_at = canonical_source_updated_at;
+
+-- Every source row already stores its own normalized projection, so its
+-- content backfills from there rather than from the entity a later copy may
+-- have overwritten. Fields the projection omits at their default read as
+-- that default.
+UPDATE calendar_event_sources
+SET title = COALESCE(normalized_payload -> 'event' ->> 'title', ''),
+ description = normalized_payload -> 'event' ->> 'description',
+ location = normalized_payload -> 'event' ->> 'location',
+ event_type = CASE
+ WHEN normalized_payload -> 'event' ->> 'eventType' IN (
+ 'default', 'out_of_office', 'focus_time', 'working_location',
+ 'birthday', 'from_gmail'
+ ) THEN normalized_payload -> 'event' ->> 'eventType'
+ ELSE 'default'
+ END,
+ visibility = CASE
+ WHEN normalized_payload -> 'event' ->> 'visibility' IN (
+ 'default', 'public', 'private', 'confidential'
+ ) THEN normalized_payload -> 'event' ->> 'visibility'
+ ELSE 'default'
+ END,
+ transparency = CASE
+ WHEN normalized_payload -> 'event' ->> 'transparency' = 'transparent'
+ THEN 'transparent'
+ ELSE 'opaque'
+ END,
+ is_read_only = COALESCE(
+ (normalized_payload -> 'event' ->> 'isReadOnly')::boolean, false
+ ),
+ reminders_use_default = COALESCE(
+ (normalized_payload -> 'event' -> 'reminders' ->> 'useDefault')::boolean, true
+ ),
+ reminder_overrides = COALESCE(
+ normalized_payload -> 'event' -> 'reminders' -> 'overrides', '[]'::jsonb
+ ),
+ creator_email = normalized_payload -> 'event' ->> 'creatorEmail',
+ creator_name = normalized_payload -> 'event' ->> 'creatorName';
+
+-- Entities with more than one source hold whichever copy synced last. Rewrite
+-- them from the canonical copy so the primary copy's type, access,
+-- availability, visibility, and reminders are restored without waiting for a
+-- resync.
+WITH multi_source AS (
+ SELECT event_id
+ FROM calendar_event_sources
+ GROUP BY event_id
+ HAVING count(*) > 1
+)
+UPDATE calendar_events event
+SET title = canonical.title,
+ description = canonical.description,
+ location = canonical.location,
+ event_type = canonical.event_type,
+ visibility = canonical.visibility,
+ transparency = canonical.transparency,
+ is_read_only = canonical.is_read_only,
+ reminders_use_default = canonical.reminders_use_default,
+ reminder_overrides = canonical.reminder_overrides,
+ creator_email = canonical.creator_email,
+ creator_name = canonical.creator_name,
+ sequence = canonical.source_sequence
+FROM calendar_event_sources canonical
+JOIN multi_source ON multi_source.event_id = canonical.event_id
+WHERE event.id = canonical.event_id
+ AND canonical.id = calendar_event_canonical_source_id(event.id);
+
+-- Every entity's content and schedule are attributed to its canonical copy.
+UPDATE calendar_events event
+SET content_source_id = canonical.id,
+ schedule_source_id = canonical.id,
+ schedule_updated_at = canonical.source_updated_at
+FROM calendar_event_sources canonical
+WHERE canonical.id = calendar_event_canonical_source_id(event.id);
+
+-- The firing schedule of a rewritten entity may have been built from the
+-- other copy's reminders. Rebuild it from the restored configuration and the
+-- canonical calendar's defaults, mirroring the service's rebuild: status
+-- events never resolve calendar defaults, all-day starts anchor at midnight
+-- in the calendar's zone, and firings older than a day are dropped.
+DELETE FROM calendar_event_reminder_firings firing
+USING (
+ SELECT event_id
+ FROM calendar_event_sources
+ GROUP BY event_id
+ HAVING count(*) > 1
+) multi_source
+WHERE firing.event_id = multi_source.event_id;
+
+WITH multi_source AS (
+ SELECT event_id
+ FROM calendar_event_sources
+ GROUP BY event_id
+ HAVING count(*) > 1
+),
+canonical_calendar AS (
+ SELECT
+ source.event_id,
+ calendar.default_reminders,
+ CASE
+ WHEN calendar.time_zone IS NOT NULL
+ AND EXISTS (
+ SELECT 1 FROM pg_timezone_names zone WHERE zone.name = calendar.time_zone
+ )
+ THEN calendar.time_zone
+ ELSE 'UTC'
+ END AS anchor_zone
+ FROM calendar_event_sources source
+ JOIN multi_source ON multi_source.event_id = source.event_id
+ JOIN calendars calendar ON calendar.id = source.calendar_id
+ WHERE source.id = calendar_event_canonical_source_id(source.event_id)
+)
+INSERT INTO calendar_event_reminder_firings (
+ event_id, occurrence_key, minutes_before, fire_at
+)
+SELECT DISTINCT
+ occurrence.event_id,
+ occurrence.occurrence_key,
+ offsets.minutes,
+ COALESCE(
+ occurrence.starts_at,
+ occurrence.start_date::timestamp AT TIME ZONE canonical_calendar.anchor_zone
+ ) - make_interval(mins => offsets.minutes)
+FROM canonical_calendar
+JOIN calendar_events event ON event.id = canonical_calendar.event_id
+JOIN calendar_event_occurrences occurrence ON occurrence.event_id = event.id
+CROSS JOIN LATERAL (
+ SELECT (reminder.value ->> 'minutes')::int AS minutes
+ FROM jsonb_array_elements(
+ CASE
+ WHEN event.reminders_use_default
+ AND event.event_type IN ('default', 'from_gmail')
+ THEN canonical_calendar.default_reminders
+ WHEN event.reminders_use_default THEN '[]'::jsonb
+ ELSE event.reminder_overrides
+ END
+ ) AS reminder(value)
+ WHERE reminder.value ->> 'method' = 'popup'
+ AND (reminder.value ->> 'minutes')::int >= 0
+) offsets
+WHERE event.status <> 'cancelled'
+ AND NOT occurrence.is_cancelled
+ AND COALESCE(
+ occurrence.starts_at,
+ occurrence.start_date::timestamp AT TIME ZONE canonical_calendar.anchor_zone
+ ) - make_interval(mins => offsets.minutes) > now() - interval '1 day'
+ON CONFLICT (event_id, occurrence_key, minutes_before) DO NOTHING;
+
+-- The canonical copy's stamp had one reader, the old cross-copy precedence
+-- guard, which the per-copy freshness rules above replace.
+ALTER TABLE calendar_events DROP COLUMN canonical_source_updated_at;
diff --git a/crates/macro_db_client/src/calendar_event/get_event_for_index.rs b/crates/macro_db_client/src/calendar_event/get_event_for_index.rs
index 8b1c9305fb..d62c56e645 100644
--- a/crates/macro_db_client/src/calendar_event/get_event_for_index.rs
+++ b/crates/macro_db_client/src/calendar_event/get_event_for_index.rs
@@ -13,6 +13,9 @@ pub struct CalendarEventForIndex {
pub source_link_id: Uuid,
pub ical_uid: String,
pub title: String,
+ /// Every copy's title, the canonical one included, so a search for a
+ /// shared calendar's bracketed re-import finds the same entity.
+ pub source_titles: Vec<String>,
pub status: String,
pub starts_at: Option<DateTime<Utc>>,
pub ends_at: Option<DateTime<Utc>>,
@@ -58,7 +61,16 @@ pub async fn get_calendar_event_for_index(
WHERE attendee.event_id = event.id
),
'{}'
- ) AS "attendee_emails!"
+ ) AS "attendee_emails!",
+ COALESCE(
+ (
+ SELECT array_agg(DISTINCT source.title ORDER BY source.title)
+ FROM calendar_event_sources source
+ WHERE source.event_id = event.id
+ AND source.title <> ''
+ ),
+ '{}'
+ ) AS "source_titles!"
FROM calendar_events event
WHERE event.id = $1
"#,
@@ -73,6 +85,7 @@ pub async fn get_calendar_event_for_index(
source_link_id: row.source_link_id,
ical_uid: row.ical_uid,
title: row.title,
+ source_titles: row.source_titles,
status: row.status,
starts_at: row.starts_at,
ends_at: row.ends_at,
diff --git a/crates/opensearch_client/src/search/builder.rs b/crates/opensearch_client/src/search/builder.rs
index e74a6bbf63..d20f42a148 100644
--- a/crates/opensearch_client/src/search/builder.rs
+++ b/crates/opensearch_client/src/search/builder.rs
@@ -294,6 +294,11 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {
/// Builds a query targeting the title field (TITLE_KEY)
pub fn build_title_term_query<'a>(&'a self) -> Result<QueryType<'a>> {
+ self.build_field_term_query(T::TITLE_KEY)
+ }
+
+ /// Builds a query matching every term against one text field.
+ pub fn build_field_term_query<'a>(&'a self, field: &'a str) -> Result<QueryType<'a>> {
if self.terms.is_empty() {
return Err(OpensearchClientError::NoTermsProvided);
}
@@ -304,7 +309,7 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {
Ok(generate_terms_must_query(
query_key,
- T::TITLE_KEY,
+ field,
terms,
self.term_combine,
))
diff --git a/crates/opensearch_client/src/search/calendar_events.rs b/crates/opensearch_client/src/search/calendar_events.rs
index 2f03fef32a..d02fb99849 100644
--- a/crates/opensearch_client/src/search/calendar_events.rs
+++ b/crates/opensearch_client/src/search/calendar_events.rs
@@ -18,6 +18,9 @@ impl SearchQueryConfig for CalendarEventSearchConfig {
const ENTITY_INDEX: OpenSearchEntityType = OpenSearchEntityType::CalendarEvents;
}
+/// Index field holding the title of every provider copy of the event.
+const SOURCE_NAMES_KEY: &str = "source_names";
+
/// Query builder for the flat calendar events index.
///
/// One doc per **series master**: recurring instances are query projections
@@ -27,9 +30,11 @@ impl SearchQueryConfig for CalendarEventSearchConfig {
/// enrichment time instead.
///
/// Calendar events carry no indexed content, so every mode matches terms
-/// against `name` alone. Access mirrors the soup predicate: `owner_id ==
-/// caller` or the event's `source_link_id` is one of the caller's delegated
-/// inbox links.
+/// against the titles alone: `name` holds the canonical copy's title and
+/// `source_names` every copy's, so a shared calendar's bracketed re-import
+/// of a member's event is found under either. Access mirrors the soup
+/// predicate: `owner_id == caller` or the event's `source_link_id` is one of
+/// the caller's delegated inbox links.
pub(crate) struct CalendarEventQueryBuilder {
inner: SearchQueryBuilder<CalendarEventSearchConfig>,
link_ids: Vec<String>,
@@ -164,8 +169,13 @@ impl CalendarEventQueryBuilder {
bool_query.filter(nested);
}
- // Title match: every term must match the event title.
- bool_query.must(self.inner.build_title_term_query()?);
+ // Title match: every term must match the canonical title or one
+ // copy's title.
+ let mut titles = BoolQueryBuilder::new();
+ titles.minimum_should_match(1);
+ titles.should(self.inner.build_title_term_query()?);
+ titles.should(self.inner.build_field_term_query(SOURCE_NAMES_KEY)?);
+ bool_query.must(titles.build().into());
Ok(bool_query)
}
diff --git a/crates/opensearch_client/src/search/calendar_events/test.rs b/crates/opensearch_client/src/search/calendar_events/test.rs
index 429b2d2f1d..1c5de0b45c 100644
--- a/crates/opensearch_client/src/search/calendar_events/test.rs
+++ b/crates/opensearch_client/src/search/calendar_events/test.rs
@@ -34,6 +34,23 @@ fn test_build_bool_query_owner_or_delegated_link() -> anyhow::Result<()> {
let must = json["bool"]["must"].as_array().expect("must array");
assert_eq!(must.len(), 1, "one title clause per query: {must:?}");
+ // Either the canonical title or any copy's title satisfies the terms.
+ let titles = &must[0]["bool"];
+ assert_eq!(titles["minimum_should_match"], 1);
+ let fields: Vec<_> = titles["should"]
+ .as_array()
+ .expect("title should array")
+ .iter()
+ .map(|clause| {
+ clause
+ .as_object()
+ .and_then(|object| object.values().next())
+ .and_then(|inner| inner.as_object())
+ .and_then(|inner| inner.keys().next().cloned())
+ .expect("single-field title clause")
+ })
+ .collect();
+ assert_eq!(fields, ["name", "source_names"], "{titles:?}");
Ok(())
}
diff --git a/crates/opensearch_client/src/search/model.rs b/crates/opensearch_client/src/search/model.rs
index 1da8976ce5..304ad11b2c 100644
--- a/crates/opensearch_client/src/search/model.rs
+++ b/crates/opensearch_client/src/search/model.rs
@@ -295,8 +295,11 @@ pub(crate) fn parse_highlight_hit(
Highlight {
user_id,
+ // A calendar event found only through another copy's title has its
+ // match under `source_names`, so that stands in for the name.
name: highlight
.get(keys.title_key)
+ .or_else(|| highlight.get("source_names"))
.and_then(|v| v.first())
.map(|v| v.to_string()),
content: highlight
diff --git a/crates/opensearch_client/src/search/unified.rs b/crates/opensearch_client/src/search/unified.rs
index 8cf4749a79..b7735c22cd 100644
--- a/crates/opensearch_client/src/search/unified.rs
+++ b/crates/opensearch_client/src/search/unified.rs
@@ -819,6 +819,7 @@ fn build_unified_search_request(args: &UnifiedSearchArgs) -> Result<SearchReques
.field("content", em_field().number_of_fragments(1))
.field("document_name", em_field().number_of_fragments(0))
.field("name", em_field().number_of_fragments(0))
+ .field("source_names", em_field().number_of_fragments(0))
.field("subject", em_field().number_of_fragments(0))
.field("sender", em_field().number_of_fragments(0))
.field("sender_name", em_field().number_of_fragments(0))
diff --git a/crates/opensearch_client/src/search/unified/test.rs b/crates/opensearch_client/src/search/unified/test.rs
index 083f03114c..c8e54c805a 100644
--- a/crates/opensearch_client/src/search/unified/test.rs
+++ b/crates/opensearch_client/src/search/unified/test.rs
@@ -530,6 +530,7 @@ fn test_build_unified_search_request_content() -> anyhow::Result<()> {
"content": { "number_of_fragments": 1, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"document_name": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"name": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
+ "source_names": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"subject": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"sender": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"sender_name": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
@@ -856,6 +857,7 @@ fn test_build_unified_search_request_single_index() -> anyhow::Result<()> {
"content": { "number_of_fragments": 1, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"document_name": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"name": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
+ "source_names": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"subject": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"sender": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
"sender_name": { "number_of_fragments": 0, "post_tags": ["</macro_em>"], "pre_tags": ["<macro_em>"], "type": "plain" },
diff --git a/crates/opensearch_client/src/upsert/calendar_event.rs b/crates/opensearch_client/src/upsert/calendar_event.rs
index b17b3dbccc..4b8c1ec27e 100644
--- a/crates/opensearch_client/src/upsert/calendar_event.rs
+++ b/crates/opensearch_client/src/upsert/calendar_event.rs
@@ -22,6 +22,10 @@ pub struct UpsertCalendarEventArgs {
/// other flat index uses for its title.
#[serde(rename = "name")]
pub title: String,
+ /// The title of every provider copy of the event, the canonical one
+ /// included. A shared calendar's re-import of a member's event carries
+ /// its own title, and a search for either must find the entity.
+ pub source_names: Vec<String>,
/// Owner of this per-user event projection
pub owner_id: String,
/// The inbox link the canonical source belongs to. Delegated access is
diff --git a/crates/soup/fixtures/notified_at.sql b/crates/soup/fixtures/notified_at.sql
index c9cac6b2db..3d3c0e8508 100644
--- a/crates/soup/fixtures/notified_at.sql
+++ b/crates/soup/fixtures/notified_at.sql
@@ -100,12 +100,12 @@ VALUES ('44444444-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '55555555-aaaa-aaaa-aaaa-aaaaaaa
-- Notified at T14 but the thread lives in user-2's inbox: must never surface.
('44444444-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '55555555-bbbb-bbbb-bbbb-bbbbbbbbbbbb', TRUE, TRUE, '2024-06-01 09:00:00+00', '2024-06-01 09:00:00+00', '2024-06-01 09:00:00+00');
-INSERT INTO public.calendar_events ("id", "owner_id", "source_link_id", "ical_uid", "title", "starts_at", "ends_at", "canonical_source_kind", "canonical_source_updated_at")
-VALUES ('66666666-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'macro|[email protected]', '55555555-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'e1@test', 'Event E1', '2024-06-02 10:00:00+00', '2024-06-02 11:00:00+00', 'google', '2024-06-01 09:00:00+00'),
+INSERT INTO public.calendar_events ("id", "owner_id", "source_link_id", "ical_uid", "title", "starts_at", "ends_at", "canonical_source_kind")
+VALUES ('66666666-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'macro|[email protected]', '55555555-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'e1@test', 'Event E1', '2024-06-02 10:00:00+00', '2024-06-02 11:00:00+00', 'google'),
-- Notified at T15 but owned by user-2 with no delegation: must never surface.
- ('66666666-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'macro|[email protected]', '55555555-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'e2@test', 'Event E2', '2024-06-02 10:00:00+00', '2024-06-02 11:00:00+00', 'google', '2024-06-01 09:00:00+00'),
+ ('66666666-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'macro|[email protected]', '55555555-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'e2@test', 'Event E2', '2024-06-02 10:00:00+00', '2024-06-02 11:00:00+00', 'google'),
-- user-2's event on the inbox delegated to user-1: visible through the delegation.
- ('66666666-cccc-cccc-cccc-cccccccccccc', 'macro|[email protected]', '55555555-cccc-cccc-cccc-cccccccccccc', 'e3@test', 'Event E3', '2024-06-02 12:00:00+00', '2024-06-02 13:00:00+00', 'google', '2024-06-01 09:00:00+00');
+ ('66666666-cccc-cccc-cccc-cccccccccccc', 'macro|[email protected]', '55555555-cccc-cccc-cccc-cccccccccccc', 'e3@test', 'Event E3', '2024-06-02 12:00:00+00', '2024-06-02 13:00:00+00', 'google');
INSERT INTO public.foreign_entity ("id", "foreign_entity_id", "foreign_entity_source", "metadata", "stored_for_id", "stored_for_auth_entity", "created_at", "updated_at")
VALUES ('77777777-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'org/repo#1', 'github_pull_request', '{}', 'macro|[email protected]', 'user', '2024-06-01 09:00:00+00', '2024-06-01 09:00:00+00'),
diff --git a/crates/soup/src/outbound/pg_soup_repo/calendar_event/test.rs b/crates/soup/src/outbound/pg_soup_repo/calendar_event/test.rs
index db954ca25e..83f4c295ef 100644
--- a/crates/soup/src/outbound/pg_soup_repo/calendar_event/test.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/calendar_event/test.rs
@@ -26,12 +26,11 @@ async fn frecency_fallback_keeps_calendar_events_with_aggregates(
r#"
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
- starts_at, ends_at, canonical_source_kind,
- canonical_source_updated_at
+ starts_at, ends_at, canonical_source_kind
)
VALUES (
$1, $2, $3, '[email protected]', 'Frecency event',
- now(), now() + interval '1 hour', 'google', now()
+ now(), now() + interval '1 hour', 'google'
)
"#,
event_id,
@@ -102,11 +101,11 @@ async fn recency_sort_uses_reminder_delivery_time(pool: PgPool) -> anyhow::Resul
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
starts_at, ends_at, canonical_source_kind,
- canonical_source_updated_at, updated_at, last_reminder_fired_at
+ updated_at, last_reminder_fired_at
)
VALUES (
$1, $2, $3, '[email protected]', 'Reminded event',
- now(), now() + interval '1 hour', 'google', now(),
+ now(), now() + interval '1 hour', 'google',
now() - interval '10 days', now()
)
"#,
@@ -122,11 +121,11 @@ async fn recency_sort_uses_reminder_delivery_time(pool: PgPool) -> anyhow::Resul
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
starts_at, ends_at, canonical_source_kind,
- canonical_source_updated_at, updated_at
+ updated_at
)
VALUES (
$1, $2, $3, '[email protected]', 'Edited event',
- now(), now() + interval '1 hour', 'google', now(),
+ now(), now() + interval '1 hour', 'google',
now() - interval '1 day'
)
"#,
diff --git a/crates/soup/src/outbound/pg_soup_repo/grouping/test.rs b/crates/soup/src/outbound/pg_soup_repo/grouping/test.rs
index ac31a8c616..1bda45619b 100644
--- a/crates/soup/src/outbound/pg_soup_repo/grouping/test.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/grouping/test.rs
@@ -337,12 +337,11 @@ async fn tagged_calendar_event_participates_in_grouped_property_soup(
r#"
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
- starts_at, ends_at, canonical_source_kind, canonical_source_updated_at
+ starts_at, ends_at, canonical_source_kind
)
VALUES (
$1, $2, $3, '[email protected]', 'Grouped calendar event',
- '2026-07-24T14:00:00Z', '2026-07-24T15:00:00Z', 'google',
- '2026-07-24T12:00:00Z'
+ '2026-07-24T14:00:00Z', '2026-07-24T15:00:00Z', 'google'
)
"#,
EVENT_ID,
@@ -432,11 +431,11 @@ async fn grouped_recency_sort_uses_reminder_delivery_time(
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
starts_at, ends_at, canonical_source_kind,
- canonical_source_updated_at, updated_at, last_reminder_fired_at
+ updated_at, last_reminder_fired_at
)
VALUES (
$1, $2, $3, '[email protected]', 'Reminded event',
- now(), now() + interval '1 hour', 'google', now(),
+ now(), now() + interval '1 hour', 'google',
now() - interval '10 days', now()
)
"#,
@@ -451,11 +450,11 @@ async fn grouped_recency_sort_uses_reminder_delivery_time(
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
starts_at, ends_at, canonical_source_kind,
- canonical_source_updated_at, updated_at
+ updated_at
)
VALUES (
$1, $2, $3, '[email protected]', 'Edited event',
- now(), now() + interval '1 hour', 'google', now(),
+ now(), now() + interval '1 hour', 'google',
now() - interval '1 day'
)
"#,
@@ -664,12 +663,11 @@ async fn grouped_soup_renders_bind_bearing_calendar_literals(
r#"
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title, organizer_email,
- starts_at, ends_at, canonical_source_kind, canonical_source_updated_at
+ starts_at, ends_at, canonical_source_kind
)
VALUES (
$1, $2, $3, '[email protected]', 'Bind-bearing event', '[email protected]',
- '2026-07-24T14:00:00Z', '2026-07-24T15:00:00Z', 'google',
- '2026-07-24T12:00:00Z'
+ '2026-07-24T14:00:00Z', '2026-07-24T15:00:00Z', 'google'
)
"#,
EVENT_ID,
@@ -773,12 +771,11 @@ async fn grouped_soup_filters_calendar_events_by_notification_done(
r#"
INSERT INTO calendar_events (
id, owner_id, source_link_id, ical_uid, title,
- starts_at, ends_at, canonical_source_kind, canonical_source_updated_at
+ starts_at, ends_at, canonical_source_kind
)
VALUES (
$1, $2, $3, $4, $5,
- '2026-07-24T14:00:00Z', '2026-07-24T15:00:00Z', 'google',
- '2026-07-24T12:00:00Z'
+ '2026-07-24T14:00:00Z', '2026-07-24T15:00:00Z', 'google'
)
"#,
event_id,
diff --git a/infra/stacks/opensearch/helpers/scripts/create_indices.ts b/infra/stacks/opensearch/helpers/scripts/create_indices.ts
index e590831578..a76d70ff58 100644
--- a/infra/stacks/opensearch/helpers/scripts/create_indices.ts
+++ b/infra/stacks/opensearch/helpers/scripts/create_indices.ts
@@ -662,6 +662,13 @@ const CALENDAR_EVENTS_BODY = {
override_names: {
type: 'text',
},
+ // The title of every provider copy of the event, the canonical one
+ // included. A shared calendar's re-import of a member's event carries
+ // its own title (`[teo] OOO` beside the member's `OOO`), and the
+ // query matches either field so both spellings find the one entity.
+ source_names: {
+ type: 'text',
+ },
owner_id: {
type: 'keyword',
index: true,
diff --git a/packages/sdk/generated/email/index.ts b/packages/sdk/generated/email/index.ts
index 23153613d0..e4b2d00eb1 100644
--- a/packages/sdk/generated/email/index.ts
+++ b/packages/sdk/generated/email/index.ts
@@ -1,4 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export { type Options, Sdk } from './sdk.gen';
-export type { AccessLevel, AddDraftAttachmentData, AddDraftAttachmentError, AddDraftAttachmentErrors, AddDraftAttachmentRequest, AddDraftAttachmentResponse, AddDraftAttachmentResponse2, AddDraftAttachmentResponses, AddForwardedAttachmentData, AddForwardedAttachmentError, AddForwardedAttachmentErrors, AddForwardedAttachmentRequest, AddForwardedAttachmentResponse, AddForwardedAttachmentResponse2, AddForwardedAttachmentResponses, AddRemoveLabelData, AddRemoveLabelError, AddRemoveLabelErrors, AddRemoveLabelResponse, AddRemoveLabelResponses, AddRemoveThreadLabelData, AddRemoveThreadLabelError, AddRemoveThreadLabelErrors, AddRemoveThreadLabelResponse, AddRemoveThreadLabelResponses, ApiAttachment, ApiAttachmentDraft, ApiAttachmentForwarded, ApiContact, ApiContactInfo, ApiDraftContactInfo, ApiDraftInput, ApiDraftOutput, ApiEmailFilter, ApiLabel, ApiLabelListVisibility, ApiLabelType, ApiMessage, ApiMessageAttachment, ApiMessageLabel, ApiMessageListVisibility, ApiPaginatedThreadCursor, ApiSortMethod, ApiThread, ApiThreadPreviewCursor, ApiThreadPreviewCursorInner, ArchiveThreadData, ArchiveThreadError, ArchiveThreadErrors, ArchiveThreadRequest, ArchiveThreadResponse, ArchiveThreadResponses, Attachment, AttachmentDraft, AttachmentForwarded, AttendeeResponseStatus, BackfillJob, BackfillJobStatus, BackfillStatus, BlockSenderData, BlockSenderError, BlockSenderErrors, BlockSenderRequest, BlockSenderResponses, CalendarAttendee, CalendarAttendeeInputBody, CalendarDeletionScopeParam, CalendarEvent, CalendarMutationApiError, CalendarMutationErrorCode, CalendarRsvpScopeParam, CalendarUpdateScopeParam, CancelBackfillGmailData, CancelBackfillGmailError, CancelBackfillGmailErrors, CancelBackfillGmailResponse, CancelBackfillGmailResponses, CancelBackfillParams, ClientOptions, ConferenceChange, ConferenceProvider, Contact, ContactInfo, ContactInfoLegacy, ContactInfoWithInteraction, CreateCalendarEventData, CreateCalendarEventError, CreateCalendarEventErrors, CreateCalendarEventRequest, CreateCalendarEventResponse, CreateCalendarEventResponses, CreateDraftData, CreateDraftError, CreateDraftErrors, CreateDraftRequest, CreateDraftResponse, CreateDraftResponse2, CreateDraftResponses, CreateLabelData, CreateLabelError, CreateLabelErrors, CreateLabelRequest, CreateLabelResponse, CreateLabelResponse2, CreateLabelResponses, DeleteCalendarEventData, DeleteCalendarEventError, DeleteCalendarEventErrors, DeleteCalendarEventResponse, DeleteCalendarEventResponses, DeleteDraftData, DeleteDraftError, DeleteDraftErrors, DeleteDraftResponse, DeleteDraftResponses, DeleteEmailFilterData, DeleteEmailFilterError, DeleteEmailFilterErrors, DeleteEmailFilterResponse, DeleteEmailFilterResponses, DeleteLabelData, DeleteLabelError, DeleteLabelErrors, DeleteLabelResponse, DeleteLabelResponses, DeleteLinkData, DeleteLinkError, DeleteLinkErrors, DeleteLinkResponse, DeleteLinkResponses, DeleteScheduledDraftData, DeleteScheduledDraftError, DeleteScheduledDraftErrors, DeleteScheduledDraftResponse, DeleteScheduledDraftResponses, DisableLinkCalendarData, DisableLinkCalendarError, DisableLinkCalendarErrors, DisableLinkCalendarResponse, DisableLinkCalendarResponses, DisableSyncData, DisableSyncError, DisableSyncErrors, DisableSyncResponse, DisableSyncResponses, EmptyResponse, ErrorResponse, EventReminderOverride, EventReminders, EventStatus, EventTime, EventTransparency, EventType, EventVisibility, GetActiveBackfillJobResponse, GetAttachmentData, GetAttachmentDocumentIdData, GetAttachmentDocumentIdError, GetAttachmentDocumentIdErrors, GetAttachmentDocumentIdResponse, GetAttachmentDocumentIdResponse2, GetAttachmentDocumentIdResponses, GetAttachmentError, GetAttachmentErrors, GetAttachmentResponse, GetAttachmentResponse2, GetAttachmentResponses, GetBackfillGmailActiveData, GetBackfillGmailActiveError, GetBackfillGmailActiveErrors, GetBackfillGmailActiveResponse, GetBackfillGmailActiveResponses, GetBackfillGmailData, GetBackfillGmailError, GetBackfillGmailErrors, GetBackfillGmailResponse, GetBackfillGmailResponses, GetBackfillJobResponse, GetMessageData, GetMessageError, GetMessageErrors, GetMessageResponse, GetMessageResponses, GetMessagesBatchData, GetMessagesBatchError, GetMessagesBatchErrors, GetMessagesBatchResponse, GetMessagesBatchResponses, GetPreviewsCursorParams, GetScheduledMessagesData, GetScheduledMessagesError, GetScheduledMessagesErrors, GetScheduledMessagesResponse, GetScheduledMessagesResponses, GetScheduledResponse, GetThreadData, GetThreadError, GetThreadErrors, GetThreadMessagesHandlerData, GetThreadMessagesHandlerError, GetThreadMessagesHandlerErrors, GetThreadMessagesHandlerResponse, GetThreadMessagesHandlerResponses, GetThreadResponse, GetThreadResponse2, GetThreadResponses, HealthCheckLinksData, HealthCheckLinksError, HealthCheckLinksErrors, HealthCheckLinksResponse, HealthCheckLinksResponses, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitErrorCodeResponse, InitResponse, InitUserData, InitUserError, InitUserErrors, InitUserResponse, InitUserResponses, Label, LabelInfo, LabelListVisibility, LabelType, Link, ListBackfillGmailData, ListBackfillGmailError, ListBackfillGmailErrors, ListBackfillGmailResponse, ListBackfillGmailResponses, ListBackfillJobsResponse, ListBlockedResponse, ListBlockedSendersData, ListBlockedSendersError, ListBlockedSendersErrors, ListBlockedSendersResponse, ListBlockedSendersResponses, ListCalendarsData, ListCalendarsError, ListCalendarsErrors, ListCalendarsResponse, ListCalendarsResponse2, ListCalendarsResponses, ListContactsData, ListContactsError, ListContactsErrors, ListContactsResponse, ListContactsResponse2, ListContactsResponses, ListEmailFiltersData, ListEmailFiltersError, ListEmailFiltersErrors, ListEmailFiltersResponse, ListEmailFiltersResponse2, ListEmailFiltersResponses, ListLabelsData, ListLabelsError, ListLabelsErrors, ListLabelsResponse, ListLabelsResponse2, ListLabelsResponses, ListLinksData, ListLinksError, ListLinksErrors, ListLinksResponse, ListLinksResponse2, ListLinksResponses, Message, MessageListVisibility, OutOfOfficeAutoDeclineMode, OutOfOfficeProperties, ParsedMessage, PatchSettingsData, PatchSettingsError, PatchSettingsErrors, PatchSettingsRequest, PatchSettingsResponse, PatchSettingsResponse2, PatchSettingsResponses, PreviewsInboxCursorData, PreviewsInboxCursorError, PreviewsInboxCursorErrors, PreviewsInboxCursorResponse, PreviewsInboxCursorResponses, PreviewView, PreviewViewStandardLabel, RefreshCalendarEvent, RefreshEmailEvent, RemoveDraftAttachmentData, RemoveDraftAttachmentError, RemoveDraftAttachmentErrors, RemoveDraftAttachmentResponse, RemoveDraftAttachmentResponses, RemoveForwardedAttachmentData, RemoveForwardedAttachmentError, RemoveForwardedAttachmentErrors, RemoveForwardedAttachmentResponse, RemoveForwardedAttachmentResponses, ResyncLinkData, ResyncLinkError, ResyncLinkErrors, ResyncLinkResponse, ResyncLinkResponses, ResyncResponse, RsvpCalendarEventData, RsvpCalendarEventError, RsvpCalendarEventErrors, RsvpCalendarEventRequest, RsvpCalendarEventResponse, RsvpCalendarEventResponses, SendMessageData, SendMessageError, SendMessageErrors, SendMessageRequest, SendMessageResponse, SendMessageResponse2, SendMessageResponses, Settings, SharedInboxConflictResponse, SyncStatus, Thread, ThreadList, ThreadPreviewCursor, ThreadSeenData, ThreadSeenError, ThreadSeenErrors, ThreadSeenResponse, ThreadSeenResponses, ThreadSummary, UnblockSenderData, UnblockSenderError, UnblockSenderErrors, UnblockSenderRequest, UnblockSenderResponse, UnblockSenderResponses, UnresolvedSignatureImagesError, UpdateCalendarEventData, UpdateCalendarEventError, UpdateCalendarEventErrors, UpdateCalendarEventRequest, UpdateCalendarEventResponse, UpdateCalendarEventResponses, UpdateLabelBatchRequest, UpdateLabelBatchResponse, UpdateThreadLabelRequest, UpdateThreadLabelsResponse, UpdateThreadProjectData, UpdateThreadProjectError, UpdateThreadProjectErrors, UpdateThreadProjectRequest, UpdateThreadProjectResponse, UpdateThreadProjectResponse2, UpdateThreadProjectResponses, UpsertEmailFilterData, UpsertEmailFilterError, UpsertEmailFilterErrors, UpsertEmailFilterRequest, UpsertEmailFilterResponse, UpsertEmailFilterResponse2, UpsertEmailFilterResponses, UpsertScheduledMessageData, UpsertScheduledMessageError, UpsertScheduledMessageErrors, UpsertScheduledMessageResponse, UpsertScheduledMessageResponses, UpsertScheduledRequest, UpsertScheduledResponse, UserProvider, Value, VisibleCalendar } from './types.gen';
+export type { AccessLevel, AddDraftAttachmentData, AddDraftAttachmentError, AddDraftAttachmentErrors, AddDraftAttachmentRequest, AddDraftAttachmentResponse, AddDraftAttachmentResponse2, AddDraftAttachmentResponses, AddForwardedAttachmentData, AddForwardedAttachmentError, AddForwardedAttachmentErrors, AddForwardedAttachmentRequest, AddForwardedAttachmentResponse, AddForwardedAttachmentResponse2, AddForwardedAttachmentResponses, AddRemoveLabelData, AddRemoveLabelError, AddRemoveLabelErrors, AddRemoveLabelResponse, AddRemoveLabelResponses, AddRemoveThreadLabelData, AddRemoveThreadLabelError, AddRemoveThreadLabelErrors, AddRemoveThreadLabelResponse, AddRemoveThreadLabelResponses, ApiAttachment, ApiAttachmentDraft, ApiAttachmentForwarded, ApiContact, ApiContactInfo, ApiDraftContactInfo, ApiDraftInput, ApiDraftOutput, ApiEmailFilter, ApiLabel, ApiLabelListVisibility, ApiLabelType, ApiMessage, ApiMessageAttachment, ApiMessageLabel, ApiMessageListVisibility, ApiPaginatedThreadCursor, ApiSortMethod, ApiThread, ApiThreadPreviewCursor, ApiThreadPreviewCursorInner, ArchiveThreadData, ArchiveThreadError, ArchiveThreadErrors, ArchiveThreadRequest, ArchiveThreadResponse, ArchiveThreadResponses, Attachment, AttachmentDraft, AttachmentForwarded, AttendeeResponseStatus, BackfillJob, BackfillJobStatus, BackfillStatus, BlockSenderData, BlockSenderError, BlockSenderErrors, BlockSenderRequest, BlockSenderResponses, CalendarAttendee, CalendarAttendeeInputBody, CalendarDeletionScopeParam, CalendarEvent, CalendarEventSourceContent, CalendarMutationApiError, CalendarMutationErrorCode, CalendarRsvpScopeParam, CalendarUpdateScopeParam, CancelBackfillGmailData, CancelBackfillGmailError, CancelBackfillGmailErrors, CancelBackfillGmailResponse, CancelBackfillGmailResponses, CancelBackfillParams, ClientOptions, ConferenceChange, ConferenceProvider, Contact, ContactInfo, ContactInfoLegacy, ContactInfoWithInteraction, CreateCalendarEventData, CreateCalendarEventError, CreateCalendarEventErrors, CreateCalendarEventRequest, CreateCalendarEventResponse, CreateCalendarEventResponses, CreateDraftData, CreateDraftError, CreateDraftErrors, CreateDraftRequest, CreateDraftResponse, CreateDraftResponse2, CreateDraftResponses, CreateLabelData, CreateLabelError, CreateLabelErrors, CreateLabelRequest, CreateLabelResponse, CreateLabelResponse2, CreateLabelResponses, DeleteCalendarEventData, DeleteCalendarEventError, DeleteCalendarEventErrors, DeleteCalendarEventResponse, DeleteCalendarEventResponses, DeleteDraftData, DeleteDraftError, DeleteDraftErrors, DeleteDraftResponse, DeleteDraftResponses, DeleteEmailFilterData, DeleteEmailFilterError, DeleteEmailFilterErrors, DeleteEmailFilterResponse, DeleteEmailFilterResponses, DeleteLabelData, DeleteLabelError, DeleteLabelErrors, DeleteLabelResponse, DeleteLabelResponses, DeleteLinkData, DeleteLinkError, DeleteLinkErrors, DeleteLinkResponse, DeleteLinkResponses, DeleteScheduledDraftData, DeleteScheduledDraftError, DeleteScheduledDraftErrors, DeleteScheduledDraftResponse, DeleteScheduledDraftResponses, DisableLinkCalendarData, DisableLinkCalendarError, DisableLinkCalendarErrors, DisableLinkCalendarResponse, DisableLinkCalendarResponses, DisableSyncData, DisableSyncError, DisableSyncErrors, DisableSyncResponse, DisableSyncResponses, EmptyResponse, ErrorResponse, EventReminderOverride, EventReminders, EventStatus, EventTime, EventTransparency, EventType, EventVisibility, GetActiveBackfillJobResponse, GetAttachmentData, GetAttachmentDocumentIdData, GetAttachmentDocumentIdError, GetAttachmentDocumentIdErrors, GetAttachmentDocumentIdResponse, GetAttachmentDocumentIdResponse2, GetAttachmentDocumentIdResponses, GetAttachmentError, GetAttachmentErrors, GetAttachmentResponse, GetAttachmentResponse2, GetAttachmentResponses, GetBackfillGmailActiveData, GetBackfillGmailActiveError, GetBackfillGmailActiveErrors, GetBackfillGmailActiveResponse, GetBackfillGmailActiveResponses, GetBackfillGmailData, GetBackfillGmailError, GetBackfillGmailErrors, GetBackfillGmailResponse, GetBackfillGmailResponses, GetBackfillJobResponse, GetMessageData, GetMessageError, GetMessageErrors, GetMessageResponse, GetMessageResponses, GetMessagesBatchData, GetMessagesBatchError, GetMessagesBatchErrors, GetMessagesBatchResponse, GetMessagesBatchResponses, GetPreviewsCursorParams, GetScheduledMessagesData, GetScheduledMessagesError, GetScheduledMessagesErrors, GetScheduledMessagesResponse, GetScheduledMessagesResponses, GetScheduledResponse, GetThreadData, GetThreadError, GetThreadErrors, GetThreadMessagesHandlerData, GetThreadMessagesHandlerError, GetThreadMessagesHandlerErrors, GetThreadMessagesHandlerResponse, GetThreadMessagesHandlerResponses, GetThreadResponse, GetThreadResponse2, GetThreadResponses, HealthCheckLinksData, HealthCheckLinksError, HealthCheckLinksErrors, HealthCheckLinksResponse, HealthCheckLinksResponses, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitErrorCodeResponse, InitResponse, InitUserData, InitUserError, InitUserErrors, InitUserResponse, InitUserResponses, Label, LabelInfo, LabelListVisibility, LabelType, Link, ListBackfillGmailData, ListBackfillGmailError, ListBackfillGmailErrors, ListBackfillGmailResponse, ListBackfillGmailResponses, ListBackfillJobsResponse, ListBlockedResponse, ListBlockedSendersData, ListBlockedSendersError, ListBlockedSendersErrors, ListBlockedSendersResponse, ListBlockedSendersResponses, ListCalendarsData, ListCalendarsError, ListCalendarsErrors, ListCalendarsResponse, ListCalendarsResponse2, ListCalendarsResponses, ListContactsData, ListContactsError, ListContactsErrors, ListContactsResponse, ListContactsResponse2, ListContactsResponses, ListEmailFiltersData, ListEmailFiltersError, ListEmailFiltersErrors, ListEmailFiltersResponse, ListEmailFiltersResponse2, ListEmailFiltersResponses, ListLabelsData, ListLabelsError, ListLabelsErrors, ListLabelsResponse, ListLabelsResponse2, ListLabelsResponses, ListLinksData, ListLinksError, ListLinksErrors, ListLinksResponse, ListLinksResponse2, ListLinksResponses, Message, MessageListVisibility, OutOfOfficeAutoDeclineMode, OutOfOfficeProperties, ParsedMessage, PatchSettingsData, PatchSettingsError, PatchSettingsErrors, PatchSettingsRequest, PatchSettingsResponse, PatchSettingsResponse2, PatchSettingsResponses, PreviewsInboxCursorData, PreviewsInboxCursorError, PreviewsInboxCursorErrors, PreviewsInboxCursorResponse, PreviewsInboxCursorResponses, PreviewView, PreviewViewStandardLabel, RefreshCalendarEvent, RefreshEmailEvent, RemoveDraftAttachmentData, RemoveDraftAttachmentError, RemoveDraftAttachmentErrors, RemoveDraftAttachmentResponse, RemoveDraftAttachmentResponses, RemoveForwardedAttachmentData, RemoveForwardedAttachmentError, RemoveForwardedAttachmentErrors, RemoveForwardedAttachmentResponse, RemoveForwardedAttachmentResponses, ResyncLinkData, ResyncLinkError, ResyncLinkErrors, ResyncLinkResponse, ResyncLinkResponses, ResyncResponse, RsvpCalendarEventData, RsvpCalendarEventError, RsvpCalendarEventErrors, RsvpCalendarEventRequest, RsvpCalendarEventResponse, RsvpCalendarEventResponses, SendMessageData, SendMessageError, SendMessageErrors, SendMessageRequest, SendMessageResponse, SendMessageResponse2, SendMessageResponses, Settings, SharedInboxConflictResponse, SyncStatus, Thread, ThreadList, ThreadPreviewCursor, ThreadSeenData, ThreadSeenError, ThreadSeenErrors, ThreadSeenResponse, ThreadSeenResponses, ThreadSummary, UnblockSenderData, UnblockSenderError, UnblockSenderErrors, UnblockSenderRequest, UnblockSenderResponse, UnblockSenderResponses, UnresolvedSignatureImagesError, UpdateCalendarEventData, UpdateCalendarEventError, UpdateCalendarEventErrors, UpdateCalendarEventRequest, UpdateCalendarEventResponse, UpdateCalendarEventResponses, UpdateLabelBatchRequest, UpdateLabelBatchResponse, UpdateThreadLabelRequest, UpdateThreadLabelsResponse, UpdateThreadProjectData, UpdateThreadProjectError, UpdateThreadProjectErrors, UpdateThreadProjectRequest, UpdateThreadProjectResponse, UpdateThreadProjectResponse2, UpdateThreadProjectResponses, UpsertEmailFilterData, UpsertEmailFilterError, UpsertEmailFilterErrors, UpsertEmailFilterRequest, UpsertEmailFilterResponse, UpsertEmailFilterResponse2, UpsertEmailFilterResponses, UpsertScheduledMessageData, UpsertScheduledMessageError, UpsertScheduledMessageErrors, UpsertScheduledMessageResponse, UpsertScheduledMessageResponses, UpsertScheduledRequest, UpsertScheduledResponse, UserProvider, Value, VisibleCalendar } from './types.gen';
diff --git a/packages/sdk/generated/email/types.gen.ts b/packages/sdk/generated/email/types.gen.ts
index c29cbcf524..454454c154 100644
--- a/packages/sdk/generated/email/types.gen.ts
+++ b/packages/sdk/generated/email/types.gen.ts
@@ -589,6 +589,9 @@ export type CalendarDeletionScopeParam = 'all' | 'this_event' | 'this_and_follow
/**
* A stable, first-class Macro calendar event entity.
+ *
+ * Content fields hold the canonical source's values: the account's primary
+ * calendar copy when one is synced, else the freshest remaining copy.
*/
export type CalendarEvent = {
/**
@@ -639,7 +642,7 @@ export type CalendarEvent = {
*/
id: string;
/**
- * Whether the current user can edit the canonical source.
+ * Whether the canonical source's calendar prohibits editing it.
*/
isReadOnly: boolean;
/**
@@ -672,6 +675,13 @@ export type CalendarEvent = {
* Provider/iCalendar sequence number.
*/
sequence: number;
+ /**
+ * Content of every active copy of this event, canonical first: the
+ * primary calendar's copy, then the freshest. A client picks the copy
+ * whose calendar it is showing and falls back to the first. Populated
+ * only on the read path, so stored projections omit it.
+ */
+ sources?: Array<CalendarEventSourceContent>;
/**
* Event status.
*/
@@ -698,6 +708,62 @@ export type CalendarEvent = {
visibility: EventVisibility;
};
+/**
+ * The content one provider copy of an event carries.
+ *
+ * Google keeps these fields per calendar copy: a shared calendar's copy of a
+ * member's event can have its own title, type, reminders, and access role.
+ * The entity holds its canonical source's values. Every other copy's values
+ * are read from here so a client can show the copy that belongs to the
+ * calendar being viewed.
+ */
+export type CalendarEventSourceContent = {
+ /**
+ * Calendar this copy lives on.
+ */
+ calendarId: string;
+ /**
+ * Provider-reported creator email.
+ */
+ creatorEmail?: string | null;
+ /**
+ * Provider-reported creator display name.
+ */
+ creatorName?: string | null;
+ /**
+ * Optional event body.
+ */
+ description?: string | null;
+ /**
+ * Provider event type.
+ */
+ eventType: EventType;
+ /**
+ * Whether the calendar's access role prohibits editing this copy.
+ */
+ isReadOnly: boolean;
+ /**
+ * Optional physical or virtual location label.
+ */
+ location?: string | null;
+ /**
+ * Reminder configuration of this copy.
+ */
+ reminders: EventReminders;
+ /**
+ * Display title.
+ */
+ title: string;
+ /**
+ * Availability behavior.
+ */
+ transparency: EventTransparency;
+ /**
+ * Event visibility.
+ */
+ visibility: EventVisibility;
+};
+
/**
* HTTP error body returned by calendar mutation endpoints.
*/
@@ -1343,6 +1409,11 @@ export type ResyncResponse = {
* Request body setting the requester's RSVP on an event.
*/
export type RsvpCalendarEventRequest = {
+ /**
+ * Calendar whose copy of the event is answered, for an event synced
+ * from more than one calendar. Omit to answer on the canonical copy.
+ */
+ calendarId?: string | null;
/**
* Original-start key of the occurrence the response targets.
*/
@@ -1483,6 +1554,11 @@ export type UpdateCalendarEventRequest = {
* Replacement attendee list.
*/
attendees?: Array<CalendarAttendeeInputBody> | null;
+ /**
+ * Calendar whose copy of the event is patched, for an event synced from
+ * more than one calendar. Omit to patch the canonical copy.
+ */
+ calendarId?: string | null;
conference?: null | ConferenceChange;
/**
* Replacement description; an empty string clears it.
@@ -1723,6 +1799,11 @@ export type DeleteCalendarEventData = {
event_id: string;
};
query?: {
+ /**
+ * Calendar whose copy of the event is deleted, for an event synced from
+ * more than one calendar. Omit to delete the canonical copy.
+ */
+ calendarId?: string;
/**
* Deletion scope; defaults to the entire event or series.
*/
diff --git a/packages/sdk/generated/storage/index.ts b/packages/sdk/generated/storage/index.ts
index dabfa05e20..264f4739fa 100644
--- a/packages/sdk/generated/storage/index.ts
+++ b/packages/sdk/generated/storage/index.ts
@@ -1,4 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export { type Options, Sdk } from './sdk.gen';
-export type { AccessLevel, ActiveCallsResponse, ActiveCallSummary, ActivityType, AddFavoriteData, AddFavoriteError, AddFavoriteErrors, AddFavoriteRequest, AddFavoriteResponse, AddFavoriteResponses, AddParticipantsData, AddParticipantsError, AddParticipantsErrors, AddParticipantsRequest, AddParticipantsResponses, AddPinHandlerData, AddPinHandlerError, AddPinHandlerErrors, AddPinHandlerResponse, AddPinHandlerResponses, AddPinRequest, Agent, AgentChannelScope, AgentMcpServer, AgentMcpServers, Anchor, AnchorId, AnchorRequest, AnchorResponse, AnnotationIncrementalUpdate, ApiActivity, ApiAttachmentChannelReference, ApiAttachmentEntityReference, ApiAttachmentGenericReference, ApiChannelAttachment, ApiChannelAttachmentsPage, ApiChannelContextMessage, ApiChannelDetail, ApiChannelListMessage, ApiChannelListPage, ApiChannelListParticipant, ApiChannelListType, ApiChannelMessage, ApiChannelMessageKind, ApiChannelMessagesPage, ApiChannelParticipant, ApiChannelWithLatest, ApiCountedReaction, ApiEntityFilterAst, ApiGroupByField, ApiGroupMeta, ApiMessageAttachment, ApiMessageSender, ApiMessageSenderType, ApiParticipantListRole, ApiParticipantRole, ApiPropertyEntityType, ApiResolvedChannelMessage, ApiThreadInfo, ApiThreadReply, ApproveHarnessPairingData, ApproveHarnessPairingError, ApproveHarnessPairingErrors, ApproveHarnessPairingResponse, ApproveHarnessPairingResponses, ApprovePairingRequest, AttendeeResponseStatus, BasicDocument, BasicDocumentSubType, BomPart, Bot, BotChannel, BotChannelType, BotId, BotKind, BotOwner, BotToken, BranchNameResponse, BTreeMap, BulkWakeupRequest, BulkWakeupResponse, BulkWakeupSyncServiceDocumentsData, BulkWakeupSyncServiceDocumentsErrors, BulkWakeupSyncServiceDocumentsResponse, BulkWakeupSyncServiceDocumentsResponses, CalendarAttendee, CalendarEvent, CalendarEventFilters, CalendarMentionEvent, CalendarMentionPreviewItem, CalendarMentionPreviewKind, CalendarMentionPreviewRequest, CalendarMentionPreviewRequestItem, CalendarMentionPreviewResponse, CalendarOccurrence, CalendarOccurrenceItem, CalendarOccurrenceResponse, CalendarSyncStatus, CallActiveResponse, CallFilters, CallRecord, CallRecordParticipant, CallRecordPreview, CallRecordPreviewData, CallRecordTranscriptSegment, CallStatus, CallTokenResponse, CallWebhookData, CallWebhookError, CallWebhookErrors, CallWebhookResponses, Channel, ChannelCreatedMetadata, ChannelDeletedMetadata, ChannelEventAttachment, ChannelFilters, ChannelJoinCodeResponse, ChannelMentionedMetadata, ChannelMessage, ChannelMessageAttachmentCreatedMetadata, ChannelMessageAttachmentRemovedMetadata, ChannelMessageDeletedMetadata, ChannelMessageFilters, ChannelMessagePatchedMetadata, ChannelMessagePostedMetadata, ChannelParticipant, ChannelParticipantAddedMetadata, ChannelParticipantRemovedMetadata, ChannelPreview, ChannelPreviewData, ChannelSender, ChannelSharePermission, ChannelThreadFilters, ChannelTopicEvent, ChannelType, ChannelUpdatedMetadata, ChannelWebhookRequest, ChannelWebhookResponse, ChannelWithParticipants, Chat, ChatFilters, CheckActiveCallData, CheckActiveCallError, CheckActiveCallErrors, CheckActiveCallResponse, CheckActiveCallResponses, ClaimedPairing, ClaimHarnessPairingData, ClaimHarnessPairingError, ClaimHarnessPairingErrors, ClaimHarnessPairingResponse, ClaimHarnessPairingResponses, ClaimPairingRequest, ClientOptions, CloudStorageItemType, CollabSurfaceResponse, CollabSurfaceTokenResponse, Comment, CommentThread, ConferenceProvider, CopyDocumentData, CopyDocumentError, CopyDocumentErrors, CopyDocumentQueryParams, CopyDocumentRequest, CopyDocumentResponse, CopyDocumentResponse2, CopyDocumentResponses, CreateAgentData, CreateAgentError, CreateAgentErrors, CreateAgentRequest, CreateAgentResponse, CreateAgentResponses, CreateAnchorData, CreateAnchorError, CreateAnchorErrors, CreateAnchorResponse, CreateAnchorResponses, CreateBotRequest, CreateBulkDocumentResponse, CreateBulkDocumentResponseData, CreateChannelData, CreateChannelError, CreateChannelErrors, CreateChannelRequest, CreateChannelResponse, CreateChannelResponse2, CreateChannelResponses, CreateChannelScopedBotData, CreateChannelScopedBotError, CreateChannelScopedBotErrors, CreateChannelScopedBotRequest, CreateChannelScopedBotResponse, CreateChannelScopedBotResponse2, CreateChannelScopedBotResponses, CreateCollabSurfaceTokenData, CreateCollabSurfaceTokenError, CreateCollabSurfaceTokenErrors, CreateCollabSurfaceTokenResponse, CreateCollabSurfaceTokenResponses, CreateCommentData, CreateCommentError, CreateCommentErrors, CreateCommentRequest, CreateCommentResponse, CreateCommentResponse2, CreateCommentResponses, CreateCrmCommentData, CreateCrmCommentError, CreateCrmCommentErrors, CreateCrmCommentRequest, CreateCrmCommentResponse, CreateCrmCommentResponses, CreateCrmCompanyData, CreateCrmCompanyError, CreateCrmCompanyErrors, CreateCrmCompanyRequest, CreateCrmCompanyResponse, CreateCrmCompanyResponses, CreateCrmContactData, CreateCrmContactError, CreateCrmContactErrors, CreateCrmContactRequest, CreateCrmContactResponse, CreateCrmContactResponses, CreateDocumentData, CreateDocumentError, CreateDocumentErrors, CreateDocumentRequest, CreateDocumentResponse, CreateDocumentResponseData, CreateDocumentResponses, CreatedPairing, CreatedUserApiKey, CreateEntityMentionData, CreateEntityMentionError, CreateEntityMentionErrors, CreateEntityMentionRequest, CreateEntityMentionResponse, CreateEntityMentionResponse2, CreateEntityMentionResponses, CreateHarnessPairingData, CreateHarnessPairingError, CreateHarnessPairingErrors, CreateHarnessPairingResponse, CreateHarnessPairingResponses, CreateInstructionsDocumentResponse, CreateInstructionsHandlerData, CreateInstructionsHandlerError, CreateInstructionsHandlerErrors, CreateInstructionsHandlerResponse, CreateInstructionsHandlerResponses, CreateMarkdownDocumentRequest, CreateMarkdownDocumentResponse, CreateMarkdownHandlerData, CreateMarkdownHandlerError, CreateMarkdownHandlerErrors, CreateMarkdownHandlerResponse, CreateMarkdownHandlerResponses, CreatePairingRequest, CreateProjectHandlerData, CreateProjectHandlerError, CreateProjectHandlerErrors, CreateProjectHandlerResponse, CreateProjectHandlerResponses, CreateProjectRequest, CreateProjectResponse, CreateReminderData, CreateReminderError, CreateReminderErrors, CreateReminderRequest, CreateReminderResponse, CreateReminderResponses, CreateSkillHandlerData, CreateSkillHandlerError, CreateSkillHandlerErrors, CreateSkillHandlerResponse, CreateSkillHandlerResponses, CreateSkillRequest, CreateSkillResponse, CreateSnippetHandlerData, CreateSnippetHandlerError, CreateSnippetHandlerErrors, CreateSnippetHandlerResponse, CreateSnippetHandlerResponses, CreateSnippetRequest, CreateSnippetResponse, CreateTaskHandlerData, CreateTaskHandlerError, CreateTaskHandlerErrors, CreateTaskHandlerResponse, CreateTaskHandlerResponses, CreateTaskRequest, CreateTaskResponse, CreateUnthreadedAnchorRequest, CreateUnthreadedAnchorResponse, CreateUnthreadedPdfAnchorRequest, CreateUserApiKeyData, CreateUserApiKeyError, CreateUserApiKeyErrors, CreateUserApiKeyRequest, CreateUserApiKeyResponse, CreateUserApiKeyResponses, CreateViewHandlerData, CreateViewHandlerError, CreateViewHandlerErrors, CreateViewHandlerResponse, CreateViewHandlerResponses, CreateViewRequest, CreateWebhookData, CreateWebhookError, CreateWebhookErrors, CreateWebhookRequest, CreateWebhookResponse, CreateWebhookResponse2, CreateWebhookResponses, CrmComment, CrmCommentEntityType, CrmCommentThread, CrmCompanyFilters, CrmCompanyResponse, CrmContactResponse, CrmDomainResponse, CrmPermissionRole, CrmTeamSettingsResponse, CrmThread, CustomSpeakerAssignment, DataType, DeleteAnchorData, DeleteAnchorError, DeleteAnchorErrors, DeleteAnchorInfo, DeleteAnchorResponse, DeleteAnchorResponses, DeleteCallRecordData, DeleteCallRecordError, DeleteCallRecordErrors, DeleteCallRecordResponse, DeleteCallRecordResponses, DeleteChannelData, DeleteChannelError, DeleteChannelErrors, DeleteChannelResponse, DeleteChannelResponses, DeleteCollabSurfaceData, DeleteCollabSurfaceError, DeleteCollabSurfaceErrors, DeleteCollabSurfaceResponse, DeleteCollabSurfaceResponses, DeleteCommentData, DeleteCommentError, DeleteCommentErrors, DeleteCommentRequest, DeleteCommentResponse, DeleteCommentResponse2, DeleteCommentResponses, DeleteCrmCommentData, DeleteCrmCommentError, DeleteCrmCommentErrors, DeleteCrmCommentResponse, DeleteCrmCommentResponses, DeleteCrmCommentResult, DeleteDocumentData, DeleteDocumentError, DeleteDocumentErrors, DeleteDocumentResponse, DeleteDocumentResponses, DeleteEntityMentionData, DeleteEntityMentionError, DeleteEntityMentionErrors, DeleteEntityMentionResponse, DeleteEntityMentionResponse2, DeleteEntityMentionResponses, DeleteHarnessData, DeleteHarnessError, DeleteHarnessErrors, DeleteHarnessResponse, DeleteHarnessResponses, DeleteHistoryHandlerData, DeleteHistoryHandlerError, DeleteHistoryHandlerErrors, DeleteHistoryHandlerResponse, DeleteHistoryHandlerResponses, DeleteMessageData, DeleteMessageError, DeleteMessageErrors, DeleteMessageQuery, DeleteMessageResponse, DeleteMessageResponses, DeleteProjectHandlerData, DeleteProjectHandlerError, DeleteProjectHandlerErrors, DeleteProjectHandlerResponse, DeleteProjectHandlerResponses, DeleteReminderData, DeleteReminderError, DeleteReminderErrors, DeleteReminderResponse, DeleteReminderResponses, DeleteSelfHarnessData, DeleteSelfHarnessError, DeleteSelfHarnessErrors, DeleteSelfHarnessResponse, DeleteSelfHarnessResponses, DeleteThreadInfo, DeleteUnthreadedAnchorRequest, DeleteUnthreadedAnchorResponse, DeleteUnthreadedPdfAnchorRequest, DeleteUserApiKeyData, DeleteUserApiKeyError, DeleteUserApiKeyErrors, DeleteUserApiKeyResponse, DeleteUserApiKeyResponses, DeleteUserDocumentViewLocationData, DeleteUserDocumentViewLocationError, DeleteUserDocumentViewLocationErrors, DeleteUserDocumentViewLocationResponse, DeleteUserDocumentViewLocationResponses, DeleteViewHandlerData, DeleteViewHandlerError, DeleteViewHandlerErrors, DeleteViewHandlerResponses, DeleteWebhookData, DeleteWebhookError, DeleteWebhookErrors, DeleteWebhookResponse, DeleteWebhookResponses, DocumentBasic, DocumentContent, DocumentContentLocation, DocumentContentState, DocumentContentUploadedMetadata, DocumentCopiedMetadata, DocumentCreatedMetadata, DocumentDeletedMetadata, DocumentFilters, DocumentInteractionMetadata, DocumentMetadata, DocumentMetadataWithContent, DocumentPermissionsToken, DocumentPermissionsTokenRequest, DocumentPermissionsTokenResponse, DocumentPreview, DocumentPreviewData, DocumentPreviewDataSubType, DocumentPurgedMetadata, DocumentResponse, DocumentResponseMetadata, DocumentResponseMetadataWithContent, DocumentStorageServiceApiVersion, DocumentSubType, DocumentSyncContentUpdatedMetadata, DocumentTeamShareResponse, DocumentTopicEvent, DocumentUpdatedMetadata, EditAnchorData, EditAnchorError, EditAnchorErrors, EditAnchorRequest, EditAnchorResponse, EditAnchorResponse2, EditAnchorResponses, EditCallRecordData, EditCallRecordError, EditCallRecordErrors, EditCallRecordRequest, EditCallRecordResponse, EditCallRecordResponses, EditCallTranscriptData, EditCallTranscriptError, EditCallTranscriptErrors, EditCallTranscriptRequest, EditCallTranscriptResponse, EditCallTranscriptResponses, EditCommentData, EditCommentError, EditCommentErrors, EditCommentRequest, EditCommentResponse, EditCommentResponse2, EditCommentResponses, EditCrmCommentData, EditCrmCommentError, EditCrmCommentErrors, EditCrmCommentRequest, EditCrmCommentResponse, EditCrmCommentResponses, EditDocumentData, EditDocumentError, EditDocumentErrors, EditDocumentResponse, EditDocumentResponse2, EditDocumentResponses, EditDocumentServiceArgs, EditPdfAnchorRequest, EditPdfPlaceableCommentAnchorRequest, EditProjectV2Data, EditProjectV2Error, EditProjectV2Errors, EditProjectV2Response, EditProjectV2Responses, EditThreadV2Data, EditThreadV2Error, EditThreadV2Errors, EditThreadV2Response, EditThreadV2Responses, EmailFilters, EmptyResponse, EnsureCollabSurfaceData, EnsureCollabSurfaceError, EnsureCollabSurfaceErrors, EnsureCollabSurfaceRequest, EnsureCollabSurfaceResponse, EnsureCollabSurfaceResponses, EntityFilters, EntityPermission, EntityPermissionResponse, EntityReference, EntityType, ErrorResponse, EventReminderOverride, EventReminders, EventStatus, EventTime, EventTransparency, EventType, EventVisibility, ExcludedDefaultView, ExcludeDefaultViewHandlerData, ExcludeDefaultViewHandlerError, ExcludeDefaultViewHandlerErrors, ExcludeDefaultViewHandlerResponses, ExcludeDefaultViewRequest, ExportDocumentData, ExportDocumentError, ExportDocumentErrors, ExportDocumentResponse, ExportDocumentResponse2, ExportDocumentResponses, Favorite, FavoriteEntityRef, FavoritesList, FileSystemNodeWithIds, FileType, FileTypeUpdate, FolderItem, ForeignEntity, ForeignEntityFilters, GenericErrorResponse, GenericResponse, GenericSuccessResponse, GetActiveCallsData, GetActiveCallsError, GetActiveCallsErrors, GetActiveCallsResponse, GetActiveCallsResponses, GetActivityData, GetActivityError, GetActivityErrors, GetActivityResponse, GetActivityResponses, GetAttachmentReferencesData, GetAttachmentReferencesError, GetAttachmentReferencesErrors, GetAttachmentReferencesResponse, GetAttachmentReferencesResponse2, GetAttachmentReferencesResponses, GetBatchCallRecordPreviewData, GetBatchCallRecordPreviewError, GetBatchCallRecordPreviewErrors, GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse, GetBatchCallRecordPreviewResponse2, GetBatchCallRecordPreviewResponses, GetBatchChannelPreviewData, GetBatchChannelPreviewError, GetBatchChannelPreviewErrors, GetBatchChannelPreviewRequest, GetBatchChannelPreviewResponse, GetBatchChannelPreviewResponse2, GetBatchChannelPreviewResponses, GetBatchPreviewHandlerData, GetBatchPreviewHandlerError, GetBatchPreviewHandlerErrors, GetBatchPreviewHandlerResponse, GetBatchPreviewHandlerResponses, GetBatchPreviewRequest, GetBatchPreviewResponse, GetBatchProjectPreviewData, GetBatchProjectPreviewError, GetBatchProjectPreviewErrors, GetBatchProjectPreviewRequest, GetBatchProjectPreviewResponse, GetBatchProjectPreviewResponse2, GetBatchProjectPreviewResponses, GetCallRecordData, GetCallRecordError, GetCallRecordErrors, GetCallRecordResponse, GetCallRecordResponses, GetChannelAttachmentsData, GetChannelAttachmentsError, GetChannelAttachmentsErrors, GetChannelAttachmentsResponse, GetChannelAttachmentsResponses, GetChannelData, GetChannelError, GetChannelErrors, GetChannelJoinLinkData, GetChannelJoinLinkError, GetChannelJoinLinkErrors, GetChannelJoinLinkResponse, GetChannelJoinLinkResponses, GetChannelMessagesData, GetChannelMessagesError, GetChannelMessagesErrors, GetChannelMessagesResponse, GetChannelMessagesResponses, GetChannelParticipantsData, GetChannelParticipantsError, GetChannelParticipantsErrors, GetChannelParticipantsResponse, GetChannelParticipantsResponses, GetChannelResponse, GetChannelResponses, GetChannelsData, GetChannelsError, GetChannelsErrors, GetChannelsResponse, GetChannelsResponses, GetCollabSurfaceData, GetCollabSurfaceError, GetCollabSurfaceErrors, GetCollabSurfaceResponse, GetCollabSurfaceResponses, GetCompanyData, GetCompanyError, GetCompanyErrors, GetCompanyResponse, GetCompanyResponses, GetContactByEmailData, GetContactByEmailError, GetContactByEmailErrors, GetContactByEmailResponse, GetContactByEmailResponse2, GetContactByEmailResponses, GetContactData, GetContactError, GetContactErrors, GetContactResponse, GetContactResponses, GetCrmTeamSettingsData, GetCrmTeamSettingsError, GetCrmTeamSettingsErrors, GetCrmTeamSettingsResponse, GetCrmTeamSettingsResponses, GetDocumentAnchorsData, GetDocumentAnchorsError, GetDocumentAnchorsErrors, GetDocumentAnchorsResponse, GetDocumentAnchorsResponses, GetDocumentBranchNameData, GetDocumentBranchNameError, GetDocumentBranchNameErrors, GetDocumentBranchNameResponse, GetDocumentBranchNameResponses, GetDocumentByTeamSlugData, GetDocumentByTeamSlugError, GetDocumentByTeamSlugErrors, GetDocumentByTeamSlugResponse, GetDocumentByTeamSlugResponses, GetDocumentCommentsData, GetDocumentCommentsError, GetDocumentCommentsErrors, GetDocumentCommentsResponse, GetDocumentCommentsResponses, GetDocumentData, GetDocumentError, GetDocumentErrors, GetDocumentGithubPullRequestsData, GetDocumentGithubPullRequestsError, GetDocumentGithubPullRequestsErrors, GetDocumentGithubPullRequestsResponse, GetDocumentGithubPullRequestsResponses, GetDocumentKeyResponse, GetDocumentKeyResponseData, GetDocumentListHandlerData, GetDocumentListHandlerError, GetDocumentListHandlerErrors, GetDocumentListHandlerResponse, GetDocumentListHandlerResponses, GetDocumentListResult, GetDocumentLocationV3Data, GetDocumentLocationV3Error, GetDocumentLocationV3Errors, GetDocumentLocationV3Response, GetDocumentLocationV3Responses, GetDocumentPermissionsResponseDataV2, GetDocumentPermissionsTokenData, GetDocumentPermissionsTokenError, GetDocumentPermissionsTokenErrors, GetDocumentPermissionsTokenResponse, GetDocumentPermissionsTokenResponses, GetDocumentPermissionsV2Data, GetDocumentPermissionsV2Error, GetDocumentPermissionsV2Errors, GetDocumentPermissionsV2Response, GetDocumentPermissionsV2Responses, GetDocumentProcessingResult, GetDocumentProcessingResultData, GetDocumentProcessingResultError, GetDocumentProcessingResultErrors, GetDocumentProcessingResultResponse, GetDocumentProcessingResultResponse2, GetDocumentProcessingResultResponses, GetDocumentResponse, GetDocumentResponse2, GetDocumentResponseData, GetDocumentResponses, GetDocumentSearchResponse, GetDocumentShortIdData, GetDocumentShortIdError, GetDocumentShortIdErrors, GetDocumentShortIdResponse, GetDocumentShortIdResponses, GetDocumentsResponse, GetDocumentTeamShareData, GetDocumentTeamShareError, GetDocumentTeamShareErrors, GetDocumentTeamShareResponse, GetDocumentTeamShareResponses, GetDocumentUserAccessLevelResponse, GetDocumentVersionData, GetDocumentVersionError, GetDocumentVersionErrors, GetDocumentVersionResponse, GetDocumentVersionResponses, GetDocumentViewsHandlerData, GetDocumentViewsHandlerError, GetDocumentViewsHandlerErrors, GetDocumentViewsHandlerResponse, GetDocumentViewsHandlerResponses, GetEntityPermissionData, GetEntityPermissionErrors, GetEntityPermissionResponse, GetEntityPermissionResponses, GetForeignEntityData, GetForeignEntityError, GetForeignEntityErrors, GetForeignEntityResponse, GetForeignEntityResponses, GetHarnessPairingData, GetHarnessPairingError, GetHarnessPairingErrors, GetHarnessPairingResponse, GetHarnessPairingResponses, GetHistoryHandlerData, GetHistoryHandlerError, GetHistoryHandlerErrors, GetHistoryHandlerResponse, GetHistoryHandlerResponses, GetInstructionsDocumentResponse, GetInstructionsHandlerData, GetInstructionsHandlerError, GetInstructionsHandlerErrors, GetInstructionsHandlerResponse, GetInstructionsHandlerResponses, GetItemsSoupData, GetItemsSoupError, GetItemsSoupErrors, GetItemsSoupResponse, GetItemsSoupResponses, GetLocationHandlerData, GetLocationHandlerError, GetLocationHandlerErrors, GetLocationHandlerResponse, GetLocationHandlerResponses, GetMessageWithContextData, GetMessageWithContextError, GetMessageWithContextErrors, GetMessageWithContextResponse, GetMessageWithContextResponse2, GetMessageWithContextResponses, GetOrCreateAction, GetOrCreateCallData, GetOrCreateCallError, GetOrCreateCallErrors, GetOrCreateCallResponse, GetOrCreateCallResponses, GetOrCreateChannelResponse, GetOrCreateDmData, GetOrCreateDmError, GetOrCreateDmErrors, GetOrCreateDmRequest, GetOrCreateDmResponse, GetOrCreateDmResponses, GetOrCreatePrivateData, GetOrCreatePrivateError, GetOrCreatePrivateErrors, GetOrCreatePrivateRequest, GetOrCreatePrivateResponse, GetOrCreatePrivateResponses, GetPendingProjectsHandlerData, GetPendingProjectsHandlerError, GetPendingProjectsHandlerErrors, GetPendingProjectsHandlerResponse, GetPendingProjectsHandlerResponses, GetPinsHandlerData, GetPinsHandlerError, GetPinsHandlerErrors, GetPinsHandlerResponse, GetPinsHandlerResponses, GetPinsResponse, GetProjectContentHandlerData, GetProjectContentHandlerError, GetProjectContentHandlerErrors, GetProjectContentHandlerResponse, GetProjectContentHandlerResponses, GetProjectContentResponse, GetProjectHandlerData, GetProjectHandlerError, GetProjectHandlerErrors, GetProjectHandlerResponse, GetProjectHandlerResponses, GetProjectPermissionsV2Data, GetProjectPermissionsV2Error, GetProjectPermissionsV2Errors, GetProjectPermissionsV2Response, GetProjectPermissionsV2Responses, GetProjectResponse, GetProjectResponseData, GetProjectsHandlerData, GetProjectsHandlerError, GetProjectsHandlerErrors, GetProjectsHandlerResponse, GetProjectsHandlerResponses, GetProjectsResponse, GetProjectUserAccessLevelData, GetProjectUserAccessLevelError, GetProjectUserAccessLevelErrors, GetProjectUserAccessLevelResponse, GetProjectUserAccessLevelResponses, GetReminderData, GetReminderError, GetReminderErrors, GetReminderResponse, GetReminderResponses, GetRingStatusData, GetRingStatusError, GetRingStatusErrors, GetRingStatusResponse, GetRingStatusResponses, GetSelfBotData, GetSelfBotError, GetSelfBotErrors, GetSelfBotResponse, GetSelfBotResponses, GetSelfHarnessData, GetSelfHarnessError, GetSelfHarnessErrors, GetSelfHarnessResponse, GetSelfHarnessResponses, GetSystemSkillsHandlerData, GetSystemSkillsHandlerError, GetSystemSkillsHandlerErrors, GetSystemSkillsHandlerResponse, GetSystemSkillsHandlerResponses, GetThreadRepliesData, GetThreadRepliesError, GetThreadRepliesErrors, GetThreadRepliesResponse, GetThreadRepliesResponses, GetUserDocumentsHandlerData, GetUserDocumentsHandlerError, GetUserDocumentsHandlerErrors, GetUserDocumentsHandlerResponse, GetUserDocumentsHandlerResponses, GetUserDocumentViewLocationData, GetUserDocumentViewLocationError, GetUserDocumentViewLocationErrors, GetUserDocumentViewLocationResponse, GetUserDocumentViewLocationResponses, GetUserHistoryResponse, GetViewsHandlerData, GetViewsHandlerError, GetViewsHandlerErrors, GetViewsHandlerResponse, GetViewsHandlerResponses, GetWebhookData, GetWebhookError, GetWebhookErrors, GetWebhookResponse, GetWebhookResponses, GithubPullRequest, GithubPullRequestCheckRun, GithubPullRequestComment, GithubPullRequestsResponse, GroupedInitialParams, GroupedPageParams, GroupedSoupGroupPage, GroupedSoupInitialPage, GroupedSoupPage, GroupedSoupSort, HandlerData, HandlerError, HandlerErrors, HandlerResponse, HandlerResponses, Harness, HarnessAgent, HarnessId, HarnessOwner, HarnessSession, HashMap, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, HighlightType, IngestTranscriptData, IngestTranscriptError, IngestTranscriptErrors, IngestTranscriptResponses, InitializeUserDocumentsData, InitializeUserDocumentsError, InitializeUserDocumentsErrors, InitializeUserDocumentsResponse, InitializeUserDocumentsResponses, InstallSyncData, InstallSyncErrors, InteractionReason, Item, ItemWithUserAccessLevel, JobProcessingResultHandlerData, JobProcessingResultHandlerError, JobProcessingResultHandlerErrors, JobProcessingResultHandlerResponse, JobProcessingResultHandlerResponses, JoinChannelByCodeData, JoinChannelByCodeError, JoinChannelByCodeErrors, JoinChannelByCodeResponses, JoinChannelData, JoinChannelError, JoinChannelErrors, JoinChannelResponses, LatestMessage, LeaveCallResponse, LeaveChannelData, LeaveChannelError, LeaveChannelErrors, LeaveChannelResponses, LeaveOrEndCallData, LeaveOrEndCallError, LeaveOrEndCallErrors, LeaveOrEndCallResponse, LeaveOrEndCallResponses, LinkShare, ListAgentsData, ListAgentsError, ListAgentsErrors, ListAgentsResponse, ListAgentsResponses, ListBotChannelsData, ListBotChannelsError, ListBotChannelsErrors, ListBotChannelsResponse, ListBotChannelsResponses, ListCompanyContactsData, ListCompanyContactsError, ListCompanyContactsErrors, ListCompanyContactsResponse, ListCompanyContactsResponses, ListCrmCommentsData, ListCrmCommentsError, ListCrmCommentsErrors, ListCrmCommentsResponse, ListCrmCommentsResponses, ListFavoritesData, ListFavoritesError, ListFavoritesErrors, ListFavoritesResponse, ListFavoritesResponses, ListHarnessAgentsData, ListHarnessAgentsError, ListHarnessAgentsErrors, ListHarnessAgentsResponse, ListHarnessAgentsResponses, ListHarnessesData, ListHarnessesError, ListHarnessesErrors, ListHarnessesResponse, ListHarnessesResponses, ListHarnessSessionsData, ListHarnessSessionsError, ListHarnessSessionsErrors, ListHarnessSessionsResponse, ListHarnessSessionsResponses, ListOccurrencesData, ListOccurrencesErrors, ListOccurrencesResponse, ListOccurrencesResponses, ListRemindersData, ListRemindersError, ListRemindersErrors, ListRemindersResponse, ListRemindersResponses, ListTeamOutOfOfficeData, ListTeamOutOfOfficeErrors, ListTeamOutOfOfficeResponse, ListTeamOutOfOfficeResponses, ListUserApiKeysData, ListUserApiKeysError, ListUserApiKeysErrors, ListUserApiKeysResponse, ListUserApiKeysResponses, ListWebhooksData, ListWebhooksError, ListWebhooksErrors, ListWebhooksResponse, ListWebhooksResponse2, ListWebhooksResponses, LocationResponseData, LocationResponseV3, MacroUserIdStr, MentionPreviewsData, MentionPreviewsErrors, MentionPreviewsResponse, MentionPreviewsResponses, Mentions, NewChannelAttachment, NotificationFilters, PairingDetails, Params, ParticipantRole, PatchBotRequest, PatchChannelData, PatchChannelError, PatchChannelErrors, PatchChannelRequest, PatchChannelResponse, PatchChannelResponses, PatchMessageData, PatchMessageError, PatchMessageErrors, PatchMessageRequest, PatchMessageResponse, PatchMessageResponses, PatchProjectRequestV2, PatchThreadRequestV2, PatchViewHandlerData, PatchViewHandlerError, PatchViewHandlerErrors, PatchViewHandlerResponses, PatchWebhookData, PatchWebhookError, PatchWebhookErrors, PatchWebhookRequest, PatchWebhookResponse, PatchWebhookResponses, PdfAnchor, PdfAnchorId, PdfAnchorRequest, PdfHighlightAnchor, PdfHighlightAnchorRequest, PdfHighlightRect, PdfHighlightRectAnchorRequest, PdfPlaceableCommentAnchor, PdfPlaceableCommentAnchorRequest, PendingClaimResponse, PermanentlyDeleteDocumentData, PermanentlyDeleteDocumentError, PermanentlyDeleteDocumentErrors, PermanentlyDeleteDocumentResponse, PermanentlyDeleteDocumentResponses, PermanentlyDeleteProjectData, PermanentlyDeleteProjectError, PermanentlyDeleteProjectErrors, PermanentlyDeleteProjectResponse, PermanentlyDeleteProjectResponses, PinnedItem, PinRequest, PostActivityData, PostActivityError, PostActivityErrors, PostActivityRequest, PostActivityResponse, PostActivityResponses, PostChannelBotWebhookData, PostChannelBotWebhookError, PostChannelBotWebhookErrors, PostChannelBotWebhookResponse, PostChannelBotWebhookResponses, PostChannelMessagesData, PostChannelMessagesError, PostChannelMessagesErrors, PostChannelMessagesResponse, PostChannelMessagesResponses, PostGroupedSoupAstGroupPageRequest, PostGroupedSoupAstInitialRequest, PostGroupedSoupAstRequest, PostItemsSoupAstData, PostItemsSoupAstError, PostItemsSoupAstErrors, PostItemsSoupAstGroupedData, PostItemsSoupAstGroupedError, PostItemsSoupAstGroupedErrors, PostItemsSoupAstGroupedResponse, PostItemsSoupAstGroupedResponses, PostItemsSoupAstResponse, PostItemsSoupAstResponses, PostItemsSoupData, PostItemsSoupError, PostItemsSoupErrors, PostItemsSoupResponse, PostItemsSoupResponses, PostMessageData, PostMessageError, PostMessageErrors, PostMessageRequest, PostMessageResponse, PostMessageResponse2, PostMessageResponses, PostReactionData, PostReactionError, PostReactionErrors, PostReactionRequest, PostReactionResponse, PostReactionResponses, PostSoupAstRequest, PostSoupRequest, PostTypingData, PostTypingError, PostTypingErrors, PostTypingRequest, PostTypingResponse, PostTypingResponses, PresaveDocumentHandlerData, PresaveDocumentHandlerError, PresaveDocumentHandlerErrors, PresaveDocumentHandlerResponse, PresaveDocumentHandlerResponses, PreSaveDocumentRequest, PreSaveDocumentResponse, PreSaveDocumentResponseData, PresignedUrl, Project, ProjectDeleteResponseData, ProjectDocumentStatus, ProjectFilters, ProjectPreview, ProjectPreviewData, PropertyDefinition, PropertyFilter, PropertyInput, PropertyOwner, PropertyValue, PutCrmTeamSettingsData, PutCrmTeamSettingsError, PutCrmTeamSettingsErrors, PutCrmTeamSettingsResponse, PutCrmTeamSettingsResponses, ReactionAction, RecentlyDeletedData, RecentlyDeletedError, RecentlyDeletedErrors, RecentlyDeletedResponse, RecentlyDeletedResponseData, RecentlyDeletedResponses, Reminder, ReminderFilters, ReminderSchedule, RemindersList, RemoveBotFromChannelByBotData, RemoveBotFromChannelByBotError, RemoveBotFromChannelByBotErrors, RemoveBotFromChannelByBotResponse, RemoveBotFromChannelByBotResponses, RemoveFavoriteByEntityData, RemoveFavoriteByEntityError, RemoveFavoriteByEntityErrors, RemoveFavoriteByEntityResponses, RemoveParticipantsData, RemoveParticipantsError, RemoveParticipantsErrors, RemoveParticipantsRequest, RemoveParticipantsResponses, RemovePinHandlerData, RemovePinHandlerError, RemovePinHandlerErrors, RemovePinHandlerResponse, RemovePinHandlerResponses, ReorderFavoritesData, ReorderFavoritesError, ReorderFavoritesErrors, ReorderFavoritesRequest, ReorderFavoritesResponses, ReorderPinRequest, ReorderPinsHandlerData, ReorderPinsHandlerError, ReorderPinsHandlerErrors, ReorderPinsHandlerResponse, ReorderPinsHandlerResponses, RequestedHarnessScope, ResolveChannelMessageData, ResolveChannelMessageError, ResolveChannelMessageErrors, ResolveChannelMessageResponse, ResolveChannelMessageResponses, RevertDeleteDocumentData, RevertDeleteDocumentError, RevertDeleteDocumentErrors, RevertDeleteDocumentResponse, RevertDeleteDocumentResponses, RevertDeleteProjectData, RevertDeleteProjectError, RevertDeleteProjectErrors, RevertDeleteProjectResponse, RevertDeleteProjectResponses, RingStatus, RingStatusResponse, S3ObjectInfo, SaveBomPart, SaveDocumentHandlerData, SaveDocumentHandlerError, SaveDocumentHandlerErrors, SaveDocumentHandlerResponse, SaveDocumentHandlerResponses, SaveDocumentRequest, SaveDocumentResponse, SaveDocumentResponseData, SetCompanyHiddenData, SetCompanyHiddenError, SetCompanyHiddenErrors, SetCompanyHiddenRequest, SetCompanyHiddenResponse, SetCompanyHiddenResponses, SetCompanyNameRequest, SetContactHiddenData, SetContactHiddenError, SetContactHiddenErrors, SetContactHiddenRequest, SetContactHiddenResponse, SetContactHiddenResponses, SetContactNameRequest, SetCrmCompanyNameData, SetCrmCompanyNameError, SetCrmCompanyNameErrors, SetCrmCompanyNameResponse, SetCrmCompanyNameResponses, SetCrmContactNameData, SetCrmContactNameError, SetCrmContactNameErrors, SetCrmContactNameResponse, SetCrmContactNameResponses, SetDocumentTeamShareData, SetDocumentTeamShareError, SetDocumentTeamShareErrors, SetDocumentTeamShareRequest, SetDocumentTeamShareResponse, SetDocumentTeamShareResponses, SetEmailSyncData, SetEmailSyncError, SetEmailSyncErrors, SetEmailSyncRequest, SetEmailSyncResponse, SetEmailSyncResponses, SetPropertyValue, SharedEmailFilter, SharePermissionV2, ShortIdResponse, SimpleMention, SimpleSaveData, SimpleSaveError, SimpleSaveErrors, SimpleSaveResponse, SimpleSaveResponses, SoupApiItem, SoupApiSort, SoupApiSortDirection, SoupAttachment, SoupCalendarEventSoupPropertiesField, SoupCalendarEventTime, SoupCallRecordParticipant, SoupCallRecordSoupPropertiesField, SoupChannel, SoupChannelThread, SoupChatSoupPropertiesField, SoupContact, SoupCountedReaction, SoupCrmCompanySoupPropertiesField, SoupCrmDomain, SoupDocumentSoupPropertiesField, SoupDocumentSubType, SoupEmailThreadPreview, SoupEnrichedEmailThreadPreviewSoupPropertiesField, SoupForeignEntity, SoupItem, SoupLabel, SoupLabelListVisibility, SoupLabelType, SoupMessageAttachment, SoupMessageListVisibility, SoupMessageSender, SoupMessageSenderType, SoupPage, SoupProjectSoupPropertiesField, SoupPropertiesField, SoupProperty, SoupReminderReference, SoupReminderSchedule, SoupReminderSoupPropertiesField, SoupThreadInfo, SoupThreadReply, StarterDocumentsResponse, StreamEventsData, StreamEventsError, StreamEventsErrors, StreamEventsResponse, StreamEventsResponses, String, SuccessResponse, SurfaceState, SyncServiceVersionId, SystemSkillSummary, TagFilterMode, TaskFilters, TeamOutOfOfficeItem, TeamOutOfOfficeResponse, TeamRole, Thread, ThreadResponse, ToggleShareWithTeamData, ToggleShareWithTeamError, ToggleShareWithTeamErrors, ToggleShareWithTeamResponse, ToggleShareWithTeamResponses, TranscriptSegmentRequest, TypedSuccessResponse, TypedSuccessResponseGetDocumentResponseData, TypingAction, UnthreadedPdfUuidRequest, UpdateAgentData, UpdateAgentError, UpdateAgentErrors, UpdateAgentRequest, UpdateAgentResponse, UpdateAgentResponses, UpdateChannelSharePermission, UpdateCrmTeamSettingsRequest, UpdateOperation, UpdateReminderData, UpdateReminderError, UpdateReminderErrors, UpdateReminderRequest, UpdateReminderResponse, UpdateReminderResponses, UpdateSharePermissionRequestV2, UploadDocumentStatus, UploadExtractFolderHandlerData, UploadExtractFolderHandlerError, UploadExtractFolderHandlerErrors, UploadExtractFolderHandlerResponse, UploadExtractFolderHandlerResponses, UploadExtractFolderRequest, UploadFolderHandlerData, UploadFolderHandlerError, UploadFolderHandlerErrors, UploadFolderHandlerResponse, UploadFolderHandlerResponses, UploadFolderRequest, UpsertHistoryHandlerData, UpsertHistoryHandlerError, UpsertHistoryHandlerErrors, UpsertHistoryHandlerResponse, UpsertHistoryHandlerResponses, UpsertUserDocumentViewLocationData, UpsertUserDocumentViewLocationError, UpsertUserDocumentViewLocationErrors, UpsertUserDocumentViewLocationRequest, UpsertUserDocumentViewLocationResponse, UpsertUserDocumentViewLocationResponses, UserApiKeyId, UserApiKeyInfo, UserApiKeysList, UserDocumentsResponse, UserDocumentViewLocation, UserDocumentViewLocationResponse, UserPinsResponse, UserViewsResponse, ValidateDocumentPermissionsTokenData, ValidateDocumentPermissionsTokenError, ValidateDocumentPermissionsTokenErrors, ValidateDocumentPermissionsTokenResponse, ValidateDocumentPermissionsTokenResponses, ValidateWebhookData, ValidateWebhookError, ValidateWebhookErrors, ValidateWebhookResponse, ValidateWebhookResponse2, ValidateWebhookResponses, Vec, View, ViewPatch, ViewsResponse, Webhook, WebhookEvent, WebhookFilter, WebhookScope, WebhookStatus, WebhookValidationTestEvent, WithCallId, WithChannelId, WithDocumentId, WithProjectId } from './types.gen';
+export type { AccessLevel, ActiveCallsResponse, ActiveCallSummary, ActivityType, AddFavoriteData, AddFavoriteError, AddFavoriteErrors, AddFavoriteRequest, AddFavoriteResponse, AddFavoriteResponses, AddParticipantsData, AddParticipantsError, AddParticipantsErrors, AddParticipantsRequest, AddParticipantsResponses, AddPinHandlerData, AddPinHandlerError, AddPinHandlerErrors, AddPinHandlerResponse, AddPinHandlerResponses, AddPinRequest, Agent, AgentChannelScope, AgentMcpServer, AgentMcpServers, Anchor, AnchorId, AnchorRequest, AnchorResponse, AnnotationIncrementalUpdate, ApiActivity, ApiAttachmentChannelReference, ApiAttachmentEntityReference, ApiAttachmentGenericReference, ApiChannelAttachment, ApiChannelAttachmentsPage, ApiChannelContextMessage, ApiChannelDetail, ApiChannelListMessage, ApiChannelListPage, ApiChannelListParticipant, ApiChannelListType, ApiChannelMessage, ApiChannelMessageKind, ApiChannelMessagesPage, ApiChannelParticipant, ApiChannelWithLatest, ApiCountedReaction, ApiEntityFilterAst, ApiGroupByField, ApiGroupMeta, ApiMessageAttachment, ApiMessageSender, ApiMessageSenderType, ApiParticipantListRole, ApiParticipantRole, ApiPropertyEntityType, ApiResolvedChannelMessage, ApiThreadInfo, ApiThreadReply, ApproveHarnessPairingData, ApproveHarnessPairingError, ApproveHarnessPairingErrors, ApproveHarnessPairingResponse, ApproveHarnessPairingResponses, ApprovePairingRequest, AttendeeResponseStatus, BasicDocument, BasicDocumentSubType, BomPart, Bot, BotChannel, BotChannelType, BotId, BotKind, BotOwner, BotToken, BranchNameResponse, BTreeMap, BulkWakeupRequest, BulkWakeupResponse, BulkWakeupSyncServiceDocumentsData, BulkWakeupSyncServiceDocumentsErrors, BulkWakeupSyncServiceDocumentsResponse, BulkWakeupSyncServiceDocumentsResponses, CalendarAttendee, CalendarEvent, CalendarEventFilters, CalendarEventSourceContent, CalendarMentionEvent, CalendarMentionPreviewItem, CalendarMentionPreviewKind, CalendarMentionPreviewRequest, CalendarMentionPreviewRequestItem, CalendarMentionPreviewResponse, CalendarOccurrence, CalendarOccurrenceItem, CalendarOccurrenceResponse, CalendarSyncStatus, CallActiveResponse, CallFilters, CallRecord, CallRecordParticipant, CallRecordPreview, CallRecordPreviewData, CallRecordTranscriptSegment, CallStatus, CallTokenResponse, CallWebhookData, CallWebhookError, CallWebhookErrors, CallWebhookResponses, Channel, ChannelCreatedMetadata, ChannelDeletedMetadata, ChannelEventAttachment, ChannelFilters, ChannelJoinCodeResponse, ChannelMentionedMetadata, ChannelMessage, ChannelMessageAttachmentCreatedMetadata, ChannelMessageAttachmentRemovedMetadata, ChannelMessageDeletedMetadata, ChannelMessageFilters, ChannelMessagePatchedMetadata, ChannelMessagePostedMetadata, ChannelParticipant, ChannelParticipantAddedMetadata, ChannelParticipantRemovedMetadata, ChannelPreview, ChannelPreviewData, ChannelSender, ChannelSharePermission, ChannelThreadFilters, ChannelTopicEvent, ChannelType, ChannelUpdatedMetadata, ChannelWebhookRequest, ChannelWebhookResponse, ChannelWithParticipants, Chat, ChatFilters, CheckActiveCallData, CheckActiveCallError, CheckActiveCallErrors, CheckActiveCallResponse, CheckActiveCallResponses, ClaimedPairing, ClaimHarnessPairingData, ClaimHarnessPairingError, ClaimHarnessPairingErrors, ClaimHarnessPairingResponse, ClaimHarnessPairingResponses, ClaimPairingRequest, ClientOptions, CloudStorageItemType, CollabSurfaceResponse, CollabSurfaceTokenResponse, Comment, CommentThread, ConferenceProvider, CopyDocumentData, CopyDocumentError, CopyDocumentErrors, CopyDocumentQueryParams, CopyDocumentRequest, CopyDocumentResponse, CopyDocumentResponse2, CopyDocumentResponses, CreateAgentData, CreateAgentError, CreateAgentErrors, CreateAgentRequest, CreateAgentResponse, CreateAgentResponses, CreateAnchorData, CreateAnchorError, CreateAnchorErrors, CreateAnchorResponse, CreateAnchorResponses, CreateBotRequest, CreateBulkDocumentResponse, CreateBulkDocumentResponseData, CreateChannelData, CreateChannelError, CreateChannelErrors, CreateChannelRequest, CreateChannelResponse, CreateChannelResponse2, CreateChannelResponses, CreateChannelScopedBotData, CreateChannelScopedBotError, CreateChannelScopedBotErrors, CreateChannelScopedBotRequest, CreateChannelScopedBotResponse, CreateChannelScopedBotResponse2, CreateChannelScopedBotResponses, CreateCollabSurfaceTokenData, CreateCollabSurfaceTokenError, CreateCollabSurfaceTokenErrors, CreateCollabSurfaceTokenResponse, CreateCollabSurfaceTokenResponses, CreateCommentData, CreateCommentError, CreateCommentErrors, CreateCommentRequest, CreateCommentResponse, CreateCommentResponse2, CreateCommentResponses, CreateCrmCommentData, CreateCrmCommentError, CreateCrmCommentErrors, CreateCrmCommentRequest, CreateCrmCommentResponse, CreateCrmCommentResponses, CreateCrmCompanyData, CreateCrmCompanyError, CreateCrmCompanyErrors, CreateCrmCompanyRequest, CreateCrmCompanyResponse, CreateCrmCompanyResponses, CreateCrmContactData, CreateCrmContactError, CreateCrmContactErrors, CreateCrmContactRequest, CreateCrmContactResponse, CreateCrmContactResponses, CreateDocumentData, CreateDocumentError, CreateDocumentErrors, CreateDocumentRequest, CreateDocumentResponse, CreateDocumentResponseData, CreateDocumentResponses, CreatedPairing, CreatedUserApiKey, CreateEntityMentionData, CreateEntityMentionError, CreateEntityMentionErrors, CreateEntityMentionRequest, CreateEntityMentionResponse, CreateEntityMentionResponse2, CreateEntityMentionResponses, CreateHarnessPairingData, CreateHarnessPairingError, CreateHarnessPairingErrors, CreateHarnessPairingResponse, CreateHarnessPairingResponses, CreateInstructionsDocumentResponse, CreateInstructionsHandlerData, CreateInstructionsHandlerError, CreateInstructionsHandlerErrors, CreateInstructionsHandlerResponse, CreateInstructionsHandlerResponses, CreateMarkdownDocumentRequest, CreateMarkdownDocumentResponse, CreateMarkdownHandlerData, CreateMarkdownHandlerError, CreateMarkdownHandlerErrors, CreateMarkdownHandlerResponse, CreateMarkdownHandlerResponses, CreatePairingRequest, CreateProjectHandlerData, CreateProjectHandlerError, CreateProjectHandlerErrors, CreateProjectHandlerResponse, CreateProjectHandlerResponses, CreateProjectRequest, CreateProjectResponse, CreateReminderData, CreateReminderError, CreateReminderErrors, CreateReminderRequest, CreateReminderResponse, CreateReminderResponses, CreateSkillHandlerData, CreateSkillHandlerError, CreateSkillHandlerErrors, CreateSkillHandlerResponse, CreateSkillHandlerResponses, CreateSkillRequest, CreateSkillResponse, CreateSnippetHandlerData, CreateSnippetHandlerError, CreateSnippetHandlerErrors, CreateSnippetHandlerResponse, CreateSnippetHandlerResponses, CreateSnippetRequest, CreateSnippetResponse, CreateTaskHandlerData, CreateTaskHandlerError, CreateTaskHandlerErrors, CreateTaskHandlerResponse, CreateTaskHandlerResponses, CreateTaskRequest, CreateTaskResponse, CreateUnthreadedAnchorRequest, CreateUnthreadedAnchorResponse, CreateUnthreadedPdfAnchorRequest, CreateUserApiKeyData, CreateUserApiKeyError, CreateUserApiKeyErrors, CreateUserApiKeyRequest, CreateUserApiKeyResponse, CreateUserApiKeyResponses, CreateViewHandlerData, CreateViewHandlerError, CreateViewHandlerErrors, CreateViewHandlerResponse, CreateViewHandlerResponses, CreateViewRequest, CreateWebhookData, CreateWebhookError, CreateWebhookErrors, CreateWebhookRequest, CreateWebhookResponse, CreateWebhookResponse2, CreateWebhookResponses, CrmComment, CrmCommentEntityType, CrmCommentThread, CrmCompanyFilters, CrmCompanyResponse, CrmContactResponse, CrmDomainResponse, CrmPermissionRole, CrmTeamSettingsResponse, CrmThread, CustomSpeakerAssignment, DataType, DeleteAnchorData, DeleteAnchorError, DeleteAnchorErrors, DeleteAnchorInfo, DeleteAnchorResponse, DeleteAnchorResponses, DeleteCallRecordData, DeleteCallRecordError, DeleteCallRecordErrors, DeleteCallRecordResponse, DeleteCallRecordResponses, DeleteChannelData, DeleteChannelError, DeleteChannelErrors, DeleteChannelResponse, DeleteChannelResponses, DeleteCollabSurfaceData, DeleteCollabSurfaceError, DeleteCollabSurfaceErrors, DeleteCollabSurfaceResponse, DeleteCollabSurfaceResponses, DeleteCommentData, DeleteCommentError, DeleteCommentErrors, DeleteCommentRequest, DeleteCommentResponse, DeleteCommentResponse2, DeleteCommentResponses, DeleteCrmCommentData, DeleteCrmCommentError, DeleteCrmCommentErrors, DeleteCrmCommentResponse, DeleteCrmCommentResponses, DeleteCrmCommentResult, DeleteDocumentData, DeleteDocumentError, DeleteDocumentErrors, DeleteDocumentResponse, DeleteDocumentResponses, DeleteEntityMentionData, DeleteEntityMentionError, DeleteEntityMentionErrors, DeleteEntityMentionResponse, DeleteEntityMentionResponse2, DeleteEntityMentionResponses, DeleteHarnessData, DeleteHarnessError, DeleteHarnessErrors, DeleteHarnessResponse, DeleteHarnessResponses, DeleteHistoryHandlerData, DeleteHistoryHandlerError, DeleteHistoryHandlerErrors, DeleteHistoryHandlerResponse, DeleteHistoryHandlerResponses, DeleteMessageData, DeleteMessageError, DeleteMessageErrors, DeleteMessageQuery, DeleteMessageResponse, DeleteMessageResponses, DeleteProjectHandlerData, DeleteProjectHandlerError, DeleteProjectHandlerErrors, DeleteProjectHandlerResponse, DeleteProjectHandlerResponses, DeleteReminderData, DeleteReminderError, DeleteReminderErrors, DeleteReminderResponse, DeleteReminderResponses, DeleteSelfHarnessData, DeleteSelfHarnessError, DeleteSelfHarnessErrors, DeleteSelfHarnessResponse, DeleteSelfHarnessResponses, DeleteThreadInfo, DeleteUnthreadedAnchorRequest, DeleteUnthreadedAnchorResponse, DeleteUnthreadedPdfAnchorRequest, DeleteUserApiKeyData, DeleteUserApiKeyError, DeleteUserApiKeyErrors, DeleteUserApiKeyResponse, DeleteUserApiKeyResponses, DeleteUserDocumentViewLocationData, DeleteUserDocumentViewLocationError, DeleteUserDocumentViewLocationErrors, DeleteUserDocumentViewLocationResponse, DeleteUserDocumentViewLocationResponses, DeleteViewHandlerData, DeleteViewHandlerError, DeleteViewHandlerErrors, DeleteViewHandlerResponses, DeleteWebhookData, DeleteWebhookError, DeleteWebhookErrors, DeleteWebhookResponse, DeleteWebhookResponses, DocumentBasic, DocumentContent, DocumentContentLocation, DocumentContentState, DocumentContentUploadedMetadata, DocumentCopiedMetadata, DocumentCreatedMetadata, DocumentDeletedMetadata, DocumentFilters, DocumentInteractionMetadata, DocumentMetadata, DocumentMetadataWithContent, DocumentPermissionsToken, DocumentPermissionsTokenRequest, DocumentPermissionsTokenResponse, DocumentPreview, DocumentPreviewData, DocumentPreviewDataSubType, DocumentPurgedMetadata, DocumentResponse, DocumentResponseMetadata, DocumentResponseMetadataWithContent, DocumentStorageServiceApiVersion, DocumentSubType, DocumentSyncContentUpdatedMetadata, DocumentTeamShareResponse, DocumentTopicEvent, DocumentUpdatedMetadata, EditAnchorData, EditAnchorError, EditAnchorErrors, EditAnchorRequest, EditAnchorResponse, EditAnchorResponse2, EditAnchorResponses, EditCallRecordData, EditCallRecordError, EditCallRecordErrors, EditCallRecordRequest, EditCallRecordResponse, EditCallRecordResponses, EditCallTranscriptData, EditCallTranscriptError, EditCallTranscriptErrors, EditCallTranscriptRequest, EditCallTranscriptResponse, EditCallTranscriptResponses, EditCommentData, EditCommentError, EditCommentErrors, EditCommentRequest, EditCommentResponse, EditCommentResponse2, EditCommentResponses, EditCrmCommentData, EditCrmCommentError, EditCrmCommentErrors, EditCrmCommentRequest, EditCrmCommentResponse, EditCrmCommentResponses, EditDocumentData, EditDocumentError, EditDocumentErrors, EditDocumentResponse, EditDocumentResponse2, EditDocumentResponses, EditDocumentServiceArgs, EditPdfAnchorRequest, EditPdfPlaceableCommentAnchorRequest, EditProjectV2Data, EditProjectV2Error, EditProjectV2Errors, EditProjectV2Response, EditProjectV2Responses, EditThreadV2Data, EditThreadV2Error, EditThreadV2Errors, EditThreadV2Response, EditThreadV2Responses, EmailFilters, EmptyResponse, EnsureCollabSurfaceData, EnsureCollabSurfaceError, EnsureCollabSurfaceErrors, EnsureCollabSurfaceRequest, EnsureCollabSurfaceResponse, EnsureCollabSurfaceResponses, EntityFilters, EntityPermission, EntityPermissionResponse, EntityReference, EntityType, ErrorResponse, EventReminderOverride, EventReminders, EventStatus, EventTime, EventTransparency, EventType, EventVisibility, ExcludedDefaultView, ExcludeDefaultViewHandlerData, ExcludeDefaultViewHandlerError, ExcludeDefaultViewHandlerErrors, ExcludeDefaultViewHandlerResponses, ExcludeDefaultViewRequest, ExportDocumentData, ExportDocumentError, ExportDocumentErrors, ExportDocumentResponse, ExportDocumentResponse2, ExportDocumentResponses, Favorite, FavoriteEntityRef, FavoritesList, FileSystemNodeWithIds, FileType, FileTypeUpdate, FolderItem, ForeignEntity, ForeignEntityFilters, GenericErrorResponse, GenericResponse, GenericSuccessResponse, GetActiveCallsData, GetActiveCallsError, GetActiveCallsErrors, GetActiveCallsResponse, GetActiveCallsResponses, GetActivityData, GetActivityError, GetActivityErrors, GetActivityResponse, GetActivityResponses, GetAttachmentReferencesData, GetAttachmentReferencesError, GetAttachmentReferencesErrors, GetAttachmentReferencesResponse, GetAttachmentReferencesResponse2, GetAttachmentReferencesResponses, GetBatchCallRecordPreviewData, GetBatchCallRecordPreviewError, GetBatchCallRecordPreviewErrors, GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse, GetBatchCallRecordPreviewResponse2, GetBatchCallRecordPreviewResponses, GetBatchChannelPreviewData, GetBatchChannelPreviewError, GetBatchChannelPreviewErrors, GetBatchChannelPreviewRequest, GetBatchChannelPreviewResponse, GetBatchChannelPreviewResponse2, GetBatchChannelPreviewResponses, GetBatchPreviewHandlerData, GetBatchPreviewHandlerError, GetBatchPreviewHandlerErrors, GetBatchPreviewHandlerResponse, GetBatchPreviewHandlerResponses, GetBatchPreviewRequest, GetBatchPreviewResponse, GetBatchProjectPreviewData, GetBatchProjectPreviewError, GetBatchProjectPreviewErrors, GetBatchProjectPreviewRequest, GetBatchProjectPreviewResponse, GetBatchProjectPreviewResponse2, GetBatchProjectPreviewResponses, GetCallRecordData, GetCallRecordError, GetCallRecordErrors, GetCallRecordResponse, GetCallRecordResponses, GetChannelAttachmentsData, GetChannelAttachmentsError, GetChannelAttachmentsErrors, GetChannelAttachmentsResponse, GetChannelAttachmentsResponses, GetChannelData, GetChannelError, GetChannelErrors, GetChannelJoinLinkData, GetChannelJoinLinkError, GetChannelJoinLinkErrors, GetChannelJoinLinkResponse, GetChannelJoinLinkResponses, GetChannelMessagesData, GetChannelMessagesError, GetChannelMessagesErrors, GetChannelMessagesResponse, GetChannelMessagesResponses, GetChannelParticipantsData, GetChannelParticipantsError, GetChannelParticipantsErrors, GetChannelParticipantsResponse, GetChannelParticipantsResponses, GetChannelResponse, GetChannelResponses, GetChannelsData, GetChannelsError, GetChannelsErrors, GetChannelsResponse, GetChannelsResponses, GetCollabSurfaceData, GetCollabSurfaceError, GetCollabSurfaceErrors, GetCollabSurfaceResponse, GetCollabSurfaceResponses, GetCompanyData, GetCompanyError, GetCompanyErrors, GetCompanyResponse, GetCompanyResponses, GetContactByEmailData, GetContactByEmailError, GetContactByEmailErrors, GetContactByEmailResponse, GetContactByEmailResponse2, GetContactByEmailResponses, GetContactData, GetContactError, GetContactErrors, GetContactResponse, GetContactResponses, GetCrmTeamSettingsData, GetCrmTeamSettingsError, GetCrmTeamSettingsErrors, GetCrmTeamSettingsResponse, GetCrmTeamSettingsResponses, GetDocumentAnchorsData, GetDocumentAnchorsError, GetDocumentAnchorsErrors, GetDocumentAnchorsResponse, GetDocumentAnchorsResponses, GetDocumentBranchNameData, GetDocumentBranchNameError, GetDocumentBranchNameErrors, GetDocumentBranchNameResponse, GetDocumentBranchNameResponses, GetDocumentByTeamSlugData, GetDocumentByTeamSlugError, GetDocumentByTeamSlugErrors, GetDocumentByTeamSlugResponse, GetDocumentByTeamSlugResponses, GetDocumentCommentsData, GetDocumentCommentsError, GetDocumentCommentsErrors, GetDocumentCommentsResponse, GetDocumentCommentsResponses, GetDocumentData, GetDocumentError, GetDocumentErrors, GetDocumentGithubPullRequestsData, GetDocumentGithubPullRequestsError, GetDocumentGithubPullRequestsErrors, GetDocumentGithubPullRequestsResponse, GetDocumentGithubPullRequestsResponses, GetDocumentKeyResponse, GetDocumentKeyResponseData, GetDocumentListHandlerData, GetDocumentListHandlerError, GetDocumentListHandlerErrors, GetDocumentListHandlerResponse, GetDocumentListHandlerResponses, GetDocumentListResult, GetDocumentLocationV3Data, GetDocumentLocationV3Error, GetDocumentLocationV3Errors, GetDocumentLocationV3Response, GetDocumentLocationV3Responses, GetDocumentPermissionsResponseDataV2, GetDocumentPermissionsTokenData, GetDocumentPermissionsTokenError, GetDocumentPermissionsTokenErrors, GetDocumentPermissionsTokenResponse, GetDocumentPermissionsTokenResponses, GetDocumentPermissionsV2Data, GetDocumentPermissionsV2Error, GetDocumentPermissionsV2Errors, GetDocumentPermissionsV2Response, GetDocumentPermissionsV2Responses, GetDocumentProcessingResult, GetDocumentProcessingResultData, GetDocumentProcessingResultError, GetDocumentProcessingResultErrors, GetDocumentProcessingResultResponse, GetDocumentProcessingResultResponse2, GetDocumentProcessingResultResponses, GetDocumentResponse, GetDocumentResponse2, GetDocumentResponseData, GetDocumentResponses, GetDocumentSearchResponse, GetDocumentShortIdData, GetDocumentShortIdError, GetDocumentShortIdErrors, GetDocumentShortIdResponse, GetDocumentShortIdResponses, GetDocumentsResponse, GetDocumentTeamShareData, GetDocumentTeamShareError, GetDocumentTeamShareErrors, GetDocumentTeamShareResponse, GetDocumentTeamShareResponses, GetDocumentUserAccessLevelResponse, GetDocumentVersionData, GetDocumentVersionError, GetDocumentVersionErrors, GetDocumentVersionResponse, GetDocumentVersionResponses, GetDocumentViewsHandlerData, GetDocumentViewsHandlerError, GetDocumentViewsHandlerErrors, GetDocumentViewsHandlerResponse, GetDocumentViewsHandlerResponses, GetEntityPermissionData, GetEntityPermissionErrors, GetEntityPermissionResponse, GetEntityPermissionResponses, GetForeignEntityData, GetForeignEntityError, GetForeignEntityErrors, GetForeignEntityResponse, GetForeignEntityResponses, GetHarnessPairingData, GetHarnessPairingError, GetHarnessPairingErrors, GetHarnessPairingResponse, GetHarnessPairingResponses, GetHistoryHandlerData, GetHistoryHandlerError, GetHistoryHandlerErrors, GetHistoryHandlerResponse, GetHistoryHandlerResponses, GetInstructionsDocumentResponse, GetInstructionsHandlerData, GetInstructionsHandlerError, GetInstructionsHandlerErrors, GetInstructionsHandlerResponse, GetInstructionsHandlerResponses, GetItemsSoupData, GetItemsSoupError, GetItemsSoupErrors, GetItemsSoupResponse, GetItemsSoupResponses, GetLocationHandlerData, GetLocationHandlerError, GetLocationHandlerErrors, GetLocationHandlerResponse, GetLocationHandlerResponses, GetMessageWithContextData, GetMessageWithContextError, GetMessageWithContextErrors, GetMessageWithContextResponse, GetMessageWithContextResponse2, GetMessageWithContextResponses, GetOrCreateAction, GetOrCreateCallData, GetOrCreateCallError, GetOrCreateCallErrors, GetOrCreateCallResponse, GetOrCreateCallResponses, GetOrCreateChannelResponse, GetOrCreateDmData, GetOrCreateDmError, GetOrCreateDmErrors, GetOrCreateDmRequest, GetOrCreateDmResponse, GetOrCreateDmResponses, GetOrCreatePrivateData, GetOrCreatePrivateError, GetOrCreatePrivateErrors, GetOrCreatePrivateRequest, GetOrCreatePrivateResponse, GetOrCreatePrivateResponses, GetPendingProjectsHandlerData, GetPendingProjectsHandlerError, GetPendingProjectsHandlerErrors, GetPendingProjectsHandlerResponse, GetPendingProjectsHandlerResponses, GetPinsHandlerData, GetPinsHandlerError, GetPinsHandlerErrors, GetPinsHandlerResponse, GetPinsHandlerResponses, GetPinsResponse, GetProjectContentHandlerData, GetProjectContentHandlerError, GetProjectContentHandlerErrors, GetProjectContentHandlerResponse, GetProjectContentHandlerResponses, GetProjectContentResponse, GetProjectHandlerData, GetProjectHandlerError, GetProjectHandlerErrors, GetProjectHandlerResponse, GetProjectHandlerResponses, GetProjectPermissionsV2Data, GetProjectPermissionsV2Error, GetProjectPermissionsV2Errors, GetProjectPermissionsV2Response, GetProjectPermissionsV2Responses, GetProjectResponse, GetProjectResponseData, GetProjectsHandlerData, GetProjectsHandlerError, GetProjectsHandlerErrors, GetProjectsHandlerResponse, GetProjectsHandlerResponses, GetProjectsResponse, GetProjectUserAccessLevelData, GetProjectUserAccessLevelError, GetProjectUserAccessLevelErrors, GetProjectUserAccessLevelResponse, GetProjectUserAccessLevelResponses, GetReminderData, GetReminderError, GetReminderErrors, GetReminderResponse, GetReminderResponses, GetRingStatusData, GetRingStatusError, GetRingStatusErrors, GetRingStatusResponse, GetRingStatusResponses, GetSelfBotData, GetSelfBotError, GetSelfBotErrors, GetSelfBotResponse, GetSelfBotResponses, GetSelfHarnessData, GetSelfHarnessError, GetSelfHarnessErrors, GetSelfHarnessResponse, GetSelfHarnessResponses, GetSystemSkillsHandlerData, GetSystemSkillsHandlerError, GetSystemSkillsHandlerErrors, GetSystemSkillsHandlerResponse, GetSystemSkillsHandlerResponses, GetThreadRepliesData, GetThreadRepliesError, GetThreadRepliesErrors, GetThreadRepliesResponse, GetThreadRepliesResponses, GetUserDocumentsHandlerData, GetUserDocumentsHandlerError, GetUserDocumentsHandlerErrors, GetUserDocumentsHandlerResponse, GetUserDocumentsHandlerResponses, GetUserDocumentViewLocationData, GetUserDocumentViewLocationError, GetUserDocumentViewLocationErrors, GetUserDocumentViewLocationResponse, GetUserDocumentViewLocationResponses, GetUserHistoryResponse, GetViewsHandlerData, GetViewsHandlerError, GetViewsHandlerErrors, GetViewsHandlerResponse, GetViewsHandlerResponses, GetWebhookData, GetWebhookError, GetWebhookErrors, GetWebhookResponse, GetWebhookResponses, GithubPullRequest, GithubPullRequestCheckRun, GithubPullRequestComment, GithubPullRequestsResponse, GroupedInitialParams, GroupedPageParams, GroupedSoupGroupPage, GroupedSoupInitialPage, GroupedSoupPage, GroupedSoupSort, HandlerData, HandlerError, HandlerErrors, HandlerResponse, HandlerResponses, Harness, HarnessAgent, HarnessId, HarnessOwner, HarnessSession, HashMap, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, HighlightType, IngestTranscriptData, IngestTranscriptError, IngestTranscriptErrors, IngestTranscriptResponses, InitializeUserDocumentsData, InitializeUserDocumentsError, InitializeUserDocumentsErrors, InitializeUserDocumentsResponse, InitializeUserDocumentsResponses, InstallSyncData, InstallSyncErrors, InteractionReason, Item, ItemWithUserAccessLevel, JobProcessingResultHandlerData, JobProcessingResultHandlerError, JobProcessingResultHandlerErrors, JobProcessingResultHandlerResponse, JobProcessingResultHandlerResponses, JoinChannelByCodeData, JoinChannelByCodeError, JoinChannelByCodeErrors, JoinChannelByCodeResponses, JoinChannelData, JoinChannelError, JoinChannelErrors, JoinChannelResponses, LatestMessage, LeaveCallResponse, LeaveChannelData, LeaveChannelError, LeaveChannelErrors, LeaveChannelResponses, LeaveOrEndCallData, LeaveOrEndCallError, LeaveOrEndCallErrors, LeaveOrEndCallResponse, LeaveOrEndCallResponses, LinkShare, ListAgentsData, ListAgentsError, ListAgentsErrors, ListAgentsResponse, ListAgentsResponses, ListBotChannelsData, ListBotChannelsError, ListBotChannelsErrors, ListBotChannelsResponse, ListBotChannelsResponses, ListCompanyContactsData, ListCompanyContactsError, ListCompanyContactsErrors, ListCompanyContactsResponse, ListCompanyContactsResponses, ListCrmCommentsData, ListCrmCommentsError, ListCrmCommentsErrors, ListCrmCommentsResponse, ListCrmCommentsResponses, ListFavoritesData, ListFavoritesError, ListFavoritesErrors, ListFavoritesResponse, ListFavoritesResponses, ListHarnessAgentsData, ListHarnessAgentsError, ListHarnessAgentsErrors, ListHarnessAgentsResponse, ListHarnessAgentsResponses, ListHarnessesData, ListHarnessesError, ListHarnessesErrors, ListHarnessesResponse, ListHarnessesResponses, ListHarnessSessionsData, ListHarnessSessionsError, ListHarnessSessionsErrors, ListHarnessSessionsResponse, ListHarnessSessionsResponses, ListOccurrencesData, ListOccurrencesErrors, ListOccurrencesResponse, ListOccurrencesResponses, ListRemindersData, ListRemindersError, ListRemindersErrors, ListRemindersResponse, ListRemindersResponses, ListTeamOutOfOfficeData, ListTeamOutOfOfficeErrors, ListTeamOutOfOfficeResponse, ListTeamOutOfOfficeResponses, ListUserApiKeysData, ListUserApiKeysError, ListUserApiKeysErrors, ListUserApiKeysResponse, ListUserApiKeysResponses, ListWebhooksData, ListWebhooksError, ListWebhooksErrors, ListWebhooksResponse, ListWebhooksResponse2, ListWebhooksResponses, LocationResponseData, LocationResponseV3, MacroUserIdStr, MentionPreviewsData, MentionPreviewsErrors, MentionPreviewsResponse, MentionPreviewsResponses, Mentions, NewChannelAttachment, NotificationFilters, PairingDetails, Params, ParticipantRole, PatchBotRequest, PatchChannelData, PatchChannelError, PatchChannelErrors, PatchChannelRequest, PatchChannelResponse, PatchChannelResponses, PatchMessageData, PatchMessageError, PatchMessageErrors, PatchMessageRequest, PatchMessageResponse, PatchMessageResponses, PatchProjectRequestV2, PatchThreadRequestV2, PatchViewHandlerData, PatchViewHandlerError, PatchViewHandlerErrors, PatchViewHandlerResponses, PatchWebhookData, PatchWebhookError, PatchWebhookErrors, PatchWebhookRequest, PatchWebhookResponse, PatchWebhookResponses, PdfAnchor, PdfAnchorId, PdfAnchorRequest, PdfHighlightAnchor, PdfHighlightAnchorRequest, PdfHighlightRect, PdfHighlightRectAnchorRequest, PdfPlaceableCommentAnchor, PdfPlaceableCommentAnchorRequest, PendingClaimResponse, PermanentlyDeleteDocumentData, PermanentlyDeleteDocumentError, PermanentlyDeleteDocumentErrors, PermanentlyDeleteDocumentResponse, PermanentlyDeleteDocumentResponses, PermanentlyDeleteProjectData, PermanentlyDeleteProjectError, PermanentlyDeleteProjectErrors, PermanentlyDeleteProjectResponse, PermanentlyDeleteProjectResponses, PinnedItem, PinRequest, PostActivityData, PostActivityError, PostActivityErrors, PostActivityRequest, PostActivityResponse, PostActivityResponses, PostChannelBotWebhookData, PostChannelBotWebhookError, PostChannelBotWebhookErrors, PostChannelBotWebhookResponse, PostChannelBotWebhookResponses, PostChannelMessagesData, PostChannelMessagesError, PostChannelMessagesErrors, PostChannelMessagesResponse, PostChannelMessagesResponses, PostGroupedSoupAstGroupPageRequest, PostGroupedSoupAstInitialRequest, PostGroupedSoupAstRequest, PostItemsSoupAstData, PostItemsSoupAstError, PostItemsSoupAstErrors, PostItemsSoupAstGroupedData, PostItemsSoupAstGroupedError, PostItemsSoupAstGroupedErrors, PostItemsSoupAstGroupedResponse, PostItemsSoupAstGroupedResponses, PostItemsSoupAstResponse, PostItemsSoupAstResponses, PostItemsSoupData, PostItemsSoupError, PostItemsSoupErrors, PostItemsSoupResponse, PostItemsSoupResponses, PostMessageData, PostMessageError, PostMessageErrors, PostMessageRequest, PostMessageResponse, PostMessageResponse2, PostMessageResponses, PostReactionData, PostReactionError, PostReactionErrors, PostReactionRequest, PostReactionResponse, PostReactionResponses, PostSoupAstRequest, PostSoupRequest, PostTypingData, PostTypingError, PostTypingErrors, PostTypingRequest, PostTypingResponse, PostTypingResponses, PresaveDocumentHandlerData, PresaveDocumentHandlerError, PresaveDocumentHandlerErrors, PresaveDocumentHandlerResponse, PresaveDocumentHandlerResponses, PreSaveDocumentRequest, PreSaveDocumentResponse, PreSaveDocumentResponseData, PresignedUrl, Project, ProjectDeleteResponseData, ProjectDocumentStatus, ProjectFilters, ProjectPreview, ProjectPreviewData, PropertyDefinition, PropertyFilter, PropertyInput, PropertyOwner, PropertyValue, PutCrmTeamSettingsData, PutCrmTeamSettingsError, PutCrmTeamSettingsErrors, PutCrmTeamSettingsResponse, PutCrmTeamSettingsResponses, ReactionAction, RecentlyDeletedData, RecentlyDeletedError, RecentlyDeletedErrors, RecentlyDeletedResponse, RecentlyDeletedResponseData, RecentlyDeletedResponses, Reminder, ReminderFilters, ReminderSchedule, RemindersList, RemoveBotFromChannelByBotData, RemoveBotFromChannelByBotError, RemoveBotFromChannelByBotErrors, RemoveBotFromChannelByBotResponse, RemoveBotFromChannelByBotResponses, RemoveFavoriteByEntityData, RemoveFavoriteByEntityError, RemoveFavoriteByEntityErrors, RemoveFavoriteByEntityResponses, RemoveParticipantsData, RemoveParticipantsError, RemoveParticipantsErrors, RemoveParticipantsRequest, RemoveParticipantsResponses, RemovePinHandlerData, RemovePinHandlerError, RemovePinHandlerErrors, RemovePinHandlerResponse, RemovePinHandlerResponses, ReorderFavoritesData, ReorderFavoritesError, ReorderFavoritesErrors, ReorderFavoritesRequest, ReorderFavoritesResponses, ReorderPinRequest, ReorderPinsHandlerData, ReorderPinsHandlerError, ReorderPinsHandlerErrors, ReorderPinsHandlerResponse, ReorderPinsHandlerResponses, RequestedHarnessScope, ResolveChannelMessageData, ResolveChannelMessageError, ResolveChannelMessageErrors, ResolveChannelMessageResponse, ResolveChannelMessageResponses, RevertDeleteDocumentData, RevertDeleteDocumentError, RevertDeleteDocumentErrors, RevertDeleteDocumentResponse, RevertDeleteDocumentResponses, RevertDeleteProjectData, RevertDeleteProjectError, RevertDeleteProjectErrors, RevertDeleteProjectResponse, RevertDeleteProjectResponses, RingStatus, RingStatusResponse, S3ObjectInfo, SaveBomPart, SaveDocumentHandlerData, SaveDocumentHandlerError, SaveDocumentHandlerErrors, SaveDocumentHandlerResponse, SaveDocumentHandlerResponses, SaveDocumentRequest, SaveDocumentResponse, SaveDocumentResponseData, SetCompanyHiddenData, SetCompanyHiddenError, SetCompanyHiddenErrors, SetCompanyHiddenRequest, SetCompanyHiddenResponse, SetCompanyHiddenResponses, SetCompanyNameRequest, SetContactHiddenData, SetContactHiddenError, SetContactHiddenErrors, SetContactHiddenRequest, SetContactHiddenResponse, SetContactHiddenResponses, SetContactNameRequest, SetCrmCompanyNameData, SetCrmCompanyNameError, SetCrmCompanyNameErrors, SetCrmCompanyNameResponse, SetCrmCompanyNameResponses, SetCrmContactNameData, SetCrmContactNameError, SetCrmContactNameErrors, SetCrmContactNameResponse, SetCrmContactNameResponses, SetDocumentTeamShareData, SetDocumentTeamShareError, SetDocumentTeamShareErrors, SetDocumentTeamShareRequest, SetDocumentTeamShareResponse, SetDocumentTeamShareResponses, SetEmailSyncData, SetEmailSyncError, SetEmailSyncErrors, SetEmailSyncRequest, SetEmailSyncResponse, SetEmailSyncResponses, SetPropertyValue, SharedEmailFilter, SharePermissionV2, ShortIdResponse, SimpleMention, SimpleSaveData, SimpleSaveError, SimpleSaveErrors, SimpleSaveResponse, SimpleSaveResponses, SoupApiItem, SoupApiSort, SoupApiSortDirection, SoupAttachment, SoupCalendarEventSoupPropertiesField, SoupCalendarEventTime, SoupCallRecordParticipant, SoupCallRecordSoupPropertiesField, SoupChannel, SoupChannelThread, SoupChatSoupPropertiesField, SoupContact, SoupCountedReaction, SoupCrmCompanySoupPropertiesField, SoupCrmDomain, SoupDocumentSoupPropertiesField, SoupDocumentSubType, SoupEmailThreadPreview, SoupEnrichedEmailThreadPreviewSoupPropertiesField, SoupForeignEntity, SoupItem, SoupLabel, SoupLabelListVisibility, SoupLabelType, SoupMessageAttachment, SoupMessageListVisibility, SoupMessageSender, SoupMessageSenderType, SoupPage, SoupProjectSoupPropertiesField, SoupPropertiesField, SoupProperty, SoupReminderReference, SoupReminderSchedule, SoupReminderSoupPropertiesField, SoupThreadInfo, SoupThreadReply, StarterDocumentsResponse, StreamEventsData, StreamEventsError, StreamEventsErrors, StreamEventsResponse, StreamEventsResponses, String, SuccessResponse, SurfaceState, SyncServiceVersionId, SystemSkillSummary, TagFilterMode, TaskFilters, TeamOutOfOfficeItem, TeamOutOfOfficeResponse, TeamRole, Thread, ThreadResponse, ToggleShareWithTeamData, ToggleShareWithTeamError, ToggleShareWithTeamErrors, ToggleShareWithTeamResponse, ToggleShareWithTeamResponses, TranscriptSegmentRequest, TypedSuccessResponse, TypedSuccessResponseGetDocumentResponseData, TypingAction, UnthreadedPdfUuidRequest, UpdateAgentData, UpdateAgentError, UpdateAgentErrors, UpdateAgentRequest, UpdateAgentResponse, UpdateAgentResponses, UpdateChannelSharePermission, UpdateCrmTeamSettingsRequest, UpdateOperation, UpdateReminderData, UpdateReminderError, UpdateReminderErrors, UpdateReminderRequest, UpdateReminderResponse, UpdateReminderResponses, UpdateSharePermissionRequestV2, UploadDocumentStatus, UploadExtractFolderHandlerData, UploadExtractFolderHandlerError, UploadExtractFolderHandlerErrors, UploadExtractFolderHandlerResponse, UploadExtractFolderHandlerResponses, UploadExtractFolderRequest, UploadFolderHandlerData, UploadFolderHandlerError, UploadFolderHandlerErrors, UploadFolderHandlerResponse, UploadFolderHandlerResponses, UploadFolderRequest, UpsertHistoryHandlerData, UpsertHistoryHandlerError, UpsertHistoryHandlerErrors, UpsertHistoryHandlerResponse, UpsertHistoryHandlerResponses, UpsertUserDocumentViewLocationData, UpsertUserDocumentViewLocationError, UpsertUserDocumentViewLocationErrors, UpsertUserDocumentViewLocationRequest, UpsertUserDocumentViewLocationResponse, UpsertUserDocumentViewLocationResponses, UserApiKeyId, UserApiKeyInfo, UserApiKeysList, UserDocumentsResponse, UserDocumentViewLocation, UserDocumentViewLocationResponse, UserPinsResponse, UserViewsResponse, ValidateDocumentPermissionsTokenData, ValidateDocumentPermissionsTokenError, ValidateDocumentPermissionsTokenErrors, ValidateDocumentPermissionsTokenResponse, ValidateDocumentPermissionsTokenResponses, ValidateWebhookData, ValidateWebhookError, ValidateWebhookErrors, ValidateWebhookResponse, ValidateWebhookResponse2, ValidateWebhookResponses, Vec, View, ViewPatch, ViewsResponse, Webhook, WebhookEvent, WebhookFilter, WebhookScope, WebhookStatus, WebhookValidationTestEvent, WithCallId, WithChannelId, WithDocumentId, WithProjectId } from './types.gen';
diff --git a/packages/sdk/generated/storage/types.gen.ts b/packages/sdk/generated/storage/types.gen.ts
index 6f819730a9..017ee4fb75 100644
--- a/packages/sdk/generated/storage/types.gen.ts
+++ b/packages/sdk/generated/storage/types.gen.ts
@@ -1323,6 +1323,9 @@ export type CalendarAttendee = {
/**
* A stable, first-class Macro calendar event entity.
+ *
+ * Content fields hold the canonical source's values: the account's primary
+ * calendar copy when one is synced, else the freshest remaining copy.
*/
export type CalendarEvent = {
/**
@@ -1373,7 +1376,7 @@ export type CalendarEvent = {
*/
id: string;
/**
- * Whether the current user can edit the canonical source.
+ * Whether the canonical source's calendar prohibits editing it.
*/
isReadOnly: boolean;
/**
@@ -1406,6 +1409,13 @@ export type CalendarEvent = {
* Provider/iCalendar sequence number.
*/
sequence: number;
+ /**
+ * Content of every active copy of this event, canonical first: the
+ * primary calendar's copy, then the freshest. A client picks the copy
+ * whose calendar it is showing and falls back to the first. Populated
+ * only on the read path, so stored projections omit it.
+ */
+ sources?: Array<CalendarEventSourceContent>;
/**
* Event status.
*/
@@ -1462,6 +1472,62 @@ export type CalendarEventFilters = {
statuses?: Array<string>;
};
+/**
+ * The content one provider copy of an event carries.
+ *
+ * Google keeps these fields per calendar copy: a shared calendar's copy of a
+ * member's event can have its own title, type, reminders, and access role.
+ * The entity holds its canonical source's values. Every other copy's values
+ * are read from here so a client can show the copy that belongs to the
+ * calendar being viewed.
+ */
+export type CalendarEventSourceContent = {
+ /**
+ * Calendar this copy lives on.
+ */
+ calendarId: string;
+ /**
+ * Provider-reported creator email.
+ */
+ creatorEmail?: string | null;
+ /**
+ * Provider-reported creator display name.
+ */
+ creatorName?: string | null;
+ /**
+ * Optional event body.
+ */
+ description?: string | null;
+ /**
+ * Provider event type.
+ */
+ eventType: EventType;
+ /**
+ * Whether the calendar's access role prohibits editing this copy.
+ */
+ isReadOnly: boolean;
+ /**
+ * Optional physical or virtual location label.
+ */
+ location?: string | null;
+ /**
+ * Reminder configuration of this copy.
+ */
+ reminders: EventReminders;
+ /**
+ * Display title.
+ */
+ title: string;
+ /**
+ * Availability behavior.
+ */
+ transparency: EventTransparency;
+ /**
+ * Event visibility.
+ */
+ visibility: EventVisibility;
+};
+
/**
* Meeting-level fields shown in a calendar event mention preview, taken from
* the requester's own projection of the meeting.
diff --git a/packages/sdk/specs/email.json b/packages/sdk/specs/email.json
index 3e4dd3f746..5166b29ae5 100644
--- a/packages/sdk/specs/email.json
+++ b/packages/sdk/specs/email.json
@@ -130,6 +130,16 @@
"format": "uuid"
}
},
+ {
+ "name": "calendarId",
+ "in": "query",
+ "description": "Calendar whose copy of the event is deleted, for an event synced from\nmore than one calendar. Omit to delete the canonical copy.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "uuid"
+ }
+ },
{
"name": "scope",
"in": "query",
@@ -4505,7 +4515,7 @@
},
"CalendarEvent": {
"type": "object",
- "description": "A stable, first-class Macro calendar event entity.",
+ "description": "A stable, first-class Macro calendar event entity.\n\nContent fields hold the canonical source's values: the account's primary\ncalendar copy when one is synced, else the freshest remaining copy.",
"required": [
"id",
"ownerId",
@@ -4582,7 +4592,7 @@
},
"isReadOnly": {
"type": "boolean",
- "description": "Whether the current user can edit the canonical source."
+ "description": "Whether the canonical source's calendar prohibits editing it."
},
"location": {
"type": ["string", "null"],
@@ -4617,6 +4627,13 @@
"description": "Provider/iCalendar sequence number.",
"minimum": 0
},
+ "sources": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CalendarEventSourceContent"
+ },
+ "description": "Content of every active copy of this event, canonical first: the\nprimary calendar's copy, then the freshest. A client picks the copy\nwhose calendar it is showing and falls back to the first. Populated\nonly on the read path, so stored projections omit it."
+ },
"status": {
"$ref": "#/components/schemas/EventStatus",
"description": "Event status."
@@ -4644,6 +4661,66 @@
}
}
},
+ "CalendarEventSourceContent": {
+ "type": "object",
+ "description": "The content one provider copy of an event carries.\n\nGoogle keeps these fields per calendar copy: a shared calendar's copy of a\nmember's event can have its own title, type, reminders, and access role.\nThe entity holds its canonical source's values. Every other copy's values\nare read from here so a client can show the copy that belongs to the\ncalendar being viewed.",
+ "required": [
+ "calendarId",
+ "title",
+ "eventType",
+ "visibility",
+ "transparency",
+ "isReadOnly",
+ "reminders"
+ ],
+ "properties": {
+ "calendarId": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Calendar this copy lives on."
+ },
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
+ "description": {
+ "type": ["string", "null"],
+ "description": "Optional event body."
+ },
+ "eventType": {
+ "$ref": "#/components/schemas/EventType",
+ "description": "Provider event type."
+ },
+ "isReadOnly": {
+ "type": "boolean",
+ "description": "Whether the calendar's access role prohibits editing this copy."
+ },
+ "location": {
+ "type": ["string", "null"],
+ "description": "Optional physical or virtual location label."
+ },
+ "reminders": {
+ "$ref": "#/components/schemas/EventReminders",
+ "description": "Reminder configuration of this copy."
+ },
+ "title": {
+ "type": "string",
+ "description": "Display title."
+ },
+ "transparency": {
+ "$ref": "#/components/schemas/EventTransparency",
+ "description": "Availability behavior."
+ },
+ "visibility": {
+ "$ref": "#/components/schemas/EventVisibility",
+ "description": "Event visibility."
+ }
+ }
+ },
"CalendarMutationApiError": {
"type": "object",
"description": "HTTP error body returned by calendar mutation endpoints.",
@@ -5922,6 +5999,11 @@
"description": "Request body setting the requester's RSVP on an event.",
"required": ["response"],
"properties": {
+ "calendarId": {
+ "type": ["string", "null"],
+ "format": "uuid",
+ "description": "Calendar whose copy of the event is answered, for an event synced\nfrom more than one calendar. Omit to answer on the canonical copy."
+ },
"recurrenceId": {
"type": ["string", "null"],
"description": "Original-start key of the occurrence the response targets."
@@ -6205,6 +6287,11 @@
},
"description": "Replacement attendee list."
},
+ "calendarId": {
+ "type": ["string", "null"],
+ "format": "uuid",
+ "description": "Calendar whose copy of the event is patched, for an event synced from\nmore than one calendar. Omit to patch the canonical copy."
+ },
"conference": {
"oneOf": [
{
diff --git a/packages/sdk/specs/storage.json b/packages/sdk/specs/storage.json
index 3f64f2a747..9ace1dd09d 100644
--- a/packages/sdk/specs/storage.json
+++ b/packages/sdk/specs/storage.json
@@ -14478,7 +14478,7 @@
},
"CalendarEvent": {
"type": "object",
- "description": "A stable, first-class Macro calendar event entity.",
+ "description": "A stable, first-class Macro calendar event entity.\n\nContent fields hold the canonical source's values: the account's primary\ncalendar copy when one is synced, else the freshest remaining copy.",
"required": [
"id",
"ownerId",
@@ -14555,7 +14555,7 @@
},
"isReadOnly": {
"type": "boolean",
- "description": "Whether the current user can edit the canonical source."
+ "description": "Whether the canonical source's calendar prohibits editing it."
},
"location": {
"type": ["string", "null"],
@@ -14590,6 +14590,13 @@
"description": "Provider/iCalendar sequence number.",
"minimum": 0
},
+ "sources": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CalendarEventSourceContent"
+ },
+ "description": "Content of every active copy of this event, canonical first: the\nprimary calendar's copy, then the freshest. A client picks the copy\nwhose calendar it is showing and falls back to the first. Populated\nonly on the read path, so stored projections omit it."
+ },
"status": {
"$ref": "#/components/schemas/EventStatus",
"description": "Event status."
@@ -14661,6 +14668,66 @@
}
}
},
+ "CalendarEventSourceContent": {
+ "type": "object",
+ "description": "The content one provider copy of an event carries.\n\nGoogle keeps these fields per calendar copy: a shared calendar's copy of a\nmember's event can have its own title, type, reminders, and access role.\nThe entity holds its canonical source's values. Every other copy's values\nare read from here so a client can show the copy that belongs to the\ncalendar being viewed.",
+ "required": [
+ "calendarId",
+ "title",
+ "eventType",
+ "visibility",
+ "transparency",
+ "isReadOnly",
+ "reminders"
+ ],
+ "properties": {
+ "calendarId": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Calendar this copy lives on."
+ },
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
+ "description": {
+ "type": ["string", "null"],
+ "description": "Optional event body."
+ },
+ "eventType": {
+ "$ref": "#/components/schemas/EventType",
+ "description": "Provider event type."
+ },
+ "isReadOnly": {
+ "type": "boolean",
+ "description": "Whether the calendar's access role prohibits editing this copy."
+ },
+ "location": {
+ "type": ["string", "null"],
+ "description": "Optional physical or virtual location label."
+ },
+ "reminders": {
+ "$ref": "#/components/schemas/EventReminders",
+ "description": "Reminder configuration of this copy."
+ },
+ "title": {
+ "type": "string",
+ "description": "Display title."
+ },
+ "transparency": {
+ "$ref": "#/components/schemas/EventTransparency",
+ "description": "Availability behavior."
+ },
+ "visibility": {
+ "$ref": "#/components/schemas/EventVisibility",
+ "description": "Event visibility."
+ }
+ }
+ },
"CalendarMentionEvent": {
"type": "object",
"description": "Meeting-level fields shown in a calendar event mention preview, taken from\nthe requester's own projection of the meeting.",
diff --git a/services/search_processing_service/src/process/calendar_event.rs b/services/search_processing_service/src/process/calendar_event.rs
index fc7d11db3f..f6bd3f22a6 100644
--- a/services/search_processing_service/src/process/calendar_event.rs
+++ b/services/search_processing_service/src/process/calendar_event.rs
@@ -75,6 +75,7 @@ pub async fn upsert_calendar_event(
&UpsertCalendarEventArgs {
event_id: event.id.to_string(),
title: event.title,
+ source_names: event.source_titles,
owner_id: event.owner_id,
source_link_id: event.source_link_id.to_string(),
ical_uid: event.ical_uid,