@resolveio/server-lib 20.10.1 → 20.10.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.
- package/collections/email-history.collection.js +18 -0
- package/collections/email-history.collection.js.map +1 -1
- package/collections/log.collection.js +4 -0
- package/collections/log.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +44 -0
- package/collections/report-builder-report.collection.js.map +1 -1
- package/managers/method.manager.d.ts +9 -1
- package/managers/method.manager.js +444 -178
- package/managers/method.manager.js.map +1 -1
- package/managers/subscription.manager.js +73 -29
- package/managers/subscription.manager.js.map +1 -1
- package/methods/logs.js +23 -4
- package/methods/logs.js.map +1 -1
- package/methods/report-builder.js +234 -2
- package/methods/report-builder.js.map +1 -1
- package/methods.ts +4 -4
- package/models/email-history.model.d.ts +11 -0
- package/models/email-history.model.js.map +1 -1
- package/models/log.model.d.ts +1 -0
- package/models/log.model.js.map +1 -1
- package/models/report-builder-report.model.d.ts +2 -0
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.d.ts +14 -0
- package/models/report-builder.model.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +79 -36
- package/server-app.js.map +1 -1
- package/util/error-tracking.d.ts +13 -0
- package/util/error-tracking.js +121 -0
- package/util/error-tracking.js.map +1 -0
|
@@ -16,6 +16,20 @@ export interface LookupTables {
|
|
|
16
16
|
lookup: string;
|
|
17
17
|
local_key: string;
|
|
18
18
|
}
|
|
19
|
+
export type ReportBuilderJoinOperator = 'sum' | 'avg' | 'min' | 'max' | 'count';
|
|
20
|
+
export interface ReportBuilderJoinAggregation {
|
|
21
|
+
fieldPath?: string;
|
|
22
|
+
operator: ReportBuilderJoinOperator;
|
|
23
|
+
alias: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ReportBuilderCollectionJoin {
|
|
26
|
+
collection: string;
|
|
27
|
+
alias: string;
|
|
28
|
+
rootFieldPath: string;
|
|
29
|
+
foreignField: string;
|
|
30
|
+
aggregations: ReportBuilderJoinAggregation[];
|
|
31
|
+
matchFilters?: object[];
|
|
32
|
+
}
|
|
19
33
|
export interface TreeItemLeafType {
|
|
20
34
|
text: string;
|
|
21
35
|
value: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/models/report-builder.model.ts"],"names":[],"mappings":"","file":"report-builder.model.js","sourcesContent":["export interface ReportBuilderQueryOptionsModel {\n\trootCollection: string;\n\tsearchString: string;\n\tentriesPerPage: string;\n\tpageNum: number;\n\tsortColumn: string;\n\tsortOrder: string; \n\tfilters?: Object;\n}\n\nexport interface CollectionTree { \n\tcollection_name: string;\n\ttree: any;\n\tis_root: boolean; \n}\n\nexport interface LookupTables {\n\tlookup: string;\n\tlocal_key: string; // MUST be type: String\n}\n\nexport interface TreeItemLeafType {\n\ttext: string;\n\tvalue: any;\n}\n\nexport interface TreeItem {\n\ttext: string;\n\tisLeaf: boolean;\n\tchildren?: TreeItem[];\n\tparent?: TreeItem;\n\tisSelected?: boolean;\n\tisActive?: boolean;\n\tisVisible: boolean;\n\tvalue: string;\n\tdepth?: number;\n\trowNumber?: number;\n\tdisabled?: boolean;\n\tlayers?: any[];\n\tleafFieldTypeValue?: string;\n\tleafValueTypeValue?: string;\n}\n\nexport interface ReportTableColumn {\n\tcollection: string;\n\tcollectionAlias?: string;\n\tlookupIsRootNode?: boolean;\n\tcolumnName: string;\n\tfieldPath: String;\n\tlocalKey?: string;\n\tlookupKey?: string;\n}\n\nexport interface ReportTableModel {\n\trootCollection: string;\n\tsearchString: string;\n\tentriesPerPage: string;\n\tpageNum: number;\n\tsortColumn: string;\n\tsortOrder: string; \n\tfilters?: Object;\n}\n\nexport interface UnwindPaths {\n\tcollectionName: string;\n\tcollectionNameAlias?: string;\n\tpaths: string[];\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/models/report-builder.model.ts"],"names":[],"mappings":"","file":"report-builder.model.js","sourcesContent":["export interface ReportBuilderQueryOptionsModel {\n\trootCollection: string;\n\tsearchString: string;\n\tentriesPerPage: string;\n\tpageNum: number;\n\tsortColumn: string;\n\tsortOrder: string; \n\tfilters?: Object;\n}\n\nexport interface CollectionTree { \n\tcollection_name: string;\n\ttree: any;\n\tis_root: boolean; \n}\n\nexport interface LookupTables {\n\tlookup: string;\n\tlocal_key: string; // MUST be type: String\n}\n\nexport type ReportBuilderJoinOperator = 'sum' | 'avg' | 'min' | 'max' | 'count';\n\nexport interface ReportBuilderJoinAggregation {\n\tfieldPath?: string;\n\toperator: ReportBuilderJoinOperator;\n\talias: string;\n}\n\nexport interface ReportBuilderCollectionJoin {\n\tcollection: string;\n\talias: string;\n\trootFieldPath: string;\n\tforeignField: string;\n\taggregations: ReportBuilderJoinAggregation[];\n\tmatchFilters?: object[];\n}\n\nexport interface TreeItemLeafType {\n\ttext: string;\n\tvalue: any;\n}\n\nexport interface TreeItem {\n\ttext: string;\n\tisLeaf: boolean;\n\tchildren?: TreeItem[];\n\tparent?: TreeItem;\n\tisSelected?: boolean;\n\tisActive?: boolean;\n\tisVisible: boolean;\n\tvalue: string;\n\tdepth?: number;\n\trowNumber?: number;\n\tdisabled?: boolean;\n\tlayers?: any[];\n\tleafFieldTypeValue?: string;\n\tleafValueTypeValue?: string;\n}\n\nexport interface ReportTableColumn {\n\tcollection: string;\n\tcollectionAlias?: string;\n\tlookupIsRootNode?: boolean;\n\tcolumnName: string;\n\tfieldPath: String;\n\tlocalKey?: string;\n\tlookupKey?: string;\n}\n\nexport interface ReportTableModel {\n\trootCollection: string;\n\tsearchString: string;\n\tentriesPerPage: string;\n\tpageNum: number;\n\tsortColumn: string;\n\tsortOrder: string; \n\tfilters?: Object;\n}\n\nexport interface UnwindPaths {\n\tcollectionName: string;\n\tcollectionNameAlias?: string;\n\tpaths: string[];\n}\n"]}
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -89,6 +89,7 @@ var method_manager_1 = require("./managers/method.manager");
|
|
|
89
89
|
var monitor_manager_1 = require("./managers/monitor.manager");
|
|
90
90
|
var subscription_manager_1 = require("./managers/subscription.manager");
|
|
91
91
|
var common_1 = require("./util/common");
|
|
92
|
+
var error_tracking_1 = require("./util/error-tracking");
|
|
92
93
|
var mongodb_1 = require("mongodb");
|
|
93
94
|
var auth_1 = require("./http/auth");
|
|
94
95
|
var health_1 = require("./http/health");
|
|
@@ -162,103 +163,145 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
162
163
|
}, 5000);
|
|
163
164
|
process.removeAllListeners('unhandledRejection');
|
|
164
165
|
process.on('unhandledRejection', function (error, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
165
|
-
var diffTimeSec;
|
|
166
|
+
var _a, normalizedError, correlationId, errorDetails, diffTimeSec;
|
|
166
167
|
var _this = this;
|
|
167
|
-
return __generator(this, function (
|
|
168
|
-
switch (
|
|
168
|
+
return __generator(this, function (_b) {
|
|
169
|
+
switch (_b.label) {
|
|
169
170
|
case 0:
|
|
171
|
+
_a = (0, error_tracking_1.ensureErrorWithCorrelation)(error), normalizedError = _a.error, correlationId = _a.correlationId;
|
|
170
172
|
if (this._methodManager.getEnableDebug()) {
|
|
171
|
-
console.error(new Date(), 'ERROR DETECTED w/ Debug Flag Active: unhandledRejection', [
|
|
173
|
+
console.error(new Date(), 'ERROR DETECTED w/ Debug Flag Active: unhandledRejection', [normalizedError, rej, { correlationId: correlationId }]);
|
|
172
174
|
}
|
|
173
|
-
// Condition to filter out the MongoError with
|
|
174
|
-
if (
|
|
175
|
+
// Condition to filter out the MongoError with specific codes
|
|
176
|
+
if (normalizedError && normalizedError['name'] === 'MongoError' && (normalizedError['code'] === 48 || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 251)) {
|
|
175
177
|
return [2 /*return*/]; // Simply return without doing anything further
|
|
176
178
|
}
|
|
177
|
-
if (
|
|
179
|
+
if (normalizedError && normalizedError['name'] === 'MongoServerError' && (!initServerFlag || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 86 || normalizedError['code'] === 251)) {
|
|
178
180
|
return [2 /*return*/]; // Simply return without doing anything further
|
|
179
181
|
}
|
|
180
|
-
|
|
182
|
+
errorDetails = {
|
|
183
|
+
id: correlationId,
|
|
184
|
+
name: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.name,
|
|
185
|
+
message: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.message,
|
|
186
|
+
stack: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.stack,
|
|
187
|
+
code: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.code,
|
|
188
|
+
codeName: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.codeName
|
|
189
|
+
};
|
|
190
|
+
console.error(new Date(), 'Unhandled Rejection at Promise', [errorDetails]);
|
|
181
191
|
diffTimeSec = moment().diff(this._serverStartTime, 'seconds');
|
|
182
|
-
if (!(
|
|
192
|
+
if (!(normalizedError && (normalizedError['name'] === 'MongoNetworkTimeoutError' || normalizedError instanceof mongodb_1.MongoNetworkTimeoutError))) return [3 /*break*/, 3];
|
|
183
193
|
if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 2];
|
|
184
194
|
this._lastErrorMsg = new Date();
|
|
185
195
|
setTimeout(function () {
|
|
186
196
|
_this._lastErrorMsg = null;
|
|
187
197
|
}, 60000);
|
|
188
198
|
// Sending email notification (using your existing method)
|
|
189
|
-
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - MongoNetworkTimeoutError - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - MongoNetworkTimeoutError - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(errorDetails, null, 2), null, null, null, null, false, false, {
|
|
200
|
+
correlationId: correlationId,
|
|
201
|
+
meta: {
|
|
202
|
+
context: 'unhandledRejection',
|
|
203
|
+
scenario: 'MongoNetworkTimeoutError'
|
|
204
|
+
}
|
|
205
|
+
})];
|
|
194
206
|
case 1:
|
|
195
207
|
// Sending email notification (using your existing method)
|
|
196
|
-
|
|
208
|
+
_b.sent();
|
|
197
209
|
// Exiting the process
|
|
198
210
|
process.exit(1);
|
|
199
|
-
|
|
211
|
+
_b.label = 2;
|
|
200
212
|
case 2: return [3 /*break*/, 11];
|
|
201
213
|
case 3:
|
|
202
|
-
if (!(
|
|
214
|
+
if (!(normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master')) return [3 /*break*/, 6];
|
|
203
215
|
if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 5];
|
|
204
216
|
this._lastErrorMsg = new Date();
|
|
205
217
|
setTimeout(function () {
|
|
206
218
|
_this._lastErrorMsg = null;
|
|
207
219
|
}, 60000);
|
|
208
|
-
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(
|
|
220
|
+
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(errorDetails, null, 2), null, null, null, null, false, false, {
|
|
221
|
+
correlationId: correlationId,
|
|
222
|
+
meta: {
|
|
223
|
+
context: 'unhandledRejection',
|
|
224
|
+
scenario: 'MongoNotMaster'
|
|
225
|
+
}
|
|
226
|
+
})];
|
|
209
227
|
case 4:
|
|
210
|
-
|
|
211
|
-
|
|
228
|
+
_b.sent();
|
|
229
|
+
_b.label = 5;
|
|
212
230
|
case 5:
|
|
213
231
|
process.exit(1);
|
|
214
232
|
return [3 /*break*/, 11];
|
|
215
233
|
case 6:
|
|
216
|
-
if (!(
|
|
234
|
+
if (!(normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master and slaveOk=false')) return [3 /*break*/, 9];
|
|
217
235
|
if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 8];
|
|
218
236
|
this._lastErrorMsg = new Date();
|
|
219
237
|
setTimeout(function () {
|
|
220
238
|
_this._lastErrorMsg = null;
|
|
221
239
|
}, 60000);
|
|
222
|
-
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(
|
|
240
|
+
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(errorDetails, null, 2), null, null, null, null, false, false, {
|
|
241
|
+
correlationId: correlationId,
|
|
242
|
+
meta: {
|
|
243
|
+
context: 'unhandledRejection',
|
|
244
|
+
scenario: 'MongoNotMasterSlaveOk'
|
|
245
|
+
}
|
|
246
|
+
})];
|
|
223
247
|
case 7:
|
|
224
|
-
|
|
225
|
-
|
|
248
|
+
_b.sent();
|
|
249
|
+
_b.label = 8;
|
|
226
250
|
case 8:
|
|
227
251
|
process.exit(1);
|
|
228
252
|
return [3 /*break*/, 11];
|
|
229
253
|
case 9:
|
|
230
|
-
if (!
|
|
231
|
-
if (!(error['name'] !== 'StatusError' && error['message'] !== '')) return [3 /*break*/, 11];
|
|
254
|
+
if (!(normalizedError && normalizedError['name'] !== 'StatusError' && normalizedError['message'] !== '')) return [3 /*break*/, 11];
|
|
232
255
|
if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 11];
|
|
233
256
|
this._lastErrorMsg = new Date();
|
|
234
257
|
setTimeout(function () {
|
|
235
258
|
_this._lastErrorMsg = null;
|
|
236
259
|
}, 60000);
|
|
237
|
-
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(
|
|
260
|
+
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(errorDetails, null, 2), null, null, null, null, false, false, {
|
|
261
|
+
correlationId: correlationId,
|
|
262
|
+
meta: {
|
|
263
|
+
context: 'unhandledRejection',
|
|
264
|
+
scenario: 'General'
|
|
265
|
+
}
|
|
266
|
+
})];
|
|
238
267
|
case 10:
|
|
239
|
-
|
|
240
|
-
|
|
268
|
+
_b.sent();
|
|
269
|
+
_b.label = 11;
|
|
241
270
|
case 11: return [2 /*return*/];
|
|
242
271
|
}
|
|
243
272
|
});
|
|
244
273
|
}); });
|
|
245
274
|
process.on('uncaughtException', function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
246
|
-
var diffTimeSec;
|
|
275
|
+
var _a, normalizedError, correlationId, diffTimeSec, errorDetails;
|
|
247
276
|
var _this = this;
|
|
248
|
-
return __generator(this, function (
|
|
249
|
-
switch (
|
|
277
|
+
return __generator(this, function (_b) {
|
|
278
|
+
switch (_b.label) {
|
|
250
279
|
case 0:
|
|
251
|
-
|
|
280
|
+
_a = (0, error_tracking_1.ensureErrorWithCorrelation)(error), normalizedError = _a.error, correlationId = _a.correlationId;
|
|
281
|
+
console.error(normalizedError, 'Uncaught Exception thrown', { correlationId: correlationId });
|
|
252
282
|
diffTimeSec = moment().diff(this._serverStartTime, 'seconds');
|
|
253
283
|
if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 2];
|
|
254
284
|
this._lastErrorMsg = new Date();
|
|
255
285
|
setTimeout(function () {
|
|
256
286
|
_this._lastErrorMsg = null;
|
|
257
287
|
}, 60000);
|
|
258
|
-
|
|
288
|
+
errorDetails = {
|
|
289
|
+
id: correlationId,
|
|
290
|
+
name: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.name,
|
|
291
|
+
message: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.message,
|
|
292
|
+
stack: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.stack,
|
|
293
|
+
code: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.code,
|
|
294
|
+
codeName: normalizedError === null || normalizedError === void 0 ? void 0 : normalizedError.codeName
|
|
295
|
+
};
|
|
296
|
+
return [4 /*yield*/, this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], JSON.stringify(errorDetails, null, 2), null, null, null, null, false, false, {
|
|
297
|
+
correlationId: correlationId,
|
|
298
|
+
meta: {
|
|
299
|
+
context: 'uncaughtException'
|
|
300
|
+
}
|
|
301
|
+
})];
|
|
259
302
|
case 1:
|
|
260
|
-
|
|
261
|
-
|
|
303
|
+
_b.sent();
|
|
304
|
+
_b.label = 2;
|
|
262
305
|
case 2: return [2 /*return*/];
|
|
263
306
|
}
|
|
264
307
|
});
|