@burdenoff/microfe-notification 2026.424.101

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 (161) hide show
  1. package/README.md +376 -0
  2. package/dist/AdminNotificationRoot.d.ts +35 -0
  3. package/dist/AdminNotificationRoot.d.ts.map +1 -0
  4. package/dist/AdminNotificationRoot.js +81 -0
  5. package/dist/AdminNotificationRoot.js.map +1 -0
  6. package/dist/AdminNotificationRoutes.d.ts +2 -0
  7. package/dist/AdminNotificationRoutes.d.ts.map +1 -0
  8. package/dist/AdminNotificationRoutes.js +108 -0
  9. package/dist/AdminNotificationRoutes.js.map +1 -0
  10. package/dist/NotificationRoot.d.ts +31 -0
  11. package/dist/NotificationRoot.d.ts.map +1 -0
  12. package/dist/NotificationRoot.js +81 -0
  13. package/dist/NotificationRoot.js.map +1 -0
  14. package/dist/NotificationRoutes.d.ts +17 -0
  15. package/dist/NotificationRoutes.d.ts.map +1 -0
  16. package/dist/NotificationRoutes.js +67 -0
  17. package/dist/NotificationRoutes.js.map +1 -0
  18. package/dist/UserNotificationRoot.d.ts +34 -0
  19. package/dist/UserNotificationRoot.d.ts.map +1 -0
  20. package/dist/UserNotificationRoot.js +64 -0
  21. package/dist/UserNotificationRoot.js.map +1 -0
  22. package/dist/UserNotificationRoutes.d.ts +15 -0
  23. package/dist/UserNotificationRoutes.d.ts.map +1 -0
  24. package/dist/UserNotificationRoutes.js +52 -0
  25. package/dist/UserNotificationRoutes.js.map +1 -0
  26. package/dist/__tests__/setup.d.ts +2 -0
  27. package/dist/__tests__/setup.d.ts.map +1 -0
  28. package/dist/components/NotificationBell.d.ts +14 -0
  29. package/dist/components/NotificationBell.d.ts.map +1 -0
  30. package/dist/components/NotificationBell.js +47 -0
  31. package/dist/components/NotificationBell.js.map +1 -0
  32. package/dist/components/NotificationCard.d.ts +19 -0
  33. package/dist/components/NotificationCard.d.ts.map +1 -0
  34. package/dist/components/NotificationCard.js +112 -0
  35. package/dist/components/NotificationCard.js.map +1 -0
  36. package/dist/components/NotificationPanel.d.ts +11 -0
  37. package/dist/components/NotificationPanel.d.ts.map +1 -0
  38. package/dist/components/NotificationPanel.js +100 -0
  39. package/dist/components/NotificationPanel.js.map +1 -0
  40. package/dist/components/RecipientSelector.d.ts +34 -0
  41. package/dist/components/RecipientSelector.d.ts.map +1 -0
  42. package/dist/components/RecipientSelector.js +212 -0
  43. package/dist/components/RecipientSelector.js.map +1 -0
  44. package/dist/components/TemplatePreview.d.ts +22 -0
  45. package/dist/components/TemplatePreview.d.ts.map +1 -0
  46. package/dist/components/TemplatePreview.js +425 -0
  47. package/dist/components/TemplatePreview.js.map +1 -0
  48. package/dist/components/VariableInserter.d.ts +12 -0
  49. package/dist/components/VariableInserter.d.ts.map +1 -0
  50. package/dist/components/index.d.ts +4 -0
  51. package/dist/components/index.d.ts.map +1 -0
  52. package/dist/components/index.js +3 -0
  53. package/dist/constants/permissions.d.ts +24 -0
  54. package/dist/constants/permissions.d.ts.map +1 -0
  55. package/dist/constants/permissions.js +17 -0
  56. package/dist/constants/permissions.js.map +1 -0
  57. package/dist/dev/main.d.ts +2 -0
  58. package/dist/dev/main.d.ts.map +1 -0
  59. package/dist/generated/global-operations.d.ts +1408 -0
  60. package/dist/generated/global-operations.d.ts.map +1 -0
  61. package/dist/generated/global-operations.js +514 -0
  62. package/dist/generated/global-operations.js.map +1 -0
  63. package/dist/generated/global-types.d.ts +20773 -0
  64. package/dist/generated/global-types.d.ts.map +1 -0
  65. package/dist/generated/wspace-operations.d.ts +2 -0
  66. package/dist/generated/wspace-operations.d.ts.map +1 -0
  67. package/dist/generated/wspace-types.d.ts +53363 -0
  68. package/dist/generated/wspace-types.d.ts.map +1 -0
  69. package/dist/graphql/global-client.d.ts +19 -0
  70. package/dist/graphql/global-client.d.ts.map +1 -0
  71. package/dist/graphql/global-client.js +57 -0
  72. package/dist/graphql/global-client.js.map +1 -0
  73. package/dist/hooks/index.d.ts +6 -0
  74. package/dist/hooks/index.d.ts.map +1 -0
  75. package/dist/hooks/index.js +5 -0
  76. package/dist/hooks/useNotificationAdmin.d.ts +51 -0
  77. package/dist/hooks/useNotificationAdmin.d.ts.map +1 -0
  78. package/dist/hooks/useNotificationAdmin.js +203 -0
  79. package/dist/hooks/useNotificationAdmin.js.map +1 -0
  80. package/dist/hooks/useNotificationTemplates.d.ts +136 -0
  81. package/dist/hooks/useNotificationTemplates.d.ts.map +1 -0
  82. package/dist/hooks/useNotificationTemplates.js +168 -0
  83. package/dist/hooks/useNotificationTemplates.js.map +1 -0
  84. package/dist/hooks/useNotificationTopics.d.ts +36 -0
  85. package/dist/hooks/useNotificationTopics.d.ts.map +1 -0
  86. package/dist/hooks/useNotificationTopics.js +127 -0
  87. package/dist/hooks/useNotificationTopics.js.map +1 -0
  88. package/dist/hooks/useNotifications.d.ts +36 -0
  89. package/dist/hooks/useNotifications.d.ts.map +1 -0
  90. package/dist/hooks/useNotifications.js +289 -0
  91. package/dist/hooks/useNotifications.js.map +1 -0
  92. package/dist/hooks/useSendNotification.d.ts +159 -0
  93. package/dist/hooks/useSendNotification.d.ts.map +1 -0
  94. package/dist/hooks/useSendNotification.js +123 -0
  95. package/dist/hooks/useSendNotification.js.map +1 -0
  96. package/dist/hooks/useUserSearch.d.ts +27 -0
  97. package/dist/hooks/useUserSearch.d.ts.map +1 -0
  98. package/dist/hooks/useUserSearch.js +76 -0
  99. package/dist/hooks/useUserSearch.js.map +1 -0
  100. package/dist/index.d.ts +37 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +13 -0
  103. package/dist/pages/CreateNotificationPage.d.ts +6 -0
  104. package/dist/pages/CreateNotificationPage.d.ts.map +1 -0
  105. package/dist/pages/CreateNotificationPage.js +1366 -0
  106. package/dist/pages/CreateNotificationPage.js.map +1 -0
  107. package/dist/pages/NotificationCenterPage.d.ts +7 -0
  108. package/dist/pages/NotificationCenterPage.d.ts.map +1 -0
  109. package/dist/pages/NotificationCenterPage.js +203 -0
  110. package/dist/pages/NotificationCenterPage.js.map +1 -0
  111. package/dist/pages/NotificationHistoryAdminPage.d.ts +3 -0
  112. package/dist/pages/NotificationHistoryAdminPage.d.ts.map +1 -0
  113. package/dist/pages/NotificationHistoryAdminPage.js +484 -0
  114. package/dist/pages/NotificationHistoryAdminPage.js.map +1 -0
  115. package/dist/pages/NotificationHistoryPage.d.ts +3 -0
  116. package/dist/pages/NotificationHistoryPage.d.ts.map +1 -0
  117. package/dist/pages/NotificationHistoryPage.js +136 -0
  118. package/dist/pages/NotificationHistoryPage.js.map +1 -0
  119. package/dist/pages/NotificationLandingPage.d.ts +11 -0
  120. package/dist/pages/NotificationLandingPage.d.ts.map +1 -0
  121. package/dist/pages/NotificationLandingPage.js +85 -0
  122. package/dist/pages/NotificationLandingPage.js.map +1 -0
  123. package/dist/pages/NotificationPreferencesPage.d.ts +2 -0
  124. package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -0
  125. package/dist/pages/NotificationPreferencesPage.js +108 -0
  126. package/dist/pages/NotificationPreferencesPage.js.map +1 -0
  127. package/dist/pages/NotificationTemplatesPage.d.ts +8 -0
  128. package/dist/pages/NotificationTemplatesPage.d.ts.map +1 -0
  129. package/dist/pages/NotificationTemplatesPage.js +310 -0
  130. package/dist/pages/NotificationTemplatesPage.js.map +1 -0
  131. package/dist/pages/NotificationTopicsPage.d.ts +2 -0
  132. package/dist/pages/NotificationTopicsPage.d.ts.map +1 -0
  133. package/dist/pages/NotificationTopicsPage.js +254 -0
  134. package/dist/pages/NotificationTopicsPage.js.map +1 -0
  135. package/dist/pages/TemplateEditorPage.d.ts +13 -0
  136. package/dist/pages/TemplateEditorPage.d.ts.map +1 -0
  137. package/dist/pages/TemplateEditorPage.js +790 -0
  138. package/dist/pages/TemplateEditorPage.js.map +1 -0
  139. package/dist/providers/NotificationProvider.d.ts +19 -0
  140. package/dist/providers/NotificationProvider.d.ts.map +1 -0
  141. package/dist/providers/NotificationProvider.js +35 -0
  142. package/dist/providers/NotificationProvider.js.map +1 -0
  143. package/dist/shared/hooks/useTr.d.ts +14 -0
  144. package/dist/shared/hooks/useTr.d.ts.map +1 -0
  145. package/dist/shared/hooks/useTr.js +14 -0
  146. package/dist/shared/hooks/useTr.js.map +1 -0
  147. package/dist/store/notificationStore.d.ts +32 -0
  148. package/dist/store/notificationStore.d.ts.map +1 -0
  149. package/dist/store/notificationStore.js +124 -0
  150. package/dist/store/notificationStore.js.map +1 -0
  151. package/dist/types/index.d.ts +215 -0
  152. package/dist/types/index.d.ts.map +1 -0
  153. package/dist/utils/index.d.ts +68 -0
  154. package/dist/utils/index.d.ts.map +1 -0
  155. package/dist/utils/index.js +122 -0
  156. package/dist/utils/index.js.map +1 -0
  157. package/dist/utils/notificationHistoryExport.d.ts +13 -0
  158. package/dist/utils/notificationHistoryExport.d.ts.map +1 -0
  159. package/dist/utils/notificationHistoryExport.js +29 -0
  160. package/dist/utils/notificationHistoryExport.js.map +1 -0
  161. package/package.json +115 -0
