@resolveio/server-lib 22.2.0 → 22.2.2
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/collections/customer-notification.collection.d.ts +3 -0
- package/collections/customer-notification.collection.js +130 -0
- package/collections/customer-notification.collection.js.map +1 -0
- package/managers/local-log.manager.js +1 -2
- package/managers/local-log.manager.js.map +1 -1
- package/managers/method.manager.js +3 -2
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +18 -36
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +4 -8
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +2 -0
- package/managers/subscription.manager.js.map +1 -1
- package/methods/ai-terminal.js +5 -2
- package/methods/ai-terminal.js.map +1 -1
- package/methods/customer-notifications.d.ts +2 -0
- package/methods/customer-notifications.js +456 -0
- package/methods/customer-notifications.js.map +1 -0
- package/methods/logs.js +2 -4
- package/methods/logs.js.map +1 -1
- package/methods/mongo-explorer.js +2 -6
- package/methods/mongo-explorer.js.map +1 -1
- package/methods.ts +12 -0
- package/models/customer-notification.model.d.ts +26 -0
- package/models/customer-notification.model.js +4 -0
- package/models/customer-notification.model.js.map +1 -0
- package/package.json +1 -1
- package/public_api.d.ts +2 -0
- package/public_api.js +2 -0
- package/public_api.js.map +1 -1
- package/publications/customer-notifications.d.ts +2 -0
- package/publications/customer-notifications.js +161 -0
- package/publications/customer-notifications.js.map +1 -0
- package/publications.ts +6 -0
- package/resolveio-server-app.d.ts +4 -0
- package/resolveio-server-app.js +38 -0
- package/resolveio-server-app.js.map +1 -1
- package/server-app.js +2 -4
- package/server-app.js.map +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomerNotifications = void 0;
|
|
4
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
5
|
+
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
6
|
+
var schema = {
|
|
7
|
+
_id: {
|
|
8
|
+
type: String,
|
|
9
|
+
optional: true
|
|
10
|
+
},
|
|
11
|
+
__v: {
|
|
12
|
+
type: Number,
|
|
13
|
+
optional: true
|
|
14
|
+
},
|
|
15
|
+
updatedAt: {
|
|
16
|
+
type: Date,
|
|
17
|
+
optional: true
|
|
18
|
+
},
|
|
19
|
+
createdAt: {
|
|
20
|
+
type: Date,
|
|
21
|
+
optional: true
|
|
22
|
+
},
|
|
23
|
+
id_user: {
|
|
24
|
+
type: String
|
|
25
|
+
},
|
|
26
|
+
id_client: {
|
|
27
|
+
type: String,
|
|
28
|
+
optional: true
|
|
29
|
+
},
|
|
30
|
+
client_name: {
|
|
31
|
+
type: String,
|
|
32
|
+
optional: true
|
|
33
|
+
},
|
|
34
|
+
title: {
|
|
35
|
+
type: String
|
|
36
|
+
},
|
|
37
|
+
message: {
|
|
38
|
+
type: String
|
|
39
|
+
},
|
|
40
|
+
details: {
|
|
41
|
+
type: String,
|
|
42
|
+
optional: true
|
|
43
|
+
},
|
|
44
|
+
category: {
|
|
45
|
+
type: String,
|
|
46
|
+
optional: true
|
|
47
|
+
},
|
|
48
|
+
severity: {
|
|
49
|
+
type: String,
|
|
50
|
+
optional: true
|
|
51
|
+
},
|
|
52
|
+
status: {
|
|
53
|
+
type: String,
|
|
54
|
+
allowedValues: ['unread', 'read']
|
|
55
|
+
},
|
|
56
|
+
read_at: {
|
|
57
|
+
type: Date,
|
|
58
|
+
optional: true
|
|
59
|
+
},
|
|
60
|
+
read_by: {
|
|
61
|
+
type: String,
|
|
62
|
+
optional: true
|
|
63
|
+
},
|
|
64
|
+
source: {
|
|
65
|
+
type: String,
|
|
66
|
+
optional: true
|
|
67
|
+
},
|
|
68
|
+
source_id: {
|
|
69
|
+
type: String,
|
|
70
|
+
optional: true
|
|
71
|
+
},
|
|
72
|
+
action_label: {
|
|
73
|
+
type: String,
|
|
74
|
+
optional: true
|
|
75
|
+
},
|
|
76
|
+
action_route: {
|
|
77
|
+
type: String,
|
|
78
|
+
optional: true
|
|
79
|
+
},
|
|
80
|
+
dedupe_key: {
|
|
81
|
+
type: String,
|
|
82
|
+
optional: true
|
|
83
|
+
},
|
|
84
|
+
metadata: {
|
|
85
|
+
type: Object,
|
|
86
|
+
optional: true,
|
|
87
|
+
blackbox: true
|
|
88
|
+
},
|
|
89
|
+
expires_at: {
|
|
90
|
+
type: Date,
|
|
91
|
+
optional: true
|
|
92
|
+
},
|
|
93
|
+
created_by: {
|
|
94
|
+
type: String,
|
|
95
|
+
optional: true
|
|
96
|
+
},
|
|
97
|
+
created_by_name: {
|
|
98
|
+
type: String,
|
|
99
|
+
optional: true
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.CustomerNotifications = null;
|
|
103
|
+
initializeCollection();
|
|
104
|
+
function initializeCollection() {
|
|
105
|
+
if (resolveio_server_app_1.ResolveIOServer && resolveio_server_app_1.ResolveIOServer.getMainDB() && mongo_manager_1.MongoManagerModel) {
|
|
106
|
+
var model = mongo_manager_1.MongoManagerModel.create({
|
|
107
|
+
collectionName: 'customer-notifications',
|
|
108
|
+
schema: schema,
|
|
109
|
+
useVersionCollection: false,
|
|
110
|
+
useReportBuilder: false,
|
|
111
|
+
reportBuilderLookupTables: [],
|
|
112
|
+
timestamps: true,
|
|
113
|
+
createLogs: false,
|
|
114
|
+
checkSchema: true,
|
|
115
|
+
collectionOptions: null
|
|
116
|
+
});
|
|
117
|
+
exports.CustomerNotifications = model.collection_main;
|
|
118
|
+
exports.CustomerNotifications.createIndex({ id_user: 1, status: 1, createdAt: -1 });
|
|
119
|
+
exports.CustomerNotifications.createIndex({ id_client: 1, createdAt: -1 });
|
|
120
|
+
exports.CustomerNotifications.createIndex({ dedupe_key: 1, id_user: 1, createdAt: -1 });
|
|
121
|
+
exports.CustomerNotifications.createIndex({ expires_at: 1 }, { expireAfterSeconds: 0 });
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
setImmediate(function () {
|
|
125
|
+
initializeCollection();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=customer-notification.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/customer-notification.collection.ts"],"names":[],"mappings":";;;AAAA,2DAAsF;AAEtF,gEAA0D;AAE1D,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACR,IAAI,EAAE,MAAM;KACZ;IACD,SAAS,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,WAAW,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,KAAK,EAAE;QACN,IAAI,EAAE,MAAM;KACZ;IACD,OAAO,EAAE;QACR,IAAI,EAAE,MAAM;KACZ;IACD,OAAO,EAAE;QACR,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,MAAM,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;KACjC;IACD,OAAO,EAAE;QACR,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACR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BAAqB,CAAC,WAAW,CAAC,EAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;QAC1E,6BAAqB,CAAC,WAAW,CAAC,EAAC,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;QACjE,6BAAqB,CAAC,WAAW,CAAC,EAAC,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;QAC9E,6BAAqB,CAAC,WAAW,CAAC,EAAC,UAAU,EAAE,CAAC,EAAC,EAAE,EAAC,kBAAkB,EAAE,CAAC,EAAC,CAAC,CAAC;IAC7E,CAAC;SACI,CAAC;QACL,YAAY,CAAC;YACZ,oBAAoB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","file":"customer-notification.collection.js","sourcesContent":["import { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { CustomerNotificationModel } from '../models/customer-notification.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_user: {\n\t\ttype: String\n\t},\n\tid_client: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tclient_name: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\ttitle: {\n\t\ttype: String\n\t},\n\tmessage: {\n\t\ttype: String\n\t},\n\tdetails: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcategory: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tseverity: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tstatus: {\n\t\ttype: String,\n\t\tallowedValues: ['unread', 'read']\n\t},\n\tread_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tread_by: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tsource: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tsource_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\taction_label: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\taction_route: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdedupe_key: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tmetadata: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\texpires_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreated_by: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcreated_by_name: {\n\t\ttype: String,\n\t\toptional: true\n\t}\n};\n\nexport let CustomerNotifications: MongoManagerCollection<CustomerNotificationModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<CustomerNotificationModel>({\n\t\t\tcollectionName: 'customer-notifications',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\n\t\tCustomerNotifications = model.collection_main;\n\t\tCustomerNotifications.createIndex({id_user: 1, status: 1, createdAt: -1});\n\t\tCustomerNotifications.createIndex({id_client: 1, createdAt: -1});\n\t\tCustomerNotifications.createIndex({dedupe_key: 1, id_user: 1, createdAt: -1});\n\t\tCustomerNotifications.createIndex({expires_at: 1}, {expireAfterSeconds: 0});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}\n"]}
|
|
@@ -17,8 +17,7 @@ var LocalLogManager = /** @class */ (function () {
|
|
|
17
17
|
};
|
|
18
18
|
LocalLogManager.prototype.initialize = function () {
|
|
19
19
|
var logDir = resolveLocalLogDir();
|
|
20
|
-
if (resolveio_server_app_1.ResolveIOServer.
|
|
21
|
-
&& resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200') {
|
|
20
|
+
if (resolveio_server_app_1.ResolveIOServer.shouldWriteLogsOffline()) {
|
|
22
21
|
if (!fs.existsSync(logDir)) {
|
|
23
22
|
fs.mkdirSync(logDir, { recursive: true });
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":[],"mappings":";;;AAAA;;iBAEiB;AACjB,uBAAyB;AACzB,2BAA6B;AAC7B,gEAA0D;AAgB1D;IAGC;IAAe,CAAC;IAET,sBAAM,GAAb;QACC,IAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,eAAe,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,eAAe,CAAC;IACxB,CAAC;IAEO,oCAAU,GAAlB;QACC,IAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACpC,IACC,sCAAe,CAAC,
|
|
1
|
+
{"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":[],"mappings":";;;AAAA;;iBAEiB;AACjB,uBAAyB;AACzB,2BAA6B;AAC7B,gEAA0D;AAgB1D;IAGC;IAAe,CAAC;IAET,sBAAM,GAAb;QACC,IAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,eAAe,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,eAAe,CAAC;IACxB,CAAC;IAEO,oCAAU,GAAlB;QACC,IAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACpC,IACC,sCAAe,CAAC,sBAAsB,EAAE,EACvC,CAAC;YACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,C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7E,IAAI,WAAW,EAAE,CAAC;QACjB,OAAO,WAAW,CAAC;IACpB,CAAC;IACD,OAAO,6BAA6B,CAAC;AACtC,CAAC","file":"local-log.manager.js","sourcesContent":["/***************\nlocal-logs.manager.ts\n****************/\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nexport type LocalLogType = 'monitor-mongo' \n\t| 'monitor-memory'\n\t| 'monitor-cpu'\n\t| 'monitor-function'\n\t| 'log'\n\t| 'log-subscription'\n\t| 'log-method-latency';\n\nexport interface LocalLogModel {\n\ttype: LocalLogType;\n\tdata: any;\n\tinstance_index?: string;\n}\n\nexport class LocalLogManager {\n\tprivate _logFilePath: string;\n\n\tconstructor() {}\n\n\tstatic create() {\n\t\tconst localLogManager = new LocalLogManager();\n\t\tlocalLogManager.initialize();\n\t\treturn localLogManager;\n\t}\n\n\tprivate initialize() {\n\t\tconst logDir = resolveLocalLogDir();\n\t\tif (\n\t\t\tResolveIOServer.shouldWriteLogsOffline()\n\t\t) {\n\t\t\tif (!fs.existsSync(logDir)) {\n\t\t\t\tfs.mkdirSync(logDir, { recursive: true });\n\t\t\t}\n\t\t}\n\t\t\n\t\tthis._logFilePath = path.join(logDir, 'local-logs.jsonl');\n\t}\n\n\t// Internal method to append a JSON line to the file\n\tpublic writeLog(logEntry: LocalLogModel): void {\n\t\ttry {\n\t\t\tlogEntry.instance_index = process.env.NODE_APP_INSTANCE || '';\n\n\t\t\tlet log = JSON.stringify(logEntry) + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, log, { encoding: 'utf8' });\n\t\t}\n\t\tcatch(err) {\n\t\t\t// If there's an error writing logs, you might want to handle it or queue it\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write log to file:', err);\n\t\t}\n\t}\n\n\tpublic writeLogs(logEntries: LocalLogModel[]): void {\n\t\tif (!logEntries || logEntries.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert each item to a JSON string, add newline\n\t\t\tlet logs = logEntries.map(logEntry => {\n\t\t\t\tlogEntry.instance_index = process.env.NODE_APP_INSTANCE || '';\n\t\t\t\treturn JSON.stringify(logEntry);\n\t\t\t}).join('\\n') + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, logs, { encoding: 'utf8' });\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write logs batch:', err);\n\t\t}\n\t}\n\n\t/**\n\t * Reads all logs from disk, then empties the file.\n\t */\n\tpublic offloadLogs(): any[] {\n\t\tlet result = [];\n\n\t\ttry {\n\t\t\tif (!fs.existsSync(this._logFilePath)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tlet fileData = fs.readFileSync(this._logFilePath, 'utf8');\n\t\t\tif (fileData.trim().length === 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tresult = fileData.split('\\n').filter(l => l.trim() !== '');\n\n\t\t\t// Truncate the file so we don't send logs more than once\n\t\t\tfs.writeFileSync(this._logFilePath, '');\n\t\t}\n\t\tcatch(err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to offload logs:', err);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\nfunction resolveLocalLogDir(): string {\n\tconst overrideDir = String(process.env.RESOLVEIO_LOCAL_LOG_DIR || '').trim();\n\tif (overrideDir) {\n\t\treturn overrideDir;\n\t}\n\treturn '/home/ubuntu/resolveio/logs';\n}\n"]}
|
|
@@ -100,6 +100,7 @@ var accounts_1 = require("../methods/accounts");
|
|
|
100
100
|
var aws_1 = require("../methods/aws");
|
|
101
101
|
var ai_terminal_1 = require("../methods/ai-terminal");
|
|
102
102
|
var collections_1 = require("../methods/collections");
|
|
103
|
+
var customer_notifications_1 = require("../methods/customer-notifications");
|
|
103
104
|
var counters_1 = require("../methods/counters");
|
|
104
105
|
var cron_jobs_2 = require("../methods/cron-jobs");
|
|
105
106
|
var flag_updates_1 = require("../methods/flag-updates");
|
|
@@ -346,6 +347,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
346
347
|
(0, aws_1.loadAWSMethods)(this);
|
|
347
348
|
(0, ai_terminal_1.loadAiTerminalMethods)(this);
|
|
348
349
|
(0, collections_1.loadCollectionMethods)(this);
|
|
350
|
+
(0, customer_notifications_1.loadCustomerNotificationMethods)(this);
|
|
349
351
|
(0, counters_1.loadCounterMethods)(this);
|
|
350
352
|
(0, logs_1.loadLogMethods)(this);
|
|
351
353
|
(0, pdf_1.loadPDFMethods)(this);
|
|
@@ -752,8 +754,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
752
754
|
methodName !== 'countWithQuery' &&
|
|
753
755
|
methodName !== 'qbFetchRequests' &&
|
|
754
756
|
methodName !== 'qbHandleResponse')) return [3 /*break*/, 6];
|
|
755
|
-
if (!
|
|
756
|
-
&& resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200')) return [3 /*break*/, 3];
|
|
757
|
+
if (!resolveio_server_app_1.ResolveIOServer.shouldWriteLogsOffline()) return [3 /*break*/, 3];
|
|
757
758
|
resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({
|
|
758
759
|
type: 'log',
|
|
759
760
|
data: {
|