Inject
TSXinject
1import {
2 ContainerRegistryManager,
3 NotificationService,
4 Inject,
5 Service,
6} from "@quan-erp/shared-backend-core";
7
8@Service()
9export class MyPluginService {
10 @Inject(NotificationService, ContainerRegistryManager.BUILTIN_PLUGIN)
11 private notificationService: NotificationService;
12}send(props: CreateNotificationDto)
Persists notification rows and triggers push. Targeting: userIds → specific users; roleIds → specific roles; omit both → all users. You may pass both userIds and roleIds to create two targeted notifications.
- title: string — required headline
- subtitle: string — required secondary line
- body: string — required message body
- pluginName: string — usually metadata.name from your plugin
- topic: string — logical event key (e.g. project-update)
- userIds?: number[] — target users
- roleIds?: number[] — target roles
- url?: string — deep link / open URL
- data?: object — extra payload for clients / FCM
TSXsend
1import {
2 ContainerRegistryManager,
3 Inject,
4 NotificationService,
5 Service,
6} from "@quan-erp/shared-backend-core";
7import metadata from "../../module.metadata.json" with { type: "json" };
8
9@Service()
10export class ProjectNotifyService {
11 @Inject(NotificationService, ContainerRegistryManager.BUILTIN_PLUGIN)
12 private notificationService: NotificationService;
13
14 async notifyUpdate() {
15 await this.notificationService.send({
16 userIds: [1, 2],
17 // roleIds: [1],
18 title: "Project Updated",
19 subtitle: "Status change",
20 body: "Status changed to Completed.",
21 pluginName: metadata.name,
22 topic: "project-update",
23 url: "/app/projects/12",
24 data: { projectId: 12 },
25 });
26 }
27}Inbox methods
- get({ userId, roleId, skip, limit, manager? }) — paginated notifications visible to the user (by user + role membership)
- getUnreadNotiCount({ userId, roleId }) — unread count for badge UI
- markRead({ id, userId, manager? }) — mark one notification as read for that user
TSXinbox
1import {
2 ContainerRegistryManager,
3 Inject,
4 NotificationService,
5 Service,
6} from "@quan-erp/shared-backend-core";
7
8@Service()
9export class InboxService {
10 @Inject(NotificationService, ContainerRegistryManager.BUILTIN_PLUGIN)
11 private notificationService: NotificationService;
12
13 async list(userId: number, roleId: number) {
14 const unread = await this.notificationService.getUnreadNotiCount({
15 userId,
16 roleId,
17 });
18 const items = await this.notificationService.get({
19 userId,
20 roleId,
21 skip: 0,
22 limit: 20,
23 });
24 return { unread, items };
25 }
26
27 async read(id: number, userId: number) {
28 await this.notificationService.markRead({ id, userId });
29 }
30}