@resolveio/server-lib 22.2.3 → 22.2.5
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/app-setting.collection.d.ts +3 -0
- package/collections/app-setting.collection.js +103 -0
- package/collections/app-setting.collection.js.map +1 -0
- package/managers/method.manager.js +3 -1
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +18 -18
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.js +2 -0
- package/managers/subscription.manager.js.map +1 -1
- package/methods/app-settings.d.ts +2 -0
- package/methods/app-settings.js +169 -0
- package/methods/app-settings.js.map +1 -0
- package/methods/logs.js +2 -2
- package/methods/logs.js.map +1 -1
- package/methods.ts +3 -0
- package/models/app-setting.model.d.ts +16 -0
- package/models/app-setting.model.js +4 -0
- package/models/app-setting.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/app-settings.d.ts +2 -0
- package/publications/app-settings.js +28 -0
- package/publications/app-settings.js.map +1 -0
- package/publications.ts +6 -0
- package/resolveio-server-app.d.ts +6 -0
- package/resolveio-server-app.js +126 -0
- package/resolveio-server-app.js.map +1 -1
- package/server-app.js +2 -2
- package/server-app.js.map +1 -1
- package/util/error-reporter.js +72 -2
- package/util/error-reporter.js.map +1 -1
- package/util/slow-query-reporter.d.ts +1 -0
- package/util/slow-query-reporter.js +53 -3
- package/util/slow-query-reporter.js.map +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.loadAppSettingsMethods = loadAppSettingsMethods;
|
|
51
|
+
var simpl_schema_1 = require("simpl-schema");
|
|
52
|
+
var app_setting_collection_1 = require("../collections/app-setting.collection");
|
|
53
|
+
var common_1 = require("../util/common");
|
|
54
|
+
function loadAppSettingsMethods(methodManager) {
|
|
55
|
+
methodManager.methods({
|
|
56
|
+
appSettingsUpsert: {
|
|
57
|
+
check: new simpl_schema_1.default({
|
|
58
|
+
settings: {
|
|
59
|
+
type: Object,
|
|
60
|
+
blackbox: true
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
function: function (settings) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var update, idSetting, existing, now, newIdSetting, insertDoc;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
update = {
|
|
70
|
+
updatedAt: new Date()
|
|
71
|
+
};
|
|
72
|
+
if (settings.company_name !== undefined) {
|
|
73
|
+
update.company_name = normalizeOptionalString(settings.company_name);
|
|
74
|
+
}
|
|
75
|
+
if (settings.timezone !== undefined) {
|
|
76
|
+
update.timezone = normalizeOptionalString(settings.timezone);
|
|
77
|
+
}
|
|
78
|
+
if (settings.currency !== undefined) {
|
|
79
|
+
update.currency = normalizeOptionalString(settings.currency);
|
|
80
|
+
}
|
|
81
|
+
if (settings.invoice_prefix !== undefined) {
|
|
82
|
+
update.invoice_prefix = normalizeOptionalString(settings.invoice_prefix);
|
|
83
|
+
}
|
|
84
|
+
if (settings.support_email !== undefined) {
|
|
85
|
+
update.support_email = normalizeOptionalString(settings.support_email);
|
|
86
|
+
}
|
|
87
|
+
if (settings.support_phone !== undefined) {
|
|
88
|
+
update.support_phone = normalizeOptionalString(settings.support_phone);
|
|
89
|
+
}
|
|
90
|
+
if (settings.support_address !== undefined) {
|
|
91
|
+
update.support_address = normalizeOptionalString(settings.support_address);
|
|
92
|
+
}
|
|
93
|
+
if (settings.notes !== undefined) {
|
|
94
|
+
update.notes = normalizeOptionalString(settings.notes);
|
|
95
|
+
}
|
|
96
|
+
if (settings.enable_ai !== undefined) {
|
|
97
|
+
update.enable_ai = !!settings.enable_ai;
|
|
98
|
+
}
|
|
99
|
+
if (settings.enable_auto_fix !== undefined) {
|
|
100
|
+
update.enable_auto_fix = !!settings.enable_auto_fix;
|
|
101
|
+
}
|
|
102
|
+
if (settings.enable_slow_query_optimizer !== undefined) {
|
|
103
|
+
update.enable_slow_query_optimizer = !!settings.enable_slow_query_optimizer;
|
|
104
|
+
}
|
|
105
|
+
if (settings.custom_settings !== undefined) {
|
|
106
|
+
update.custom_settings = normalizeCustomSettings(settings.custom_settings);
|
|
107
|
+
}
|
|
108
|
+
if (settings.is_active !== undefined) {
|
|
109
|
+
update.is_active = settings.is_active;
|
|
110
|
+
}
|
|
111
|
+
idSetting = normalizeOptionalString(settings.id_app_setting);
|
|
112
|
+
if (!idSetting) return [3 /*break*/, 2];
|
|
113
|
+
return [4 /*yield*/, app_setting_collection_1.AppSettings.updateOne({ _id: idSetting }, { $set: update })];
|
|
114
|
+
case 1:
|
|
115
|
+
_a.sent();
|
|
116
|
+
return [2 /*return*/, { id_app_setting: idSetting }];
|
|
117
|
+
case 2: return [4 /*yield*/, app_setting_collection_1.AppSettings.findOne({}, { sort: { createdAt: -1 } })];
|
|
118
|
+
case 3:
|
|
119
|
+
existing = _a.sent();
|
|
120
|
+
if (!(existing && existing._id)) return [3 /*break*/, 5];
|
|
121
|
+
return [4 /*yield*/, app_setting_collection_1.AppSettings.updateOne({ _id: existing._id }, { $set: update })];
|
|
122
|
+
case 4:
|
|
123
|
+
_a.sent();
|
|
124
|
+
return [2 /*return*/, { id_app_setting: existing._id }];
|
|
125
|
+
case 5:
|
|
126
|
+
now = new Date();
|
|
127
|
+
newIdSetting = (0, common_1.objectIdHexString)();
|
|
128
|
+
insertDoc = {
|
|
129
|
+
_id: newIdSetting,
|
|
130
|
+
__v: 0,
|
|
131
|
+
company_name: update.company_name || 'New Company',
|
|
132
|
+
timezone: update.timezone,
|
|
133
|
+
currency: update.currency,
|
|
134
|
+
invoice_prefix: update.invoice_prefix,
|
|
135
|
+
support_email: update.support_email,
|
|
136
|
+
support_phone: update.support_phone,
|
|
137
|
+
support_address: update.support_address,
|
|
138
|
+
notes: update.notes,
|
|
139
|
+
enable_ai: update.enable_ai !== undefined ? update.enable_ai : false,
|
|
140
|
+
enable_auto_fix: update.enable_auto_fix !== undefined ? update.enable_auto_fix : true,
|
|
141
|
+
enable_slow_query_optimizer: update.enable_slow_query_optimizer !== undefined ? update.enable_slow_query_optimizer : true,
|
|
142
|
+
custom_settings: update.custom_settings,
|
|
143
|
+
is_active: update.is_active !== undefined ? update.is_active : true,
|
|
144
|
+
createdAt: now,
|
|
145
|
+
updatedAt: now
|
|
146
|
+
};
|
|
147
|
+
return [4 /*yield*/, app_setting_collection_1.AppSettings.insertOne(insertDoc)];
|
|
148
|
+
case 6:
|
|
149
|
+
_a.sent();
|
|
150
|
+
return [2 /*return*/, { id_app_setting: newIdSetting }];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function normalizeOptionalString(value) {
|
|
159
|
+
var raw = typeof value === 'string' ? value.trim() : '';
|
|
160
|
+
return raw || undefined;
|
|
161
|
+
}
|
|
162
|
+
function normalizeCustomSettings(value) {
|
|
163
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
return __assign({}, value);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=app-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/methods/app-settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wDA6FC;AAnGD,6CAAwC;AACxC,gFAAoE;AAGpE,yCAAmD;AAEnD,SAAgB,sBAAsB,CAAC,aAA4B;IAClE,aAAa,CAAC,OAAO,CAAC;QACrB,iBAAiB,EAAE;YAClB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD,CAAC;YACF,QAAQ,EAAE,UAAe,QAAa;;;;;;gCAC/B,MAAM,GAAmD;oCAC9D,SAAS,EAAE,IAAI,IAAI,EAAE;iCACrB,CAAC;gCAEF,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;oCACzC,MAAM,CAAC,YAAY,GAAG,uBAAuB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gCACtE,CAAC;gCACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;oCACrC,MAAM,CAAC,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gCAC9D,CAAC;gCACD,IAAI,QAAQ,CAAC,QAA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AAC,KAAU;IAC1C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,OAAO,EAAE,CAAC;IACX,CAAC;IACD,oBACI,KAAK,EACP;AACH,CAAC","file":"app-settings.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { AppSettings } from '../collections/app-setting.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { AppSettingModel } from '../models/app-setting.model';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadAppSettingsMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tappSettingsUpsert: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tsettings: {\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(settings: any) {\n\t\t\t\tconst update: Partial<AppSettingModel> & { updatedAt: Date } = {\n\t\t\t\t\tupdatedAt: new Date()\n\t\t\t\t};\n\n\t\t\t\tif (settings.company_name !== undefined) {\n\t\t\t\t\tupdate.company_name = normalizeOptionalString(settings.company_name);\n\t\t\t\t}\n\t\t\t\tif (settings.timezone !== undefined) {\n\t\t\t\t\tupdate.timezone = normalizeOptionalString(settings.timezone);\n\t\t\t\t}\n\t\t\t\tif (settings.currency !== undefined) {\n\t\t\t\t\tupdate.currency = normalizeOptionalString(settings.currency);\n\t\t\t\t}\n\t\t\t\tif (settings.invoice_prefix !== undefined) {\n\t\t\t\t\tupdate.invoice_prefix = normalizeOptionalString(settings.invoice_prefix);\n\t\t\t\t}\n\t\t\t\tif (settings.support_email !== undefined) {\n\t\t\t\t\tupdate.support_email = normalizeOptionalString(settings.support_email);\n\t\t\t\t}\n\t\t\t\tif (settings.support_phone !== undefined) {\n\t\t\t\t\tupdate.support_phone = normalizeOptionalString(settings.support_phone);\n\t\t\t\t}\n\t\t\t\tif (settings.support_address !== undefined) {\n\t\t\t\t\tupdate.support_address = normalizeOptionalString(settings.support_address);\n\t\t\t\t}\n\t\t\t\tif (settings.notes !== undefined) {\n\t\t\t\t\tupdate.notes = normalizeOptionalString(settings.notes);\n\t\t\t\t}\n\t\t\t\tif (settings.enable_ai !== undefined) {\n\t\t\t\t\tupdate.enable_ai = !!settings.enable_ai;\n\t\t\t\t}\n\t\t\t\tif (settings.enable_auto_fix !== undefined) {\n\t\t\t\t\tupdate.enable_auto_fix = !!settings.enable_auto_fix;\n\t\t\t\t}\n\t\t\t\tif (settings.enable_slow_query_optimizer !== undefined) {\n\t\t\t\t\tupdate.enable_slow_query_optimizer = !!settings.enable_slow_query_optimizer;\n\t\t\t\t}\n\t\t\t\tif (settings.custom_settings !== undefined) {\n\t\t\t\t\tupdate.custom_settings = normalizeCustomSettings(settings.custom_settings);\n\t\t\t\t}\n\t\t\t\tif (settings.is_active !== undefined) {\n\t\t\t\t\tupdate.is_active = settings.is_active;\n\t\t\t\t}\n\n\t\t\t\tconst idSetting = normalizeOptionalString(settings.id_app_setting);\n\t\t\t\tif (idSetting) {\n\t\t\t\t\tawait AppSettings.updateOne({ _id: idSetting }, { $set: update });\n\t\t\t\t\treturn { id_app_setting: idSetting };\n\t\t\t\t}\n\n\t\t\t\tconst existing = await AppSettings.findOne({}, { sort: { createdAt: -1 } });\n\t\t\t\tif (existing && existing._id) {\n\t\t\t\t\tawait AppSettings.updateOne({ _id: existing._id }, { $set: update });\n\t\t\t\t\treturn { id_app_setting: existing._id };\n\t\t\t\t}\n\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst newIdSetting = objectIdHexString();\n\t\t\t\tconst insertDoc: Partial<AppSettingModel> = {\n\t\t\t\t\t_id: newIdSetting,\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tcompany_name: update.company_name || 'New Company',\n\t\t\t\t\ttimezone: update.timezone,\n\t\t\t\t\tcurrency: update.currency,\n\t\t\t\t\tinvoice_prefix: update.invoice_prefix,\n\t\t\t\t\tsupport_email: update.support_email,\n\t\t\t\t\tsupport_phone: update.support_phone,\n\t\t\t\t\tsupport_address: update.support_address,\n\t\t\t\t\tnotes: update.notes,\n\t\t\t\t\tenable_ai: update.enable_ai !== undefined ? update.enable_ai : false,\n\t\t\t\t\tenable_auto_fix: update.enable_auto_fix !== undefined ? update.enable_auto_fix : true,\n\t\t\t\t\tenable_slow_query_optimizer: update.enable_slow_query_optimizer !== undefined ? update.enable_slow_query_optimizer : true,\n\t\t\t\t\tcustom_settings: update.custom_settings,\n\t\t\t\t\tis_active: update.is_active !== undefined ? update.is_active : true,\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tupdatedAt: now\n\t\t\t\t};\n\n\t\t\t\tawait AppSettings.insertOne(insertDoc as AppSettingModel);\n\t\t\t\treturn { id_app_setting: newIdSetting };\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction normalizeOptionalString(value: any): string | undefined {\n\tconst raw = typeof value === 'string' ? value.trim() : '';\n\treturn raw || undefined;\n}\n\nfunction normalizeCustomSettings(value: any): Record<string, any> {\n\tif (!value || typeof value !== 'object' || Array.isArray(value)) {\n\t\treturn {};\n\t}\n\treturn {\n\t\t...value\n\t};\n}\n"]}
|
package/methods/logs.js
CHANGED
|
@@ -115,7 +115,7 @@ function loadLogMethods(methodManager) {
|
|
|
115
115
|
messageId: 0,
|
|
116
116
|
route: '',
|
|
117
117
|
client: 'ResolveIO',
|
|
118
|
-
instance:
|
|
118
|
+
instance: resolveio_server_app_1.ResolveIOServer.getInstanceHost(),
|
|
119
119
|
instance_index: process.env.NODE_APP_INSTANCE || '0',
|
|
120
120
|
correlationId: correlationId
|
|
121
121
|
})];
|
|
@@ -159,7 +159,7 @@ function loadLogMethods(methodManager) {
|
|
|
159
159
|
collection_name: collection_name,
|
|
160
160
|
subData: subData,
|
|
161
161
|
client: 'ResolveIO',
|
|
162
|
-
instance:
|
|
162
|
+
instance: resolveio_server_app_1.ResolveIOServer.getInstanceHost()
|
|
163
163
|
})];
|
|
164
164
|
case 2:
|
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AC,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"]}
|
|
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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,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,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.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: ResolveIOServer.getInstanceHost(),\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: ResolveIOServer.getInstanceHost()\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"]}
|
package/methods.ts
CHANGED
|
@@ -48,6 +48,9 @@ export function SERVER_METHODS(resolveioServer) {
|
|
|
48
48
|
aiTerminalUploadFile: (id_conversation: string, file_name: string, content_base64: string, size: number, content_type?: string, cb?: Function): Promise<any> => {
|
|
49
49
|
return resolveioServer.call('aiTerminalUploadFile', id_conversation, file_name, content_base64, size, content_type, cb);
|
|
50
50
|
},
|
|
51
|
+
appSettingsUpsert: (settings: any, cb?: Function): Promise<any> => {
|
|
52
|
+
return resolveioServer.call('appSettingsUpsert', settings, cb);
|
|
53
|
+
},
|
|
51
54
|
collectionListAll: (cb?: Function): Promise<any> => {
|
|
52
55
|
return resolveioServer.call('collectionListAll', cb);
|
|
53
56
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CollectionDocument } from './collection-document.model';
|
|
2
|
+
export interface AppSettingModel extends CollectionDocument {
|
|
3
|
+
company_name?: string;
|
|
4
|
+
timezone?: string;
|
|
5
|
+
currency?: string;
|
|
6
|
+
invoice_prefix?: string;
|
|
7
|
+
support_email?: string;
|
|
8
|
+
support_phone?: string;
|
|
9
|
+
support_address?: string;
|
|
10
|
+
notes?: string;
|
|
11
|
+
enable_ai?: boolean;
|
|
12
|
+
enable_auto_fix?: boolean;
|
|
13
|
+
enable_slow_query_optimizer?: boolean;
|
|
14
|
+
custom_settings?: Record<string, any>;
|
|
15
|
+
is_active?: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/models/app-setting.model.ts"],"names":[],"mappings":"","file":"app-setting.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface AppSettingModel extends CollectionDocument {\n\tcompany_name?: string;\n\ttimezone?: string;\n\tcurrency?: string;\n\tinvoice_prefix?: string;\n\tsupport_email?: string;\n\tsupport_phone?: string;\n\tsupport_address?: string;\n\tnotes?: string;\n\tenable_ai?: boolean;\n\tenable_auto_fix?: boolean;\n\tenable_slow_query_optimizer?: boolean;\n\tcustom_settings?: Record<string, any>;\n\tis_active?: boolean;\n}\n"]}
|
package/package.json
CHANGED
package/public_api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './collections/app-status.collection';
|
|
2
|
+
export * from './collections/app-setting.collection';
|
|
2
3
|
export * from './collections/ai-terminal-issue-report.collection';
|
|
3
4
|
export * from './collections/ai-terminal-conversation.collection';
|
|
4
5
|
export * from './collections/ai-terminal-message.collection';
|
|
@@ -29,6 +30,7 @@ export * from './collections/user-guide.collection';
|
|
|
29
30
|
export * from './collections/user.collection';
|
|
30
31
|
export * from './managers/mongo.manager';
|
|
31
32
|
export * from './models/app-status.model';
|
|
33
|
+
export * from './models/app-setting.model';
|
|
32
34
|
export * from './models/ai-terminal-issue-report.model';
|
|
33
35
|
export * from './models/ai-terminal-conversation.model';
|
|
34
36
|
export * from './models/ai-terminal-message.model';
|
package/public_api.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./collections/app-status.collection"), exports);
|
|
18
|
+
__exportStar(require("./collections/app-setting.collection"), exports);
|
|
18
19
|
__exportStar(require("./collections/ai-terminal-issue-report.collection"), exports);
|
|
19
20
|
__exportStar(require("./collections/ai-terminal-conversation.collection"), exports);
|
|
20
21
|
__exportStar(require("./collections/ai-terminal-message.collection"), exports);
|
|
@@ -45,6 +46,7 @@ __exportStar(require("./collections/user-guide.collection"), exports);
|
|
|
45
46
|
__exportStar(require("./collections/user.collection"), exports);
|
|
46
47
|
__exportStar(require("./managers/mongo.manager"), exports);
|
|
47
48
|
__exportStar(require("./models/app-status.model"), exports);
|
|
49
|
+
__exportStar(require("./models/app-setting.model"), exports);
|
|
48
50
|
__exportStar(require("./models/ai-terminal-issue-report.model"), exports);
|
|
49
51
|
__exportStar(require("./models/ai-terminal-conversation.model"), exports);
|
|
50
52
|
__exportStar(require("./models/ai-terminal-message.model"), exports);
|
package/public_api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/public_api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD;AACpD,oFAAkE;AAClE,oFAAkE;AAClE,+EAA6D;AAC7D,mEAAiD;AACjD,iFAA+D;AAC/D,gFAA8D;AAC9D,4EAA0D;AAC1D,oEAAkD;AAClD,yEAAuD;AACvD,0EAAwD;AACxD,gEAA8C;AAC9C,uEAAqD;AACrD,gEAA8C;AAC9C,8EAA4D;AAC5D,4EAA0D;AAC1D,+DAA6C;AAC7C,2EAAyD;AACzD,uEAAqD;AACrD,4EAA0D;AAC1D,0EAAwD;AACxD,yEAAuD;AACvD,wEAAsD;AACtD,+EAA6D;AAC7D,kFAAgE;AAChE,iFAA+D;AAC/D,sEAAoD;AACpD,sEAAoD;AACpD,gEAA8C;AAC9C,2DAAyC;AACzC,4DAA0C;AAC1C,0EAAwD;AACxD,0EAAwD;AACxD,qEAAmD;AACnD,yEAAuD;AACvD,qEAAmD;AACnD,sEAAoD;AACpD,yDAAuC;AACvC,uEAAqD;AACrD,kEAAgD;AAChD,0DAAwC;AACxC,wDAAsC;AACtC,+DAA6C;AAC7C,gEAA8C;AAC9C,sDAAoC;AACpC,6DAA2C;AAC3C,sDAAoC;AACpC,oEAAkD;AAClD,kEAAgD;AAChD,qDAAmC;AACnC,iEAA+C;AAC/C,iEAA+C;AAC/C,wDAAsC;AACtC,6DAA2C;AAC3C,gEAA8C;AAC9C,+DAA6C;AAC7C,8DAA4C;AAC5C,qEAAmD;AACnD,4DAA0C;AAC1C,4DAA0C;AAC1C,wEAAsD;AACtD,uEAAqD;AACrD,gEAA8C;AAC9C,mEAAiD;AACjD,gEAA8C;AAC9C,8DAA4C;AAC5C,gEAA8C;AAC9C,4DAA0C;AAC1C,4DAA0C;AAC1C,sDAAoC;AACpC,yEAAuD;AACvD,0EAAwD;AACxD,yDAAuC;AACvC,2DAAyC;AACzC,0DAAwC;AACxC,gDAA8B;AAC9B,mDAAiC","file":"public_api.js","sourcesContent":["export * from './collections/app-status.collection';\nexport * from './collections/ai-terminal-issue-report.collection';\nexport * from './collections/ai-terminal-conversation.collection';\nexport * from './collections/ai-terminal-message.collection';\nexport * from './collections/counter.collection';\nexport * from './collections/customer-notification.collection';\nexport * from './collections/communication-metric.collection';\nexport * from './collections/cron-job-history.collection';\nexport * from './collections/cron-job.collection';\nexport * from './collections/email-history.collection';\nexport * from './collections/email-verified.collection';\nexport * from './collections/file.collection';\nexport * from './collections/flag-update.collection';\nexport * from './collections/flag.collection';\nexport * from './collections/log-method-latency.collection';\nexport * from './collections/log-subscription.collection';\nexport * from './collections/log.collection';\nexport * from './collections/logged-in-users.collection';\nexport * from './collections/monitor-cpu.collection';\nexport * from './collections/monitor-function.collection';\nexport * from './collections/monitor-memory.collection';\nexport * from './collections/monitor-mongo.collection';\nexport * from './collections/notification.collection';\nexport * from './collections/openai-usage-ledger.collection';\nexport * from './collections/report-builder-library.collection';\nexport * from './collections/report-builder-report.collection';\nexport * from './collections/user-group.collection';\nexport * from './collections/user-guide.collection';\nexport * from './collections/user.collection';\nexport * from './managers/mongo.manager';\nexport * from './models/app-status.model';\nexport * from './models/ai-terminal-issue-report.model';\nexport * from './models/ai-terminal-conversation.model';\nexport * from './models/ai-terminal-message.model';\nexport * from './models/billing-logged-in-users.model';\nexport * from './models/collection-document.model';\nexport * from './models/communication-metric.model';\nexport * from './models/counter.model';\nexport * from './models/customer-notification.model';\nexport * from './models/cron-job-history.model';\nexport * from './models/cron-job.model';\nexport * from './models/dialog.model';\nexport * from './models/email-history.model';\nexport * from './models/email-verified.model';\nexport * from './models/file.model';\nexport * from './models/flag-update.model';\nexport * from './models/flag.model';\nexport * from './models/log-method-latency.model';\nexport * from './models/log-subscription.model';\nexport * from './models/log.model';\nexport * from './models/logged-in-users.model';\nexport * from './models/method-response.model';\nexport * from './models/method.model';\nexport * from './models/monitor-cpu.model';\nexport * from './models/monitor-memory.model';\nexport * from './models/monitor-mongo.model';\nexport * from './models/notification.model';\nexport * from './models/openai-usage-ledger.model';\nexport * from './models/pagination.model';\nexport * from './models/permission.model';\nexport * from './models/report-builder-library.model';\nexport * from './models/report-builder-report.model';\nexport * from './models/report-builder.model';\nexport * from './models/select-data-label.model';\nexport * from './models/server-message.model';\nexport * from './models/subscription.model';\nexport * from './models/support-ticket.model';\nexport * from './models/user-group.model';\nexport * from './models/user-guide.model';\nexport * from './models/user.model';\nexport * from './managers/openai-usage-ledger.manager';\nexport * from './managers/communication-metric.manager';\nexport * from './resolveio-server-app';\nexport * from './services/openai-client';\nexport * from './services/codex-client';\nexport * from './util/common';\nexport * from './util/tokenizer';\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/public_api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD;AACpD,uEAAqD;AACrD,oFAAkE;AAClE,oFAAkE;AAClE,+EAA6D;AAC7D,mEAAiD;AACjD,iFAA+D;AAC/D,gFAA8D;AAC9D,4EAA0D;AAC1D,oEAAkD;AAClD,yEAAuD;AACvD,0EAAwD;AACxD,gEAA8C;AAC9C,uEAAqD;AACrD,gEAA8C;AAC9C,8EAA4D;AAC5D,4EAA0D;AAC1D,+DAA6C;AAC7C,2EAAyD;AACzD,uEAAqD;AACrD,4EAA0D;AAC1D,0EAAwD;AACxD,yEAAuD;AACvD,wEAAsD;AACtD,+EAA6D;AAC7D,kFAAgE;AAChE,iFAA+D;AAC/D,sEAAoD;AACpD,sEAAoD;AACpD,gEAA8C;AAC9C,2DAAyC;AACzC,4DAA0C;AAC1C,6DAA2C;AAC3C,0EAAwD;AACxD,0EAAwD;AACxD,qEAAmD;AACnD,yEAAuD;AACvD,qEAAmD;AACnD,sEAAoD;AACpD,yDAAuC;AACvC,uEAAqD;AACrD,kEAAgD;AAChD,0DAAwC;AACxC,wDAAsC;AACtC,+DAA6C;AAC7C,gEAA8C;AAC9C,sDAAoC;AACpC,6DAA2C;AAC3C,sDAAoC;AACpC,oEAAkD;AAClD,kEAAgD;AAChD,qDAAmC;AACnC,iEAA+C;AAC/C,iEAA+C;AAC/C,wDAAsC;AACtC,6DAA2C;AAC3C,gEAA8C;AAC9C,+DAA6C;AAC7C,8DAA4C;AAC5C,qEAAmD;AACnD,4DAA0C;AAC1C,4DAA0C;AAC1C,wEAAsD;AACtD,uEAAqD;AACrD,gEAA8C;AAC9C,mEAAiD;AACjD,gEAA8C;AAC9C,8DAA4C;AAC5C,gEAA8C;AAC9C,4DAA0C;AAC1C,4DAA0C;AAC1C,sDAAoC;AACpC,yEAAuD;AACvD,0EAAwD;AACxD,yDAAuC;AACvC,2DAAyC;AACzC,0DAAwC;AACxC,gDAA8B;AAC9B,mDAAiC","file":"public_api.js","sourcesContent":["export * from './collections/app-status.collection';\nexport * from './collections/app-setting.collection';\nexport * from './collections/ai-terminal-issue-report.collection';\nexport * from './collections/ai-terminal-conversation.collection';\nexport * from './collections/ai-terminal-message.collection';\nexport * from './collections/counter.collection';\nexport * from './collections/customer-notification.collection';\nexport * from './collections/communication-metric.collection';\nexport * from './collections/cron-job-history.collection';\nexport * from './collections/cron-job.collection';\nexport * from './collections/email-history.collection';\nexport * from './collections/email-verified.collection';\nexport * from './collections/file.collection';\nexport * from './collections/flag-update.collection';\nexport * from './collections/flag.collection';\nexport * from './collections/log-method-latency.collection';\nexport * from './collections/log-subscription.collection';\nexport * from './collections/log.collection';\nexport * from './collections/logged-in-users.collection';\nexport * from './collections/monitor-cpu.collection';\nexport * from './collections/monitor-function.collection';\nexport * from './collections/monitor-memory.collection';\nexport * from './collections/monitor-mongo.collection';\nexport * from './collections/notification.collection';\nexport * from './collections/openai-usage-ledger.collection';\nexport * from './collections/report-builder-library.collection';\nexport * from './collections/report-builder-report.collection';\nexport * from './collections/user-group.collection';\nexport * from './collections/user-guide.collection';\nexport * from './collections/user.collection';\nexport * from './managers/mongo.manager';\nexport * from './models/app-status.model';\nexport * from './models/app-setting.model';\nexport * from './models/ai-terminal-issue-report.model';\nexport * from './models/ai-terminal-conversation.model';\nexport * from './models/ai-terminal-message.model';\nexport * from './models/billing-logged-in-users.model';\nexport * from './models/collection-document.model';\nexport * from './models/communication-metric.model';\nexport * from './models/counter.model';\nexport * from './models/customer-notification.model';\nexport * from './models/cron-job-history.model';\nexport * from './models/cron-job.model';\nexport * from './models/dialog.model';\nexport * from './models/email-history.model';\nexport * from './models/email-verified.model';\nexport * from './models/file.model';\nexport * from './models/flag-update.model';\nexport * from './models/flag.model';\nexport * from './models/log-method-latency.model';\nexport * from './models/log-subscription.model';\nexport * from './models/log.model';\nexport * from './models/logged-in-users.model';\nexport * from './models/method-response.model';\nexport * from './models/method.model';\nexport * from './models/monitor-cpu.model';\nexport * from './models/monitor-memory.model';\nexport * from './models/monitor-mongo.model';\nexport * from './models/notification.model';\nexport * from './models/openai-usage-ledger.model';\nexport * from './models/pagination.model';\nexport * from './models/permission.model';\nexport * from './models/report-builder-library.model';\nexport * from './models/report-builder-report.model';\nexport * from './models/report-builder.model';\nexport * from './models/select-data-label.model';\nexport * from './models/server-message.model';\nexport * from './models/subscription.model';\nexport * from './models/support-ticket.model';\nexport * from './models/user-group.model';\nexport * from './models/user-guide.model';\nexport * from './models/user.model';\nexport * from './managers/openai-usage-ledger.manager';\nexport * from './managers/communication-metric.manager';\nexport * from './resolveio-server-app';\nexport * from './services/openai-client';\nexport * from './services/codex-client';\nexport * from './util/common';\nexport * from './util/tokenizer';\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAppSettingsPublications = loadAppSettingsPublications;
|
|
4
|
+
var simpl_schema_1 = require("simpl-schema");
|
|
5
|
+
var app_setting_collection_1 = require("../collections/app-setting.collection");
|
|
6
|
+
function loadAppSettingsPublications(subscriptionManager) {
|
|
7
|
+
subscriptionManager.publications({
|
|
8
|
+
appSettings: {
|
|
9
|
+
function: function () {
|
|
10
|
+
return app_setting_collection_1.AppSettings.find({}, { sort: { company_name: 1 } });
|
|
11
|
+
},
|
|
12
|
+
collections: ['app-settings']
|
|
13
|
+
},
|
|
14
|
+
appSettingById: {
|
|
15
|
+
check: new simpl_schema_1.default({
|
|
16
|
+
id_app_setting: {
|
|
17
|
+
type: String
|
|
18
|
+
}
|
|
19
|
+
}),
|
|
20
|
+
function: function (id_app_setting) {
|
|
21
|
+
return app_setting_collection_1.AppSettings.findById(id_app_setting);
|
|
22
|
+
},
|
|
23
|
+
collections: ['app-settings']
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=app-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/publications/app-settings.ts"],"names":[],"mappings":";;AAIA,kEAoBC;AAxBD,6CAAwC;AACxC,gFAAoE;AAGpE,SAAgB,2BAA2B,CAAC,mBAAwC;IACnF,mBAAmB,CAAC,YAAY,CAAC;QAChC,WAAW,EAAE;YACZ,QAAQ,EAAE;gBACT,OAAO,oCAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,WAAW,EAAE,CAAC,cAAc,CAAC;SAC7B;QACD,cAAc,EAAE;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,cAAc,EAAE;oBACf,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,cAAsB;gBACxC,OAAO,oCAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;YAC7C,CAAC;YACD,WAAW,EAAE,CAAC,cAAc,CAAC;SAC7B;KACD,CAAC,CAAC;AACJ,CAAC","file":"app-settings.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { AppSettings } from '../collections/app-setting.collection';\nimport { SubscriptionManager } from '../managers/subscription.manager';\n\nexport function loadAppSettingsPublications(subscriptionManager: SubscriptionManager) {\n\tsubscriptionManager.publications({\n\t\tappSettings: {\n\t\t\tfunction: function() {\n\t\t\t\treturn AppSettings.find({}, { sort: { company_name: 1 } });\n\t\t\t},\n\t\t\tcollections: ['app-settings']\n\t\t},\n\t\tappSettingById: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_app_setting: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(id_app_setting: string) {\n\t\t\t\treturn AppSettings.findById(id_app_setting);\n\t\t\t},\n\t\t\tcollections: ['app-settings']\n\t\t}\n\t});\n}\n"]}
|
package/publications.ts
CHANGED
|
@@ -8,6 +8,12 @@ export function SERVER_PUBLICATIONS(resolveioServer) {
|
|
|
8
8
|
aiTerminalMessages: (id_conversation: string, limit?: number) => {
|
|
9
9
|
return <Observable<any>> resolveioServer.subscribe('aiTerminalMessages', id_conversation, limit);
|
|
10
10
|
},
|
|
11
|
+
appSettingById: (id_app_setting: string) => {
|
|
12
|
+
return <Observable<any>> resolveioServer.subscribe('appSettingById', id_app_setting);
|
|
13
|
+
},
|
|
14
|
+
appSettings: () => {
|
|
15
|
+
return <Observable<any>> resolveioServer.subscribe('appSettings');
|
|
16
|
+
},
|
|
11
17
|
appstatus: () => {
|
|
12
18
|
return <Observable<any>> resolveioServer.subscribe('appstatus');
|
|
13
19
|
},
|
|
@@ -41,6 +41,12 @@ export declare class ResolveIOServer {
|
|
|
41
41
|
static shouldWriteLogsOffline(): boolean;
|
|
42
42
|
private static resolveConfiguredLogStorageMode;
|
|
43
43
|
private static resolveLegacyLogStorageMode;
|
|
44
|
+
static getInstanceHost(): string;
|
|
45
|
+
static getServerApiBaseUrl(): string;
|
|
46
|
+
static buildServerApiUrl(pathname: string): string;
|
|
47
|
+
private static findFirstNonEmptyString;
|
|
48
|
+
private static normalizeBaseUrl;
|
|
49
|
+
private static extractHostName;
|
|
44
50
|
static getClientRoutes(): any[];
|
|
45
51
|
static getClientDir(): string;
|
|
46
52
|
static getSESMail(): boolean;
|
package/resolveio-server-app.js
CHANGED
|
@@ -376,6 +376,132 @@ var ResolveIOServer = /** @class */ (function () {
|
|
|
376
376
|
}
|
|
377
377
|
return 'direct';
|
|
378
378
|
};
|
|
379
|
+
ResolveIOServer.getInstanceHost = function () {
|
|
380
|
+
var config = ResolveIOServer.getServerConfig() || {};
|
|
381
|
+
var explicitHost = this.findFirstNonEmptyString([
|
|
382
|
+
process.env.RESOLVEIO_INSTANCE_HOST,
|
|
383
|
+
process.env.INSTANCE_HOST,
|
|
384
|
+
config['RESOLVEIO_INSTANCE_HOST'],
|
|
385
|
+
config['INSTANCE_HOST'],
|
|
386
|
+
config['SERVER_HOST']
|
|
387
|
+
]);
|
|
388
|
+
if (explicitHost) {
|
|
389
|
+
return explicitHost;
|
|
390
|
+
}
|
|
391
|
+
var hostFromUrl = this.extractHostName(this.findFirstNonEmptyString([
|
|
392
|
+
process.env.RESOLVEIO_SERVER_URL,
|
|
393
|
+
process.env.SERVER_URL,
|
|
394
|
+
config['RESOLVEIO_SERVER_URL'],
|
|
395
|
+
config['SERVER_URL'],
|
|
396
|
+
process.env.ROOT_URL,
|
|
397
|
+
config['ROOT_URL']
|
|
398
|
+
]));
|
|
399
|
+
if (hostFromUrl) {
|
|
400
|
+
return hostFromUrl;
|
|
401
|
+
}
|
|
402
|
+
var envHostName = this.findFirstNonEmptyString([
|
|
403
|
+
process.env.EC2_PUBLIC_HOSTNAME,
|
|
404
|
+
process.env.HOSTNAME
|
|
405
|
+
]);
|
|
406
|
+
if (envHostName) {
|
|
407
|
+
return envHostName;
|
|
408
|
+
}
|
|
409
|
+
return 'local-instance';
|
|
410
|
+
};
|
|
411
|
+
ResolveIOServer.getServerApiBaseUrl = function () {
|
|
412
|
+
var config = ResolveIOServer.getServerConfig() || {};
|
|
413
|
+
var explicitBaseUrl = this.normalizeBaseUrl(this.findFirstNonEmptyString([
|
|
414
|
+
process.env.RESOLVEIO_SERVER_URL,
|
|
415
|
+
process.env.SERVER_URL,
|
|
416
|
+
config['RESOLVEIO_SERVER_URL'],
|
|
417
|
+
config['SERVER_URL']
|
|
418
|
+
]));
|
|
419
|
+
if (explicitBaseUrl) {
|
|
420
|
+
return explicitBaseUrl;
|
|
421
|
+
}
|
|
422
|
+
var normalizedRootUrl = this.normalizeBaseUrl(this.findFirstNonEmptyString([
|
|
423
|
+
process.env.ROOT_URL,
|
|
424
|
+
config['ROOT_URL']
|
|
425
|
+
]));
|
|
426
|
+
if (normalizedRootUrl) {
|
|
427
|
+
try {
|
|
428
|
+
var parsedRootUrl = new URL(normalizedRootUrl);
|
|
429
|
+
if (parsedRootUrl.port === '4200') {
|
|
430
|
+
parsedRootUrl.port = '8080';
|
|
431
|
+
}
|
|
432
|
+
parsedRootUrl.pathname = '';
|
|
433
|
+
parsedRootUrl.search = '';
|
|
434
|
+
parsedRootUrl.hash = '';
|
|
435
|
+
return parsedRootUrl.toString().replace(/\/$/, '');
|
|
436
|
+
}
|
|
437
|
+
catch (_a) {
|
|
438
|
+
return normalizedRootUrl;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
var defaultPort = this.findFirstNonEmptyString([
|
|
442
|
+
process.env.PORT,
|
|
443
|
+
config['PORT']
|
|
444
|
+
]) || '8080';
|
|
445
|
+
return "http://127.0.0.1:".concat(defaultPort);
|
|
446
|
+
};
|
|
447
|
+
ResolveIOServer.buildServerApiUrl = function (pathname) {
|
|
448
|
+
var normalizedPath = pathname && pathname.startsWith('/')
|
|
449
|
+
? pathname
|
|
450
|
+
: "/".concat(pathname || '');
|
|
451
|
+
return this.getServerApiBaseUrl().replace(/\/$/, '') + normalizedPath;
|
|
452
|
+
};
|
|
453
|
+
ResolveIOServer.findFirstNonEmptyString = function (values) {
|
|
454
|
+
var e_3, _a;
|
|
455
|
+
try {
|
|
456
|
+
for (var _b = __values(values || []), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
457
|
+
var value = _c.value;
|
|
458
|
+
if (typeof value === 'string' && value.trim().length) {
|
|
459
|
+
return value.trim();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
464
|
+
finally {
|
|
465
|
+
try {
|
|
466
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
467
|
+
}
|
|
468
|
+
finally { if (e_3) throw e_3.error; }
|
|
469
|
+
}
|
|
470
|
+
return null;
|
|
471
|
+
};
|
|
472
|
+
ResolveIOServer.normalizeBaseUrl = function (value) {
|
|
473
|
+
if (!value || typeof value !== 'string') {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
var trimmedValue = value.trim();
|
|
477
|
+
if (!trimmedValue) {
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
var hasScheme = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(trimmedValue);
|
|
481
|
+
var candidate = hasScheme ? trimmedValue : "http://".concat(trimmedValue);
|
|
482
|
+
try {
|
|
483
|
+
var parsed = new URL(candidate);
|
|
484
|
+
parsed.pathname = '';
|
|
485
|
+
parsed.search = '';
|
|
486
|
+
parsed.hash = '';
|
|
487
|
+
return parsed.toString().replace(/\/$/, '');
|
|
488
|
+
}
|
|
489
|
+
catch (_a) {
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
ResolveIOServer.extractHostName = function (value) {
|
|
494
|
+
var normalizedBase = this.normalizeBaseUrl(value || '');
|
|
495
|
+
if (!normalizedBase) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
try {
|
|
499
|
+
return new URL(normalizedBase).hostname || null;
|
|
500
|
+
}
|
|
501
|
+
catch (_a) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
379
505
|
ResolveIOServer.getClientRoutes = function () {
|
|
380
506
|
return ResolveIOServer._clientRoutes;
|
|
381
507
|
};
|