@webtypen/webframez-core 0.3.60 → 0.3.62

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.
@@ -26,6 +26,7 @@ const ErrorHandler_1 = require("../ErrorHandling/ErrorHandler");
26
26
  const BackupManager_1 = require("../Backup/BackupManager");
27
27
  const WebframezHooks_1 = require("../Hooks/WebframezHooks");
28
28
  const AutomationSchedule_1 = require("../Queue/AutomationSchedule");
29
+ const NotificationService_1 = require("../Notifications/NotificationService");
29
30
  class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
30
31
  constructor() {
31
32
  super(...arguments);
@@ -534,6 +535,7 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
534
535
  job_executions_count: job.executions.length,
535
536
  };
536
537
  let jobInstance = null;
538
+ let jobNotification = null;
537
539
  const jobType = this.jobTypes && this.jobTypes[job.jobclass] ? this.jobTypes[job.jobclass] : null;
538
540
  const jobOperationId = WebframezHooks_1.WebframezHooks.createOperationId("job");
539
541
  yield WebframezHooks_1.WebframezHooks.emit("queue.job.start", {
@@ -546,6 +548,22 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
546
548
  },
547
549
  });
548
550
  try {
551
+ if (job.notification_queue_job) {
552
+ if (!job._notification) {
553
+ throw new Error(`Notification queue-job '${job._id.toString()}' has no _notification reference.`);
554
+ }
555
+ jobNotification = yield NotificationService_1.NotificationService.getNotification(job._notification);
556
+ const targetContext = yield NotificationService_1.NotificationService.resolveTarget({
557
+ target: jobNotification.target,
558
+ target_id: jobNotification.target_id,
559
+ });
560
+ if (!(targetContext === null || targetContext === void 0 ? void 0 : targetContext.targetModel)) {
561
+ throw new Error(`Notification queue-job '${job._id.toString()}' references a missing target.`);
562
+ }
563
+ NotificationService_1.NotificationService.attachTargetModel(jobNotification, targetContext.targetModel);
564
+ job.notification = jobNotification;
565
+ yield NotificationService_1.NotificationService.setChangingStatus(jobNotification, "running");
566
+ }
549
567
  if (!jobType) {
550
568
  throw new Error(`QueueError: Invalid job-type ${job.jobclass}`);
551
569
  }
@@ -558,11 +576,13 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
558
576
  job.executions[0].ended_at = endedAt;
559
577
  job.executions[0].log = jobInstance.getLog();
560
578
  job.executions[0].duration_ms = (0, moment_timezone_1.default)().diff((0, moment_timezone_1.default)(startedAt), "milliseconds");
561
- const updateData = {};
562
579
  if (result && typeof result === "object" && result.__execute_again) {
563
580
  job.status = "pending";
564
- job.started_at = result.__execute_again;
565
- updateData.started_at = result.__execute_again;
581
+ job.ended_at = null;
582
+ job.not_before = result.__execute_again;
583
+ }
584
+ if (jobNotification) {
585
+ yield NotificationService_1.NotificationService.setChangingStatus(jobNotification, job.status === "pending" ? "pending" : "success");
566
586
  }
567
587
  yield connection.client
568
588
  .db(null)
@@ -571,6 +591,7 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
571
591
  $set: {
572
592
  status: job.status,
573
593
  ended_at: job.ended_at,
594
+ not_before: job.status === "pending" ? job.not_before : null,
574
595
  executions: [...job.executions],
575
596
  },
576
597
  });
@@ -615,6 +636,51 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
615
636
  });
616
637
  const errorMessage = e instanceof Error ? e.stack || e.message : String(e);
617
638
  const endedAt = new Date();
