@resolveio/server-lib 22.2.1 → 22.2.3

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.
Files changed (35) hide show
  1. package/collections/customer-notification.collection.d.ts +3 -0
  2. package/collections/customer-notification.collection.js +130 -0
  3. package/collections/customer-notification.collection.js.map +1 -0
  4. package/managers/local-log.manager.js +1 -2
  5. package/managers/local-log.manager.js.map +1 -1
  6. package/managers/method.manager.js +3 -2
  7. package/managers/method.manager.js.map +1 -1
  8. package/managers/mongo.manager.js +18 -36
  9. package/managers/mongo.manager.js.map +1 -1
  10. package/managers/monitor.manager.js +4 -8
  11. package/managers/monitor.manager.js.map +1 -1
  12. package/managers/subscription.manager.js +2 -0
  13. package/managers/subscription.manager.js.map +1 -1
  14. package/methods/customer-notifications.d.ts +2 -0
  15. package/methods/customer-notifications.js +460 -0
  16. package/methods/customer-notifications.js.map +1 -0
  17. package/methods/logs.js +2 -4
  18. package/methods/logs.js.map +1 -1
  19. package/methods.ts +12 -0
  20. package/models/customer-notification.model.d.ts +26 -0
  21. package/models/customer-notification.model.js +4 -0
  22. package/models/customer-notification.model.js.map +1 -0
  23. package/package.json +1 -1
  24. package/public_api.d.ts +2 -0
  25. package/public_api.js +2 -0
  26. package/public_api.js.map +1 -1
  27. package/publications/customer-notifications.d.ts +2 -0
  28. package/publications/customer-notifications.js +161 -0
  29. package/publications/customer-notifications.js.map +1 -0
  30. package/publications.ts +6 -0
  31. package/resolveio-server-app.d.ts +4 -0
  32. package/resolveio-server-app.js +38 -0
  33. package/resolveio-server-app.js.map +1 -1
  34. package/server-app.js +2 -4
  35. package/server-app.js.map +1 -1
