@burdenoff/microfe-notification 2026.424.101 → 2026.513.1

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.
Files changed (138) hide show
  1. package/dist/components/NotificationCard.d.ts.map +1 -1
  2. package/dist/components/NotificationCard.js +62 -57
  3. package/dist/components/NotificationCard.js.map +1 -1
  4. package/dist/generated/global-operations.d.ts +556 -8
  5. package/dist/generated/global-operations.d.ts.map +1 -1
  6. package/dist/generated/global-operations.js +198 -155
  7. package/dist/generated/global-operations.js.map +1 -1
  8. package/dist/generated/global-types.d.ts +2907 -153
  9. package/dist/generated/global-types.d.ts.map +1 -1
  10. package/dist/generated/wspace-types.d.ts +4521 -569
  11. package/dist/generated/wspace-types.d.ts.map +1 -1
  12. package/dist/graphql/global-client.d.ts.map +1 -1
  13. package/dist/graphql/global-client.js +41 -23
  14. package/dist/graphql/global-client.js.map +1 -1
  15. package/dist/hooks/index.d.ts +1 -0
  16. package/dist/hooks/index.d.ts.map +1 -1
  17. package/dist/hooks/index.js +1 -0
  18. package/dist/hooks/useNotificationAdmin.d.ts.map +1 -1
  19. package/dist/hooks/useNotificationPreferences.d.ts +12 -0
  20. package/dist/hooks/useNotificationPreferences.d.ts.map +1 -0
  21. package/dist/hooks/useNotificationPreferences.js +114 -0
  22. package/dist/hooks/useNotificationPreferences.js.map +1 -0
  23. package/dist/hooks/useNotifications.d.ts +6 -1
  24. package/dist/hooks/useNotifications.d.ts.map +1 -1
  25. package/dist/hooks/useNotifications.js +148 -99
  26. package/dist/hooks/useNotifications.js.map +1 -1
  27. package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +24 -0
  28. package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +1 -0
  29. package/dist/node_modules/@apollo/client/errors/utils.js +16 -0
  30. package/dist/node_modules/@apollo/client/errors/utils.js.map +1 -0
  31. package/dist/node_modules/@apollo/client/link/core/ApolloLink.js +52 -0
  32. package/dist/node_modules/@apollo/client/link/core/ApolloLink.js.map +1 -0
  33. package/dist/node_modules/@apollo/client/link/subscriptions/index.js +41 -0
  34. package/dist/node_modules/@apollo/client/link/subscriptions/index.js.map +1 -0
  35. package/dist/node_modules/@apollo/client/link/utils/createOperation.js +34 -0
  36. package/dist/node_modules/@apollo/client/link/utils/createOperation.js.map +1 -0
  37. package/dist/node_modules/@apollo/client/utilities/caching/sizes.js +6 -0
  38. package/dist/node_modules/@apollo/client/utilities/caching/sizes.js.map +1 -0
  39. package/dist/node_modules/@apollo/client/utilities/graphql/print.js +16 -0
  40. package/dist/node_modules/@apollo/client/utilities/graphql/print.js.map +1 -0
  41. package/dist/node_modules/@apollo/client/utilities/internal/caches.js +19 -0
  42. package/dist/node_modules/@apollo/client/utilities/internal/caches.js.map +1 -0
  43. package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js +21 -0
  44. package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js.map +1 -0
  45. package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js +17 -0
  46. package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js.map +1 -0
  47. package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js +9 -0
  48. package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js.map +1 -0
  49. package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js +9 -0
  50. package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js.map +1 -0
  51. package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js +8 -0
  52. package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js.map +1 -0
  53. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +9 -0
  54. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js.map +1 -0
  55. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +10 -0
  56. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js.map +1 -0
  57. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +8 -0
  58. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js.map +1 -0
  59. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +10 -0
  60. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js.map +1 -0
  61. package/dist/node_modules/@apollo/client/utilities/internal/memoize.js +23 -0
  62. package/dist/node_modules/@apollo/client/utilities/internal/memoize.js.map +1 -0
  63. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +10 -0
  64. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js.map +1 -0
  65. package/dist/node_modules/@apollo/client/utilities/invariant/index.js +57 -0
  66. package/dist/node_modules/@apollo/client/utilities/invariant/index.js.map +1 -0
  67. package/dist/node_modules/@apollo/client/version.js +6 -0
  68. package/dist/node_modules/@apollo/client/version.js.map +1 -0
  69. package/dist/node_modules/@wry/caches/lib/weak.js +67 -0
  70. package/dist/node_modules/@wry/caches/lib/weak.js.map +1 -0
  71. package/dist/node_modules/@wry/trie/lib/index.js +53 -0
  72. package/dist/node_modules/@wry/trie/lib/index.js.map +1 -0
  73. package/dist/node_modules/graphql-ws/dist/client.js +272 -0
  74. package/dist/node_modules/graphql-ws/dist/client.js.map +1 -0
  75. package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js +62 -0
  76. package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js.map +1 -0
  77. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +21 -0
  78. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js.map +1 -0
  79. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +78 -0
  80. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js.map +1 -0
  81. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +117 -0
  82. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js.map +1 -0
  83. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +93 -0
  84. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js.map +1 -0
  85. package/dist/node_modules/rxjs/dist/esm5/internal/config.js +12 -0
  86. package/dist/node_modules/rxjs/dist/esm5/internal/config.js.map +1 -0
  87. package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js +9 -0
  88. package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js.map +1 -0
  89. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +16 -0
  90. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.map +1 -0
  91. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +8 -0
  92. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js.map +1 -0
  93. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +13 -0
  94. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.map +1 -0
  95. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +11 -0
  96. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js.map +1 -0
  97. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +11 -0
  98. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js.map +1 -0
  99. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +22 -0
  100. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js.map +1 -0
  101. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +8 -0
  102. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js.map +1 -0
  103. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +8 -0
  104. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +1 -0
  105. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +6 -0
  106. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js.map +1 -0
  107. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +13 -0
  108. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js.map +1 -0
  109. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +14 -0
  110. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js.map +1 -0
  111. package/dist/node_modules/rxjs/node_modules/tslib/tslib.es6.js +52 -0
  112. package/dist/node_modules/rxjs/node_modules/tslib/tslib.es6.js.map +1 -0
  113. package/dist/pages/CreateNotificationPage.d.ts.map +1 -1
  114. package/dist/pages/CreateNotificationPage.js +449 -448
  115. package/dist/pages/CreateNotificationPage.js.map +1 -1
  116. package/dist/pages/NotificationCenterPage.d.ts.map +1 -1
  117. package/dist/pages/NotificationCenterPage.js +128 -123
  118. package/dist/pages/NotificationCenterPage.js.map +1 -1
  119. package/dist/pages/NotificationHistoryAdminPage.js +1 -1
  120. package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
  121. package/dist/pages/NotificationHistoryPage.d.ts.map +1 -1
  122. package/dist/pages/NotificationHistoryPage.js +35 -37
  123. package/dist/pages/NotificationHistoryPage.js.map +1 -1
  124. package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -1
  125. package/dist/pages/NotificationPreferencesPage.js +224 -79
  126. package/dist/pages/NotificationPreferencesPage.js.map +1 -1
  127. package/dist/pages/NotificationTemplatesPage.d.ts.map +1 -1
  128. package/dist/pages/NotificationTemplatesPage.js +155 -141
  129. package/dist/pages/NotificationTemplatesPage.js.map +1 -1
  130. package/dist/providers/NotificationProvider.d.ts.map +1 -1
  131. package/dist/providers/NotificationProvider.js +6 -5
  132. package/dist/providers/NotificationProvider.js.map +1 -1
  133. package/dist/types/index.d.ts +36 -0
  134. package/dist/types/index.d.ts.map +1 -1
  135. package/dist/utils/nativeBridge.d.ts +3 -0
  136. package/dist/utils/nativeBridge.d.ts.map +1 -0
  137. package/dist/utils/nativeBridge.js +2 -0
  138. package/package.json +5 -3
