Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(notif): no pattern matches value undefined (#1502)
Sean Ayeaf692051c32a
diff --git a/js/app/flake.lock b/js/app/flake.lockindex 24f6872fa9..8f527ffad5 100644--- a/js/app/flake.lock+++ b/js/app/flake.lock@@ -8,11 +8,11 @@"rust-analyzer-src": "rust-analyzer-src"},"locked": {- "lastModified": 1767682236,- "narHash": "sha256-AWf4whMu4V1QA1wUFetWyddSfmhw6/VY5H90lXSDXjY=",+ "lastModified": 1770966612,+ "narHash": "sha256-S6k14z/JsDwX6zZyLucDBTOe/9RsvxH9GTUxHn2o4vc=","owner": "nix-community","repo": "fenix",- "rev": "ab32805338a72d8d69427426ce4259162e3d68bd",+ "rev": "e90d48dcfaebac7ea7a5687888a2d0733be26343","type": "github"},"original": {@@ -41,11 +41,11 @@},"nixpkgs": {"locked": {- "lastModified": 1767379071,- "narHash": "sha256-EgE0pxsrW9jp9YFMkHL9JMXxcqi/OoumPJYwf+Okucw=",+ "lastModified": 1770841267,+ "narHash": "sha256-9xejG0KoqsoKEGp2kVbXRlEYtFFcDTHjidiuX8hGO44=","owner": "NixOS","repo": "nixpkgs",- "rev": "fb7944c166a3b630f177938e478f0378e64ce108",+ "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae","type": "github"},"original": {@@ -82,11 +82,11 @@"rust-analyzer-src": {"flake": false,"locked": {- "lastModified": 1767609612,- "narHash": "sha256-ghz849iTGb+if+co4yGQC2Nfc0H6B/K4JFeul9rm7n4=",+ "lastModified": 1770934477,+ "narHash": "sha256-GX0cINHhhzUbQHyDYN2Mc+ovb6Sx/4yrF95VVou9aW4=","owner": "rust-lang","repo": "rust-analyzer",- "rev": "58646b524408a5aecb12d91121ea5825bef3d0c8",+ "rev": "931cd553be123b11db1435ac7ea5657e62e5e601","type": "github"},"original": {diff --git a/js/app/packages/app/component/next-soup/filters/filters.ts b/js/app/packages/app/component/next-soup/filters/filters.tsindex fe2cea59ac..686c14dd7e 100644--- a/js/app/packages/app/component/next-soup/filters/filters.ts+++ b/js/app/packages/app/component/next-soup/filters/filters.ts@@ -48,7 +48,7 @@ export function unreadFilter(entity: EnhancedEntity): boolean {if (entity.type === 'email') {return !entity.isRead;}- return entity.notifications?.()?.some((n) => !n.viewedAt) ?? false;+ return entity.notifications?.()?.some((n) => !n.viewed_at) ?? false;}/**diff --git a/js/app/packages/app/component/next-soup/soup-view/sort-options.ts b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsindex 5434135800..c0b428f5e2 100644--- a/js/app/packages/app/component/next-soup/soup-view/sort-options.ts+++ b/js/app/packages/app/component/next-soup/soup-view/sort-options.ts@@ -22,7 +22,7 @@ export function sortByNotifiedAt<T extends WithNotification<EntityData>>(const bNotification = b.notifications?.()[0];if (aNotification && bNotification) {- return compareDateDesc(aNotification.createdAt, bNotification.createdAt);+ return compareDateDesc(aNotification.created_at, bNotification.created_at);} else if (aNotification) {return -1;} else if (bNotification) {diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex d99284b318..630ebd301a 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -105,7 +105,7 @@ const useSoupNotificationInvalidators = () => {notificationSource,'document',(notification) => {- if (notification.notificationEventType === 'task_assigned') {+ if (notification.notification_event_type === 'task_assigned') {entityQueryClient.invalidateQueries({queryKey: soupKeys._def,});diff --git a/js/app/packages/block-email/component/EmailContext.tsx b/js/app/packages/block-email/component/EmailContext.tsxindex 3f22cfb07b..7695728320 100644--- a/js/app/packages/block-email/component/EmailContext.tsx+++ b/js/app/packages/block-email/component/EmailContext.tsx@@ -169,7 +169,7 @@ export function EmailProvider(props: FlowProps<{ threadID: string }>) {notificationSource,'email',(notification) => {- const meta = notification.notificationMetadata;+ const meta = notification.notification_metadata;if (meta.tag !== 'new_email') return;if (meta.content.threadId === threadQuery.data?.db_id) {threadQuery.refetch();diff --git a/js/app/packages/core/component/GlobalNotificationBell.tsx b/js/app/packages/core/component/GlobalNotificationBell.tsxindex ca7029d717..a66b2099d6 100644--- a/js/app/packages/core/component/GlobalNotificationBell.tsx+++ b/js/app/packages/core/component/GlobalNotificationBell.tsx@@ -30,7 +30,7 @@ export function GlobalNotificationBell(props: GlobalNotificationBellProps) {const mostRecent = () =>unreadNotifications().sort((a, b) =>- compareDateDesc(a.createdAt, b.createdAt)+ compareDateDesc(a.created_at, b.created_at))[0];const handleNotificationClick = async () => {diff --git a/js/app/packages/core/component/NotificationRenderer.tsx b/js/app/packages/core/component/NotificationRenderer.tsxindex 390d0eeb67..12daeec700 100644--- a/js/app/packages/core/component/NotificationRenderer.tsx+++ b/js/app/packages/core/component/NotificationRenderer.tsx@@ -17,8 +17,8 @@ type NotificationRendererProps = {};export function NotificationRenderer(props: NotificationRendererProps) {- const time = () => formatDate(props.notification.createdAt);- const actorId = () => props.notification.senderId ?? '';+ const time = () => formatDate(props.notification.created_at);+ const actorId = () => props.notification.sender_id ?? '';const macroId = () => tryMacroId(actorId());const [actorName] = useDisplayName(macroId());const emailFallback = () => {@@ -35,12 +35,12 @@ export function NotificationRenderer(props: NotificationRendererProps) {const entityId = () => props.notification.entity_id;const emailMeta = () => {- const meta = props.notification.notificationMetadata;+ const meta = props.notification.notification_metadata;if (meta.tag !== 'new_email') return null;return { subject: meta.content.subject, snippet: meta.content.snippet };};return (- <Show when={props.notification.notificationMetadata}>+ <Show when={props.notification.notification_metadata}>{(_metadata) => {if (props.mode === 'preview') {return (diff --git a/js/app/packages/core/component/Notifications.tsx b/js/app/packages/core/component/Notifications.tsxindex a0a924ebfd..5fbbd82356 100644--- a/js/app/packages/core/component/Notifications.tsx+++ b/js/app/packages/core/component/Notifications.tsx@@ -23,7 +23,7 @@ export function Notifications(props: NotificationsProps) {`${props.entity.type}@${props.entity.id}`] ?? [];return entityNotifications.sort((a, b) => {- return compareDateDesc(a.createdAt, b.createdAt);+ return compareDateDesc(a.created_at, b.created_at);});});@@ -47,7 +47,7 @@ export function Notifications(props: NotificationsProps) {><For each={notifications()}>{(notification) => {- const isUnread = !notification.viewedAt;+ const isUnread = !notification.viewed_at;const navHandlers = useSplitNavigationHandler(() =>handleNotificationClick(notification));@@ -68,12 +68,14 @@ export function Notifications(props: NotificationsProps) {<div>{NOTIFICATION_LABEL_BY_TYPE[- notification.notificationMetadata.tag+ notification.notification_metadata.tag]}</div><div class="grow" />- <div>{formatDate(notification.createdAt ?? new Date(0))}</div>+ <div>+ {formatDate(notification.created_at ?? new Date(0))}+ </div></div><div class="flex flex-col gap-2 ml-4">diff --git a/js/app/packages/core/component/NotificationsModal.tsx b/js/app/packages/core/component/NotificationsModal.tsxindex c748eb3190..293210aa39 100644--- a/js/app/packages/core/component/NotificationsModal.tsx+++ b/js/app/packages/core/component/NotificationsModal.tsx@@ -28,7 +28,7 @@ export function NotificationsModal(props: NotificationsModalProps) {);const unreadCount = createMemo(() => {- return notifications().filter((n) => !n.viewedAt).length;+ return notifications().filter((n) => !n.viewed_at).length;});const title = () => {diff --git a/js/app/packages/entity/mocks/mockEntityData.ts b/js/app/packages/entity/mocks/mockEntityData.tsindex 289e8ee671..8e8870a13c 100644--- a/js/app/packages/entity/mocks/mockEntityData.ts+++ b/js/app/packages/entity/mocks/mockEntityData.ts@@ -131,15 +131,15 @@ export const createMockNotification = (id: 'notif_123',done: false,sent: true,- senderId: MOCK_USER_IDS.teamMember1,- notificationEventType: 'document_mention',+ sender_id: MOCK_USER_IDS.teamMember1,+ notification_event_type: 'document_mention',entity_id: 'doc_123',entity_type: 'document',- createdAt: MOCK_TIMESTAMPS.today.toISOString(),- updatedAt: MOCK_TIMESTAMPS.today.toISOString(),- deletedAt: null,- viewedAt: null,- notificationMetadata: {+ created_at: MOCK_TIMESTAMPS.today.toISOString(),+ updated_at: MOCK_TIMESTAMPS.today.toISOString(),+ deleted_at: null,+ viewed_at: null,+ notification_metadata: {tag: 'document_mention',content: { documentName: 'Test Document', owner: 'user_123' },},@@ -149,21 +149,21 @@ export const createMockNotification = (export const MOCK_NOTIFICATIONS: Notification[] = [createMockNotification({id: 'notif_mention_1',- notificationEventType: 'document_mention',- senderId: MOCK_USER_IDS.teamMember1,- createdAt: MOCK_TIMESTAMPS.today.toISOString(),+ notification_event_type: 'document_mention',+ sender_id: MOCK_USER_IDS.teamMember1,+ created_at: MOCK_TIMESTAMPS.today.toISOString(),}),createMockNotification({id: 'notif_task_1',- notificationEventType: 'task_assigned',- senderId: MOCK_USER_IDS.teamMember2,- createdAt: MOCK_TIMESTAMPS.yesterday.toISOString(),+ notification_event_type: 'task_assigned',+ sender_id: MOCK_USER_IDS.teamMember2,+ created_at: MOCK_TIMESTAMPS.yesterday.toISOString(),}),createMockNotification({id: 'notif_channel_1',- notificationEventType: 'channel_message_send',- senderId: MOCK_USER_IDS.sharedUser,- createdAt: MOCK_TIMESTAMPS.lastWeek.toISOString(),+ notification_event_type: 'channel_message_send',+ sender_id: MOCK_USER_IDS.sharedUser,+ created_at: MOCK_TIMESTAMPS.lastWeek.toISOString(),entity_type: 'channel',}),];diff --git a/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts b/js/app/packages/entity/src/extractors-notification/notification-description-helpers.tsindex 327de19ee6..0f7ec9a26a 100644--- a/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts+++ b/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts@@ -9,8 +9,8 @@ import type { NotificationType } from '@core/types';export function getUniqueSenderIds(notifications: Notification[]): string[] {const senderIds = new Set<string>();for (const notification of notifications) {- if (notification.senderId) {- senderIds.add(notification.senderId);+ if (notification.sender_id) {+ senderIds.add(notification.sender_id);}}return Array.from(senderIds);diff --git a/js/app/packages/entity/src/extractors-notification/notification-description.tsx b/js/app/packages/entity/src/extractors-notification/notification-description.tsxindex 40fe355231..6424ba366f 100644--- a/js/app/packages/entity/src/extractors-notification/notification-description.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-description.tsx@@ -33,7 +33,7 @@ export function NotificationDescription(props: NotificationDescriptionProps) {};const notificationType = (): NotificationType | undefined => {- if (props.notification) return props.notification.notificationMetadata.tag;+ if (props.notification) return props.notification.notification_metadata.tag;if (props.stack) return props.stack.type;return undefined;};@@ -44,8 +44,8 @@ export function NotificationDescription(props: NotificationDescriptionProps) {};const primarySenderId = () => {- if (props.notification?.senderId) {- return props.notification.senderId;+ if (props.notification?.sender_id) {+ return props.notification.sender_id;}if (props.stack) {const senderIds = getUniqueSenderIds(props.stack.notifications);diff --git a/js/app/packages/entity/src/extractors-notification/notification-icon.tsx b/js/app/packages/entity/src/extractors-notification/notification-icon.tsxindex 65387673c0..d5ab676286 100644--- a/js/app/packages/entity/src/extractors-notification/notification-icon.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-icon.tsx@@ -43,7 +43,7 @@ function getNotificationIcon(export function NotificationIcon(props: NotificationIconProps) {const notificationType = (): NotificationType | undefined => {if (props.stack) return props.stack.type;- if (props.notification) return props.notification.notificationMetadata.tag;+ if (props.notification) return props.notification.notification_metadata.tag;return undefined;};diff --git a/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx b/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsxindex 314454af3a..02abe9fe1e 100644--- a/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx@@ -16,8 +16,8 @@ interface NotificationSenderIconProps {function getUniqueSenderIds(notifications: Notification[]): string[] {const senderIds = new Set<string>();for (const notification of notifications) {- if (notification.senderId) {- senderIds.add(notification.senderId);+ if (notification.sender_id) {+ senderIds.add(notification.sender_id);}}return Array.from(senderIds);@@ -32,8 +32,8 @@ export function NotificationSenderIcon(props: NotificationSenderIconProps) {const size = () => props.size ?? 'sm';const senderIds = () => {- if (props.notification?.senderId) {- return [props.notification.senderId];+ if (props.notification?.sender_id) {+ return [props.notification.sender_id];}if (props.stack) {return getUniqueSenderIds(props.stack.notifications);diff --git a/js/app/packages/entity/src/extractors-notification/notification-sender.tsx b/js/app/packages/entity/src/extractors-notification/notification-sender.tsxindex fee33f9359..e82da42827 100644--- a/js/app/packages/entity/src/extractors-notification/notification-sender.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-sender.tsx@@ -14,8 +14,8 @@ interface NotificationSenderProps {function getUniqueSenderIds(notifications: Notification[]): string[] {const senderIds = new Set<string>();for (const notification of notifications) {- if (notification.senderId) {- senderIds.add(notification.senderId);+ if (notification.sender_id) {+ senderIds.add(notification.sender_id);}}return Array.from(senderIds);@@ -29,8 +29,8 @@ function getUniqueSenderIds(notifications: Notification[]): string[] {*/export function NotificationSender(props: NotificationSenderProps) {const senderId = () => {- if (props.notification?.senderId) {- return props.notification.senderId;+ if (props.notification?.sender_id) {+ return props.notification.sender_id;}if (props.stack) {const senderIds = getUniqueSenderIds(props.stack.notifications);diff --git a/js/app/packages/entity/src/extractors-notification/notification-timestamp.tsx b/js/app/packages/entity/src/extractors-notification/notification-timestamp.tsxindex ca320af6c9..ffb771e549 100644--- a/js/app/packages/entity/src/extractors-notification/notification-timestamp.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-timestamp.tsx@@ -15,10 +15,10 @@ interface NotificationTimestampProps {export function NotificationTimestamp(props: NotificationTimestampProps) {const timestamp = () => {if (props.notification) {- return props.notification.createdAt;+ return props.notification.created_at;}if (props.stack && props.stack.notifications.length > 0) {- return props.stack.notifications[0].createdAt;+ return props.stack.notifications[0].created_at;}return undefined;};diff --git a/js/app/packages/entity/src/types/notification.ts b/js/app/packages/entity/src/types/notification.tsindex 3385812bf6..e5e503bebf 100644--- a/js/app/packages/entity/src/types/notification.ts+++ b/js/app/packages/entity/src/types/notification.ts@@ -1,7 +1,7 @@import type { ApiUserNotification } from '@service-notification/generated/schemas/apiUserNotification';import type { Accessor } from 'solid-js';-export type Notification = Omit<ApiUserNotification, 'ownerId'>;+export type Notification = Omit<ApiUserNotification, 'owner_id'>;export type WithNotification<T> = T & {notifications?: Accessor<Notification[]>;diff --git a/js/app/packages/entity/src/utils/filter.ts b/js/app/packages/entity/src/utils/filter.tsindex 822805d231..303fc8fb86 100644--- a/js/app/packages/entity/src/utils/filter.ts+++ b/js/app/packages/entity/src/utils/filter.ts@@ -3,5 +3,5 @@ import type { WithNotification } from '../types/notification';export function unreadFilterFn(entity: WithNotification<EntityData>) {if (entity.type === 'email') return !entity.isRead;- return entity.notifications?.()?.some(({ viewedAt }) => !viewedAt) ?? false;+ return entity.notifications?.()?.some(({ viewed_at }) => !viewed_at) ?? false;}diff --git a/js/app/packages/entity/src/utils/notification.ts b/js/app/packages/entity/src/utils/notification.tsindex 2bda54d340..d39513e905 100644--- a/js/app/packages/entity/src/utils/notification.ts+++ b/js/app/packages/entity/src/utils/notification.ts@@ -12,7 +12,7 @@ export function filterValidNotifications(if (!notifications) return [];return notifications.filter((n) => {- return n.notificationEventType !== undefined;+ return n.notification_event_type !== undefined;});}@@ -33,8 +33,8 @@ export function extractNotificationSenderIds(for (const notification of notifications) {if (senderIds.size >= maxCount) break;- if (notification.senderId) {- senderIds.add(notification.senderId);+ if (notification.sender_id) {+ senderIds.add(notification.sender_id);}}@@ -48,7 +48,7 @@ export function extractNotificationSenderIds(* Returns a short verb phrase like "mentioned", "replied", "shared", etc.*/export function getNotificationActionText(n: Notification): string {- const tag = n.notificationMetadata.tag;+ const tag = n.notification_metadata.tag;return match(tag).with('channel_mention', () => 'mentioned')@@ -65,7 +65,7 @@ export function getNotificationActionText(n: Notification): string {export function extractMessageContent(notification: Notification): string {const n = notification as UnifiedNotification;- const meta = n.notificationMetadata;+ const meta = n.notification_metadata;return match(meta).with({ tag: 'channel_mention' }, (m) => m.content.messageContent || '')@@ -97,10 +97,10 @@ export function isNotificationUnread(if ('notifications' in item && Array.isArray(item.notifications)) {const stack = item as NotificationStack;return stack.notifications.some(- (notification) => !notification.viewedAt && !notification.done+ (notification) => !notification.viewed_at && !notification.done);}const notification = item as Notification;- return !notification.viewedAt && !notification.done;+ return !notification.viewed_at && !notification.done;}diff --git a/js/app/packages/entity/tests/notification-description.test.ts b/js/app/packages/entity/tests/notification-description.test.tsindex f8d132fc1d..9a031f5717 100644--- a/js/app/packages/entity/tests/notification-description.test.ts+++ b/js/app/packages/entity/tests/notification-description.test.ts@@ -10,9 +10,9 @@ describe('notification-description helpers', () => {describe('getUniqueSenderIds', () => {it('extracts unique sender IDs from notifications', () => {const notifications: Notification[] = [- { senderId: 'user1' } as Notification,- { senderId: 'user2' } as Notification,- { senderId: 'user3' } as Notification,+ { sender_id: 'user1' } as Notification,+ { sender_id: 'user2' } as Notification,+ { sender_id: 'user3' } as Notification,];const result = getUniqueSenderIds(notifications);@@ -21,11 +21,11 @@ describe('notification-description helpers', () => {it('deduplicates sender IDs', () => {const notifications: Notification[] = [- { senderId: 'user1' } as Notification,- { senderId: 'user2' } as Notification,- { senderId: 'user1' } as Notification,- { senderId: 'user3' } as Notification,- { senderId: 'user2' } as Notification,+ { sender_id: 'user1' } as Notification,+ { sender_id: 'user2' } as Notification,+ { sender_id: 'user1' } as Notification,+ { sender_id: 'user3' } as Notification,+ { sender_id: 'user2' } as Notification,];const result = getUniqueSenderIds(notifications);@@ -34,10 +34,10 @@ describe('notification-description helpers', () => {it('skips notifications without senderId', () => {const notifications: Notification[] = [- { senderId: 'user1' } as Notification,+ { sender_id: 'user1' } as Notification,{} as Notification,- { senderId: 'user2' } as Notification,- { senderId: undefined } as any,+ { sender_id: 'user2' } as Notification,+ { sender_id: undefined } as any,];const result = getUniqueSenderIds(notifications);@@ -61,10 +61,10 @@ describe('notification-description helpers', () => {it('maintains insertion order of unique sender IDs', () => {const notifications: Notification[] = [- { senderId: 'user3' } as Notification,- { senderId: 'user1' } as Notification,- { senderId: 'user2' } as Notification,- { senderId: 'user3' } as Notification,+ { sender_id: 'user3' } as Notification,+ { sender_id: 'user1' } as Notification,+ { sender_id: 'user2' } as Notification,+ { sender_id: 'user3' } as Notification,];const result = getUniqueSenderIds(notifications);diff --git a/js/app/packages/entity/tests/notification.test.ts b/js/app/packages/entity/tests/notification.test.tsindex 3bda0f3e2b..8b32f47c73 100644--- a/js/app/packages/entity/tests/notification.test.ts+++ b/js/app/packages/entity/tests/notification.test.ts@@ -19,15 +19,15 @@ describe('notification utils', () => {const notifications: Notification[] = [{id: '1',- notificationEventType: 'channel_mention',+ notification_event_type: 'channel_mention',} as Notification,{id: '2',- notificationEventType: 'channel_message_send',+ notification_event_type: 'channel_message_send',} as Notification,{id: '3',- notificationEventType: 'new_email',+ notification_event_type: 'new_email',} as Notification,];@@ -40,11 +40,11 @@ describe('notification utils', () => {const notifications = [{id: '1',- notificationEventType: 'channel_mention',+ notification_event_type: 'channel_mention',} as Notification,{id: '2',- notificationEventType: undefined,+ notification_event_type: undefined,} as any,];@@ -57,14 +57,17 @@ describe('notification utils', () => {const notifications: Notification[] = [{id: '1',- notificationEventType: 'channel_mention',+ notification_event_type: 'channel_mention',} as Notification,{id: '2',- notificationEventType: 'document_mention',+ notification_event_type: 'document_mention',} as Notification,- { id: '3', notificationEventType: 'item_shared_user' } as Notification,- { id: '4', notificationEventType: 'new_email' } as Notification,+ {+ id: '3',+ notification_event_type: 'item_shared_user',+ } as Notification,+ { id: '4', notification_event_type: 'new_email' } as Notification,];const result = filterValidNotifications(notifications);@@ -103,9 +106,9 @@ describe('notification utils', () => {describe('extractNotificationSenderIds', () => {it('extracts sender IDs from notifications', () => {const notifications = [- { senderId: 'user1' },- { senderId: 'user2' },- { senderId: 'user3' },+ { sender_id: 'user1' },+ { sender_id: 'user2' },+ { sender_id: 'user3' },] as any[];const result = extractNotificationSenderIds(notifications);@@ -114,10 +117,10 @@ describe('notification utils', () => {it('limits results to maxCount', () => {const notifications = [- { senderId: 'user1' },- { senderId: 'user2' },- { senderId: 'user3' },- { senderId: 'user4' },+ { sender_id: 'user1' },+ { sender_id: 'user2' },+ { sender_id: 'user3' },+ { sender_id: 'user4' },] as any[];const result = extractNotificationSenderIds(notifications, 2);@@ -127,10 +130,10 @@ describe('notification utils', () => {it('defaults to maxCount of 3', () => {const notifications = [- { senderId: 'user1' },- { senderId: 'user2' },- { senderId: 'user3' },- { senderId: 'user4' },+ { sender_id: 'user1' },+ { sender_id: 'user2' },+ { sender_id: 'user3' },+ { sender_id: 'user4' },] as any[];const result = extractNotificationSenderIds(notifications);@@ -139,9 +142,9 @@ describe('notification utils', () => {it('deduplicates sender IDs', () => {const notifications = [- { senderId: 'user1' },- { senderId: 'user2' },- { senderId: 'user1' },+ { sender_id: 'user1' },+ { sender_id: 'user2' },+ { sender_id: 'user1' },] as any[];const result = extractNotificationSenderIds(notifications);@@ -150,9 +153,9 @@ describe('notification utils', () => {it('skips notifications without senderId', () => {const notifications = [- { senderId: 'user1' },+ { sender_id: 'user1' },{},- { senderId: 'user2' },+ { sender_id: 'user2' },] as any[];const result = extractNotificationSenderIds(notifications);@@ -161,9 +164,9 @@ describe('notification utils', () => {it('skips notifications with empty senderId', () => {const notifications = [- { senderId: 'user1' },- { senderId: '' },- { senderId: 'user2' },+ { sender_id: 'user1' },+ { sender_id: '' },+ { sender_id: 'user2' },] as any[];const result = extractNotificationSenderIds(notifications);@@ -172,9 +175,9 @@ describe('notification utils', () => {it('reverses result when reverse is true', () => {const notifications = [- { senderId: 'user1' },- { senderId: 'user2' },- { senderId: 'user3' },+ { sender_id: 'user1' },+ { sender_id: 'user2' },+ { sender_id: 'user3' },] as any[];const result = extractNotificationSenderIds(notifications, 3, true);@@ -185,63 +188,63 @@ describe('notification utils', () => {describe('getNotificationActionText', () => {it('returns correct action text for channel_mention', () => {const notification = {- notificationMetadata: { tag: 'channel_mention' },+ notification_metadata: { tag: 'channel_mention' },} as Notification;expect(getNotificationActionText(notification)).toBe('mentioned');});it('returns correct action text for channel_message_send', () => {const notification = {- notificationMetadata: { tag: 'channel_message_send' },+ notification_metadata: { tag: 'channel_message_send' },} as Notification;expect(getNotificationActionText(notification)).toBe('sent');});it('returns correct action text for channel_message_reply', () => {const notification = {- notificationMetadata: { tag: 'channel_message_reply' },+ notification_metadata: { tag: 'channel_message_reply' },} as Notification;expect(getNotificationActionText(notification)).toBe('replied');});it('returns correct action text for document_mention', () => {const notification = {- notificationMetadata: { tag: 'document_mention' },+ notification_metadata: { tag: 'document_mention' },} as Notification;expect(getNotificationActionText(notification)).toBe('mentioned');});it('returns correct action text for mentioned_in_document_comment', () => {const notification = {- notificationMetadata: { tag: 'mentioned_in_document_comment' },+ notification_metadata: { tag: 'mentioned_in_document_comment' },} as Notification;expect(getNotificationActionText(notification)).toBe('mentioned');});it('returns correct action text for channel_invite', () => {const notification = {- notificationMetadata: { tag: 'channel_invite' },+ notification_metadata: { tag: 'channel_invite' },} as Notification;expect(getNotificationActionText(notification)).toBe('invited');});it('returns correct action text for new_email', () => {const notification = {- notificationMetadata: { tag: 'new_email' },+ notification_metadata: { tag: 'new_email' },} as Notification;expect(getNotificationActionText(notification)).toBe('emailed');});it('returns correct action text for invite_to_team', () => {const notification = {- notificationMetadata: { tag: 'invite_to_team' },+ notification_metadata: { tag: 'invite_to_team' },} as Notification;expect(getNotificationActionText(notification)).toBe('invited');});it('returns correct action text for task_assigned', () => {const notification = {- notificationMetadata: { tag: 'task_assigned' },+ notification_metadata: { tag: 'task_assigned' },} as Notification;expect(getNotificationActionText(notification)).toBe('assigned');});@@ -250,7 +253,7 @@ describe('notification utils', () => {describe('extractMessageContent', () => {it('extracts messageContent for channel_mention', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'channel_mention',content: { messageContent: 'Hey @user, check this out' },},@@ -263,7 +266,7 @@ describe('notification utils', () => {it('extracts messageContent for channel_message_send', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'channel_message_send',content: { messageContent: 'Hello everyone' },},@@ -274,7 +277,7 @@ describe('notification utils', () => {it('extracts messageContent for channel_message_reply', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'channel_message_reply',content: { messageContent: 'Great point!' },},@@ -285,7 +288,7 @@ describe('notification utils', () => {it('extracts documentName for document_mention', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'document_mention',content: { documentName: 'Project Plan.doc' },},@@ -296,7 +299,7 @@ describe('notification utils', () => {it('extracts text for mentioned_in_document_comment', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'mentioned_in_document_comment',content: { text: 'Check this comment' },},@@ -307,7 +310,7 @@ describe('notification utils', () => {it('extracts subject for new_email', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'new_email',content: { subject: 'Important Update' },},@@ -318,7 +321,7 @@ describe('notification utils', () => {it('extracts taskName for task_assigned', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'task_assigned',content: { taskName: 'Review PR' },},@@ -329,7 +332,7 @@ describe('notification utils', () => {it('returns empty string for channel_invite', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'channel_invite',content: {},},@@ -340,7 +343,7 @@ describe('notification utils', () => {it('returns empty string for invite_to_team', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'invite_to_team',content: {},},@@ -351,7 +354,7 @@ describe('notification utils', () => {it('returns empty string when content is missing', () => {const notification = {- notificationMetadata: {+ notification_metadata: {tag: 'channel_mention',content: {},},@@ -365,7 +368,7 @@ describe('notification utils', () => {describe('single notification', () => {it('returns true for unviewed notification', () => {const notification = {- viewedAt: null,+ viewed_at: null,done: false,} as Notification;@@ -374,7 +377,7 @@ describe('notification utils', () => {it('returns false for viewed notification', () => {const notification = {- viewedAt: new Date(1234567890).toISOString(),+ viewed_at: new Date(1234567890).toISOString(),done: false,} as Notification;@@ -383,7 +386,7 @@ describe('notification utils', () => {it('returns false for done notification', () => {const notification = {- viewedAt: null,+ viewed_at: null,done: true,} as Notification;@@ -392,7 +395,7 @@ describe('notification utils', () => {it('returns false for viewed and done notification', () => {const notification = {- viewedAt: new Date(1234567890).toISOString(),+ viewed_at: new Date(1234567890).toISOString(),done: true,} as Notification;@@ -405,12 +408,12 @@ describe('notification utils', () => {const stack = {notifications: [{- viewedAt: new Date(1234567890).toISOString(),+ viewed_at: new Date(1234567890).toISOString(),done: false,} as Notification,- { viewedAt: null, done: false } as Notification,+ { viewed_at: null, done: false } as Notification,{- viewedAt: new Date(1234567890).toISOString(),+ viewed_at: new Date(1234567890).toISOString(),done: false,} as Notification,],@@ -423,11 +426,11 @@ describe('notification utils', () => {const stack = {notifications: [{- viewedAt: new Date(1234567890).toISOString(),+ viewed_at: new Date(1234567890).toISOString(),done: false,} as Notification,{- viewedAt: new Date(1234567890).toISOString(),+ viewed_at: new Date(1234567890).toISOString(),done: false,} as Notification,],@@ -439,8 +442,8 @@ describe('notification utils', () => {it('returns false if all notifications are done', () => {const stack = {notifications: [- { viewedAt: null, done: true } as Notification,- { viewedAt: null, done: true } as Notification,+ { viewed_at: null, done: true } as Notification,+ { viewed_at: null, done: true } as Notification,],} as any;diff --git a/js/app/packages/notifications/components/Playground.tsx b/js/app/packages/notifications/components/Playground.tsxindex 2194d11a63..468f928102 100644--- a/js/app/packages/notifications/components/Playground.tsx+++ b/js/app/packages/notifications/components/Playground.tsx@@ -37,7 +37,7 @@ function groupNotificationsByType(): NotificationsByType {const groups = new Map<string, UnifiedNotification[]>();for (const notification of notifications) {- const type = notification.notificationEventType;+ const type = notification.notification_event_type;if (!groups.has(type)) {groups.set(type, []);}@@ -47,7 +47,7 @@ function groupNotificationsByType(}function hasNotificationMetadata(notification: UnifiedNotification): boolean {- return notification.notificationMetadata != null;+ return notification.notification_metadata != null;}function TypeButton(props: {@@ -103,7 +103,7 @@ function NotificationItem(props: {onSelect: () => void;}) {const hasData = () => hasNotificationMetadata(props.notification);- const isUnread = () => !props.notification.viewedAt;+ const isUnread = () => !props.notification.viewed_at;return (<button@@ -128,7 +128,7 @@ function NotificationItem(props: {/></Show><div class="text-xs text-ink-muted font-mono mt-2">- {formatDate(props.notification.createdAt)}+ {formatDate(props.notification.created_at)}</div></div></div>@@ -348,11 +348,11 @@ function NotificationDetail(props: {<h2 class="text-3xl font-semibold text-ink mb-2">{NOTIFICATION_LABEL_BY_TYPE[props.notification- .notificationEventType as keyof typeof NOTIFICATION_LABEL_BY_TYPE- ] || props.notification.notificationEventType}+ .notification_event_type as keyof typeof NOTIFICATION_LABEL_BY_TYPE+ ] || props.notification.notification_event_type}</h2><p class="text-sm text-ink-muted">- {formatDate(props.notification.createdAt)}+ {formatDate(props.notification.created_at)}</p></div><DeprecatedTextButton@@ -369,7 +369,7 @@ function NotificationDetail(props: {<div class="flex items-start gap-3"><divclass={`size-2 mt-1 shrink-0 ${- !props.notification.viewedAt+ !props.notification.viewed_at? 'bg-accent': 'bg-ink-extra-muted'}`}@@ -388,13 +388,13 @@ function NotificationDetail(props: {<h3 class="text-lg font-semibold text-ink mb-4">Full Mode</h3><divclass={`p-6 rounded-xl border border-edge-muted ${- !props.notification.viewedAt ? 'bg-menu-hover' : 'bg-menu'+ !props.notification.viewed_at ? 'bg-menu-hover' : 'bg-menu'}`}><div class="flex justify-start items-center gap-3 mb-4 font-mono text-ink-muted text-xs uppercase"><divclass={`size-2 ${- !props.notification.viewedAt+ !props.notification.viewed_at? 'bg-accent': 'bg-ink-extra-muted'}`}@@ -403,12 +403,12 @@ function NotificationDetail(props: {{NOTIFICATION_LABEL_BY_TYPE[props.notification- .notificationEventType as keyof typeof NOTIFICATION_LABEL_BY_TYPE+ .notification_event_type as keyof typeof NOTIFICATION_LABEL_BY_TYPE]}</div><div class="grow" />- <div>{formatDate(props.notification.createdAt)}</div>+ <div>{formatDate(props.notification.created_at)}</div></div><div class="ml-5"><NotificationRenderer@@ -481,19 +481,19 @@ function PlaygroundContent() {/** @ts-ignore */return {id: `custom-${Date.now()}`,- createdAt: new Date().toISOString(),+ created_at: new Date().toISOString(),eventItemId: 'channel-custom',eventItemType: 'channel',- senderId: 'user-custom',- notificationEventType: 'channel_message_send',- notificationMetadata: {+ sender_id: 'user-custom',+ notification_event_type: 'channel_message_send',+ notification_metadata: {sender: 'user-custom',messageContent: markdownArea.state(),messageId: 'msg-custom',channelType: 'direct_message',channelName: 'test-channel',},- viewedAt: null,+ viewed_at: null,done: false,} as UnifiedNotification;});diff --git a/js/app/packages/notifications/notification-helpers.ts b/js/app/packages/notifications/notification-helpers.tsindex 2930721c15..6e25681bb6 100644--- a/js/app/packages/notifications/notification-helpers.ts+++ b/js/app/packages/notifications/notification-helpers.ts@@ -48,7 +48,7 @@ export function notificationIsOfEntityType(* @returns boolean*/export function notificationIsRead(notification: UnifiedNotification): boolean {- return !!notification.viewedAt || notification.done;+ return !!notification.viewed_at || notification.done;}/**diff --git a/js/app/packages/notifications/notification-metadata.ts b/js/app/packages/notifications/notification-metadata.tsindex 3299c1f740..5c20101124 100644--- a/js/app/packages/notifications/notification-metadata.ts+++ b/js/app/packages/notifications/notification-metadata.ts@@ -4,7 +4,7 @@ import { match } from 'ts-pattern';// Helper functions for derived notification dataexport function getNotificationAction(n: UnifiedNotification): string {- return match(n.notificationMetadata.tag)+ return match(n.notification_metadata.tag).with('channel_mention', () => 'mentioned you in').with('document_mention', () => 'sent a document').with('mentioned_in_document_comment', () => 'mentioned you in')@@ -20,7 +20,7 @@ export function getNotificationAction(n: UnifiedNotification): string {export function getNotificationTargetName(n: UnifiedNotification): string | undefined {- const m = n.notificationMetadata;+ const m = n.notification_metadata;return match(m).with({ tag: 'channel_invite' }, (m) => m.content.channelName).with({ tag: 'document_mention' }, (m) => m.content.documentName)@@ -40,7 +40,7 @@ export function getNotificationTargetName(export function getNotificationContent(n: UnifiedNotification): string | undefined {- const m = n.notificationMetadata;+ const m = n.notification_metadata;return match(m).with({ tag: 'channel_mention' }, (m) => m.content.messageContent).with({ tag: 'channel_message_send' }, (m) => m.content.messageContent)@@ -55,7 +55,7 @@ export function getNotificationContent(}export function shouldShowNotificationTarget(n: UnifiedNotification): boolean {- const m = n.notificationMetadata;+ const m = n.notification_metadata;return match(m).with({ tag: 'channel_mention' },diff --git a/js/app/packages/notifications/notification-navigation.ts b/js/app/packages/notifications/notification-navigation.tsindex 567ed6edea..eb6626e933 100644--- a/js/app/packages/notifications/notification-navigation.ts+++ b/js/app/packages/notifications/notification-navigation.ts@@ -51,15 +51,15 @@ async function openChannelNotification(let messageId: string | undefined;let threadId: string | undefined;- const tag = notification.notificationMetadata.tag;+ const tag = notification.notification_metadata.tag;if (tag === 'channel_mention') {- messageId = notification.notificationMetadata.content.messageId;- threadId = notification.notificationMetadata.content.threadId ?? undefined;+ messageId = notification.notification_metadata.content.messageId;+ threadId = notification.notification_metadata.content.threadId ?? undefined;} else if (tag === 'channel_message_send') {- messageId = notification.notificationMetadata.content.messageId;+ messageId = notification.notification_metadata.content.messageId;} else if (tag === 'channel_message_reply') {- messageId = notification.notificationMetadata.content.messageId;- threadId = notification.notificationMetadata.content.threadId;+ messageId = notification.notification_metadata.content.messageId;+ threadId = notification.notification_metadata.content.threadId;}openSplitIfNotOpen(layoutManager, 'channel', channelId, newSplit);@@ -92,7 +92,7 @@ export type OpenNotificationFromIdError = NotSupportedError | NotFoundError;function getSupportedHandler(notification: UnifiedNotification): ((layoutManager: SplitManager, newSplit?: boolean) => Promise<void>) | null {- const tag = notification.notificationMetadata.tag;+ const tag = notification.notification_metadata.tag;return match(tag).with(@@ -102,7 +102,7 @@ function getSupportedHandler(openChannelNotification(notification, lm, newSplit)).with('new_email', () => {- const meta = notification.notificationMetadata;+ const meta = notification.notification_metadata;if (meta.tag !== 'new_email') return null;return async (lm: SplitManager, newSplit: boolean = false) => {openSplitIfNotOpen(lm, 'email', meta.content.threadId, newSplit);@@ -115,7 +115,7 @@ function getSupportedHandler(openSplitIfNotOpen(lm, 'channel', notification.entity_id, newSplit)).with('document_mention', () => {- const meta = notification.notificationMetadata;+ const meta = notification.notification_metadata;if (meta.tag !== 'document_mention') return null;return async (lm: SplitManager, newSplit: boolean = false) =>openSplitIfNotOpen(@@ -127,14 +127,14 @@ function getSupportedHandler(}).with('invite_to_team', () => null).with('task_assigned', () => {- const meta = notification.notificationMetadata;+ const meta = notification.notification_metadata;if (meta.tag !== 'task_assigned') return null;return async (lm: SplitManager, newSplit: boolean = false) => {openSplitIfNotOpen(lm, 'task', meta.content.taskId, newSplit);};}).with('mentioned_in_document_comment', () => {- const meta = notification.notificationMetadata;+ const meta = notification.notification_metadata;if (meta.tag !== 'mentioned_in_document_comment') return null;return async (lm: SplitManager, newSplit: boolean = false) =>openSplitIfNotOpen(@@ -160,7 +160,7 @@ export function openNotification(if (!handler) {return errAsync({tag: 'NotSupportedError',- notificationType: notification.notificationMetadata.tag,+ notificationType: notification.notification_metadata.tag,});}return ResultAsync.fromSafePromise(handler(layoutManager, newSplit));diff --git a/js/app/packages/notifications/notification-platform.ts b/js/app/packages/notifications/notification-platform.tsindex d8c198b1d0..de76d26b47 100644--- a/js/app/packages/notifications/notification-platform.ts+++ b/js/app/packages/notifications/notification-platform.ts@@ -42,7 +42,7 @@ export async function toPlatformNotificationData(resolveUserName: UserNameResolver,resolveDocumentName: DocumentNameResolver): Promise<PlatformNotificationData | null> {- const actorId = notification.senderId;+ const actorId = notification.sender_id;const actor =(actorId ? await resolveUserName(actorId) : undefined) ??USER_NAME_FALLBACK;diff --git a/js/app/packages/notifications/notification-stacking.ts b/js/app/packages/notifications/notification-stacking.tsindex 9193a5ff7f..998e1c5e85 100644--- a/js/app/packages/notifications/notification-stacking.ts+++ b/js/app/packages/notifications/notification-stacking.ts@@ -30,8 +30,8 @@ export function getAllNotificationsFromGroup(*/export function getThreadId(group: NotificationStack): string {const notification = group.notifications[0];- if (notification.notificationMetadata.tag === 'channel_message_reply') {- return notification.notificationMetadata.content.threadId ?? '';+ if (notification.notification_metadata.tag === 'channel_message_reply') {+ return notification.notification_metadata.content.threadId ?? '';}return '';}@@ -43,28 +43,28 @@ export function stackNotifications(notifications: UnifiedNotification[]): NotificationStack[] {const isChannelMention = (n: UnifiedNotification) =>- n.notificationMetadata.tag === 'channel_mention';+ n.notification_metadata.tag === 'channel_mention';const isChannelMessageSend = (n: UnifiedNotification) =>- n.notificationMetadata.tag === 'channel_message_send';+ n.notification_metadata.tag === 'channel_message_send';const isChannelMessageReply = (n: UnifiedNotification) =>- n.notificationMetadata.tag === 'channel_message_reply';+ n.notification_metadata.tag === 'channel_message_reply';// Collect mention messageIds for shadowingconst mentionedMsgIds = new Set(notifications.filter(isChannelMention).flatMap((n) =>- n.notificationMetadata.tag === 'channel_mention'- ? [n.notificationMetadata.content.messageId]+ n.notification_metadata.tag === 'channel_mention'+ ? [n.notification_metadata.content.messageId]: []).filter(Boolean));const isShadowed = (n: UnifiedNotification) => {- const tag = n.notificationMetadata.tag;+ const tag = n.notification_metadata.tag;if (tag === 'channel_message_send' || tag === 'channel_message_reply') {- const messageId = n.notificationMetadata.content.messageId;+ const messageId = n.notification_metadata.content.messageId;return messageId && mentionedMsgIds.has(messageId);}return false;@@ -90,7 +90,7 @@ export function stackNotifications(...mentions.flatMap((n) => makeStack('channel_mention', [n])),...makeStack('channel_message_send', newMsgs),...makeReplyStacks(replies),- ...others.flatMap((n) => makeStack(n.notificationMetadata.tag, [n])),+ ...others.flatMap((n) => makeStack(n.notification_metadata.tag, [n])),];// Sort: mentions first, then by recency@@ -99,14 +99,14 @@ export function stackNotifications(return a.type === 'channel_mention' ? -1 : 1;}return compareDateDesc(- a.notifications[0].createdAt,- b.notifications[0].createdAt+ a.notifications[0].created_at,+ b.notifications[0].created_at);});}function sortByRecency(items: UnifiedNotification[]): UnifiedNotification[] {- return [...items].sort((a, b) => compareDateDesc(a.createdAt, b.createdAt));+ return [...items].sort((a, b) => compareDateDesc(a.created_at, b.created_at));}const groupBy: <T, K>(items: T[], keyFn: (item: T) => K) => Map<K, T[]> =@@ -135,8 +135,8 @@ function makeStack(function makeReplyStacks(replies: UnifiedNotification[]): NotificationStack[] {const byThread = groupBy(replies, (r) => {- if (r.notificationMetadata.tag === 'channel_message_reply') {- return r.notificationMetadata.content.threadId ?? '';+ if (r.notification_metadata.tag === 'channel_message_reply') {+ return r.notification_metadata.content.threadId ?? '';}return '';});diff --git a/js/app/packages/notifications/tests/notification-preview.test.ts b/js/app/packages/notifications/tests/notification-preview.test.tsindex cdcccaca79..402b5e3935 100644--- a/js/app/packages/notifications/tests/notification-preview.test.ts+++ b/js/app/packages/notifications/tests/notification-preview.test.ts@@ -9,15 +9,15 @@ function createEmailNotification(id: 'notif-1',entity_id: 'thread-1',entity_type: 'email',- createdAt: new Date().toISOString(),- updatedAt: null,- viewedAt: null,- deletedAt: null,+ created_at: new Date().toISOString(),+ updated_at: null,+ viewed_at: null,+ deleted_at: null,done: false,sent: true,- senderId,- notificationEventType: 'new_email',- notificationMetadata: {+ sender_id: senderId,+ notification_event_type: 'new_email',+ notification_metadata: {tag: 'new_email',content: {sender: metadataSender,@@ -37,17 +37,17 @@ describe('new_email notification', () => {);- // senderId is directly available on the notification- expect(notification.senderId).toBe('macro|[email protected]');+ // sender_id is directly available on the notification+ expect(notification.sender_id).toBe('macro|[email protected]');});it('falls back to metadata sender when senderId is null', () => {const notification = createEmailNotification(null, '[email protected]');- // When senderId is null, the metadata sender can be used- expect(notification.senderId).toBeNull();+ // When sender_id is null, the metadata sender can be used+ expect(notification.sender_id).toBeNull();// Access the sender field after type assertion since we know this is a new_email notification- const content = notification.notificationMetadata.content as {+ const content = notification.notification_metadata.content as {sender?: string | null;};expect(content.sender).toBe('[email protected]');diff --git a/js/app/packages/notifications/tests/notification-stacking.test.ts b/js/app/packages/notifications/tests/notification-stacking.test.tsindex e3b3de45e2..53e3886b02 100644--- a/js/app/packages/notifications/tests/notification-stacking.test.ts+++ b/js/app/packages/notifications/tests/notification-stacking.test.ts@@ -18,15 +18,15 @@ function createBaseNotification(id,entity_id: 'channel-1',entity_type: 'channel',- createdAt: new Date(createdAt).toISOString(),- updatedAt: null,- viewedAt: null,- deletedAt: null,+ created_at: new Date(createdAt).toISOString(),+ updated_at: null,+ viewed_at: null,+ deleted_at: null,done: false,sent: true,- senderId: 'user-1',- notificationEventType: notificationMetadata.tag,- notificationMetadata,+ sender_id: 'user-1',+ notification_event_type: notificationMetadata.tag,+ notification_metadata: notificationMetadata,};}diff --git a/js/app/packages/notifications/types.ts b/js/app/packages/notifications/types.tsindex 6d69373222..25d04ec72b 100644--- a/js/app/packages/notifications/types.ts+++ b/js/app/packages/notifications/types.ts@@ -1,7 +1,7 @@import type { Entity, EntityType } from '@core/types';import type { ApiUserNotification } from '@service-notification/generated/schemas';-export type UnifiedNotification = Omit<ApiUserNotification, 'ownerId'>;+export type UnifiedNotification = Omit<ApiUserNotification, 'owner_id'>;export type CompositeEntity = `${EntityType}@${string}`;diff --git a/js/app/packages/queries/notification/tests/user-notifications.test.tsx b/js/app/packages/queries/notification/tests/user-notifications.test.tsxindex afd9b509a4..3a0ac6fbf0 100644--- a/js/app/packages/queries/notification/tests/user-notifications.test.tsx+++ b/js/app/packages/queries/notification/tests/user-notifications.test.tsx@@ -54,14 +54,14 @@ function createMockNotification(id: `notification-${Math.random().toString(36).slice(2)}`,entity_id: 'entity-1',entity_type: 'document',- createdAt: new Date().toISOString(),- updatedAt: null,- viewedAt: null,- deletedAt: null,+ created_at: new Date().toISOString(),+ updated_at: null,+ viewed_at: null,+ deleted_at: null,done: false,sent: true,- notificationEventType: 'item_shared_user',- notificationMetadata: {+ notification_event_type: 'item_shared_user',+ notification_metadata: {tag: 'item_shared_user',content: {sharedBy: 'user-1',@@ -147,9 +147,9 @@ describe('notification mutations', () => {});describe('useMarkNotificationsAsSeenMutation', () => {- it('should optimistically update viewedAt when marking as seen', async () => {- const n1 = createMockNotification({ id: 'n1', viewedAt: null });- const n2 = createMockNotification({ id: 'n2', viewedAt: null });+ it('should optimistically update viewed_at when marking as seen', async () => {+ const n1 = createMockNotification({ id: 'n1', viewed_at: null });+ const n2 = createMockNotification({ id: 'n2', viewed_at: null });seedQueryCache([createMockNotificationPage([n1, n2])]);mockBulkMarkNotificationAsSeen.mockResolvedValue(ok({ success: true }));@@ -167,14 +167,14 @@ describe('notification mutations', () => {await mutatePromise;const notifications = getNotificationsFromCache();- expect(typeof notifications[0].viewedAt).toBe('string');- expect(notifications[1].viewedAt).toBe(null);+ expect(typeof notifications[0].viewed_at).toBe('string');+ expect(notifications[1].viewed_at).toBe(null);cleanup();});it('should rollback optimistic update on error', async () => {- const n1 = createMockNotification({ id: 'n1', viewedAt: null });+ const n1 = createMockNotification({ id: 'n1', viewed_at: null });seedQueryCache([createMockNotificationPage([n1])]);mockBulkMarkNotificationAsSeen.mockResolvedValue(@@ -198,14 +198,14 @@ describe('notification mutations', () => {await new Promise((r) => setTimeout(r, 10));const notifications = getNotificationsFromCache();- expect(notifications[0].viewedAt).toBe(null);+ expect(notifications[0].viewed_at).toBe(null);cleanup();});it('should handle marking notifications across multiple pages', async () => {- const n1 = createMockNotification({ id: 'n1', viewedAt: null });- const n2 = createMockNotification({ id: 'n2', viewedAt: null });+ const n1 = createMockNotification({ id: 'n1', viewed_at: null });+ const n2 = createMockNotification({ id: 'n2', viewed_at: null });seedQueryCache([createMockNotificationPage([n1]),createMockNotificationPage([n2]),@@ -226,8 +226,8 @@ describe('notification mutations', () => {await mutatePromise;const notifications = getNotificationsFromCache();- expect(notifications[0].viewedAt).toBe(null); // n1 unchanged- expect(typeof notifications[1].viewedAt).toBe('string'); // n2 updated+ expect(notifications[0].viewed_at).toBe(null); // n1 unchanged+ expect(typeof notifications[1].viewed_at).toBe('string'); // n2 updatedcleanup();});diff --git a/js/app/packages/queries/notification/user-notifications.ts b/js/app/packages/queries/notification/user-notifications.tsindex 5eef69a866..9322b03d88 100644--- a/js/app/packages/queries/notification/user-notifications.ts+++ b/js/app/packages/queries/notification/user-notifications.ts@@ -15,7 +15,7 @@ import { notificationKeys } from './keys';import type { UnifiedNotification } from '@notifications/types';function stripOwnerId({- ownerId: _,+ owner_id: _,...rest}: ApiUserNotification): UnifiedNotification {return rest;@@ -322,7 +322,7 @@ const mapNotificationsAsSeen = (...page,items: page.items.map((n) =>params.notificationIds.includes(n.id)- ? { ...n, viewedAt: new Date().toISOString() }+ ? { ...n, viewed_at: new Date().toISOString() }: n),})),diff --git a/js/app/packages/queries/soup/normalized-cache/operations.ts b/js/app/packages/queries/soup/normalized-cache/operations.tsindex a685bb3dce..7c207c0d7f 100644--- a/js/app/packages/queries/soup/normalized-cache/operations.ts+++ b/js/app/packages/queries/soup/normalized-cache/operations.ts@@ -37,7 +37,7 @@ export function optimisticUpdateSoupEntity<T extends SoupEntityTag>(: [];const previous = dependentKeys.map(- (key) =>+ (key: QueryKey) =>[key,queryClient.getQueryData<InfiniteData<SoupPage, unknown>>(key),diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/apiUserNotificationAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/apiUserNotificationAllOf.tsindex f499e3ab90..5c9f4c1e55 100644--- a/js/app/packages/service-clients/service-notification/generated/schemas/apiUserNotificationAllOf.ts+++ b/js/app/packages/service-clients/service-notification/generated/schemas/apiUserNotificationAllOf.ts@@ -13,26 +13,26 @@ import type { NotifEvent } from './notifEvent';export type ApiUserNotificationAllOf = {/** When the notification was created. */- createdAt?: ApiUserNotificationAllOfCreatedAt;+ created_at?: ApiUserNotificationAllOfCreatedAt;/** When the notification was deleted. */- deletedAt?: ApiUserNotificationAllOfDeletedAt;+ deleted_at?: ApiUserNotificationAllOfDeletedAt;/** Whether the notification is marked as done. */done: boolean;/** The notification ID. */id: string;/** The notification event type string (e.g. "channel_mention").TODO make this a new type */- notificationEventType: string;+ notification_event_type: string;/** Deserialized notification metadata. */- notificationMetadata: NotifEvent;+ notification_metadata: NotifEvent;/** The user who owns this notification. */- ownerId: string;+ owner_id: string;/** The user who triggered the notification. */- senderId?: ApiUserNotificationAllOfSenderId;+ sender_id?: ApiUserNotificationAllOfSenderId;/** Whether the notification has been sent. */sent: boolean;/** When the notification was last updated. */- updatedAt?: ApiUserNotificationAllOfUpdatedAt;+ updated_at?: ApiUserNotificationAllOfUpdatedAt;/** When the notification was viewed/seen. */- viewedAt?: ApiUserNotificationAllOfViewedAt;+ viewed_at?: ApiUserNotificationAllOfViewedAt;};diff --git a/js/app/packages/service-clients/service-notification/openapi.json b/js/app/packages/service-clients/service-notification/openapi.jsonindex 6a7bcfad06..7030437da2 100644--- a/js/app/packages/service-clients/service-notification/openapi.json+++ b/js/app/packages/service-clients/service-notification/openapi.json@@ -960,20 +960,20 @@{"type": "object","required": [- "ownerId",+ "owner_id","id",- "notificationEventType",+ "notification_event_type","sent","done",- "notificationMetadata"+ "notification_metadata"],"properties": {- "createdAt": {+ "created_at": {"type": ["string", "null"],"format": "date-time","description": "When the notification was created."},- "deletedAt": {+ "deleted_at": {"type": ["string", "null"],"format": "date-time","description": "When the notification was deleted."@@ -987,19 +987,19 @@"format": "uuid","description": "The notification ID."},- "notificationEventType": {+ "notification_event_type": {"type": "string","description": "The notification event type string (e.g. \"channel_mention\").\nTODO make this a new type"},- "notificationMetadata": {+ "notification_metadata": {"$ref": "#/components/schemas/NotifEvent","description": "Deserialized notification metadata."},- "ownerId": {+ "owner_id": {"type": "string","description": "The user who owns this notification."},- "senderId": {+ "sender_id": {"type": ["string", "null"],"description": "The user who triggered the notification."},@@ -1007,12 +1007,12 @@"type": "boolean","description": "Whether the notification has been sent."},- "updatedAt": {+ "updated_at": {"type": ["string", "null"],"format": "date-time","description": "When the notification was last updated."},- "viewedAt": {+ "viewed_at": {"type": ["string", "null"],"format": "date-time","description": "When the notification was viewed/seen."diff --git a/rust/cloud-storage/notification/.sqlx/query-01dd9435cfbfb5050e24e65f854fbe902364f0c8886a49feacd938f7ccf5291c.json b/rust/cloud-storage/notification/.sqlx/query-01dd9435cfbfb5050e24e65f854fbe902364f0c8886a49feacd938f7ccf5291c.jsondeleted file mode 100644index 12ca64bf33..0000000000--- a/rust/cloud-storage/notification/.sqlx/query-01dd9435cfbfb5050e24e65f854fbe902364f0c8886a49feacd938f7ccf5291c.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "SELECT id FROM notification WHERE id = $1",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "01dd9435cfbfb5050e24e65f854fbe902364f0c8886a49feacd938f7ccf5291c"-}diff --git a/rust/cloud-storage/notification/.sqlx/query-3b56482fd4025765cb40a4eec09614b1de6f8fec1cfd2a52d4bd1203790a45a0.json b/rust/cloud-storage/notification/.sqlx/query-3b56482fd4025765cb40a4eec09614b1de6f8fec1cfd2a52d4bd1203790a45a0.jsondeleted file mode 100644index 2ff05438c8..0000000000--- a/rust/cloud-storage/notification/.sqlx/query-3b56482fd4025765cb40a4eec09614b1de6f8fec1cfd2a52d4bd1203790a45a0.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "SELECT sent FROM user_notification WHERE notification_id = $1",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "sent",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "3b56482fd4025765cb40a4eec09614b1de6f8fec1cfd2a52d4bd1203790a45a0"-}diff --git a/rust/cloud-storage/notification/.sqlx/query-5ed9ce53ae62e9f7b951d91e63b01a67c76157d88abb22bbfb1f39d92ac5dcc1.json b/rust/cloud-storage/notification/.sqlx/query-5ed9ce53ae62e9f7b951d91e63b01a67c76157d88abb22bbfb1f39d92ac5dcc1.jsondeleted file mode 100644index a924d6020c..0000000000--- a/rust/cloud-storage/notification/.sqlx/query-5ed9ce53ae62e9f7b951d91e63b01a67c76157d88abb22bbfb1f39d92ac5dcc1.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "SELECT seen_at FROM user_notification WHERE notification_id = $1 AND user_id = $2",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "seen_at",- "type_info": "Timestamp"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- true- ]- },- "hash": "5ed9ce53ae62e9f7b951d91e63b01a67c76157d88abb22bbfb1f39d92ac5dcc1"-}diff --git a/rust/cloud-storage/notification/.sqlx/query-e267af62eaa9b86a89b8c830122d47ab0252ac02a67ec0e7fa72c1ddc3791f04.json b/rust/cloud-storage/notification/.sqlx/query-73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98.jsonsimilarity index 50%rename from rust/cloud-storage/notification/.sqlx/query-e267af62eaa9b86a89b8c830122d47ab0252ac02a67ec0e7fa72c1ddc3791f04.jsonrename to rust/cloud-storage/notification/.sqlx/query-73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98.jsonindex 9a417527bc..65459bcefd 100644--- a/rust/cloud-storage/notification/.sqlx/query-e267af62eaa9b86a89b8c830122d47ab0252ac02a67ec0e7fa72c1ddc3791f04.json+++ b/rust/cloud-storage/notification/.sqlx/query-73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98.json@@ -1,22 +1,22 @@{"db_name": "PostgreSQL",- "query": "SELECT user_id FROM user_notification WHERE notification_id = $1",+ "query": "\n SELECT id\n FROM \"User\"\n WHERE email = $1\n ","describe": {"columns": [{"ordinal": 0,- "name": "user_id",+ "name": "id","type_info": "Text"}],"parameters": {"Left": [- "Uuid"+ "Text"]},"nullable": [false]},- "hash": "e267af62eaa9b86a89b8c830122d47ab0252ac02a67ec0e7fa72c1ddc3791f04"+ "hash": "73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98"}diff --git a/rust/cloud-storage/notification/.sqlx/query-d7db871243688236109f3c665819a0772f2f010406e4f1e17433c310b53c57da.json b/rust/cloud-storage/notification/.sqlx/query-d7db871243688236109f3c665819a0772f2f010406e4f1e17433c310b53c57da.jsondeleted file mode 100644index ba20677fc4..0000000000--- a/rust/cloud-storage/notification/.sqlx/query-d7db871243688236109f3c665819a0772f2f010406e4f1e17433c310b53c57da.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "INSERT INTO user_notification (user_id, notification_id, created_at) VALUES ($1, $2, '2025-01-01 00:00:00')",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Text",- "Uuid"- ]- },- "nullable": []- },- "hash": "d7db871243688236109f3c665819a0772f2f010406e4f1e17433c310b53c57da"-}diff --git a/rust/cloud-storage/notification/src/domain/models.rs b/rust/cloud-storage/notification/src/domain/models.rsindex 609f206cec..e17dc1c38e 100644--- a/rust/cloud-storage/notification/src/domain/models.rs+++ b/rust/cloud-storage/notification/src/domain/models.rs@@ -8,7 +8,7 @@ pub mod apple;pub mod email_notification_digest;pub mod mobile;-pub(crate) mod queue_message;+pub mod queue_message;pub mod rate_limit;pub mod recipient;pub mod request;diff --git a/rust/cloud-storage/notification/src/domain/models/queue_message.rs b/rust/cloud-storage/notification/src/domain/models/queue_message.rsindex 0654a3421a..f0b3a8ae40 100644--- a/rust/cloud-storage/notification/src/domain/models/queue_message.rs+++ b/rust/cloud-storage/notification/src/domain/models/queue_message.rs@@ -1,3 +1,5 @@+//! Queue message models for notification delivery via SQS.+use crate::domain::models::{Notification, RateLimitConfig, RateLimitKey, SendNotificationRequest, TaggedContent,apple::APNSPushNotification, mobile::MessageAttributes,@@ -14,6 +16,7 @@ use uuid::Uuid;pub struct APNSTargets<T> {/// The APNS notification payload.pub notif: APNSPushNotification<T>,+ /// The APNS message attributes.pub attributes: MessageAttributes,/// The iOS device endpoints to deliver to.pub ios_device_endpoints: Vec<String>,@@ -33,6 +36,7 @@ pub struct EmailContent {pub struct EmailNotification<'a> {/// The recipient email/user ID.pub to: MacroUserIdStr<'a>,+ /// The email content (subject and body).pub content: EmailContent,}@@ -40,29 +44,29 @@ pub struct EmailNotification<'a> {#[derive(Debug, Clone, Serialize, Deserialize)]pub struct ConnGatewayInnerNotif<T> {/// The notification ID.- pub(crate) notification_id: uuid::Uuid,+ pub notification_id: uuid::Uuid,/// The notification event type string (e.g. "channel_mention")./// TODO make this a new type- pub(crate) notification_event_type: String,+ pub notification_event_type: String,/// The entity the notification is about.#[serde(flatten)]- pub(crate) entity: Entity<'static>,+ pub entity: Entity<'static>,/// Whether the notification has been sent.- pub(crate) sent: bool,+ pub sent: bool,/// Whether the notification is marked as done.- pub(crate) done: bool,+ pub done: bool,/// When the notification was created.- pub(crate) created_at: Option<DateTime<Utc>>,+ pub created_at: Option<DateTime<Utc>>,/// When the notification was viewed/seen.- pub(crate) viewed_at: Option<DateTime<Utc>>,+ pub viewed_at: Option<DateTime<Utc>>,/// When the notification was last updated.- pub(crate) updated_at: Option<DateTime<Utc>>,+ pub updated_at: Option<DateTime<Utc>>,/// When the notification was deleted.- pub(crate) deleted_at: Option<DateTime<Utc>>,+ pub deleted_at: Option<DateTime<Utc>>,/// Deserialized notification metadata.- pub(crate) notification_metadata: TaggedContent<T>,+ pub notification_metadata: TaggedContent<T>,/// The user who triggered the notification.- pub(crate) sender_id: Option<MacroUserIdStr<'static>>,+ pub sender_id: Option<MacroUserIdStr<'static>>,}/// Connection gateway (WebSocket) notification payload.@@ -97,6 +101,7 @@ impl<'a, T: Notification + Clone> ConnGatewayNotification<'a, T> {#[cfg(test)]impl<'a, T: Notification> ConnGatewayNotification<'a, T> {+ /// function which is used for testing do not use in runtime codepub fn testing_to_value(self) -> ConnGatewayNotification<'a, serde_json::Value> {let ConnGatewayNotification {notif:@@ -200,10 +205,13 @@ pub enum DeliverySuccess {Email,}+/// Failure during notification delivery.#[derive(Debug, Error)]pub enum DeliveryFailure {+ /// The rate limit for this notification type was exceeded.#[error("The rate limit was exceeded")]RateLimit,+ /// A delivery error occurred.#[error("A delivery error occured")]Other,}diff --git a/rust/cloud-storage/notification_service/src/api/user_notification.rs b/rust/cloud-storage/notification_service/src/api/user_notification.rsindex 268fd3d279..d5c0f3df03 100644--- a/rust/cloud-storage/notification_service/src/api/user_notification.rs+++ b/rust/cloud-storage/notification_service/src/api/user_notification.rs@@ -11,7 +11,6 @@ use utoipa::ToSchema;mod test;#[derive(Debug, Serialize, ToSchema)]-#[serde(rename_all = "camelCase")]pub struct ApiUserNotification {/// The user who owns this notification.#[schema(value_type = String)]diff --git a/rust/cloud-storage/notification_service/src/api/user_notification/test.rs b/rust/cloud-storage/notification_service/src/api/user_notification/test.rsindex 350ff72e9d..20ba042ce4 100644--- a/rust/cloud-storage/notification_service/src/api/user_notification/test.rs+++ b/rust/cloud-storage/notification_service/src/api/user_notification/test.rs@@ -194,6 +194,88 @@ fn to_typed_row_preserves_row_fields() {}}+/// Verifies that the `notification_metadata` field serializes identically between+/// `ApiUserNotification` and `ConnGatewayInnerNotif`.+/// This ensures frontend code can use the same parsing logic for both HTTP API and WebSocket delivery.+#[test]+fn api_user_notification_and_conn_gateway_inner_notif_metadata_serialize_identically() {+ use chrono::{TimeZone, Utc};+ use notification::domain::models::TaggedContent;+ use notification::domain::models::queue_message::ConnGatewayInnerNotif;++ let created_at = Utc.with_ymd_and_hms(2025, 1, 15, 12, 0, 0).unwrap();+ let notification_id = uuid::Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000").unwrap();+ let entity = EntityType::Document.with_entity_string("doc-123".to_string());++ let notif_metadata = ChannelMentionMetadata {+ message_id: "msg-1".to_string(),+ message_content: "Hello @user".to_string(),+ thread_id: None,+ common: model_notifications::CommonChannelMetadata {+ channel_type: model_notifications::ChannelType::Public,+ channel_name: "general".to_string(),+ },+ };++ // Create ApiUserNotification (used by HTTP API)+ let api_notif = ApiUserNotification {+ owner_id: MacroUserIdStr::parse_from_str("macro|[email protected]")+ .unwrap()+ .into_owned(),+ notification_id,+ notification_event_type: "channel_mention".to_string(),+ entity: entity.clone(),+ sent: true,+ done: false,+ created_at: Some(created_at),+ viewed_at: None,+ updated_at: None,+ deleted_at: None,+ notification_metadata: NotifEvent::ChannelMention(notif_metadata.clone()),+ sender_id: Some(+ MacroUserIdStr::parse_from_str("macro|[email protected]")+ .unwrap()+ .into_owned(),+ ),+ };++ // Create ConnGatewayInnerNotif (used by WebSocket delivery)+ let conn_gateway_notif = ConnGatewayInnerNotif {+ notification_id,+ notification_event_type: "channel_mention".to_string(),+ entity,+ sent: true,+ done: false,+ created_at: Some(created_at),+ viewed_at: None,+ updated_at: None,+ deleted_at: None,+ notification_metadata: TaggedContent::new(notif_metadata),+ sender_id: Some(+ MacroUserIdStr::parse_from_str("macro|[email protected]")+ .unwrap()+ .into_owned(),+ ),+ };++ let api_json = serde_json::to_value(&api_notif).unwrap();+ let conn_gateway_json = serde_json::to_value(&conn_gateway_notif).unwrap();++ let key = "notification_metadata";+ let api_metadata = &api_json[key];+ let conn_gateway_metadata = &conn_gateway_json[key];++ assert_eq!(+ api_metadata,+ conn_gateway_metadata,+ "notification_metadata should serialize identically.\n\+ ApiUserNotification (HTTP API): {}\n\+ ConnGatewayInnerNotif (WebSocket): {}",+ serde_json::to_string_pretty(api_metadata).unwrap(),+ serde_json::to_string_pretty(conn_gateway_metadata).unwrap(),+ );+}+/// Verifies that `TaggedContent<T>` (used by ConnGatewayInnerNotif for WebSocket delivery)/// and `NotifEvent` (used by ApiUserNotification for HTTP API) serialize identically./// This ensures frontend code can use the same parsing logic for both delivery methods.