639
+ let notificationFailureStatusSaved = false;
640
+ if (jobNotification) {
641
+ try {
642
+ yield NotificationService_1.NotificationService.setChangingStatus(jobNotification, "error", errorMessage);
643
+ notificationFailureStatusSaved = true;
644
+ }
645
+ catch (notificationError) {
646
+ yield ErrorHandler_1.ErrorHandler.report(notificationError, {
647
+ scope: "job",
648
+ source: "queue.worker.notification.status",
649
+ job: {
650
+ id: job && job._id ? job._id.toString() : undefined,
651
+ number: job && job.number ? job.number : undefined,
652
+ jobclass: job && job.jobclass ? job.jobclass : undefined,
653
+ worker: this.workerKey,
654
+ },
655
+ metadata: {
656
+ notification: job._notification ? job._notification.toString() : null,
657
+ },
658
+ });
659
+ }
660
+ }
661
+ if (!notificationFailureStatusSaved && job.notification_queue_job && job._notification) {
662
+ try {
663
+ const notificationFound = yield NotificationService_1.NotificationService.setQueueJobFailureStatus(job._notification, errorMessage);
664
+ if (!notificationFound) {
665
+ throw new Error(`Notification queue-job '${job._id.toString()}' references a missing notification '${job._notification.toString()}'.`);
666
+ }
667
+ }
668
+ catch (notificationError) {
669
+ yield ErrorHandler_1.ErrorHandler.report(notificationError, {
670
+ scope: "job",
671
+ source: "queue.worker.notification.status.fallback",
672
+ job: {
673
+ id: job && job._id ? job._id.toString() : undefined,
674
+ number: job && job.number ? job.number : undefined,
675
+ jobclass: job && job.jobclass ? job.jobclass : undefined,
676
+ worker: this.workerKey,
677
+ },
678
+ metadata: {
679
+ notification: job._notification.toString(),
680
+ },
681
+ });
682
+ }
683
+ }
618
684
  job.status = "failed";
619
685
  job.ended_at = endedAt;
620
686
  job.executions[0].status = "failed";
