captify 0.1.19 → 1.1.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.
- package/dist/agents/components/agents-list-header.d.ts.map +1 -1
- package/dist/agents/components/agents-list-header.js +3 -2
- package/dist/agents/components/agents-list-header.js.map +1 -1
- package/dist/chat/components/chat-content-approval.d.ts.map +1 -1
- package/dist/chat/components/chat-content-approval.js.map +1 -1
- package/dist/chat/components/chat-context-toggle.d.ts.map +1 -1
- package/dist/chat/components/chat-context-toggle.js +2 -4
- package/dist/chat/components/chat-context-toggle.js.map +1 -1
- package/dist/comments/comments.constants.d.ts +8 -1
- package/dist/comments/comments.constants.d.ts.map +1 -1
- package/dist/comments/comments.constants.js +18 -0
- package/dist/comments/comments.constants.js.map +1 -1
- package/dist/comments/comments.interfaces.d.ts +5 -0
- package/dist/comments/comments.interfaces.d.ts.map +1 -1
- package/dist/comments/comments.utilities.d.ts +30 -1
- package/dist/comments/comments.utilities.d.ts.map +1 -1
- package/dist/comments/comments.utilities.js +41 -1
- package/dist/comments/comments.utilities.js.map +1 -1
- package/dist/comments/hooks/use-comments.d.ts.map +1 -1
- package/dist/comments/hooks/use-comments.js +1 -0
- package/dist/comments/hooks/use-comments.js.map +1 -1
- package/dist/comments/services/comments.factory.d.ts.map +1 -1
- package/dist/comments/services/comments.factory.js +5 -2
- package/dist/comments/services/comments.factory.js.map +1 -1
- package/dist/comments/services/comments.service.d.ts +9 -2
- package/dist/comments/services/comments.service.d.ts.map +1 -1
- package/dist/comments/services/comments.service.js +96 -4
- package/dist/comments/services/comments.service.js.map +1 -1
- package/dist/db/schemas/index.d.ts +6 -4
- package/dist/db/schemas/index.d.ts.map +1 -1
- package/dist/db/schemas/index.js +2 -1
- package/dist/db/schemas/index.js.map +1 -1
- package/dist/db/schemas/notifications.schema.d.ts +107 -0
- package/dist/db/schemas/notifications.schema.d.ts.map +1 -0
- package/dist/db/schemas/notifications.schema.js +124 -0
- package/dist/db/schemas/notifications.schema.js.map +1 -0
- package/dist/feedback/api/feedback.handlers.d.ts.map +1 -1
- package/dist/feedback/api/feedback.handlers.js +1 -0
- package/dist/feedback/api/feedback.handlers.js.map +1 -1
- package/dist/feedback/components/feedback-editor.d.ts.map +1 -1
- package/dist/feedback/components/feedback-editor.js +6 -4
- package/dist/feedback/components/feedback-editor.js.map +1 -1
- package/dist/feedback/feedback.interfaces.d.ts +24 -1
- package/dist/feedback/feedback.interfaces.d.ts.map +1 -1
- package/dist/feedback/services/feedback.service.d.ts +26 -3
- package/dist/feedback/services/feedback.service.d.ts.map +1 -1
- package/dist/feedback/services/feedback.service.js +270 -11
- package/dist/feedback/services/feedback.service.js.map +1 -1
- package/dist/files/components/folder-browser/folder-breadcrumb.d.ts.map +1 -1
- package/dist/files/components/folder-browser/folder-breadcrumb.js +1 -1
- package/dist/files/components/folder-browser/folder-breadcrumb.js.map +1 -1
- package/dist/files/components/folder-browser/folder-list-item.js +1 -1
- package/dist/files/components/folder-browser/folder-list-item.js.map +1 -1
- package/dist/files/components/folder-browser/folder-tree-item.d.ts.map +1 -1
- package/dist/files/components/folder-browser/folder-tree-item.js +1 -1
- package/dist/files/components/folder-browser/folder-tree-item.js.map +1 -1
- package/dist/files/components/folder-browser/folder-tree-sidebar.js +1 -1
- package/dist/files/components/folder-browser/folder-tree-sidebar.js.map +1 -1
- package/dist/notifications/api/index.d.ts +7 -0
- package/dist/notifications/api/index.d.ts.map +1 -0
- package/dist/notifications/api/index.js +8 -0
- package/dist/notifications/api/index.js.map +1 -0
- package/dist/notifications/api/notifications.client.d.ts +86 -0
- package/dist/notifications/api/notifications.client.d.ts.map +1 -0
- package/dist/notifications/api/notifications.client.js +102 -0
- package/dist/notifications/api/notifications.client.js.map +1 -0
- package/dist/notifications/api/notifications.handlers.d.ts +166 -0
- package/dist/notifications/api/notifications.handlers.d.ts.map +1 -0
- package/dist/notifications/api/notifications.handlers.js +187 -0
- package/dist/notifications/api/notifications.handlers.js.map +1 -0
- package/dist/notifications/hooks/index.d.ts +5 -0
- package/dist/notifications/hooks/index.d.ts.map +1 -0
- package/dist/notifications/hooks/index.js +5 -0
- package/dist/notifications/hooks/index.js.map +1 -0
- package/dist/notifications/hooks/use-notifications-api.d.ts +111 -0
- package/dist/notifications/hooks/use-notifications-api.d.ts.map +1 -0
- package/dist/notifications/hooks/use-notifications-api.js +253 -0
- package/dist/notifications/hooks/use-notifications-api.js.map +1 -0
- package/dist/notifications/index.d.ts +16 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +18 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notification.utilities.d.ts +12 -0
- package/dist/notifications/notification.utilities.d.ts.map +1 -0
- package/dist/notifications/notification.utilities.js +35 -0
- package/dist/notifications/notification.utilities.js.map +1 -0
- package/dist/notifications/notifications.constants.d.ts +72 -0
- package/dist/notifications/notifications.constants.d.ts.map +1 -0
- package/dist/notifications/notifications.constants.js +104 -0
- package/dist/notifications/notifications.constants.js.map +1 -0
- package/dist/notifications/notifications.errors.d.ts +35 -0
- package/dist/notifications/notifications.errors.d.ts.map +1 -0
- package/dist/notifications/notifications.errors.js +51 -0
- package/dist/notifications/notifications.errors.js.map +1 -0
- package/dist/notifications/notifications.interfaces.d.ts +116 -0
- package/dist/notifications/notifications.interfaces.d.ts.map +1 -0
- package/dist/notifications/notifications.interfaces.js +10 -0
- package/dist/notifications/notifications.interfaces.js.map +1 -0
- package/dist/notifications/notifications.schemas.d.ts +139 -0
- package/dist/notifications/notifications.schemas.d.ts.map +1 -0
- package/dist/notifications/notifications.schemas.js +167 -0
- package/dist/notifications/notifications.schemas.js.map +1 -0
- package/dist/notifications/services/index.d.ts +6 -0
- package/dist/notifications/services/index.d.ts.map +1 -0
- package/dist/notifications/services/index.js +6 -0
- package/dist/notifications/services/index.js.map +1 -0
- package/dist/notifications/services/notifications.factory.d.ts +19 -0
- package/dist/notifications/services/notifications.factory.d.ts.map +1 -0
- package/dist/notifications/services/notifications.factory.js +58 -0
- package/dist/notifications/services/notifications.factory.js.map +1 -0
- package/dist/notifications/services/notifications.service.d.ts +88 -0
- package/dist/notifications/services/notifications.service.d.ts.map +1 -0
- package/dist/notifications/services/notifications.service.js +620 -0
- package/dist/notifications/services/notifications.service.js.map +1 -0
- package/dist/permissions/api/permissions.handlers.d.ts +20 -20
- package/dist/permissions/components/resource-panel.d.ts.map +1 -1
- package/dist/permissions/components/resource-panel.js +2 -1
- package/dist/permissions/components/resource-panel.js.map +1 -1
- package/dist/permissions/hooks/index.d.ts +1 -0
- package/dist/permissions/hooks/index.d.ts.map +1 -1
- package/dist/permissions/hooks/index.js +1 -0
- package/dist/permissions/hooks/index.js.map +1 -1
- package/dist/permissions/hooks/use-notification-permissions.d.ts +19 -0
- package/dist/permissions/hooks/use-notification-permissions.d.ts.map +1 -0
- package/dist/permissions/hooks/use-notification-permissions.js +32 -0
- package/dist/permissions/hooks/use-notification-permissions.js.map +1 -0
- package/dist/permissions/hooks/use-permissions-dashboard.d.ts +6 -6
- package/dist/permissions/hooks/use-policies.d.ts +2 -2
- package/dist/permissions/permissions.constants.d.ts +5 -0
- package/dist/permissions/permissions.constants.d.ts.map +1 -1
- package/dist/permissions/permissions.constants.js +35 -0
- package/dist/permissions/permissions.constants.js.map +1 -1
- package/dist/permissions/permissions.interfaces.d.ts +12 -0
- package/dist/permissions/permissions.interfaces.d.ts.map +1 -1
- package/dist/permissions/permissions.schemas.d.ts +56 -21
- package/dist/permissions/permissions.schemas.d.ts.map +1 -1
- package/dist/permissions/permissions.schemas.js +6 -1
- package/dist/permissions/permissions.schemas.js.map +1 -1
- package/dist/search/components/global-search-bar.d.ts.map +1 -1
- package/dist/search/components/global-search-bar.js +10 -11
- package/dist/search/components/global-search-bar.js.map +1 -1
- package/dist/shared/components/skeleton/console-layout-skeleton.d.ts +9 -21
- package/dist/shared/components/skeleton/console-layout-skeleton.d.ts.map +1 -1
- package/dist/shared/components/skeleton/console-layout-skeleton.js +13 -29
- package/dist/shared/components/skeleton/console-layout-skeleton.js.map +1 -1
- package/dist/shared/components/ui/sidebar.js +9 -9
- package/dist/shared/components/ui/sidebar.js.map +1 -1
- package/dist/shared/shared.constants.d.ts +1 -0
- package/dist/shared/shared.constants.d.ts.map +1 -1
- package/dist/shared/shared.constants.js +1 -0
- package/dist/shared/shared.constants.js.map +1 -1
- package/dist/shared/shared.interfaces.d.ts +0 -1
- package/dist/shared/shared.interfaces.d.ts.map +1 -1
- package/dist/shell/components/ConsoleLayout.d.ts +1 -1
- package/dist/shell/components/ConsoleLayout.d.ts.map +1 -1
- package/dist/shell/components/ConsoleLayout.js +6 -3
- package/dist/shell/components/ConsoleLayout.js.map +1 -1
- package/dist/shell/components/app-launcher/app-launcher-search-bar.js +1 -1
- package/dist/shell/components/app-launcher/app-launcher-search-bar.js.map +1 -1
- package/dist/shell/components/app-launcher/app-launcher.d.ts.map +1 -1
- package/dist/shell/components/app-launcher/app-launcher.js +2 -1
- package/dist/shell/components/app-launcher/app-launcher.js.map +1 -1
- package/dist/shell/components/app-launcher/category-navigation.d.ts.map +1 -1
- package/dist/shell/components/app-launcher/category-navigation.js +9 -2
- package/dist/shell/components/app-launcher/category-navigation.js.map +1 -1
- package/dist/shell/components/app-launcher/left-sidebar.d.ts +1 -1
- package/dist/shell/components/app-launcher/left-sidebar.d.ts.map +1 -1
- package/dist/shell/components/app-launcher/left-sidebar.js +3 -4
- package/dist/shell/components/app-launcher/left-sidebar.js.map +1 -1
- package/dist/shell/components/app-launcher/service-item.d.ts.map +1 -1
- package/dist/shell/components/app-launcher/service-item.js +2 -2
- package/dist/shell/components/app-launcher/service-item.js.map +1 -1
- package/dist/shell/components/index.d.ts +1 -0
- package/dist/shell/components/index.d.ts.map +1 -1
- package/dist/shell/components/index.js +2 -0
- package/dist/shell/components/index.js.map +1 -1
- package/dist/shell/components/layouts/app-sidebar.d.ts +4 -1
- package/dist/shell/components/layouts/app-sidebar.d.ts.map +1 -1
- package/dist/shell/components/layouts/app-sidebar.js +39 -6
- package/dist/shell/components/layouts/app-sidebar.js.map +1 -1
- package/dist/shell/components/layouts/content-header.d.ts.map +1 -1
- package/dist/shell/components/layouts/content-header.js +5 -24
- package/dist/shell/components/layouts/content-header.js.map +1 -1
- package/dist/shell/components/layouts/index.d.ts +1 -3
- package/dist/shell/components/layouts/index.d.ts.map +1 -1
- package/dist/shell/components/layouts/index.js +1 -3
- package/dist/shell/components/layouts/index.js.map +1 -1
- package/dist/shell/components/layouts/sidebar-nested-item.d.ts.map +1 -1
- package/dist/shell/components/layouts/sidebar-nested-item.js +12 -5
- package/dist/shell/components/layouts/sidebar-nested-item.js.map +1 -1
- package/dist/shell/components/notifications/notification-container.d.ts +16 -2
- package/dist/shell/components/notifications/notification-container.d.ts.map +1 -1
- package/dist/shell/components/notifications/notification-container.js +75 -4
- package/dist/shell/components/notifications/notification-container.js.map +1 -1
- package/dist/shell/components/notifications/notification-item.d.ts +1 -1
- package/dist/shell/components/notifications/notification-item.d.ts.map +1 -1
- package/dist/shell/components/notifications/notification-item.js +26 -7
- package/dist/shell/components/notifications/notification-item.js.map +1 -1
- package/dist/shell/components/notifications/notification-panel-header.d.ts.map +1 -1
- package/dist/shell/components/notifications/notification-panel-header.js +4 -1
- package/dist/shell/components/notifications/notification-panel-header.js.map +1 -1
- package/dist/shell/components/notifications/notifications.d.ts +1 -1
- package/dist/shell/components/notifications/notifications.d.ts.map +1 -1
- package/dist/shell/components/notifications/notifications.js +2 -2
- package/dist/shell/components/notifications/notifications.js.map +1 -1
- package/dist/shell/components/toolbars/index.d.ts +1 -4
- package/dist/shell/components/toolbars/index.d.ts.map +1 -1
- package/dist/shell/components/toolbars/index.js +2 -5
- package/dist/shell/components/toolbars/index.js.map +1 -1
- package/dist/shell/components/toolbars/top-right-toolbar.d.ts +1 -1
- package/dist/shell/components/toolbars/top-right-toolbar.d.ts.map +1 -1
- package/dist/shell/components/toolbars/top-right-toolbar.js +2 -2
- package/dist/shell/components/toolbars/top-right-toolbar.js.map +1 -1
- package/dist/shell/components/toolbars/top-toolbar-feedback.js +1 -1
- package/dist/shell/components/toolbars/top-toolbar-feedback.js.map +1 -1
- package/dist/shell/shell.constants.d.ts +1 -1
- package/dist/shell/shell.constants.js +1 -1
- package/dist/shell/shell.interfaces.d.ts +8 -4
- package/dist/shell/shell.interfaces.d.ts.map +1 -1
- package/dist/shell/shell.utilities.d.ts +7 -0
- package/dist/shell/shell.utilities.d.ts.map +1 -1
- package/dist/shell/shell.utilities.js +17 -0
- package/dist/shell/shell.utilities.js.map +1 -1
- package/package.json +130 -12
- package/dist/chat/components/chat-assistant-legacy.d.ts +0 -9
- package/dist/chat/components/chat-assistant-legacy.d.ts.map +0 -1
- package/dist/chat/components/chat-assistant-legacy.js +0 -73
- package/dist/chat/components/chat-assistant-legacy.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Client API
|
|
3
|
+
*
|
|
4
|
+
* Client-side functions for making requests to the notifications API.
|
|
5
|
+
*/
|
|
6
|
+
import type { notificationHandlers } from "./notifications.handlers";
|
|
7
|
+
import type { FetchNotificationsParams } from "../notifications.interfaces";
|
|
8
|
+
import type { ApiRouteResponse } from "../../shared/shared.interfaces";
|
|
9
|
+
export type NotificationsListResponse = ApiRouteResponse<typeof notificationHandlers.list>;
|
|
10
|
+
export type UnreadCountResponse = ApiRouteResponse<typeof notificationHandlers.getUnreadCount>;
|
|
11
|
+
export type MarkAsReadResponse = ApiRouteResponse<typeof notificationHandlers.markAsRead>;
|
|
12
|
+
export type MarkAllAsReadResponse = ApiRouteResponse<typeof notificationHandlers.markAllAsRead>;
|
|
13
|
+
export type DismissNotificationResponse = ApiRouteResponse<typeof notificationHandlers.dismiss>;
|
|
14
|
+
export type DismissAllResponse = ApiRouteResponse<typeof notificationHandlers.dismissAll>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch notifications for the current user
|
|
17
|
+
*
|
|
18
|
+
* @param params - Query parameters for listing notifications
|
|
19
|
+
* @param endpoint - API endpoint (defaults to /api/notifications)
|
|
20
|
+
* @returns Promise resolving to notifications and pagination info
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const { notifications, nextCursor } = await fetchNotifications({
|
|
24
|
+
* limit: 20,
|
|
25
|
+
* unreadOnly: true,
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
export declare function fetchNotifications(params?: FetchNotificationsParams, endpoint?: string): Promise<NotificationsListResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetch unread notification count for the current user
|
|
31
|
+
*
|
|
32
|
+
* @param endpoint - API endpoint (defaults to /api/notifications/unread-count)
|
|
33
|
+
* @returns Promise resolving to the unread count object
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const { count } = await fetchUnreadCount();
|
|
37
|
+
* console.log(`You have ${count} unread notifications`);
|
|
38
|
+
*/
|
|
39
|
+
export declare function fetchUnreadCount(endpoint?: string): Promise<UnreadCountResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Mark a notification as read
|
|
42
|
+
*
|
|
43
|
+
* @param notificationId - ID of the notification to mark as read
|
|
44
|
+
* @param endpoint - API endpoint base (defaults to /api/notifications)
|
|
45
|
+
* @returns Promise resolving to the updated notification status
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const result = await markAsReadRequest('notif-123');
|
|
49
|
+
* console.log(`Notification ${result.notificationId} is now read: ${result.read}`);
|
|
50
|
+
*/
|
|
51
|
+
export declare function markAsReadRequest(notificationId: string, endpoint?: string): Promise<MarkAsReadResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Mark all notifications as read for the current user
|
|
54
|
+
*
|
|
55
|
+
* @param endpoint - API endpoint (defaults to /api/notifications/mark-all-read)
|
|
56
|
+
* @returns Promise resolving to the number of updated notifications
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const result = await markAllAsReadRequest();
|
|
60
|
+
* console.log(`Marked ${result.updatedCount} notifications as read`);
|
|
61
|
+
*/
|
|
62
|
+
export declare function markAllAsReadRequest(endpoint?: string): Promise<MarkAllAsReadResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Dismiss (soft delete) a notification
|
|
65
|
+
*
|
|
66
|
+
* @param notificationId - ID of the notification to dismiss
|
|
67
|
+
* @param endpoint - API endpoint base (defaults to /api/notifications)
|
|
68
|
+
* @returns Promise resolving to the updated notification status
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const result = await dismissNotificationRequest('notif-123');
|
|
72
|
+
* console.log(`Notification ${result.notificationId} dismissed: ${result.isDismissed}`);
|
|
73
|
+
*/
|
|
74
|
+
export declare function dismissNotificationRequest(notificationId: string, endpoint?: string): Promise<DismissNotificationResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Dismiss (soft delete) all notifications for the current user
|
|
77
|
+
*
|
|
78
|
+
* @param endpoint - API endpoint (defaults to /api/notifications/dismiss-all)
|
|
79
|
+
* @returns Promise resolving to the number of dismissed notifications
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const result = await dismissAllRequest();
|
|
83
|
+
* console.log(`Dismissed ${result.dismissedCount} notifications`);
|
|
84
|
+
*/
|
|
85
|
+
export declare function dismissAllRequest(endpoint?: string): Promise<DismissAllResponse>;
|
|
86
|
+
//# sourceMappingURL=notifications.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.client.d.ts","sourceRoot":"","sources":["../../../lib/notifications/api/notifications.client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIvE,MAAM,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAA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../shared/utilities/fetch";
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Client Functions
|
|
5
|
+
// ============================================================================
|
|
6
|
+
/**
|
|
7
|
+
* Fetch notifications for the current user
|
|
8
|
+
*
|
|
9
|
+
* @param params - Query parameters for listing notifications
|
|
10
|
+
* @param endpoint - API endpoint (defaults to /api/notifications)
|
|
11
|
+
* @returns Promise resolving to notifications and pagination info
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const { notifications, nextCursor } = await fetchNotifications({
|
|
15
|
+
* limit: 20,
|
|
16
|
+
* unreadOnly: true,
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
export async function fetchNotifications(params = {}, endpoint = NOTIFICATIONS_API_ENDPOINT) {
|
|
20
|
+
const searchParams = new URLSearchParams();
|
|
21
|
+
if (params.limit)
|
|
22
|
+
searchParams.set("limit", params.limit.toString());
|
|
23
|
+
if (params.cursor)
|
|
24
|
+
searchParams.set("cursor", params.cursor);
|
|
25
|
+
if (params.unreadOnly !== undefined)
|
|
26
|
+
searchParams.set("unreadOnly", params.unreadOnly.toString());
|
|
27
|
+
if (params.includeDismissed !== undefined) {
|
|
28
|
+
searchParams.set("includeDismissed", params.includeDismissed.toString());
|
|
29
|
+
}
|
|
30
|
+
const url = searchParams.toString().length > 0 ? `${endpoint}?${searchParams}` : endpoint;
|
|
31
|
+
return fetchJson(url);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fetch unread notification count for the current user
|
|
35
|
+
*
|
|
36
|
+
* @param endpoint - API endpoint (defaults to /api/notifications/unread-count)
|
|
37
|
+
* @returns Promise resolving to the unread count object
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const { count } = await fetchUnreadCount();
|
|
41
|
+
* console.log(`You have ${count} unread notifications`);
|
|
42
|
+
*/
|
|
43
|
+
export async function fetchUnreadCount(endpoint = `${NOTIFICATIONS_API_ENDPOINT}/unread-count`) {
|
|
44
|
+
return fetchJson(endpoint);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Mark a notification as read
|
|
48
|
+
*
|
|
49
|
+
* @param notificationId - ID of the notification to mark as read
|
|
50
|
+
* @param endpoint - API endpoint base (defaults to /api/notifications)
|
|
51
|
+
* @returns Promise resolving to the updated notification status
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const result = await markAsReadRequest('notif-123');
|
|
55
|
+
* console.log(`Notification ${result.notificationId} is now read: ${result.read}`);
|
|
56
|
+
*/
|
|
57
|
+
export async function markAsReadRequest(notificationId, endpoint = NOTIFICATIONS_API_ENDPOINT) {
|
|
58
|
+
return fetchJson(`${endpoint}/${notificationId}/read`, { method: "POST" });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Mark all notifications as read for the current user
|
|
62
|
+
*
|
|
63
|
+
* @param endpoint - API endpoint (defaults to /api/notifications/mark-all-read)
|
|
64
|
+
* @returns Promise resolving to the number of updated notifications
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const result = await markAllAsReadRequest();
|
|
68
|
+
* console.log(`Marked ${result.updatedCount} notifications as read`);
|
|
69
|
+
*/
|
|
70
|
+
export async function markAllAsReadRequest(endpoint = `${NOTIFICATIONS_API_ENDPOINT}/mark-all-read`) {
|
|
71
|
+
return fetchJson(endpoint, { method: "POST" });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Dismiss (soft delete) a notification
|
|
75
|
+
*
|
|
76
|
+
* @param notificationId - ID of the notification to dismiss
|
|
77
|
+
* @param endpoint - API endpoint base (defaults to /api/notifications)
|
|
78
|
+
* @returns Promise resolving to the updated notification status
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const result = await dismissNotificationRequest('notif-123');
|
|
82
|
+
* console.log(`Notification ${result.notificationId} dismissed: ${result.isDismissed}`);
|
|
83
|
+
*/
|
|
84
|
+
export async function dismissNotificationRequest(notificationId, endpoint = NOTIFICATIONS_API_ENDPOINT) {
|
|
85
|
+
return fetchJson(`${endpoint}/${notificationId}`, {
|
|
86
|
+
method: "DELETE",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Dismiss (soft delete) all notifications for the current user
|
|
91
|
+
*
|
|
92
|
+
* @param endpoint - API endpoint (defaults to /api/notifications/dismiss-all)
|
|
93
|
+
* @returns Promise resolving to the number of dismissed notifications
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const result = await dismissAllRequest();
|
|
97
|
+
* console.log(`Dismissed ${result.dismissedCount} notifications`);
|
|
98
|
+
*/
|
|
99
|
+
export async function dismissAllRequest(endpoint = `${NOTIFICATIONS_API_ENDPOINT}/dismiss-all`) {
|
|
100
|
+
return fetchJson(endpoint, { method: "DELETE" });
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=notifications.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.client.js","sourceRoot":"","sources":["../../../lib/notifications/api/notifications.client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAUzD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,SAAmC,EAAE,EACrC,QAAQ,GAAG,0BAA0B;IAErC,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;IAE3C,IAAI,MAAM,CAAC,KAAK;QAAE,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,IAAI,MAAM,CAAC,MAAM;QAAE,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,MAAM,CAAC,UAAU,KAAK,SA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AC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAQ,GAAG,GAAG,0BAA0B,cAAc;IAEtD,OAAO,SAAS,CAAqB,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications API Handlers
|
|
3
|
+
*
|
|
4
|
+
* Route handlers for notifications API endpoints.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* GET /api/notifications
|
|
8
|
+
*
|
|
9
|
+
* Lists notifications for the authenticated user with pagination support.
|
|
10
|
+
*
|
|
11
|
+
* Query parameters:
|
|
12
|
+
* - limit: Number of notifications to return (optional, defaults to 20)
|
|
13
|
+
* - cursor: Pagination cursor for next page (optional)
|
|
14
|
+
* - unreadOnly: Only return unread notifications (optional, defaults to false)
|
|
15
|
+
* - includeDismissed: Include dismissed notifications (optional, defaults to false)
|
|
16
|
+
*
|
|
17
|
+
* @returns Object containing:
|
|
18
|
+
* - notifications: Array of Notification objects
|
|
19
|
+
* - nextCursor: Pagination cursor for next page (if more exist)
|
|
20
|
+
*/
|
|
21
|
+
export declare const listNotifications: (request: import("next/server").NextRequest, context: {
|
|
22
|
+
params: Promise<Record<string, unknown>>;
|
|
23
|
+
}) => Promise<import("next/server").NextResponse<import("..").PaginatedNotifications | {
|
|
24
|
+
error: string;
|
|
25
|
+
}>>;
|
|
26
|
+
/**
|
|
27
|
+
* GET /api/notifications/unread-count
|
|
28
|
+
*
|
|
29
|
+
* Gets the count of unread notifications for the authenticated user.
|
|
30
|
+
*
|
|
31
|
+
* @returns Object containing:
|
|
32
|
+
* - count: Number of unread notifications
|
|
33
|
+
*/
|
|
34
|
+
export declare const getUnreadCount: (request: import("next/server").NextRequest, context: {
|
|
35
|
+
params: Promise<Record<string, unknown>>;
|
|
36
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
37
|
+
error: string;
|
|
38
|
+
} | {
|
|
39
|
+
count: number;
|
|
40
|
+
}>>;
|
|
41
|
+
/**
|
|
42
|
+
* POST /api/notifications/:id/read
|
|
43
|
+
*
|
|
44
|
+
* Marks a specific notification as read.
|
|
45
|
+
*
|
|
46
|
+
* URL parameters:
|
|
47
|
+
* - id: Notification ID to mark as read (required)
|
|
48
|
+
*
|
|
49
|
+
* @returns Object containing:
|
|
50
|
+
* - notificationId: ID of the notification
|
|
51
|
+
* - read: Updated read status (true)
|
|
52
|
+
*/
|
|
53
|
+
export declare const markAsRead: (request: import("next/server").NextRequest, context: {
|
|
54
|
+
params: Promise<{
|
|
55
|
+
id: string;
|
|
56
|
+
}>;
|
|
57
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
58
|
+
error: string;
|
|
59
|
+
} | {
|
|
60
|
+
notificationId: string;
|
|
61
|
+
read: boolean;
|
|
62
|
+
}>>;
|
|
63
|
+
/**
|
|
64
|
+
* POST /api/notifications/mark-all-read
|
|
65
|
+
*
|
|
66
|
+
* Marks all notifications as read for the authenticated user.
|
|
67
|
+
*
|
|
68
|
+
* @returns Object containing:
|
|
69
|
+
* - updatedCount: Number of notifications marked as read
|
|
70
|
+
*/
|
|
71
|
+
export declare const markAllAsRead: (request: import("next/server").NextRequest, context: {
|
|
72
|
+
params: Promise<Record<string, unknown>>;
|
|
73
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
74
|
+
error: string;
|
|
75
|
+
} | {
|
|
76
|
+
updatedCount: number;
|
|
77
|
+
}>>;
|
|
78
|
+
/**
|
|
79
|
+
* DELETE /api/notifications/:id
|
|
80
|
+
*
|
|
81
|
+
* Dismisses (soft deletes) a notification.
|
|
82
|
+
*
|
|
83
|
+
* URL parameters:
|
|
84
|
+
* - id: Notification ID to dismiss (required)
|
|
85
|
+
*
|
|
86
|
+
* @returns Object containing:
|
|
87
|
+
* - notificationId: ID of the notification
|
|
88
|
+
* - isDismissed: Updated dismissed status (true)
|
|
89
|
+
*/
|
|
90
|
+
export declare const dismissNotification: (request: import("next/server").NextRequest, context: {
|
|
91
|
+
params: Promise<{
|
|
92
|
+
id: string;
|
|
93
|
+
}>;
|
|
94
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
95
|
+
error: string;
|
|
96
|
+
} | {
|
|
97
|
+
notificationId: string;
|
|
98
|
+
isDismissed: boolean;
|
|
99
|
+
}>>;
|
|
100
|
+
/**
|
|
101
|
+
* DELETE /api/notifications/dismiss-all
|
|
102
|
+
*
|
|
103
|
+
* Dismisses (soft deletes) all notifications for the authenticated user.
|
|
104
|
+
*
|
|
105
|
+
* @returns Object containing:
|
|
106
|
+
* - dismissedCount: Number of notifications dismissed
|
|
107
|
+
*/
|
|
108
|
+
export declare const dismissAllNotifications: (request: import("next/server").NextRequest, context: {
|
|
109
|
+
params: Promise<Record<string, unknown>>;
|
|
110
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
111
|
+
error: string;
|
|
112
|
+
} | {
|
|
113
|
+
dismissedCount: number;
|
|
114
|
+
}>>;
|
|
115
|
+
/**
|
|
116
|
+
* Export all handlers as a single object for type inference
|
|
117
|
+
*/
|
|
118
|
+
export declare const notificationHandlers: {
|
|
119
|
+
list: (request: import("next/server").NextRequest, context: {
|
|
120
|
+
params: Promise<Record<string, unknown>>;
|
|
121
|
+
}) => Promise<import("next/server").NextResponse<import("..").PaginatedNotifications | {
|
|
122
|
+
error: string;
|
|
123
|
+
}>>;
|
|
124
|
+
getUnreadCount: (request: import("next/server").NextRequest, context: {
|
|
125
|
+
params: Promise<Record<string, unknown>>;
|
|
126
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
127
|
+
error: string;
|
|
128
|
+
} | {
|
|
129
|
+
count: number;
|
|
130
|
+
}>>;
|
|
131
|
+
markAsRead: (request: import("next/server").NextRequest, context: {
|
|
132
|
+
params: Promise<{
|
|
133
|
+
id: string;
|
|
134
|
+
}>;
|
|
135
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
136
|
+
error: string;
|
|
137
|
+
} | {
|
|
138
|
+
notificationId: string;
|
|
139
|
+
read: boolean;
|
|
140
|
+
}>>;
|
|
141
|
+
markAllAsRead: (request: import("next/server").NextRequest, context: {
|
|
142
|
+
params: Promise<Record<string, unknown>>;
|
|
143
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
144
|
+
error: string;
|
|
145
|
+
} | {
|
|
146
|
+
updatedCount: number;
|
|
147
|
+
}>>;
|
|
148
|
+
dismiss: (request: import("next/server").NextRequest, context: {
|
|
149
|
+
params: Promise<{
|
|
150
|
+
id: string;
|
|
151
|
+
}>;
|
|
152
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
153
|
+
error: string;
|
|
154
|
+
} | {
|
|
155
|
+
notificationId: string;
|
|
156
|
+
isDismissed: boolean;
|
|
157
|
+
}>>;
|
|
158
|
+
dismissAll: (request: import("next/server").NextRequest, context: {
|
|
159
|
+
params: Promise<Record<string, unknown>>;
|
|
160
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
161
|
+
error: string;
|
|
162
|
+
} | {
|
|
163
|
+
dismissedCount: number;
|
|
164
|
+
}>>;
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=notifications.handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.handlers.d.ts","sourceRoot":"","sources":["../../../lib/notifications/api/notifications.handlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB;;;;GA2B7B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;GAoB1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;;YAIiB,MAAM;;;;;;;GA4B7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;;GAqBzB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB;;YAIQ,MAAM;;;;;;;GA4B7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;;;;GAsBnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;gBA9IO,MAAM;;;;;;;;;;;;;;;;;gBA6EN,MAAM;;;;;;;;;;;;;;;CAwE7C,CAAC"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications API Handlers
|
|
3
|
+
*
|
|
4
|
+
* Route handlers for notifications API endpoints.
|
|
5
|
+
*/
|
|
6
|
+
import { listNotificationsSchema } from "../notifications.schemas";
|
|
7
|
+
import { getNotificationsService } from "../services";
|
|
8
|
+
import { ACTION, RESOURCE } from "../../permissions/permissions.constants";
|
|
9
|
+
import { requirePermission } from "../../permissions/permissions.utilities";
|
|
10
|
+
import { getUserAwsCredentials, handleApi, withAuth } from "../../shared/utilities/api";
|
|
11
|
+
/**
|
|
12
|
+
* GET /api/notifications
|
|
13
|
+
*
|
|
14
|
+
* Lists notifications for the authenticated user with pagination support.
|
|
15
|
+
*
|
|
16
|
+
* Query parameters:
|
|
17
|
+
* - limit: Number of notifications to return (optional, defaults to 20)
|
|
18
|
+
* - cursor: Pagination cursor for next page (optional)
|
|
19
|
+
* - unreadOnly: Only return unread notifications (optional, defaults to false)
|
|
20
|
+
* - includeDismissed: Include dismissed notifications (optional, defaults to false)
|
|
21
|
+
*
|
|
22
|
+
* @returns Object containing:
|
|
23
|
+
* - notifications: Array of Notification objects
|
|
24
|
+
* - nextCursor: Pagination cursor for next page (if more exist)
|
|
25
|
+
*/
|
|
26
|
+
export const listNotifications = withAuth(async (request, { idToken, user, userId, tenantId }) => handleApi(async () => {
|
|
27
|
+
var _a, _b, _c, _d;
|
|
28
|
+
const userCredentials = await getUserAwsCredentials(idToken);
|
|
29
|
+
await requirePermission({
|
|
30
|
+
userId,
|
|
31
|
+
tenantId,
|
|
32
|
+
resource: RESOURCE.NOTIFICATIONS,
|
|
33
|
+
action: ACTION.LIST,
|
|
34
|
+
groups: user.groups,
|
|
35
|
+
userCredentials,
|
|
36
|
+
});
|
|
37
|
+
const search = request.nextUrl.searchParams;
|
|
38
|
+
// Schema transforms query string values (string → number, string → boolean)
|
|
39
|
+
const query = listNotificationsSchema.parse({
|
|
40
|
+
tenantId,
|
|
41
|
+
userId: user.id,
|
|
42
|
+
limit: (_a = search.get("limit")) !== null && _a !== void 0 ? _a : undefined,
|
|
43
|
+
cursor: (_b = search.get("cursor")) !== null && _b !== void 0 ? _b : undefined,
|
|
44
|
+
unreadOnly: (_c = search.get("unreadOnly")) !== null && _c !== void 0 ? _c : undefined,
|
|
45
|
+
includeDismissed: (_d = search.get("includeDismissed")) !== null && _d !== void 0 ? _d : undefined,
|
|
46
|
+
});
|
|
47
|
+
return getNotificationsService().listNotifications(query, { userCredentials });
|
|
48
|
+
}));
|
|
49
|
+
/**
|
|
50
|
+
* GET /api/notifications/unread-count
|
|
51
|
+
*
|
|
52
|
+
* Gets the count of unread notifications for the authenticated user.
|
|
53
|
+
*
|
|
54
|
+
* @returns Object containing:
|
|
55
|
+
* - count: Number of unread notifications
|
|
56
|
+
*/
|
|
57
|
+
export const getUnreadCount = withAuth(async (request, { idToken, user, userId, tenantId }) => handleApi(async () => {
|
|
58
|
+
const userCredentials = await getUserAwsCredentials(idToken);
|
|
59
|
+
await requirePermission({
|
|
60
|
+
userId,
|
|
61
|
+
tenantId,
|
|
62
|
+
resource: RESOURCE.NOTIFICATIONS,
|
|
63
|
+
action: ACTION.READ,
|
|
64
|
+
groups: user.groups,
|
|
65
|
+
userCredentials,
|
|
66
|
+
});
|
|
67
|
+
const count = await getNotificationsService().getUnreadCount({ tenantId, userId: user.id }, { userCredentials });
|
|
68
|
+
return { count };
|
|
69
|
+
}));
|
|
70
|
+
/**
|
|
71
|
+
* POST /api/notifications/:id/read
|
|
72
|
+
*
|
|
73
|
+
* Marks a specific notification as read.
|
|
74
|
+
*
|
|
75
|
+
* URL parameters:
|
|
76
|
+
* - id: Notification ID to mark as read (required)
|
|
77
|
+
*
|
|
78
|
+
* @returns Object containing:
|
|
79
|
+
* - notificationId: ID of the notification
|
|
80
|
+
* - read: Updated read status (true)
|
|
81
|
+
*/
|
|
82
|
+
export const markAsRead = withAuth(async (_request, { idToken, user, userId, tenantId }, { params }) => handleApi(async () => {
|
|
83
|
+
const userCredentials = await getUserAwsCredentials(idToken);
|
|
84
|
+
await requirePermission({
|
|
85
|
+
userId,
|
|
86
|
+
tenantId,
|
|
87
|
+
resource: RESOURCE.NOTIFICATIONS,
|
|
88
|
+
action: ACTION.MARK_READ,
|
|
89
|
+
groups: user.groups,
|
|
90
|
+
userCredentials,
|
|
91
|
+
});
|
|
92
|
+
const { id: notificationId } = await params;
|
|
93
|
+
// Service validates params - no need to validate here since tenantId/userId
|
|
94
|
+
// come from withAuth and notificationId comes from URL route params
|
|
95
|
+
const notification = await getNotificationsService().markAsRead({ tenantId, userId: user.id, notificationId }, { userCredentials });
|
|
96
|
+
return {
|
|
97
|
+
notificationId: notification.id,
|
|
98
|
+
read: notification.read,
|
|
99
|
+
};
|
|
100
|
+
}));
|
|
101
|
+
/**
|
|
102
|
+
* POST /api/notifications/mark-all-read
|
|
103
|
+
*
|
|
104
|
+
* Marks all notifications as read for the authenticated user.
|
|
105
|
+
*
|
|
106
|
+
* @returns Object containing:
|
|
107
|
+
* - updatedCount: Number of notifications marked as read
|
|
108
|
+
*/
|
|
109
|
+
export const markAllAsRead = withAuth(async (_request, { idToken, user, userId, tenantId }) => handleApi(async () => {
|
|
110
|
+
const userCredentials = await getUserAwsCredentials(idToken);
|
|
111
|
+
await requirePermission({
|
|
112
|
+
userId,
|
|
113
|
+
tenantId,
|
|
114
|
+
resource: RESOURCE.NOTIFICATIONS,
|
|
115
|
+
action: ACTION.MARK_ALL_READ,
|
|
116
|
+
groups: user.groups,
|
|
117
|
+
userCredentials,
|
|
118
|
+
});
|
|
119
|
+
// Service validates params - no need to validate here since tenantId/userId come from withAuth
|
|
120
|
+
const updatedCount = await getNotificationsService().markAllAsRead({ tenantId, userId: user.id }, { userCredentials });
|
|
121
|
+
return { updatedCount };
|
|
122
|
+
}));
|
|
123
|
+
/**
|
|
124
|
+
* DELETE /api/notifications/:id
|
|
125
|
+
*
|
|
126
|
+
* Dismisses (soft deletes) a notification.
|
|
127
|
+
*
|
|
128
|
+
* URL parameters:
|
|
129
|
+
* - id: Notification ID to dismiss (required)
|
|
130
|
+
*
|
|
131
|
+
* @returns Object containing:
|
|
132
|
+
* - notificationId: ID of the notification
|
|
133
|
+
* - isDismissed: Updated dismissed status (true)
|
|
134
|
+
*/
|
|
135
|
+
export const dismissNotification = withAuth(async (_request, { idToken, user, userId, tenantId }, { params }) => handleApi(async () => {
|
|
136
|
+
const userCredentials = await getUserAwsCredentials(idToken);
|
|
137
|
+
await requirePermission({
|
|
138
|
+
userId,
|
|
139
|
+
tenantId,
|
|
140
|
+
resource: RESOURCE.NOTIFICATIONS,
|
|
141
|
+
action: ACTION.DISMISS,
|
|
142
|
+
groups: user.groups,
|
|
143
|
+
userCredentials,
|
|
144
|
+
});
|
|
145
|
+
const { id: notificationId } = await params;
|
|
146
|
+
// Service validates params - no need to validate here since tenantId/userId
|
|
147
|
+
// come from withAuth and notificationId comes from URL route params
|
|
148
|
+
const notification = await getNotificationsService().dismissNotification({ tenantId, userId: user.id, notificationId }, { userCredentials });
|
|
149
|
+
return {
|
|
150
|
+
notificationId: notification.id,
|
|
151
|
+
isDismissed: notification.isDismissed,
|
|
152
|
+
};
|
|
153
|
+
}));
|
|
154
|
+
/**
|
|
155
|
+
* DELETE /api/notifications/dismiss-all
|
|
156
|
+
*
|
|
157
|
+
* Dismisses (soft deletes) all notifications for the authenticated user.
|
|
158
|
+
*
|
|
159
|
+
* @returns Object containing:
|
|
160
|
+
* - dismissedCount: Number of notifications dismissed
|
|
161
|
+
*/
|
|
162
|
+
export const dismissAllNotifications = withAuth(async (_request, { idToken, user, userId, tenantId }) => handleApi(async () => {
|
|
163
|
+
const userCredentials = await getUserAwsCredentials(idToken);
|
|
164
|
+
await requirePermission({
|
|
165
|
+
userId,
|
|
166
|
+
tenantId,
|
|
167
|
+
resource: RESOURCE.NOTIFICATIONS,
|
|
168
|
+
action: ACTION.DISMISS_ALL,
|
|
169
|
+
groups: user.groups,
|
|
170
|
+
userCredentials,
|
|
171
|
+
});
|
|
172
|
+
// Service validates params - no need to validate here since tenantId/userId come from withAuth
|
|
173
|
+
const dismissedCount = await getNotificationsService().dismissAllNotifications({ tenantId, userId: user.id }, { userCredentials });
|
|
174
|
+
return { dismissedCount };
|
|
175
|
+
}));
|
|
176
|
+
/**
|
|
177
|
+
* Export all handlers as a single object for type inference
|
|
178
|
+
*/
|
|
179
|
+
export const notificationHandlers = {
|
|
180
|
+
list: listNotifications,
|
|
181
|
+
getUnreadCount,
|
|
182
|
+
markAsRead,
|
|
183
|
+
markAllAsRead,
|
|
184
|
+
dismiss: dismissNotification,
|
|
185
|
+
dismissAll: dismissAllNotifications,
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=notifications.handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.handlers.js","sourceRoot":"","sources":["../../../lib/notifications/api/notifications.handlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAExF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE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AAuB;CACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/notifications/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,iDAAiD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/notifications/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,iDAAiD,CAAC"}
|