@optimiser/common 1.0.210 → 1.0.214
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/dist/lib/connection.d.ts +0 -8
- package/dist/lib/connection.js +0 -39
- package/dist/lib/helper.d.ts +17 -1
- package/dist/lib/helper.js +127 -41
- package/dist/lib/utility.d.ts +11 -2
- package/dist/lib/utility.js +55 -1
- package/package.json +1 -1
package/dist/lib/connection.d.ts
CHANGED
|
@@ -100,13 +100,5 @@ declare class Connection {
|
|
|
100
100
|
* @description Helper function to send response
|
|
101
101
|
*/
|
|
102
102
|
ReturnJsonResponse: (req: OPT_Request, res: Response, params: ResponseStructure) => void;
|
|
103
|
-
/**
|
|
104
|
-
* @param Error Error object
|
|
105
|
-
* @param ServiceOrigin - Error Occur in Service (Service Name)
|
|
106
|
-
* @param Module Module
|
|
107
|
-
* @param db db connection
|
|
108
|
-
* @description Error handler function: Send Error Email & Save Error in database
|
|
109
|
-
*/
|
|
110
|
-
ErrorHandlerForServices: (Error: OPT_ERROR, ServiceOrigin: string, Module?: string | undefined, db?: Db | undefined) => Promise<any>;
|
|
111
103
|
}
|
|
112
104
|
export { Connection };
|
package/dist/lib/connection.js
CHANGED
|
@@ -44,7 +44,6 @@ var mongodb_1 = require("mongodb");
|
|
|
44
44
|
var sequelize_1 = require("sequelize");
|
|
45
45
|
var errorHandler_1 = __importDefault(require("../utility/errorHandler"));
|
|
46
46
|
var mail_1 = require("../utility/mail");
|
|
47
|
-
var errorHandlerForServices_1 = __importDefault(require("../utility/errorHandlerForServices"));
|
|
48
47
|
var Connection = /** @class */ (function () {
|
|
49
48
|
/**
|
|
50
49
|
* @param masterConfig Master Connectivity Object
|
|
@@ -262,44 +261,6 @@ var Connection = /** @class */ (function () {
|
|
|
262
261
|
data: params.Data
|
|
263
262
|
});
|
|
264
263
|
};
|
|
265
|
-
/**
|
|
266
|
-
* @param Error Error object
|
|
267
|
-
* @param ServiceOrigin - Error Occur in Service (Service Name)
|
|
268
|
-
* @param Module Module
|
|
269
|
-
* @param db db connection
|
|
270
|
-
* @description Error handler function: Send Error Email & Save Error in database
|
|
271
|
-
*/
|
|
272
|
-
this.ErrorHandlerForServices = function (Error, ServiceOrigin, Module, db) { return __awaiter(_this, void 0, void 0, function () {
|
|
273
|
-
var errorConfig, _a, mailObj, errorObj, saveObj, error_2;
|
|
274
|
-
return __generator(this, function (_b) {
|
|
275
|
-
switch (_b.label) {
|
|
276
|
-
case 0:
|
|
277
|
-
errorConfig = { ErrorReportFrom: this.masterConfig.ERROR_REPORT_FROM, ErrorReportTo: this.masterConfig.ERROR_REPORT_TO };
|
|
278
|
-
_a = errorHandlerForServices_1.default(Error, errorConfig, ServiceOrigin), mailObj = _a.mailObj, errorObj = _a.errorObj;
|
|
279
|
-
_b.label = 1;
|
|
280
|
-
case 1:
|
|
281
|
-
_b.trys.push([1, 4, , 5]);
|
|
282
|
-
mail_1.SendMail(mailObj, {
|
|
283
|
-
SES_ACCESS_ID: this.masterConfig.SES_ACCESS_ID,
|
|
284
|
-
SES_SECRET_KEY: this.masterConfig.SES_SECRET_KEY,
|
|
285
|
-
SES_REGION: this.masterConfig.SES_REGION
|
|
286
|
-
}).then(function (response) {
|
|
287
|
-
// console.log(response)
|
|
288
|
-
});
|
|
289
|
-
if (!db) return [3 /*break*/, 3];
|
|
290
|
-
return [4 /*yield*/, db.collection(Module + "-Error").insertOne(errorObj)];
|
|
291
|
-
case 2:
|
|
292
|
-
saveObj = _b.sent();
|
|
293
|
-
_b.label = 3;
|
|
294
|
-
case 3: return [3 /*break*/, 5];
|
|
295
|
-
case 4:
|
|
296
|
-
error_2 = _b.sent();
|
|
297
|
-
console.log("Error While connectin to Master DB", error_2);
|
|
298
|
-
return [3 /*break*/, 5];
|
|
299
|
-
case 5: return [2 /*return*/];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
}); };
|
|
303
264
|
this.ConnectToDb({
|
|
304
265
|
DBAddress: masterConfig.MASTER_CONNECTION_STRING,
|
|
305
266
|
DBName: masterConfig.MASTER_DB_NAME
|
package/dist/lib/helper.d.ts
CHANGED
|
@@ -65,4 +65,20 @@ declare const SubscribeEmailForAllDomains: (db: Db, email: string, isSubscribe:
|
|
|
65
65
|
}
|
|
66
66
|
*/
|
|
67
67
|
declare const IsValidPhoneNumber: (phoneNumber: string, countryCode: string) => AnyObjectInterface;
|
|
68
|
-
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* Server side field validatinon
|
|
71
|
+
* @param {db} object database connection
|
|
72
|
+
* @param {dataObj} object contains field data
|
|
73
|
+
* @param {objectType} string object name
|
|
74
|
+
* @param {countryCode} string, ISO country code
|
|
75
|
+
* @returns {
|
|
76
|
+
IsValid: boolean, //phone is valid or not
|
|
77
|
+
CountryCode?: string, //phone country code
|
|
78
|
+
PhoneCallingCode?: CountryCallingCode, //phone country calling code
|
|
79
|
+
PhoneNumberParsed?: NationalNumber, //phone no local to the country, without country calling code and only digits
|
|
80
|
+
Error: Error
|
|
81
|
+
}
|
|
82
|
+
*/
|
|
83
|
+
declare function ValidateData(db: Db, dataObj: AnyObjectInterface, objectType: string): Promise<unknown>;
|
|
84
|
+
export { GetCompanyDetails, GetListSchema, GetEmailwiseUnsubscribeData, GenerateAutoIncrementFieldValue, GetAccountDetailByName, GetContactDetailByEmail, GetSystemEmailTemplate, UpdateContactDetails, CreateContact, MapAccountContact, UpdatePipelineMailStatus, AddLog, CheckDateExistInRange, GetDateRangeFromOperatorValue, GetEmailSubscribeStatus, SubscribeEmailForAllDomains, IsValidPhoneNumber, ValidateData };
|
package/dist/lib/helper.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.IsValidPhoneNumber = exports.SubscribeEmailForAllDomains = exports.GetEmailSubscribeStatus = exports.GetDateRangeFromOperatorValue = exports.CheckDateExistInRange = exports.AddLog = exports.UpdatePipelineMailStatus = exports.MapAccountContact = exports.CreateContact = exports.UpdateContactDetails = exports.GetSystemEmailTemplate = exports.GetContactDetailByEmail = exports.GetAccountDetailByName = exports.GenerateAutoIncrementFieldValue = exports.GetEmailwiseUnsubscribeData = exports.GetListSchema = exports.GetCompanyDetails = void 0;
|
|
42
|
+
exports.ValidateData = exports.IsValidPhoneNumber = exports.SubscribeEmailForAllDomains = exports.GetEmailSubscribeStatus = exports.GetDateRangeFromOperatorValue = exports.CheckDateExistInRange = exports.AddLog = exports.UpdatePipelineMailStatus = exports.MapAccountContact = exports.CreateContact = exports.UpdateContactDetails = exports.GetSystemEmailTemplate = exports.GetContactDetailByEmail = exports.GetAccountDetailByName = exports.GenerateAutoIncrementFieldValue = exports.GetEmailwiseUnsubscribeData = exports.GetListSchema = exports.GetCompanyDetails = void 0;
|
|
43
43
|
var mongodb_1 = require("mongodb");
|
|
44
44
|
var moment_1 = __importDefault(require("moment"));
|
|
45
45
|
var libphonenumber_js_1 = require("libphonenumber-js");
|
|
@@ -242,48 +242,97 @@ function UpdateContactDetails(db, contactData) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
exports.UpdateContactDetails = UpdateContactDetails;
|
|
245
|
+
// function CreateContact(db: Db, contactData: AnyObjectInterface): Promise<null | AnyObjectInterface> {
|
|
246
|
+
// return new Promise(function (resolve, reject) {
|
|
247
|
+
// let contactObj = {
|
|
248
|
+
// "Salutation": null,
|
|
249
|
+
// "OwnerID": contactData.OwnerID,
|
|
250
|
+
// "FirstName": contactData.FirstName,
|
|
251
|
+
// "LastName": contactData.LastName,
|
|
252
|
+
// "ReportsTo": null,
|
|
253
|
+
// "JobTitle": contactData.JobTitle,
|
|
254
|
+
// "Department": null,
|
|
255
|
+
// "Email": contactData.Email,
|
|
256
|
+
// "PrimaryEmailCategory": contactData.PrimaryEmailCategory,
|
|
257
|
+
// "PhoneCountryCode": contactData.PhoneCountryCode,
|
|
258
|
+
// "Phone": contactData.Phone,
|
|
259
|
+
// "Mobile": null,
|
|
260
|
+
// "Birthdate": null,
|
|
261
|
+
// "LinkedIn": null,
|
|
262
|
+
// "AccountID": null,
|
|
263
|
+
// "Address": null,
|
|
264
|
+
// "City": null,
|
|
265
|
+
// "State": null,
|
|
266
|
+
// "Country": null,
|
|
267
|
+
// "PostalCode": null,
|
|
268
|
+
// "SearchAddress": {
|
|
269
|
+
// "lat": "",
|
|
270
|
+
// "lng": ""
|
|
271
|
+
// },
|
|
272
|
+
// "CreatedBy": contactData.OwnerID,
|
|
273
|
+
// "CreatedDate": new Date(),
|
|
274
|
+
// "IsActive": true,
|
|
275
|
+
// "RelationID": null
|
|
276
|
+
// }
|
|
277
|
+
// db.collection("Contact").insertOne(contactObj, function (error, result) {
|
|
278
|
+
// if (error) {
|
|
279
|
+
// resolve(null);
|
|
280
|
+
// }
|
|
281
|
+
// if (result) {
|
|
282
|
+
// resolve(result);
|
|
283
|
+
// } else {
|
|
284
|
+
// resolve(null);
|
|
285
|
+
// }
|
|
286
|
+
// });
|
|
287
|
+
// });
|
|
288
|
+
// }
|
|
245
289
|
function CreateContact(db, contactData) {
|
|
246
290
|
return new Promise(function (resolve, reject) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
291
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
292
|
+
var contactObj;
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
contactObj = {
|
|
295
|
+
"Salutation": contactData.Salutation,
|
|
296
|
+
"OwnerID": contactData.OwnerID,
|
|
297
|
+
"FirstName": contactData.FirstName,
|
|
298
|
+
"LastName": contactData.LastName,
|
|
299
|
+
"ReportsTo": null,
|
|
300
|
+
"JobTitle": contactData.JobTitle,
|
|
301
|
+
"Department": null,
|
|
302
|
+
"Email": contactData.Email,
|
|
303
|
+
"PrimaryEmailCategory": contactData.PrimaryEmailCategory,
|
|
304
|
+
"PhoneCountryCode": contactData.PhoneCountryCode,
|
|
305
|
+
"Phone": contactData.Phone,
|
|
306
|
+
"Mobile": null,
|
|
307
|
+
"Birthdate": null,
|
|
308
|
+
"LinkedIn": null,
|
|
309
|
+
"AccountID": null,
|
|
310
|
+
"Address": null,
|
|
311
|
+
"City": null,
|
|
312
|
+
"State": null,
|
|
313
|
+
"Country": null,
|
|
314
|
+
"PostalCode": null,
|
|
315
|
+
"SearchAddress": {
|
|
316
|
+
"lat": "",
|
|
317
|
+
"lng": ""
|
|
318
|
+
},
|
|
319
|
+
"CreatedBy": contactData.OwnerID,
|
|
320
|
+
"CreatedDate": new Date(),
|
|
321
|
+
"IsActive": true,
|
|
322
|
+
"RelationID": null
|
|
323
|
+
};
|
|
324
|
+
// let validationMsg = await ValidateData(db,contactObj,"Contact");
|
|
325
|
+
// if(validationMsg == 'success'){
|
|
326
|
+
db.collection("Contact").insertOne(contactObj, function (error, result) {
|
|
327
|
+
if (error) {
|
|
328
|
+
resolve([error, null]);
|
|
329
|
+
}
|
|
330
|
+
if (result) {
|
|
331
|
+
resolve([null, result]);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
return [2 /*return*/];
|
|
335
|
+
});
|
|
287
336
|
});
|
|
288
337
|
});
|
|
289
338
|
}
|
|
@@ -830,3 +879,40 @@ var IsValidPhoneNumber = function (phoneNumber, countryCode) {
|
|
|
830
879
|
return result;
|
|
831
880
|
};
|
|
832
881
|
exports.IsValidPhoneNumber = IsValidPhoneNumber;
|
|
882
|
+
/**
|
|
883
|
+
*
|
|
884
|
+
* Server side field validatinon
|
|
885
|
+
* @param {db} object database connection
|
|
886
|
+
* @param {dataObj} object contains field data
|
|
887
|
+
* @param {objectType} string object name
|
|
888
|
+
* @param {countryCode} string, ISO country code
|
|
889
|
+
* @returns {
|
|
890
|
+
IsValid: boolean, //phone is valid or not
|
|
891
|
+
CountryCode?: string, //phone country code
|
|
892
|
+
PhoneCallingCode?: CountryCallingCode, //phone country calling code
|
|
893
|
+
PhoneNumberParsed?: NationalNumber, //phone no local to the country, without country calling code and only digits
|
|
894
|
+
Error: Error
|
|
895
|
+
}
|
|
896
|
+
*/
|
|
897
|
+
function ValidateData(db, dataObj, objectType) {
|
|
898
|
+
return new Promise(function (resolve, reject) {
|
|
899
|
+
db.collection("ObjectSchema").findOne({ "Name": objectType }, function (error, result) {
|
|
900
|
+
if (error) {
|
|
901
|
+
resolve('error');
|
|
902
|
+
}
|
|
903
|
+
if (result && result.Fields) {
|
|
904
|
+
var emailRegexp = /^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
|
|
905
|
+
for (var i = 0; i < result.Fields.length; i++) {
|
|
906
|
+
if (result.Fields[i].IsRequired && result.Fields[i].IsRequired == true && result.Fields[i].UIDataType != 'formula' && (dataObj[result.Fields[i].Name] == '' || dataObj[result.Fields[i].Name] == null)) {
|
|
907
|
+
resolve(result.Fields[i].Name + ' is required');
|
|
908
|
+
}
|
|
909
|
+
if (result.Fields[i].Name == 'Email' && (!emailRegexp.test(dataObj[result.Fields[i].Name]))) {
|
|
910
|
+
resolve(result.Fields[i].Name + ' is not valid');
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
resolve('success');
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
exports.ValidateData = ValidateData;
|
package/dist/lib/utility.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Moment } from "moment";
|
|
2
2
|
import { NextFunction, Response } from "express";
|
|
3
3
|
import { ObjectID, ObjectId, Db } from "mongodb";
|
|
4
|
-
import { ResponseStructure } from "../modals/connection.modal";
|
|
4
|
+
import { ResponseStructure, OPT_ERROR } from "../modals/connection.modal";
|
|
5
5
|
import { Express } from '../modals/log.modal';
|
|
6
6
|
import { AnyObjectInterface, callBackInterface } from "../modals/utility.modal";
|
|
7
7
|
import { OPT_Request } from "../modals/connection.modal";
|
|
@@ -171,4 +171,13 @@ declare function GetUserProfile(msp_d: AnyObjectInterface, db: Db, mdb: Db, next
|
|
|
171
171
|
message: string;
|
|
172
172
|
data: any;
|
|
173
173
|
} | undefined>;
|
|
174
|
-
|
|
174
|
+
/**
|
|
175
|
+
* @param Error Error object
|
|
176
|
+
* @param ServiceOrigin - Error Occur in Service (Service Name)
|
|
177
|
+
* @param EmailConfig Email configuration object
|
|
178
|
+
* @param Module Module
|
|
179
|
+
* @param db db connection
|
|
180
|
+
* @description Error handler function: Send Error Email & Save Error in database
|
|
181
|
+
*/
|
|
182
|
+
declare function ErrorHandlerForServices(Error: OPT_ERROR, ServiceOrigin: string, EmailConfig: any, Module?: string, db?: Db): Promise<any>;
|
|
183
|
+
export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, AddLog, CheckFilterFieldsProjection, VerifyEmailPassword, GetMyTeamUsers, ExtractChildUsersTree, GetMaxKeyValueListSchema, VerifyAWSEmailConfig, GenerateId, SyncUserDetailsWithMasterDB, SignoutUserFromAllDevices, SignoutUsersWithPromise, SignoutMultipleUsersFromAllDevices, UserLicenseConsumeCalculate, sendMailWithUserAccount, GetEmailClientConfigs, GetCompanyEncryptionKey, ExecuteDynamicDMLQuery, ExecuteDynamicDQLQuery, GetUserProfilePermissions, MakeUserPasswordInvalid, ConvertJsonToXLXS, SendResetPasswordMail, SendMailToSupport, MailTemplateStructure, SendMailToCustomer, parseMSPCookie, GetIPDetailsFromReq, isEmptyObj, SyncListSchemaFieldInOtherCollection, UpdateTagCountAfterDelete, SyncTagCountAfterUpdate, ReactivateFieldInOtherCollection, SyncUserLicenceConsumedCount, BroadCastEventToAllCompanyUsers, CheckDataPermission, SyncCompanyLicenceInMasterCompanyAfterAdd, NextServiceDateForDashboard, CheckDateNotInPast, GetWeekDayByDayAndOccurance, GetInterValFromOccurance, GetWeekDayInfoInMonth, GetDayIndex, GetUserProfile, ErrorHandlerForServices };
|
package/dist/lib/utility.js
CHANGED
|
@@ -54,11 +54,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
54
54
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
58
|
+
var t = {};
|
|
59
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
60
|
+
t[p] = s[p];
|
|
61
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
62
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
63
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
64
|
+
t[p[i]] = s[p[i]];
|
|
65
|
+
}
|
|
66
|
+
return t;
|
|
67
|
+
};
|
|
57
68
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
69
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
70
|
};
|
|
60
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
exports.GetUserProfile = exports.GetDayIndex = exports.GetWeekDayInfoInMonth = exports.GetInterValFromOccurance = exports.GetWeekDayByDayAndOccurance = exports.CheckDateNotInPast = exports.NextServiceDateForDashboard = exports.SyncCompanyLicenceInMasterCompanyAfterAdd = exports.CheckDataPermission = exports.BroadCastEventToAllCompanyUsers = exports.SyncUserLicenceConsumedCount = exports.ReactivateFieldInOtherCollection = exports.SyncTagCountAfterUpdate = exports.UpdateTagCountAfterDelete = exports.SyncListSchemaFieldInOtherCollection = exports.isEmptyObj = exports.GetIPDetailsFromReq = exports.parseMSPCookie = exports.SendMailToCustomer = exports.MailTemplateStructure = exports.SendMailToSupport = exports.SendResetPasswordMail = exports.ConvertJsonToXLXS = exports.MakeUserPasswordInvalid = exports.GetUserProfilePermissions = exports.ExecuteDynamicDQLQuery = exports.ExecuteDynamicDMLQuery = exports.GetCompanyEncryptionKey = exports.GetEmailClientConfigs = exports.sendMailWithUserAccount = exports.UserLicenseConsumeCalculate = exports.SignoutMultipleUsersFromAllDevices = exports.SignoutUsersWithPromise = exports.SignoutUserFromAllDevices = exports.SyncUserDetailsWithMasterDB = exports.GenerateId = exports.VerifyAWSEmailConfig = exports.GetMaxKeyValueListSchema = exports.ExtractChildUsersTree = exports.GetMyTeamUsers = exports.VerifyEmailPassword = exports.CheckFilterFieldsProjection = exports.AddLog = exports.GirdHeaderFilters = exports.FilterConditions = exports.BuildLookupFieldProjection = exports.BuildFieldProjection = exports.BuildGridFieldProjection = exports.CheckDataBeforeUpdate = exports.CheckDataBeforeAdd = exports.BuildLookupDataField = exports.SyncUserInOtherCollection = exports.SyncFieldInOtherCollection = exports.SyncFieldInSameCollectionByObjectIDWithPromise = exports.SyncFieldInSameCollectionByObjectID = exports.SyncFieldInSameCollection = exports.DeleteFieldInOtherCollection = exports.SyncParentObjectData = exports.SyncChildObjectData = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
|
|
72
|
+
exports.ErrorHandlerForServices = exports.GetUserProfile = exports.GetDayIndex = exports.GetWeekDayInfoInMonth = exports.GetInterValFromOccurance = exports.GetWeekDayByDayAndOccurance = exports.CheckDateNotInPast = exports.NextServiceDateForDashboard = exports.SyncCompanyLicenceInMasterCompanyAfterAdd = exports.CheckDataPermission = exports.BroadCastEventToAllCompanyUsers = exports.SyncUserLicenceConsumedCount = exports.ReactivateFieldInOtherCollection = exports.SyncTagCountAfterUpdate = exports.UpdateTagCountAfterDelete = exports.SyncListSchemaFieldInOtherCollection = exports.isEmptyObj = exports.GetIPDetailsFromReq = exports.parseMSPCookie = exports.SendMailToCustomer = exports.MailTemplateStructure = exports.SendMailToSupport = exports.SendResetPasswordMail = exports.ConvertJsonToXLXS = exports.MakeUserPasswordInvalid = exports.GetUserProfilePermissions = exports.ExecuteDynamicDQLQuery = exports.ExecuteDynamicDMLQuery = exports.GetCompanyEncryptionKey = exports.GetEmailClientConfigs = exports.sendMailWithUserAccount = exports.UserLicenseConsumeCalculate = exports.SignoutMultipleUsersFromAllDevices = exports.SignoutUsersWithPromise = exports.SignoutUserFromAllDevices = exports.SyncUserDetailsWithMasterDB = exports.GenerateId = exports.VerifyAWSEmailConfig = exports.GetMaxKeyValueListSchema = exports.ExtractChildUsersTree = exports.GetMyTeamUsers = exports.VerifyEmailPassword = exports.CheckFilterFieldsProjection = exports.AddLog = exports.GirdHeaderFilters = exports.FilterConditions = exports.BuildLookupFieldProjection = exports.BuildFieldProjection = exports.BuildGridFieldProjection = exports.CheckDataBeforeUpdate = exports.CheckDataBeforeAdd = exports.BuildLookupDataField = exports.SyncUserInOtherCollection = exports.SyncFieldInOtherCollection = exports.SyncFieldInSameCollectionByObjectIDWithPromise = exports.SyncFieldInSameCollectionByObjectID = exports.SyncFieldInSameCollection = exports.DeleteFieldInOtherCollection = exports.SyncParentObjectData = exports.SyncChildObjectData = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
|
|
62
73
|
var moment_1 = __importDefault(require("moment"));
|
|
63
74
|
var nodemailer_1 = __importDefault(require("nodemailer"));
|
|
64
75
|
var mongodb_1 = require("mongodb");
|
|
@@ -70,6 +81,7 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
70
81
|
var crypto_1 = __importDefault(require("crypto"));
|
|
71
82
|
var constants_1 = __importDefault(require("../constants"));
|
|
72
83
|
var mail_1 = require("../utility/mail");
|
|
84
|
+
var errorHandlerForServices_1 = __importDefault(require("../utility/errorHandlerForServices"));
|
|
73
85
|
var cryptoService = __importStar(require("../utility/crypto"));
|
|
74
86
|
var https_1 = __importDefault(require("https"));
|
|
75
87
|
require("moment-timezone");
|
|
@@ -3515,3 +3527,45 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
3515
3527
|
});
|
|
3516
3528
|
}
|
|
3517
3529
|
exports.GetUserProfile = GetUserProfile;
|
|
3530
|
+
/**
|
|
3531
|
+
* @param Error Error object
|
|
3532
|
+
* @param ServiceOrigin - Error Occur in Service (Service Name)
|
|
3533
|
+
* @param EmailConfig Email configuration object
|
|
3534
|
+
* @param Module Module
|
|
3535
|
+
* @param db db connection
|
|
3536
|
+
* @description Error handler function: Send Error Email & Save Error in database
|
|
3537
|
+
*/
|
|
3538
|
+
function ErrorHandlerForServices(Error, ServiceOrigin, EmailConfig, Module, db) {
|
|
3539
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3540
|
+
var _a, mailObj, errorObj, sendMailResult, ErrorOrigin, ErrorData, error_3;
|
|
3541
|
+
return __generator(this, function (_b) {
|
|
3542
|
+
switch (_b.label) {
|
|
3543
|
+
case 0:
|
|
3544
|
+
_a = errorHandlerForServices_1.default(Error, EmailConfig, ServiceOrigin), mailObj = _a.mailObj, errorObj = _a.errorObj;
|
|
3545
|
+
_b.label = 1;
|
|
3546
|
+
case 1:
|
|
3547
|
+
_b.trys.push([1, 5, , 6]);
|
|
3548
|
+
return [4 /*yield*/, mail_1.SendMail(mailObj, {
|
|
3549
|
+
SES_ACCESS_ID: EmailConfig.SES_ACCESS_ID,
|
|
3550
|
+
SES_SECRET_KEY: EmailConfig.SES_SECRET_KEY,
|
|
3551
|
+
SES_REGION: EmailConfig.SES_REGION
|
|
3552
|
+
})];
|
|
3553
|
+
case 2:
|
|
3554
|
+
sendMailResult = _b.sent();
|
|
3555
|
+
if (!(sendMailResult && db)) return [3 /*break*/, 4];
|
|
3556
|
+
ErrorOrigin = errorObj.ErrorOrigin, ErrorData = __rest(errorObj, ["ErrorOrigin"]);
|
|
3557
|
+
return [4 /*yield*/, db.collection(Module + "Error").insertOne(ErrorData)];
|
|
3558
|
+
case 3:
|
|
3559
|
+
_b.sent();
|
|
3560
|
+
_b.label = 4;
|
|
3561
|
+
case 4: return [3 /*break*/, 6];
|
|
3562
|
+
case 5:
|
|
3563
|
+
error_3 = _b.sent();
|
|
3564
|
+
console.log("Error While connectin to Master DB", error_3);
|
|
3565
|
+
return [3 /*break*/, 6];
|
|
3566
|
+
case 6: return [2 /*return*/];
|
|
3567
|
+
}
|
|
3568
|
+
});
|
|
3569
|
+
});
|
|
3570
|
+
}
|
|
3571
|
+
exports.ErrorHandlerForServices = ErrorHandlerForServices;
|