@burdenoff/microfe-notification 2026.1127.1 → 2026.1129.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NotificationRoutes.d.ts +10 -0
- package/dist/NotificationRoutes.js +76 -71
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/generated/global-operations.d.ts +62 -3
- package/dist/generated/global-operations.js +35 -23
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.d.ts +10933 -581
- package/dist/hooks/useNotificationAnalytics.d.ts +1 -1
- package/dist/hooks/useNotificationAnalytics.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +3 -0
- package/dist/hooks/useNotifications.d.ts +7 -0
- package/dist/hooks/useNotifications.js +1 -1
- package/dist/hooks/useNotifications.js.map +1 -1
- package/dist/translations/en.d.ts +204 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/v2/ArchivedRedirect.d.ts +1 -0
- package/dist/v2/ArchivedRedirect.js +14 -0
- package/dist/v2/ArchivedRedirect.js.map +1 -0
- package/dist/v2/InboxPage.d.ts +1 -0
- package/dist/v2/InboxPage.js +191 -0
- package/dist/v2/InboxPage.js.map +1 -0
- package/dist/v2/InboxRows.d.ts +10 -0
- package/dist/v2/InboxRows.js +101 -0
- package/dist/v2/InboxRows.js.map +1 -0
- package/dist/v2/KindIcon.d.ts +4 -0
- package/dist/v2/KindIcon.js +33 -0
- package/dist/v2/KindIcon.js.map +1 -0
- package/dist/v2/NotificationDetailPanel.d.ts +8 -0
- package/dist/v2/NotificationDetailPanel.js +200 -0
- package/dist/v2/NotificationDetailPanel.js.map +1 -0
- package/dist/v2/PreferencesPage.d.ts +1 -0
- package/dist/v2/PreferencesPage.js +139 -0
- package/dist/v2/PreferencesPage.js.map +1 -0
- package/dist/v2/__tests__/routeShapes.d.ts +13 -0
- package/dist/v2/admin/ChoiceSelect.d.ts +9 -0
- package/dist/v2/admin/ChoiceSelect.js +24 -0
- package/dist/v2/admin/ChoiceSelect.js.map +1 -0
- package/dist/v2/admin/DeliveryLogPage.d.ts +1 -0
- package/dist/v2/admin/DeliveryLogPage.js +207 -0
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -0
- package/dist/v2/admin/InsertDetail.d.ts +6 -0
- package/dist/v2/admin/InsertDetail.js +77 -0
- package/dist/v2/admin/InsertDetail.js.map +1 -0
- package/dist/v2/admin/TemplateEditor.d.ts +6 -0
- package/dist/v2/admin/TemplateEditor.js +92 -0
- package/dist/v2/admin/TemplateEditor.js.map +1 -0
- package/dist/v2/admin/TemplateFields.d.ts +9 -0
- package/dist/v2/admin/TemplateFields.js +130 -0
- package/dist/v2/admin/TemplateFields.js.map +1 -0
- package/dist/v2/admin/TemplatePage.d.ts +1 -0
- package/dist/v2/admin/TemplatePage.js +62 -0
- package/dist/v2/admin/TemplatePage.js.map +1 -0
- package/dist/v2/admin/TemplatePreview.d.ts +8 -0
- package/dist/v2/admin/TemplatePreview.js +112 -0
- package/dist/v2/admin/TemplatePreview.js.map +1 -0
- package/dist/v2/admin/TemplatesPage.d.ts +1 -0
- package/dist/v2/admin/TemplatesPage.js +173 -0
- package/dist/v2/admin/TemplatesPage.js.map +1 -0
- package/dist/v2/admin/TopicDialog.d.ts +11 -0
- package/dist/v2/admin/TopicDialog.js +113 -0
- package/dist/v2/admin/TopicDialog.js.map +1 -0
- package/dist/v2/admin/TopicsPage.d.ts +1 -0
- package/dist/v2/admin/TopicsPage.js +152 -0
- package/dist/v2/admin/TopicsPage.js.map +1 -0
- package/dist/v2/admin/templateText.d.ts +35 -0
- package/dist/v2/admin/templateText.js +109 -0
- package/dist/v2/admin/templateText.js.map +1 -0
- package/dist/v2/admin/useTemplateDraft.d.ts +32 -0
- package/dist/v2/admin/useTemplateDraft.js +117 -0
- package/dist/v2/admin/useTemplateDraft.js.map +1 -0
- package/dist/v2/admin/words.d.ts +15 -0
- package/dist/v2/admin/words.js +67 -0
- package/dist/v2/admin/words.js.map +1 -0
- package/dist/v2/model/days.d.ts +9 -0
- package/dist/v2/model/days.js +25 -0
- package/dist/v2/model/days.js.map +1 -0
- package/dist/v2/model/events.d.ts +17 -0
- package/dist/v2/model/events.js +72 -0
- package/dist/v2/model/events.js.map +1 -0
- package/dist/v2/model/icons.d.ts +6 -0
- package/dist/v2/model/icons.js +19 -0
- package/dist/v2/model/icons.js.map +1 -0
- package/dist/v2/model/inbox.d.ts +15 -0
- package/dist/v2/model/inbox.js +22 -0
- package/dist/v2/model/inbox.js.map +1 -0
- package/dist/v2/model/thing.d.ts +16 -0
- package/dist/v2/model/thing.js +41 -0
- package/dist/v2/model/thing.js.map +1 -0
- package/dist/v2/model/tr.d.ts +2 -0
- package/dist/v2/useNotificationDetail.d.ts +19 -0
- package/dist/v2/useNotificationDetail.js +65 -0
- package/dist/v2/useNotificationDetail.js.map +1 -0
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ interface NotificationAnalyticsPayload {
|
|
|
4
4
|
source?: 'center' | 'panel' | 'history' | 'preferences' | 'admin_history' | 'composer' | 'template_editor';
|
|
5
5
|
action?: 'open' | 'set' | 'reset' | 'send' | 'create' | 'update' | 'cancel' | 'reschedule';
|
|
6
6
|
interaction?: 'card' | 'primary_action' | 'custom_action';
|
|
7
|
-
scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC';
|
|
7
|
+
scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC' | 'CATEGORY';
|
|
8
8
|
channel?: string;
|
|
9
9
|
type?: string;
|
|
10
10
|
priority?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotificationAnalytics.js","names":["toNotificationOpenPayload","notification","useNotificationAnalytics","eventBus","useEventBus","emit","useCallback","name","payload","source","interaction","input"],"sources":["../../src/hooks/useNotificationAnalytics.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport type { Notification, NotificationPreferenceScope } from '../types';\nimport type {\n NotificationChannelType,\n NotificationPriorityEnum,\n NotificationTypeEnum,\n} from './useSendNotification';\n\ntype NotificationAnalyticsName =\n | 'notification.item.opened'\n | 'notification.preference.updated'\n | 'notification.admin.sent'\n | 'notification.template.saved'\n | 'notification.schedule.updated';\n\ninterface NotificationAnalyticsPayload {\n source?:\n | 'center'\n | 'panel'\n | 'history'\n | 'preferences'\n | 'admin_history'\n | 'composer'\n | 'template_editor';\n action?: 'open' | 'set' | 'reset' | 'send' | 'create' | 'update' | 'cancel' | 'reschedule';\n interaction?: 'card' | 'primary_action' | 'custom_action';\n scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC';\n channel?: string;\n type?: string;\n priority?: string;\n mode?: 'compose' | 'template';\n recipientSource?: 'manual' | 'directory';\n recipientCount?: number;\n successCount?: number;\n failedCount?: number;\n scheduled?: boolean;\n includeInApp?: boolean;\n enabled?: boolean;\n hasActions?: boolean;\n hasMedia?: boolean;\n hasHtml?: boolean;\n variableCount?: number;\n}\n\ninterface NotificationAnalyticsEventBus {\n emit: (\n name: NotificationAnalyticsName,\n payload: NotificationAnalyticsPayload,\n options?: { component?: string }\n ) => void;\n}\n\ntype NotificationAnalyticsSource = NonNullable<NotificationAnalyticsPayload['source']>;\ntype NotificationAnalyticsAction = NonNullable<NotificationAnalyticsPayload['action']>;\ntype NotificationInteraction = NonNullable<NotificationAnalyticsPayload['interaction']>;\n\ninterface NotificationSentInput {\n mode: 'compose' | 'template';\n channel: NotificationChannelType;\n type?: NotificationTypeEnum | string;\n priority?: NotificationPriorityEnum | string;\n recipientSource: 'manual' | 'directory';\n recipientCount: number;\n successCount?: number;\n failedCount?: number;\n scheduled: boolean;\n includeInApp: boolean;\n hasActions: boolean;\n hasMedia: boolean;\n}\n\ninterface TemplateSavedInput {\n action: Extract<NotificationAnalyticsAction, 'create' | 'update'>;\n channel?: string;\n type?: string;\n variableCount: number;\n hasHtml?: boolean;\n}\n\ninterface PreferenceUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'set' | 'reset'>;\n scope: NotificationPreferenceScope;\n channel?: string;\n type?: string;\n enabled?: boolean;\n}\n\ninterface ScheduleUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'cancel' | 'reschedule'>;\n}\n\nfunction toNotificationOpenPayload(\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n): NotificationAnalyticsPayload {\n return {\n source,\n action: 'open',\n interaction,\n channel: notification.channel,\n type: notification.type,\n priority: notification.priority,\n hasActions: Boolean(notification.actionUrl || notification.actions.length > 0),\n hasMedia: notification.media.length > 0,\n };\n}\n\nexport function useNotificationAnalytics() {\n const eventBus = useEventBus();\n\n const emit = useCallback(\n (name: NotificationAnalyticsName, payload: NotificationAnalyticsPayload) => {\n // The runtime event bus accepts string names; this local typed facade keeps\n // notification emissions constrained to the sparse Rybbit allowlist while\n // consuming app shells roll forward to the updated fe-libs event registry.\n const notificationEventBus = eventBus as unknown as NotificationAnalyticsEventBus;\n notificationEventBus.emit(name, payload, { component: 'microfe-notification' });\n },\n [eventBus]\n );\n\n const trackNotificationOpened = useCallback(\n (\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n ) =>\n emit(\n 'notification.item.opened',\n toNotificationOpenPayload(notification, source, interaction)\n ),\n [emit]\n );\n\n const trackPreferenceUpdated = useCallback(\n (input: PreferenceUpdatedInput) =>\n emit('notification.preference.updated', {\n source: 'preferences',\n action: input.action,\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: input.enabled,\n }),\n [emit]\n );\n\n const trackNotificationSent = useCallback(\n (input: NotificationSentInput) =>\n emit('notification.admin.sent', {\n source: 'composer',\n action: 'send',\n mode: input.mode,\n channel: input.channel,\n type: input.type,\n priority: input.priority,\n recipientSource: input.recipientSource,\n recipientCount: input.recipientCount,\n successCount: input.successCount,\n failedCount: input.failedCount,\n scheduled: input.scheduled,\n includeInApp: input.includeInApp,\n hasActions: input.hasActions,\n hasMedia: input.hasMedia,\n }),\n [emit]\n );\n\n const trackTemplateSaved = useCallback(\n (input: TemplateSavedInput) =>\n emit('notification.template.saved', {\n source: 'template_editor',\n action: input.action,\n channel: input.channel,\n type: input.type,\n variableCount: input.variableCount,\n hasHtml: input.hasHtml,\n }),\n [emit]\n );\n\n const trackScheduleUpdated = useCallback(\n (input: ScheduleUpdatedInput) =>\n emit('notification.schedule.updated', {\n source: 'admin_history',\n action: input.action,\n scheduled: input.action === 'reschedule',\n }),\n [emit]\n );\n\n return {\n trackNotificationOpened,\n trackPreferenceUpdated,\n trackNotificationSent,\n trackTemplateSaved,\n trackScheduleUpdated,\n };\n}\n"],"mappings":";;;AA4FA,SAASA,EACP,GACA,GACA,GAC8B;CAC9B,OAAO;EACL;EACA,QAAQ;EACR;EACA,SAASC,EAAa;EACtB,MAAMA,EAAa;EACnB,UAAUA,EAAa;EACvB,YAAY,GAAQA,EAAa,aAAaA,EAAa,QAAQ,SAAS;EAC5E,UAAUA,EAAa,MAAM,SAAS;CACxC;AACF;AAEA,SAAgBC,IAA2B;CACzC,IAAMC,IAAWC,EAAY,GAEvBC,IAAOC,GACV,GAAiC,MAA0C;EAK1E,EAAqB,KAAKC,GAAMC,GAAS,EAAE,WAAW,uBAAuB,CAAC;CAChF,GACA,CAACL,CAAQ,CACX;CAwEA,OAAO;EACL,yBAvE8BG,GAE5B,GACA,GACA,MAEAD,EACE,4BACAL,EAA0BC,GAAcQ,GAAQC,CAAW,CAC7D,GACF,CAACL,CAAI,CA6DL;EACA,wBA3D6BC,GAC5B,MACCD,EAAK,mCAAmC;GACtC,QAAQ;GACR,QAAQM,EAAM;GACd,OAAOA,EAAM;GACb,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,SAASA,EAAM;EACjB,CAAC,GACH,CAACN,CAAI,CAiDL;EACA,uBA/C4BC,GAC3B,MACCD,EAAK,2BAA2B;GAC9B,QAAQ;GACR,QAAQ;GACR,MAAMM,EAAM;GACZ,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,UAAUA,EAAM;GAChB,iBAAiBA,EAAM;GACvB,gBAAgBA,EAAM;GACtB,cAAcA,EAAM;GACpB,aAAaA,EAAM;GACnB,WAAWA,EAAM;GACjB,cAAcA,EAAM;GACpB,YAAYA,EAAM;GAClB,UAAUA,EAAM;EAClB,CAAC,GACH,CAACN,CAAI,CA6BL;EACA,oBA3ByBC,GACxB,MACCD,EAAK,+BAA+B;GAClC,QAAQ;GACR,QAAQM,EAAM;GACd,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,eAAeA,EAAM;GACrB,SAASA,EAAM;EACjB,CAAC,GACH,CAACN,CAAI,CAiBL;EACA,sBAf2BC,GAC1B,MACCD,EAAK,iCAAiC;GACpC,QAAQ;GACR,QAAQM,EAAM;GACd,WAAWA,EAAM,WAAW;EAC9B,CAAC,GACH,CAACN,CAAI,CAQL;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotificationAnalytics.js","names":["toNotificationOpenPayload","notification","useNotificationAnalytics","eventBus","useEventBus","emit","useCallback","name","payload","source","interaction","input"],"sources":["../../src/hooks/useNotificationAnalytics.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport type { Notification, NotificationPreferenceScope } from '../types';\nimport type {\n NotificationChannelType,\n NotificationPriorityEnum,\n NotificationTypeEnum,\n} from './useSendNotification';\n\ntype NotificationAnalyticsName =\n | 'notification.item.opened'\n | 'notification.preference.updated'\n | 'notification.admin.sent'\n | 'notification.template.saved'\n | 'notification.schedule.updated';\n\ninterface NotificationAnalyticsPayload {\n source?:\n | 'center'\n | 'panel'\n | 'history'\n | 'preferences'\n | 'admin_history'\n | 'composer'\n | 'template_editor';\n action?: 'open' | 'set' | 'reset' | 'send' | 'create' | 'update' | 'cancel' | 'reschedule';\n interaction?: 'card' | 'primary_action' | 'custom_action';\n scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC' | 'CATEGORY';\n channel?: string;\n type?: string;\n priority?: string;\n mode?: 'compose' | 'template';\n recipientSource?: 'manual' | 'directory';\n recipientCount?: number;\n successCount?: number;\n failedCount?: number;\n scheduled?: boolean;\n includeInApp?: boolean;\n enabled?: boolean;\n hasActions?: boolean;\n hasMedia?: boolean;\n hasHtml?: boolean;\n variableCount?: number;\n}\n\ninterface NotificationAnalyticsEventBus {\n emit: (\n name: NotificationAnalyticsName,\n payload: NotificationAnalyticsPayload,\n options?: { component?: string }\n ) => void;\n}\n\ntype NotificationAnalyticsSource = NonNullable<NotificationAnalyticsPayload['source']>;\ntype NotificationAnalyticsAction = NonNullable<NotificationAnalyticsPayload['action']>;\ntype NotificationInteraction = NonNullable<NotificationAnalyticsPayload['interaction']>;\n\ninterface NotificationSentInput {\n mode: 'compose' | 'template';\n channel: NotificationChannelType;\n type?: NotificationTypeEnum | string;\n priority?: NotificationPriorityEnum | string;\n recipientSource: 'manual' | 'directory';\n recipientCount: number;\n successCount?: number;\n failedCount?: number;\n scheduled: boolean;\n includeInApp: boolean;\n hasActions: boolean;\n hasMedia: boolean;\n}\n\ninterface TemplateSavedInput {\n action: Extract<NotificationAnalyticsAction, 'create' | 'update'>;\n channel?: string;\n type?: string;\n variableCount: number;\n hasHtml?: boolean;\n}\n\ninterface PreferenceUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'set' | 'reset'>;\n scope: NotificationPreferenceScope;\n channel?: string;\n type?: string;\n enabled?: boolean;\n}\n\ninterface ScheduleUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'cancel' | 'reschedule'>;\n}\n\nfunction toNotificationOpenPayload(\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n): NotificationAnalyticsPayload {\n return {\n source,\n action: 'open',\n interaction,\n channel: notification.channel,\n type: notification.type,\n priority: notification.priority,\n hasActions: Boolean(notification.actionUrl || notification.actions.length > 0),\n hasMedia: notification.media.length > 0,\n };\n}\n\nexport function useNotificationAnalytics() {\n const eventBus = useEventBus();\n\n const emit = useCallback(\n (name: NotificationAnalyticsName, payload: NotificationAnalyticsPayload) => {\n // The runtime event bus accepts string names; this local typed facade keeps\n // notification emissions constrained to the sparse Rybbit allowlist while\n // consuming app shells roll forward to the updated fe-libs event registry.\n const notificationEventBus = eventBus as unknown as NotificationAnalyticsEventBus;\n notificationEventBus.emit(name, payload, { component: 'microfe-notification' });\n },\n [eventBus]\n );\n\n const trackNotificationOpened = useCallback(\n (\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n ) =>\n emit(\n 'notification.item.opened',\n toNotificationOpenPayload(notification, source, interaction)\n ),\n [emit]\n );\n\n const trackPreferenceUpdated = useCallback(\n (input: PreferenceUpdatedInput) =>\n emit('notification.preference.updated', {\n source: 'preferences',\n action: input.action,\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: input.enabled,\n }),\n [emit]\n );\n\n const trackNotificationSent = useCallback(\n (input: NotificationSentInput) =>\n emit('notification.admin.sent', {\n source: 'composer',\n action: 'send',\n mode: input.mode,\n channel: input.channel,\n type: input.type,\n priority: input.priority,\n recipientSource: input.recipientSource,\n recipientCount: input.recipientCount,\n successCount: input.successCount,\n failedCount: input.failedCount,\n scheduled: input.scheduled,\n includeInApp: input.includeInApp,\n hasActions: input.hasActions,\n hasMedia: input.hasMedia,\n }),\n [emit]\n );\n\n const trackTemplateSaved = useCallback(\n (input: TemplateSavedInput) =>\n emit('notification.template.saved', {\n source: 'template_editor',\n action: input.action,\n channel: input.channel,\n type: input.type,\n variableCount: input.variableCount,\n hasHtml: input.hasHtml,\n }),\n [emit]\n );\n\n const trackScheduleUpdated = useCallback(\n (input: ScheduleUpdatedInput) =>\n emit('notification.schedule.updated', {\n source: 'admin_history',\n action: input.action,\n scheduled: input.action === 'reschedule',\n }),\n [emit]\n );\n\n return {\n trackNotificationOpened,\n trackPreferenceUpdated,\n trackNotificationSent,\n trackTemplateSaved,\n trackScheduleUpdated,\n };\n}\n"],"mappings":";;;AA4FA,SAASA,EACP,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AAK,iCAAiC;GACpC,QAAQ;GACR,QAAQM,EAAM;GACd,WAAWA,EAAM,WAAW;EAC9B,CAAC,GACH,CAACN,CAAI,CAQL;CACF;AACF"}
|
|
@@ -55,6 +55,7 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
|
|
|
55
55
|
name: string;
|
|
56
56
|
description: string | null;
|
|
57
57
|
type: import('../generated/global-types').NotificationType;
|
|
58
|
+
channel: import('../generated/global-types').NotificationChannel;
|
|
58
59
|
locale: string;
|
|
59
60
|
subject: string | null;
|
|
60
61
|
bodyTemplate: string;
|
|
@@ -73,6 +74,7 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
|
|
|
73
74
|
name: string;
|
|
74
75
|
description: string | null;
|
|
75
76
|
type: import('../generated/global-types').NotificationType;
|
|
77
|
+
channel: import('../generated/global-types').NotificationChannel;
|
|
76
78
|
locale: string;
|
|
77
79
|
subject: string | null;
|
|
78
80
|
bodyTemplate: string;
|
|
@@ -113,6 +115,7 @@ export declare function useNotificationTemplate(slug: string | undefined, locale
|
|
|
113
115
|
name: string;
|
|
114
116
|
description: string | null;
|
|
115
117
|
type: import('../generated/global-types').NotificationType;
|
|
118
|
+
channel: import('../generated/global-types').NotificationChannel;
|
|
116
119
|
locale: string;
|
|
117
120
|
subject: string | null;
|
|
118
121
|
bodyTemplate: string;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { Notification, NotificationFilter } from '../types';
|
|
2
|
+
import { NotificationFieldsFragment } from '../generated/global-operations';
|
|
3
|
+
/**
|
|
4
|
+
* Backend Notification item type derived from the generated query
|
|
5
|
+
*/
|
|
6
|
+
type BackendNotification = NotificationFieldsFragment;
|
|
2
7
|
interface UseNotificationsOptions {
|
|
3
8
|
baseFilter?: Partial<NotificationFilter>;
|
|
4
9
|
unreadFilter?: Record<string, unknown>;
|
|
5
10
|
}
|
|
11
|
+
/** The GraphQL notification as the module's `Notification` (also used by the v2 detail panel). */
|
|
12
|
+
export declare function mapBackendToMfeNotification(n: BackendNotification): Notification;
|
|
6
13
|
/**
|
|
7
14
|
* Hook to manage notifications with real GraphQL backend integration.
|
|
8
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetMyUnreadNotificationCountDocument","NotificationOps.MarkNotificationAsReadDocument","NotificationOps.MarkAllMyNotificationsAsReadDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.ArchiveNotificationsDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.RecordNotificationActionDocument","NotificationOps.NotificationReceivedDocument","NotificationOps.UnreadCountUpdatedDocument","mapBackendToMfeNotification","n","mapNotificationType","mapPriority","action","item","mapStatus","t","p","s","buildBackendFilter","backend","filter","mergeNotificationFilter","baseFilter","useNotifications","useNotification","setStoreUnreadCount","useNotificationStore","notifications","setNotifications","useState","selectedNotification","setSelectedNotification","isLoading","setIsLoading","error","setError","hasMore","setHasMore","total","setTotal","isLoadingMore","setIsLoadingMore","loadingMoreRef","useRef","listGenerationRef","pagedIdsRef","refreshSeqRef","replacingListRef","notificationsRef","effectiveFilter","useMemo","notificationFilter","options","debouncedFilter","setDebouncedFilter","timeout","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","generation","setIsLoadingNotifications","result","USER_NOTIFICATION_CONTEXT","GetNotificationsDocument","mapped","notification","err","message","fetchUnreadCount","GetMyUnreadNotificationCountDocument","loadMore","pageWindow","nextNotificationWindow","more","appendNotificationPage","prev","refreshFirstPage","refresh","freshTotal","firstPageHasMore","firstPage","items","merged","mergeRefreshedFirstPage","handleMarkAsRead","MarkNotificationAsReadDocument","notificationId","unreadCount","handleMarkAllAsRead","MarkAllMyNotificationsAsReadDocument","handleArchive","ArchiveNotificationDocument","handleBulkArchive","ArchiveNotificationsDocument","idsSet","notificationIds","handleUnarchive","UnarchiveNotificationDocument","handleRecordAction","RecordNotificationActionDocument","useEffect","currentUser","client","notificationSubscription","NotificationReceivedDocument","eventBus","unreadSubscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","updateNotificationFilter","resetNotificationFilter"],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport {\n NOTIFICATION_PAGE_SIZE,\n appendNotificationPage,\n mergeRefreshedFirstPage,\n nextNotificationWindow,\n} from './notificationPaging';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\n NotificationFieldsFragment,\n NotificationReceivedSubscription,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\n\n// ---------------------------------------------------------------------------\n// GraphQL Operations — using generated Document nodes from global-operations\n// ---------------------------------------------------------------------------\n\n/**\n * Backend Notification item type derived from the generated query\n */\ntype BackendNotification = NotificationFieldsFragment;\n\ninterface UseNotificationsOptions {\n baseFilter?: Partial<NotificationFilter>;\n unreadFilter?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Mapping helpers — backend → MFE types\n// ---------------------------------------------------------------------------\n\nfunction mapBackendToMfeNotification(n: BackendNotification): Notification {\n return {\n id: n.id,\n type: mapNotificationType(n.type),\n priority: mapPriority(n.priority),\n title: n.title,\n body: n.message,\n actionUrl: n.redirectUrl ?? undefined,\n actions: (n.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n appName: n.appName ?? undefined,\n archivedAt: n.archivedAt ?? undefined,\n channel: n.channel as Notification['channel'],\n clickedAt: n.clickedAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n deliveryStatus: n.deliveryStatus ?? undefined,\n htmlBody: n.htmlMessage ?? undefined,\n media: (n.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n openedAt: n.openedAt ?? undefined,\n recipientEmail: n.recipientEmail ?? undefined,\n recipientPhone: n.recipientPhone ?? undefined,\n scheduledFor: n.scheduledFor ?? undefined,\n scheduledNotification: n.scheduledNotification\n ? {\n id: n.scheduledNotification.id,\n scheduledFor: n.scheduledNotification.scheduledFor,\n status: n.scheduledNotification.status,\n timezone: n.scheduledNotification.timezone ?? undefined,\n }\n : undefined,\n sentAt: n.sentAt ?? undefined,\n status: mapStatus(n.status),\n readAt: n.readAt ?? undefined,\n createdAt: n.createdAt,\n channels: [\n {\n id: n.id,\n channel: n.channel as Notification['channel'],\n status: mapStatus(n.status),\n sentAt: n.sentAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n failedAt: n.failedAt ?? undefined,\n errorCode: n.errorCode ?? undefined,\n errorMessage: n.errorMessage ?? undefined,\n },\n ],\n metadata: n.metadata ?? undefined,\n topic: n.topic\n ? {\n id: n.topic.id,\n name: n.topic.name,\n slug: n.topic.slug,\n type: mapNotificationType(n.topic.type),\n }\n : undefined,\n topicId: n.topicId ?? undefined,\n };\n}\n\nfunction mapNotificationType(t: string) {\n const map: Record<string, Notification['type']> = {\n SYSTEM: 'SYSTEM',\n TRANSACTIONAL: 'TRANSACTIONAL',\n MARKETING: 'MARKETING',\n ALERT: 'ALERT',\n };\n return map[t] || 'SYSTEM';\n}\n\nfunction mapPriority(p: string) {\n const map: Record<string, Notification['priority']> = {\n LOW: 'LOW',\n MEDIUM: 'NORMAL',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n return map[p] || 'NORMAL';\n}\n\nfunction mapStatus(s: string) {\n const map: Record<string, Notification['status']> = {\n DRAFT: 'PENDING',\n PENDING: 'PENDING',\n SCHEDULED: 'PENDING',\n TRIGGERED: 'SENT',\n SENT: 'SENT',\n DELIVERED: 'DELIVERED',\n READ: 'DELIVERED',\n FAILED: 'FAILED',\n CANCELLED: 'ARCHIVED',\n EXPIRED: 'ARCHIVED',\n };\n return map[s] || 'PENDING';\n}\n\n// ---------------------------------------------------------------------------\n// Build the backend filter from the MFE NotificationFilter shape\n// ---------------------------------------------------------------------------\n\nfunction buildBackendFilter(filter: NotificationFilter) {\n const backend: Record<string, unknown> = {};\n\n // Type filter — map MFE type names to backend enum\n if (filter.type !== 'ALL') {\n const typeMap: Record<string, string> = {\n SYSTEM: 'SYSTEM',\n ACTIVITY: 'TRANSACTIONAL',\n BILLING: 'TRANSACTIONAL',\n SECURITY: 'ALERT',\n SOCIAL: 'MARKETING',\n REMINDER: 'SYSTEM',\n };\n backend.type = typeMap[filter.type] || filter.type;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL') {\n const prioMap: Record<string, string> = {\n LOW: 'LOW',\n NORMAL: 'MEDIUM',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n backend.priority = prioMap[filter.priority] || filter.priority;\n }\n\n // Read/unread filter — coerce null to undefined\n if (filter.isRead !== null && filter.isRead !== undefined) {\n backend.isRead = filter.isRead;\n }\n\n if (filter.topicId) {\n backend.topicId = filter.topicId;\n }\n\n if (filter.channel && filter.channel !== 'ALL') {\n backend.channel = filter.channel;\n }\n\n if (filter.archived !== null && filter.archived !== undefined) {\n backend.archived = filter.archived;\n }\n\n if (filter.search) {\n backend.search = filter.search;\n }\n\n // Date range\n if (filter.dateRange.start) {\n backend.startDate = filter.dateRange.start.toISOString();\n }\n if (filter.dateRange.end) {\n backend.endDate = filter.dateRange.end.toISOString();\n }\n\n return Object.keys(backend).length > 0 ? backend : undefined;\n}\n\nfunction mergeNotificationFilter(\n filter: NotificationFilter,\n baseFilter?: Partial<NotificationFilter>\n): NotificationFilter {\n if (!baseFilter) return filter;\n\n return {\n ...filter,\n ...baseFilter,\n dateRange: {\n ...filter.dateRange,\n ...(baseFilter.dateRange || {}),\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to manage notifications with real GraphQL backend integration.\n *\n * Uses the global Apollo client to query the notification service via the\n * public gateway (https://gw-global.local.burdenoff.com/global/graphql).\n *\n * @example\n * ```tsx\n * const { notifications, unreadCount, markAsRead } = useNotifications();\n * ```\n */\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { authToken, apiGatewayUrl, currentUser, eventBus } = useNotification();\n const {\n notificationFilter,\n updateNotificationFilter,\n resetNotificationFilter,\n unreadCount,\n setUnreadCount: setStoreUnreadCount,\n setIsLoadingNotifications,\n } = useNotificationStore();\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [hasMore, setHasMore] = useState(false);\n const [total, setTotal] = useState(0);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n // One \"load more\" at a time; the state drives the list's loading row.\n const loadingMoreRef = useRef(false);\n // Bumped whenever the list starts over (a new filter, a refetch), so a page\n // that was requested for the previous list is dropped instead of appended.\n const listGenerationRef = useRef(0);\n // Ids that came from the server's pages for the current list, as opposed to\n // the live feed; only these set where the next page starts.\n const pagedIdsRef = useRef<Set<string>>(new Set());\n // Each tab-refresh gets a number; only the latest one's answer is used.\n const refreshSeqRef = useRef(0);\n // A new first page (new filter, refetch) is on its way: the loaded list is\n // about to be replaced, so no page may be added after it meanwhile.\n const replacingListRef = useRef(false);\n // The loaded list as of the last render, for the tab-refresh merge below.\n const notificationsRef = useRef<Notification[]>([]);\n useEffect(() => {\n notificationsRef.current = notifications;\n }, [notifications]);\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\n const [debouncedFilter, setDebouncedFilter] = useState(effectiveFilter);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => setDebouncedFilter(effectiveFilter), 250);\n return () => window.clearTimeout(timeout);\n }, [effectiveFilter]);\n\n // Client accessor — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n // ---- Fetch notifications ------------------------------------------------\n\n const fetchNotifications = useCallback(async () => {\n listGenerationRef.current += 1;\n const generation = listGenerationRef.current;\n replacingListRef.current = true;\n setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications && generation === listGenerationRef.current) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n pagedIdsRef.current = new Set(mapped.map((notification) => notification.id));\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch notifications';\n console.error('[useNotifications] Failed to fetch notifications:', err);\n setError(message);\n // The list on screen was loaded for an earlier filter: do not page it.\n if (generation === listGenerationRef.current) setHasMore(false);\n } finally {\n if (generation === listGenerationRef.current) replacingListRef.current = false;\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [debouncedFilter, getClient, setIsLoadingNotifications]);\n\n // ---- Fetch unread count -------------------------------------------------\n\n const fetchUnreadCount = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: options.unreadFilter || { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n if (result.data) {\n setStoreUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to fetch unread count:', err);\n }\n }, [getClient, options.unreadFilter, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore || loadingMoreRef.current || replacingListRef.current) return;\n const pageWindow = nextNotificationWindow(notifications, pagedIdsRef.current, debouncedFilter);\n if (!pageWindow) return;\n loadingMoreRef.current = true;\n setIsLoadingMore(true);\n const generation = listGenerationRef.current;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n // Everything at or before the oldest loaded notification (the\n // filter's own end date is never earlier than that).\n filter: buildBackendFilter({\n ...debouncedFilter,\n dateRange: { ...debouncedFilter.dateRange, end: pageWindow.before },\n }),\n limit: pageWindow.limit,\n offset: pageWindow.offset,\n },\n fetchPolicy: 'network-only',\n });\n\n // The list started over (new filter or refetch) while this page loaded.\n if (generation !== listGenerationRef.current) return;\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n for (const notification of more) pagedIdsRef.current.add(notification.id);\n setNotifications((prev) => appendNotificationPage(prev, more));\n // `total` here counts only the window, so the list's total stays as\n // the first page reported it.\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more notifications';\n console.error('[useNotifications] Failed to load more:', err);\n setError(message);\n } finally {\n loadingMoreRef.current = false;\n setIsLoadingMore(false);\n }\n }, [debouncedFilter, getClient, hasMore, notifications]);\n\n // Coming back to the tab: fetch the first page again for anything new, and\n // keep the older pages already scrolled through.\n const refreshFirstPage = useCallback(async () => {\n const generation = listGenerationRef.current;\n refreshSeqRef.current += 1;\n const refresh = refreshSeqRef.current;\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n // The list started over, or a later refresh superseded this one.\n if (\n generation !== listGenerationRef.current ||\n refresh !== refreshSeqRef.current ||\n !result.data?.notifications\n ) {\n return;\n }\n const { items, total: freshTotal, hasMore: firstPageHasMore } = result.data.notifications;\n const firstPage = items.map(mapBackendToMfeNotification);\n const merged = mergeRefreshedFirstPage(\n notificationsRef.current,\n firstPage,\n firstPageHasMore,\n pagedIdsRef.current\n );\n if (merged.continued) {\n // The older pages carry on after the fresh one: keep them, and\n // whether more exist is still what the last of them said.\n for (const notification of firstPage) pagedIdsRef.current.add(notification.id);\n setNotifications(merged.list);\n } else {\n // The list starts over from the fresh first page; a page still\n // loading belongs to the old list and is dropped when it arrives.\n listGenerationRef.current += 1;\n pagedIdsRef.current = new Set(firstPage.map((notification) => notification.id));\n setNotifications(merged.list);\n setHasMore(firstPageHasMore);\n }\n setTotal(freshTotal);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to refresh notifications:', err);\n }\n }, [debouncedFilter, getClient]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkNotificationAsReadDocument,\n variables: { id: notificationId },\n });\n // Optimistic: update local state\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, readAt: new Date().toISOString() } : n\n )\n );\n setStoreUnreadCount(Math.max(0, unreadCount - 1));\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark as read:', err);\n setError('Failed to mark notification as read');\n }\n },\n [getClient, setStoreUnreadCount, unreadCount]\n );\n\n const handleMarkAllAsRead = useCallback(async () => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument,\n });\n // Optimistic: update all local\n setNotifications((prev) =>\n prev.map((n) => ({ ...n, readAt: n.readAt || new Date().toISOString() }))\n );\n setStoreUnreadCount(0);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark all as read:', err);\n setError('Failed to mark all notifications as read');\n }\n }, [getClient, setStoreUnreadCount]);\n\n const handleArchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, archivedAt: new Date().toISOString() } : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to archive notification:', err);\n setError('Failed to archive notification');\n }\n },\n [getClient]\n );\n\n const handleBulkArchive = useCallback(\n async (notificationIds: string[]) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationsDocument,\n variables: { notificationIds },\n });\n const idsSet = new Set(notificationIds);\n setNotifications((prev) =>\n prev.map((n) => (idsSet.has(n.id) ? { ...n, archivedAt: new Date().toISOString() } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to bulk archive:', err);\n setError('Failed to archive notifications');\n }\n },\n [getClient]\n );\n\n const handleUnarchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, archivedAt: undefined } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to unarchive notification:', err);\n setError('Failed to restore notification');\n }\n },\n [getClient]\n );\n\n const handleRecordAction = useCallback(\n async (notificationId: string, actionId?: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.RecordNotificationActionDocument,\n variables: { input: { notificationId, actionId } },\n });\n\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId\n ? {\n ...n,\n clickedAt: new Date().toISOString(),\n readAt: n.readAt || new Date().toISOString(),\n }\n : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to record notification action:', err);\n setError('Failed to record notification action');\n }\n },\n [getClient]\n );\n\n // ---- Initial fetch on mount + when filter changes -----------------------\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n fetchUnreadCount();\n }, [fetchUnreadCount]);\n\n // ---- Live notification subscriptions ------------------------------------\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getClient();\n const notificationSubscription = client\n .subscribe<NotificationReceivedSubscription>({\n query: NotificationOps.NotificationReceivedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const notification = result.data?.notificationReceived;\n if (!notification) return;\n const mapped = mapBackendToMfeNotification(notification);\n setNotifications((prev) => [mapped, ...prev.filter((item) => item.id !== mapped.id)]);\n eventBus?.emit('notification:received', { notification: mapped });\n },\n error: (err) => {\n console.error('[useNotifications] Notification subscription failed:', err);\n },\n });\n\n const unreadSubscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: NotificationOps.UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setStoreUnreadCount(nextCount);\n eventBus?.emit('notification:unread-count-updated', { unreadCount: nextCount });\n }\n },\n error: (err) => {\n console.error('[useNotifications] Unread count subscription failed:', err);\n },\n });\n\n return () => {\n notificationSubscription.unsubscribe();\n unreadSubscription.unsubscribe();\n };\n }, [currentUser?.id, eventBus, getClient, setStoreUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n void refreshFirstPage();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshFirstPage, fetchUnreadCount]);\n\n const visibleNotifications = useMemo(\n () =>\n notifications.filter((notification) => {\n if (notification.deliveryStatus === 'UNSUBSCRIBED') {\n return false;\n }\n\n if (notification.status === 'ARCHIVED' && !notification.archivedAt) {\n return false;\n }\n\n if (effectiveFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (effectiveFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n }),\n [effectiveFilter.archived, notifications]\n );\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\n /** A further page is loading (infinite scroll). */\n isLoadingMore,\n error,\n hasMore,\n total,\n markAsRead: handleMarkAsRead,\n markAllAsRead: handleMarkAllAsRead,\n archiveNotification: handleArchive,\n bulkArchive: handleBulkArchive,\n unarchiveNotification: handleUnarchive,\n recordAction: handleRecordAction,\n setSelectedNotification,\n updateFilter: updateNotificationFilter,\n resetFilter: resetNotificationFilter,\n refetch: fetchNotifications,\n loadMore,\n };\n}\n"],"mappings":";;;;;;;AAsCA,SAASU,EAA4B,GAAsC;CACzE,OAAO;EACL,IAAIC,EAAE;EACN,MAAMC,EAAoBD,EAAE,IAAI;EAChC,UAAUE,EAAYF,EAAE,QAAQ;EAChC,OAAOA,EAAE;EACT,MAAMA,EAAE;EACR,WAAWA,EAAE,eAAe,KAAA;EAC5B,UAAUA,EAAE,WAAW,CAAC,EAAA,CAAG,KAAK,OAAY;GAC1C,IAAIG,EAAO;GACX,OAAOA,EAAO;GACd,KAAKA,EAAO;GACZ,OAAOA,EAAO,SAAS,KAAA;GACvB,YAAYA,EAAO,cAAc,KAAA;GACjC,UAAUA,EAAO,YAAY,KAAA;EAC/B,EAAE;EACF,SAASH,EAAE,WAAW,KAAA;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C,GAAkBR,CAAgB,CAAC,GA0BhC;EACL,eAzB2BrB,QAEzBvB,EAAc,QAAQ,MAChByC,EAAa,mBAAmB,kBAIhCA,EAAa,WAAW,cAAc,CAACA,EAAa,aAC/C,KAGLnB,EAAgB,aAAa,KACxB,EAAQmB,EAAa,aAG1BnB,EAAgB,aAAa,MACxB,CAACmB,EAAa,UAIxB,GACH,CAACnB,EAAgB,UAAUtB,CAAa,CAIzB;EACf,kBAAkBA;EAClB;EACA;EACA,oBAAoBsB;EACpB;EAEA;EACA;EACA;EACA;EACA,YAAYsC;EACZ,eAAeI;EACf,qBAAqBE;EACrB,aAAaE;EACb,uBAAuBI;EACvB,cAAcE;EACd;EACA,cAAcY;EACd,aAAaC;EACb,SAASrD;EACT;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotifications.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetMyUnreadNotificationCountDocument","NotificationOps.MarkNotificationAsReadDocument","NotificationOps.MarkAllMyNotificationsAsReadDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.ArchiveNotificationsDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.RecordNotificationActionDocument","NotificationOps.NotificationReceivedDocument","NotificationOps.UnreadCountUpdatedDocument","mapBackendToMfeNotification","n","mapNotificationType","mapPriority","action","item","mapStatus","t","p","s","buildBackendFilter","backend","filter","mergeNotificationFilter","baseFilter","useNotifications","useNotification","setStoreUnreadCount","useNotificationStore","notifications","setNotifications","useState","selectedNotification","setSelectedNotification","isLoading","setIsLoading","error","setError","hasMore","setHasMore","total","setTotal","isLoadingMore","setIsLoadingMore","loadingMoreRef","useRef","listGenerationRef","pagedIdsRef","refreshSeqRef","replacingListRef","notificationsRef","effectiveFilter","useMemo","notificationFilter","options","debouncedFilter","setDebouncedFilter","timeout","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","generation","setIsLoadingNotifications","result","USER_NOTIFICATION_CONTEXT","GetNotificationsDocument","mapped","notification","err","message","fetchUnreadCount","GetMyUnreadNotificationCountDocument","loadMore","pageWindow","nextNotificationWindow","more","appendNotificationPage","prev","refreshFirstPage","refresh","freshTotal","firstPageHasMore","firstPage","items","merged","mergeRefreshedFirstPage","handleMarkAsRead","MarkNotificationAsReadDocument","notificationId","unreadCount","handleMarkAllAsRead","MarkAllMyNotificationsAsReadDocument","handleArchive","ArchiveNotificationDocument","handleBulkArchive","ArchiveNotificationsDocument","idsSet","notificationIds","handleUnarchive","UnarchiveNotificationDocument","handleRecordAction","RecordNotificationActionDocument","useEffect","currentUser","client","notificationSubscription","NotificationReceivedDocument","eventBus","unreadSubscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","updateNotificationFilter","resetNotificationFilter"],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport {\n NOTIFICATION_PAGE_SIZE,\n appendNotificationPage,\n mergeRefreshedFirstPage,\n nextNotificationWindow,\n} from './notificationPaging';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\n NotificationFieldsFragment,\n NotificationReceivedSubscription,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\n\n// ---------------------------------------------------------------------------\n// GraphQL Operations — using generated Document nodes from global-operations\n// ---------------------------------------------------------------------------\n\n/**\n * Backend Notification item type derived from the generated query\n */\ntype BackendNotification = NotificationFieldsFragment;\n\ninterface UseNotificationsOptions {\n baseFilter?: Partial<NotificationFilter>;\n unreadFilter?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Mapping helpers — backend → MFE types\n// ---------------------------------------------------------------------------\n\n/** The GraphQL notification as the module's `Notification` (also used by the v2 detail panel). */\nexport function mapBackendToMfeNotification(n: BackendNotification): Notification {\n return {\n id: n.id,\n type: mapNotificationType(n.type),\n priority: mapPriority(n.priority),\n title: n.title,\n body: n.message,\n actionUrl: n.redirectUrl ?? undefined,\n actions: (n.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n appName: n.appName ?? undefined,\n archivedAt: n.archivedAt ?? undefined,\n channel: n.channel as Notification['channel'],\n clickedAt: n.clickedAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n deliveryStatus: n.deliveryStatus ?? undefined,\n htmlBody: n.htmlMessage ?? undefined,\n media: (n.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n openedAt: n.openedAt ?? undefined,\n recipientEmail: n.recipientEmail ?? undefined,\n recipientPhone: n.recipientPhone ?? undefined,\n scheduledFor: n.scheduledFor ?? undefined,\n scheduledNotification: n.scheduledNotification\n ? {\n id: n.scheduledNotification.id,\n scheduledFor: n.scheduledNotification.scheduledFor,\n status: n.scheduledNotification.status,\n timezone: n.scheduledNotification.timezone ?? undefined,\n }\n : undefined,\n sentAt: n.sentAt ?? undefined,\n status: mapStatus(n.status),\n readAt: n.readAt ?? undefined,\n createdAt: n.createdAt,\n channels: [\n {\n id: n.id,\n channel: n.channel as Notification['channel'],\n status: mapStatus(n.status),\n sentAt: n.sentAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n failedAt: n.failedAt ?? undefined,\n errorCode: n.errorCode ?? undefined,\n errorMessage: n.errorMessage ?? undefined,\n },\n ],\n metadata: n.metadata ?? undefined,\n topic: n.topic\n ? {\n id: n.topic.id,\n name: n.topic.name,\n slug: n.topic.slug,\n type: mapNotificationType(n.topic.type),\n }\n : undefined,\n topicId: n.topicId ?? undefined,\n };\n}\n\nfunction mapNotificationType(t: string) {\n const map: Record<string, Notification['type']> = {\n SYSTEM: 'SYSTEM',\n TRANSACTIONAL: 'TRANSACTIONAL',\n MARKETING: 'MARKETING',\n ALERT: 'ALERT',\n };\n return map[t] || 'SYSTEM';\n}\n\nfunction mapPriority(p: string) {\n const map: Record<string, Notification['priority']> = {\n LOW: 'LOW',\n MEDIUM: 'NORMAL',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n return map[p] || 'NORMAL';\n}\n\nfunction mapStatus(s: string) {\n const map: Record<string, Notification['status']> = {\n DRAFT: 'PENDING',\n PENDING: 'PENDING',\n SCHEDULED: 'PENDING',\n TRIGGERED: 'SENT',\n SENT: 'SENT',\n DELIVERED: 'DELIVERED',\n READ: 'DELIVERED',\n FAILED: 'FAILED',\n CANCELLED: 'ARCHIVED',\n EXPIRED: 'ARCHIVED',\n };\n return map[s] || 'PENDING';\n}\n\n// ---------------------------------------------------------------------------\n// Build the backend filter from the MFE NotificationFilter shape\n// ---------------------------------------------------------------------------\n\nfunction buildBackendFilter(filter: NotificationFilter) {\n const backend: Record<string, unknown> = {};\n\n // Type filter — map MFE type names to backend enum\n if (filter.type !== 'ALL') {\n const typeMap: Record<string, string> = {\n SYSTEM: 'SYSTEM',\n ACTIVITY: 'TRANSACTIONAL',\n BILLING: 'TRANSACTIONAL',\n SECURITY: 'ALERT',\n SOCIAL: 'MARKETING',\n REMINDER: 'SYSTEM',\n };\n backend.type = typeMap[filter.type] || filter.type;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL') {\n const prioMap: Record<string, string> = {\n LOW: 'LOW',\n NORMAL: 'MEDIUM',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n backend.priority = prioMap[filter.priority] || filter.priority;\n }\n\n // Read/unread filter — coerce null to undefined\n if (filter.isRead !== null && filter.isRead !== undefined) {\n backend.isRead = filter.isRead;\n }\n\n if (filter.topicId) {\n backend.topicId = filter.topicId;\n }\n\n if (filter.channel && filter.channel !== 'ALL') {\n backend.channel = filter.channel;\n }\n\n if (filter.archived !== null && filter.archived !== undefined) {\n backend.archived = filter.archived;\n }\n\n if (filter.search) {\n backend.search = filter.search;\n }\n\n // Date range\n if (filter.dateRange.start) {\n backend.startDate = filter.dateRange.start.toISOString();\n }\n if (filter.dateRange.end) {\n backend.endDate = filter.dateRange.end.toISOString();\n }\n\n return Object.keys(backend).length > 0 ? backend : undefined;\n}\n\nfunction mergeNotificationFilter(\n filter: NotificationFilter,\n baseFilter?: Partial<NotificationFilter>\n): NotificationFilter {\n if (!baseFilter) return filter;\n\n return {\n ...filter,\n ...baseFilter,\n dateRange: {\n ...filter.dateRange,\n ...(baseFilter.dateRange || {}),\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to manage notifications with real GraphQL backend integration.\n *\n * Uses the global Apollo client to query the notification service via the\n * public gateway (https://gw-global.local.burdenoff.com/global/graphql).\n *\n * @example\n * ```tsx\n * const { notifications, unreadCount, markAsRead } = useNotifications();\n * ```\n */\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { authToken, apiGatewayUrl, currentUser, eventBus } = useNotification();\n const {\n notificationFilter,\n updateNotificationFilter,\n resetNotificationFilter,\n unreadCount,\n setUnreadCount: setStoreUnreadCount,\n setIsLoadingNotifications,\n } = useNotificationStore();\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [hasMore, setHasMore] = useState(false);\n const [total, setTotal] = useState(0);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n // One \"load more\" at a time; the state drives the list's loading row.\n const loadingMoreRef = useRef(false);\n // Bumped whenever the list starts over (a new filter, a refetch), so a page\n // that was requested for the previous list is dropped instead of appended.\n const listGenerationRef = useRef(0);\n // Ids that came from the server's pages for the current list, as opposed to\n // the live feed; only these set where the next page starts.\n const pagedIdsRef = useRef<Set<string>>(new Set());\n // Each tab-refresh gets a number; only the latest one's answer is used.\n const refreshSeqRef = useRef(0);\n // A new first page (new filter, refetch) is on its way: the loaded list is\n // about to be replaced, so no page may be added after it meanwhile.\n const replacingListRef = useRef(false);\n // The loaded list as of the last render, for the tab-refresh merge below.\n const notificationsRef = useRef<Notification[]>([]);\n useEffect(() => {\n notificationsRef.current = notifications;\n }, [notifications]);\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\n const [debouncedFilter, setDebouncedFilter] = useState(effectiveFilter);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => setDebouncedFilter(effectiveFilter), 250);\n return () => window.clearTimeout(timeout);\n }, [effectiveFilter]);\n\n // Client accessor — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n // ---- Fetch notifications ------------------------------------------------\n\n const fetchNotifications = useCallback(async () => {\n listGenerationRef.current += 1;\n const generation = listGenerationRef.current;\n replacingListRef.current = true;\n setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications && generation === listGenerationRef.current) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n pagedIdsRef.current = new Set(mapped.map((notification) => notification.id));\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch notifications';\n console.error('[useNotifications] Failed to fetch notifications:', err);\n setError(message);\n // The list on screen was loaded for an earlier filter: do not page it.\n if (generation === listGenerationRef.current) setHasMore(false);\n } finally {\n if (generation === listGenerationRef.current) replacingListRef.current = false;\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [debouncedFilter, getClient, setIsLoadingNotifications]);\n\n // ---- Fetch unread count -------------------------------------------------\n\n const fetchUnreadCount = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: options.unreadFilter || { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n if (result.data) {\n setStoreUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to fetch unread count:', err);\n }\n }, [getClient, options.unreadFilter, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore || loadingMoreRef.current || replacingListRef.current) return;\n const pageWindow = nextNotificationWindow(notifications, pagedIdsRef.current, debouncedFilter);\n if (!pageWindow) return;\n loadingMoreRef.current = true;\n setIsLoadingMore(true);\n const generation = listGenerationRef.current;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n // Everything at or before the oldest loaded notification (the\n // filter's own end date is never earlier than that).\n filter: buildBackendFilter({\n ...debouncedFilter,\n dateRange: { ...debouncedFilter.dateRange, end: pageWindow.before },\n }),\n limit: pageWindow.limit,\n offset: pageWindow.offset,\n },\n fetchPolicy: 'network-only',\n });\n\n // The list started over (new filter or refetch) while this page loaded.\n if (generation !== listGenerationRef.current) return;\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n for (const notification of more) pagedIdsRef.current.add(notification.id);\n setNotifications((prev) => appendNotificationPage(prev, more));\n // `total` here counts only the window, so the list's total stays as\n // the first page reported it.\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more notifications';\n console.error('[useNotifications] Failed to load more:', err);\n setError(message);\n } finally {\n loadingMoreRef.current = false;\n setIsLoadingMore(false);\n }\n }, [debouncedFilter, getClient, hasMore, notifications]);\n\n // Coming back to the tab: fetch the first page again for anything new, and\n // keep the older pages already scrolled through.\n const refreshFirstPage = useCallback(async () => {\n const generation = listGenerationRef.current;\n refreshSeqRef.current += 1;\n const refresh = refreshSeqRef.current;\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n // The list started over, or a later refresh superseded this one.\n if (\n generation !== listGenerationRef.current ||\n refresh !== refreshSeqRef.current ||\n !result.data?.notifications\n ) {\n return;\n }\n const { items, total: freshTotal, hasMore: firstPageHasMore } = result.data.notifications;\n const firstPage = items.map(mapBackendToMfeNotification);\n const merged = mergeRefreshedFirstPage(\n notificationsRef.current,\n firstPage,\n firstPageHasMore,\n pagedIdsRef.current\n );\n if (merged.continued) {\n // The older pages carry on after the fresh one: keep them, and\n // whether more exist is still what the last of them said.\n for (const notification of firstPage) pagedIdsRef.current.add(notification.id);\n setNotifications(merged.list);\n } else {\n // The list starts over from the fresh first page; a page still\n // loading belongs to the old list and is dropped when it arrives.\n listGenerationRef.current += 1;\n pagedIdsRef.current = new Set(firstPage.map((notification) => notification.id));\n setNotifications(merged.list);\n setHasMore(firstPageHasMore);\n }\n setTotal(freshTotal);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to refresh notifications:', err);\n }\n }, [debouncedFilter, getClient]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkNotificationAsReadDocument,\n variables: { id: notificationId },\n });\n // Optimistic: update local state\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, readAt: new Date().toISOString() } : n\n )\n );\n setStoreUnreadCount(Math.max(0, unreadCount - 1));\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark as read:', err);\n setError('Failed to mark notification as read');\n }\n },\n [getClient, setStoreUnreadCount, unreadCount]\n );\n\n const handleMarkAllAsRead = useCallback(async () => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument,\n });\n // Optimistic: update all local\n setNotifications((prev) =>\n prev.map((n) => ({ ...n, readAt: n.readAt || new Date().toISOString() }))\n );\n setStoreUnreadCount(0);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark all as read:', err);\n setError('Failed to mark all notifications as read');\n }\n }, [getClient, setStoreUnreadCount]);\n\n const handleArchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, archivedAt: new Date().toISOString() } : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to archive notification:', err);\n setError('Failed to archive notification');\n }\n },\n [getClient]\n );\n\n const handleBulkArchive = useCallback(\n async (notificationIds: string[]) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationsDocument,\n variables: { notificationIds },\n });\n const idsSet = new Set(notificationIds);\n setNotifications((prev) =>\n prev.map((n) => (idsSet.has(n.id) ? { ...n, archivedAt: new Date().toISOString() } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to bulk archive:', err);\n setError('Failed to archive notifications');\n }\n },\n [getClient]\n );\n\n const handleUnarchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, archivedAt: undefined } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to unarchive notification:', err);\n setError('Failed to restore notification');\n }\n },\n [getClient]\n );\n\n const handleRecordAction = useCallback(\n async (notificationId: string, actionId?: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.RecordNotificationActionDocument,\n variables: { input: { notificationId, actionId } },\n });\n\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId\n ? {\n ...n,\n clickedAt: new Date().toISOString(),\n readAt: n.readAt || new Date().toISOString(),\n }\n : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to record notification action:', err);\n setError('Failed to record notification action');\n }\n },\n [getClient]\n );\n\n // ---- Initial fetch on mount + when filter changes -----------------------\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n fetchUnreadCount();\n }, [fetchUnreadCount]);\n\n // ---- Live notification subscriptions ------------------------------------\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getClient();\n const notificationSubscription = client\n .subscribe<NotificationReceivedSubscription>({\n query: NotificationOps.NotificationReceivedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const notification = result.data?.notificationReceived;\n if (!notification) return;\n const mapped = mapBackendToMfeNotification(notification);\n setNotifications((prev) => [mapped, ...prev.filter((item) => item.id !== mapped.id)]);\n eventBus?.emit('notification:received', { notification: mapped });\n },\n error: (err) => {\n console.error('[useNotifications] Notification subscription failed:', err);\n },\n });\n\n const unreadSubscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: NotificationOps.UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setStoreUnreadCount(nextCount);\n eventBus?.emit('notification:unread-count-updated', { unreadCount: nextCount });\n }\n },\n error: (err) => {\n console.error('[useNotifications] Unread count subscription failed:', err);\n },\n });\n\n return () => {\n notificationSubscription.unsubscribe();\n unreadSubscription.unsubscribe();\n };\n }, [currentUser?.id, eventBus, getClient, setStoreUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n void refreshFirstPage();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshFirstPage, fetchUnreadCount]);\n\n const visibleNotifications = useMemo(\n () =>\n notifications.filter((notification) => {\n if (notification.deliveryStatus === 'UNSUBSCRIBED') {\n return false;\n }\n\n if (notification.status === 'ARCHIVED' && !notification.archivedAt) {\n return false;\n }\n\n if (effectiveFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (effectiveFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n }),\n [effectiveFilter.archived, notifications]\n );\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\n /** A further page is loading (infinite scroll). */\n isLoadingMore,\n error,\n hasMore,\n total,\n markAsRead: handleMarkAsRead,\n markAllAsRead: handleMarkAllAsRead,\n archiveNotification: handleArchive,\n bulkArchive: handleBulkArchive,\n unarchiveNotification: handleUnarchive,\n recordAction: handleRecordAction,\n setSelectedNotification,\n updateFilter: updateNotificationFilter,\n resetFilter: resetNotificationFilter,\n refetch: fetchNotifications,\n loadMore,\n };\n}\n"],"mappings":";;;;;;;AAuCA,SAAgBU,EAA4B,GAAsC;CAChF,O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,CAAC;GAElF;GACA,QAAQ,MAAQ;IACd,QAAQ,MAAM,wDAAwD1C,CAAG;GAC3E;EACF,CAAC;EAEH,aAAa;GAEX,AADAqC,EAAyB,YAAY,GACrCG,EAAmB,YAAY;EACjC;CACF,GAAG;EAACL,GAAa;EAAII;EAAUpD;EAAW/B;CAAmB,CAAC,GAE9D8E,QAAgB;EACd,IAAMS,UAA+B;GACnC,AAAI,SAAS,oBAAoB,cAC/BjC,EAAsB,GACtBR,EAAiB;EAErB;EAGA,OADA,SAAS,iBAAiB,oBAAoByC,CAAsB,SACvD,SAAS,oBAAoB,oBAAoBA,CAAsB;CACtF,GAAG,CAACjC,GAAkBR,CAAgB,CAAC,GA0BhC;EACL,eAzB2BrB,QAEzBvB,EAAc,QAAQ,MAChByC,EAAa,mBAAmB,kBAIhCA,EAAa,WAAW,cAAc,CAACA,EAAa,aAC/C,KAGLnB,EAAgB,aAAa,KACxB,EAAQmB,EAAa,aAG1BnB,EAAgB,aAAa,MACxB,CAACmB,EAAa,UAIxB,GACH,CAACnB,EAAgB,UAAUtB,CAAa,CAIzB;EACf,kBAAkBA;EAClB;EACA;EACA,oBAAoBsB;EACpB;EAEA;EACA;EACA;EACA;EACA,YAAYsC;EACZ,eAAeI;EACf,qBAAqBE;EACrB,aAAaE;EACb,uBAAuBI;EACvB,cAAcE;EACd;EACA,cAAcY;EACd,aAAaC;EACb,SAASrD;EACT;CACF;AACF"}
|
|
@@ -467,5 +467,209 @@ export declare const enTranslations: {
|
|
|
467
467
|
usingTemplate: string;
|
|
468
468
|
view: string;
|
|
469
469
|
youHave: string;
|
|
470
|
+
v3: {
|
|
471
|
+
actionsFor: string;
|
|
472
|
+
archive: string;
|
|
473
|
+
cancel: string;
|
|
474
|
+
channel: {
|
|
475
|
+
email: string;
|
|
476
|
+
inApp: string;
|
|
477
|
+
other: string;
|
|
478
|
+
push: string;
|
|
479
|
+
slack: string;
|
|
480
|
+
sms: string;
|
|
481
|
+
whatsapp: string;
|
|
482
|
+
};
|
|
483
|
+
delivery: {
|
|
484
|
+
delivered: string;
|
|
485
|
+
failed: string;
|
|
486
|
+
sent: string;
|
|
487
|
+
waiting: string;
|
|
488
|
+
};
|
|
489
|
+
empty: {
|
|
490
|
+
actionBody: string;
|
|
491
|
+
actionTitle: string;
|
|
492
|
+
allBody: string;
|
|
493
|
+
allTitle: string;
|
|
494
|
+
archivedBody: string;
|
|
495
|
+
archivedTitle: string;
|
|
496
|
+
searchBody: string;
|
|
497
|
+
searchTitle: string;
|
|
498
|
+
unreadTitle: string;
|
|
499
|
+
};
|
|
500
|
+
event: {
|
|
501
|
+
bounced: string;
|
|
502
|
+
cancelled: string;
|
|
503
|
+
clicked: string;
|
|
504
|
+
complained: string;
|
|
505
|
+
created: string;
|
|
506
|
+
delivered: string;
|
|
507
|
+
expired: string;
|
|
508
|
+
failed: string;
|
|
509
|
+
opened: string;
|
|
510
|
+
other: string;
|
|
511
|
+
retry: string;
|
|
512
|
+
scheduled: string;
|
|
513
|
+
sent: string;
|
|
514
|
+
unsubscribed: string;
|
|
515
|
+
};
|
|
516
|
+
kind: {
|
|
517
|
+
activity: string;
|
|
518
|
+
alerts: string;
|
|
519
|
+
news: string;
|
|
520
|
+
other: string;
|
|
521
|
+
updates: string;
|
|
522
|
+
};
|
|
523
|
+
log: {
|
|
524
|
+
any: string;
|
|
525
|
+
delivered: string;
|
|
526
|
+
emptyBody: string;
|
|
527
|
+
emptyTitle: string;
|
|
528
|
+
failed: string;
|
|
529
|
+
inApp: string;
|
|
530
|
+
line: string;
|
|
531
|
+
noneTitle: string;
|
|
532
|
+
purpose: string;
|
|
533
|
+
show: string;
|
|
534
|
+
title: string;
|
|
535
|
+
waiting: string;
|
|
536
|
+
waitingShort: string;
|
|
537
|
+
};
|
|
538
|
+
markAll: string;
|
|
539
|
+
markedAll: string;
|
|
540
|
+
markRead: string;
|
|
541
|
+
markUnread: string;
|
|
542
|
+
more: string;
|
|
543
|
+
needsYou: string;
|
|
544
|
+
off: string;
|
|
545
|
+
on: string;
|
|
546
|
+
panel: {
|
|
547
|
+
close: string;
|
|
548
|
+
loading: string;
|
|
549
|
+
missing: string;
|
|
550
|
+
open: string;
|
|
551
|
+
what: string;
|
|
552
|
+
};
|
|
553
|
+
prefs: {
|
|
554
|
+
openInbox: string;
|
|
555
|
+
pause: string;
|
|
556
|
+
pausedNow: string;
|
|
557
|
+
pauseHelp: string;
|
|
558
|
+
pauseTitle: string;
|
|
559
|
+
purpose: string;
|
|
560
|
+
topicsTitle: string;
|
|
561
|
+
useDefault: string;
|
|
562
|
+
whatTitle: string;
|
|
563
|
+
whereTitle: string;
|
|
564
|
+
};
|
|
565
|
+
purpose: string;
|
|
566
|
+
read: string;
|
|
567
|
+
restore: string;
|
|
568
|
+
search: string;
|
|
569
|
+
settings: string;
|
|
570
|
+
tab: {
|
|
571
|
+
action: string;
|
|
572
|
+
all: string;
|
|
573
|
+
archived: string;
|
|
574
|
+
unread: string;
|
|
575
|
+
};
|
|
576
|
+
template: {
|
|
577
|
+
anotherDetail: string;
|
|
578
|
+
channel: string;
|
|
579
|
+
channelFixed: string;
|
|
580
|
+
create: string;
|
|
581
|
+
created: string;
|
|
582
|
+
detailName: string;
|
|
583
|
+
detailPlaceholder: string;
|
|
584
|
+
detailsHelp: string;
|
|
585
|
+
form: string;
|
|
586
|
+
htmlKept: string;
|
|
587
|
+
insert: string;
|
|
588
|
+
kind: string;
|
|
589
|
+
loading: string;
|
|
590
|
+
message: string;
|
|
591
|
+
messagePlaceholder: string;
|
|
592
|
+
missingBody: string;
|
|
593
|
+
missingTitle: string;
|
|
594
|
+
name: string;
|
|
595
|
+
namePlaceholder: string;
|
|
596
|
+
new: string;
|
|
597
|
+
newDetail: string;
|
|
598
|
+
newDetailHelp: string;
|
|
599
|
+
newPurpose: string;
|
|
600
|
+
now: string;
|
|
601
|
+
preview: string;
|
|
602
|
+
previewFrom: string;
|
|
603
|
+
previewMessage: string;
|
|
604
|
+
previewTitle: string;
|
|
605
|
+
previewWith: string;
|
|
606
|
+
productFallback: string;
|
|
607
|
+
purpose: string;
|
|
608
|
+
save: string;
|
|
609
|
+
saved: string;
|
|
610
|
+
title: string;
|
|
611
|
+
titlePlaceholder: string;
|
|
612
|
+
what: string;
|
|
613
|
+
};
|
|
614
|
+
templates: {
|
|
615
|
+
actionsFor: string;
|
|
616
|
+
channel: string;
|
|
617
|
+
delete: string;
|
|
618
|
+
deleteBody: string;
|
|
619
|
+
deleted: string;
|
|
620
|
+
deleteFailed: string;
|
|
621
|
+
deleteTitle: string;
|
|
622
|
+
edited: string;
|
|
623
|
+
emptyBody: string;
|
|
624
|
+
emptyTitle: string;
|
|
625
|
+
kind: string;
|
|
626
|
+
new: string;
|
|
627
|
+
noMatch: string;
|
|
628
|
+
purpose: string;
|
|
629
|
+
saveFailed: string;
|
|
630
|
+
search: string;
|
|
631
|
+
status: string;
|
|
632
|
+
template: string;
|
|
633
|
+
title: string;
|
|
634
|
+
turnedOff: string;
|
|
635
|
+
turnedOn: string;
|
|
636
|
+
turnOff: string;
|
|
637
|
+
turnOn: string;
|
|
638
|
+
};
|
|
639
|
+
thing: {
|
|
640
|
+
affectedRuns: string;
|
|
641
|
+
attempt: string;
|
|
642
|
+
firstSeen: string;
|
|
643
|
+
label: string;
|
|
644
|
+
openRun: string;
|
|
645
|
+
step: string;
|
|
646
|
+
};
|
|
647
|
+
timeline: string;
|
|
648
|
+
title: string;
|
|
649
|
+
today: string;
|
|
650
|
+
topics: {
|
|
651
|
+
about: string;
|
|
652
|
+
create: string;
|
|
653
|
+
created: string;
|
|
654
|
+
deleteBody: string;
|
|
655
|
+
deleteTitle: string;
|
|
656
|
+
dialogHelp: string;
|
|
657
|
+
edit: string;
|
|
658
|
+
editTitle: string;
|
|
659
|
+
emptyBody: string;
|
|
660
|
+
emptyTitle: string;
|
|
661
|
+
namePlaceholder: string;
|
|
662
|
+
new: string;
|
|
663
|
+
people: string;
|
|
664
|
+
purpose: string;
|
|
665
|
+
saved: string;
|
|
666
|
+
title: string;
|
|
667
|
+
topic: string;
|
|
668
|
+
turnedOff: string;
|
|
669
|
+
turnedOn: string;
|
|
670
|
+
};
|
|
671
|
+
unread: string;
|
|
672
|
+
yesterday: string;
|
|
673
|
+
};
|
|
470
674
|
};
|
|
471
675
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -188,7 +188,8 @@ export interface NotificationTopicSubscription {
|
|
|
188
188
|
topicId: string;
|
|
189
189
|
userId: string;
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
/** CATEGORY: a feature category such as "proactive" (global-notification-svc, BOFF-13164). */
|
|
192
|
+
export type NotificationPreferenceScope = 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC' | 'CATEGORY';
|
|
192
193
|
export type NotificationPreferenceFrequency = 'IMMEDIATE' | 'DAILY_DIGEST' | 'WEEKLY_DIGEST' | 'NEVER';
|
|
193
194
|
export interface NotificationPreference {
|
|
194
195
|
id: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ArchivedRedirect(): import('react').JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useNotificationPaths as e } from "../navigation-v2/paths.js";
|
|
2
|
+
import { Navigate as t } from "react-router";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
// src/v2/ArchivedRedirect.tsx
|
|
5
|
+
function r() {
|
|
6
|
+
let r = e();
|
|
7
|
+
return /* @__PURE__ */ n(t, {
|
|
8
|
+
to: `${r.inbox}?tab=archived`,
|
|
9
|
+
replace: !0
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { r as ArchivedRedirect };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=ArchivedRedirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArchivedRedirect.js","names":["ArchivedRedirect","paths","useNotificationPaths","Navigate"],"sources":["../../src/v2/ArchivedRedirect.tsx"],"sourcesContent":["/**\n * `/notifications/history` under fe-libs' `accountPagesV2` (BOFF-16785, C1): the inbox's Archived\n * tab. Only rendered under the opt-in.\n */\nimport { Navigate } from 'react-router';\nimport { useNotificationPaths } from '../navigation-v2/paths';\n\nexport function ArchivedRedirect() {\n const paths = useNotificationPaths();\n return <Navigate to={`${paths.inbox}?tab=archived`} replace />;\n}\n"],"mappings":";;;;AAOA,SAAgBA,IAAmB;CACjC,IAAMC,IAAQC,EAAqB;CACnC,OAAO,kBAACC,GAAD;EAAU,IAAI,GAAGF,EAAM,MAAM;EAAgB,SAAA;CAAS,CAAA;AAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InboxPage(): import('react').JSX.Element;
|