@@ -1,14 +1,14 @@
1
1
  import { useNotification as e } from "../providers/NotificationProvider.js";
2
2
  import { getGlobalNotificationClient as t } from "../graphql/global-client.js";
3
3
  import { useNotificationStore as n } from "../store/notificationStore.js";
4
- import { ArchiveNotificationDocument as r, ArchiveNotificationsDocument as i, GetMyUnreadNotificationCountDocument as a, GetNotificationsDocument as o, MarkAllMyNotificationsAsReadDocument as s, MarkNotificationAsReadDocument as c, RecordNotificationActionDocument as l, UnarchiveNotificationDocument as u } from "../generated/global-operations.js";
5
- import { useCallback as d, useEffect as f, useState as p } from "react";
4
+ import { ArchiveNotificationDocument as r, ArchiveNotificationsDocument as i, GetMyUnreadNotificationCountDocument as a, GetNotificationsDocument as o, MarkAllMyNotificationsAsReadDocument as s, MarkNotificationAsReadDocument as c, NotificationReceivedDocument as l, RecordNotificationActionDocument as u, UnarchiveNotificationDocument as d, UnreadCountUpdatedDocument as f } from "../generated/global-operations.js";
5
+ import { useCallback as p, useEffect as m, useMemo as h, useState as g } from "react";
6
6
  //#region src/hooks/useNotifications.ts
