@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,19 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+
3
+ /**
4
+ * Default Global Gateway URL
5
+ * Notifications are a GLOBAL service and must use the global gateway
6
+ */
7
+ export declare const DEFAULT_GLOBAL_GATEWAY_URL = "https://gw-global.local.burdenoff.com/global/graphql";
8
+ /**
9
+ * Get or create the singleton Apollo client for global notification operations
10
+ *
11
+ * @param globalGatewayUrl - Global Gateway GraphQL URL (default: https://gw-global.local.burdenoff.com/global/graphql)
12
+ * @param authToken - Optional JWT auth token
13
+ */
14
+ export declare function getGlobalNotificationClient(globalGatewayUrl?: string, authToken?: string): InstanceType<typeof ApolloClient>;
15
+ /**
16
+ * Reset the singleton client (useful for testing or re-initialization)
17
+ */
18
+ export declare function resetGlobalNotificationClient(): void;
19
+ //# sourceMappingURL=global-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-client.d.ts","sourceRoot":"","sources":["../../src/graphql/global-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,gBAAgB,CAAC;AAiC7E;;;GAGG;AACH,eAAO,MAAM,0BAA0B,yDAAyD,CAAC;AAEjG;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,CAAC,EAAE,MAAM,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,YAAY,CAAC,OAAO,YAAY,CAAC,CAgFnC;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAOpD"}
@@ -0,0 +1,57 @@
1
+ import { ApolloClient as e, HttpLink as t, InMemoryCache as n, from as r } from "@apollo/client";
2
+ import { setContext as i } from "@apollo/client/link/context";
3
+ import { onError as a } from "@apollo/client/link/error";
4
+ import { isAuthNetworkError as o, redirectToLogin as s } from "@burdenoff/fe-libs/shared/utils";
5
+ //#region src/graphql/global-client.ts
6
+ function c(e = []) {
7
+ return e.some((e) => {
8
+ let t = typeof e.extensions?.code == "string" ? e.extensions.code : "", n = typeof e.extensions?.errorCode == "string" ? e.extensions.errorCode : "", r = (e.message ?? "").toLowerCase();
9
+ return t === "UNAUTHENTICATED" || n === "TOKEN_EXPIRED" || r.includes("token_expired") || r.includes("token expired") || r.includes("session expired") || r.includes("unauthorized") || r.includes("unauthenticated") || r.includes("authentication required") || r.includes("workspace context missing");
10
+ });
11
+ }
12
+ var l = null, u = null, d = null;
13
+ function f(f, p) {
14
+ let m = f || "https://gw-global.local.burdenoff.com/global/graphql";
15
+ if (l && u === m && d === p) return l;
16
+ u = m, d = p ?? null;
17
+ let h = new t({ uri: m }), g = i((e, t) => ({ headers: {
18
+ ...t.headers,
19
+ authorization: p ? `Bearer ${p}` : ""
20
+ } }));
21
+ return l = new e({
22
+ link: r([
23
+ a(({ error: e }) => {
24
+ if (e) {
25
+ if (c("errors" in e && Array.isArray(e.errors) ? e.errors : [])) {
26
+ s();
27
+ return;
28
+ }
29
+ e instanceof Error && o(e) && s();
30
+ }
31
+ }),
32
+ g,
33
+ h
34
+ ]),
35
+ cache: new n({ typePolicies: {
36
+ Query: { fields: {
37
+ notifications: { merge(e, t) {
38
+ return t;
39
+ } },
40
+ notificationTemplates: { merge(e, t) {
41
+ return t;
42
+ } }
43
+ } },
44
+ Notification: { keyFields: ["id"] },
45
+ NotificationTemplate: { keyFields: ["id"] }
46
+ } }),
47
+ defaultOptions: {
48
+ watchQuery: { fetchPolicy: "cache-and-network" },
49
+ query: { fetchPolicy: "network-only" },
50
+ mutate: { fetchPolicy: "network-only" }
51
+ }
52
+ }), l;
53
+ }
54
+ //#endregion
55
+ export { f as getGlobalNotificationClient };
56
+
57
+ //# sourceMappingURL=global-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-client.js","names":[],"sources":["../../src/graphql/global-client.ts"],"sourcesContent":["import { ApolloClient, InMemoryCache, HttpLink, from } from '@apollo/client';\nimport { setContext } from '@apollo/client/link/context';\nimport { onError } from '@apollo/client/link/error';\nimport { isAuthNetworkError, redirectToLogin } from '@burdenoff/fe-libs/shared/utils';\n\nfunction hasSessionAuthErrors(\n errors: ReadonlyArray<{ message?: string; extensions?: Record<string, unknown> }> = []\n): boolean {\n return errors.some((error) => {\n const code = typeof error.extensions?.code === 'string' ? error.extensions.code : '';\n const errorCode =\n typeof error.extensions?.errorCode === 'string' ? error.extensions.errorCode : '';\n const message = (error.message ?? '').toLowerCase();\n\n return (\n code === 'UNAUTHENTICATED' ||\n errorCode === 'TOKEN_EXPIRED' ||\n message.includes('token_expired') ||\n message.includes('token expired') ||\n message.includes('session expired') ||\n message.includes('unauthorized') ||\n message.includes('unauthenticated') ||\n message.includes('authentication required') ||\n message.includes('workspace context missing')\n );\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalClientInstance: InstanceType<typeof ApolloClient> | null = null;\nlet currentGlobalUrl: string | null = null;\nlet currentAuthToken: string | null = null;\n\n/**\n * Default Global Gateway URL\n * Notifications are a GLOBAL service and must use the global gateway\n */\nexport const DEFAULT_GLOBAL_GATEWAY_URL = 'https://gw-global.local.burdenoff.com/global/graphql';\n\n/**\n * Get or create the singleton Apollo client for global notification operations\n *\n * @param globalGatewayUrl - Global Gateway GraphQL URL (default: https://gw-global.local.burdenoff.com/global/graphql)\n * @param authToken - Optional JWT auth token\n */\nexport function getGlobalNotificationClient(\n globalGatewayUrl?: string,\n authToken?: string\n): InstanceType<typeof ApolloClient> {\n const url = globalGatewayUrl || DEFAULT_GLOBAL_GATEWAY_URL;\n\n // Return existing instance if config hasn't changed\n if (globalClientInstance && currentGlobalUrl === url && currentAuthToken === authToken) {\n return globalClientInstance;\n }\n\n // Update current config\n currentGlobalUrl = url;\n currentAuthToken = authToken ?? null;\n\n const httpLink = new HttpLink({\n uri: url,\n });\n\n const authLink = setContext((_, prevContext) => {\n return {\n headers: {\n ...(prevContext.headers as Record<string, string>),\n authorization: authToken ? `Bearer ${authToken}` : '',\n },\n };\n });\n\n const errorLink = onError(({ error }) => {\n if (!error) return;\n\n const graphQLErrors = 'errors' in error && Array.isArray(error.errors) ? error.errors : [];\n\n if (hasSessionAuthErrors(graphQLErrors)) {\n redirectToLogin();\n return;\n }\n\n if (error instanceof Error && isAuthNetworkError(error)) {\n redirectToLogin();\n }\n });\n\n globalClientInstance = new ApolloClient({\n link: from([errorLink, authLink, httpLink]),\n cache: new InMemoryCache({\n typePolicies: {\n Query: {\n fields: {\n notifications: {\n merge(_existing: unknown, incoming: unknown) {\n return incoming;\n },\n },\n notificationTemplates: {\n merge(_existing: unknown, incoming: unknown) {\n return incoming;\n },\n },\n },\n },\n Notification: {\n keyFields: ['id'],\n },\n NotificationTemplate: {\n keyFields: ['id'],\n },\n },\n }),\n defaultOptions: {\n watchQuery: {\n fetchPolicy: 'cache-and-network',\n },\n query: {\n fetchPolicy: 'network-only',\n },\n mutate: {\n fetchPolicy: 'network-only',\n },\n },\n });\n\n return globalClientInstance;\n}\n\n/**\n * Reset the singleton client (useful for testing or re-initialization)\n */\nexport function resetGlobalNotificationClient(): void {\n if (globalClientInstance) {\n globalClientInstance.clear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N,eAAe,EACb,MAAM,GAAoB,GAAmB;AAC3C,YAAO;OAEV;IACD,uBAAuB,EACrB,MAAM,GAAoB,GAAmB;AAC3C,YAAO;OAEV;IACF,EACF;GACD,cAAc,EACZ,WAAW,CAAC,KAAK,EAClB;GACD,sBAAsB,EACpB,WAAW,CAAC,KAAK,EAClB;GACF,EACF,CAAC;EACF,gBAAgB;GACd,YAAY,EACV,aAAa,qBACd;GACD,OAAO,EACL,aAAa,gBACd;GACD,QAAQ,EACN,aAAa,gBACd;GACF;EACF,CAAC,EAEK"}
@@ -0,0 +1,6 @@
1
+ export { useNotifications } from './useNotifications';
2
+ export { useNotificationAdmin } from './useNotificationAdmin';
3
+ export { useNotificationTopics } from './useNotificationTopics';
4
+ export { useNotificationStore } from '../store/notificationStore';
5
+ export { useNotification } from '../providers/NotificationProvider';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import "../providers/NotificationProvider.js";
2
+ import "../store/notificationStore.js";
3
+ import "./useNotifications.js";
4
+ import "./useNotificationAdmin.js";
5
+ import "./useNotificationTopics.js";
@@ -0,0 +1,51 @@
1
+ import { Notification, NotificationAdminFilters } from '../types';
2
+
3
+ export declare function useNotificationAdmin(): {
4
+ filters: NotificationAdminFilters;
5
+ setFilters: import('react').Dispatch<import('react').SetStateAction<NotificationAdminFilters>>;
6
+ notifications: Notification[];
7
+ scheduledNotifications: {
8
+ __typename?: "ScheduledNotification";
9
+ id: string;
10
+ scheduledFor: string;
11
+ status: import('../generated/global-types').ScheduledNotificationStatus;
12
+ timezone?: string | null;
13
+ retryCount: number;
14
+ errorMessage?: string | null;
15
+ createdAt: string;
16
+ notification: {
17
+ __typename?: "Notification";
18
+ id: string;
19
+ title: string;
20
+ message: string;
21
+ type: import('../generated/global-types').NotificationType;
22
+ priority: import('../generated/global-types').NotificationPriority;
23
+ channel: import('../generated/global-types').NotificationChannel;
24
+ userId: string;
25
+ topicId?: string | null;
26
+ };
27
+ }[];
28
+ selectedNotification: Notification | null;
29
+ events: {
30
+ __typename?: "NotificationEvent";
31
+ id: string;
32
+ notificationId: string;
33
+ eventType: import('../generated/global-types').NotificationEventType;
34
+ deliveryStatus?: import('../generated/global-types').NotificationDeliveryStatus | null;
35
+ timestamp: string;
36
+ externalId?: string | null;
37
+ channelServiceEventId?: string | null;
38
+ details?: Record<string, unknown> | null;
39
+ metadata?: Record<string, unknown> | null;
40
+ }[];
41
+ isLoading: boolean;
42
+ error: string | null;
43
+ refetch: () => Promise<void>;
44
+ loadNotification: (notificationId: string) => Promise<void>;
45
+ archiveNotification: (notificationId: string) => Promise<void>;
46
+ unarchiveNotification: (notificationId: string) => Promise<void>;
47
+ cancelScheduledNotification: (scheduledNotificationId: string) => Promise<void>;
48
+ rescheduleNotification: (scheduledNotificationId: string, scheduledFor: string, timezone?: string) => Promise<void>;
49
+ clearSelection: () => void;
50
+ };
51
+ //# sourceMappingURL=useNotificationAdmin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationAdmin.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotificationAdmin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AA8GvE,wBAAgB,oBAAoB;;;;;;;;;;;;;;sBA+Ki5L,CAAC;;;;;;;;mBAA6L,CAAC;;;;;;;;;;;;;;;;;;;uCA9GzlM,MAAM;0CA+BN,MAAM;4CAYN,MAAM;2DAYG,MAAM;sDAYN,MAAM,gBAAgB,MAAM,aAAa,MAAM;;EA0ClF"}
@@ -0,0 +1,203 @@
1
+ import { useNotification as e } from "../providers/NotificationProvider.js";
2
+ import { getGlobalNotificationClient as t } from "../graphql/global-client.js";
3
+ import { ArchiveNotificationDocument as n, CancelScheduledNotificationDocument as r, GetNotificationDocument as i, GetNotificationEventsDocument as a, GetNotificationsDocument as o, GetScheduledNotificationsDocument as s, RescheduleNotificationDocument as c, UnarchiveNotificationDocument as l } from "../generated/global-operations.js";
4
+ import { useCallback as u, useEffect as d, useState as f } from "react";
5
+ //#region src/hooks/useNotificationAdmin.ts
6
+ var p = {
7
+ search: "",
8
+ status: "all",
9
+ channel: "all",
10
+ deliveryStatus: "all",
11
+ type: "all",
12
+ topicId: "",
13
+ archived: "all"
14
+ };
15
+ function m(e) {
16
+ return e === "MEDIUM" ? "NORMAL" : e || "NORMAL";
17
+ }
18
+ function h(e) {
19
+ return e === "CANCELLED" ? "ARCHIVED" : e === "READ" ? "DELIVERED" : e || "PENDING";
20
+ }
21
+ function g(e) {
22
+ return {
23
+ id: e.id,
24
+ title: e.title,
25
+ body: e.message,
26
+ type: e.type,
27
+ priority: m(e.priority),
28
+ status: h(e.status),
29
+ channel: e.channel,
30
+ deliveryStatus: e.deliveryStatus ?? void 0,
31
+ createdAt: e.createdAt,
32
+ updatedAt: e.updatedAt,
33
+ readAt: e.readAt ?? void 0,
34
+ archivedAt: e.archivedAt ?? void 0,
35
+ clickedAt: e.clickedAt ?? void 0,
36
+ openedAt: e.openedAt ?? void 0,
37
+ deliveredAt: e.deliveredAt ?? void 0,
38
+ sentAt: e.sentAt ?? void 0,
39
+ actionUrl: e.redirectUrl ?? void 0,
40
+ actions: (e.actions || []).map((e) => ({
41
+ id: e.id,
42
+ label: e.label,
43
+ url: e.url,
44
+ style: e.style ?? void 0,
45
+ actionType: e.actionType ?? void 0,
46
+ metadata: e.metadata ?? void 0
47
+ })),
48
+ media: (e.media || []).map((e) => ({
49
+ url: e.url,
50
+ label: e.label ?? void 0,
51
+ kind: e.kind ?? void 0,
52
+ contentType: e.contentType ?? void 0,
53
+ thumbnailUrl: e.thumbnailUrl ?? void 0
54
+ })),
55
+ appName: e.appName ?? void 0,
56
+ htmlBody: e.htmlMessage ?? void 0,
57
+ metadata: e.metadata ?? void 0,
58
+ channels: [{
59
+ id: e.id,
60
+ channel: e.channel,
61
+ status: h(e.status),
62
+ sentAt: e.sentAt ?? void 0,
63
+ deliveredAt: e.deliveredAt ?? void 0,
64
+ failedAt: e.failedAt ?? void 0,
65
+ errorCode: e.errorCode ?? void 0,
66
+ errorMessage: e.errorMessage ?? void 0
67
+ }],
68
+ recipientEmail: e.recipientEmail ?? void 0,
69
+ recipientPhone: e.recipientPhone ?? void 0,
70
+ scheduledFor: e.scheduledFor ?? void 0,
71
+ scheduledNotification: e.scheduledNotification ? {
72
+ id: e.scheduledNotification.id,
73
+ scheduledFor: e.scheduledNotification.scheduledFor,
74
+ status: e.scheduledNotification.status,
75
+ timezone: e.scheduledNotification.timezone ?? void 0,
76
+ retryCount: e.scheduledNotification.retryCount ?? void 0,
77
+ errorMessage: e.scheduledNotification.errorMessage ?? void 0
78
+ } : void 0,
79
+ topicId: e.topicId ?? void 0,
80
+ topic: e.topic ? {
81
+ id: e.topic.id,
82
+ name: e.topic.name,
83
+ slug: e.topic.slug,
84
+ type: e.topic.type,
85
+ description: e.topic.description ?? void 0
86
+ } : void 0,
87
+ imageUrl: e.media?.[0]?.url ?? void 0
88
+ };
89
+ }
90
+ function _() {
91
+ let { authToken: m, apiGatewayUrl: h } = e(), [_, v] = f(p), [y, b] = f([]), [x, S] = f([]), [C, w] = f(null), [T, E] = f([]), [D, O] = f(!1), [k, A] = f(null), j = u(() => t(h ?? void 0, m ?? void 0), [h, m]), M = u(async () => {
92
+ O(!0), A(null);
93
+ try {
94
+ b(((await j().query({
95
+ query: o,
96
+ variables: {
97
+ filter: {
98
+ ..._.search ? { search: _.search } : {},
99
+ ..._.status === "all" ? {} : { status: _.status },
100
+ ..._.channel === "all" ? {} : { channel: _.channel },
101
+ ..._.deliveryStatus === "all" ? {} : { deliveryStatus: _.deliveryStatus },
102
+ ..._.type === "all" ? {} : { type: _.type },
103
+ ..._.topicId ? { topicId: _.topicId } : {},
104
+ ..._.archived === "all" ? {} : { archived: _.archived === "archived" }
105
+ },
106
+ limit: 100,
107
+ offset: 0
108
+ },
109
+ fetchPolicy: "network-only"
110
+ })).data?.notifications.items || []).map(g));
111
+ } catch (e) {
112
+ console.error("[useNotificationAdmin] Failed to fetch notifications:", e), A(e instanceof Error ? e.message : "Failed to fetch notifications");
113
+ } finally {
114
+ O(!1);
115
+ }
116
+ }, [_, j]), N = u(async () => {
117
+ try {
118
+ S((await j().query({
119
+ query: s,
120
+ variables: {
121
+ limit: 100,
122
+ offset: 0
123
+ },
124
+ fetchPolicy: "network-only"
125
+ })).data?.scheduledNotifications.items || []);
126
+ } catch (e) {
127
+ console.error("[useNotificationAdmin] Failed to fetch scheduled notifications:", e);
128
+ }
129
+ }, [j]), P = u(async (e) => {
130
+ A(null);
131
+ try {
132
+ let t = j(), [n, r] = await Promise.all([t.query({
133
+ query: i,
134
+ variables: { id: e },
135
+ fetchPolicy: "network-only"
136
+ }), t.query({
137
+ query: a,
138
+ variables: { notificationId: e },
139
+ fetchPolicy: "network-only"
140
+ })]);
141
+ n.data?.notification && w(g(n.data.notification)), E(r.data?.notificationEvents || []);
142
+ } catch (e) {
143
+ console.error("[useNotificationAdmin] Failed to load notification detail:", e), A(e instanceof Error ? e.message : "Failed to load notification detail");
144
+ }
145
+ }, [j]), F = u(async (e) => {
146
+ await j().mutate({
147
+ mutation: n,
148
+ variables: { id: e }
149
+ }), await M();
150
+ }, [M, j]), I = u(async (e) => {
151
+ await j().mutate({
152
+ mutation: l,
153
+ variables: { id: e }
154
+ }), await M();
155
+ }, [M, j]), L = u(async (e) => {
156
+ await j().mutate({
157
+ mutation: r,
158
+ variables: { id: e }
159
+ }), await Promise.all([M(), N()]);
160
+ }, [
161
+ M,
162
+ N,
163
+ j
164
+ ]), R = u(async (e, t, n) => {
165
+ await j().mutate({
166
+ mutation: c,
167
+ variables: { input: {
168
+ scheduledNotificationId: e,
169
+ scheduledFor: t,
170
+ timezone: n
171
+ } }
172
+ }), await Promise.all([M(), N()]);
173
+ }, [
174
+ M,
175
+ N,
176
+ j
177
+ ]);
178
+ return d(() => {
179
+ M(), N();
180
+ }, [M, N]), {
181
+ filters: _,
182
+ setFilters: v,
183
+ notifications: y,
184
+ scheduledNotifications: x,
185
+ selectedNotification: C,
186
+ events: T,
187
+ isLoading: D,
188
+ error: k,
189
+ refetch: M,
190
+ loadNotification: P,
191
+ archiveNotification: F,
192
+ unarchiveNotification: I,
193
+ cancelScheduledNotification: L,
194
+ rescheduleNotification: R,
195
+ clearSelection: () => {
196
+ w(null), E([]);
197
+ }
198
+ };
199
+ }
200
+ //#endregion
201
+ export { _ as useNotificationAdmin };
202
+
203
+ //# sourceMappingURL=useNotificationAdmin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationAdmin.js","names":[],"sources":["../../src/hooks/useNotificationAdmin.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport type { Notification, NotificationAdminFilters } from '../types';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetNotificationQuery,\n GetNotificationEventsQuery,\n GetScheduledNotificationsQuery,\n} from '../generated/global-operations';\n\nconst defaultFilters: NotificationAdminFilters = {\n search: '',\n status: 'all',\n channel: 'all',\n deliveryStatus: 'all',\n type: 'all',\n topicId: '',\n archived: 'all',\n};\n\nfunction mapPriority(priority: string): Notification['priority'] {\n if (priority === 'MEDIUM') return 'NORMAL';\n return (priority as Notification['priority']) || 'NORMAL';\n}\n\nfunction mapStatus(status: string): Notification['status'] {\n if (status === 'CANCELLED') return 'ARCHIVED';\n if (status === 'READ') return 'DELIVERED';\n return (status as Notification['status']) || 'PENDING';\n}\n\nfunction mapNotification(\n notification:\n | GetNotificationsQuery['notifications']['items'][number]\n | NonNullable<GetNotificationQuery['notification']>\n): Notification {\n return {\n id: notification.id,\n title: notification.title,\n body: notification.message,\n type: notification.type as Notification['type'],\n priority: mapPriority(notification.priority),\n status: mapStatus(notification.status),\n channel: notification.channel as Notification['channel'],\n deliveryStatus: notification.deliveryStatus ?? undefined,\n createdAt: notification.createdAt,\n updatedAt: notification.updatedAt,\n readAt: notification.readAt ?? undefined,\n archivedAt: notification.archivedAt ?? undefined,\n clickedAt: notification.clickedAt ?? undefined,\n openedAt: notification.openedAt ?? undefined,\n deliveredAt: notification.deliveredAt ?? undefined,\n sentAt: notification.sentAt ?? undefined,\n actionUrl: notification.redirectUrl ?? undefined,\n actions: (notification.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n media: (notification.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n appName: notification.appName ?? undefined,\n htmlBody: notification.htmlMessage ?? undefined,\n metadata: notification.metadata ?? undefined,\n channels: [\n {\n id: notification.id,\n channel: notification.channel as Notification['channel'],\n status: mapStatus(notification.status),\n sentAt: notification.sentAt ?? undefined,\n deliveredAt: notification.deliveredAt ?? undefined,\n failedAt: notification.failedAt ?? undefined,\n errorCode: notification.errorCode ?? undefined,\n errorMessage: notification.errorMessage ?? undefined,\n },\n ],\n recipientEmail: notification.recipientEmail ?? undefined,\n recipientPhone: notification.recipientPhone ?? undefined,\n scheduledFor: notification.scheduledFor ?? undefined,\n scheduledNotification: notification.scheduledNotification\n ? {\n id: notification.scheduledNotification.id,\n scheduledFor: notification.scheduledNotification.scheduledFor,\n status: notification.scheduledNotification.status,\n timezone: notification.scheduledNotification.timezone ?? undefined,\n retryCount: notification.scheduledNotification.retryCount ?? undefined,\n errorMessage: notification.scheduledNotification.errorMessage ?? undefined,\n }\n : undefined,\n topicId: notification.topicId ?? undefined,\n topic: notification.topic\n ? {\n id: notification.topic.id,\n name: notification.topic.name,\n slug: notification.topic.slug,\n type: notification.topic.type as Notification['type'],\n description: notification.topic.description ?? undefined,\n }\n : undefined,\n imageUrl: notification.media?.[0]?.url ?? undefined,\n };\n}\n\nexport function useNotificationAdmin() {\n const { authToken, apiGatewayUrl } = useNotification();\n const [filters, setFilters] = useState<NotificationAdminFilters>(defaultFilters);\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [scheduledNotifications, setScheduledNotifications] = useState<\n GetScheduledNotificationsQuery['scheduledNotifications']['items']\n >([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [events, setEvents] = useState<GetNotificationEventsQuery['notificationEvents']>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n const fetchNotifications = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: {\n ...(filters.search ? { search: filters.search } : {}),\n ...(filters.status !== 'all' ? { status: filters.status } : {}),\n ...(filters.channel !== 'all' ? { channel: filters.channel } : {}),\n ...(filters.deliveryStatus !== 'all' ? { deliveryStatus: filters.deliveryStatus } : {}),\n ...(filters.type !== 'all' ? { type: filters.type } : {}),\n ...(filters.topicId ? { topicId: filters.topicId } : {}),\n ...(filters.archived !== 'all' ? { archived: filters.archived === 'archived' } : {}),\n },\n limit: 100,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n setNotifications((result.data?.notifications.items || []).map(mapNotification));\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to fetch notifications:', err);\n setError(err instanceof Error ? err.message : 'Failed to fetch notifications');\n } finally {\n setIsLoading(false);\n }\n }, [filters, getClient]);\n\n const fetchScheduledNotifications = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetScheduledNotificationsQuery>({\n query: NotificationOps.GetScheduledNotificationsDocument,\n variables: { limit: 100, offset: 0 },\n fetchPolicy: 'network-only',\n });\n\n setScheduledNotifications(result.data?.scheduledNotifications.items || []);\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to fetch scheduled notifications:', err);\n }\n }, [getClient]);\n\n const loadNotification = useCallback(\n async (notificationId: string) => {\n setError(null);\n\n try {\n const client = getClient();\n const [notificationResult, eventsResult] = await Promise.all([\n client.query<GetNotificationQuery>({\n query: NotificationOps.GetNotificationDocument,\n variables: { id: notificationId },\n fetchPolicy: 'network-only',\n }),\n client.query<GetNotificationEventsQuery>({\n query: NotificationOps.GetNotificationEventsDocument,\n variables: { notificationId },\n fetchPolicy: 'network-only',\n }),\n ]);\n\n if (notificationResult.data?.notification) {\n setSelectedNotification(mapNotification(notificationResult.data.notification));\n }\n setEvents(eventsResult.data?.notificationEvents || []);\n } catch (err) {\n console.error('[useNotificationAdmin] Failed to load notification detail:', err);\n setError(err instanceof Error ? err.message : 'Failed to load notification detail');\n }\n },\n [getClient]\n );\n\n const archiveNotification = useCallback(\n async (notificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n await fetchNotifications();\n },\n [fetchNotifications, getClient]\n );\n\n const unarchiveNotification = useCallback(\n async (notificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n await fetchNotifications();\n },\n [fetchNotifications, getClient]\n );\n\n const cancelScheduledNotification = useCallback(\n async (scheduledNotificationId: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.CancelScheduledNotificationDocument,\n variables: { id: scheduledNotificationId },\n });\n await Promise.all([fetchNotifications(), fetchScheduledNotifications()]);\n },\n [fetchNotifications, fetchScheduledNotifications, getClient]\n );\n\n const rescheduleNotification = useCallback(\n async (scheduledNotificationId: string, scheduledFor: string, timezone?: string) => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.RescheduleNotificationDocument,\n variables: {\n input: {\n scheduledNotificationId,\n scheduledFor,\n timezone,\n },\n },\n });\n await Promise.all([fetchNotifications(), fetchScheduledNotifications()]);\n },\n [fetchNotifications, fetchScheduledNotifications, getClient]\n );\n\n useEffect(() => {\n fetchNotifications();\n fetchScheduledNotifications();\n }, [fetchNotifications, fetchScheduledNotifications]);\n\n return {\n filters,\n setFilters,\n notifications,\n scheduledNotifications,\n selectedNotification,\n events,\n isLoading,\n error,\n refetch: fetchNotifications,\n loadNotification,\n archiveNotification,\n unarchiveNotification,\n cancelScheduledNotification,\n rescheduleNotification,\n clearSelection: () => {\n setSelectedNotification(null);\n setEvents([]);\n },\n };\n}\n"],"mappings":";;;;;AAYA,IAAM,IAA2C;CAC/C,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,gBAAgB;CAChB,MAAM;CACN,SAAS;CACT,UAAU;CACX;AAED,SAAS,EAAY,GAA4C;AAE/D,QADI,MAAa,WAAiB,WAC1B,KAAyC;;AAGnD,SAAS,EAAU,GAAwC;AAGzD,QAFI,MAAW,cAAoB,aAC/B,MAAW,SAAe,cACtB,KAAqC;;AAG/C,SAAS,EACP,GAGc;AACd,QAAO;EACL,IAAI,EAAa;EACjB,OAAO,EAAa;EACpB,MAAM,EAAa;EACnB,MAAM,EAAa;EACnB,UAAU,EAAY,EAAa,SAAS;EAC5C,QAAQ,EAAU,EAAa,OAAO;EACtC,SAAS,EAAa;EACtB,gBAAgB,EAAa,kBAAkB,KAAA;EAC/C,WAAW,EAAa;EACxB,WAAW,EAAa;EACxB,QAAQ,EAAa,UAAU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AAU,CACZ,EAEK,IAAsB,EAC1B,OAAO,MAA2B;AAMhC,EAJA,MADe,GAAW,CACb,OAAO;GAClB,UAAU;GACV,WAAW,EAAE,IAAI,GAAgB;GAClC,CAAC,EACF,MAAM,GAAoB;IAE5B,CAAC,GAAoB,EAAU,CAChC,EAEK,IAAwB,EAC5B,OAAO,MAA2B;AAMhC,EAJA,MADe,GAAW,CACb,OAAO;GAClB,UAAU;GACV,WAAW,EAAE,IAAI,GAAgB;GAClC,CAAC,EACF,MAAM,GAAoB;IAE5B,CAAC,GAAoB,EAAU,CAChC,EAEK,IAA8B,EAClC,OAAO,MAAoC;AAMzC,EAJA,MADe,GAAW,CACb,OAAO;GAClB,UAAU;GACV,WAAW,EAAE,IAAI,GAAyB;GAC3C,CAAC,EACF,MAAM,QAAQ,IAAI,CAAC,GAAoB,EAAE,GAA6B,CAAC,CAAC;IAE1E;EAAC;EAAoB;EAA6B;EAAU,CAC7D,EAEK,IAAyB,EAC7B,OAAO,GAAiC,GAAsB,MAAsB;AAYlF,EAVA,MADe,GAAW,CACb,OAAO;GAClB,UAAU;GACV,WAAW,EACT,OAAO;IACL;IACA;IACA;IACD,EACF;GACF,CAAC,EACF,MAAM,QAAQ,IAAI,CAAC,GAAoB,EAAE,GAA6B,CAAC,CAAC;IAE1E;EAAC;EAAoB;EAA6B;EAAU,CAC7D;AAOD,QALA,QAAgB;AAEd,EADA,GAAoB,EACpB,GAA6B;IAC5B,CAAC,GAAoB,EAA4B,CAAC,EAE9C;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,sBAAsB;AAEpB,GADA,EAAwB,KAAK,EAC7B,EAAU,EAAE,CAAC;;EAEhB"}
@@ -0,0 +1,136 @@
1
+ import { NotificationType } from '../types';
2
+ import { GetNotificationTemplatesQuery } from '../generated/global-operations';
3
+
4
+ /**
5
+ * Backend template type derived from the generated query
6
+ */
7
+ export type BackendNotificationTemplate = GetNotificationTemplatesQuery['notificationTemplates']['items'][number];
8
+ /**
9
+ * Input type for creating a template (matches backend CreateTemplateInput)
10
+ * Note: Templates are content-only - channel is specified at send time
11
+ */
12
+ export interface CreateTemplateInput {
13
+ slug: string;
14
+ name: string;
15
+ description?: string;
16
+ type: NotificationType;
17
+ channel?: string;
18
+ locale?: string;
19
+ subject?: string;
20
+ bodyTemplate: string;
21
+ htmlTemplate?: string;
22
+ variables: Record<string, unknown>;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Input type for updating a template (matches backend UpdateTemplateInput)
27
+ */
28
+ export interface UpdateTemplateInput {
29
+ name?: string;
30
+ description?: string;
31
+ subject?: string;
32
+ bodyTemplate?: string;
33
+ htmlTemplate?: string;
34
+ variables?: Record<string, unknown>;
35
+ enabled?: boolean;
36
+ metadata?: Record<string, unknown>;
37
+ }
38
+ /**
39
+ * Filter options for templates (matches backend TemplateFilterInput)
40
+ * Note: channel filter removed - templates are content-only
41
+ */
42
+ export interface TemplateFilter {
43
+ type?: NotificationType;
44
+ locale?: string;
45
+ enabled?: boolean;
46
+ search?: string;
47
+ }
48
+ /**
49
+ * Hook to manage notification templates
50
+ * Uses the GLOBAL Apollo client for API calls
51
+ */
52
+ export declare function useNotificationTemplates(initialFilter?: TemplateFilter): {
53
+ templates: {
54
+ __typename?: "NotificationTemplate";
55
+ id: string;
56
+ slug: string;
57
+ name: string;
58
+ description?: string | null;
59
+ type: import('../generated/global-types').NotificationType;
60
+ locale: string;
61
+ subject?: string | null;
62
+ bodyTemplate: string;
63
+ htmlTemplate?: string | null;
64
+ variables: Record<string, unknown>;
65
+ enabled: boolean;
66
+ version: number;
67
+ createdAt: string;
68
+ updatedAt: string;
69
+ createdBy: string;
70
+ metadata?: Record<string, unknown> | null;
71
+ }[];
72
+ allTemplates: {
73
+ __typename?: "NotificationTemplate";
74
+ id: string;
75
+ slug: string;
76
+ name: string;
77
+ description?: string | null;
78
+ type: import('../generated/global-types').NotificationType;
79
+ locale: string;
80
+ subject?: string | null;
81
+ bodyTemplate: string;
82
+ htmlTemplate?: string | null;
83
+ variables: Record<string, unknown>;
84
+ enabled: boolean;
85
+ version: number;
86
+ createdAt: string;
87
+ updatedAt: string;
88
+ createdBy: string;
89
+ metadata?: Record<string, unknown> | null;
90
+ }[];
91
+ isLoading: boolean;
92
+ isCreating: boolean;
93
+ isUpdating: boolean;
94
+ isDeleting: boolean;
95
+ isMutating: boolean;
96
+ error: string | null;
97
+ hasMore: boolean;
98
+ total: number;
99
+ filter: TemplateFilter;
100
+ refetch: () => Promise<void>;
101
+ loadMore: () => Promise<void>;
102
+ createTemplate: (input: CreateTemplateInput) => Promise<BackendNotificationTemplate>;
103
+ updateTemplate: (id: string, input: UpdateTemplateInput) => Promise<BackendNotificationTemplate>;
104
+ deleteTemplate: (id: string) => Promise<boolean>;
105
+ updateFilter: (newFilter: Partial<TemplateFilter>) => void;
106
+ resetFilter: () => void;
107
+ };
108
+ /**
109
+ * Hook to fetch a single template by slug
110
+ * Uses the GLOBAL Apollo client for API calls
111
+ */
112
+ export declare function useNotificationTemplate(slug: string | undefined, locale?: string): {
113
+ template: {
114
+ __typename?: "NotificationTemplate";
115
+ id: string;
116
+ slug: string;
117
+ name: string;
118
+ description?: string | null;
119
+ type: import('../generated/global-types').NotificationType;
120
+ locale: string;
121
+ subject?: string | null;
122
+ bodyTemplate: string;
123
+ htmlTemplate?: string | null;
124
+ variables: Record<string, unknown>;
125
+ enabled: boolean;
126
+ version: number;
127
+ createdAt: string;
128
+ updatedAt: string;
129
+ createdBy: string;
130
+ metadata?: Record<string, unknown> | null;
131
+ } | undefined;
132
+ isLoading: boolean;
133
+ error: string | null;
134
+ refetch: () => Promise<void>;
135
+ };
136
+ //# sourceMappingURL=useNotificationTemplates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationTemplates.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotificationTemplates.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gB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