@@ -33,6 +33,7 @@ const BackupRestorePointsCommand_1 = require("./Commands/BackupRestorePointsComm
33
33
  const BackupRunJob_1 = require("./Backup/Jobs/BackupRunJob");
34
34
  const SystemCommands_1 = require("./Commands/SystemCommands");
35
35
  const ModulesLoader_1 = require("./Modules/ModulesLoader");
36
+ const NotificationService_1 = require("./Notifications/NotificationService");
36
37
  class ConsoleApplication {
37
38
  constructor() {
38
39
  this.modulesLoader = null;
@@ -62,6 +63,7 @@ class ConsoleApplication {
62
63
  Config_1.Config.register(key, options.config[key]);
63
64
  }
64
65
  }
66
+ NotificationService_1.NotificationService.init();
65
67
  if (options && options.errorHandler) {
66
68
  if (Array.isArray(options.errorHandler)) {
67
69
  ErrorHandler_1.ErrorHandler.setHandlers(options.errorHandler);
@@ -78,6 +80,7 @@ class ConsoleApplication {
78
80
  kernel: options && options.kernel ? options.kernel : null,
79
81
  options,
80
82
  });
83
+ NotificationService_1.NotificationService.registerTypes(this.modulesLoader.getNotifications());
81
84
  if (options && options.datatables) {
82
85
  DatatableRegistry_1.DatatableRegistry.registerMany(options.datatables);
83
86
  }
@@ -1,6 +1,7 @@
1
1
  import { KernelAiRegistrations } from "../Ai/AiTypes";
2
2
  import { ApiScopeRegistrationClass } from "../Api/ApiTypes";
3
3
  import { KernelMcpRegistrations } from "../Mcp/McpTypes";
4
+ import type { NotificationDefinition } from "../Notifications/NotificationService";
4
5
  export declare class ModuleProvider {
5
6
  static key: string;
6
7
  controller: {
@@ -11,6 +12,7 @@ export declare class ModuleProvider {
11
12
  };
12
13
  apiScopes: ApiScopeRegistrationClass[];
13
14
  commands: any[];
15
+ notifications: NotificationDefinition[];
14
16
  mcp?: KernelMcpRegistrations;
15
17
  ai?: KernelAiRegistrations;
16
18
  boot(_context?: any): void;
@@ -7,6 +7,7 @@ class ModuleProvider {
7
7
  this.middleware = {};
8
8
  this.apiScopes = [];
9
9
  this.commands = [];
10
+ this.notifications = [];
10
11
  }
11
12
  boot(_context) { }
12
13
  routes() { }
@@ -1,3 +1,4 @@
1
+ import type { NotificationDefinition } from "../Notifications/NotificationService";
1
2
  export declare class ModulesLoader {
2
3
  private loadedModules;
3
4
  load(modules: any[], context?: any): void;
@@ -6,6 +7,7 @@ export declare class ModulesLoader {
6
7
  };
7
8
  getLoadedModuleInstances(): any[];
8
9
  getCommands(): any[];
10
+ getNotifications(): NotificationDefinition[];
9
11
  initRoutes(): void;
10
12
  loadKernel(kernel: any): void;
11
13
  }
@@ -29,6 +29,16 @@ class ModulesLoader {
29
29
  }
30
30
  return commands;
31
31
  }
32
+ getNotifications() {
33
+ const notifications = [];
34
+ for (const key in this.loadedModules) {
35
+ const moduleNotifications = this.loadedModules[key].notifications;
36
+ if (Array.isArray(moduleNotifications)) {
37
+ notifications.push(...moduleNotifications);
38
+ }
39
+ }
40
+ return notifications;
41
+ }
32
42
  initRoutes() {
33
43
  for (let key in this.loadedModules) {
34
44
  this.loadedModules[key].routes();
@@ -0,0 +1,26 @@
1
+ import { Controller } from "../Controller/Controller";
2
+ import { Request } from "../Router/Request";
3
+ import { Response } from "../Router/Response";
4
+ import { Notification } from "./Notification";
5
+ import { NotificationTargetContext } from "./NotificationService";
6
+ export declare class BaseNotificationsController extends Controller {
7
+ endpoint(req: Request, res: Response): Promise<any>;
8
+ private getActionName;
9
+ protected getNotificationReference(req: Request): any;
10
+ protected serializeNotification(notification: Notification): object;
11
+ protected createNotification(req: Request, key: string, payload: Record<string, any>, targetContext: NotificationTargetContext): Promise<Notification | null>;
12
+ private parsePaginationValue;
13
+ private notificationNotFound;
14
+ private getAuthorizedTarget;
15
+ private getTypeForTarget;
16
+ definition(req: Request, res: Response): Promise<Response | undefined>;
17
+ create(req: Request, res: Response): Promise<Response | undefined>;
18
+ preferences(req: Request, res: Response): Promise<Response | undefined>;
19
+ savePreferences(req: Request, res: Response): Promise<Response | undefined>;
20
+ list(req: Request, res: Response): Promise<Response | undefined>;
21
+ counts(req: Request, res: Response): Promise<Response | undefined>;
22
+ details(req: Request, res: Response): Promise<Response | undefined>;
23
+ markOneAsRead(req: Request, res: Response): Promise<Response | undefined>;
24
+ markAllAsRead(req: Request, res: Response): Promise<Response | undefined>;
25
+ markAllAsViewed(req: Request, res: Response): Promise<Response | undefined>;
26
+ }
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseNotificationsController = void 0;
13
+ const Controller_1 = require("../Controller/Controller");
14
+ const NotificationService_1 = require("./NotificationService");
15
+ class BaseNotificationsController extends Controller_1.Controller {
16
+ endpoint(req, res) {
17
+ var _a;
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const actionName = this.getActionName((_a = req.body) === null || _a === void 0 ? void 0 : _a.__type);
20
+ const action = actionName ? this[actionName] : null;
21
+ if (typeof action !== "function") {
22
+ return res.status(400).send({ status: "error", message: "Invalid notification request." });
23
+ }
24
+ return yield action.call(this, req, res);
25
+ });
26
+ }
27
+ getActionName(type) {
28
+ return {
29
+ list: "list",
30
+ counts: "counts",
31
+ details: "details",
32
+ mark_one_as_read: "markOneAsRead",
33
+ mark_all_as_read: "markAllAsRead",
34
+ mark_all_as_viewed: "markAllAsViewed",
35
+ definition: "definition",
36
+ create: "create",
37
+ preferences: "preferences",
38
+ save_preferences: "savePreferences",
39
+ }[type];
40
+ }
41
+ getNotificationReference(req) {
42
+ var _a, _b, _c, _d, _e, _f, _g, _h;
43
+ return (_h = (_f = (_d = (_b = (_a = req.body) === null || _a === void 0 ? void 0 : _a._notification) !== null && _b !== void 0 ? _b : (_c = req.body) === null || _c === void 0 ? void 0 : _c.notification) !== null && _d !== void 0 ? _d : (_e = req.body) === null || _e === void 0 ? void 0 : _e._id) !== null && _f !== void 0 ? _f : (_g = req.body) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null;
44
+ }
45
+ serializeNotification(notification) {
46
+ return notification.toArray();
47
+ }
48
+ createNotification(req, key, payload, targetContext) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ return yield NotificationService_1.NotificationService.create(key, payload, Object.assign(Object.assign({}, targetContext), { request: req }));
51
+ });
52
+ }
53
+ parsePaginationValue(value, fallback, maximum) {
54
+ const parsed = Number(value);
55
+ if (!Number.isFinite(parsed) || parsed < 0)
56
+ return fallback;
57
+ const integer = Math.floor(parsed);
58
+ return maximum !== undefined ? Math.min(integer, maximum) : integer;
59
+ }
60
+ notificationNotFound(res) {
61
+ return res.status(404).send({ status: "error", message: "Notification not found." });
62
+ }
63
+ getAuthorizedTarget(req, res) {
64
+ var _a, _b;
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ try {
67
+ const context = yield NotificationService_1.NotificationService.authorizeTarget({
68
+ target: (_a = req.body) === null || _a === void 0 ? void 0 : _a.target,
69
+ target_id: (_b = req.body) === null || _b === void 0 ? void 0 : _b.target_id,
70
+ request: req,
71
+ });
72
+ if (!context) {
73
+ res.status(404).send({ status: "error", message: "Notification target not found." });
74
+ return null;
75
+ }
76
+ return context;
77
+ }
78
+ catch (error) {
79
+ if (error instanceof NotificationService_1.NotificationTargetValidationError) {
80
+ res.status(400).send({ status: "error", message: error.message });
81
+ return null;
82
+ }
83
+ throw error;
84
+ }
85
+ });
86
+ }
87
+ getTypeForTarget(key, target) {
88
+ const type = NotificationService_1.NotificationService.getTypeOrFail(key);
89
+ return type.targets.includes(target) ? type : null;
90
+ }
91
+ definition(req, res) {
92
+ var _a;
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const context = yield this.getAuthorizedTarget(req, res);
95
+ if (!context)
96
+ return;
97
+ const key = (_a = req.body) === null || _a === void 0 ? void 0 : _a.key;
98
+ if (typeof key !== "string" || key.trim() === "") {
99
+ return res.status(400).send({ status: "error", message: "Notification type key required." });
100
+ }
101
+ try {
102
+ if (!this.getTypeForTarget(key, context.target))
103
+ throw new Error("not available");
104
+ return res.send({
105
+ status: "success",
106
+ data: { definition: NotificationService_1.NotificationService.getPublicTypeDefinition(key) },
107
+ });
108
+ }
109
+ catch (_error) {
110
+ return res.status(404).send({ status: "error", message: "Notification type not found." });
111
+ }
112
+ });
113
+ }
114
+ create(req, res) {
115
+ var _a, _b;
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ const context = yield this.getAuthorizedTarget(req, res);
118
+ if (!context)
119
+ return;
120
+ const key = (_a = req.body) === null || _a === void 0 ? void 0 : _a.key;
121
+ if (typeof key !== "string" || key.trim() === "") {
122
+ return res.status(400).send({ status: "error", message: "Notification type key required." });
123
+ }
124
+ const payload = (_b = req.body) === null || _b === void 0 ? void 0 : _b.payload;
125
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
126
+ return res.status(400).send({ status: "error", message: "Notification payload must be an object." });
127
+ }
128
+ let type;
129
+ try {
130
+ type = this.getTypeForTarget(key, context.target);
131
+ }
132
+ catch (_error) {
133
+ type = null;
134
+ }
135
+ if (!type)
136
+ return res.status(404).send({ status: "error", message: "Notification type not found." });
137
+ if ((type.mode || "fixed") !== "changing" || !type.queueJobAutomation) {
138
+ return res.status(400).send({
139
+ status: "error",
140
+ message: "Notification type does not start an automated queue job.",
141
+ });
142
+ }
143
+ try {
144
+ const notification = yield this.createNotification(req, key, payload, context);
145
+ if (!notification) {
146
+ return res.status(403).send({ status: "error", message: "Notification type is disabled." });
147
+ }
148
+ return res.send({ status: "success", data: { entry: this.serializeNotification(notification) } });
149
+ }
150
+ catch (error) {
151
+ return res
152
+ .status(error instanceof NotificationService_1.NotificationPayloadValidationError ||
153
+ error instanceof NotificationService_1.NotificationTargetValidationError
154
+ ? 400
155
+ : 500)
156
+ .send({ status: "error", message: (error === null || error === void 0 ? void 0 : error.message) || "Notification could not be created." });
157
+ }
158
+ });
159
+ }
160
+ preferences(req, res) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const context = yield this.getAuthorizedTarget(req, res);
163
+ if (!context)
164
+ return;
165
+ const preferences = yield NotificationService_1.NotificationService.getTargetPreferences(context);
166
+ if (!preferences) {
167
+ return res.status(404).send({ status: "error", message: "Notification target not found." });
168
+ }
169
+ return res.send({ status: "success", data: preferences });
170
+ });
171
+ }
172
+ savePreferences(req, res) {
173
+ var _a, _b, _c;
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ const context = yield this.getAuthorizedTarget(req, res);
176
+ if (!context)
177
+ return;
178
+ const key = (_a = req.body) === null || _a === void 0 ? void 0 : _a.key;
179
+ const enabled = (_b = req.body) === null || _b === void 0 ? void 0 : _b.enabled;
180
+ const outputChannels = (_c = req.body) === null || _c === void 0 ? void 0 : _c.output_channels;
181
+ if (typeof key !== "string" || key.trim() === "") {
182
+ return res.status(400).send({ status: "error", message: "Notification type key required." });
183
+ }
184
+ if (typeof enabled !== "boolean") {
185
+ return res.status(400).send({ status: "error", message: "Enabled must be a boolean." });
186
+ }
187
+ if (!Array.isArray(outputChannels) || outputChannels.some((channel) => typeof channel !== "string")) {
188
+ return res.status(400).send({ status: "error", message: "Output channels must be an array of strings." });
189
+ }
190
+ try {
191
+ const entry = yield NotificationService_1.NotificationService.saveTargetPreference(key, { enabled, output_channels: outputChannels }, context);
192
+ if (!entry)
193
+ return res.status(404).send({ status: "error", message: "Notification target not found." });
194
+ return res.send({ status: "success", data: { entry } });
195
+ }
196
+ catch (error) {
197
+ return res.status(400).send({ status: "error", message: (error === null || error === void 0 ? void 0 : error.message) || "Preferences could not be saved." });
198
+ }
199
+ });
200
+ }
201
+ list(req, res) {
202
+ var _a, _b;
203
+ return __awaiter(this, void 0, void 0, function* () {
204
+ const context = yield this.getAuthorizedTarget(req, res);
205
+ if (!context)
206
+ return;
207
+ const offset = this.parsePaginationValue((_a = req.body) === null || _a === void 0 ? void 0 : _a.offset, 0);
208
+ const limit = this.parsePaginationValue((_b = req.body) === null || _b === void 0 ? void 0 : _b.limit, 10, 100) || 10;
209
+ const [loaded, unreadCount, unviewedCount] = yield Promise.all([
210
+ NotificationService_1.NotificationService.loadNotifications(Object.assign(Object.assign({}, context), { offset, limit: limit + 1 })),
211
+ NotificationService_1.NotificationService.getUnreadCount(context),
212
+ NotificationService_1.NotificationService.getUnviewedCount(context),
213
+ ]);
214
+ return res.send({
215
+ status: "success",
216
+ data: {
217
+ entries: loaded.slice(0, limit).map((entry) => this.serializeNotification(entry)),
218
+ unread_count: unreadCount,
219
+ unviewed_count: unviewedCount,
220
+ has_more: loaded.length > limit,
221
+ },
222
+ });
223
+ });
224
+ }
225
+ counts(req, res) {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ const context = yield this.getAuthorizedTarget(req, res);
228
+ if (!context)
229
+ return;
230
+ const [unreadCount, unviewedCount] = yield Promise.all([
231
+ NotificationService_1.NotificationService.getUnreadCount(context),
232
+ NotificationService_1.NotificationService.getUnviewedCount(context),
233
+ ]);
234
+ return res.send({ status: "success", data: { unread_count: unreadCount, unviewed_count: unviewedCount } });
235
+ });
236
+ }
237
+ details(req, res) {
238
+ return __awaiter(this, void 0, void 0, function* () {
239
+ const context = yield this.getAuthorizedTarget(req, res);
240
+ if (!context)
241
+ return;
242
+ const notification = yield NotificationService_1.NotificationService.getNotificationForTarget(this.getNotificationReference(req), context);
243
+ if (!notification)
244
+ return this.notificationNotFound(res);
245
+ return res.send({ status: "success", data: { entry: this.serializeNotification(notification) } });
246
+ });
247
+ }
248
+ markOneAsRead(req, res) {
249
+ return __awaiter(this, void 0, void 0, function* () {
250
+ const context = yield this.getAuthorizedTarget(req, res);
251
+ if (!context)
252
+ return;
253
+ const notification = yield NotificationService_1.NotificationService.getNotificationForTarget(this.getNotificationReference(req), context);
254
+ if (!notification)
255
+ return this.notificationNotFound(res);
256
+ const entry = yield NotificationService_1.NotificationService.markAsRead(notification);
257
+ return res.send({ status: "success", data: { entry: this.serializeNotification(entry) } });
258
+ });
259
+ }
260
+ markAllAsRead(req, res) {
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ const context = yield this.getAuthorizedTarget(req, res);
263
+ if (!context)
264
+ return;
265
+ yield NotificationService_1.NotificationService.markAllAsRead(context);
266
+ return res.send({ status: "success", data: { message: "All notifications marked as read." } });
267
+ });
268
+ }
269
+ markAllAsViewed(req, res) {
270
+ return __awaiter(this, void 0, void 0, function* () {
271
+ const context = yield this.getAuthorizedTarget(req, res);
272
+ if (!context)
273
+ return;
274
+ yield NotificationService_1.NotificationService.markAllAsViewed(context);
275
+ return res.send({ status: "success", data: { message: "All notifications marked as viewed." } });
276
+ });
277
+ }
278
+ }
279
+ exports.BaseNotificationsController = BaseNotificationsController;
@@ -0,0 +1,19 @@
1
+ import type { ObjectId } from "mongodb";
2
+ import { Model } from "../Database/Model";
3
+ import type { NotificationChangingStatus, NotificationModes, NotificationReadStatus, NotificationViewStatus } from "./NotificationService";
4
+ export declare class Notification extends Model {
5
+ target?: string;
6
+ target_id?: ObjectId;
7
+ targetModel?: any;
8
+ key?: string;
9
+ mode?: NotificationModes;
10
+ changing_status?: NotificationChangingStatus;
11
+ changing_error?: string | null;
12
+ _queue_job?: ObjectId;
13
+ _files?: ObjectId[];
14
+ read_status?: NotificationReadStatus;
15
+ read_at?: Date | null;
16
+ view_status?: NotificationViewStatus;
17
+ viewed_at?: Date | null;
18
+ __table: string;
19
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Notification = void 0;
4
+ const Model_1 = require("../Database/Model");
5
+ class Notification extends Model_1.Model {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.__table = "notifications";
9
+ }
10
+ }
11
+ exports.Notification = Notification;