7
- function m(e) {
7
+ function _(e) {
8
8
  return {
9
9
  id: e.id,
10
- type: h(e.type),
11
- priority: g(e.priority),
10
+ type: v(e.type),
11
+ priority: y(e.priority),
12
12
  title: e.title,
13
13
  body: e.message,
14
14
  actionUrl: e.redirectUrl ?? void 0,
@@ -45,13 +45,13 @@ function m(e) {
45
45
  timezone: e.scheduledNotification.timezone ?? void 0
46
46
  } : void 0,
47
47
  sentAt: e.sentAt ?? void 0,
48
- status: _(e.status),
48
+ status: b(e.status),
49
49
  readAt: e.readAt ?? void 0,
50
50
  createdAt: e.createdAt,
51
51
  channels: [{
52
52
  id: e.id,
53
53
  channel: e.channel,
54
- status: _(e.status),
54
+ status: b(e.status),
55
55
  sentAt: e.sentAt ?? void 0,
56
56
  deliveredAt: e.deliveredAt ?? void 0,
57
57
  failedAt: e.failedAt ?? void 0,
@@ -63,12 +63,12 @@ function m(e) {
63
63
  id: e.topic.id,
64
64
  name: e.topic.name,
65
65
  slug: e.topic.slug,
66
- type: h(e.topic.type)
66
+ type: v(e.topic.type)
67
67
  } : void 0,
68
68
  topicId: e.topicId ?? void 0
69
69
  };
70
70
  }
71
- function h(e) {
71
+ function v(e) {
72
72
  return {
73
73
  SYSTEM: "SYSTEM",
74
74
  TRANSACTIONAL: "TRANSACTIONAL",
@@ -76,7 +76,7 @@ function h(e) {
76
76
  ALERT: "ALERT"
77
77
  }[e] || "SYSTEM";
78
78
  }
79
- function g(e) {
79
+ function y(e) {
80
80
  return {
81
81
  LOW: "LOW",
82
82
  MEDIUM: "NORMAL",
@@ -84,7 +84,7 @@ function g(e) {
84
84
  URGENT: "URGENT"
85
85
  }[e] || "NORMAL";
86
86
  }
87
- function _(e) {
87
+ function b(e) {
88
88
  return {
89
89
  DRAFT: "PENDING",
90
90
  PENDING: "PENDING",
@@ -98,7 +98,7 @@ function _(e) {
98
98
  EXPIRED: "ARCHIVED"
99
99
  }[e] || "PENDING";
100
100
  }
101
- function v(e) {
101
+ function x(e) {
102
102
  let t = {};
103
103
  return e.type !== "ALL" && (t.type = {
104
104
  SYSTEM: "SYSTEM",
@@ -114,176 +114,225 @@ function v(e) {
114
114
  URGENT: "URGENT"
115
115
  }[e.priority] || e.priority), e.isRead !== null && e.isRead !== void 0 && (t.isRead = e.isRead), e.topicId && (t.topicId = e.topicId), e.channel && e.channel !== "ALL" && (t.channel = e.channel), e.archived !== null && e.archived !== void 0 && (t.archived = e.archived), e.search && (t.search = e.search), e.dateRange.start && (t.startDate = e.dateRange.start.toISOString()), e.dateRange.end && (t.endDate = e.dateRange.end.toISOString()), Object.keys(t).length > 0 ? t : void 0;
116
116
  }
117
- function y() {
118
- let { authToken: h, apiGatewayUrl: g } = e(), { notificationFilter: _, updateNotificationFilter: y, resetNotificationFilter: b, unreadCount: x, setUnreadCount: S, setIsLoadingNotifications: C } = n(), [w, T] = p([]), [E, D] = p(null), [O, k] = p(!1), [A, j] = p(null), [M, N] = p(!1), [P, F] = p(0), [I, L] = p(0), R = d(() => t(g ?? void 0, h ?? void 0), [g, h]), z = d(async () => {
119
- k(!0), C(!0), j(null);
117
+ function S(e, t) {
118
+ return t ? {
119
+ ...e,
120
+ ...t,
121
+ dateRange: {
122
+ ...e.dateRange,
123
+ ...t.dateRange || {}
124
+ }
125
+ } : e;
126
+ }
127
+ function C(v = {}) {
128
+ let { authToken: y, apiGatewayUrl: b, currentUser: C, eventBus: w } = e(), { notificationFilter: T, updateNotificationFilter: E, resetNotificationFilter: D, unreadCount: O, setUnreadCount: k, setIsLoadingNotifications: A } = n(), [j, M] = g([]), [N, P] = g(null), [F, I] = g(!1), [L, R] = g(null), [z, B] = g(!1), [V, H] = g(0), [U, W] = g(0), G = h(() => S(T, v.baseFilter), [T, v.baseFilter]), K = p(() => t(b ?? void 0, y ?? void 0), [b, y]), q = p(async () => {
129
+ I(!0), A(!0), R(null);
120
130
  try {
121
- let e = await R().query({
131
+ let e = await K().query({
122
132
  query: o,
123
133
  variables: {
124
- filter: v(_),
134
+ filter: x(G),
125
135
  limit: 50,
126
136
  offset: 0
127
137
  },
128
138
  fetchPolicy: "network-only"
129
139
  });
130
- e.data?.notifications && (T(e.data.notifications.items.map(m)), F(e.data.notifications.total), N(e.data.notifications.hasMore), L(50));
140
+ e.data?.notifications && (M(e.data.notifications.items.map(_)), H(e.data.notifications.total), B(e.data.notifications.hasMore), W(50));
131
141
  } catch (e) {
132
142
  let t = e instanceof Error ? e.message : "Failed to fetch notifications";
133
- console.error("[useNotifications] Failed to fetch notifications:", e), j(t);
143
+ console.error("[useNotifications] Failed to fetch notifications:", e), R(t);
134
144
  } finally {
135
- k(!1), C(!1);
145
+ I(!1), A(!1);
136
146
  }
137
147
  }, [
138
- R,
139
- _,
140
- C
141
- ]), B = d(async () => {
148
+ G,
149
+ K,
150
+ A
151
+ ]), J = p(async () => {
142
152
  try {
143
- let e = await R().query({
153
+ let e = await K().query({
144
154
  query: a,
145
- variables: { filter: { channel: "IN_APP" } },
155
+ variables: { filter: v.unreadFilter || { channel: "IN_APP" } },
146
156
  fetchPolicy: "network-only"
147
157
  });
148
- e.data && S(e.data.myUnreadNotificationCount);
158
+ e.data && k(e.data.myUnreadNotificationCount);
149
159
  } catch (e) {
150
160
  console.error("[useNotifications] Failed to fetch unread count:", e);
151
161
  }
152
- }, [R, S]), V = d(async () => {
153
- if (M) try {
154
- let e = await R().query({
162
+ }, [
163
+ K,
164
+ v.unreadFilter,
165
+ k
166
+ ]), Y = p(async () => {
167
+ if (z) try {
168
+ let e = await K().query({
155
169
  query: o,
156
170
  variables: {
157
- filter: v(_),
171
+ filter: x(G),
158
172
  limit: 50,
159
- offset: I
173
+ offset: U
160
174
  },
161
175
  fetchPolicy: "network-only"
162
176
  });
163
177
  if (e.data?.notifications) {
164
- let t = e.data.notifications.items.map(m);
165
- T((e) => [...e, ...t]), N(e.data.notifications.hasMore), L((e) => e + 50);
178
+ let t = e.data.notifications.items.map(_);
179
+ M((e) => [...e, ...t]), B(e.data.notifications.hasMore), W((e) => e + 50);
166
180
  }
167
181
  } catch (e) {
168
182
  let t = e instanceof Error ? e.message : "Failed to load more notifications";
169
- console.error("[useNotifications] Failed to load more:", e), j(t);
183
+ console.error("[useNotifications] Failed to load more:", e), R(t);
170
184
  }
171
185
  }, [
172
- R,
173
- _,
174
- M,
175
- I
176
- ]), H = d(async (e) => {
186
+ G,
187
+ K,
188
+ z,
189
+ U
190
+ ]), X = p(async (e) => {
177
191
  try {
178
- await R().mutate({
192
+ await K().mutate({
179
193
  mutation: c,
180
194
  variables: { id: e }
181
- }), T((t) => t.map((t) => t.id === e ? {
195
+ }), M((t) => t.map((t) => t.id === e ? {
182
196
  ...t,
183
197
  readAt: (/* @__PURE__ */ new Date()).toISOString()
184
- } : t)), S(Math.max(0, x - 1));
198
+ } : t)), k(Math.max(0, O - 1));
185
199
  } catch (e) {
186
- console.error("[useNotifications] Failed to mark as read:", e), j("Failed to mark notification as read");
200
+ console.error("[useNotifications] Failed to mark as read:", e), R("Failed to mark notification as read");
187
201
  }
188
202
  }, [
189
- R,
190
- S,
191
- x
192
- ]), U = d(async () => {
203
+ K,
204
+ k,
205
+ O
206
+ ]), Z = p(async () => {
193
207
  try {
194
- await R().mutate({ mutation: s }), T((e) => e.map((e) => ({
208
+ await K().mutate({ mutation: s }), M((e) => e.map((e) => ({
195
209
  ...e,
196
210
  readAt: e.readAt || (/* @__PURE__ */ new Date()).toISOString()
197
- }))), S(0);
211
+ }))), k(0);
198
212
  } catch (e) {
199
- console.error("[useNotifications] Failed to mark all as read:", e), j("Failed to mark all notifications as read");
213
+ console.error("[useNotifications] Failed to mark all as read:", e), R("Failed to mark all notifications as read");
200
214
  }
201
- }, [R, S]), W = d(async (e) => {
215
+ }, [K, k]), Q = p(async (e) => {
202
216
  try {
203
- await R().mutate({
217
+ await K().mutate({
204
218
  mutation: r,
205
219
  variables: { id: e }
206
- }), T((t) => t.map((t) => t.id === e ? {
220
+ }), M((t) => t.map((t) => t.id === e ? {
207
221
  ...t,
208
222
  archivedAt: (/* @__PURE__ */ new Date()).toISOString()
209
223
  } : t));
210
224
  } catch (e) {
211
- console.error("[useNotifications] Failed to archive notification:", e), j("Failed to archive notification");
225
+ console.error("[useNotifications] Failed to archive notification:", e), R("Failed to archive notification");
212
226
  }
213
- }, [R]), G = d(async (e) => {
227
+ }, [K]), $ = p(async (e) => {
214
228
  try {
215
- await R().mutate({
229
+ await K().mutate({
216
230
  mutation: i,
217
231
  variables: { notificationIds: e }
218
232
  });
219
233
  let t = new Set(e);
220
- T((e) => e.map((e) => t.has(e.id) ? {
234
+ M((e) => e.map((e) => t.has(e.id) ? {
221
235
  ...e,
222
236
  archivedAt: (/* @__PURE__ */ new Date()).toISOString()
223
237
  } : e));
224
238
  } catch (e) {
225
- console.error("[useNotifications] Failed to bulk archive:", e), j("Failed to archive notifications");
239
+ console.error("[useNotifications] Failed to bulk archive:", e), R("Failed to archive notifications");
226
240
  }
227
- }, [R]), K = d(async (e) => {
241
+ }, [K]), ee = p(async (e) => {
228
242
  try {
229
- await R().mutate({
230
- mutation: u,
243
+ await K().mutate({
244
+ mutation: d,
231
245
  variables: { id: e }
232
- }), T((t) => t.map((t) => t.id === e ? {
246
+ }), M((t) => t.map((t) => t.id === e ? {
233
247
  ...t,
234
248
  archivedAt: void 0
235
249
  } : t));
236
250
  } catch (e) {
237
- console.error("[useNotifications] Failed to unarchive notification:", e), j("Failed to restore notification");
251
+ console.error("[useNotifications] Failed to unarchive notification:", e), R("Failed to restore notification");
238
252
  }
239
- }, [R]), q = d(async (e, t) => {
253
+ }, [K]), te = p(async (e, t) => {
240
254
  try {
241
- await R().mutate({
242
- mutation: l,
255
+ await K().mutate({
256
+ mutation: u,
243
257
  variables: { input: {
244
258
  notificationId: e,
245
259
  actionId: t
246
260
  } }
247
- }), T((t) => t.map((t) => t.id === e ? {
261
+ }), M((t) => t.map((t) => t.id === e ? {
248
262
  ...t,
249
263
  clickedAt: (/* @__PURE__ */ new Date()).toISOString(),
250
264
  readAt: t.readAt || (/* @__PURE__ */ new Date()).toISOString()
251
265
  } : t));
252
266
  } catch (e) {
253
- console.error("[useNotifications] Failed to record notification action:", e), j("Failed to record notification action");
267
+ console.error("[useNotifications] Failed to record notification action:", e), R("Failed to record notification action");
254
268
  }
255
- }, [R]);
256
- return f(() => {
257
- z(), B();
258
- }, [z, B]), f(() => {
259
- let e = setInterval(() => {
260
- z(), B();
261
- }, 5e3);
262
- return () => clearInterval(e);
263
- }, [z, B]), {
264
- notifications: w.filter((e) => e.deliveryStatus === "UNSUBSCRIBED" || e.status === "ARCHIVED" && !e.archivedAt ? !1 : _.archived === !0 ? !!e.archivedAt : _.archived === !1 ? !e.archivedAt : !0),
265
- allNotifications: w,
266
- unreadCount: x,
267
- selectedNotification: E,
268
- notificationFilter: _,
269
- isLoading: O,
270
- error: A,
271
- hasMore: M,
272
- total: P,
273
- markAsRead: H,
274
- markAllAsRead: U,
275
- archiveNotification: W,
276
- bulkArchive: G,
277
- unarchiveNotification: K,
278
- recordAction: q,
279
- setSelectedNotification: D,
280
- updateFilter: y,
281
- resetFilter: b,
282
- refetch: z,
283
- loadMore: V
269
+ }, [K]);
270
+ return m(() => {
271
+ q(), J();
272
+ }, [q, J]), m(() => {
273
+ if (!C?.id) return;
274
+ let e = K(), t = e.subscribe({
275
+ query: l,
276
+ variables: { userId: C.id }
277
+ }).subscribe({
278
+ next: (e) => {
279
+ let t = e.data?.notificationReceived;
280
+ if (!t) return;
281
+ let n = _(t);
282
+ M((e) => [n, ...e.filter((e) => e.id !== n.id)]), w?.emit("notification:received", { notification: n });
283
+ },
284
+ error: (e) => {
285
+ console.error("[useNotifications] Notification subscription failed:", e);
286
+ }
287
+ }), n = e.subscribe({
288
+ query: f,
289
+ variables: { userId: C.id }
290
+ }).subscribe({
291
+ next: (e) => {
292
+ let t = e.data?.unreadCountUpdated;
293
+ typeof t == "number" && (k(t), w?.emit("notification:unread-count-updated", { unreadCount: t }));
294
+ },
295
+ error: (e) => {
296
+ console.error("[useNotifications] Unread count subscription failed:", e);
297
+ }
298
+ });
299
+ return () => {
300
+ t.unsubscribe(), n.unsubscribe();
301
+ };
302
+ }, [
303
+ C?.id,
304
+ w,
305
+ K,
306
+ k
307
+ ]), m(() => {
308
+ let e = () => {
309
+ document.visibilityState === "visible" && (q(), J());
310
+ };
311
+ return document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e);
312
+ }, [q, J]), {
313
+ notifications: j.filter((e) => e.deliveryStatus === "UNSUBSCRIBED" || e.status === "ARCHIVED" && !e.archivedAt ? !1 : G.archived === !0 ? !!e.archivedAt : G.archived === !1 ? !e.archivedAt : !0),
314
+ allNotifications: j,
315
+ unreadCount: O,
316
+ selectedNotification: N,
317
+ notificationFilter: G,
318
+ isLoading: F,
319
+ error: L,
320
+ hasMore: z,
321
+ total: V,
322
+ markAsRead: X,
323
+ markAllAsRead: Z,
324
+ archiveNotification: Q,
325
+ bulkArchive: $,
326
+ unarchiveNotification: ee,
327
+ recordAction: te,
328
+ setSelectedNotification: P,
329
+ updateFilter: E,
330
+ resetFilter: D,
331
+ refetch: q,
332
+ loadMore: Y
284
333
  };
285
334
  }
286
335
  //#endregion
287
- export { y as useNotifications };
336
+ export { C as useNotifications };
288
337
 
289
338
  //# sourceMappingURL=useNotifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.js","names":[],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\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 = GetNotificationsQuery['notifications']['items'][number];\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\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() {\n const { authToken, apiGatewayUrl } = 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 [offset, setOffset] = useState(0);\n\n const LIMIT = 50;\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 setIsLoading(true);\n setIsLoadingNotifications(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: buildBackendFilter(notificationFilter),\n limit: LIMIT,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n setOffset(LIMIT);\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 } finally {\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [getClient, notificationFilter, 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 query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: { 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, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore) return;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(notificationFilter),\n limit: LIMIT,\n offset,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n setNotifications((prev) => [...prev, ...more]);\n setHasMore(result.data.notifications.hasMore);\n setOffset((prev) => prev + LIMIT);\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 }\n }, [getClient, notificationFilter, hasMore, offset]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\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({ mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument });\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 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 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 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 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 fetchUnreadCount();\n }, [fetchNotifications, fetchUnreadCount]);\n\n // ---- Notification + unread auto-polling (5s interval) -------------------\n\n useEffect(() => {\n const interval = setInterval(() => {\n fetchNotifications();\n fetchUnreadCount();\n }, 5_000);\n return () => clearInterval(interval);\n }, [fetchNotifications, fetchUnreadCount]);\n\n const visibleNotifications = 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 (notificationFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (notificationFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n });\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter,\n isLoading,\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":";;;;;;AAwBA,SAAS,EAA4B,GAAsC;AACzE,QAAO;EACL,IAAI,EAAE;EACN,MAAM,EAAoB,EAAE,KAAK;EACjC,UAAU,EAAY,EAAE,SAAS;EACjC,OAAO,EAAE;EACT,MAAM,EAAE;EACR,WAAW,EAAE,eAAe,KAAA;EAC5B,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,OAAY;GAC1C,IAAI,EAAO;GACX,OAAO,EAAO;GACd,KAAK,EAAO;GACZ,OAAO,EAAO,SAAS,KAAA;GACvB,YAAY,EAAO,cAAc,KAAA;GACjC,UAAU,EAAO,YAAY,KAAA;GAC9B,EAAE;EACH,SAAS,EAAE,WAAW,KAAA;EACtB,YAAY,EAAE,cAAc,KAAA;EAC5B,SAAS,EAAE;EACX,WAAW,EAAE,aAAa,KAAA;EAC1B,aAAa,EA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ALA,MADe,GAAW,CACb,OAAO;IAClB,UAAU;IACV,WAAW,EAAE,OAAO;KAAE;KAAgB;KAAU,EAAE;IACnD,CAAC,EAEF,GAAkB,MAChB,EAAK,KAAK,MACR,EAAE,OAAO,IACL;IACE,GAAG;IACH,4BAAW,IAAI,MAAM,EAAC,aAAa;IACnC,QAAQ,EAAE,2BAAU,IAAI,MAAM,EAAC,aAAa;IAC7C,GACD,EACL,CACF;WACM,GAAc;AAErB,GADA,QAAQ,MAAM,4DAA4D,EAAI,EAC9E,EAAS,uCAAuC;;IAGpD,CAAC,EAAU,CACZ;AAuCD,QAnCA,QAAgB;AAEd,EADA,GAAoB,EACpB,GAAkB;IACjB,CAAC,GAAoB,EAAiB,CAAC,EAI1C,QAAgB;EACd,IAAM,IAAW,kBAAkB;AAEjC,GADA,GAAoB,EACpB,GAAkB;KACjB,IAAM;AACT,eAAa,cAAc,EAAS;IACnC,CAAC,GAAoB,EAAiB,CAAC,EAsBnC;EACL,eArB2B,EAAc,QAAQ,MAC7C,EAAa,mBAAmB,kBAIhC,EAAa,WAAW,cAAc,CAAC,EAAa,aAC/C,KAGL,EAAmB,aAAa,KAC3B,EAAQ,EAAa,aAG1B,EAAmB,aAAa,KAC3B,CAAC,EAAa,aAGhB,GACP;EAIA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ,eAAe;EACf,qBAAqB;EACrB,aAAa;EACb,uBAAuB;EACvB,cAAc;EACd;EACA,cAAc;EACd,aAAa;EACb,SAAS;EACT;EACD"}
1
+ {"version":3,"file":"useNotifications.js","names":[],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\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 [offset, setOffset] = useState(0);\n\n const LIMIT = 50;\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\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 setIsLoading(true);\n setIsLoadingNotifications(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: buildBackendFilter(effectiveFilter),\n limit: LIMIT,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n setOffset(LIMIT);\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 } finally {\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [effectiveFilter, 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 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) return;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(effectiveFilter),\n limit: LIMIT,\n offset,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n setNotifications((prev) => [...prev, ...more]);\n setHasMore(result.data.notifications.hasMore);\n setOffset((prev) => prev + LIMIT);\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 }\n }, [effectiveFilter, getClient, hasMore, offset]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\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({ mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument });\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 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 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 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 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 fetchUnreadCount();\n }, [fetchNotifications, 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 fetchNotifications();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [fetchNotifications, fetchUnreadCount]);\n\n const visibleNotifications = 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\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\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":";;;;;;AAgCA,SAAS,EAA4B,GAAsC;AACzE,QAAO;EACL,IAAI,EAAE;EACN,MAAM,EAAoB,EAAE,KAAK;EACjC,UAAU,EAAY,EAAE,SAAS;EACjC,OAAO,EAAE;EACT,MAAM,EAAE;EACR,WAAW,EAAE,eAAe,KAAA;EAC5B,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,OAAY;GAC1C,IAAI,EAAO;GACX,OAAO,EAAO;GACd,KAAK,EAAO;GACZ,OAAO,EAAO,SAAS,KAAA;GACvB,YAAY,EAAO,cAAc,KAAA;GACjC,UAAU,EAAO,YAAY,KAAA;GAC9B,EAAE;EACH,SAAS,EAAE,WAAW,KAAA;EACtB,YAAY,EAAE,cAAc,KAAA;EAC5B,SAAS,EAAE;EACX,WAAW,EAAE,aAAa,KAAA;EAC1B,aAAa,EAAE,eAAe,KAAA;EAC9B,gBAAgB,EAAE,kBAAkB,KAAA;EACpC,UAAU,EAAE,eAAe,KAAA;EAC3B,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,OAAU;GACpC,KAAK,EAAK;GACV,OAAO,EAAK,SAAS,KAAA;GACrB,MAAM,EAAK,QAAQ,KAAA;GACnB,aAAa,EAAK,eAAe,KAAA;GACjC,cAAc,EAAK,gBAAgB,KAAA;GACpC,EAAE;EACH,UAAU,EAAE,YAAY,KAAA;EACxB,gBAAgB,EAAE,kBAAkB,KAAA;EACpC,gBAAgB,EAAE,kBAAkB,KAAA;EACpC,cAAc,EAAE,gBAAgB,KAA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CAAC,EAE/D,QAAgB;EACd,IAAM,UAA+B;AACnC,GAAI,SAAS,oBAAoB,cAC/B,GAAoB,EACpB,GAAkB;;AAKtB,SADA,SAAS,iBAAiB,oBAAoB,EAAuB,QACxD,SAAS,oBAAoB,oBAAoB,EAAuB;IACpF,CAAC,GAAoB,EAAiB,CAAC,EAsBnC;EACL,eArB2B,EAAc,QAAQ,MAC7C,EAAa,mBAAmB,kBAIhC,EAAa,WAAW,cAAc,CAAC,EAAa,aAC/C,KAGL,EAAgB,aAAa,KACxB,EAAQ,EAAa,aAG1B,EAAgB,aAAa,KACxB,CAAC,EAAa,aAGhB,GACP;EAIA,kBAAkB;EAClB;EACA;EACA,oBAAoB;EACpB;EACA;EACA;EACA;EACA,YAAY;EACZ,eAAe;EACf,qBAAqB;EACrB,aAAa;EACb,uBAAuB;EACvB,cAAc;EACd;EACA,cAAc;EACd,aAAa;EACb,SAAS;EACT;EACD"}
@@ -0,0 +1,24 @@
1
+ import { brand as e, isBranded as t } from "./utils.js";
2
+ //#region node_modules/@apollo/client/errors/CombinedGraphQLErrors.js
3
+ function n(e) {
4
+ return e.filter((e) => e).map((e) => e.message || "Error message not found.").join("\n");
5
+ }
6
+ var r = class r extends Error {
7
+ static is(e) {
8
+ return t(e, "CombinedGraphQLErrors");
9
+ }
10
+ static formatMessage = n;
11
+ errors;
12
+ data;
13
+ extensions;
14
+ constructor(t, i = t.errors || []) {
15
+ super(r.formatMessage(i, {
16
+ result: t,
17
+ defaultFormatMessage: n
18
+ })), this.errors = i, this.data = t.data, this.extensions = t.extensions, this.name = "CombinedGraphQLErrors", e(this), Object.setPrototypeOf(this, r.prototype);
19
+ }
20
+ };
21
+ //#endregion
22
+ export { r as CombinedGraphQLErrors };
23
+
24
+ //# sourceMappingURL=CombinedGraphQLErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CombinedGraphQLErrors.js","names":[],"sources":["../../../../../node_modules/@apollo/client/errors/CombinedGraphQLErrors.js"],"sourcesContent":["import { brand, isBranded } from \"./utils.js\";\nfunction defaultFormatMessage(errors) {\n return (errors\n // Handle non-spec-compliant servers: See #1185\n .filter((e) => e)\n .map((e) => e.message || \"Error message not found.\")\n .join(\"\\n\"));\n}\n/**\n * Represents the combined list of GraphQL errors returned from the server in a\n * GraphQL response. This error type is used when your GraphQL operation returns\n * errors in the `errors` field of the response.\n *\n * @remarks\n *\n * When your GraphQL operation encounters errors on the server side (such as\n * resolver errors, validation errors, or syntax errors), the server returns\n * these errors in the `errors` array of the GraphQL response. Apollo Client\n * wraps these errors in a `CombinedGraphQLErrors` object, which provides access\n * to the individual errors while maintaining additional context about the\n * response.\n *\n * @example\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client/errors\";\n *\n * // Check if an error is a CombinedGraphQLErrors object\n * if (CombinedGraphQLErrors.is(error)) {\n * // Access individual GraphQL errors\n * error.errors.forEach((graphQLError) => {\n * console.log(graphQLError.message);\n * console.log(graphQLError.path);\n * console.log(graphQLError.locations);\n * });\n *\n * // Access the original GraphQL result\n * console.log(error.result);\n * }\n * ```\n */\nexport class CombinedGraphQLErrors extends Error {\n /**\n * A method that determines whether an error is a `CombinedGraphQLErrors`\n * object. This method enables TypeScript to narrow the error type.\n * \n * @example\n * \n * ```ts\n * if (CombinedGraphQLErrors.is(error)) {\n * // TypeScript now knows `error` is a `CombinedGraphQLErrors` object\n * console.log(error.errors);\n * }\n * ```\n */\n static is(error) {\n return isBranded(error, \"CombinedGraphQLErrors\");\n }\n /**\n * A function that formats the error message used for the error's `message`\n * property. Override this method to provide your own formatting.\n * \n * @remarks\n * \n * The `formatMessage` function is called by the `CombinedGraphQLErrors`\n * constructor to provide a formatted message as the `message` property of the\n * `CombinedGraphQLErrors` object. Follow the [\"Providing a custom message\n * formatter\"](https://www.apollographql.com/docs/react/api/errors/CombinedGraphQLErrors#providing-a-custom-message-formatter) guide to learn how to modify the message format.\n * \n * @param errors - The array of GraphQL errors returned from the server in\n * the `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n static formatMessage = defaultFormatMessage;\n /**\n * The raw list of GraphQL errors returned by the `errors` field in the GraphQL response.\n */\n errors;\n /**\n * Partial data returned in the `data` field of the GraphQL response.\n */\n data;\n /**\n * Extensions returned by the `extensions` field in the GraphQL response.\n */\n extensions;\n constructor(result, errors = result.errors || []) {\n super(CombinedGraphQLErrors.formatMessage(errors, {\n result,\n defaultFormatMessage,\n }));\n this.errors = errors;\n this.data = result.data;\n this.extensions = result.extensions;\n this.name = \"CombinedGraphQLErrors\";\n brand(this);\n Object.setPrototypeOf(this, CombinedGraphQLErrors.prototype);\n }\n}\n//# sourceMappingURL=CombinedGraphQLErrors.js.map\n"],"x_google_ignoreList":[0],"mappings":";;AACA,SAAS,EAAqB,GAAQ;AAClC,QAAQ,EAEH,QAAQ,MAAM,EAAE,CAChB,KAAK,MAAM,EAAE,WAAW,2BAA2B,CACnD,KAAK,KAAK;;AAmCnB,IAAa,IAAb,MAAa,UAA8B,MAAM;CAc7C,OAAO,GAAG,GAAO;AACb,SAAO,EAAU,GAAO,wBAAwB;;CAkBpD,OAAO,gBAAgB;CAIvB;CAIA;CAIA;CACA,YAAY,GAAQ,IAAS,EAAO,UAAU,EAAE,EAAE;AAU9C,EATA,MAAM,EAAsB,cAAc,GAAQ;GAC9C;GACA;GACH,CAAC,CAAC,EACH,KAAK,SAAS,GACd,KAAK,OAAO,EAAO,MACnB,KAAK,aAAa,EAAO,YACzB,KAAK,OAAO,yBACZ,EAAM,KAAK,EACX,OAAO,eAAe,MAAM,EAAsB,UAAU"}
@@ -0,0 +1,16 @@
1
+ //#region node_modules/@apollo/client/errors/utils.js
2
+ function e(e, t) {
3
+ return typeof e == "object" && !!e && e[Symbol.for("apollo.error")] === t;
4
+ }
5
+ function t(e) {
6
+ Object.defineProperty(e, Symbol.for("apollo.error"), {
7
+ value: e.name,
8
+ enumerable: !1,
9
+ writable: !1,
10
+ configurable: !1
11
+ });
12
+ }
13
+ //#endregion
14
+ export { t as brand, e as isBranded };
15
+
16
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../../node_modules/@apollo/client/errors/utils.js"],"sourcesContent":["export function isBranded(error, name) {\n return (typeof error === \"object\" &&\n error !== null &&\n error[Symbol.for(\"apollo.error\")] === name);\n}\nexport function brand(error) {\n Object.defineProperty(error, Symbol.for(\"apollo.error\"), {\n value: error.name,\n enumerable: false,\n writable: false,\n configurable: false,\n });\n}\n//# sourceMappingURL=utils.js.map"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAgB,EAAU,GAAO,GAAM;AACnC,QAAQ,OAAO,KAAU,cACrB,KACA,EAAM,OAAO,IAAI,eAAe,MAAM;;AAE9C,SAAgB,EAAM,GAAO;AACzB,QAAO,eAAe,GAAO,OAAO,IAAI,eAAe,EAAE;EACrD,OAAO,EAAM;EACb,YAAY;EACZ,UAAU;EACV,cAAc;EACjB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { EMPTY as e } from "../../../../rxjs/dist/esm5/internal/observable/empty.js";
2
+ import { newInvariantError as t } from "../../utilities/invariant/index.js";
3
+ import { createOperation as n } from "../utils/createOperation.js";
4
+ //#region node_modules/@apollo/client/link/core/ApolloLink.js
5
+ var r = class r {
6
+ static empty() {
7
+ return new r(() => e);
8
+ }
9
+ static from(e) {
10
+ if (e.length === 0) return r.empty();
11
+ let [t, ...n] = e;
12
+ return t.concat(...n);
13
+ }
14
+ static split(e, t, n = new r((e, t) => t(e))) {
15
+ let i = new r((r, i) => e(r) ? t.request(r, i) : n.request(r, i));
16
+ return Object.assign(i, {
17
+ left: t,
18
+ right: n
19
+ });
20
+ }
21
+ static execute(t, r, i) {
22
+ return t.request(n(r, i), () => e);
23
+ }
24
+ static concat(...e) {
25
+ return r.from(e);
26
+ }
27
+ constructor(e) {
28
+ e && (this.request = e);
29
+ }
30
+ split(e, t, n) {
31
+ return this.concat(r.split(e, t, n));
32
+ }
33
+ concat(...e) {
34
+ return e.length === 0 ? this : e.reduce(this.combine.bind(this), this);
35
+ }
36
+ combine(e, t) {
37
+ let n = new r((n, r) => e.request(n, (e) => t.request(e, r)));
38
+ return Object.assign(n, {
39
+ left: e,
40
+ right: t
41
+ });
42
+ }
43
+ request(e, n) {
44
+ throw t(65);
45
+ }
46
+ left;
47
+ right;
48
+ };
49
+ //#endregion
50
+ export { r as ApolloLink };
51
+
52
+ //# sourceMappingURL=ApolloLink.js.map