cloud-ide-model-schema 1.1.141 → 1.1.143
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/lib/config/database.js +297 -30
- package/lib/schema/academics/academics_bonafide_request.d.ts +8 -0
- package/lib/schema/academics/academics_bonafide_request.js +98 -0
- package/lib/schema/academics/index.d.ts +1 -0
- package/lib/schema/academics/index.js +1 -0
- package/lib/schema/admission/admission_application_main.js +44 -0
- package/lib/schema/admission/admission_family_members.js +5 -0
- package/lib/schema/admission/admission_rte_details.d.ts +45 -0
- package/lib/schema/admission/admission_rte_details.js +177 -0
- package/lib/schema/admission/admission_vital_information.d.ts +45 -0
- package/lib/schema/admission/admission_vital_information.js +120 -0
- package/lib/schema/admission/index.d.ts +2 -0
- package/lib/schema/admission/index.js +2 -0
- package/lib/schema/auth/auth_user_mst.js +11 -0
- package/lib/schema/core/core_department.js +6 -0
- package/lib/schema/core/core_designation.js +6 -0
- package/lib/schema/core/core_entity_mapping.js +11 -0
- package/lib/schema/core/core_user_role.js +6 -0
- package/lib/schema/core/core_workflow_approver_rules.d.ts +8 -0
- package/lib/schema/core/core_workflow_approver_rules.js +83 -0
- package/lib/schema/core/core_workflow_config.d.ts +8 -0
- package/lib/schema/core/core_workflow_config.js +103 -0
- package/lib/schema/core/core_workflow_registry.d.ts +8 -0
- package/lib/schema/core/core_workflow_registry.js +128 -0
- package/lib/schema/core/core_workflow_transaction_history.d.ts +8 -0
- package/lib/schema/core/core_workflow_transaction_history.js +86 -0
- package/lib/schema/core/index.d.ts +13 -1
- package/lib/schema/core/index.js +9 -1
- package/lib/schema/email/email_log.js +22 -1
- package/lib/schema/email/email_reference.js +23 -3
- package/lib/schema/email/email_subscription_vendor.js +16 -1
- package/lib/schema/email/email_templete.js +36 -1
- package/package.json +2 -2
package/lib/config/database.js
CHANGED
|
@@ -40,6 +40,8 @@ exports.customUUID = void 0;
|
|
|
40
40
|
exports.connectDB = connectDB;
|
|
41
41
|
var mongoose = require("mongoose");
|
|
42
42
|
require("dotenv/config");
|
|
43
|
+
var fs = require("fs");
|
|
44
|
+
var path = require("path");
|
|
43
45
|
// Connection state tracking
|
|
44
46
|
var isConnecting = false;
|
|
45
47
|
var connectionRetryCount = 0;
|
|
@@ -47,6 +49,7 @@ var MAX_RETRY_ATTEMPTS = 10;
|
|
|
47
49
|
var INITIAL_RETRY_DELAY = 1000; // 1 second
|
|
48
50
|
var MAX_RETRY_DELAY = 30000; // 30 seconds
|
|
49
51
|
var retryTimeout = null;
|
|
52
|
+
var alertEmailSent = false; // Track if alert email has been sent
|
|
50
53
|
/**
|
|
51
54
|
* Check if MongoDB is already connected
|
|
52
55
|
*/
|
|
@@ -59,19 +62,36 @@ function isConnected() {
|
|
|
59
62
|
function isConnectingState() {
|
|
60
63
|
return mongoose.connection.readyState === 2; // 2 = connecting
|
|
61
64
|
}
|
|
65
|
+
// Track if listeners have been set up to prevent duplicates
|
|
66
|
+
// This prevents the "Possible EventEmitter memory leak detected" warning
|
|
67
|
+
// that occurs when multiple modules call connectDB() and listeners are added multiple times
|
|
68
|
+
var listenersSetup = false;
|
|
62
69
|
/**
|
|
63
70
|
* Setup MongoDB connection event listeners (idempotent)
|
|
71
|
+
* This function ensures listeners are only added once, even if called multiple times.
|
|
72
|
+
*
|
|
73
|
+
* IMPORTANT: This prevents EventEmitter memory leaks that occur when:
|
|
74
|
+
* - Multiple controller/service files call connectDB() at module import time
|
|
75
|
+
* - Reconnection logic calls connectDB() recursively
|
|
76
|
+
* - Each call would add duplicate event listeners without this protection
|
|
77
|
+
*
|
|
78
|
+
* The fix uses a flag to ensure listeners are only added once, regardless of
|
|
79
|
+
* how many times connectDB() is called.
|
|
64
80
|
*/
|
|
65
81
|
function setupConnectionListeners() {
|
|
66
|
-
// Only setup once
|
|
67
|
-
if (
|
|
82
|
+
// Only setup once - check flag to ensure no duplicates
|
|
83
|
+
if (listenersSetup) {
|
|
68
84
|
return;
|
|
69
85
|
}
|
|
86
|
+
// Keep max listeners at default (10) since we prevent duplicates with the flag
|
|
87
|
+
// No need to increase if listeners are only added once
|
|
88
|
+
mongoose.connection.setMaxListeners(10);
|
|
70
89
|
// Connection successful
|
|
71
90
|
mongoose.connection.on('connected', function () {
|
|
72
91
|
console.log('✅ MongoDB connected successfully');
|
|
73
92
|
connectionRetryCount = 0; // Reset retry count on success
|
|
74
93
|
isConnecting = false;
|
|
94
|
+
alertEmailSent = false; // Reset alert flag on successful connection
|
|
75
95
|
});
|
|
76
96
|
// Connection error
|
|
77
97
|
mongoose.connection.on('error', function (error) {
|
|
@@ -83,6 +103,15 @@ function setupConnectionListeners() {
|
|
|
83
103
|
mongoose.connection.on('disconnected', function () {
|
|
84
104
|
console.warn('⚠️ MongoDB disconnected. Will attempt to reconnect...');
|
|
85
105
|
isConnecting = false;
|
|
106
|
+
// Send alert for unexpected disconnection (but not on initial connection failure)
|
|
107
|
+
if (connectionRetryCount > 0) {
|
|
108
|
+
sendMongoDBConnectionAlert('WARNING: MongoDB Disconnected', {
|
|
109
|
+
name: 'MongoDisconnected',
|
|
110
|
+
message: 'MongoDB connection was lost unexpectedly'
|
|
111
|
+
}).catch(function (alertError) {
|
|
112
|
+
console.error('❌ Failed to send disconnection alert:', (alertError === null || alertError === void 0 ? void 0 : alertError.message) || alertError);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
86
115
|
// Attempt reconnection
|
|
87
116
|
attemptReconnection();
|
|
88
117
|
});
|
|
@@ -100,6 +129,8 @@ function setupConnectionListeners() {
|
|
|
100
129
|
// Attempt reconnection
|
|
101
130
|
attemptReconnection();
|
|
102
131
|
});
|
|
132
|
+
// Mark listeners as setup
|
|
133
|
+
listenersSetup = true;
|
|
103
134
|
}
|
|
104
135
|
/**
|
|
105
136
|
* Attempt to reconnect to MongoDB with exponential backoff
|
|
@@ -115,9 +146,27 @@ function attemptReconnection() {
|
|
|
115
146
|
clearTimeout(retryTimeout);
|
|
116
147
|
retryTimeout = null;
|
|
117
148
|
}
|
|
118
|
-
// Check retry limit
|
|
149
|
+
// Check retry limit - but allow reset after a longer delay
|
|
119
150
|
if (connectionRetryCount >= MAX_RETRY_ATTEMPTS) {
|
|
120
|
-
|
|
151
|
+
// Send alert email if not already sent
|
|
152
|
+
if (!alertEmailSent) {
|
|
153
|
+
sendMongoDBConnectionAlert('CRITICAL: Maximum retry attempts reached').catch(function (alertError) {
|
|
154
|
+
console.error('❌ Failed to send max retry alert:', (alertError === null || alertError === void 0 ? void 0 : alertError.message) || alertError);
|
|
155
|
+
});
|
|
156
|
+
alertEmailSent = true;
|
|
157
|
+
}
|
|
158
|
+
// After max attempts, wait longer before allowing another attempt
|
|
159
|
+
// This prevents infinite retries but allows recovery if MongoDB becomes available
|
|
160
|
+
var longDelay = MAX_RETRY_DELAY * 2; // 60 seconds
|
|
161
|
+
console.log("\u23F3 MongoDB reconnection paused after ".concat(MAX_RETRY_ATTEMPTS, " attempts. Will retry in ").concat(longDelay, "ms..."));
|
|
162
|
+
retryTimeout = setTimeout(function () {
|
|
163
|
+
retryTimeout = null;
|
|
164
|
+
connectionRetryCount = 0; // Reset retry count to allow fresh attempt
|
|
165
|
+
console.log('🔄 Resetting retry count. Attempting fresh MongoDB connection...');
|
|
166
|
+
connectDB().catch(function () {
|
|
167
|
+
// If it fails, start retry cycle again
|
|
168
|
+
});
|
|
169
|
+
}, longDelay);
|
|
121
170
|
return;
|
|
122
171
|
}
|
|
123
172
|
// Calculate exponential backoff delay
|
|
@@ -129,10 +178,12 @@ function attemptReconnection() {
|
|
|
129
178
|
switch (_a.label) {
|
|
130
179
|
case 0:
|
|
131
180
|
retryTimeout = null;
|
|
181
|
+
if (!(!isConnected() && !isConnecting)) return [3 /*break*/, 2];
|
|
132
182
|
return [4 /*yield*/, connectDB()];
|
|
133
183
|
case 1:
|
|
134
184
|
_a.sent(); // Recursive call
|
|
135
|
-
|
|
185
|
+
_a.label = 2;
|
|
186
|
+
case 2: return [2 /*return*/];
|
|
136
187
|
}
|
|
137
188
|
});
|
|
138
189
|
}); }, delay);
|
|
@@ -143,7 +194,7 @@ function attemptReconnection() {
|
|
|
143
194
|
*/
|
|
144
195
|
function connectDB() {
|
|
145
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
146
|
-
var mongoUri, options,
|
|
197
|
+
var mongoUri, closeError_1, options, error_1, errorMessage, errorStack, errorName, closeError_2;
|
|
147
198
|
return __generator(this, function (_a) {
|
|
148
199
|
switch (_a.label) {
|
|
149
200
|
case 0:
|
|
@@ -151,10 +202,23 @@ function connectDB() {
|
|
|
151
202
|
if (isConnected()) {
|
|
152
203
|
return [2 /*return*/];
|
|
153
204
|
}
|
|
154
|
-
|
|
155
|
-
|
|
205
|
+
if (!(isConnecting || isConnectingState())) return [3 /*break*/, 2];
|
|
206
|
+
// Wait 2 seconds and check if connection succeeded
|
|
207
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
|
208
|
+
case 1:
|
|
209
|
+
// Wait 2 seconds and check if connection succeeded
|
|
210
|
+
_a.sent();
|
|
211
|
+
// If connected now, return
|
|
212
|
+
if (isConnected()) {
|
|
156
213
|
return [2 /*return*/];
|
|
157
214
|
}
|
|
215
|
+
// If still connecting after wait, allow new attempt (might be stuck)
|
|
216
|
+
if (isConnecting || isConnectingState()) {
|
|
217
|
+
console.warn('⚠️ Previous connection attempt seems stuck. Starting fresh connection attempt...');
|
|
218
|
+
isConnecting = false; // Reset flag to allow new attempt
|
|
219
|
+
}
|
|
220
|
+
_a.label = 2;
|
|
221
|
+
case 2:
|
|
158
222
|
// Setup event listeners (idempotent)
|
|
159
223
|
setupConnectionListeners();
|
|
160
224
|
mongoUri = process.env.MONGODB_URI;
|
|
@@ -164,13 +228,30 @@ function connectDB() {
|
|
|
164
228
|
return [2 /*return*/];
|
|
165
229
|
}
|
|
166
230
|
isConnecting = true;
|
|
167
|
-
_a.label =
|
|
168
|
-
case
|
|
169
|
-
_a.trys.push([
|
|
231
|
+
_a.label = 3;
|
|
232
|
+
case 3:
|
|
233
|
+
_a.trys.push([3, 9, , 15]);
|
|
234
|
+
if (!(mongoose.connection.readyState !== 0)) return [3 /*break*/, 7];
|
|
235
|
+
_a.label = 4;
|
|
236
|
+
case 4:
|
|
237
|
+
_a.trys.push([4, 6, , 7]);
|
|
238
|
+
return [4 /*yield*/, mongoose.connection.close()];
|
|
239
|
+
case 5:
|
|
240
|
+
_a.sent();
|
|
241
|
+
return [3 /*break*/, 7];
|
|
242
|
+
case 6:
|
|
243
|
+
closeError_1 = _a.sent();
|
|
244
|
+
// Log close errors instead of suppressing them
|
|
245
|
+
console.warn('⚠️ Error closing existing MongoDB connection:', (closeError_1 === null || closeError_1 === void 0 ? void 0 : closeError_1.message) || closeError_1);
|
|
246
|
+
if (closeError_1 === null || closeError_1 === void 0 ? void 0 : closeError_1.stack) {
|
|
247
|
+
console.warn(' Stack:', closeError_1.stack);
|
|
248
|
+
}
|
|
249
|
+
return [3 /*break*/, 7];
|
|
250
|
+
case 7:
|
|
170
251
|
options = {
|
|
171
|
-
connectTimeoutMS: 15000, //
|
|
172
|
-
socketTimeoutMS: 45000, //
|
|
173
|
-
serverSelectionTimeoutMS: 15000, //
|
|
252
|
+
connectTimeoutMS: 15000, // 15 second timeout
|
|
253
|
+
socketTimeoutMS: 45000, // 45 second socket timeout
|
|
254
|
+
serverSelectionTimeoutMS: 15000, // 15 second server selection timeout
|
|
174
255
|
heartbeatFrequencyMS: 10000, // Heartbeat frequency
|
|
175
256
|
retryWrites: true,
|
|
176
257
|
retryReads: true,
|
|
@@ -179,39 +260,225 @@ function connectDB() {
|
|
|
179
260
|
maxPoolSize: 10, // Maximum number of connections in the pool
|
|
180
261
|
minPoolSize: 2, // Minimum number of connections in the pool
|
|
181
262
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}, 20000); // 20 second timeout
|
|
187
|
-
});
|
|
188
|
-
return [4 /*yield*/, Promise.race([connectPromise, timeoutPromise])];
|
|
189
|
-
case 2:
|
|
263
|
+
// Attempt connection
|
|
264
|
+
return [4 /*yield*/, mongoose.connect(mongoUri, options)];
|
|
265
|
+
case 8:
|
|
266
|
+
// Attempt connection
|
|
190
267
|
_a.sent();
|
|
191
268
|
// If we get here, connection was successful
|
|
192
269
|
console.log('✅ Connected to MongoDB');
|
|
193
|
-
connectionRetryCount = 0; // Reset retry count
|
|
270
|
+
connectionRetryCount = 0; // Reset retry count on success
|
|
194
271
|
isConnecting = false;
|
|
195
|
-
return [3 /*break*/,
|
|
196
|
-
case
|
|
272
|
+
return [3 /*break*/, 15];
|
|
273
|
+
case 9:
|
|
197
274
|
error_1 = _a.sent();
|
|
198
275
|
isConnecting = false;
|
|
199
276
|
errorMessage = (error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || 'Unknown error';
|
|
200
|
-
|
|
277
|
+
errorStack = (error_1 === null || error_1 === void 0 ? void 0 : error_1.stack) || 'No stack trace available';
|
|
278
|
+
errorName = (error_1 === null || error_1 === void 0 ? void 0 : error_1.name) || 'Error';
|
|
279
|
+
console.error('❌ MongoDB connection failed:');
|
|
280
|
+
console.error(" Error Name: ".concat(errorName));
|
|
281
|
+
console.error(" Error Message: ".concat(errorMessage));
|
|
282
|
+
console.error(" Error Stack: ".concat(errorStack));
|
|
283
|
+
if (error_1 === null || error_1 === void 0 ? void 0 : error_1.code) {
|
|
284
|
+
console.error(" Error Code: ".concat(error_1.code));
|
|
285
|
+
}
|
|
286
|
+
if (error_1 === null || error_1 === void 0 ? void 0 : error_1.codeName) {
|
|
287
|
+
console.error(" Error Code Name: ".concat(error_1.codeName));
|
|
288
|
+
}
|
|
289
|
+
_a.label = 10;
|
|
290
|
+
case 10:
|
|
291
|
+
_a.trys.push([10, 13, , 14]);
|
|
292
|
+
if (!(mongoose.connection.readyState !== 0)) return [3 /*break*/, 12];
|
|
293
|
+
return [4 /*yield*/, mongoose.connection.close()];
|
|
294
|
+
case 11:
|
|
295
|
+
_a.sent();
|
|
296
|
+
_a.label = 12;
|
|
297
|
+
case 12: return [3 /*break*/, 14];
|
|
298
|
+
case 13:
|
|
299
|
+
closeError_2 = _a.sent();
|
|
300
|
+
// Log close errors instead of suppressing them
|
|
301
|
+
console.error('❌ Error closing MongoDB connection:', (closeError_2 === null || closeError_2 === void 0 ? void 0 : closeError_2.message) || closeError_2);
|
|
302
|
+
if (closeError_2 === null || closeError_2 === void 0 ? void 0 : closeError_2.stack) {
|
|
303
|
+
console.error(' Stack:', closeError_2.stack);
|
|
304
|
+
}
|
|
305
|
+
return [3 /*break*/, 14];
|
|
306
|
+
case 14:
|
|
307
|
+
// Send immediate alert on first connection failure (critical issue)
|
|
308
|
+
if (connectionRetryCount === 0) {
|
|
309
|
+
console.error('🚨 CRITICAL: MongoDB connection failed on first attempt. Sending immediate alert...');
|
|
310
|
+
sendMongoDBConnectionAlert('CRITICAL: Initial connection failure', error_1).catch(function (alertError) {
|
|
311
|
+
console.error('❌ Failed to send immediate alert:', (alertError === null || alertError === void 0 ? void 0 : alertError.message) || alertError);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
201
314
|
// Only attempt retry if we haven't exceeded max attempts
|
|
202
315
|
if (connectionRetryCount < MAX_RETRY_ATTEMPTS) {
|
|
203
316
|
attemptReconnection();
|
|
204
317
|
}
|
|
205
318
|
else {
|
|
206
|
-
|
|
207
|
-
|
|
319
|
+
// Send alert email if we've reached max attempts and haven't sent it yet
|
|
320
|
+
if (!alertEmailSent) {
|
|
321
|
+
console.error('🚨 CRITICAL: MongoDB connection failed after maximum retry attempts. Sending alert...');
|
|
322
|
+
sendMongoDBConnectionAlert('CRITICAL: Maximum retry attempts reached', error_1).catch(function (alertError) {
|
|
323
|
+
console.error('❌ Failed to send max retry alert:', (alertError === null || alertError === void 0 ? void 0 : alertError.message) || alertError);
|
|
324
|
+
});
|
|
325
|
+
alertEmailSent = true;
|
|
326
|
+
}
|
|
327
|
+
// After max attempts, schedule a longer wait before retrying
|
|
328
|
+
attemptReconnection(); // This will handle the long delay
|
|
329
|
+
}
|
|
330
|
+
return [3 /*break*/, 15];
|
|
331
|
+
case 15: return [2 /*return*/];
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Send email alert to Cloud IDE team about MongoDB connection failure
|
|
338
|
+
* This function works without requiring MongoDB connection
|
|
339
|
+
* @param severity - Alert severity level (e.g., 'CRITICAL', 'WARNING')
|
|
340
|
+
* @param error - Optional error object for detailed error information
|
|
341
|
+
*/
|
|
342
|
+
function sendMongoDBConnectionAlert() {
|
|
343
|
+
return __awaiter(this, arguments, void 0, function (severity, error) {
|
|
344
|
+
var subject, body, recipientEmail, serverName_1, serverName, mongoUri, errorDetails, emailGatewayUrl, emailGatewayApiKey, senderEmail, axios, emailPayload, emailError_1, error_2;
|
|
345
|
+
if (severity === void 0) { severity = 'WARNING'; }
|
|
346
|
+
return __generator(this, function (_a) {
|
|
347
|
+
switch (_a.label) {
|
|
348
|
+
case 0:
|
|
349
|
+
subject = '';
|
|
350
|
+
body = '';
|
|
351
|
+
_a.label = 1;
|
|
352
|
+
case 1:
|
|
353
|
+
_a.trys.push([1, 8, , 9]);
|
|
354
|
+
recipientEmail = process.env.CLOUD_IDE_ALERT_EMAIL || process.env.SYSTEM_ALERT_EMAIL;
|
|
355
|
+
if (!recipientEmail) {
|
|
356
|
+
console.warn('⚠️ MongoDB alert email not sent: CLOUD_IDE_ALERT_EMAIL or SYSTEM_ALERT_EMAIL not configured');
|
|
357
|
+
serverName_1 = process.env.SERVER_NAME || process.env.NODE_ENV || 'Unknown';
|
|
358
|
+
subject = "\uD83D\uDEA8 ".concat(severity, ": MongoDB Connection Failure - ").concat(serverName_1);
|
|
359
|
+
body = "MongoDB connection alert - email recipient not configured. Please check CLOUD_IDE_ALERT_EMAIL or SYSTEM_ALERT_EMAIL environment variable.";
|
|
360
|
+
logAlertToFile(severity, subject, body, error);
|
|
361
|
+
return [2 /*return*/];
|
|
208
362
|
}
|
|
209
|
-
|
|
210
|
-
|
|
363
|
+
serverName = process.env.SERVER_NAME || process.env.NODE_ENV || 'Unknown';
|
|
364
|
+
mongoUri = process.env.MONGODB_URI ?
|
|
365
|
+
process.env.MONGODB_URI.replace(/\/\/([^:]+):([^@]+)@/, '//***:***@') : // Mask credentials
|
|
366
|
+
'Not configured';
|
|
367
|
+
errorDetails = error ? "\nError Details:\n- Error Name: ".concat((error === null || error === void 0 ? void 0 : error.name) || 'Unknown', "\n- Error Message: ").concat((error === null || error === void 0 ? void 0 : error.message) || 'No error message', "\n- Error Code: ").concat((error === null || error === void 0 ? void 0 : error.code) || 'N/A', "\n- Error Code Name: ").concat((error === null || error === void 0 ? void 0 : error.codeName) || 'N/A', "\n").concat((error === null || error === void 0 ? void 0 : error.stack) ? "- Error Stack: ".concat(error.stack.substring(0, 500), "...") : '', "\n ") : '';
|
|
368
|
+
subject = "\uD83D\uDEA8 ".concat(severity, ": MongoDB Connection Failure - ").concat(serverName);
|
|
369
|
+
body = "\n".concat(severity, ": MongoDB Connection Failure Alert\n\nSystem Information:\n- Server: ").concat(serverName, "\n- Environment: ").concat(process.env.NODE_ENV || 'Unknown', "\n- Timestamp: ").concat(new Date().toISOString(), "\n- MongoDB URI: ").concat(mongoUri, "\n- Severity: ").concat(severity, "\n\nConnection Status:\n- Retry Attempts: ").concat(connectionRetryCount, "/").concat(MAX_RETRY_ATTEMPTS, "\n- Connection State: ").concat(mongoose.connection.readyState === 0 ? 'Disconnected' :
|
|
370
|
+
mongoose.connection.readyState === 1 ? 'Connected' :
|
|
371
|
+
mongoose.connection.readyState === 2 ? 'Connecting' : 'Unknown', "\n- Is Connecting: ").concat(isConnecting ? 'Yes' : 'No', "\n\n").concat(errorDetails, "\n\nAction Required:\n").concat(severity === 'CRITICAL' ?
|
|
372
|
+
'⚠️ CRITICAL: The system cannot connect to MongoDB. Database operations are failing.' :
|
|
373
|
+
"The system has failed to connect to MongoDB after ".concat(connectionRetryCount, " retry attempts."), "\n\nPlease check immediately:\n1. MongoDB server status (Atlas cluster, local server, etc.)\n2. Network connectivity and firewall rules\n3. IP whitelist in MongoDB Atlas (if using Atlas)\n4. MongoDB URI configuration and credentials\n5. MongoDB authentication credentials validity\n6. Server resources (memory, CPU, disk space)\n\nCommon Issues:\n- IP address not whitelisted in MongoDB Atlas\n- Network connectivity problems\n- MongoDB server is down or unreachable\n- Incorrect connection string or credentials\n- Firewall blocking MongoDB port (usually 27017)\n\nThe system will continue to retry connection automatically, but database operations may fail until connection is restored.\n\nThis is an automated alert from Cloud IDE System Monitoring.\n ").trim();
|
|
374
|
+
emailGatewayUrl = process.env.EMAIL_GATEWAY_URL;
|
|
375
|
+
emailGatewayApiKey = process.env.EMAIL_GATEWAY_API_KEY;
|
|
376
|
+
senderEmail = process.env.EMAIL_SENDER || process.env.SYSTEM_EMAIL || 'noreply@cloudide.com';
|
|
377
|
+
if (!(emailGatewayUrl && emailGatewayApiKey)) return [3 /*break*/, 6];
|
|
378
|
+
axios = require('axios');
|
|
379
|
+
emailPayload = {
|
|
380
|
+
to: recipientEmail,
|
|
381
|
+
from: senderEmail,
|
|
382
|
+
subject: subject,
|
|
383
|
+
body: body,
|
|
384
|
+
html: body.replace(/\n/g, '<br>') // Convert newlines to HTML breaks
|
|
385
|
+
};
|
|
386
|
+
_a.label = 2;
|
|
387
|
+
case 2:
|
|
388
|
+
_a.trys.push([2, 4, , 5]);
|
|
389
|
+
return [4 /*yield*/, axios.post(emailGatewayUrl, emailPayload, {
|
|
390
|
+
headers: {
|
|
391
|
+
'Content-Type': 'application/json',
|
|
392
|
+
'Authorization': "Bearer ".concat(emailGatewayApiKey),
|
|
393
|
+
'X-API-Key': emailGatewayApiKey
|
|
394
|
+
},
|
|
395
|
+
timeout: 10000 // 10 second timeout
|
|
396
|
+
})];
|
|
397
|
+
case 3:
|
|
398
|
+
_a.sent();
|
|
399
|
+
console.log("\uD83D\uDCE7 MongoDB connection failure alert email sent to ".concat(recipientEmail));
|
|
400
|
+
return [3 /*break*/, 5];
|
|
401
|
+
case 4:
|
|
402
|
+
emailError_1 = _a.sent();
|
|
403
|
+
console.error('❌ Failed to send alert email via gateway:', (emailError_1 === null || emailError_1 === void 0 ? void 0 : emailError_1.message) || emailError_1);
|
|
404
|
+
// Fallback: Log to file when email fails
|
|
405
|
+
logAlertToFile(severity, subject, body, emailError_1);
|
|
406
|
+
return [3 /*break*/, 5];
|
|
407
|
+
case 5: return [3 /*break*/, 7];
|
|
408
|
+
case 6:
|
|
409
|
+
console.warn('⚠️ Alert email not sent: EMAIL_GATEWAY_URL and EMAIL_GATEWAY_API_KEY not configured');
|
|
410
|
+
console.warn('⚠️ Please configure email gateway environment variables for MongoDB connection failure alerts');
|
|
411
|
+
console.warn("\u26A0\uFE0F Alert details would have been sent to: ".concat(recipientEmail));
|
|
412
|
+
// Fallback: Log to file when email gateway not configured
|
|
413
|
+
logAlertToFile(severity, subject, body, error);
|
|
414
|
+
_a.label = 7;
|
|
415
|
+
case 7: return [3 /*break*/, 9];
|
|
416
|
+
case 8:
|
|
417
|
+
error_2 = _a.sent();
|
|
418
|
+
// Don't throw - this is a non-critical operation
|
|
419
|
+
console.error('❌ Failed to send MongoDB connection alert email:', (error_2 === null || error_2 === void 0 ? void 0 : error_2.message) || error_2);
|
|
420
|
+
// Fallback: Log to file when everything fails
|
|
421
|
+
logAlertToFile(severity, subject || 'MongoDB Connection Alert', body || 'MongoDB connection issue detected', error_2);
|
|
422
|
+
return [3 /*break*/, 9];
|
|
423
|
+
case 9: return [2 /*return*/];
|
|
211
424
|
}
|
|
212
425
|
});
|
|
213
426
|
});
|
|
214
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Log alert to file (fallback when email fails)
|
|
430
|
+
* This ensures critical alerts are never lost
|
|
431
|
+
*/
|
|
432
|
+
function logAlertToFile(severity, subject, body, error) {
|
|
433
|
+
var _a, _b;
|
|
434
|
+
try {
|
|
435
|
+
// Log directory - create in project root/logs/alerts
|
|
436
|
+
var logDir = path.join(process.cwd(), 'logs', 'alerts');
|
|
437
|
+
// Ensure directory exists
|
|
438
|
+
if (!fs.existsSync(logDir)) {
|
|
439
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
440
|
+
}
|
|
441
|
+
// Get log file path for today (YYYY-MM-DD format)
|
|
442
|
+
var today = new Date();
|
|
443
|
+
var dateStr = today.toISOString().split('T')[0];
|
|
444
|
+
var logFilePath = path.join(logDir, "mongodb-alerts-".concat(dateStr, ".log"));
|
|
445
|
+
// Format log entry
|
|
446
|
+
var now = new Date();
|
|
447
|
+
var timestamp = now.toISOString();
|
|
448
|
+
var dateTime = now.toLocaleString('en-US', {
|
|
449
|
+
timeZone: 'UTC',
|
|
450
|
+
dateStyle: 'full',
|
|
451
|
+
timeStyle: 'long'
|
|
452
|
+
});
|
|
453
|
+
var logEntry = "\n".concat('='.repeat(80), "\nMONGODB ALERT LOG ENTRY\n").concat('='.repeat(80), "\nTimestamp: ").concat(timestamp, "\nDate & Time: ").concat(dateTime, "\nSeverity: ").concat(severity, "\nSubject: ").concat(subject, "\n\n").concat(body, "\n\n");
|
|
454
|
+
// Add error details if provided
|
|
455
|
+
if (error) {
|
|
456
|
+
logEntry += "\nERROR DETAILS:\n".concat('-'.repeat(80), "\n- Error Name: ").concat((error === null || error === void 0 ? void 0 : error.name) || 'Unknown', "\n- Error Message: ").concat((error === null || error === void 0 ? void 0 : error.message) || 'No error message', "\n- Error Code: ").concat((error === null || error === void 0 ? void 0 : error.code) || 'N/A', "\n- Error Code Name: ").concat((error === null || error === void 0 ? void 0 : error.codeName) || 'N/A', "\n");
|
|
457
|
+
if (error === null || error === void 0 ? void 0 : error.stack) {
|
|
458
|
+
logEntry += "- Error Stack:\n".concat(error.stack, "\n");
|
|
459
|
+
}
|
|
460
|
+
if (error === null || error === void 0 ? void 0 : error.response) {
|
|
461
|
+
logEntry += "- HTTP Response Status: ".concat(((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) || 'N/A', "\n");
|
|
462
|
+
logEntry += "- HTTP Response Data: ".concat(JSON.stringify(((_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) || {}, null, 2), "\n");
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
logEntry += "".concat('='.repeat(80), "\n\n");
|
|
466
|
+
// Append to log file
|
|
467
|
+
fs.appendFileSync(logFilePath, logEntry, 'utf8');
|
|
468
|
+
console.log("\uD83D\uDCDD Alert logged to file: ".concat(logFilePath));
|
|
469
|
+
}
|
|
470
|
+
catch (fileError) {
|
|
471
|
+
// If file logging fails, at least log to console
|
|
472
|
+
console.error('❌ Failed to write alert to log file:', (fileError === null || fileError === void 0 ? void 0 : fileError.message) || fileError);
|
|
473
|
+
console.error('📝 Alert details (console fallback):');
|
|
474
|
+
console.error(" Severity: ".concat(severity));
|
|
475
|
+
console.error(" Subject: ".concat(subject));
|
|
476
|
+
console.error(" Body: ".concat(body));
|
|
477
|
+
if (error) {
|
|
478
|
+
console.error(" Error: ".concat((error === null || error === void 0 ? void 0 : error.message) || error));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
215
482
|
// Event listener for success and error
|
|
216
483
|
var customUUID = function () {
|
|
217
484
|
var _a, _b, _c;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IAcademicsBonafideRequest } from "cloud-ide-lms-model";
|
|
2
|
+
import mongoose from "mongoose";
|
|
3
|
+
declare const CAcademicsBonafideRequest: mongoose.Model<IAcademicsBonafideRequest, {}, {}, {}, mongoose.Document<unknown, {}, IAcademicsBonafideRequest, {}> & IAcademicsBonafideRequest & Required<{
|
|
4
|
+
_id: string;
|
|
5
|
+
}> & {
|
|
6
|
+
__v: number;
|
|
7
|
+
}, any>;
|
|
8
|
+
export { CAcademicsBonafideRequest };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CAcademicsBonafideRequest = void 0;
|
|
4
|
+
var mongoose_1 = require("mongoose");
|
|
5
|
+
/* SCHEMA START */
|
|
6
|
+
var academics_bonafide_request = new mongoose_1.Schema({
|
|
7
|
+
abnr_request_number: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true,
|
|
10
|
+
unique: true,
|
|
11
|
+
maxlength: 50,
|
|
12
|
+
trim: true,
|
|
13
|
+
comment: "Auto-generated request number (e.g., BNF-2025-001234)"
|
|
14
|
+
},
|
|
15
|
+
abnr_student_id: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
maxlength: 50,
|
|
19
|
+
trim: true,
|
|
20
|
+
comment: "Student ID"
|
|
21
|
+
},
|
|
22
|
+
abnr_student_id_auth: {
|
|
23
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
24
|
+
ref: "auth_user_mst",
|
|
25
|
+
required: true,
|
|
26
|
+
comment: "Student user ID"
|
|
27
|
+
},
|
|
28
|
+
abnr_purpose: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true,
|
|
31
|
+
maxlength: 500,
|
|
32
|
+
trim: true,
|
|
33
|
+
comment: "Purpose of bonafide certificate"
|
|
34
|
+
},
|
|
35
|
+
abnr_request_date: {
|
|
36
|
+
type: Date,
|
|
37
|
+
required: true,
|
|
38
|
+
default: Date.now,
|
|
39
|
+
comment: "Request submission date"
|
|
40
|
+
},
|
|
41
|
+
abnr_status_id_sygms: {
|
|
42
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
43
|
+
ref: "core_general_master",
|
|
44
|
+
required: true,
|
|
45
|
+
comment: "Request status (from BONAFIDE_STATUS type)"
|
|
46
|
+
},
|
|
47
|
+
abnr_current_step: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: 1,
|
|
50
|
+
comment: "Current workflow step"
|
|
51
|
+
},
|
|
52
|
+
abnr_workflow_id_wfrg: {
|
|
53
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
54
|
+
ref: "core_workflow_registry",
|
|
55
|
+
required: true,
|
|
56
|
+
comment: "Workflow reference"
|
|
57
|
+
},
|
|
58
|
+
abnr_requested_by_user: {
|
|
59
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
60
|
+
ref: "auth_user_mst",
|
|
61
|
+
required: true,
|
|
62
|
+
comment: "User who created the request"
|
|
63
|
+
},
|
|
64
|
+
abnr_soft_copy_id_cyfm: {
|
|
65
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
66
|
+
ref: "core_file_manager",
|
|
67
|
+
comment: "Generated soft copy PDF"
|
|
68
|
+
},
|
|
69
|
+
abnr_stamped_copy_id_cyfm: {
|
|
70
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
71
|
+
ref: "core_file_manager",
|
|
72
|
+
comment: "Stamped hard copy scan"
|
|
73
|
+
},
|
|
74
|
+
abnr_completed_date: {
|
|
75
|
+
type: Date,
|
|
76
|
+
comment: "Date when request was completed"
|
|
77
|
+
},
|
|
78
|
+
abnr_entity_id_syen: {
|
|
79
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
80
|
+
ref: "core_system_entity",
|
|
81
|
+
required: true,
|
|
82
|
+
comment: "Entity reference"
|
|
83
|
+
},
|
|
84
|
+
abnr_isactive: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: true,
|
|
87
|
+
comment: "Active status"
|
|
88
|
+
}
|
|
89
|
+
}, { collection: 'academics_bonafide_request' });
|
|
90
|
+
// Indexes for performance optimization
|
|
91
|
+
academics_bonafide_request.index({ abnr_request_number: 1 });
|
|
92
|
+
academics_bonafide_request.index({ abnr_student_id_auth: 1, abnr_isactive: 1 });
|
|
93
|
+
academics_bonafide_request.index({ abnr_status_id_sygms: 1, abnr_isactive: 1 });
|
|
94
|
+
academics_bonafide_request.index({ abnr_workflow_id_wfrg: 1, abnr_current_step: 1 });
|
|
95
|
+
academics_bonafide_request.index({ abnr_entity_id_syen: 1, abnr_isactive: 1 });
|
|
96
|
+
academics_bonafide_request.index({ abnr_request_date: -1 });
|
|
97
|
+
var CAcademicsBonafideRequest = mongoose_1.default.model("academics_bonafide_request", academics_bonafide_request);
|
|
98
|
+
exports.CAcademicsBonafideRequest = CAcademicsBonafideRequest;
|
|
@@ -20,3 +20,4 @@ __exportStar(require("./aca_class_program_master"), exports);
|
|
|
20
20
|
__exportStar(require("./aca_class_program_term"), exports);
|
|
21
21
|
__exportStar(require("./aca_prg_trm_section"), exports);
|
|
22
22
|
__exportStar(require("./aca_class_prg_branch"), exports);
|
|
23
|
+
__exportStar(require("./academics_bonafide_request"), exports);
|
|
@@ -99,6 +99,50 @@ var admission_application_main = new mongoose_1.Schema({
|
|
|
99
99
|
ref: "core_file_manager",
|
|
100
100
|
comment: "Student photo file manager ID"
|
|
101
101
|
},
|
|
102
|
+
admap_identification_status_id_sygms: {
|
|
103
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
104
|
+
ref: "core_general_master",
|
|
105
|
+
comment: "Student identification status (Alive, Passed Away, etc.) - Reference to core_general_master with type 'IDENTIFICATION_STATUS'"
|
|
106
|
+
},
|
|
107
|
+
admap_is_rte_scheme: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: false,
|
|
110
|
+
comment: "Is student under Right to Education (RTE) scheme - if true, RTE details will be required"
|
|
111
|
+
},
|
|
112
|
+
admap_grn: {
|
|
113
|
+
type: String,
|
|
114
|
+
maxlength: 100,
|
|
115
|
+
trim: true,
|
|
116
|
+
comment: "General Registration Number assigned by authority (CBSE, State Board, etc.)"
|
|
117
|
+
},
|
|
118
|
+
admap_grn_authority_id_edbrd: {
|
|
119
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
120
|
+
ref: "core_education_board",
|
|
121
|
+
comment: "Education board/authority that assigned GRN - Reference to core_education_board"
|
|
122
|
+
},
|
|
123
|
+
admap_handicap_certificate_id_cyfm: {
|
|
124
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
125
|
+
ref: "core_file_manager",
|
|
126
|
+
comment: "Handicap certificate file manager ID"
|
|
127
|
+
},
|
|
128
|
+
admap_handicap_certificate_number: {
|
|
129
|
+
type: String,
|
|
130
|
+
maxlength: 100,
|
|
131
|
+
trim: true,
|
|
132
|
+
comment: "Handicap certificate number"
|
|
133
|
+
},
|
|
134
|
+
admap_handicap_percentage: {
|
|
135
|
+
type: Number,
|
|
136
|
+
min: 0,
|
|
137
|
+
max: 100,
|
|
138
|
+
comment: "Handicap percentage (0-100)"
|
|
139
|
+
},
|
|
140
|
+
admap_accessibility_requirements: {
|
|
141
|
+
type: String,
|
|
142
|
+
maxlength: 1000,
|
|
143
|
+
trim: true,
|
|
144
|
+
comment: "Accessibility requirements and special accommodations needed"
|
|
145
|
+
},
|
|
102
146
|
// SECTION 2: CONTACT & ADDRESS INFORMATION
|
|
103
147
|
admap_primary_email: {
|
|
104
148
|
type: String,
|
|
@@ -249,6 +249,11 @@ var admission_family_members = new mongoose_1.Schema({
|
|
|
249
249
|
trim: true,
|
|
250
250
|
comment: "Additional remarks/notes"
|
|
251
251
|
},
|
|
252
|
+
admfm_identification_status_id_sygms: {
|
|
253
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
254
|
+
ref: 'core_general_master',
|
|
255
|
+
comment: "Identification status for father/guardian (Alive, Passed Away, etc.) - Reference to core_general_master with type 'IDENTIFICATION_STATUS'"
|
|
256
|
+
},
|
|
252
257
|
admfm_isactive: {
|
|
253
258
|
type: Boolean,
|
|
254
259
|
default: true,
|