@goplusvn/core 0.1.51 → 0.1.53
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/features/README.md +11 -2
- package/features/error-logs/migrations/0001_init.sql +32 -0
- package/features/error-logs/schema.prisma +28 -0
- package/features/notifications/README.md +14 -0
- package/features/notifications/migrations/0001_init.sql +59 -0
- package/features/notifications/schema.prisma +46 -0
- package/package.json +4 -1
- package/src/notification/__tests__/notification-service.test.ts +192 -0
- package/src/notification/__tests__/notification-ui.test.tsx +62 -0
- package/src/notification/index.ts +15 -13
- package/src/notification/notification-service.ts +270 -96
- package/src/notification/ui/index.ts +2 -0
- package/src/notification/ui/notification-bell.tsx +244 -0
- package/src/notification/ui/notifications-inbox.tsx +193 -0
- package/src/system/pages/error-logs-page.tsx +652 -0
- package/src/notification/storage/in-memory.ts +0 -56
- package/src/notification/storage/index.ts +0 -1
- package/src/notification/types.ts +0 -51
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Notification, NotificationStorage } from "../types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* In-memory notification storage for development/testing
|
|
5
|
-
* In production, replace with database storage
|
|
6
|
-
*/
|
|
7
|
-
export class InMemoryStorage implements NotificationStorage {
|
|
8
|
-
private notifications = new Map<string, Notification>();
|
|
9
|
-
|
|
10
|
-
async save(notification: Notification): Promise<void> {
|
|
11
|
-
this.notifications.set(notification.id, notification);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async findByUserId(
|
|
15
|
-
userId: string,
|
|
16
|
-
options?: { unreadOnly?: boolean },
|
|
17
|
-
): Promise<Notification[]> {
|
|
18
|
-
const result: Notification[] = [];
|
|
19
|
-
|
|
20
|
-
for (const notification of this.notifications.values()) {
|
|
21
|
-
if (notification.userId === userId) {
|
|
22
|
-
if (options?.unreadOnly && notification.status === "read") {
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
result.push(notification);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return result.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async findById(id: string): Promise<Notification | null> {
|
|
33
|
-
return this.notifications.get(id) || null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async markAsRead(id: string): Promise<void> {
|
|
37
|
-
const notification = this.notifications.get(id);
|
|
38
|
-
if (notification) {
|
|
39
|
-
notification.status = "read";
|
|
40
|
-
notification.readAt = new Date();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async markAllAsRead(userId: string): Promise<void> {
|
|
45
|
-
for (const notification of this.notifications.values()) {
|
|
46
|
-
if (notification.userId === userId && notification.status !== "read") {
|
|
47
|
-
notification.status = "read";
|
|
48
|
-
notification.readAt = new Date();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async delete(id: string): Promise<void> {
|
|
54
|
-
this.notifications.delete(id);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { InMemoryStorage } from "./in-memory";
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Notification Types
|
|
2
|
-
export type NotificationType =
|
|
3
|
-
| "info"
|
|
4
|
-
| "warning"
|
|
5
|
-
| "error"
|
|
6
|
-
| "success"
|
|
7
|
-
| "approval";
|
|
8
|
-
export type NotificationChannel = "in-app" | "email" | "sms";
|
|
9
|
-
export type NotificationStatus = "pending" | "sent" | "read" | "failed";
|
|
10
|
-
|
|
11
|
-
export interface Notification {
|
|
12
|
-
id: string;
|
|
13
|
-
userId: string;
|
|
14
|
-
title: string;
|
|
15
|
-
content: string;
|
|
16
|
-
type: NotificationType;
|
|
17
|
-
channel: NotificationChannel;
|
|
18
|
-
status: NotificationStatus;
|
|
19
|
-
/** Link to navigate when clicked */
|
|
20
|
-
link?: string;
|
|
21
|
-
/** Additional metadata */
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
createdAt: Date;
|
|
24
|
-
readAt?: Date;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface CreateNotificationInput {
|
|
28
|
-
userId: string;
|
|
29
|
-
title: string;
|
|
30
|
-
content: string;
|
|
31
|
-
type?: NotificationType;
|
|
32
|
-
channel?: NotificationChannel;
|
|
33
|
-
link?: string;
|
|
34
|
-
metadata?: Record<string, unknown>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface NotificationStorage {
|
|
38
|
-
save(notification: Notification): Promise<void>;
|
|
39
|
-
findByUserId(
|
|
40
|
-
userId: string,
|
|
41
|
-
options?: { unreadOnly?: boolean },
|
|
42
|
-
): Promise<Notification[]>;
|
|
43
|
-
findById(id: string): Promise<Notification | null>;
|
|
44
|
-
markAsRead(id: string): Promise<void>;
|
|
45
|
-
markAllAsRead(userId: string): Promise<void>;
|
|
46
|
-
delete(id: string): Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface NotificationServiceOptions {
|
|
50
|
-
storage?: NotificationStorage;
|
|
51
|
-
}
|