@flusys/nestjs-notification 3.0.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/README.md +998 -0
- package/adapters/index.d.ts +1 -0
- package/adapters/notification.adapter.d.ts +10 -0
- package/cjs/adapters/index.js +18 -0
- package/cjs/adapters/notification.adapter.js +79 -0
- package/cjs/config/index.js +18 -0
- package/cjs/config/notification.constants.js +11 -0
- package/cjs/controllers/index.js +18 -0
- package/cjs/controllers/notification.controller.js +278 -0
- package/cjs/docs/index.js +18 -0
- package/cjs/docs/notification-swagger.config.js +61 -0
- package/cjs/dtos/index.js +18 -0
- package/cjs/dtos/notification.dto.js +244 -0
- package/cjs/entities/index.js +48 -0
- package/cjs/entities/notification-with-company.entity.js +57 -0
- package/cjs/entities/notification.entity.js +111 -0
- package/cjs/gateways/index.js +18 -0
- package/cjs/gateways/notification.gateway.js +226 -0
- package/cjs/index.js +28 -0
- package/cjs/interfaces/index.js +19 -0
- package/cjs/interfaces/notification-module.interface.js +4 -0
- package/cjs/interfaces/notification.interface.js +4 -0
- package/cjs/modules/index.js +18 -0
- package/cjs/modules/notification.module.js +139 -0
- package/cjs/services/index.js +21 -0
- package/cjs/services/notification-config.service.js +72 -0
- package/cjs/services/notification-datasource.provider.js +174 -0
- package/cjs/services/notification-helper.service.js +186 -0
- package/cjs/services/notification.service.js +220 -0
- package/config/index.d.ts +1 -0
- package/config/notification.constants.d.ts +1 -0
- package/controllers/index.d.ts +1 -0
- package/controllers/notification.controller.d.ts +26 -0
- package/docs/index.d.ts +1 -0
- package/docs/notification-swagger.config.d.ts +2 -0
- package/dtos/index.d.ts +1 -0
- package/dtos/notification.dto.d.ts +47 -0
- package/entities/index.d.ts +8 -0
- package/entities/notification-with-company.entity.d.ts +4 -0
- package/entities/notification.entity.d.ts +10 -0
- package/fesm/adapters/index.js +1 -0
- package/fesm/adapters/notification.adapter.js +69 -0
- package/fesm/config/index.js +1 -0
- package/fesm/config/notification.constants.js +1 -0
- package/fesm/controllers/index.js +1 -0
- package/fesm/controllers/notification.controller.js +268 -0
- package/fesm/docs/index.js +1 -0
- package/fesm/docs/notification-swagger.config.js +51 -0
- package/fesm/dtos/index.js +1 -0
- package/fesm/dtos/notification.dto.js +211 -0
- package/fesm/entities/index.js +14 -0
- package/fesm/entities/notification-with-company.entity.js +47 -0
- package/fesm/entities/notification.entity.js +101 -0
- package/fesm/gateways/index.js +1 -0
- package/fesm/gateways/notification.gateway.js +175 -0
- package/fesm/index.js +20 -0
- package/fesm/interfaces/index.js +2 -0
- package/fesm/interfaces/notification-module.interface.js +1 -0
- package/fesm/interfaces/notification.interface.js +1 -0
- package/fesm/modules/index.js +1 -0
- package/fesm/modules/notification.module.js +129 -0
- package/fesm/services/index.js +4 -0
- package/fesm/services/notification-config.service.js +62 -0
- package/fesm/services/notification-datasource.provider.js +123 -0
- package/fesm/services/notification-helper.service.js +176 -0
- package/fesm/services/notification.service.js +210 -0
- package/gateways/index.d.ts +1 -0
- package/gateways/notification.gateway.d.ts +21 -0
- package/index.d.ts +10 -0
- package/interfaces/index.d.ts +2 -0
- package/interfaces/notification-module.interface.d.ts +20 -0
- package/interfaces/notification.interface.d.ts +19 -0
- package/modules/index.d.ts +1 -0
- package/modules/notification.module.d.ts +8 -0
- package/package.json +98 -0
- package/services/index.d.ts +4 -0
- package/services/notification-config.service.d.ts +13 -0
- package/services/notification-datasource.provider.d.ts +23 -0
- package/services/notification-helper.service.d.ts +44 -0
- package/services/notification.service.d.ts +35 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification.adapter';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { INotificationAdapter, NotificationSendOptions, NotificationBulkSendOptions, NotificationType } from '@flusys/nestjs-shared';
|
|
2
|
+
import { NotificationHelperService } from '../services/notification-helper.service';
|
|
3
|
+
export declare class NotificationAdapter implements INotificationAdapter {
|
|
4
|
+
private readonly notificationHelper;
|
|
5
|
+
constructor(notificationHelper: NotificationHelperService);
|
|
6
|
+
send(options: NotificationSendOptions): Promise<void>;
|
|
7
|
+
sendToMany(options: NotificationBulkSendOptions): Promise<void>;
|
|
8
|
+
broadcastToCompany(companyId: string, title: string, message?: string, type?: NotificationType, data?: Record<string, unknown>): Promise<void>;
|
|
9
|
+
isUserOnline(userId: string): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./notification.adapter"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NotificationAdapter", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NotificationAdapter;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _common = require("@nestjs/common");
|
|
12
|
+
const _notificationhelperservice = require("../services/notification-helper.service");
|
|
13
|
+
function _define_property(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
}
|
|
32
|
+
function _ts_metadata(k, v) {
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
34
|
+
}
|
|
35
|
+
function _ts_param(paramIndex, decorator) {
|
|
36
|
+
return function(target, key) {
|
|
37
|
+
decorator(target, key, paramIndex);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
let NotificationAdapter = class NotificationAdapter {
|
|
41
|
+
async send(options) {
|
|
42
|
+
await this.notificationHelper.send({
|
|
43
|
+
userId: options.userId,
|
|
44
|
+
title: options.title,
|
|
45
|
+
message: options.message,
|
|
46
|
+
type: options.type,
|
|
47
|
+
data: options.data,
|
|
48
|
+
companyId: options.companyId
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async sendToMany(options) {
|
|
52
|
+
await this.notificationHelper.sendToMany({
|
|
53
|
+
userIds: options.userIds,
|
|
54
|
+
title: options.title,
|
|
55
|
+
message: options.message,
|
|
56
|
+
type: options.type,
|
|
57
|
+
data: options.data,
|
|
58
|
+
companyId: options.companyId
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async broadcastToCompany(companyId, title, message, type, data) {
|
|
62
|
+
await this.notificationHelper.sendToCompany(companyId, title, message, type, data);
|
|
63
|
+
}
|
|
64
|
+
isUserOnline(userId) {
|
|
65
|
+
return this.notificationHelper.isUserOnline(userId);
|
|
66
|
+
}
|
|
67
|
+
constructor(notificationHelper){
|
|
68
|
+
_define_property(this, "notificationHelper", void 0);
|
|
69
|
+
this.notificationHelper = notificationHelper;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
NotificationAdapter = _ts_decorate([
|
|
73
|
+
(0, _common.Injectable)(),
|
|
74
|
+
_ts_param(0, (0, _common.Inject)(_notificationhelperservice.NotificationHelperService)),
|
|
75
|
+
_ts_metadata("design:type", Function),
|
|
76
|
+
_ts_metadata("design:paramtypes", [
|
|
77
|
+
typeof _notificationhelperservice.NotificationHelperService === "undefined" ? Object : _notificationhelperservice.NotificationHelperService
|
|
78
|
+
])
|
|
79
|
+
], NotificationAdapter);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./notification.constants"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NOTIFICATION_MODULE_OPTIONS", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NOTIFICATION_MODULE_OPTIONS;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const NOTIFICATION_MODULE_OPTIONS = 'NOTIFICATION_MODULE_OPTIONS';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./notification.controller"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NotificationController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NotificationController;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _classes = require("@flusys/nestjs-shared/classes");
|
|
12
|
+
const _constants = require("@flusys/nestjs-shared/constants");
|
|
13
|
+
const _decorators = require("@flusys/nestjs-shared/decorators");
|
|
14
|
+
const _dtos = require("@flusys/nestjs-shared/dtos");
|
|
15
|
+
const _guards = require("@flusys/nestjs-shared/guards");
|
|
16
|
+
const _interfaces = require("@flusys/nestjs-shared/interfaces");
|
|
17
|
+
const _common = require("@nestjs/common");
|
|
18
|
+
const _swagger = require("@nestjs/swagger");
|
|
19
|
+
const _classtransformer = require("class-transformer");
|
|
20
|
+
const _dtos1 = require("../dtos");
|
|
21
|
+
const _notificationhelperservice = require("../services/notification-helper.service");
|
|
22
|
+
const _notificationservice = require("../services/notification.service");
|
|
23
|
+
function _define_property(obj, key, value) {
|
|
24
|
+
if (key in obj) {
|
|
25
|
+
Object.defineProperty(obj, key, {
|
|
26
|
+
value: value,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
obj[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
37
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
38
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
39
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
40
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
|
+
}
|
|
42
|
+
function _ts_metadata(k, v) {
|
|
43
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
44
|
+
}
|
|
45
|
+
function _ts_param(paramIndex, decorator) {
|
|
46
|
+
return function(target, key) {
|
|
47
|
+
decorator(target, key, paramIndex);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
let NotificationController = class NotificationController extends (0, _classes.createApiController)(_dtos1.CreateNotificationDto, _dtos1.UpdateNotificationDto, _dtos1.NotificationResponseDto, {
|
|
51
|
+
security: {
|
|
52
|
+
insert: {
|
|
53
|
+
level: 'permission',
|
|
54
|
+
permissions: [
|
|
55
|
+
_constants.NOTIFICATION_PERMISSIONS.CREATE
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
insertMany: {
|
|
59
|
+
level: 'permission',
|
|
60
|
+
permissions: [
|
|
61
|
+
_constants.NOTIFICATION_PERMISSIONS.CREATE
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
getById: {
|
|
65
|
+
level: 'permission',
|
|
66
|
+
permissions: [
|
|
67
|
+
_constants.NOTIFICATION_PERMISSIONS.READ
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
getAll: {
|
|
71
|
+
level: 'jwt'
|
|
72
|
+
},
|
|
73
|
+
update: {
|
|
74
|
+
level: 'permission',
|
|
75
|
+
permissions: [
|
|
76
|
+
_constants.NOTIFICATION_PERMISSIONS.UPDATE
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
updateMany: {
|
|
80
|
+
level: 'permission',
|
|
81
|
+
permissions: [
|
|
82
|
+
_constants.NOTIFICATION_PERMISSIONS.UPDATE
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
delete: {
|
|
86
|
+
level: 'permission',
|
|
87
|
+
permissions: [
|
|
88
|
+
_constants.NOTIFICATION_PERMISSIONS.DELETE
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}) {
|
|
93
|
+
async markAsRead(dto, user) {
|
|
94
|
+
const notification = await this.service.markAsRead(dto.id, user);
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
message: 'Notification marked as read',
|
|
98
|
+
data: (0, _classtransformer.plainToInstance)(_dtos1.NotificationResponseDto, notification)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async markAllAsRead(user) {
|
|
102
|
+
const count = await this.service.markAllAsRead(user);
|
|
103
|
+
return {
|
|
104
|
+
success: true,
|
|
105
|
+
message: `${count} notifications marked as read`
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async getUnreadCount(user) {
|
|
109
|
+
const count = await this.service.getUnreadCount(user);
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
message: 'Unread count retrieved',
|
|
113
|
+
data: {
|
|
114
|
+
count
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async sendNotification(dto) {
|
|
119
|
+
const notification = await this.notificationHelper.send({
|
|
120
|
+
userId: dto.userId,
|
|
121
|
+
title: dto.title,
|
|
122
|
+
message: dto.message,
|
|
123
|
+
type: dto.type,
|
|
124
|
+
data: dto.data,
|
|
125
|
+
companyId: dto.companyId
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
success: true,
|
|
129
|
+
message: 'Notification sent successfully',
|
|
130
|
+
data: (0, _classtransformer.plainToInstance)(_dtos1.NotificationResponseDto, notification)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async sendBulkNotification(dto) {
|
|
134
|
+
const notifications = await this.notificationHelper.sendToMany({
|
|
135
|
+
userIds: dto.userIds,
|
|
136
|
+
title: dto.title,
|
|
137
|
+
message: dto.message,
|
|
138
|
+
type: dto.type,
|
|
139
|
+
data: dto.data,
|
|
140
|
+
companyId: dto.companyId
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
success: true,
|
|
144
|
+
message: `${notifications.length} notifications sent successfully`,
|
|
145
|
+
data: notifications.map((n)=>(0, _classtransformer.plainToInstance)(_dtos1.NotificationResponseDto, n)),
|
|
146
|
+
meta: {
|
|
147
|
+
count: notifications.length,
|
|
148
|
+
total: dto.userIds.length
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
constructor(service, notificationHelper){
|
|
153
|
+
super(service), _define_property(this, "service", void 0), _define_property(this, "notificationHelper", void 0), this.service = service, this.notificationHelper = notificationHelper;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
_ts_decorate([
|
|
157
|
+
(0, _common.Post)('mark-read'),
|
|
158
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
159
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
160
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
161
|
+
(0, _swagger.ApiOperation)({
|
|
162
|
+
summary: 'Mark a notification as read'
|
|
163
|
+
}),
|
|
164
|
+
(0, _swagger.ApiBody)({
|
|
165
|
+
type: _dtos1.MarkReadDto
|
|
166
|
+
}),
|
|
167
|
+
(0, _swagger.ApiResponse)({
|
|
168
|
+
status: 200,
|
|
169
|
+
description: 'Notification marked as read',
|
|
170
|
+
type: _dtos.SingleResponseDto
|
|
171
|
+
}),
|
|
172
|
+
_ts_param(0, (0, _common.Body)()),
|
|
173
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
174
|
+
_ts_metadata("design:type", Function),
|
|
175
|
+
_ts_metadata("design:paramtypes", [
|
|
176
|
+
typeof _dtos1.MarkReadDto === "undefined" ? Object : _dtos1.MarkReadDto,
|
|
177
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
178
|
+
]),
|
|
179
|
+
_ts_metadata("design:returntype", Promise)
|
|
180
|
+
], NotificationController.prototype, "markAsRead", null);
|
|
181
|
+
_ts_decorate([
|
|
182
|
+
(0, _common.Post)('mark-all-read'),
|
|
183
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
184
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
185
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
186
|
+
(0, _swagger.ApiOperation)({
|
|
187
|
+
summary: 'Mark all notifications as read'
|
|
188
|
+
}),
|
|
189
|
+
(0, _swagger.ApiResponse)({
|
|
190
|
+
status: 200,
|
|
191
|
+
description: 'All notifications marked as read',
|
|
192
|
+
type: _dtos.MessageResponseDto
|
|
193
|
+
}),
|
|
194
|
+
_ts_param(0, (0, _decorators.CurrentUser)()),
|
|
195
|
+
_ts_metadata("design:type", Function),
|
|
196
|
+
_ts_metadata("design:paramtypes", [
|
|
197
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
198
|
+
]),
|
|
199
|
+
_ts_metadata("design:returntype", Promise)
|
|
200
|
+
], NotificationController.prototype, "markAllAsRead", null);
|
|
201
|
+
_ts_decorate([
|
|
202
|
+
(0, _common.Post)('unread-count'),
|
|
203
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
204
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
205
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
206
|
+
(0, _swagger.ApiOperation)({
|
|
207
|
+
summary: 'Get unread notification count'
|
|
208
|
+
}),
|
|
209
|
+
(0, _swagger.ApiResponse)({
|
|
210
|
+
status: 200,
|
|
211
|
+
description: 'Unread count retrieved',
|
|
212
|
+
type: _dtos.SingleResponseDto
|
|
213
|
+
}),
|
|
214
|
+
_ts_param(0, (0, _decorators.CurrentUser)()),
|
|
215
|
+
_ts_metadata("design:type", Function),
|
|
216
|
+
_ts_metadata("design:paramtypes", [
|
|
217
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
218
|
+
]),
|
|
219
|
+
_ts_metadata("design:returntype", Promise)
|
|
220
|
+
], NotificationController.prototype, "getUnreadCount", null);
|
|
221
|
+
_ts_decorate([
|
|
222
|
+
(0, _common.Post)('send'),
|
|
223
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
224
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard, _guards.PermissionGuard),
|
|
225
|
+
(0, _decorators.RequirePermission)(_constants.NOTIFICATION_PERMISSIONS.CREATE),
|
|
226
|
+
(0, _swagger.ApiOperation)({
|
|
227
|
+
summary: 'Send a notification to a user'
|
|
228
|
+
}),
|
|
229
|
+
(0, _swagger.ApiBody)({
|
|
230
|
+
type: _dtos1.SendNotificationDto
|
|
231
|
+
}),
|
|
232
|
+
(0, _swagger.ApiResponse)({
|
|
233
|
+
status: 200,
|
|
234
|
+
description: 'Notification sent successfully',
|
|
235
|
+
type: _dtos.SingleResponseDto
|
|
236
|
+
}),
|
|
237
|
+
_ts_param(0, (0, _common.Body)()),
|
|
238
|
+
_ts_metadata("design:type", Function),
|
|
239
|
+
_ts_metadata("design:paramtypes", [
|
|
240
|
+
typeof _dtos1.SendNotificationDto === "undefined" ? Object : _dtos1.SendNotificationDto
|
|
241
|
+
]),
|
|
242
|
+
_ts_metadata("design:returntype", Promise)
|
|
243
|
+
], NotificationController.prototype, "sendNotification", null);
|
|
244
|
+
_ts_decorate([
|
|
245
|
+
(0, _common.Post)('send-bulk'),
|
|
246
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
247
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard, _guards.PermissionGuard),
|
|
248
|
+
(0, _decorators.RequirePermission)(_constants.NOTIFICATION_PERMISSIONS.CREATE),
|
|
249
|
+
(0, _swagger.ApiOperation)({
|
|
250
|
+
summary: 'Send a notification to multiple users'
|
|
251
|
+
}),
|
|
252
|
+
(0, _swagger.ApiBody)({
|
|
253
|
+
type: _dtos1.SendBulkNotificationDto
|
|
254
|
+
}),
|
|
255
|
+
(0, _swagger.ApiResponse)({
|
|
256
|
+
status: 200,
|
|
257
|
+
description: 'Notifications sent successfully',
|
|
258
|
+
type: _dtos.BulkResponseDto
|
|
259
|
+
}),
|
|
260
|
+
_ts_param(0, (0, _common.Body)()),
|
|
261
|
+
_ts_metadata("design:type", Function),
|
|
262
|
+
_ts_metadata("design:paramtypes", [
|
|
263
|
+
typeof _dtos1.SendBulkNotificationDto === "undefined" ? Object : _dtos1.SendBulkNotificationDto
|
|
264
|
+
]),
|
|
265
|
+
_ts_metadata("design:returntype", Promise)
|
|
266
|
+
], NotificationController.prototype, "sendBulkNotification", null);
|
|
267
|
+
NotificationController = _ts_decorate([
|
|
268
|
+
(0, _swagger.ApiTags)('Notifications'),
|
|
269
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
270
|
+
(0, _common.Controller)('notification'),
|
|
271
|
+
_ts_param(0, (0, _common.Inject)(_notificationservice.NotificationService)),
|
|
272
|
+
_ts_param(1, (0, _common.Inject)(_notificationhelperservice.NotificationHelperService)),
|
|
273
|
+
_ts_metadata("design:type", Function),
|
|
274
|
+
_ts_metadata("design:paramtypes", [
|
|
275
|
+
typeof _notificationservice.NotificationService === "undefined" ? Object : _notificationservice.NotificationService,
|
|
276
|
+
typeof _notificationhelperservice.NotificationHelperService === "undefined" ? Object : _notificationhelperservice.NotificationHelperService
|
|
277
|
+
])
|
|
278
|
+
], NotificationController);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./notification-swagger.config"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "notificationSwaggerConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return notificationSwaggerConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function notificationSwaggerConfig() {
|
|
12
|
+
return {
|
|
13
|
+
title: 'Notification API',
|
|
14
|
+
description: `
|
|
15
|
+
## Notification API
|
|
16
|
+
|
|
17
|
+
Real-time notification system with WebSocket support.
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
- Push notifications to users
|
|
21
|
+
- Mark notifications as read
|
|
22
|
+
- Unread count tracking
|
|
23
|
+
- Real-time delivery via WebSocket
|
|
24
|
+
- Bulk notification sending
|
|
25
|
+
|
|
26
|
+
### Endpoints
|
|
27
|
+
|
|
28
|
+
#### User Notifications
|
|
29
|
+
- \`POST /notification/get-all\` - Get user's notifications (paginated, sorted by newest)
|
|
30
|
+
- \`POST /notification/get/:id\` - Get single notification
|
|
31
|
+
- \`POST /notification/mark-read\` - Mark notification as read
|
|
32
|
+
- \`POST /notification/mark-all-read\` - Mark all notifications as read
|
|
33
|
+
- \`POST /notification/unread-count\` - Get unread notification count
|
|
34
|
+
|
|
35
|
+
#### Admin/System
|
|
36
|
+
- \`POST /notification/send\` - Send notification to a user
|
|
37
|
+
- \`POST /notification/send-bulk\` - Send notification to multiple users
|
|
38
|
+
|
|
39
|
+
### WebSocket Events
|
|
40
|
+
|
|
41
|
+
Connect to WebSocket with JWT authentication:
|
|
42
|
+
\`\`\`
|
|
43
|
+
ws://localhost:2002/notification?token=<jwt>
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
**Events:**
|
|
47
|
+
- \`notification:new\` - New notification received
|
|
48
|
+
- \`notification:read\` - Notification marked as read
|
|
49
|
+
- \`notification:read-all\` - All notifications marked as read
|
|
50
|
+
|
|
51
|
+
### Notification Types
|
|
52
|
+
- \`info\` - General information
|
|
53
|
+
- \`success\` - Success message
|
|
54
|
+
- \`warning\` - Warning message
|
|
55
|
+
- \`error\` - Error message
|
|
56
|
+
`,
|
|
57
|
+
version: '1.0',
|
|
58
|
+
path: 'api/docs/notification',
|
|
59
|
+
bearerAuth: true
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./notification.dto"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|