@@ -0,0 +1,215 @@
1
+ import { MicrofrontendRootProps } from '@burdenoff/fe-libs/shared/types';
2
+ import { NavItem, FooterItem } from '@burdenoff/fe-libs/shared/hooks/shell';
3
+
4
+ export type { NavItem, FooterItem };
5
+ /**
6
+ * Props for the NotificationRoot component
7
+ */
8
+ export interface NotificationRootProps extends MicrofrontendRootProps {
9
+ /**
10
+ * Optional function to register navigation items with the shell
11
+ * Injected by the shell app
12
+ */
13
+ registerNavItems?: (items: NavItem | NavItem[]) => () => void;
14
+ /**
15
+ * Optional function to register footer items with the shell
16
+ * Injected by the shell app
17
+ */
18
+ registerFooterItems?: (items: FooterItem | FooterItem[]) => () => void;
19
+ /**
20
+ * Optional callback when a notification is clicked
21
+ */
22
+ onNotificationClick?: (notification: Notification) => void;
23
+ }
24
+ /**
25
+ * Notification type enum (matches backend NotificationType)
26
+ */
27
+ export type NotificationType = 'TRANSACTIONAL' | 'MARKETING' | 'SYSTEM' | 'ALERT';
28
+ /**
29
+ * Notification priority enum
30
+ */
31
+ export type NotificationPriority = 'LOW' | 'NORMAL' | 'HIGH' | 'URGENT';
32
+ /**
33
+ * Notification status enum
34
+ */
35
+ export type NotificationStatus = 'PENDING' | 'SENT' | 'DELIVERED' | 'FAILED' | 'ARCHIVED';
36
+ /**
37
+ * Notification channel enum
38
+ */
39
+ export type NotificationChannel = 'EMAIL' | 'IN_APP' | 'SMS' | 'PUSH' | 'WEBHOOK' | 'WHATSAPP' | 'TEAMS' | 'SLACK' | 'TELEGRAM' | 'DISCORD';
40
+ /**
41
+ * Notification entity
42
+ */
43
+ export interface Notification {
44
+ id: string;
45
+ type: NotificationType;
46
+ priority: NotificationPriority;
47
+ title: string;
48
+ body: string;
49
+ actionUrl?: string;
50
+ actions: NotificationAction[];
51
+ appName?: string;
52
+ archivedAt?: string;
53
+ channel: NotificationChannel | 'IN_APP';
54
+ clickedAt?: string;
55
+ deliveredAt?: string;
56
+ deliveryStatus?: string;
57
+ htmlBody?: string;
58
+ imageUrl?: string;
59
+ media: NotificationMedia[];
60
+ openedAt?: string;
61
+ recipientEmail?: string;
62
+ recipientPhone?: string;
63
+ scheduledFor?: string;
64
+ scheduledNotification?: {
65
+ id: string;
66
+ scheduledFor: string;
67
+ status: string;
68
+ timezone?: string;
69
+ retryCount?: number;
70
+ errorMessage?: string;
71
+ };
72
+ sentAt?: string;
73
+ status: NotificationStatus;
74
+ readAt?: string;
75
+ createdAt: string;
76
+ updatedAt?: string;
77
+ createdBy?: string;
78
+ channels: NotificationChannelDelivery[];
79
+ metadata?: Record<string, unknown>;
80
+ topic?: NotificationTopicSummary;
81
+ topicId?: string;
82
+ }
83
+ export interface NotificationAction {
84
+ id: string;
85
+ label: string;
86
+ url: string;
87
+ style?: string;
88
+ actionType?: string;
89
+ metadata?: Record<string, unknown>;
90
+ }
91
+ export interface NotificationMedia {
92
+ url: string;
93
+ label?: string;
94
+ kind?: string;
95
+ contentType?: string;
96
+ thumbnailUrl?: string;
97
+ }
98
+ export interface NotificationTopicSummary {
99
+ id: string;
100
+ name: string;
101
+ slug: string;
102
+ type: NotificationType;
103
+ description?: string;
104
+ }
105
+ /**
106
+ * Notification channel delivery info
107
+ */
108
+ export interface NotificationChannelDelivery {
109
+ id: string;
110
+ channel: NotificationChannel;
111
+ status: NotificationStatus;
112
+ sentAt?: string;
113
+ deliveredAt?: string;
114
+ failedAt?: string;
115
+ errorCode?: string;
116
+ errorMessage?: string;
117
+ }
118
+ /**
119
+ * Notification template entity
120
+ */
121
+ export interface NotificationTemplate {
122
+ id: string;
123
+ key: string;
124
+ name: string;
125
+ description?: string;
126
+ type: NotificationType;
127
+ channels: NotificationChannel[];
128
+ locale: string;
129
+ titleTemplate: string;
130
+ bodyTemplate: string;
131
+ variables: TemplateVariable[];
132
+ isActive: boolean;
133
+ createdAt: string;
134
+ updatedAt?: string;
135
+ createdBy?: string;
136
+ version?: number;
137
+ }
138
+ /**
139
+ * Template variable definition
140
+ */
141
+ export interface TemplateVariable {
142
+ name: string;
143
+ type: 'STRING' | 'NUMBER' | 'BOOLEAN' | 'DATE' | 'URL';
144
+ required: boolean;
145
+ description?: string;
146
+ defaultValue?: string;
147
+ }
148
+ /**
149
+ * Notification filter
150
+ */
151
+ export interface NotificationFilter {
152
+ search: string;
153
+ channel?: NotificationChannel | 'ALL';
154
+ type: NotificationType | 'ALL';
155
+ status: NotificationStatus | 'ALL';
156
+ priority: NotificationPriority | 'ALL';
157
+ isRead: boolean | null;
158
+ topicId?: string;
159
+ archived?: boolean | null;
160
+ dateRange: {
161
+ start: Date | null;
162
+ end: Date | null;
163
+ };
164
+ }
165
+ export interface NotificationTopic extends NotificationTopicSummary {
166
+ isActive: boolean;
167
+ metadata?: Record<string, unknown>;
168
+ subscriberCount: number;
169
+ mySubscription?: NotificationTopicSubscription;
170
+ createdAt: string;
171
+ updatedAt: string;
172
+ }
173
+ export interface NotificationTopicSubscription {
174
+ id: string;
175
+ subscribed: boolean;
176
+ unsubscribedAt?: string;
177
+ topicId: string;
178
+ userId: string;
179
+ }
180
+ export interface NotificationAdminFilters {
181
+ search: string;
182
+ status: string;
183
+ channel: string;
184
+ deliveryStatus: string;
185
+ type: string;
186
+ topicId: string;
187
+ archived: 'all' | 'active' | 'archived';
188
+ }
189
+ /**
190
+ * Pagination info
191
+ */
192
+ export interface PageInfo {
193
+ hasNextPage: boolean;
194
+ endCursor?: string;
195
+ }
196
+ /**
197
+ * Connection edge
198
+ */
199
+ export interface Edge<T> {
200
+ node: T;
201
+ cursor: string;
202
+ }
203
+ /**
204
+ * Connection type
205
+ */
206
+ export interface Connection<T> {
207
+ edges: Edge<T>[];
208
+ pageInfo: PageInfo;
209
+ totalCount?: number;
210
+ }
211
+ /**
212
+ * Notification preset type
213
+ */
214
+ export type NotificationPreset = 'MINIMAL' | 'STANDARD' | 'VERBOSE' | 'CUSTOM';
215
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAEjF,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;IACnE;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,KAAK,MAAM,IAAI,CAAC;IAE9D;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,KAAK,MAAM,IAAI,CAAC;IAEvE;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5D;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,WAAW,GAAG,QAAQ,GAAG,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AC;IACR,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { Notification, NotificationFilter, NotificationPriority, NotificationType } from '../types';
2
+
3
+ /**
4
+ * Format a relative time string (e.g., "2 minutes ago", "1 hour ago")
5
+ */
6
+ export declare function formatRelativeTime(date: string | Date): string;
7
+ /**
8
+ * Get priority color class name (for use with semantic tokens)
9
+ */
10
+ export declare function getPriorityColor(priority: NotificationPriority): string;
11
+ /**
12
+ * Get priority icon/indicator
13
+ */
14
+ export declare function getPriorityIcon(priority: NotificationPriority): string;
15
+ /**
16
+ * Get notification type label
17
+ */
18
+ export declare function getNotificationTypeLabel(type: NotificationType): string;
19
+ /**
20
+ * Get notification type icon
21
+ */
22
+ export declare function getNotificationTypeIcon(type: NotificationType): string;
23
+ /**
24
+ * Filter notifications based on criteria
25
+ */
26
+ export declare function filterNotifications(notifications: Notification[], filter: NotificationFilter): Notification[];
27
+ /**
28
+ * Sort notifications by created date (newest first)
29
+ */
30
+ export declare function sortNotificationsByDate(notifications: Notification[]): Notification[];
31
+ /**
32
+ * Group notifications by date (Today, Yesterday, This Week, etc.)
33
+ */
34
+ export declare function groupNotificationsByDate(notifications: Notification[]): Record<string, Notification[]>;
35
+ /**
36
+ * Truncate text to a maximum length
37
+ */
38
+ export declare function truncateText(text: string, maxLength: number): string;
39
+ /**
40
+ * Validate template variable substitution
41
+ */
42
+ export declare function validateTemplateVariables(template: string, variables: Record<string, unknown>): {
43
+ isValid: boolean;
44
+ missingVariables: string[];
45
+ };
46
+ /**
47
+ * Substitute template variables
48
+ */
49
+ export declare function substituteTemplateVariables(template: string, variables: Record<string, unknown>): string;
50
+ /**
51
+ * Get delivery status color
52
+ */
53
+ export declare function getDeliveryStatusColor(status: 'PENDING' | 'SENT' | 'DELIVERED' | 'FAILED' | 'ARCHIVED'): string;
54
+ /**
55
+ * Calculate delivery rate percentage
56
+ */
57
+ export declare function calculateDeliveryRate(delivered: number, total: number): number;
58
+ /**
59
+ * Check whether a mutation error represents a gateway-level authorization
60
+ * failure (the RBAC gateway rejected the request because the actor lacks
61
+ * the required permission). Callers surface these with a friendly toast and
62
+ * refresh the permission cache to recover from stale client state.
63
+ *
64
+ * 401/UNAUTHENTICATED is handled separately by the shell's auth flow — this
65
+ * helper intentionally ignores it.
66
+ */
67
+ export declare function isPermissionError(err: unknown): boolean;
68
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAoB9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAavE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAatE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAavE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAatE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,YAAY,EAAE,EAC7B,MAAM,EAAE,kBAAkB,GACzB,YAAY,EAAE,CA4ChB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAIrF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,YAAY,EAAE,GAC5B,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CA0ChC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAAE,CAgBlD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAC/D,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAmCvD"}
@@ -0,0 +1,122 @@
1
+ //#region src/utils/index.ts
2
+ function e(e) {
3
+ let t = /* @__PURE__ */ new Date(), n = new Date(e), r = t.getTime() - n.getTime(), i = Math.floor(r / 1e3), a = Math.floor(i / 60), o = Math.floor(a / 60), s = Math.floor(o / 24);
4
+ return i < 60 ? "just now" : a < 60 ? `${a} ${a === 1 ? "minute" : "minutes"} ago` : o < 24 ? `${o} ${o === 1 ? "hour" : "hours"} ago` : s < 7 ? `${s} ${s === 1 ? "day" : "days"} ago` : n.toLocaleDateString();
5
+ }
6
+ function t(e) {
7
+ switch (e) {
8
+ case "URGENT": return "text-error-500";
9
+ case "HIGH": return "text-warning-500";
10
+ case "NORMAL": return "text-info-500";
11
+ case "LOW": return "text-muted-foreground";
12
+ default: return "text-muted-foreground";
13
+ }
14
+ }
15
+ function n(e) {
16
+ switch (e) {
17
+ case "URGENT": return "🔴";
18
+ case "HIGH": return "🟠";
19
+ case "NORMAL": return "🟢";
20
+ case "LOW": return "⚪";
21
+ default: return "⚪";
22
+ }
23
+ }
24
+ function r(e) {
25
+ switch (e) {
26
+ case "TRANSACTIONAL": return "Transactional";
27
+ case "MARKETING": return "Marketing";
28
+ case "SYSTEM": return "System";
29
+ case "ALERT": return "Alert";
30
+ default: return "Unknown";
31
+ }
32
+ }
33
+ function i(e) {
34
+ switch (e) {
35
+ case "TRANSACTIONAL": return "📧";
36
+ case "MARKETING": return "📢";
37
+ case "SYSTEM": return "⚙️";
38
+ case "ALERT": return "🚨";
39
+ default: return "🔔";
40
+ }
41
+ }
42
+ function a(e, t) {
43
+ return e.filter((e) => {
44
+ if (t.search) {
45
+ let n = t.search.toLowerCase(), r = e.title.toLowerCase().includes(n), i = e.body.toLowerCase().includes(n);
46
+ if (!r && !i) return !1;
47
+ }
48
+ if (t.type !== "ALL" && e.type !== t.type || t.status !== "ALL" && e.status !== t.status || t.priority !== "ALL" && e.priority !== t.priority) return !1;
49
+ if (t.isRead !== null) {
50
+ let n = !!e.readAt;
51
+ if (t.isRead !== n) return !1;
52
+ }
53
+ if (t.dateRange.start || t.dateRange.end) {
54
+ let n = new Date(e.createdAt);
55
+ if (t.dateRange.start && n < t.dateRange.start || t.dateRange.end && n > t.dateRange.end) return !1;
56
+ }
57
+ return !0;
58
+ });
59
+ }
60
+ function o(e) {
61
+ return [...e].sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime());
62
+ }
63
+ function s(e) {
64
+ let t = /* @__PURE__ */ new Date(), n = new Date(t.getFullYear(), t.getMonth(), t.getDate()), r = new Date(n);
65
+ r.setDate(r.getDate() - 1);
66
+ let i = new Date(n);
67
+ i.setDate(i.getDate() - i.getDay());
68
+ let a = {
69
+ Today: [],
70
+ Yesterday: [],
71
+ "This Week": [],
72
+ Earlier: []
73
+ };
74
+ return e.forEach((e) => {
75
+ let t = new Date(e.createdAt), o = new Date(t.getFullYear(), t.getMonth(), t.getDate());
76
+ o.getTime() === n.getTime() ? a.Today.push(e) : o.getTime() === r.getTime() ? a.Yesterday.push(e) : o >= i ? a["This Week"].push(e) : a.Earlier.push(e);
77
+ }), Object.keys(a).forEach((e) => {
78
+ a[e].length === 0 && delete a[e];
79
+ }), a;
80
+ }
81
+ function c(e, t) {
82
+ return e.length <= t ? e : e.slice(0, t) + "...";
83
+ }
84
+ function l(e, t) {
85
+ let n = e.matchAll(/\{\{([^}]+)\}\}/g), r = [];
86
+ for (let e of n) {
87
+ let n = e[1].trim();
88
+ n in t || r.push(n);
89
+ }
90
+ return {
91
+ isValid: r.length === 0,
92
+ missingVariables: r
93
+ };
94
+ }
95
+ function u(e, t) {
96
+ return e.replace(/\{\{([^}]+)\}\}/g, (e, n) => {
97
+ let r = t[n.trim()];
98
+ return r === void 0 ? e : String(r);
99
+ });
100
+ }
101
+ function d(e) {
102
+ if (!e) return !1;
103
+ let t = (e) => {
104
+ for (let t of e) {
105
+ let e = typeof t.extensions?.code == "string" ? t.extensions.code : "", n = typeof t.extensions?.errorCode == "string" ? t.extensions.errorCode : "";
106
+ if (e === "FORBIDDEN" || n === "FORBIDDEN") return !0;
107
+ }
108
+ return !1;
109
+ }, n = e.graphQLErrors;
110
+ if (Array.isArray(n) && t(n)) return !0;
111
+ let r = e.errors;
112
+ if (Array.isArray(r) && t(r)) return !0;
113
+ let i = e.extensions, a = typeof i?.code == "string" ? i.code : "", o = typeof i?.errorCode == "string" ? i.errorCode : "";
114
+ if (a === "FORBIDDEN" || o === "FORBIDDEN") return !0;
115
+ if (i || Array.isArray(n) || Array.isArray(r)) return !1;
116
+ let s = e.message, c = typeof s == "string" ? s.toLowerCase() : "";
117
+ return c.includes("forbidden") || c.includes("permission denied");
118
+ }
119
+ //#endregion
120
+ export { a as filterNotifications, e as formatRelativeTime, i as getNotificationTypeIcon, r as getNotificationTypeLabel, t as getPriorityColor, n as getPriorityIcon, s as groupNotificationsByDate, d as isPermissionError, o as sortNotificationsByDate, u as substituteTemplateVariables, c as truncateText, l as validateTemplateVariables };
121
+
122
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["import type {\n Notification,\n NotificationFilter,\n NotificationPriority,\n NotificationType,\n} from '../types';\n\n/**\n * Format a relative time string (e.g., \"2 minutes ago\", \"1 hour ago\")\n */\nexport function formatRelativeTime(date: string | Date): string {\n const now = new Date();\n const past = new Date(date);\n const diffInMs = now.getTime() - past.getTime();\n const diffInSeconds = Math.floor(diffInMs / 1000);\n const diffInMinutes = Math.floor(diffInSeconds / 60);\n const diffInHours = Math.floor(diffInMinutes / 60);\n const diffInDays = Math.floor(diffInHours / 24);\n\n if (diffInSeconds < 60) {\n return 'just now';\n } else if (diffInMinutes < 60) {\n return `${diffInMinutes} ${diffInMinutes === 1 ? 'minute' : 'minutes'} ago`;\n } else if (diffInHours < 24) {\n return `${diffInHours} ${diffInHours === 1 ? 'hour' : 'hours'} ago`;\n } else if (diffInDays < 7) {\n return `${diffInDays} ${diffInDays === 1 ? 'day' : 'days'} ago`;\n } else {\n return past.toLocaleDateString();\n }\n}\n\n/**\n * Get priority color class name (for use with semantic tokens)\n */\nexport function getPriorityColor(priority: NotificationPriority): string {\n switch (priority) {\n case 'URGENT':\n return 'text-error-500';\n case 'HIGH':\n return 'text-warning-500';\n case 'NORMAL':\n return 'text-info-500';\n case 'LOW':\n return 'text-muted-foreground';\n default:\n return 'text-muted-foreground';\n }\n}\n\n/**\n * Get priority icon/indicator\n */\nexport function getPriorityIcon(priority: NotificationPriority): string {\n switch (priority) {\n case 'URGENT':\n return '🔴';\n case 'HIGH':\n return '🟠';\n case 'NORMAL':\n return '🟢';\n case 'LOW':\n return '⚪';\n default:\n return '⚪';\n }\n}\n\n/**\n * Get notification type label\n */\nexport function getNotificationTypeLabel(type: NotificationType): string {\n switch (type) {\n case 'TRANSACTIONAL':\n return 'Transactional';\n case 'MARKETING':\n return 'Marketing';\n case 'SYSTEM':\n return 'System';\n case 'ALERT':\n return 'Alert';\n default:\n return 'Unknown';\n }\n}\n\n/**\n * Get notification type icon\n */\nexport function getNotificationTypeIcon(type: NotificationType): string {\n switch (type) {\n case 'TRANSACTIONAL':\n return '📧';\n case 'MARKETING':\n return '📢';\n case 'SYSTEM':\n return '⚙️';\n case 'ALERT':\n return '🚨';\n default:\n return '🔔';\n }\n}\n\n/**\n * Filter notifications based on criteria\n */\nexport function filterNotifications(\n notifications: Notification[],\n filter: NotificationFilter\n): Notification[] {\n return notifications.filter((notification) => {\n // Search filter\n if (filter.search) {\n const searchLower = filter.search.toLowerCase();\n const titleMatch = notification.title.toLowerCase().includes(searchLower);\n const bodyMatch = notification.body.toLowerCase().includes(searchLower);\n if (!titleMatch && !bodyMatch) return false;\n }\n\n // Type filter\n if (filter.type !== 'ALL' && notification.type !== filter.type) {\n return false;\n }\n\n // Status filter\n if (filter.status !== 'ALL' && notification.status !== filter.status) {\n return false;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL' && notification.priority !== filter.priority) {\n return false;\n }\n\n // Read/Unread filter\n if (filter.isRead !== null) {\n const isRead = !!notification.readAt;\n if (filter.isRead !== isRead) return false;\n }\n\n // Date range filter\n if (filter.dateRange.start || filter.dateRange.end) {\n const notificationDate = new Date(notification.createdAt);\n if (filter.dateRange.start && notificationDate < filter.dateRange.start) {\n return false;\n }\n if (filter.dateRange.end && notificationDate > filter.dateRange.end) {\n return false;\n }\n }\n\n return true;\n });\n}\n\n/**\n * Sort notifications by created date (newest first)\n */\nexport function sortNotificationsByDate(notifications: Notification[]): Notification[] {\n return [...notifications].sort((a, b) => {\n return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();\n });\n}\n\n/**\n * Group notifications by date (Today, Yesterday, This Week, etc.)\n */\nexport function groupNotificationsByDate(\n notifications: Notification[]\n): Record<string, Notification[]> {\n const now = new Date();\n const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n const yesterday = new Date(today);\n yesterday.setDate(yesterday.getDate() - 1);\n const thisWeekStart = new Date(today);\n thisWeekStart.setDate(thisWeekStart.getDate() - thisWeekStart.getDay());\n\n const groups: Record<string, Notification[]> = {\n Today: [],\n Yesterday: [],\n 'This Week': [],\n Earlier: [],\n };\n\n notifications.forEach((notification) => {\n const notificationDate = new Date(notification.createdAt);\n const notificationDay = new Date(\n notificationDate.getFullYear(),\n notificationDate.getMonth(),\n notificationDate.getDate()\n );\n\n if (notificationDay.getTime() === today.getTime()) {\n groups.Today.push(notification);\n } else if (notificationDay.getTime() === yesterday.getTime()) {\n groups.Yesterday.push(notification);\n } else if (notificationDay >= thisWeekStart) {\n groups['This Week'].push(notification);\n } else {\n groups.Earlier.push(notification);\n }\n });\n\n // Remove empty groups\n Object.keys(groups).forEach((key) => {\n if (groups[key].length === 0) {\n delete groups[key];\n }\n });\n\n return groups;\n}\n\n/**\n * Truncate text to a maximum length\n */\nexport function truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return text.slice(0, maxLength) + '...';\n}\n\n/**\n * Validate template variable substitution\n */\nexport function validateTemplateVariables(\n template: string,\n variables: Record<string, unknown>\n): { isValid: boolean; missingVariables: string[] } {\n const variableRegex = /\\{\\{([^}]+)\\}\\}/g;\n const matches = template.matchAll(variableRegex);\n const missingVariables: string[] = [];\n\n for (const match of matches) {\n const variableName = match[1].trim();\n if (!(variableName in variables)) {\n missingVariables.push(variableName);\n }\n }\n\n return {\n isValid: missingVariables.length === 0,\n missingVariables,\n };\n}\n\n/**\n * Substitute template variables\n */\nexport function substituteTemplateVariables(\n template: string,\n variables: Record<string, unknown>\n): string {\n return template.replace(/\\{\\{([^}]+)\\}\\}/g, (match, variableName) => {\n const trimmedName = variableName.trim();\n const value = variables[trimmedName];\n return value !== undefined ? String(value) : match;\n });\n}\n\n/**\n * Get delivery status color\n */\nexport function getDeliveryStatusColor(\n status: 'PENDING' | 'SENT' | 'DELIVERED' | 'FAILED' | 'ARCHIVED'\n): string {\n switch (status) {\n case 'DELIVERED':\n return 'text-success-500';\n case 'SENT':\n return 'text-info-500';\n case 'PENDING':\n return 'text-warning-500';\n case 'FAILED':\n return 'text-error-500';\n case 'ARCHIVED':\n return 'text-muted-foreground';\n default:\n return 'text-muted-foreground';\n }\n}\n\n/**\n * Calculate delivery rate percentage\n */\nexport function calculateDeliveryRate(delivered: number, total: number): number {\n if (total === 0) return 0;\n return Math.round((delivered / total) * 100);\n}\n\n/**\n * Check whether a mutation error represents a gateway-level authorization\n * failure (the RBAC gateway rejected the request because the actor lacks\n * the required permission). Callers surface these with a friendly toast and\n * refresh the permission cache to recover from stale client state.\n *\n * 401/UNAUTHENTICATED is handled separately by the shell's auth flow — this\n * helper intentionally ignores it.\n */\nexport function isPermissionError(err: unknown): boolean {\n if (!err) return false;\n\n type GqlErrorLike = { extensions?: Record<string, unknown> };\n\n const hasForbiddenCode = (errors: readonly GqlErrorLike[]): boolean => {\n for (const gqlErr of errors) {\n const code = typeof gqlErr.extensions?.code === 'string' ? gqlErr.extensions.code : '';\n const errorCode =\n typeof gqlErr.extensions?.errorCode === 'string' ? gqlErr.extensions.errorCode : '';\n if (code === 'FORBIDDEN' || errorCode === 'FORBIDDEN') return true;\n }\n return false;\n };\n\n // Apollo v3 shape: `err.graphQLErrors[]`. Apollo v4 (what `global-client.ts` targets): `err.errors[]`.\n // Check both so the structured signal works regardless of which Apollo major we're on.\n const v3 = (err as { graphQLErrors?: GqlErrorLike[] }).graphQLErrors;\n if (Array.isArray(v3) && hasForbiddenCode(v3)) return true;\n const v4 = (err as { errors?: GqlErrorLike[] }).errors;\n if (Array.isArray(v4) && hasForbiddenCode(v4)) return true;\n\n // Non-Apollo shapes (fetch-wrapped errors, custom throws) may hang extensions off the error itself.\n const extensionsLike = (err as { extensions?: Record<string, unknown> }).extensions;\n const codeFromExtensions = typeof extensionsLike?.code === 'string' ? extensionsLike.code : '';\n const errorCodeFromExtensions =\n typeof extensionsLike?.errorCode === 'string' ? extensionsLike.errorCode : '';\n if (codeFromExtensions === 'FORBIDDEN' || errorCodeFromExtensions === 'FORBIDDEN') return true;\n\n // Last-resort message substring match. Gated on the absence of any structured error payload so\n // a notification title / template body containing \"forbidden\" doesn't trigger a false positive.\n if (extensionsLike || Array.isArray(v3) || Array.isArray(v4)) return false;\n const messageFromError = (err as { message?: unknown }).message;\n const message = typeof messageFromError === 'string' ? messageFromError.toLowerCase() : '';\n return message.includes('forbidden') || message.includes('permission denied');\n}\n"],"mappings":";AAUA,SAAgB,EAAmB,GAA6B;CAC9D,IAAM,oBAAM,IAAI,MAAM,EAChB,IAAO,IAAI,KAAK,EAAK,EACrB,IAAW,EAAI,SAAS,GAAG,EAAK,SAAS,EACzC,IAAgB,KAAK,MAAM,IAAW,IAAK,EAC3C,IAAgB,KAAK,MAAM,IAAgB,GAAG,EAC9C,IAAc,KAAK,MAAM,IAAgB,GAAG,EAC5C,IAAa,KAAK,MAAM,IAAc,GAAG;AAW7C,QATE,IAAgB,KACX,aACE,IAAgB,KAClB,GAAG,EAAc,GAAG,MAAkB,IAAI,WAAW,UAAU,QAC7D,IAAc,KAChB,GAAG,EAAY,GAAG,MAAgB,IAAI,SAAS,QAAQ,QACrD,IAAa,IACf,GAAG,EAAW,GAAG,MAAe,IAAI,QAAQ,OAAO,QAEnD,EAAK,oBAAoB;;AAOpC,SAAgB,EAAiB,GAAwC;AACvE,SAAQ,GAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,QACE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ification {
2
+ id: string;
3
+ title: string;
4
+ body: string;
5
+ type: string;
6
+ priority: string;
7
+ status: string;
8
+ createdAt: string;
9
+ readAt?: string;
10
+ archivedAt?: string;
11
+ }
12
+ export declare function exportNotificationsAsCsv(tr: (key: string, fallback: string) => string, notifications: ExportableNotification[]): void;
13
+ //# sourceMappingURL=notificationHistoryExport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationHistoryExport.d.ts","sourceRoot":"","sources":["../../src/utils/notificationHistoryExport.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,EAC7C,aAAa,EAAE,sBAAsB,EAAE,QAqCxC"}
@@ -0,0 +1,29 @@
1
+ //#region src/utils/notificationHistoryExport.ts
2
+ function e(e, t) {
3
+ let n = [
4
+ e("notifications.csv.id", "ID"),
5
+ e("notifications.csv.title", "Title"),
6
+ e("notifications.csv.body", "Body"),
7
+ e("notifications.csv.type", "Type"),
8
+ e("notifications.csv.priority", "Priority"),
9
+ e("notifications.csv.status", "Status"),
10
+ e("notifications.csv.createdAt", "Created At"),
11
+ e("notifications.csv.readAt", "Read At"),
12
+ e("notifications.csv.archivedAt", "Archived At")
13
+ ], r = (e) => `"${(e ?? "").replace(/"/g, "\"\"")}"`, i = t.map((e) => [
14
+ e.id,
15
+ e.title,
16
+ e.body,
17
+ e.type,
18
+ e.priority,
19
+ e.status,
20
+ e.createdAt,
21
+ e.readAt ?? "",
22
+ e.archivedAt ?? ""
23
+ ].map(r).join(",")), a = [n.map(r).join(","), ...i].join("\n"), o = new Blob([a], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(o), c = document.createElement("a");
24
+ c.href = s, c.download = `notifications-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`, c.click(), URL.revokeObjectURL(s);
25
+ }
26
+ //#endregion
27
+ export { e as exportNotificationsAsCsv };
28
+
29
+ //# sourceMappingURL=notificationHistoryExport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationHistoryExport.js","names":[],"sources":["../../src/utils/notificationHistoryExport.ts"],"sourcesContent":["export interface ExportableNotification {\n id: string;\n title: string;\n body: string;\n type: string;\n priority: string;\n status: string;\n createdAt: string;\n readAt?: string;\n archivedAt?: string;\n}\n\nexport function exportNotificationsAsCsv(\n tr: (key: string, fallback: string) => string,\n notifications: ExportableNotification[]\n) {\n const headers = [\n tr('notifications.csv.id', 'ID'),\n tr('notifications.csv.title', 'Title'),\n tr('notifications.csv.body', 'Body'),\n tr('notifications.csv.type', 'Type'),\n tr('notifications.csv.priority', 'Priority'),\n tr('notifications.csv.status', 'Status'),\n tr('notifications.csv.createdAt', 'Created At'),\n tr('notifications.csv.readAt', 'Read At'),\n tr('notifications.csv.archivedAt', 'Archived At'),\n ];\n const escape = (v: string) => `\"${(v ?? '').replace(/\"/g, '\"\"')}\"`;\n const rows = notifications.map((n) =>\n [\n n.id,\n n.title,\n n.body,\n n.type,\n n.priority,\n n.status,\n n.createdAt,\n n.readAt ?? '',\n n.archivedAt ?? '',\n ]\n .map(escape)\n .join(',')\n );\n const csv = [headers.map(escape).join(','), ...rows].join('\\n');\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = `notifications-${new Date().toISOString().slice(0, 10)}.csv`;\n a.click();\n URL.revokeObjectURL(url);\n}\n"],"mappings":";AAYA,SAAgB,EACd,GACA,GACA;CACA,IAAM,IAAU;EACd,EAAG,wBAAwB,KAAK;EAChC,EAAG,2BAA2B,QAAQ;EACtC,EAAG,0BAA0B,OAAO;EACpC,EAAG,0BAA0B,OAAO;EACpC,EAAG,8BAA8B,WAAW;EAC5C,EAAG,4BAA4B,SAAS;EACxC,EAAG,+BAA+B,aAAa;EAC/C,EAAG,4BAA4B,UAAU;EACzC,EAAG,gCAAgC,cAAc;EAClD,EACK,KAAU,MAAc,KAAK,KAAK,IAAI,QAAQ,MAAM,OAAK,CAAC,IAC1D,IAAO,EAAc,KAAK,MAC9B;EACE,EAAE;EACF,EAAE;EACF,EAAE;EACF,EAAE;EACF,EAAE;EACF,EAAE;EACF,EAAE;EACF,EAAE,UAAU;EACZ,EAAE,cAAc;EACjB,CACE,IAAI,EAAO,CACX,KAAK,IAAI,CACb,EACK,IAAM,CAAC,EAAQ,IAAI,EAAO,CAAC,KAAK,IAAI,EAAE,GAAG,EAAK,CAAC,KAAK,KAAK,EACzD,IAAO,IAAI,KAAK,CAAC,EAAI,EAAE,EAAE,MAAM,2BAA2B,CAAC,EAC3D,IAAM,IAAI,gBAAgB,EAAK,EAC/B,IAAI,SAAS,cAAc,IAAI;AAIrC,CAHA,EAAE,OAAO,GACT,EAAE,WAAW,kCAAiB,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC,OACpE,EAAE,OAAO,EACT,IAAI,gBAAgB,EAAI"}
package/package.json ADDED
@@ -0,0 +1,115 @@
1
+ {
2
+ "name": "@burdenoff/microfe-notification",
3
+ "version": "2026.424.101",
4
+ "description": "Notification microfrontend for multi-channel notification management",
5
+ "type": "module",
6
+ "imports": {
7
+ "#src/*": "./src/*",
8
+ "#notification/*": "./src/notification/*"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "package.json",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "dev": "vite --port 5150",
25
+ "build": "tsc && vite build",
26
+ "preview": "vite preview",
27
+ "schema:pull": "graphql-codegen --project schema-wspace && graphql-codegen --project schema-global",
28
+ "codegen": "graphql-codegen --project wspace && graphql-codegen --project global",
29
+ "codegen:all": "bun run schema:pull && bun run codegen",
30
+ "lint": "eslint src/",
31
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
32
+ "type:check": "tsc --noEmit",
33
+ "sanity": "bun run codegen && bun run lint && bun run format && bun run type:check",
34
+ "switch:status": "bun scripts/deps-mode.ts status",
35
+ "switch:remote": "bun scripts/deps-mode.ts remote",
36
+ "switch:local": "bun scripts/deps-mode.ts local",
37
+ "switch:check": "bun scripts/deps-mode.ts check",
38
+ "prepare": "lefthook install || true",
39
+ "format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest",
42
+ "test:coverage": "vitest run --coverage"
43
+ },
44
+ "peerDependencies": {
45
+ "react": ">=18.0.0",
46
+ "react-dom": ">=18.0.0",
47
+ "react-router-dom": ">=6.0.0"
48
+ },
49
+ "dependencies": {
50
+ "@apollo/client": "^4.0.9",
51
+ "@burdenoff/fe-libs": "^2026.420.95",
52
+ "@types/lodash-es": "^4.17.12",
53
+ "graphql": "^16.12.0",
54
+ "lodash-es": "^4.17.23",
55
+ "lucide-react": "^0.468.0",
56
+ "zustand": "^5.0.3"
57
+ },
58
+ "devDependencies": {
59
+ "@eslint/js": "^9.39.1",
60
+ "@graphql-codegen/add": "^5.0.0",
61
+ "@graphql-codegen/cli": "^5.0.0",
62
+ "@graphql-codegen/import-types-preset": "^3.0.0",
63
+ "@graphql-codegen/schema-ast": "^4.0.0",
64
+ "@graphql-codegen/typescript": "^4.0.0",
65
+ "@graphql-codegen/typescript-operations": "^4.0.0",
66
+ "@graphql-codegen/typescript-react-apollo": "^4.0.0",
67
+ "@testing-library/jest-dom": "^6.9.1",
68
+ "@testing-library/react": "^16.3.2",
69
+ "@testing-library/user-event": "^14.6.1",
70
+ "@types/react": "^19.0.2",
71
+ "@types/react-dom": "^19.0.2",
72
+ "@vitejs/plugin-react": "^4.3.4",
73
+ "@vitest/coverage-v8": "^4.1.2",
74
+ "eslint": "^9.18.0",
75
+ "eslint-plugin-react": "^7.37.5",
76
+ "eslint-plugin-react-hooks": "^7.0.1",
77
+ "jsdom": "^29.0.1",
78
+ "lefthook": "^2.1.1",
79
+ "prettier": "^3.4.2",
80
+ "typescript": "^5.9.0",
81
+ "typescript-eslint": "^8.46.0",
82
+ "vite": "8.0.8",
83
+ "vite-plugin-dts": "3.9.1",
84
+ "vitest": "^4.1.2"
85
+ },
86
+ "keywords": [
87
+ "microfrontend",
88
+ "notification",
89
+ "react",
90
+ "burdenoff"
91
+ ],
92
+ "repository": {
93
+ "type": "git",
94
+ "url": "git+https://github.com/burdenoff/microfe-notification.git"
95
+ },
96
+ "author": "Burdenoff",
97
+ "license": "MIT",
98
+ "publishConfig": {
99
+ "access": "restricted"
100
+ },
101
+ "overrides": {
102
+ "dompurify": ">=3.3.4",
103
+ "fast-xml-parser": ">=4.5.5",
104
+ "@xmldom/xmldom": ">=0.8.12",
105
+ "swiper": ">=12.1.2",
106
+ "brace-expansion": ">=1.1.13",
107
+ "follow-redirects": ">=1.15.12",
108
+ "smol-toml": ">=1.6.1",
109
+ "flatted": ">=3.4.1",
110
+ "yaml": ">=2.8.3",
111
+ "picomatch": ">=2.3.2",
112
+ "immutable": ">=3.8.3",
113
+ "minimatch": ">=3.1.3"
114
+ }
115
+ }