@@ -0,0 +1,2 @@
1
+ import { MethodManager } from '../managers/method.manager';
2
+ export declare function loadCustomerNotificationMethods(methodManager: MethodManager): void;
@@ -0,0 +1,460 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.loadCustomerNotificationMethods = loadCustomerNotificationMethods;
51
+ var simpl_schema_1 = require("simpl-schema");
52
+ var customer_notification_collection_1 = require("../collections/customer-notification.collection");
53
+ var user_collection_1 = require("../collections/user.collection");
54
+ var common_1 = require("../util/common");
55
+ var DEFAULT_LIST_LIMIT = 100;
56
+ var MAX_LIST_LIMIT = 500;
57
+ var DEDUPE_WINDOW_MS = 30 * 60 * 1000;
58
+ var MAX_TARGET_USERS = 5000;
59
+ function normalizeString(value, maxLength) {
60
+ if (maxLength === void 0) { maxLength = 500; }
61
+ var normalized = String(value || '').trim();
62
+ if (!normalized) {
63
+ return '';
64
+ }
65
+ if (normalized.length <= maxLength) {
66
+ return normalized;
67
+ }
68
+ return normalized.slice(0, maxLength);
69
+ }
70
+ function normalizeNotificationCategory(value) {
71
+ var normalized = normalizeString(value, 40).toLowerCase();
72
+ if (!normalized) {
73
+ return 'system';
74
+ }
75
+ if (['autofix', 'slow-query', 'system', 'manual'].includes(normalized)) {
76
+ return normalized;
77
+ }
78
+ return 'system';
79
+ }
80
+ function normalizeNotificationSeverity(value) {
81
+ var normalized = normalizeString(value, 20).toLowerCase();
82
+ if (!normalized) {
83
+ return 'info';
84
+ }
85
+ if (['info', 'success', 'warning', 'error'].includes(normalized)) {
86
+ return normalized;
87
+ }
88
+ return 'info';
89
+ }
90
+ function normalizeListLimit(value) {
91
+ var parsed = Number(value);
92
+ if (!Number.isFinite(parsed) || parsed <= 0) {
93
+ return DEFAULT_LIST_LIMIT;
94
+ }
95
+ return Math.min(Math.floor(parsed), MAX_LIST_LIMIT);
96
+ }
97
+ function isSystemMethodUser(methodUser) {
98
+ return !methodUser || methodUser === 'Internal System';
99
+ }
100
+ function resolveMethodUser(methodUser, methodUserId) {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ var idUser;
103
+ return __generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0:
106
+ if (isSystemMethodUser(methodUser)) {
107
+ return [2 /*return*/, null];
108
+ }
109
+ if (typeof methodUser === 'object' && (methodUser === null || methodUser === void 0 ? void 0 : methodUser._id) && (methodUser === null || methodUser === void 0 ? void 0 : methodUser.roles)) {
110
+ return [2 /*return*/, methodUser];
111
+ }
112
+ idUser = normalizeString(typeof methodUserId === 'string'
113
+ ? methodUserId
114
+ : ((methodUserId === null || methodUserId === void 0 ? void 0 : methodUserId._id) ||
115
+ (methodUserId === null || methodUserId === void 0 ? void 0 : methodUserId.id_user) ||
116
+ (typeof methodUser === 'string'
117
+ ? methodUser
118
+ : ((methodUser === null || methodUser === void 0 ? void 0 : methodUser._id) || (methodUser === null || methodUser === void 0 ? void 0 : methodUser.id_user) || ''))), 80);
119
+ if (!idUser) {
120
+ return [2 /*return*/, null];
121
+ }
122
+ return [4 /*yield*/, user_collection_1.Users.findById(idUser)];
123
+ case 1: return [2 /*return*/, _a.sent()];
124
+ }
125
+ });
126
+ });
127
+ }
128
+ function isSuperAdmin(user) {
129
+ var _a;
130
+ return !!((_a = user === null || user === void 0 ? void 0 : user.roles) === null || _a === void 0 ? void 0 : _a.super_admin);
131
+ }
132
+ function uniqueUserIds(input) {
133
+ var e_1, _a;
134
+ var unique = new Set();
135
+ try {
136
+ for (var _b = __values((Array.isArray(input) ? input : [])), _c = _b.next(); !_c.done; _c = _b.next()) {
137
+ var entry = _c.value;
138
+ var id = normalizeString(entry, 80);
139
+ if (id) {
140
+ unique.add(id);
141
+ }
142
+ if (unique.size >= MAX_TARGET_USERS) {
143
+ break;
144
+ }
145
+ }
146
+ }
147
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
148
+ finally {
149
+ try {
150
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
151
+ }
152
+ finally { if (e_1) throw e_1.error; }
153
+ }
154
+ return Array.from(unique);
155
+ }
156
+ function resolveTargetUsers(payload) {
157
+ return __awaiter(this, void 0, void 0, function () {
158
+ var targetType, users_1, idClient, users;
159
+ return __generator(this, function (_a) {
160
+ switch (_a.label) {
161
+ case 0:
162
+ targetType = normalizeString((payload === null || payload === void 0 ? void 0 : payload.target_type) || 'client', 20).toLowerCase() || 'client';
163
+ if (targetType === 'users') {
164
+ return [2 /*return*/, uniqueUserIds((payload === null || payload === void 0 ? void 0 : payload.id_users) || [])];
165
+ }
166
+ if (!(targetType === 'all_active')) return [3 /*break*/, 2];
167
+ return [4 /*yield*/, user_collection_1.Users.find({
168
+ active: true,
169
+ username: {
170
+ $exists: true
171
+ }
172
+ }, {
173
+ projection: {
174
+ _id: 1
175
+ },
176
+ limit: MAX_TARGET_USERS
177
+ })];
178
+ case 1:
179
+ users_1 = _a.sent();
180
+ return [2 /*return*/, uniqueUserIds(users_1.map(function (user) { return user === null || user === void 0 ? void 0 : user._id; }))];
181
+ case 2:
182
+ idClient = normalizeString(payload === null || payload === void 0 ? void 0 : payload.id_client, 80);
183
+ if (!idClient) {
184
+ return [2 /*return*/, []];
185
+ }
186
+ return [4 /*yield*/, user_collection_1.Users.find({
187
+ active: true,
188
+ username: {
189
+ $exists: true
190
+ },
191
+ $or: [
192
+ { 'other.id_client': idClient },
193
+ { 'other.idClient': idClient },
194
+ { id_client: idClient }
195
+ ]
196
+ }, {
197
+ projection: {
198
+ _id: 1
199
+ },
200
+ limit: MAX_TARGET_USERS
201
+ })];
202
+ case 3:
203
+ users = _a.sent();
204
+ return [2 /*return*/, uniqueUserIds(users.map(function (user) { return user === null || user === void 0 ? void 0 : user._id; }))];
205
+ }
206
+ });
207
+ });
208
+ }
209
+ function loadCustomerNotificationMethods(methodManager) {
210
+ methodManager.methods({
211
+ createCustomerNotification: {
212
+ check: new simpl_schema_1.default({
213
+ payload: {
214
+ type: Object,
215
+ blackbox: true
216
+ }
217
+ }),
218
+ function: function (payload) {
219
+ return __awaiter(this, void 0, void 0, function () {
220
+ var methodUser, systemUser, title, message, idClient, clientName, category, severity, details, source, sourceId, actionLabel, actionRoute, dedupeKey, expiresAt, metadata, targetUsers, now, createById, createByName, skippedByDedupe, cutoff, existing, docs;
221
+ return __generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0: return [4 /*yield*/, resolveMethodUser(this.user, this.id_user)];
224
+ case 1:
225
+ methodUser = _a.sent();
226
+ systemUser = isSystemMethodUser(this.user);
227
+ if (!systemUser && !isSuperAdmin(methodUser)) {
228
+ throw new Error('Only super admins can create notifications.');
229
+ }
230
+ title = normalizeString(payload === null || payload === void 0 ? void 0 : payload.title, 160);
231
+ message = normalizeString(payload === null || payload === void 0 ? void 0 : payload.message, 1500);
232
+ if (!title || !message) {
233
+ throw new Error('Notification title and message are required.');
234
+ }
235
+ idClient = normalizeString(payload === null || payload === void 0 ? void 0 : payload.id_client, 80);
236
+ clientName = normalizeString(payload === null || payload === void 0 ? void 0 : payload.client_name, 200);
237
+ category = normalizeNotificationCategory(payload === null || payload === void 0 ? void 0 : payload.category);
238
+ severity = normalizeNotificationSeverity(payload === null || payload === void 0 ? void 0 : payload.severity);
239
+ details = normalizeString(payload === null || payload === void 0 ? void 0 : payload.details, 6000);
240
+ source = normalizeString(payload === null || payload === void 0 ? void 0 : payload.source, 120);
241
+ sourceId = normalizeString(payload === null || payload === void 0 ? void 0 : payload.source_id, 120);
242
+ actionLabel = normalizeString(payload === null || payload === void 0 ? void 0 : payload.action_label, 80);
243
+ actionRoute = normalizeString(payload === null || payload === void 0 ? void 0 : payload.action_route, 500);
244
+ dedupeKey = normalizeString(payload === null || payload === void 0 ? void 0 : payload.dedupe_key, 160);
245
+ expiresAt = (payload === null || payload === void 0 ? void 0 : payload.expires_at) instanceof Date && !Number.isNaN(payload.expires_at.getTime())
246
+ ? payload.expires_at
247
+ : undefined;
248
+ metadata = (payload === null || payload === void 0 ? void 0 : payload.metadata) && typeof payload.metadata === 'object'
249
+ ? payload.metadata
250
+ : undefined;
251
+ return [4 /*yield*/, resolveTargetUsers(payload)];
252
+ case 2:
253
+ targetUsers = _a.sent();
254
+ if (!targetUsers.length) {
255
+ return [2 /*return*/, {
256
+ created: 0,
257
+ reason: 'no_target_users'
258
+ }];
259
+ }
260
+ now = new Date();
261
+ createById = systemUser ? 'Internal System' : normalizeString(methodUser === null || methodUser === void 0 ? void 0 : methodUser._id, 80);
262
+ createByName = systemUser
263
+ ? 'Internal System'
264
+ : normalizeString((methodUser === null || methodUser === void 0 ? void 0 : methodUser.fullname) || (methodUser === null || methodUser === void 0 ? void 0 : methodUser.username), 200);
265
+ skippedByDedupe = new Set();
266
+ if (!dedupeKey) return [3 /*break*/, 4];
267
+ cutoff = new Date(now.getTime() - DEDUPE_WINDOW_MS);
268
+ return [4 /*yield*/, customer_notification_collection_1.CustomerNotifications.find({
269
+ id_user: {
270
+ $in: targetUsers
271
+ },
272
+ dedupe_key: dedupeKey,
273
+ createdAt: {
274
+ $gte: cutoff
275
+ }
276
+ }, {
277
+ projection: {
278
+ id_user: 1
279
+ },
280
+ limit: MAX_TARGET_USERS
281
+ })];
282
+ case 3:
283
+ existing = _a.sent();
284
+ skippedByDedupe = new Set(existing.map(function (entry) { return normalizeString(entry === null || entry === void 0 ? void 0 : entry.id_user, 80); }).filter(Boolean));
285
+ _a.label = 4;
286
+ case 4:
287
+ docs = targetUsers
288
+ .filter(function (idUser) { return !skippedByDedupe.has(idUser); })
289
+ .map(function (idUser) { return ({
290
+ _id: (0, common_1.objectIdHexString)(),
291
+ __v: 0,
292
+ id_user: idUser,
293
+ id_client: idClient || undefined,
294
+ client_name: clientName || undefined,
295
+ title: title,
296
+ message: message,
297
+ details: details || undefined,
298
+ category: category,
299
+ severity: severity,
300
+ status: 'unread',
301
+ read_at: undefined,
302
+ read_by: '',
303
+ source: source || undefined,
304
+ source_id: sourceId || undefined,
305
+ action_label: actionLabel || undefined,
306
+ action_route: actionRoute || undefined,
307
+ dedupe_key: dedupeKey || undefined,
308
+ metadata: metadata,
309
+ expires_at: expiresAt,
310
+ created_by: createById || undefined,
311
+ created_by_name: createByName || undefined,
312
+ createdAt: now,
313
+ updatedAt: now
314
+ }); });
315
+ if (!docs.length) {
316
+ return [2 /*return*/, {
317
+ created: 0,
318
+ reason: 'dedupe_suppressed'
319
+ }];
320
+ }
321
+ return [4 /*yield*/, customer_notification_collection_1.CustomerNotifications.insertMany(docs)];
322
+ case 5:
323
+ _a.sent();
324
+ return [2 /*return*/, {
325
+ created: docs.length,
326
+ targeted: targetUsers.length
327
+ }];
328
+ }
329
+ });
330
+ });
331
+ }
332
+ },
333
+ markUserNotificationRead: {
334
+ check: new simpl_schema_1.default({
335
+ id_notification: {
336
+ type: String
337
+ }
338
+ }),
339
+ function: function (id_notification) {
340
+ return __awaiter(this, void 0, void 0, function () {
341
+ var methodUser, idUser;
342
+ return __generator(this, function (_a) {
343
+ switch (_a.label) {
344
+ case 0: return [4 /*yield*/, resolveMethodUser(this.user, this.id_user)];
345
+ case 1:
346
+ methodUser = _a.sent();
347
+ idUser = normalizeString(methodUser === null || methodUser === void 0 ? void 0 : methodUser._id, 80);
348
+ if (!idUser) {
349
+ throw new Error('You must be logged in to mark notifications as read.');
350
+ }
351
+ return [4 /*yield*/, customer_notification_collection_1.CustomerNotifications.updateOne({
352
+ _id: id_notification,
353
+ id_user: idUser
354
+ }, {
355
+ $set: {
356
+ status: 'read',
357
+ read_at: new Date(),
358
+ read_by: idUser
359
+ }
360
+ })];
361
+ case 2:
362
+ _a.sent();
363
+ return [2 /*return*/, true];
364
+ }
365
+ });
366
+ });
367
+ }
368
+ },
369
+ markAllUserNotificationsRead: {
370
+ check: new simpl_schema_1.default({
371
+ id_client: {
372
+ type: String,
373
+ optional: true
374
+ }
375
+ }),
376
+ function: function (id_client) {
377
+ return __awaiter(this, void 0, void 0, function () {
378
+ var methodUser, idUser, idClient, query;
379
+ return __generator(this, function (_a) {
380
+ switch (_a.label) {
381
+ case 0: return [4 /*yield*/, resolveMethodUser(this.user, this.id_user)];
382
+ case 1:
383
+ methodUser = _a.sent();
384
+ idUser = normalizeString(methodUser === null || methodUser === void 0 ? void 0 : methodUser._id, 80);
385
+ if (!idUser) {
386
+ throw new Error('You must be logged in to mark notifications as read.');
387
+ }
388
+ idClient = normalizeString(id_client, 80);
389
+ query = {
390
+ id_user: idUser,
391
+ status: 'unread'
392
+ };
393
+ if (idClient) {
394
+ query.id_client = idClient;
395
+ }
396
+ return [4 /*yield*/, customer_notification_collection_1.CustomerNotifications.updateMany(query, {
397
+ $set: {
398
+ status: 'read',
399
+ read_at: new Date(),
400
+ read_by: idUser
401
+ }
402
+ })];
403
+ case 2:
404
+ _a.sent();
405
+ return [2 /*return*/, true];
406
+ }
407
+ });
408
+ });
409
+ }
410
+ },
411
+ listCustomerNotifications: {
412
+ check: new simpl_schema_1.default({
413
+ payload: {
414
+ type: Object,
415
+ optional: true,
416
+ blackbox: true
417
+ }
418
+ }),
419
+ function: function (payload) {
420
+ return __awaiter(this, void 0, void 0, function () {
421
+ var methodUser, systemUser, query, idUser, idClient, status, limit;
422
+ return __generator(this, function (_a) {
423
+ switch (_a.label) {
424
+ case 0: return [4 /*yield*/, resolveMethodUser(this.user, this.id_user)];
425
+ case 1:
426
+ methodUser = _a.sent();
427
+ systemUser = isSystemMethodUser(this.user);
428
+ if (!systemUser && !isSuperAdmin(methodUser)) {
429
+ throw new Error('Only super admins can list all notifications.');
430
+ }
431
+ query = {};
432
+ idUser = normalizeString(payload === null || payload === void 0 ? void 0 : payload.id_user, 80);
433
+ idClient = normalizeString(payload === null || payload === void 0 ? void 0 : payload.id_client, 80);
434
+ status = normalizeString(payload === null || payload === void 0 ? void 0 : payload.status, 20).toLowerCase();
435
+ if (idUser) {
436
+ query.id_user = idUser;
437
+ }
438
+ if (idClient) {
439
+ query.id_client = idClient;
440
+ }
441
+ if (status === 'unread' || status === 'read') {
442
+ query.status = status;
443
+ }
444
+ limit = normalizeListLimit(payload === null || payload === void 0 ? void 0 : payload.limit);
445
+ return [4 /*yield*/, customer_notification_collection_1.CustomerNotifications.find(query, {
446
+ sort: {
447
+ createdAt: -1
448
+ },
449
+ limit: limit
450
+ })];
451
+ case 2: return [2 /*return*/, _a.sent()];
452
+ }
453
+ });
454
+ });
455
+ }
456
+ }
457
+ });
458
+ }
459
+
460
+ //# sourceMappingURL=customer-notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/methods/customer-notifications.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6KA,0EAyNC;AAtYD,6CAAwC;AACxC,oGAAwF;AACxF,kEAAuD;AAEvD,yCAAmD;AAEnD,IAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,IAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,IAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACxC,IAAM,gBAAgB,GAAG,IAAI,CAAC;AA4B9B,SAAS,eAAe,CAAC,KAAU,EAAE,SAAe;IAAf,0BAAA,EAAA,eAAe;IACnD,IAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QACpC,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAA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CAC9C,IAAI,EAAE;4CACL,SAAS,EAAE,CAAC,CAAC;yCACb;wCACD,KAAK,OAAA;qCACL,CAAC,EAAA;oCALF,sBAAO,SAKL,EAAC;;;;aACH;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"customer-notifications.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { CustomerNotifications } from '../collections/customer-notification.collection';\nimport { Users } from '../collections/user.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { objectIdHexString } from '../util/common';\n\nconst DEFAULT_LIST_LIMIT = 100;\nconst MAX_LIST_LIMIT = 500;\nconst DEDUPE_WINDOW_MS = 30 * 60 * 1000;\nconst MAX_TARGET_USERS = 5000;\n\ntype CreateCustomerNotificationPayload = {\n\ttitle: string;\n\tmessage: string;\n\tdetails?: string;\n\tcategory?: string;\n\tseverity?: string;\n\ttarget_type?: 'client' | 'users' | 'all_active';\n\tid_client?: string;\n\tclient_name?: string;\n\tid_users?: string[];\n\tsource?: string;\n\tsource_id?: string;\n\taction_label?: string;\n\taction_route?: string;\n\tdedupe_key?: string;\n\texpires_at?: Date;\n\tmetadata?: Record<string, any>;\n};\n\ntype ListCustomerNotificationsPayload = {\n\tid_user?: string;\n\tid_client?: string;\n\tstatus?: 'unread' | 'read';\n\tlimit?: number;\n};\n\nfunction normalizeString(value: any, maxLength = 500): string {\n\tconst normalized = String(value || '').trim();\n\tif (!normalized) {\n\t\treturn '';\n\t}\n\tif (normalized.length <= maxLength) {\n\t\treturn normalized;\n\t}\n\treturn normalized.slice(0, maxLength);\n}\n\nfunction normalizeNotificationCategory(value?: string): string {\n\tconst normalized = normalizeString(value, 40).toLowerCase();\n\tif (!normalized) {\n\t\treturn 'system';\n\t}\n\tif (['autofix', 'slow-query', 'system', 'manual'].includes(normalized)) {\n\t\treturn normalized;\n\t}\n\treturn 'system';\n}\n\nfunction normalizeNotificationSeverity(value?: string): string {\n\tconst normalized = normalizeString(value, 20).toLowerCase();\n\tif (!normalized) {\n\t\treturn 'info';\n\t}\n\tif (['info', 'success', 'warning', 'error'].includes(normalized)) {\n\t\treturn normalized;\n\t}\n\treturn 'info';\n}\n\nfunction normalizeListLimit(value?: number): number {\n\tconst parsed = Number(value);\n\tif (!Number.isFinite(parsed) || parsed <= 0) {\n\t\treturn DEFAULT_LIST_LIMIT;\n\t}\n\treturn Math.min(Math.floor(parsed), MAX_LIST_LIMIT);\n}\n\nfunction isSystemMethodUser(methodUser: any): boolean {\n\treturn !methodUser || methodUser === 'Internal System';\n}\n\nasync function resolveMethodUser(methodUser: any, methodUserId?: any): Promise<any | null> {\n\tif (isSystemMethodUser(methodUser)) {\n\t\treturn null;\n\t}\n\n\tif (typeof methodUser === 'object' && methodUser?._id && methodUser?.roles) {\n\t\treturn methodUser;\n\t}\n\n\tconst idUser = normalizeString(\n\t\ttypeof methodUserId === 'string'\n\t\t\t? methodUserId\n\t\t\t: (\n\t\t\t\tmethodUserId?._id ||\n\t\t\t\tmethodUserId?.id_user ||\n\t\t\t\t(typeof methodUser === 'string'\n\t\t\t\t\t? methodUser\n\t\t\t\t\t: (methodUser?._id || methodUser?.id_user || ''))\n\t\t\t),\n\t\t80\n\t);\n\tif (!idUser) {\n\t\treturn null;\n\t}\n\treturn await Users.findById(idUser);\n}\n\nfunction isSuperAdmin(user: any): boolean {\n\treturn !!user?.roles?.super_admin;\n}\n\nfunction uniqueUserIds(input: string[]): string[] {\n\tconst unique = new Set<string>();\n\tfor (const entry of (Array.isArray(input) ? input : [])) {\n\t\tconst id = normalizeString(entry, 80);\n\t\tif (id) {\n\t\t\tunique.add(id);\n\t\t}\n\t\tif (unique.size >= MAX_TARGET_USERS) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn Array.from(unique);\n}\n\nasync function resolveTargetUsers(payload: CreateCustomerNotificationPayload): Promise<string[]> {\n\tconst targetType = normalizeString(payload?.target_type || 'client', 20).toLowerCase() || 'client';\n\tif (targetType === 'users') {\n\t\treturn uniqueUserIds(payload?.id_users || []);\n\t}\n\n\tif (targetType === 'all_active') {\n\t\tconst users = await Users.find({\n\t\t\tactive: true,\n\t\t\tusername: {\n\t\t\t\t$exists: true\n\t\t\t}\n\t\t}, {\n\t\t\tprojection: {\n\t\t\t\t_id: 1\n\t\t\t},\n\t\t\tlimit: MAX_TARGET_USERS\n\t\t});\n\t\treturn uniqueUserIds(users.map((user: any) => user?._id));\n\t}\n\n\tconst idClient = normalizeString(payload?.id_client, 80);\n\tif (!idClient) {\n\t\treturn [];\n\t}\n\n\tconst users = await Users.find({\n\t\tactive: true,\n\t\tusername: {\n\t\t\t$exists: true\n\t\t},\n\t\t$or: [\n\t\t\t{'other.id_client': idClient},\n\t\t\t{'other.idClient': idClient},\n\t\t\t{id_client: idClient}\n\t\t]\n\t}, {\n\t\tprojection: {\n\t\t\t_id: 1\n\t\t},\n\t\tlimit: MAX_TARGET_USERS\n\t});\n\n\treturn uniqueUserIds(users.map((user: any) => user?._id));\n}\n\nexport function loadCustomerNotificationMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tcreateCustomerNotification: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tpayload: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(payload: CreateCustomerNotificationPayload) {\n\t\t\t\tconst methodUser = await resolveMethodUser(this.user, this.id_user);\n\t\t\t\tconst systemUser = isSystemMethodUser(this.user);\n\t\t\t\tif (!systemUser && !isSuperAdmin(methodUser)) {\n\t\t\t\t\tthrow new Error('Only super admins can create notifications.');\n\t\t\t\t}\n\n\t\t\t\tconst title = normalizeString(payload?.title, 160);\n\t\t\t\tconst message = normalizeString(payload?.message, 1500);\n\t\t\t\tif (!title || !message) {\n\t\t\t\t\tthrow new Error('Notification title and message are required.');\n\t\t\t\t}\n\n\t\t\t\tconst idClient = normalizeString(payload?.id_client, 80);\n\t\t\t\tconst clientName = normalizeString(payload?.client_name, 200);\n\t\t\t\tconst category = normalizeNotificationCategory(payload?.category);\n\t\t\t\tconst severity = normalizeNotificationSeverity(payload?.severity);\n\t\t\t\tconst details = normalizeString(payload?.details, 6000);\n\t\t\t\tconst source = normalizeString(payload?.source, 120);\n\t\t\t\tconst sourceId = normalizeString(payload?.source_id, 120);\n\t\t\t\tconst actionLabel = normalizeString(payload?.action_label, 80);\n\t\t\t\tconst actionRoute = normalizeString(payload?.action_route, 500);\n\t\t\t\tconst dedupeKey = normalizeString(payload?.dedupe_key, 160);\n\t\t\t\tconst expiresAt = payload?.expires_at instanceof Date && !Number.isNaN(payload.expires_at.getTime())\n\t\t\t\t\t? payload.expires_at\n\t\t\t\t\t: undefined;\n\t\t\t\tconst metadata = payload?.metadata && typeof payload.metadata === 'object'\n\t\t\t\t\t? payload.metadata\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst targetUsers = await resolveTargetUsers(payload);\n\t\t\t\tif (!targetUsers.length) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcreated: 0,\n\t\t\t\t\t\treason: 'no_target_users'\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst createById = systemUser ? 'Internal System' : normalizeString(methodUser?._id, 80);\n\t\t\t\tconst createByName = systemUser\n\t\t\t\t\t? 'Internal System'\n\t\t\t\t\t: normalizeString(methodUser?.fullname || methodUser?.username, 200);\n\n\t\t\t\tlet skippedByDedupe = new Set<string>();\n\t\t\t\tif (dedupeKey) {\n\t\t\t\t\tconst cutoff = new Date(now.getTime() - DEDUPE_WINDOW_MS);\n\t\t\t\t\tconst existing = await CustomerNotifications.find({\n\t\t\t\t\t\tid_user: {\n\t\t\t\t\t\t\t$in: targetUsers\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdedupe_key: dedupeKey,\n\t\t\t\t\t\tcreatedAt: {\n\t\t\t\t\t\t\t$gte: cutoff\n\t\t\t\t\t\t}\n\t\t\t\t\t}, {\n\t\t\t\t\t\tprojection: {\n\t\t\t\t\t\t\tid_user: 1\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlimit: MAX_TARGET_USERS\n\t\t\t\t\t});\n\t\t\t\t\tskippedByDedupe = new Set(existing.map(entry => normalizeString(entry?.id_user, 80)).filter(Boolean));\n\t\t\t\t}\n\n\t\t\t\tconst docs = targetUsers\n\t\t\t\t\t.filter(idUser => !skippedByDedupe.has(idUser))\n\t\t\t\t\t.map((idUser) => ({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tid_user: idUser,\n\t\t\t\t\t\tid_client: idClient || undefined,\n\t\t\t\t\t\tclient_name: clientName || undefined,\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tdetails: details || undefined,\n\t\t\t\t\t\tcategory,\n\t\t\t\t\t\tseverity,\n\t\t\t\t\t\tstatus: 'unread',\n\t\t\t\t\t\tread_at: undefined,\n\t\t\t\t\t\tread_by: '',\n\t\t\t\t\t\tsource: source || undefined,\n\t\t\t\t\t\tsource_id: sourceId || undefined,\n\t\t\t\t\t\taction_label: actionLabel || undefined,\n\t\t\t\t\t\taction_route: actionRoute || undefined,\n\t\t\t\t\t\tdedupe_key: dedupeKey || undefined,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\texpires_at: expiresAt,\n\t\t\t\t\t\tcreated_by: createById || undefined,\n\t\t\t\t\t\tcreated_by_name: createByName || undefined,\n\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\tupdatedAt: now\n\t\t\t\t\t}));\n\n\t\t\t\tif (!docs.length) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcreated: 0,\n\t\t\t\t\t\treason: 'dedupe_suppressed'\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tawait CustomerNotifications.insertMany(docs as any[]);\n\n\t\t\t\treturn {\n\t\t\t\t\tcreated: docs.length,\n\t\t\t\t\ttargeted: targetUsers.length\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\tmarkUserNotificationRead: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_notification: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(id_notification: string) {\n\t\t\t\tconst methodUser = await resolveMethodUser(this.user, this.id_user);\n\t\t\t\tconst idUser = normalizeString(methodUser?._id, 80);\n\t\t\t\tif (!idUser) {\n\t\t\t\t\tthrow new Error('You must be logged in to mark notifications as read.');\n\t\t\t\t}\n\n\t\t\t\tawait CustomerNotifications.updateOne({\n\t\t\t\t\t_id: id_notification,\n\t\t\t\t\tid_user: idUser\n\t\t\t\t}, {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tstatus: 'read',\n\t\t\t\t\t\tread_at: new Date(),\n\t\t\t\t\t\tread_by: idUser\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tmarkAllUserNotificationsRead: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_client: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(id_client?: string) {\n\t\t\t\tconst methodUser = await resolveMethodUser(this.user, this.id_user);\n\t\t\t\tconst idUser = normalizeString(methodUser?._id, 80);\n\t\t\t\tif (!idUser) {\n\t\t\t\t\tthrow new Error('You must be logged in to mark notifications as read.');\n\t\t\t\t}\n\n\t\t\t\tconst idClient = normalizeString(id_client, 80);\n\t\t\t\tconst query: Record<string, any> = {\n\t\t\t\t\tid_user: idUser,\n\t\t\t\t\tstatus: 'unread'\n\t\t\t\t};\n\t\t\t\tif (idClient) {\n\t\t\t\t\tquery.id_client = idClient;\n\t\t\t\t}\n\n\t\t\t\tawait CustomerNotifications.updateMany(query, {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tstatus: 'read',\n\t\t\t\t\t\tread_at: new Date(),\n\t\t\t\t\t\tread_by: idUser\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tlistCustomerNotifications: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tpayload: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\toptional: true,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(payload?: ListCustomerNotificationsPayload) {\n\t\t\t\tconst methodUser = await resolveMethodUser(this.user, this.id_user);\n\t\t\t\tconst systemUser = isSystemMethodUser(this.user);\n\t\t\t\tif (!systemUser && !isSuperAdmin(methodUser)) {\n\t\t\t\t\tthrow new Error('Only super admins can list all notifications.');\n\t\t\t\t}\n\n\t\t\t\tconst query: Record<string, any> = {};\n\t\t\t\tconst idUser = normalizeString(payload?.id_user, 80);\n\t\t\t\tconst idClient = normalizeString(payload?.id_client, 80);\n\t\t\t\tconst status = normalizeString(payload?.status, 20).toLowerCase();\n\t\t\t\tif (idUser) {\n\t\t\t\t\tquery.id_user = idUser;\n\t\t\t\t}\n\t\t\t\tif (idClient) {\n\t\t\t\t\tquery.id_client = idClient;\n\t\t\t\t}\n\t\t\t\tif (status === 'unread' || status === 'read') {\n\t\t\t\t\tquery.status = status;\n\t\t\t\t}\n\n\t\t\t\tconst limit = normalizeListLimit(payload?.limit);\n\t\t\t\treturn await CustomerNotifications.find(query, {\n\t\t\t\t\tsort: {\n\t\t\t\t\t\tcreatedAt: -1\n\t\t\t\t\t},\n\t\t\t\t\tlimit\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
package/methods/logs.js CHANGED
@@ -83,8 +83,7 @@ function loadLogMethods(methodManager) {
83
83
  })];
