@burdenoff/microfe-notification 2026.1201.1 → 2026.1202.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/hooks/answeredAt.d.ts +8 -0
- package/dist/hooks/answeredAt.js +33 -0
- package/dist/hooks/answeredAt.js.map +1 -0
- package/dist/hooks/useNotificationAdmin.d.ts +2 -0
- package/dist/hooks/useNotificationAdmin.js +32 -31
- package/dist/hooks/useNotificationAdmin.js.map +1 -1
- package/dist/hooks/useNotificationPreferences.d.ts +2 -0
- package/dist/hooks/useNotificationPreferences.js +45 -43
- package/dist/hooks/useNotificationPreferences.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +2 -0
- package/dist/hooks/useNotificationTemplates.js +92 -88
- package/dist/hooks/useNotificationTemplates.js.map +1 -1
- package/dist/hooks/useNotificationTopics.d.ts +2 -0
- package/dist/hooks/useNotificationTopics.js +19 -18
- package/dist/hooks/useNotificationTopics.js.map +1 -1
- package/dist/hooks/useNotifications.d.ts +2 -0
- package/dist/hooks/useNotifications.js +69 -68
- package/dist/hooks/useNotifications.js.map +1 -1
- package/dist/hooks/usePreferenceToggles.d.ts +2 -0
- package/dist/hooks/usePreferenceToggles.js +19 -18
- package/dist/hooks/usePreferenceToggles.js.map +1 -1
- package/dist/v2/InboxPage.js +111 -107
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/InboxRows.js +50 -45
- package/dist/v2/InboxRows.js.map +1 -1
- package/dist/v2/NotificationDetailPanel.js +97 -93
- package/dist/v2/NotificationDetailPanel.js.map +1 -1
- package/dist/v2/PreferencesPage.js +113 -106
- package/dist/v2/PreferencesPage.js.map +1 -1
- package/dist/v2/StaleHint.d.ts +4 -0
- package/dist/v2/StaleHint.js +18 -0
- package/dist/v2/StaleHint.js.map +1 -0
- package/dist/v2/admin/DeliveryLogPage.js +71 -69
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -1
- package/dist/v2/admin/TemplateEditor.js +58 -55
- package/dist/v2/admin/TemplateEditor.js.map +1 -1
- package/dist/v2/admin/TemplatesPage.js +150 -142
- package/dist/v2/admin/TemplatesPage.js.map +1 -1
- package/dist/v2/admin/TopicDialog.js +66 -65
- package/dist/v2/admin/TopicDialog.js.map +1 -1
- package/dist/v2/admin/TopicsPage.js +85 -80
- package/dist/v2/admin/TopicsPage.js.map +1 -1
- package/dist/v2/admin/useTemplateDraft.js +73 -72
- package/dist/v2/admin/useTemplateDraft.js.map +1 -1
- package/dist/v2/model/loadedAt.d.ts +5 -0
- package/dist/v2/model/loadedAt.js +8 -0
- package/dist/v2/model/loadedAt.js.map +1 -0
- package/dist/v2/send/SendNotificationDialog.js +53 -51
- package/dist/v2/send/SendNotificationDialog.js.map +1 -1
- package/dist/v2/useNeedsConnection.d.ts +29 -0
- package/dist/v2/useNeedsConnection.js +51 -0
- package/dist/v2/useNeedsConnection.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApolloClient, DocumentNode, OperationVariables } from '@apollo/client';
|
|
2
|
+
/** Whether Apollo's cache already answers this read (then a cache-first read doesn't fetch). */
|
|
3
|
+
export declare function inCache(client: ApolloClient, query: DocumentNode, variables: OperationVariables): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The time this read's data arrived (ms since the epoch): now when the answer came from the
|
|
6
|
+
* server, else when it last did (0 when that isn't known).
|
|
7
|
+
*/
|
|
8
|
+
export declare function answeredAt(client: ApolloClient, query: DocumentNode, variables: OperationVariables, fromCache: boolean): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { canonicalStringify as e, getMainDefinition as t } from "@apollo/client/utilities";
|
|
2
|
+
// src/hooks/answeredAt.ts
|
|
3
|
+
var n = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function r(e) {
|
|
5
|
+
let t = n.get(e);
|
|
6
|
+
if (!t) {
|
|
7
|
+
let r = /* @__PURE__ */ new Map();
|
|
8
|
+
t = r, n.set(e, r);
|
|
9
|
+
let i = async () => r.clear();
|
|
10
|
+
e.onClearStore(i), e.onResetStore(i);
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function i(n, r) {
|
|
15
|
+
return `${t(n).name?.value ?? ""}:${e(r)}`;
|
|
16
|
+
}
|
|
17
|
+
function a(e, t, n) {
|
|
18
|
+
try {
|
|
19
|
+
return e.readQuery({
|
|
20
|
+
query: t,
|
|
21
|
+
variables: n
|
|
22
|
+
}) !== null;
|
|
23
|
+
} catch {
|
|
24
|
+
return !1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function o(e, t, n, a) {
|
|
28
|
+
let o = r(e), s = i(t, n);
|
|
29
|
+
return a || o.set(s, Date.now()), o.get(s) ?? 0;
|
|
30
|
+
}
|
|
31
|
+
export { o as answeredAt, a as inCache };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=answeredAt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answeredAt.js","names":["times","timesOf","known","client","fresh","forget","keyOf","getMainDefinition","query","canonicalStringify","variables","inCache","answeredAt","key","fromCache"],"sources":["../../src/hooks/answeredAt.ts"],"sourcesContent":["/**\n * When a notification read's answer came from the server (BOFF-16786), kept per Apollo client,\n * operation and variables, outside the pages. A cache-first read that Apollo answers from its\n * cache keeps the time its data really arrived, so a page opened again (offline, from the cache)\n * says when that was, not \"now\". Clearing or resetting the client's store (signing out) forgets\n * the times with the cache.\n */\nimport type { ApolloClient, DocumentNode, OperationVariables } from '@apollo/client';\nimport { canonicalStringify, getMainDefinition } from '@apollo/client/utilities';\n\nconst times = new WeakMap<ApolloClient, Map<string, number>>();\n\nfunction timesOf(client: ApolloClient): Map<string, number> {\n let known = times.get(client);\n if (!known) {\n const fresh = new Map<string, number>();\n known = fresh;\n times.set(client, fresh);\n const forget = async () => fresh.clear();\n client.onClearStore(forget);\n client.onResetStore(forget);\n }\n return known;\n}\n\nfunction keyOf(query: DocumentNode, variables: OperationVariables): string {\n return `${getMainDefinition(query).name?.value ?? ''}:${canonicalStringify(variables)}`;\n}\n\n/** Whether Apollo's cache already answers this read (then a cache-first read doesn't fetch). */\nexport function inCache(\n client: ApolloClient,\n query: DocumentNode,\n variables: OperationVariables\n): boolean {\n try {\n return client.readQuery({ query, variables }) !== null;\n } catch {\n // A cache that cannot answer is the same as an empty one.\n return false;\n }\n}\n\n/**\n * The time this read's data arrived (ms since the epoch): now when the answer came from the\n * server, else when it last did (0 when that isn't known).\n */\nexport function answeredAt(\n client: ApolloClient,\n query: DocumentNode,\n variables: OperationVariables,\n fromCache: boolean\n): number {\n const known = timesOf(client);\n const key = keyOf(query, variables);\n if (!fromCache) known.set(key, Date.now());\n return known.get(key) ?? 0;\n}\n"],"mappings":";;AAUA,IAAMA,oBAAQ,IAAI,QAA2C;AAE7D,SAASC,EAAQ,GAA2C;CAC1D,IAAIC,IAAQF,EAAM,IAAIG,CAAM;CAC5B,IAAI,CAACD,GAAO;EACV,IAAME,oBAAQ,IAAI,IAAoB;EAEtC,AADA,IAAQA,GACRJ,EAAM,IAAIG,GAAQC,CAAK;EACvB,IAAMC,IAAS,YAAYD,EAAM,MAAM;EAEvC,AADAD,EAAO,aAAaE,CAAM,GAC1BF,EAAO,aAAaE,CAAM;CAC5B;CACA,OAAOH;AACT;AAEA,SAASI,EAAM,GAAqB,GAAuC;CACzE,OAAO,GAAGC,EAAkBC,CAAK,CAAC,CAAC,MAAM,SAAS,GAAG,GAAGC,EAAmBC,CAAS;AACtF;AAGA,SAAgBC,EACd,GACA,GACA,GACS;CACT,IAAI;EACF,OAAOR,EAAO,UAAU;GAAE;GAAO;EAAU,CAAC,MAAM;CACpD,QAAQ;EAEN,OAAO;CACT;AACF;AAMA,SAAgBS,EACd,GACA,GACA,GACA,GACQ;CACR,IAAMV,IAAQD,EAAQE,CAAM,GACtBU,IAAMP,EAAME,GAAOE,CAAS;CAElC,OADKI,KAAWZ,EAAM,IAAIW,GAAK,KAAK,IAAI,CAAC,GAClCX,EAAM,IAAIW,CAAG,KAAK;AAC3B"}
|
|
@@ -36,6 +36,8 @@ export declare function useNotificationAdmin(): {
|
|
|
36
36
|
}[];
|
|
37
37
|
isLoading: boolean;
|
|
38
38
|
error: string | null;
|
|
39
|
+
/** When the notifications on hand arrived (ms since the epoch); 0 before the first answer. */
|
|
40
|
+
dataUpdatedAt: number;
|
|
39
41
|
refetch: () => Promise<void>;
|
|
40
42
|
loadNotification: (notificationId: string) => Promise<void>;
|
|
41
43
|
archiveNotification: (notificationId: string) => Promise<void>;
|
|
@@ -89,10 +89,10 @@ function _(e) {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
function v() {
|
|
92
|
-
let { authToken: h, apiGatewayUrl: g } = e(), { trackScheduleUpdated: v } = n(), [y, b] = p(m), [x, S] = p([]), [C, w] = p([]), [T, E] = p(null), [D, O] = p([]), [k, A] = p(!1), [j, M] = p(null), N = d(() => t(g ?? void 0, h ?? void 0), [g, h]),
|
|
92
|
+
let { authToken: h, apiGatewayUrl: g } = e(), { trackScheduleUpdated: v } = n(), [y, b] = p(m), [x, S] = p([]), [C, w] = p([]), [T, E] = p(null), [D, O] = p([]), [k, A] = p(!1), [j, M] = p(null), [N, P] = p(0), F = d(() => t(g ?? void 0, h ?? void 0), [g, h]), I = d(async () => {
|
|
93
93
|
A(!0), M(null);
|
|
94
94
|
try {
|
|
95
|
-
let e = await
|
|
95
|
+
let e = await F().query({
|
|
96
96
|
query: s,
|
|
97
97
|
variables: {
|
|
98
98
|
filter: {
|
|
@@ -109,15 +109,15 @@ function v() {
|
|
|
109
109
|
},
|
|
110
110
|
fetchPolicy: "network-only"
|
|
111
111
|
});
|
|
112
|
-
S((e.data?.notifications.items || []).map(_));
|
|
112
|
+
S((e.data?.notifications.items || []).map(_)), P(Date.now());
|
|
113
113
|
} catch (e) {
|
|
114
114
|
console.error("[useNotificationAdmin] Failed to fetch notifications:", e), M(e instanceof Error ? e.message : "Failed to fetch notifications");
|
|
115
115
|
} finally {
|
|
116
116
|
A(!1);
|
|
117
117
|
}
|
|
118
|
-
}, [y,
|
|
118
|
+
}, [y, F]), L = d(async () => {
|
|
119
119
|
try {
|
|
120
|
-
let e = await
|
|
120
|
+
let e = await F().query({
|
|
121
121
|
query: c,
|
|
122
122
|
variables: {
|
|
123
123
|
limit: 100,
|
|
@@ -129,10 +129,10 @@ function v() {
|
|
|
129
129
|
} catch (e) {
|
|
130
130
|
console.error("[useNotificationAdmin] Failed to fetch scheduled notifications:", e);
|
|
131
131
|
}
|
|
132
|
-
}, [
|
|
132
|
+
}, [F]), R = d(async (e) => {
|
|
133
133
|
M(null);
|
|
134
134
|
try {
|
|
135
|
-
let t =
|
|
135
|
+
let t = F(), [n, r] = await Promise.all([t.query({
|
|
136
136
|
query: a,
|
|
137
137
|
variables: { id: e },
|
|
138
138
|
fetchPolicy: "network-only"
|
|
@@ -145,44 +145,44 @@ function v() {
|
|
|
145
145
|
} catch (e) {
|
|
146
146
|
console.error("[useNotificationAdmin] Failed to load notification detail:", e), M(e instanceof Error ? e.message : "Failed to load notification detail");
|
|
147
147
|
}
|
|
148
|
-
}, [
|
|
149
|
-
await
|
|
148
|
+
}, [F]), z = d(async (e) => {
|
|
149
|
+
await F().mutate({
|
|
150
150
|
mutation: r,
|
|
151
151
|
variables: { id: e }
|
|
152
|
-
}), await
|
|
153
|
-
}, [
|
|
154
|
-
await
|
|
152
|
+
}), await I();
|
|
153
|
+
}, [I, F]), B = d(async (e) => {
|
|
154
|
+
await F().mutate({
|
|
155
155
|
mutation: u,
|
|
156
156
|
variables: { id: e }
|
|
157
|
-
}), await
|
|
158
|
-
}, [
|
|
159
|
-
await
|
|
157
|
+
}), await I();
|
|
158
|
+
}, [I, F]), V = d(async (e) => {
|
|
159
|
+
await F().mutate({
|
|
160
160
|
mutation: i,
|
|
161
161
|
variables: { id: e }
|
|
162
|
-
}), v({ action: "cancel" }), await Promise.all([
|
|
162
|
+
}), v({ action: "cancel" }), await Promise.all([I(), L()]);
|
|
163
163
|
}, [
|
|
164
|
-
|
|
164
|
+
I,
|
|
165
|
+
L,
|
|
165
166
|
F,
|
|
166
|
-
N,
|
|
167
167
|
v
|
|
168
|
-
]),
|
|
169
|
-
await
|
|
168
|
+
]), H = d(async (e, t, n) => {
|
|
169
|
+
await F().mutate({
|
|
170
170
|
mutation: l,
|
|
171
171
|
variables: { input: {
|
|
172
172
|
scheduledNotificationId: e,
|
|
173
173
|
scheduledFor: t,
|
|
174
174
|
timezone: n
|
|
175
175
|
} }
|
|
176
|
-
}), v({ action: "reschedule" }), await Promise.all([
|
|
176
|
+
}), v({ action: "reschedule" }), await Promise.all([I(), L()]);
|
|
177
177
|
}, [
|
|
178
|
-
|
|
178
|
+
I,
|
|
179
|
+
L,
|
|
179
180
|
F,
|
|
180
|
-
N,
|
|
181
181
|
v
|
|
182
182
|
]);
|
|
183
183
|
return f(() => {
|
|
184
|
-
|
|
185
|
-
}, [
|
|
184
|
+
I(), L();
|
|
185
|
+
}, [I, L]), {
|
|
186
186
|
filters: y,
|
|
187
187
|
setFilters: b,
|
|
188
188
|
notifications: x,
|
|
@@ -191,12 +191,13 @@ function v() {
|
|
|
191
191
|
events: D,
|
|
192
192
|
isLoading: k,
|
|
193
193
|
error: j,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
dataUpdatedAt: N,
|
|
195
|
+
refetch: I,
|
|
196
|
+
loadNotification: R,
|
|
197
|
+
archiveNotification: z,
|
|
198
|
+
unarchiveNotification: B,
|
|
199
|
+
cancelScheduledNotification: V,
|
|
200
|
+
rescheduleNotification: H,
|
|
200
201
|
clearSelection: () => {
|
|
201
202
|
E(null), O([]);
|
|
202
203
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotificationAdmin.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetScheduledNotificationsDocument","NotificationOps.GetNotificationDocument","NotificationOps.GetNotificationEventsDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.CancelScheduledNotificationDocument","NotificationOps.RescheduleNotificationDocument","defaultFilters","mapPriority","priority","mapStatus","status","mapNotification","notification","action","item","useNotificationAdmin","useNotification","useNotificationAnalytics","filters","setFilters","useState","notifications","setNotifications","scheduledNotifications","setScheduledNotifications","selectedNotification","setSelectedNotification","events","setEvents","isLoading","setIsLoading","error","setError","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","result","GetNotificationsDocument","err","fetchScheduledNotifications","GetScheduledNotificationsDocument","loadNotification","client","notificationResult","eventsResult","GetNotificationDocument","notificationId","GetNotificationEventsDocument","archiveNotification","ArchiveNotificationDocument","unarchiveNotification","UnarchiveNotificationDocument","cancelScheduledNotification","CancelScheduledNotificationDocument","scheduledNotificationId","trackScheduleUpdated","rescheduleNotification","RescheduleNotificationDocument","useEffect"],"sources":["../../src/hooks/useNotificationAdmin.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport type { Notification, NotificationAdminFilters } from '../types';\nimport { useNotificationAnalytics } from './useNotificationAnalytics';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetNotificationQuery,\n GetNotificationEventsQuery,\n GetScheduledNotificationsQuery,\n} from '../generated/global-operations';\n\nconst defaultFilters: NotificationAdminFilters = {\n search: '',\n status: 'all',\n channel: 'all',\n deliveryStatus: 'all',\n type: 'all',\n topicId: '',\n archived: 'all',\n};\n\nfunction mapPriority(priority: string): Notification['priority'] {\n if (priority === 'MEDIUM') return 'NORMAL';\n return (priority as Notification['priority']) || 'NORMAL';\n}\n\nfunction mapStatus(status: string): Notification['status'] {\n if (status === 'CANCELLED') return 'ARCHIVED';\n if (status === 'READ') return 'DELIVERED';\n return (status as Notification['status']) || 'PENDING';\n}\n\nfunction mapNotification(\n notification:\n | GetNotificationsQuery['notifications']['items'][number]\n | NonNullable<GetNotificationQuery['notification']>\n): Notification {\n return {\n id: notification.id,\n title: notification.title,\n body: notification.message,\n type: notification.type as Notification['type'],\n priority: mapPriority(notification.priority),\n status: mapStatus(notification.status),\n channel: notification.channel as Notification['channel'],\n deliveryStatus: notification.deliveryStatus ?? undefined,\n createdAt: notification.createdAt,\n updatedAt: notification.updatedAt,\n readAt: notification.readAt ?? undefined,\n archivedAt: notification.archivedAt ?? undefined,\n clickedAt: notification.clickedAt ?? undefined,\n openedAt: notification.openedAt ?? undefined,\n deliveredAt: notification.deliveredAt ?? undefined,\n sentAt: notification.sentAt ?? undefined,\n actionUrl: notification.redirectUrl ?? undefined,\n actions: (notification.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 media: (notification.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 appName: notification.appName ?? undefined,\n htmlBody: notification.htmlMessage ?? undefined,\n metadata: notification.metadata ?? undefined,\n channels: [\n {\n id: notification.id,\n channel: notification.channel as Notification['channel'],\n status: mapStatus(notification.status),\n sentAt: notification.sentAt ?? undefined,\n deliveredAt: notification.deliveredAt ?? undefined,\n failedAt: notification.failedAt ?? undefined,\n errorCode: notification.errorCode ?? undefined,\n errorMessage: notification.errorMessage ?? undefined,\n },\n ],\n recipientEmail: notification.recipientEmail ?? undefined,\n recipientPhone: notification.recipientPhone ?? undefined,\n scheduledFor: notification.scheduledFor ?? undefined,\n scheduledNotification: notification.scheduledNotification\n ? {\n id: notification.scheduledNotification.id,\n scheduledFor: notification.scheduledNotification.scheduledFor,\n status: notification.scheduledNotification.status,\n timezone: notification.scheduledNotification.timezone ?? undefined,\n retryCount: notification.scheduledNotification.retryCount ?? undefined,\n errorMessage: notification.scheduledNotification.errorMessage ?? undefined,\n }\n : undefined,\n topicId: notification.topicId ?? undefined,\n topic: notification.topic\n ? {\n id: notification.topic.id,\n name: notification.topic.name,\n slug: notification.topic.slug,\n type: notification.topic.type as Notification['type'],\n description: notification.topic.description ?? undefined,\n }\n : undefined,\n imageUrl: notification.media?.[0]?.url ?? undefined,\n };\n}\n\nexport function useNotificationAdmin() {\n const { authToken, apiGatewayUrl } = useNotification();\n const { trackScheduleUpdated } = useNotificationAnalytics();\n const [filters, setFilters] = useState<NotificationAdminFilters>(defaultFilters);\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [scheduledNotifications, setScheduledNotifications] = useState<\n GetScheduledNotificationsQuery['scheduledNotifications']['items']\n >([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [events, setEvents] = useState<GetNotificationEventsQuery['notificationEvents']>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n const fetchNotifications = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: {\n ...(filters.search ? { search: filters.search } : {}),\n ...(filters.status !== 'all' ? { status: filters.status } : {}),\n ...(filters.channel !== 'all' ? { channel: filters.channel } : {}),\n ...(filters.deliveryStatus !== 'all' ? { deliveryStatus: filters.deliveryStatus } : {}),\n ...(filters.type !== 'all' ? { type: filters.type } : {}),\n ...(filters.topicId ? { topicId: filters.topicId } : {}),\n ...(filters.archived !== 'all' ? { archived: filters.archived === 'archived' } : {}),\n },\n limit: 100,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n setNotifications((result.data?.notifications.items || []).map(mapNotification));\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to fetch notifications:', err);\n setError(err instanceof Error ? err.message : 'Failed to fetch notifications');\n } finally {\n setIsLoading(false);\n }\n }, [filters, getClient]);\n\n const fetchScheduledNotifications = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetScheduledNotificationsQuery>({\n query: NotificationOps.GetScheduledNotificationsDocument,\n variables: { limit: 100, offset: 0 },\n fetchPolicy: 'network-only',\n });\n\n setScheduledNotifications(result.data?.scheduledNotifications.items || []);\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to fetch scheduled notifications:', err);\n }\n }, [getClient]);\n\n const loadNotification = useCallback(\n async (notificationId: string) => {\n setError(null);\n\n try {\n const client = getClient();\n const [notificationResult, eventsResult] = await Promise.all([\n client.query<GetNotificationQuery>({\n query: NotificationOps.GetNotificationDocument,\n variables: { id: notificationId },\n fetchPolicy: 'network-only',\n }),\n client.query<GetNotificationEventsQuery>({\n query: NotificationOps.GetNotificationEventsDocument,\n variables: { notificationId },\n fetchPolicy: 'network-only',\n }),\n ]);\n\n if (notificationResult.data?.notification) {\n setSelectedNotification(mapNotification(notificationResult.data.notification));\n }\n setEvents(eventsResult.data?.notificationEvents || []);\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to load notification detail:', err);\n setError(err instanceof Error ? err.message : 'Failed to load notification detail');\n }\n },\n [getClient]\n );\n\n const archiveNotification = useCallback(\n async (notificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n await fetchNotifications();\n },\n [fetchNotifications, getClient]\n );\n\n const unarchiveNotification = useCallback(\n async (notificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n await fetchNotifications();\n },\n [fetchNotifications, getClient]\n );\n\n const cancelScheduledNotification = useCallback(\n async (scheduledNotificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.CancelScheduledNotificationDocument,\n variables: { id: scheduledNotificationId },\n });\n trackScheduleUpdated({ action: 'cancel' });\n await Promise.all([fetchNotifications(), fetchScheduledNotifications()]);\n },\n [fetchNotifications, fetchScheduledNotifications, getClient, trackScheduleUpdated]\n );\n\n const rescheduleNotification = useCallback(\n async (scheduledNotificationId: string, scheduledFor: string, timezone?: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.RescheduleNotificationDocument,\n variables: {\n input: {\n scheduledNotificationId,\n scheduledFor,\n timezone,\n },\n },\n });\n trackScheduleUpdated({ action: 'reschedule' });\n await Promise.all([fetchNotifications(), fetchScheduledNotifications()]);\n },\n [fetchNotifications, fetchScheduledNotifications, getClient, trackScheduleUpdated]\n );\n\n useEffect(() => {\n fetchNotifications();\n fetchScheduledNotifications();\n }, [fetchNotifications, fetchScheduledNotifications]);\n\n return {\n filters,\n setFilters,\n notifications,\n scheduledNotifications,\n selectedNotification,\n events,\n isLoading,\n error,\n refetch: fetchNotifications,\n loadNotification,\n archiveNotification,\n unarchiveNotification,\n cancelScheduledNotification,\n rescheduleNotification,\n clearSelection: () => {\n setSelectedNotification(null);\n setEvents([]);\n },\n };\n}\n"],"mappings":";;;;;;AAaA,IAAMQ,IAA2C;CAC/C,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,gBAAgB;CAChB,MAAM;CACN,SAAS;CACT,UAAU;AACZ;AAEA,SAASC,EAAY,GAA4C;CAE/D,OADIC,MAAa,WAAiB,WAC1BA,KAAyC;AACnD;AAEA,SAASC,EAAU,GAAwC;CAGzD,OAFIC,MAAW,cAAoB,aAC/BA,MAAW,SAAe,cACtBA,KAAqC;AAC/C;AAEA,SAASC,EACP,GAGc;CACd,OAAO;EACL,IAAIC,EAAa;EACjB,OAAOA,EAAa;EACpB,MAAMA,EAAa;EACnB,MAAMA,EAAa;EACnB,UAAUL,EAAYK,EAAa,QAAQ;EAC3C,QAAQH,EAAUG,EAAa,MAAM;EACrC,SAASA,EAAa;EACtB,gBAAgBA,EAAa,kBA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ACF;EACF,CAAC,GACDqD,EAAqB,EAAE,QAAQ,aAAa,CAAC,GAC7C,MAAM,QAAQ,IAAI,CAACpB,EAAmB,GAAGI,EAA4B,CAAC,CAAC;CACzE,GACA;EAACJ;EAAoBI;EAA6BT;EAAWyB;CAAoB,CACnF;CAOA,OALAG,QAAgB;EAEd,AADAvB,EAAmB,GACnBI,EAA4B;CAC9B,GAAG,CAACJ,GAAoBI,CAA2B,CAAC,GAE7C;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAASJ;EACT;EACA;EACA;EACA;EACA;EACA,sBAAsB;GAEpB,AADAZ,EAAwB,IAAI,GAC5BE,EAAU,CAAC,CAAC;EACd;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotificationAdmin.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetScheduledNotificationsDocument","NotificationOps.GetNotificationDocument","NotificationOps.GetNotificationEventsDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.CancelScheduledNotificationDocument","NotificationOps.RescheduleNotificationDocument","defaultFilters","mapPriority","priority","mapStatus","status","mapNotification","notification","action","item","useNotificationAdmin","useNotification","useNotificationAnalytics","filters","setFilters","useState","notifications","setNotifications","scheduledNotifications","setScheduledNotifications","selectedNotification","setSelectedNotification","events","setEvents","isLoading","setIsLoading","error","setError","dataUpdatedAt","setDataUpdatedAt","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","result","GetNotificationsDocument","err","fetchScheduledNotifications","GetScheduledNotificationsDocument","loadNotification","client","notificationResult","eventsResult","GetNotificationDocument","notificationId","GetNotificationEventsDocument","archiveNotification","ArchiveNotificationDocument","unarchiveNotification","UnarchiveNotificationDocument","cancelScheduledNotification","CancelScheduledNotificationDocument","scheduledNotificationId","trackScheduleUpdated","rescheduleNotification","RescheduleNotificationDocument","useEffect"],"sources":["../../src/hooks/useNotificationAdmin.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport type { Notification, NotificationAdminFilters } from '../types';\nimport { useNotificationAnalytics } from './useNotificationAnalytics';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetNotificationQuery,\n GetNotificationEventsQuery,\n GetScheduledNotificationsQuery,\n} from '../generated/global-operations';\n\nconst defaultFilters: NotificationAdminFilters = {\n search: '',\n status: 'all',\n channel: 'all',\n deliveryStatus: 'all',\n type: 'all',\n topicId: '',\n archived: 'all',\n};\n\nfunction mapPriority(priority: string): Notification['priority'] {\n if (priority === 'MEDIUM') return 'NORMAL';\n return (priority as Notification['priority']) || 'NORMAL';\n}\n\nfunction mapStatus(status: string): Notification['status'] {\n if (status === 'CANCELLED') return 'ARCHIVED';\n if (status === 'READ') return 'DELIVERED';\n return (status as Notification['status']) || 'PENDING';\n}\n\nfunction mapNotification(\n notification:\n | GetNotificationsQuery['notifications']['items'][number]\n | NonNullable<GetNotificationQuery['notification']>\n): Notification {\n return {\n id: notification.id,\n title: notification.title,\n body: notification.message,\n type: notification.type as Notification['type'],\n priority: mapPriority(notification.priority),\n status: mapStatus(notification.status),\n channel: notification.channel as Notification['channel'],\n deliveryStatus: notification.deliveryStatus ?? undefined,\n createdAt: notification.createdAt,\n updatedAt: notification.updatedAt,\n readAt: notification.readAt ?? undefined,\n archivedAt: notification.archivedAt ?? undefined,\n clickedAt: notification.clickedAt ?? undefined,\n openedAt: notification.openedAt ?? undefined,\n deliveredAt: notification.deliveredAt ?? undefined,\n sentAt: notification.sentAt ?? undefined,\n actionUrl: notification.redirectUrl ?? undefined,\n actions: (notification.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 media: (notification.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 appName: notification.appName ?? undefined,\n htmlBody: notification.htmlMessage ?? undefined,\n metadata: notification.metadata ?? undefined,\n channels: [\n {\n id: notification.id,\n channel: notification.channel as Notification['channel'],\n status: mapStatus(notification.status),\n sentAt: notification.sentAt ?? undefined,\n deliveredAt: notification.deliveredAt ?? undefined,\n failedAt: notification.failedAt ?? undefined,\n errorCode: notification.errorCode ?? undefined,\n errorMessage: notification.errorMessage ?? undefined,\n },\n ],\n recipientEmail: notification.recipientEmail ?? undefined,\n recipientPhone: notification.recipientPhone ?? undefined,\n scheduledFor: notification.scheduledFor ?? undefined,\n scheduledNotification: notification.scheduledNotification\n ? {\n id: notification.scheduledNotification.id,\n scheduledFor: notification.scheduledNotification.scheduledFor,\n status: notification.scheduledNotification.status,\n timezone: notification.scheduledNotification.timezone ?? undefined,\n retryCount: notification.scheduledNotification.retryCount ?? undefined,\n errorMessage: notification.scheduledNotification.errorMessage ?? undefined,\n }\n : undefined,\n topicId: notification.topicId ?? undefined,\n topic: notification.topic\n ? {\n id: notification.topic.id,\n name: notification.topic.name,\n slug: notification.topic.slug,\n type: notification.topic.type as Notification['type'],\n description: notification.topic.description ?? undefined,\n }\n : undefined,\n imageUrl: notification.media?.[0]?.url ?? undefined,\n };\n}\n\nexport function useNotificationAdmin() {\n const { authToken, apiGatewayUrl } = useNotification();\n const { trackScheduleUpdated } = useNotificationAnalytics();\n const [filters, setFilters] = useState<NotificationAdminFilters>(defaultFilters);\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [scheduledNotifications, setScheduledNotifications] = useState<\n GetScheduledNotificationsQuery['scheduledNotifications']['items']\n >([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [events, setEvents] = useState<GetNotificationEventsQuery['notificationEvents']>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n // When the notifications on hand arrived (ms since the epoch), as React Query's `dataUpdatedAt`.\n const [dataUpdatedAt, setDataUpdatedAt] = useState(0);\n\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n const fetchNotifications = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: {\n ...(filters.search ? { search: filters.search } : {}),\n ...(filters.status !== 'all' ? { status: filters.status } : {}),\n ...(filters.channel !== 'all' ? { channel: filters.channel } : {}),\n ...(filters.deliveryStatus !== 'all' ? { deliveryStatus: filters.deliveryStatus } : {}),\n ...(filters.type !== 'all' ? { type: filters.type } : {}),\n ...(filters.topicId ? { topicId: filters.topicId } : {}),\n ...(filters.archived !== 'all' ? { archived: filters.archived === 'archived' } : {}),\n },\n limit: 100,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n setNotifications((result.data?.notifications.items || []).map(mapNotification));\n setDataUpdatedAt(Date.now());\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to fetch notifications:', err);\n setError(err instanceof Error ? err.message : 'Failed to fetch notifications');\n } finally {\n setIsLoading(false);\n }\n }, [filters, getClient]);\n\n const fetchScheduledNotifications = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetScheduledNotificationsQuery>({\n query: NotificationOps.GetScheduledNotificationsDocument,\n variables: { limit: 100, offset: 0 },\n fetchPolicy: 'network-only',\n });\n\n setScheduledNotifications(result.data?.scheduledNotifications.items || []);\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to fetch scheduled notifications:', err);\n }\n }, [getClient]);\n\n const loadNotification = useCallback(\n async (notificationId: string) => {\n setError(null);\n\n try {\n const client = getClient();\n const [notificationResult, eventsResult] = await Promise.all([\n client.query<GetNotificationQuery>({\n query: NotificationOps.GetNotificationDocument,\n variables: { id: notificationId },\n fetchPolicy: 'network-only',\n }),\n client.query<GetNotificationEventsQuery>({\n query: NotificationOps.GetNotificationEventsDocument,\n variables: { notificationId },\n fetchPolicy: 'network-only',\n }),\n ]);\n\n if (notificationResult.data?.notification) {\n setSelectedNotification(mapNotification(notificationResult.data.notification));\n }\n setEvents(eventsResult.data?.notificationEvents || []);\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to load notification detail:', err);\n setError(err instanceof Error ? err.message : 'Failed to load notification detail');\n }\n },\n [getClient]\n );\n\n const archiveNotification = useCallback(\n async (notificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n await fetchNotifications();\n },\n [fetchNotifications, getClient]\n );\n\n const unarchiveNotification = useCallback(\n async (notificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n await fetchNotifications();\n },\n [fetchNotifications, getClient]\n );\n\n const cancelScheduledNotification = useCallback(\n async (scheduledNotificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.CancelScheduledNotificationDocument,\n variables: { id: scheduledNotificationId },\n });\n trackScheduleUpdated({ action: 'cancel' });\n await Promise.all([fetchNotifications(), fetchScheduledNotifications()]);\n },\n [fetchNotifications, fetchScheduledNotifications, getClient, trackScheduleUpdated]\n );\n\n const rescheduleNotification = useCallback(\n async (scheduledNotificationId: string, scheduledFor: string, timezone?: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.RescheduleNotificationDocument,\n variables: {\n input: {\n scheduledNotificationId,\n scheduledFor,\n timezone,\n },\n },\n });\n trackScheduleUpdated({ action: 'reschedule' });\n await Promise.all([fetchNotifications(), fetchScheduledNotifications()]);\n },\n [fetchNotifications, fetchScheduledNotifications, getClient, trackScheduleUpdated]\n );\n\n useEffect(() => {\n fetchNotifications();\n fetchScheduledNotifications();\n }, [fetchNotifications, fetchScheduledNotifications]);\n\n return {\n filters,\n setFilters,\n notifications,\n scheduledNotifications,\n selectedNotification,\n events,\n isLoading,\n error,\n /** When the notifications on hand arrived (ms since the epoch); 0 before the first answer. */\n dataUpdatedAt,\n refetch: fetchNotifications,\n loadNotification,\n archiveNotification,\n unarchiveNotification,\n cancelScheduledNotification,\n rescheduleNotification,\n clearSelection: () => {\n setSelectedNotification(null);\n setEvents([]);\n },\n };\n}\n"],"mappings":";;;;;;AAaA,IAAMQ,IAA2C;CAC/C,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,gBAAgB;CAChB,MAAM;CACN,SAAS;CACT,UAAU;AACZ;AAEA,SAASC,EAAY,GAA4C;CAE/D,OADIC,MAAa,WAAiB,WAC1BA,KAAyC;AACnD;AAEA,SAASC,EAAU,GAAwC;CAGzD,OAFIC,MAAW,cAAoB,aAC/BA,MAAW,SAAe,cACtBA,KAAqC;AAC/C;AAEA,SAASC,EACP,GAGc;CACd,OAAO;EACL,IAAIC,EAAa;EACjB,OAAOA,EAAa;EACpB,MAAMA,EAAa;EACnB,MAAMA,EAAa;EACnB,UAAUL,EAAYK,EAAa,QAAQ;EAC3C,QAAQH,EAAUG,EAAa,MAAM;EACrC,SAASA,EAAa;EACtB,gBAAgBA,EAAa,kBAAkB,KAAA;EAC/C,WAAWA,EAAa;EACxB,WAAWA,EAAa;EACxB,QAAQA,EAAa,UAAU,KAAA;EAC/B,YAAYA,EAAa,cAAc,KAAA;EACvC,WAAWA,EAAa,aAAa,KAAA;EACrC,UAAUA,EAAa,YAAY,KAAA;EACnC,aAAaA,EAAa,eAAe,KAAA;EACzC,QAAQA,EAAa,UAAU,KAAA;EAC/B,WAAWA,EAAa,eAAe,KAAA;EACvC,UAAUA,EAAa,WAAW,CAAC,EAAA,CAAG,KAAK,OAAY;GACrD,IAAIC,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,QAAQ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AAC,CAAC;EACd;CACF;AACF"}
|
|
@@ -4,6 +4,8 @@ export declare function useNotificationPreferences(): {
|
|
|
4
4
|
preferencesByKey: Map<string, NotificationPreference>;
|
|
5
5
|
isLoading: boolean;
|
|
6
6
|
error: string | null;
|
|
7
|
+
/** When the preferences on hand arrived (ms since the epoch); 0 before the first answer. */
|
|
8
|
+
dataUpdatedAt: number;
|
|
7
9
|
refetch: () => Promise<void>;
|
|
8
10
|
setPreference: (input: UpsertNotificationPreferenceInput) => Promise<NotificationPreference | null>;
|
|
9
11
|
deletePreference: (id: string) => Promise<boolean>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getGlobalNotificationClient as e } from "../graphql/global-client.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { answeredAt as t, inCache as n } from "./answeredAt.js";
|
|
3
|
+
import { useNotification as r } from "../providers/NotificationProvider.js";
|
|
4
|
+
import { CreateNotificationPreferenceDocument as i, DeleteNotificationPreferenceDocument as a, GetNotificationPreferencesDocument as o, UpdateNotificationPreferenceDocument as s } from "../generated/global-operations.js";
|
|
5
|
+
import { useCallback as c, useEffect as l, useMemo as u, useState as d } from "react";
|
|
5
6
|
// src/hooks/useNotificationPreferences.ts
|
|
6
|
-
function
|
|
7
|
+
function f(e) {
|
|
7
8
|
return e.scope === "CHANNEL" ? `CHANNEL:${e.channel || ""}` : e.scope === "TYPE" ? `TYPE:${e.type || ""}` : e.scope === "TOPIC" ? `TOPIC:${e.topicId || ""}` : "GLOBAL";
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function p(e) {
|
|
10
11
|
return {
|
|
11
12
|
id: e.id,
|
|
12
13
|
userId: e.userId,
|
|
@@ -32,40 +33,41 @@ function d(e) {
|
|
|
32
33
|
} : void 0
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
let { authToken:
|
|
37
|
-
|
|
36
|
+
function m() {
|
|
37
|
+
let { authToken: m, apiGatewayUrl: h } = r(), [g, _] = d([]), [v, y] = d(!1), [b, x] = d(null), [S, C] = d(0), w = c(() => e(h ?? void 0, m ?? void 0), [h, m]), T = u(() => new Map(g.map((e) => [e.preferenceKey, e])), [g]), E = c(async () => {
|
|
38
|
+
y(!0), x(null);
|
|
38
39
|
try {
|
|
39
|
-
let e =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
let e = w(), r = o, i = {
|
|
41
|
+
limit: 100,
|
|
42
|
+
offset: 0
|
|
43
|
+
}, a = n(e, r, i), s = await e.query({
|
|
44
|
+
query: r,
|
|
45
|
+
variables: i,
|
|
45
46
|
fetchPolicy: "cache-first"
|
|
46
47
|
});
|
|
47
|
-
|
|
48
|
+
_((s.data?.notificationPreferences.items || []).map(p)), C(t(e, r, i, a));
|
|
48
49
|
} catch (e) {
|
|
49
|
-
console.error("[useNotificationPreferences] Failed to fetch preferences:", e),
|
|
50
|
+
console.error("[useNotificationPreferences] Failed to fetch preferences:", e), x(e instanceof Error ? e.message : "Failed to fetch notification preferences");
|
|
50
51
|
} finally {
|
|
51
|
-
|
|
52
|
+
y(!1);
|
|
52
53
|
}
|
|
53
|
-
}, [
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
}, [
|
|
57
|
-
preferences:
|
|
58
|
-
preferencesByKey:
|
|
59
|
-
isLoading:
|
|
60
|
-
error:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
}, [w]);
|
|
55
|
+
return l(() => {
|
|
56
|
+
E();
|
|
57
|
+
}, [E]), {
|
|
58
|
+
preferences: g,
|
|
59
|
+
preferencesByKey: T,
|
|
60
|
+
isLoading: v,
|
|
61
|
+
error: b,
|
|
62
|
+
dataUpdatedAt: S,
|
|
63
|
+
refetch: E,
|
|
64
|
+
setPreference: c(async (e) => {
|
|
65
|
+
let t = w(), n = f(e), r = T.get(n);
|
|
66
|
+
if (r) {
|
|
65
67
|
let n = (await t.mutate({
|
|
66
|
-
mutation:
|
|
68
|
+
mutation: s,
|
|
67
69
|
variables: {
|
|
68
|
-
id:
|
|
70
|
+
id: r.id,
|
|
69
71
|
input: {
|
|
70
72
|
scope: e.scope,
|
|
71
73
|
channel: e.channel,
|
|
@@ -81,11 +83,11 @@ function f() {
|
|
|
81
83
|
}
|
|
82
84
|
})).data?.updateNotificationPreference;
|
|
83
85
|
if (!n) return null;
|
|
84
|
-
let
|
|
85
|
-
return
|
|
86
|
+
let i = p(n);
|
|
87
|
+
return _((e) => e.map((e) => e.id === i.id ? i : e)), i;
|
|
86
88
|
}
|
|
87
|
-
let
|
|
88
|
-
mutation:
|
|
89
|
+
let a = (await t.mutate({
|
|
90
|
+
mutation: i,
|
|
89
91
|
variables: { input: {
|
|
90
92
|
scope: e.scope,
|
|
91
93
|
channel: e.channel,
|
|
@@ -99,16 +101,16 @@ function f() {
|
|
|
99
101
|
metadata: e.metadata
|
|
100
102
|
} }
|
|
101
103
|
})).data?.createNotificationPreference;
|
|
102
|
-
if (!
|
|
103
|
-
let
|
|
104
|
-
return
|
|
105
|
-
}, [
|
|
106
|
-
deletePreference:
|
|
107
|
-
mutation:
|
|
104
|
+
if (!a) return null;
|
|
105
|
+
let o = p(a);
|
|
106
|
+
return _((e) => [o, ...e]), o;
|
|
107
|
+
}, [w, T]),
|
|
108
|
+
deletePreference: c(async (e) => (await w().mutate({
|
|
109
|
+
mutation: a,
|
|
108
110
|
variables: { id: e }
|
|
109
|
-
})).data?.deleteNotificationPreference ? (
|
|
111
|
+
})).data?.deleteNotificationPreference ? (_((t) => t.filter((t) => t.id !== e)), !0) : !1, [w])
|
|
110
112
|
};
|
|
111
113
|
}
|
|
112
|
-
export {
|
|
114
|
+
export { m as useNotificationPreferences };
|
|
113
115
|
|
|
114
116
|
//# sourceMappingURL=useNotificationPreferences.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotificationPreferences.js","names":["NotificationOps.GetNotificationPreferencesDocument","NotificationOps.UpdateNotificationPreferenceDocument","NotificationOps.CreateNotificationPreferenceDocument","NotificationOps.DeleteNotificationPreferenceDocument","buildPreferenceKey","input","mapPreference","preference","useNotificationPreferences","useNotification","preferences","setPreferences","useState","isLoading","setIsLoading","error","setError","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","preferencesByKey","useMemo","fetchPreferences","result","GetNotificationPreferencesDocument","err","useEffect","client","preferenceKey","existing","updated","UpdateNotificationPreferenceDocument","mapped","prev","item","created","CreateNotificationPreferenceDocument","DeleteNotificationPreferenceDocument","id"],"sources":["../../src/hooks/useNotificationPreferences.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport { useNotification } from '../providers/NotificationProvider';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n CreateNotificationPreferenceMutation,\n CreateNotificationPreferenceMutationVariables,\n DeleteNotificationPreferenceMutation,\n DeleteNotificationPreferenceMutationVariables,\n GetNotificationPreferencesQuery,\n NotificationPreferenceFieldsFragment,\n UpdateNotificationPreferenceMutation,\n UpdateNotificationPreferenceMutationVariables,\n} from '../generated/global-operations';\nimport type {\n NotificationPreference,\n NotificationPreferenceScope,\n UpsertNotificationPreferenceInput,\n} from '../types';\n\nfunction buildPreferenceKey(input: {\n scope: NotificationPreferenceScope;\n channel?: string;\n type?: string;\n topicId?: string;\n}): string {\n if (input.scope === 'CHANNEL') return `CHANNEL:${input.channel || ''}`;\n if (input.scope === 'TYPE') return `TYPE:${input.type || ''}`;\n if (input.scope === 'TOPIC') return `TOPIC:${input.topicId || ''}`;\n return 'GLOBAL';\n}\n\nfunction mapPreference(preference: NotificationPreferenceFieldsFragment): NotificationPreference {\n return {\n id: preference.id,\n userId: preference.userId,\n preferenceKey: preference.preferenceKey,\n scope: preference.scope,\n channel: preference.channel ?? undefined,\n type: preference.type ?? undefined,\n topicId: preference.topicId ?? undefined,\n enabled: preference.enabled,\n frequency: preference.frequency,\n quietHoursStart: preference.quietHoursStart ?? undefined,\n quietHoursEnd: preference.quietHoursEnd ?? undefined,\n timezone: preference.timezone ?? undefined,\n metadata: preference.metadata ?? undefined,\n createdAt: preference.createdAt,\n updatedAt: preference.updatedAt,\n topic: preference.topic\n ? {\n id: preference.topic.id,\n name: preference.topic.name,\n slug: preference.topic.slug,\n type: preference.topic.type,\n description: preference.topic.description ?? undefined,\n }\n : undefined,\n };\n}\n\nexport function useNotificationPreferences() {\n const { authToken, apiGatewayUrl } = useNotification();\n const [preferences, setPreferences] = useState<NotificationPreference[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n const preferencesByKey = useMemo(() => {\n return new Map(preferences.map((preference) => [preference.preferenceKey, preference]));\n }, [preferences]);\n\n const fetchPreferences = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationPreferencesQuery>({\n query: NotificationOps.GetNotificationPreferencesDocument,\n variables: { limit: 100, offset: 0 },\n fetchPolicy: 'cache-first',\n });\n setPreferences((result.data?.notificationPreferences.items || []).map(mapPreference));\n } catch (err) {\n console.error('[useNotificationPreferences] Failed to fetch preferences:', err);\n setError(err instanceof Error ? err.message : 'Failed to fetch notification preferences');\n } finally {\n setIsLoading(false);\n }\n }, [getClient]);\n\n useEffect(() => {\n fetchPreferences();\n }, [fetchPreferences]);\n\n const setPreference = useCallback(\n async (input: UpsertNotificationPreferenceInput): Promise<NotificationPreference | null> => {\n const client = getClient();\n const preferenceKey = buildPreferenceKey(input);\n const existing = preferencesByKey.get(preferenceKey);\n\n if (existing) {\n const result = await client.mutate<\n UpdateNotificationPreferenceMutation,\n UpdateNotificationPreferenceMutationVariables\n >({\n mutation: NotificationOps.UpdateNotificationPreferenceDocument,\n variables: {\n id: existing.id,\n input: {\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n enabled: input.enabled,\n frequency: input.frequency,\n quietHoursStart: input.quietHoursStart,\n quietHoursEnd: input.quietHoursEnd,\n timezone: input.timezone,\n metadata: input.metadata,\n } as UpdateNotificationPreferenceMutationVariables['input'],\n },\n });\n const updated = result.data?.updateNotificationPreference;\n if (!updated) return null;\n const mapped = mapPreference(updated);\n setPreferences((prev) => prev.map((item) => (item.id === mapped.id ? mapped : item)));\n return mapped;\n }\n\n const result = await client.mutate<\n CreateNotificationPreferenceMutation,\n CreateNotificationPreferenceMutationVariables\n >({\n mutation: NotificationOps.CreateNotificationPreferenceDocument,\n variables: {\n input: {\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n enabled: input.enabled,\n frequency: input.frequency || 'IMMEDIATE',\n quietHoursStart: input.quietHoursStart,\n quietHoursEnd: input.quietHoursEnd,\n timezone: input.timezone,\n metadata: input.metadata,\n } as CreateNotificationPreferenceMutationVariables['input'],\n },\n });\n const created = result.data?.createNotificationPreference;\n if (!created) return null;\n const mapped = mapPreference(created);\n setPreferences((prev) => [mapped, ...prev]);\n return mapped;\n },\n [getClient, preferencesByKey]\n );\n\n const deletePreference = useCallback(\n async (id: string): Promise<boolean> => {\n const client = getClient();\n const result = await client.mutate<\n DeleteNotificationPreferenceMutation,\n DeleteNotificationPreferenceMutationVariables\n >({\n mutation: NotificationOps.DeleteNotificationPreferenceDocument,\n variables: { id },\n });\n if (result.data?.deleteNotificationPreference) {\n setPreferences((prev) => prev.filter((preference) => preference.id !== id));\n return true;\n }\n return false;\n },\n [getClient]\n );\n\n return {\n preferences,\n preferencesByKey,\n isLoading,\n error,\n refetch: fetchPreferences,\n setPreference,\n deletePreference,\n };\n}\n"],"mappings":";;;;;AAoBA,SAASI,EAAmB,GAKjB;CAIT,OAHIC,EAAM,UAAU,YAAkB,WAAWA,EAAM,WAAW,OAC9DA,EAAM,UAAU,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f,SAASA,EAAM;KACf,WAAWA,EAAM,aAAa;KAC9B,iBAAiBA,EAAM;KACvB,eAAeA,EAAM;KACrB,UAAUA,EAAM;KAChB,UAAUA,EAAM;IAClB,EACF;GACF,CAAC,EAAA,CACsB,MAAM;GAC7B,IAAI,CAACgC,GAAS,OAAO;GACrB,IAAMH,IAAS5B,EAAc+B,CAAO;GAEpC,OADA1B,GAAgB,MAAS,CAACuB,GAAQ,GAAGC,CAAI,CAAC,GACnCD;EACT,GACA,CAACjB,GAAWK,CAAgB,CA4B5B;EACA,kBA1BuBJ,EACvB,OAAO,OASD,MARWD,EACM,CAAA,CAAO,OAG1B;GACA,UAAUd;GACV,WAAW,EAAE,MAAG;EAClB,CAAC,EAAA,CACU,MAAM,gCACfQ,GAAgB,MAASwB,EAAK,QAAQ,MAAe5B,EAAW,OAAOiC,CAAE,CAAC,GACnE,MAEF,IAET,CAACvB,CAAS,CAUV;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotificationPreferences.js","names":["NotificationOps.GetNotificationPreferencesDocument","NotificationOps.UpdateNotificationPreferenceDocument","NotificationOps.CreateNotificationPreferenceDocument","NotificationOps.DeleteNotificationPreferenceDocument","buildPreferenceKey","input","mapPreference","preference","useNotificationPreferences","useNotification","preferences","setPreferences","useState","isLoading","setIsLoading","error","setError","dataUpdatedAt","setDataUpdatedAt","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","preferencesByKey","useMemo","fetchPreferences","client","query","GetNotificationPreferencesDocument","variables","cached","inCache","result","answeredAt","err","useEffect","preferenceKey","existing","updated","UpdateNotificationPreferenceDocument","mapped","prev","item","created","CreateNotificationPreferenceDocument","DeleteNotificationPreferenceDocument","id"],"sources":["../../src/hooks/useNotificationPreferences.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport { answeredAt, inCache } from './answeredAt';\nimport { useNotification } from '../providers/NotificationProvider';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n CreateNotificationPreferenceMutation,\n CreateNotificationPreferenceMutationVariables,\n DeleteNotificationPreferenceMutation,\n DeleteNotificationPreferenceMutationVariables,\n GetNotificationPreferencesQuery,\n NotificationPreferenceFieldsFragment,\n UpdateNotificationPreferenceMutation,\n UpdateNotificationPreferenceMutationVariables,\n} from '../generated/global-operations';\nimport type {\n NotificationPreference,\n NotificationPreferenceScope,\n UpsertNotificationPreferenceInput,\n} from '../types';\n\nfunction buildPreferenceKey(input: {\n scope: NotificationPreferenceScope;\n channel?: string;\n type?: string;\n topicId?: string;\n}): string {\n if (input.scope === 'CHANNEL') return `CHANNEL:${input.channel || ''}`;\n if (input.scope === 'TYPE') return `TYPE:${input.type || ''}`;\n if (input.scope === 'TOPIC') return `TOPIC:${input.topicId || ''}`;\n return 'GLOBAL';\n}\n\nfunction mapPreference(preference: NotificationPreferenceFieldsFragment): NotificationPreference {\n return {\n id: preference.id,\n userId: preference.userId,\n preferenceKey: preference.preferenceKey,\n scope: preference.scope,\n channel: preference.channel ?? undefined,\n type: preference.type ?? undefined,\n topicId: preference.topicId ?? undefined,\n enabled: preference.enabled,\n frequency: preference.frequency,\n quietHoursStart: preference.quietHoursStart ?? undefined,\n quietHoursEnd: preference.quietHoursEnd ?? undefined,\n timezone: preference.timezone ?? undefined,\n metadata: preference.metadata ?? undefined,\n createdAt: preference.createdAt,\n updatedAt: preference.updatedAt,\n topic: preference.topic\n ? {\n id: preference.topic.id,\n name: preference.topic.name,\n slug: preference.topic.slug,\n type: preference.topic.type,\n description: preference.topic.description ?? undefined,\n }\n : undefined,\n };\n}\n\nexport function useNotificationPreferences() {\n const { authToken, apiGatewayUrl } = useNotification();\n const [preferences, setPreferences] = useState<NotificationPreference[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n // When the preferences on hand arrived (ms since the epoch), as React Query's `dataUpdatedAt`.\n const [dataUpdatedAt, setDataUpdatedAt] = useState(0);\n\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n const preferencesByKey = useMemo(() => {\n return new Map(preferences.map((preference) => [preference.preferenceKey, preference]));\n }, [preferences]);\n\n const fetchPreferences = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const query = NotificationOps.GetNotificationPreferencesDocument;\n const variables = { limit: 100, offset: 0 };\n // A cache-first read: an answer from the cache keeps the time it really arrived.\n const cached = inCache(client, query, variables);\n const result = await client.query<GetNotificationPreferencesQuery>({\n query,\n variables,\n fetchPolicy: 'cache-first',\n });\n setPreferences((result.data?.notificationPreferences.items || []).map(mapPreference));\n setDataUpdatedAt(answeredAt(client, query, variables, cached));\n } catch (err) {\n console.error('[useNotificationPreferences] Failed to fetch preferences:', err);\n setError(err instanceof Error ? err.message : 'Failed to fetch notification preferences');\n } finally {\n setIsLoading(false);\n }\n }, [getClient]);\n\n useEffect(() => {\n fetchPreferences();\n }, [fetchPreferences]);\n\n const setPreference = useCallback(\n async (input: UpsertNotificationPreferenceInput): Promise<NotificationPreference | null> => {\n const client = getClient();\n const preferenceKey = buildPreferenceKey(input);\n const existing = preferencesByKey.get(preferenceKey);\n\n if (existing) {\n const result = await client.mutate<\n UpdateNotificationPreferenceMutation,\n UpdateNotificationPreferenceMutationVariables\n >({\n mutation: NotificationOps.UpdateNotificationPreferenceDocument,\n variables: {\n id: existing.id,\n input: {\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n enabled: input.enabled,\n frequency: input.frequency,\n quietHoursStart: input.quietHoursStart,\n quietHoursEnd: input.quietHoursEnd,\n timezone: input.timezone,\n metadata: input.metadata,\n } as UpdateNotificationPreferenceMutationVariables['input'],\n },\n });\n const updated = result.data?.updateNotificationPreference;\n if (!updated) return null;\n const mapped = mapPreference(updated);\n setPreferences((prev) => prev.map((item) => (item.id === mapped.id ? mapped : item)));\n return mapped;\n }\n\n const result = await client.mutate<\n CreateNotificationPreferenceMutation,\n CreateNotificationPreferenceMutationVariables\n >({\n mutation: NotificationOps.CreateNotificationPreferenceDocument,\n variables: {\n input: {\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n enabled: input.enabled,\n frequency: input.frequency || 'IMMEDIATE',\n quietHoursStart: input.quietHoursStart,\n quietHoursEnd: input.quietHoursEnd,\n timezone: input.timezone,\n metadata: input.metadata,\n } as CreateNotificationPreferenceMutationVariables['input'],\n },\n });\n const created = result.data?.createNotificationPreference;\n if (!created) return null;\n const mapped = mapPreference(created);\n setPreferences((prev) => [mapped, ...prev]);\n return mapped;\n },\n [getClient, preferencesByKey]\n );\n\n const deletePreference = useCallback(\n async (id: string): Promise<boolean> => {\n const client = getClient();\n const result = await client.mutate<\n DeleteNotificationPreferenceMutation,\n DeleteNotificationPreferenceMutationVariables\n >({\n mutation: NotificationOps.DeleteNotificationPreferenceDocument,\n variables: { id },\n });\n if (result.data?.deleteNotificationPreference) {\n setPreferences((prev) => prev.filter((preference) => preference.id !== id));\n return true;\n }\n return false;\n },\n [getClient]\n );\n\n return {\n preferences,\n preferencesByKey,\n isLoading,\n error,\n /** When the preferences on hand arrived (ms since the epoch); 0 before the first answer. */\n dataUpdatedAt,\n refetch: fetchPreferences,\n setPreference,\n deletePreference,\n };\n}\n"],"mappings":";;;;;;AAqBA,SAASI,EAAmB,GAKjB;CAIT,OAHIC,EAAM,UAAU,YAAkB,WAAWA,EAAM,WAAW,OAC9DA,EAAM,UAAU,SAAe,QAAQA,EAAM,QAAQ,OACrDA,EAAM,UAAU,UAAgB,SAASA,EAAM,WAAW,OACvD;AACT;AAEA,SAASC,EAAc,GAA0E;CAC/F,OAAO;EACL,IAAIC,EAAW;EACf,QAAQA,EAAW;EACnB,eAAeA,EAAW;EAC1B,OAAOA,EAAW;EAClB,SAASA,EAAW,WAAW,KAAA;EAC/B,MAAMA,EAAW,QAAQ,KAAA;EACzB,SAASA,EAAW,WAAW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KAChB,UAAUA,EAAM;IAClB,EACF;GACF,CAAC,EAAA,CACsB,MAAM;GAC7B,IAAI,CAACuC,GAAS,OAAO;GACrB,IAAMH,IAASnC,EAAcsC,CAAO;GAEpC,OADAjC,GAAgB,MAAS,CAAC8B,GAAQ,GAAGC,CAAI,CAAC,GACnCD;EACT,GACA,CAACtB,GAAWK,CAAgB,CA8B5B;EACA,kBA5BuBJ,EACvB,OAAO,OASD,MARWD,EACM,CAAA,CAAO,OAG1B;GACA,UAAUhB;GACV,WAAW,EAAE,MAAG;EAClB,CAAC,EAAA,CACU,MAAM,gCACfQ,GAAgB,MAAS+B,EAAK,QAAQ,MAAenC,EAAW,OAAOwC,CAAE,CAAC,GACnE,MAEF,IAET,CAAC5B,CAAS,CAYV;CACF;AACF"}
|
|
@@ -95,6 +95,8 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
|
|
|
95
95
|
error: string | null;
|
|
96
96
|
hasMore: boolean;
|
|
97
97
|
total: number;
|
|
98
|
+
/** When the templates on hand arrived (ms since the epoch); 0 before the first answer. */
|
|
99
|
+
dataUpdatedAt: number;
|
|
98
100
|
filter: TemplateFilter;
|
|
99
101
|
refetch: () => Promise<void>;
|
|
100
102
|
loadMore: () => Promise<void>;
|