84
84
  case 1:
85
85
  _d.sent();
86
- if (!(resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'
87
- && resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200')) return [3 /*break*/, 2];
86
+ if (!resolveio_server_app_1.ResolveIOServer.shouldWriteLogsOffline()) return [3 /*break*/, 2];
88
87
  resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({
89
88
  type: 'log',
90
89
  data: {
@@ -136,8 +135,7 @@ function loadLogMethods(methodManager) {
136
135
  return __generator(this, function (_a) {
137
136
  switch (_a.label) {
138
137
  case 0:
139
- if (!(resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'
140
- && resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200')) return [3 /*break*/, 1];
138
+ if (!resolveio_server_app_1.ResolveIOServer.shouldWriteLogsOffline()) return [3 /*break*/, 1];
141
139
  resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({
142
140
  type: 'log-subscription',
143
141
  data: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wCAkYC;AA3YD,8FAAkF;AAClF,0FAA8E;AAC9E,gEAAqD;AAErD,gEAA0D;AAC1D,yCAAmD;AACnD,yDAAuD;AACvD,yDAA0D;AAE1D,SAAgB,cAAc,CAAC,aAA4B;IACzD,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAe,OAAO,EAAE,IAAI;;;;;;;gCAC/B,oBAAoB,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI;oCAC5D,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC;2CAC5D,CAAC,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;oCAC9H,CAAC,CAAC,SAAS,CAAC;gCACP,aAA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,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,eAAe,GAAG,SAwB6G;gCAEhH,qBAAM,8CAAgB,CAAC,SAAS,CAAC;wCACnD;4CACC,MAAM,EAAE;gDACP,IAAI,EAAE;oDACL;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,UAAU,EAAC;qDAC7B;oDACD;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;qDAC3B;iDACD;6CACD;yCACD;wCACD;4CACC,MAAM,EAAE;gDACP,GAAG,EAAE,OAAO;gDACZ,KAAK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,YAAY,GAAG,SAwBgH;gCAEnI,sBAAO;wCACN,OAAO,EAAE,SAAS;wCAClB,aAAa,EAAE,aAAa;wCAC5B,eAAe,EAAE,eAAe;wCAChC,YAAY,EAAE,YAAY;qCAC1B,EAAC;;;;aACF;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC","file":"logs.js","sourcesContent":["import { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { Logs } from '../collections/log.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\nimport { getCorrelationId } from '../util/error-tracking';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\t\tmethodManager.methods({\n\t\t\tinsertErrorLog: {\n\t\t\t\tfunction: async function(message, data) {\n\t\t\t\t\tconst payloadCorrelationId = typeof data === 'object' && data\n\t\t\t\t\t\t? (typeof data.correlationId === 'string' && data.correlationId)\n\t\t\t\t\t\t\t|| (typeof data.error === 'object' && data.error && typeof data.error.correlationId === 'string' && data.error.correlationId)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst correlationId = getCorrelationId() || payloadCorrelationId || objectIdHexString();\n\t\t\t\t\tconst payload = {\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\tdata,\n\t\t\t\t\tcorrelationId\n\t\t\t\t};\n\n\t\t\t\tawait ErrorReporter.report({\n\t\t\t\t\tsourceApp: 'method-logs',\n\t\t\t\t\tmessage: 'Error Detected - ' + ResolveIOServer.getClientName(),\n\t\t\t\t\tenvironment: this.serverConfig?.ROOT_URL || ResolveIOServer.getServerConfig()?.ROOT_URL,\n\t\t\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\t\t\tclientName: ResolveIOServer.getServerConfig()?.CLIENT_NAME,\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t\tcontext: payload,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tcontext: 'insertErrorLog',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t},\n\t\t\t\t\tcorrelationId\n\t\t\t\t});\n\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\troute: '',\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '0',\n\t\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '0',\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: async function(type, subscription, collection_name, subData) {\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log-subscription',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '0'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait LogSubscriptions.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com'\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: async function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet groupId = {};\n\t\t\t\tlet groupSort = {};\n\n\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\treturn {\n\t\t\t\t\tmethods: latencies,\n\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t};\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wCAgYC;AAzYD,8FAAkF;AAClF,0FAA8E;AAC9E,gEAAqD;AAErD,gEAA0D;AAC1D,yCAAmD;AACnD,yDAAuD;AACvD,yDAA0D;AAE1D,SAAgB,cAAc,CAAC,aAA4B;IACzD,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAe,OAAO,EAAE,IAAI;;;;;;;gCAC/B,oBAAoB,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI;oCAC5D,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC;2CAC5D,CAAC,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;oCAC9H,CAAC,CAAC,SAAS,CAAC;gCACP,aAAa,GAAG,IAAA,iCAAgB,GAAE,IAAI,oBAAoB,IAAI,IAAA,0BAAiB,GAAE,CAAC;gCAClF,OAAO,GAAG;oCACf,IAAI,EAAE,IAAI,CAAC,IAAI;oCACf,OAAO,EAAE,IAAI,CAAC,OAAO;oCACrB,OAAO,SAAA;oCAC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AK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,YAAY,GAAG,SAwBgH;gCAEnI,sBAAO;wCACN,OAAO,EAAE,SAAS;wCAClB,aAAa,EAAE,aAAa;wCAC5B,eAAe,EAAE,eAAe;wCAChC,YAAY,EAAE,YAAY;qCAC1B,EAAC;;;;aACF;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC","file":"logs.js","sourcesContent":["import { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { Logs } from '../collections/log.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\nimport { getCorrelationId } from '../util/error-tracking';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\t\tmethodManager.methods({\n\t\t\tinsertErrorLog: {\n\t\t\t\tfunction: async function(message, data) {\n\t\t\t\t\tconst payloadCorrelationId = typeof data === 'object' && data\n\t\t\t\t\t\t? (typeof data.correlationId === 'string' && data.correlationId)\n\t\t\t\t\t\t\t|| (typeof data.error === 'object' && data.error && typeof data.error.correlationId === 'string' && data.error.correlationId)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst correlationId = getCorrelationId() || payloadCorrelationId || objectIdHexString();\n\t\t\t\t\tconst payload = {\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\tdata,\n\t\t\t\t\tcorrelationId\n\t\t\t\t};\n\n\t\t\t\tawait ErrorReporter.report({\n\t\t\t\t\tsourceApp: 'method-logs',\n\t\t\t\t\tmessage: 'Error Detected - ' + ResolveIOServer.getClientName(),\n\t\t\t\t\tenvironment: this.serverConfig?.ROOT_URL || ResolveIOServer.getServerConfig()?.ROOT_URL,\n\t\t\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\t\t\tclientName: ResolveIOServer.getServerConfig()?.CLIENT_NAME,\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t\tcontext: payload,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tcontext: 'insertErrorLog',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t},\n\t\t\t\t\tcorrelationId\n\t\t\t\t});\n\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.shouldWriteLogsOffline()\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\troute: '',\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '0',\n\t\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '0',\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: async function(type, subscription, collection_name, subData) {\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.shouldWriteLogsOffline()\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log-subscription',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '0'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait LogSubscriptions.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com'\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: async function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet groupId = {};\n\t\t\t\tlet groupSort = {};\n\n\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\treturn {\n\t\t\t\t\tmethods: latencies,\n\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t};\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}\n"]}