@optimiser/common 1.0.287 → 1.0.288
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/utility.d.ts +2 -1
- package/dist/lib/utility.js +428 -64
- package/package.json +2 -1
package/dist/lib/utility.d.ts
CHANGED
|
@@ -198,6 +198,7 @@ declare function RemoveFieldsFromFilters(condition: AnyObjectInterface, fields:
|
|
|
198
198
|
declare function ErrorHandlerForServices(Error: OPT_ERROR, ServiceOrigin: string, EmailConfig: any, Module?: string, db?: Db): Promise<any>;
|
|
199
199
|
declare function CheckCaptcha(token: string, captcha: string, redisClient: Redis): Promise<unknown>;
|
|
200
200
|
declare function ValidateSanitizeUserInput(inputFields: AnyObjectInterface, pageData: AnyObjectInterface): Promise<AnyObjectInterface[] | undefined>;
|
|
201
|
+
declare function ValidateUserInput(options: AnyObjectInterface): Promise<string | undefined>;
|
|
201
202
|
/**
|
|
202
203
|
* TODO: Create lookup of fields of list schema for Vat Setting data
|
|
203
204
|
*
|
|
@@ -231,4 +232,4 @@ declare function GetMailFromString(fromUser: string): string;
|
|
|
231
232
|
* @returns string
|
|
232
233
|
*/
|
|
233
234
|
declare function InvitationMailReplyContent(fromUser: string, fromEmail: string): string;
|
|
234
|
-
export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, UpdateRecentViewFields, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, FieldsGridHeaderFilters, 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, RemoveFieldsFromFilters, GetUserProfile, CheckPageAuthentication, ErrorHandlerForServices, CheckCaptcha, ValidateSanitizeUserInput, CreateBanquetingVATSettingsData, CheckReportFolderAccess, GetMailFromString, InvitationMailReplyContent };
|
|
235
|
+
export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, UpdateRecentViewFields, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, FieldsGridHeaderFilters, 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, RemoveFieldsFromFilters, GetUserProfile, CheckPageAuthentication, ErrorHandlerForServices, CheckCaptcha, ValidateSanitizeUserInput, ValidateUserInput, CreateBanquetingVATSettingsData, CheckReportFolderAccess, GetMailFromString, InvitationMailReplyContent };
|
package/dist/lib/utility.js
CHANGED
|
@@ -80,7 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
80
80
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
81
81
|
};
|
|
82
82
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
|
-
exports.InvitationMailReplyContent = exports.GetMailFromString = exports.CheckReportFolderAccess = exports.CreateBanquetingVATSettingsData = exports.ValidateSanitizeUserInput = exports.CheckCaptcha = exports.ErrorHandlerForServices = exports.CheckPageAuthentication = exports.GetUserProfile = exports.RemoveFieldsFromFilters = 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.FieldsGridHeaderFilters = 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.UpdateRecentViewFields = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
|
|
83
|
+
exports.InvitationMailReplyContent = exports.GetMailFromString = exports.CheckReportFolderAccess = exports.CreateBanquetingVATSettingsData = exports.ValidateUserInput = exports.ValidateSanitizeUserInput = exports.CheckCaptcha = exports.ErrorHandlerForServices = exports.CheckPageAuthentication = exports.GetUserProfile = exports.RemoveFieldsFromFilters = 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.FieldsGridHeaderFilters = 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.UpdateRecentViewFields = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
|
|
84
84
|
var moment_1 = __importDefault(require("moment"));
|
|
85
85
|
var nodemailer_1 = __importDefault(require("nodemailer"));
|
|
86
86
|
var mongodb_1 = require("mongodb");
|
|
@@ -98,6 +98,7 @@ var countrycode_1 = require("./countrycode");
|
|
|
98
98
|
require("moment-timezone");
|
|
99
99
|
var helper_1 = require("./helper");
|
|
100
100
|
var sanitize = require('mongo-sanitize');
|
|
101
|
+
var phoneUtil = require("google-libphonenumber").PhoneNumberUtil.getInstance();
|
|
101
102
|
function GetObjectByKeyValueFromList(list, key, val) {
|
|
102
103
|
if (list && list.length > 0) {
|
|
103
104
|
for (var i = 0; i < list.length; i++) {
|
|
@@ -1020,7 +1021,7 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
|
|
|
1020
1021
|
}
|
|
1021
1022
|
db.collection(objectName).find(findObj).forEach(function (objectData) {
|
|
1022
1023
|
return __awaiter(this, void 0, void 0, function () {
|
|
1023
|
-
var updateObj, i, fieldSchema, lookupData,
|
|
1024
|
+
var updateObj, i, fieldSchema, lookupData, ex_1;
|
|
1024
1025
|
return __generator(this, function (_a) {
|
|
1025
1026
|
switch (_a.label) {
|
|
1026
1027
|
case 0:
|
|
@@ -1041,10 +1042,6 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
|
|
|
1041
1042
|
if (lookupData !== undefined) {
|
|
1042
1043
|
updateObj[fieldSchema.Name + constants_1.default.LookupAlias] = lookupData;
|
|
1043
1044
|
}
|
|
1044
|
-
searchValue = objectData[fieldSchema.Name + constants_1.default.SearchValueAlias];
|
|
1045
|
-
if (searchValue !== undefined) {
|
|
1046
|
-
updateObj[fieldSchema.Name + constants_1.default.SearchValueAlias] = searchValue;
|
|
1047
|
-
}
|
|
1048
1045
|
_a.label = 4;
|
|
1049
1046
|
case 4:
|
|
1050
1047
|
i++;
|
|
@@ -1100,7 +1097,7 @@ function SyncFieldInSameCollectionByObjectID(objectName, objectID, db) {
|
|
|
1100
1097
|
if (fieldArr_2) {
|
|
1101
1098
|
db.collection(objectName).findOne({ '_id': objectID }, function (err, objectData) {
|
|
1102
1099
|
return __awaiter(this, void 0, void 0, function () {
|
|
1103
|
-
var updateObj, i, fieldSchema, lookupData
|
|
1100
|
+
var updateObj, i, fieldSchema, lookupData;
|
|
1104
1101
|
return __generator(this, function (_a) {
|
|
1105
1102
|
switch (_a.label) {
|
|
1106
1103
|
case 0:
|
|
@@ -1118,10 +1115,6 @@ function SyncFieldInSameCollectionByObjectID(objectName, objectID, db) {
|
|
|
1118
1115
|
if (lookupData !== undefined) {
|
|
1119
1116
|
updateObj[fieldSchema.Name + constants_1.default.LookupAlias] = lookupData;
|
|
1120
1117
|
}
|
|
1121
|
-
searchValue = objectData[fieldSchema.Name + constants_1.default.SearchValueAlias];
|
|
1122
|
-
if (searchValue !== undefined) {
|
|
1123
|
-
updateObj[fieldSchema.Name + constants_1.default.SearchValueAlias] = searchValue;
|
|
1124
|
-
}
|
|
1125
1118
|
_a.label = 3;
|
|
1126
1119
|
case 3:
|
|
1127
1120
|
i++;
|
|
@@ -1150,7 +1143,7 @@ function SyncFieldInSameCollectionByObjectIDWithPromise(objectName, objectID, db
|
|
|
1150
1143
|
if (fieldArr_3) {
|
|
1151
1144
|
db.collection(objectName).findOne({ '_id': objectID }, function (err, objectData) {
|
|
1152
1145
|
return __awaiter(this, void 0, void 0, function () {
|
|
1153
|
-
var updateObj, i, fieldSchema, lookupData
|
|
1146
|
+
var updateObj, i, fieldSchema, lookupData;
|
|
1154
1147
|
return __generator(this, function (_a) {
|
|
1155
1148
|
switch (_a.label) {
|
|
1156
1149
|
case 0:
|
|
@@ -1168,10 +1161,6 @@ function SyncFieldInSameCollectionByObjectIDWithPromise(objectName, objectID, db
|
|
|
1168
1161
|
if (lookupData !== undefined) {
|
|
1169
1162
|
updateObj[fieldSchema.Name + constants_1.default.LookupAlias] = lookupData;
|
|
1170
1163
|
}
|
|
1171
|
-
searchValue = objectData[fieldSchema.Name + constants_1.default.SearchValueAlias];
|
|
1172
|
-
if (searchValue !== undefined) {
|
|
1173
|
-
updateObj[fieldSchema.Name + constants_1.default.SearchValueAlias] = searchValue;
|
|
1174
|
-
}
|
|
1175
1164
|
_a.label = 3;
|
|
1176
1165
|
case 3:
|
|
1177
1166
|
i++;
|
|
@@ -1473,7 +1462,7 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
|
|
|
1473
1462
|
var fldName = fieldSchema.Name;
|
|
1474
1463
|
var fldValue_1 = updateObj[fldName];
|
|
1475
1464
|
var alias_1 = fldName + constants_1.default.LookupAlias;
|
|
1476
|
-
var
|
|
1465
|
+
var searchAlias = fldName + constants_1.default.SearchValueAlias;
|
|
1477
1466
|
var fldLookupData_1 = null;
|
|
1478
1467
|
if (fldValue_1) {
|
|
1479
1468
|
var aggregateArry = [];
|
|
@@ -1516,20 +1505,17 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
|
|
|
1516
1505
|
fldLookupData_1 = data[0];
|
|
1517
1506
|
updateObj[alias_1] = fldLookupData_1;
|
|
1518
1507
|
//** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
|
|
1519
|
-
|
|
1520
|
-
if (fieldSchema.LookupFields != undefined) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
|
|
1508
|
+
// let result = '';
|
|
1509
|
+
// if (fieldSchema.LookupFields != undefined) {
|
|
1510
|
+
// for (let j = 0; j < fieldSchema.LookupFields.length; j++) {
|
|
1511
|
+
// if (fieldSchema.ExcludeLookupFieldsOnSearch && fieldSchema.ExcludeLookupFieldsOnSearch.filter((x: AnyObjectInterface) => x == fieldSchema.LookupFields[j]).length != 0) {
|
|
1512
|
+
// continue;
|
|
1513
|
+
// }
|
|
1514
|
+
// if (fldLookupData[fieldSchema.LookupFields[j]] != undefined)
|
|
1515
|
+
// result += fldLookupData[fieldSchema.LookupFields[j]].toString() + ' ';
|
|
1516
|
+
// }
|
|
1517
|
+
// }
|
|
1518
|
+
// updateObj[searchAlias] = result?.trim();
|
|
1533
1519
|
//** Ends here */
|
|
1534
1520
|
}
|
|
1535
1521
|
resolve();
|
|
@@ -1561,17 +1547,17 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
|
|
|
1561
1547
|
fldLookupData_1 = data;
|
|
1562
1548
|
updateObj[alias_1] = fldLookupData_1;
|
|
1563
1549
|
//** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
|
|
1564
|
-
|
|
1565
|
-
for (
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1574
|
-
updateObj[
|
|
1550
|
+
// let result = '';
|
|
1551
|
+
// for (let i = 0; i < data.length; i++) {
|
|
1552
|
+
// let lookupRecord = data[i];
|
|
1553
|
+
// if (fieldSchema.LookupFields != undefined) {
|
|
1554
|
+
// for (let j = 0; j < fieldSchema.LookupFields.length; j++) {
|
|
1555
|
+
// if (lookupRecord[fieldSchema.LookupFields[j]] != undefined)
|
|
1556
|
+
// result += lookupRecord[fieldSchema.LookupFields[j]].toString() + ' ';
|
|
1557
|
+
// }
|
|
1558
|
+
// }
|
|
1559
|
+
// }
|
|
1560
|
+
// updateObj[searchAlias] = result?.trim();
|
|
1575
1561
|
//** Ends here */
|
|
1576
1562
|
}
|
|
1577
1563
|
resolve();
|
|
@@ -1675,9 +1661,9 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
|
|
|
1675
1661
|
else {
|
|
1676
1662
|
updateObj[alias_1] = fldLookupData_1;
|
|
1677
1663
|
// Below if cond was added by Shahzaib on 05/09/2022
|
|
1678
|
-
if (fieldSchema.UIDataType == 'lookup' || fieldSchema.UIDataType == 'multilookup') {
|
|
1679
|
-
|
|
1680
|
-
}
|
|
1664
|
+
// if (fieldSchema.UIDataType == 'lookup' || fieldSchema.UIDataType == 'multilookup') {
|
|
1665
|
+
// updateObj[searchAlias] = fldLookupData;
|
|
1666
|
+
// }
|
|
1681
1667
|
resolve();
|
|
1682
1668
|
}
|
|
1683
1669
|
}
|
|
@@ -1690,11 +1676,11 @@ exports.BuildLookupDataField = BuildLookupDataField;
|
|
|
1690
1676
|
//CheckDataBeforeAdd it sync object before add
|
|
1691
1677
|
function CheckDataBeforeAdd(updateObj, objectSchema, db) {
|
|
1692
1678
|
return __awaiter(this, void 0, void 0, function () {
|
|
1693
|
-
var
|
|
1679
|
+
var _loop_10, _i, _a, fldName;
|
|
1694
1680
|
return __generator(this, function (_b) {
|
|
1695
1681
|
switch (_b.label) {
|
|
1696
1682
|
case 0:
|
|
1697
|
-
|
|
1683
|
+
_loop_10 = function (fldName) {
|
|
1698
1684
|
var fieldSchema, sequenceDocument, val, j, item, num;
|
|
1699
1685
|
return __generator(this, function (_a) {
|
|
1700
1686
|
switch (_a.label) {
|
|
@@ -1740,7 +1726,7 @@ function CheckDataBeforeAdd(updateObj, objectSchema, db) {
|
|
|
1740
1726
|
case 1:
|
|
1741
1727
|
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
1742
1728
|
fldName = _a[_i];
|
|
1743
|
-
return [5 /*yield**/,
|
|
1729
|
+
return [5 /*yield**/, _loop_10(fldName)];
|
|
1744
1730
|
case 2:
|
|
1745
1731
|
_b.sent();
|
|
1746
1732
|
_b.label = 3;
|
|
@@ -1756,11 +1742,11 @@ exports.CheckDataBeforeAdd = CheckDataBeforeAdd;
|
|
|
1756
1742
|
//CheckDataBeforeAdd it sync object before update
|
|
1757
1743
|
function CheckDataBeforeUpdate(updateObj, objectData, objectSchema, db) {
|
|
1758
1744
|
return __awaiter(this, void 0, void 0, function () {
|
|
1759
|
-
var
|
|
1745
|
+
var _loop_11, _i, _a, fldName;
|
|
1760
1746
|
return __generator(this, function (_b) {
|
|
1761
1747
|
switch (_b.label) {
|
|
1762
1748
|
case 0:
|
|
1763
|
-
|
|
1749
|
+
_loop_11 = function (fldName) {
|
|
1764
1750
|
var fieldSchema, oldValue, newValue, isSame;
|
|
1765
1751
|
return __generator(this, function (_a) {
|
|
1766
1752
|
switch (_a.label) {
|
|
@@ -1803,7 +1789,7 @@ function CheckDataBeforeUpdate(updateObj, objectData, objectSchema, db) {
|
|
|
1803
1789
|
case 1:
|
|
1804
1790
|
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
1805
1791
|
fldName = _a[_i];
|
|
1806
|
-
return [5 /*yield**/,
|
|
1792
|
+
return [5 /*yield**/, _loop_11(fldName)];
|
|
1807
1793
|
case 2:
|
|
1808
1794
|
_b.sent();
|
|
1809
1795
|
_b.label = 3;
|
|
@@ -1838,7 +1824,7 @@ function BuildGridFieldProjection(project, field, group) {
|
|
|
1838
1824
|
alias = fldName + constants_1.default.LookupAlias;
|
|
1839
1825
|
project[fldName] = 1;
|
|
1840
1826
|
project[alias] = 1;
|
|
1841
|
-
var
|
|
1827
|
+
var _loop_12 = function (i) {
|
|
1842
1828
|
if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == field.Schema.LookupFields[i]; }).length != 0) {
|
|
1843
1829
|
return "continue";
|
|
1844
1830
|
}
|
|
@@ -1850,7 +1836,7 @@ function BuildGridFieldProjection(project, field, group) {
|
|
|
1850
1836
|
}
|
|
1851
1837
|
};
|
|
1852
1838
|
for (var i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1853
|
-
|
|
1839
|
+
_loop_12(i);
|
|
1854
1840
|
}
|
|
1855
1841
|
;
|
|
1856
1842
|
project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
|
|
@@ -2099,7 +2085,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2099
2085
|
match.$or = new Array();
|
|
2100
2086
|
sets = match.$or;
|
|
2101
2087
|
}
|
|
2102
|
-
var
|
|
2088
|
+
var _loop_13 = function (i) {
|
|
2103
2089
|
var obj = condition.Filters[i];
|
|
2104
2090
|
if (obj.Type == "Child") {
|
|
2105
2091
|
var childMatch = {};
|
|
@@ -2268,7 +2254,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2268
2254
|
}
|
|
2269
2255
|
};
|
|
2270
2256
|
for (var i = 0; i < condition.Filters.length; i++) {
|
|
2271
|
-
|
|
2257
|
+
_loop_13(i);
|
|
2272
2258
|
}
|
|
2273
2259
|
}
|
|
2274
2260
|
}
|
|
@@ -2276,7 +2262,7 @@ exports.FilterConditions = FilterConditions;
|
|
|
2276
2262
|
function GirdHeaderFilters(filters, fields) {
|
|
2277
2263
|
try {
|
|
2278
2264
|
var sets = [];
|
|
2279
|
-
var
|
|
2265
|
+
var _loop_14 = function (i) {
|
|
2280
2266
|
var obj = filters[i];
|
|
2281
2267
|
var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
|
|
2282
2268
|
if (field) {
|
|
@@ -2329,7 +2315,7 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2329
2315
|
}
|
|
2330
2316
|
};
|
|
2331
2317
|
for (var i = 0; i < filters.length; i++) {
|
|
2332
|
-
|
|
2318
|
+
_loop_14(i);
|
|
2333
2319
|
}
|
|
2334
2320
|
return { '$and': sets };
|
|
2335
2321
|
}
|
|
@@ -2341,7 +2327,7 @@ exports.GirdHeaderFilters = GirdHeaderFilters;
|
|
|
2341
2327
|
function FieldsGridHeaderFilters(filters, fields) {
|
|
2342
2328
|
var sets = [];
|
|
2343
2329
|
var lookupFieldsSets = [];
|
|
2344
|
-
var
|
|
2330
|
+
var _loop_15 = function (i) {
|
|
2345
2331
|
var _a;
|
|
2346
2332
|
var obj = filters[i];
|
|
2347
2333
|
var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
|
|
@@ -2385,7 +2371,7 @@ function FieldsGridHeaderFilters(filters, fields) {
|
|
|
2385
2371
|
}
|
|
2386
2372
|
};
|
|
2387
2373
|
for (var i = 0; i < filters.length; i++) {
|
|
2388
|
-
|
|
2374
|
+
_loop_15(i);
|
|
2389
2375
|
}
|
|
2390
2376
|
return { '$and': sets, 'lookupConditions': lookupFieldsSets };
|
|
2391
2377
|
}
|
|
@@ -2423,7 +2409,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
|
|
|
2423
2409
|
exports.AddLog = AddLog;
|
|
2424
2410
|
function CheckFilterFieldsProjection(condition, fields, pageData, project) {
|
|
2425
2411
|
if (condition != undefined && condition.Filters.length > 0) {
|
|
2426
|
-
var
|
|
2412
|
+
var _loop_16 = function (i) {
|
|
2427
2413
|
var objFilter = condition.Filters[i];
|
|
2428
2414
|
if (objFilter.Type == "Child") {
|
|
2429
2415
|
CheckFilterFieldsProjection(objFilter, fields, pageData, project);
|
|
@@ -2441,7 +2427,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
|
|
|
2441
2427
|
}
|
|
2442
2428
|
};
|
|
2443
2429
|
for (var i = 0; i < condition.Filters.length; i++) {
|
|
2444
|
-
|
|
2430
|
+
_loop_16(i);
|
|
2445
2431
|
}
|
|
2446
2432
|
}
|
|
2447
2433
|
}
|
|
@@ -4054,7 +4040,7 @@ exports.GetDayIndex = GetDayIndex;
|
|
|
4054
4040
|
function GetUserProfile(msp_d, db, mdb, next) {
|
|
4055
4041
|
var _a;
|
|
4056
4042
|
return __awaiter(this, void 0, void 0, function () {
|
|
4057
|
-
var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList,
|
|
4043
|
+
var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
|
|
4058
4044
|
return __generator(this, function (_b) {
|
|
4059
4045
|
switch (_b.label) {
|
|
4060
4046
|
case 0:
|
|
@@ -4133,14 +4119,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
4133
4119
|
moduleList = userProfile_1[0].ModuleList;
|
|
4134
4120
|
userProfile_1[0].HasControlPanelAccess = [];
|
|
4135
4121
|
if (userProfile_1[0].Permissions) {
|
|
4136
|
-
|
|
4122
|
+
_loop_17 = function (i) {
|
|
4137
4123
|
userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
|
|
4138
4124
|
if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
|
|
4139
4125
|
userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
|
|
4140
4126
|
}
|
|
4141
4127
|
};
|
|
4142
4128
|
for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
|
|
4143
|
-
|
|
4129
|
+
_loop_17(i);
|
|
4144
4130
|
}
|
|
4145
4131
|
}
|
|
4146
4132
|
if (moduleList.length == 0) {
|
|
@@ -4317,6 +4303,12 @@ function EmailValidation(elmValue) {
|
|
|
4317
4303
|
}
|
|
4318
4304
|
return false;
|
|
4319
4305
|
}
|
|
4306
|
+
function IsStringValue(val) {
|
|
4307
|
+
if (typeof val === 'string' || val instanceof String) {
|
|
4308
|
+
return true;
|
|
4309
|
+
}
|
|
4310
|
+
return false;
|
|
4311
|
+
}
|
|
4320
4312
|
/*
|
|
4321
4313
|
* Created by: Mohan as on 09-11-21
|
|
4322
4314
|
* This is a common function and used to validate and sanitise user input.
|
|
@@ -4390,6 +4382,378 @@ function ValidateSanitizeUserInput(inputFields, pageData) {
|
|
|
4390
4382
|
});
|
|
4391
4383
|
}
|
|
4392
4384
|
exports.ValidateSanitizeUserInput = ValidateSanitizeUserInput;
|
|
4385
|
+
var SystemFields = ["CreatedBy", "CreatedDate", "ModifiedBy", "ModifiedDate", "_id", "IsActive", "CompanyID", "OwnerID", "SyncStatus"];
|
|
4386
|
+
var ObjectSystemFields = [
|
|
4387
|
+
{ 'Name': 'Activity', 'Fields': ["Contacts", "Accounts", "Users", "AttendeesData", "CustomRecurrence"] },
|
|
4388
|
+
{ 'Name': 'Events', 'Fields': ["RecurrenceData", "CustomRecurrence"] },
|
|
4389
|
+
{ 'Name': 'ImplantOutplant', 'Fields': ["AllAccountIDs"] },
|
|
4390
|
+
{ 'Name': 'ShopAppointment', 'Fields': ["StartDateTime", "EndDateTime", "AppointmentHistory"] }
|
|
4391
|
+
];
|
|
4392
|
+
function IsSystemField(objectName, fieldName) {
|
|
4393
|
+
if (SystemFields.includes(fieldName)) {
|
|
4394
|
+
return true;
|
|
4395
|
+
}
|
|
4396
|
+
var objectField = ObjectSystemFields.find(function (x) { return x.Name == objectName && x.Fields.includes(fieldName); });
|
|
4397
|
+
if (objectField) {
|
|
4398
|
+
return true;
|
|
4399
|
+
}
|
|
4400
|
+
return false;
|
|
4401
|
+
}
|
|
4402
|
+
function IsAnotherObjectField(pageData, fieldName) {
|
|
4403
|
+
if (pageData.Groups && pageData.Groups.length) {
|
|
4404
|
+
var groups = pageData.Groups.filter(function (x) { return x.ChildObject != undefined; });
|
|
4405
|
+
if (groups && groups.length) {
|
|
4406
|
+
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
|
4407
|
+
var group = groups_1[_i];
|
|
4408
|
+
if (group.Fields && group.Fields.find(function (x) { return x.Name == fieldName; })) {
|
|
4409
|
+
return true;
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
return false;
|
|
4415
|
+
}
|
|
4416
|
+
/*
|
|
4417
|
+
* Created by: Nirbhay as on 01-09-22
|
|
4418
|
+
* This is a common function and used to validate user input format.
|
|
4419
|
+
* Desc: This fuinction maps all fields from user form with objectdata from ObjectSchema collection.
|
|
4420
|
+
* return value: string.
|
|
4421
|
+
* example: if there is no issue found it return "" else return error message - "FirstName is required!"
|
|
4422
|
+
*/
|
|
4423
|
+
function ValidateUserInput(options) {
|
|
4424
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4425
|
+
var inputFields, pageData, documentID, db, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_18, _i, inputField_1, name_1, state_1, _loop_19, isValid, _a, pageFields_1, pageField, state_2, err_3;
|
|
4426
|
+
return __generator(this, function (_b) {
|
|
4427
|
+
switch (_b.label) {
|
|
4428
|
+
case 0:
|
|
4429
|
+
_b.trys.push([0, 5, , 6]);
|
|
4430
|
+
inputFields = options.userInput;
|
|
4431
|
+
pageData = options.pageData;
|
|
4432
|
+
documentID = options.objectID;
|
|
4433
|
+
db = options.db;
|
|
4434
|
+
action = (documentID) ? "update" : "add";
|
|
4435
|
+
objectSchema = pageData.ObjectSchema;
|
|
4436
|
+
objectName = objectSchema.Name;
|
|
4437
|
+
pageFields = pageData.AllFields;
|
|
4438
|
+
schemaFields = objectSchema.Fields;
|
|
4439
|
+
if (options.collectionField) {
|
|
4440
|
+
pageFields = objectSchema.Fields.find(function (x) { return x.Name == options.collectionField; }).Fields;
|
|
4441
|
+
schemaFields = objectSchema.Fields.find(function (x) { return x.Name == options.collectionField; }).Fields;
|
|
4442
|
+
}
|
|
4443
|
+
inputField = Object.keys(inputFields);
|
|
4444
|
+
msg = '';
|
|
4445
|
+
if (inputField && inputField.length) {
|
|
4446
|
+
_loop_18 = function (name_1) {
|
|
4447
|
+
var field = pageFields.find(function (x) { return x.Name == name_1; });
|
|
4448
|
+
if (field == undefined && !IsSystemField(objectName, name_1)) {
|
|
4449
|
+
msg = name_1 + " is not valid field!";
|
|
4450
|
+
return "break";
|
|
4451
|
+
}
|
|
4452
|
+
};
|
|
4453
|
+
for (_i = 0, inputField_1 = inputField; _i < inputField_1.length; _i++) {
|
|
4454
|
+
name_1 = inputField_1[_i];
|
|
4455
|
+
state_1 = _loop_18(name_1);
|
|
4456
|
+
if (state_1 === "break")
|
|
4457
|
+
break;
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4460
|
+
_loop_19 = function (pageField) {
|
|
4461
|
+
var fieldName, fieldData, field, searchQuery, result, _a, filter, searchObj, result, searchObj, totalRecord, _b, schemaData, result, searchObj, result, schemaData, result, searchObj, totalRecord, regexpression, phone;
|
|
4462
|
+
return __generator(this, function (_c) {
|
|
4463
|
+
switch (_c.label) {
|
|
4464
|
+
case 0:
|
|
4465
|
+
if (msg != "") {
|
|
4466
|
+
return [2 /*return*/, "break"];
|
|
4467
|
+
}
|
|
4468
|
+
fieldName = pageField.Name;
|
|
4469
|
+
fieldData = inputFields[fieldName];
|
|
4470
|
+
field = schemaFields.find(function (x) { return x.Name == fieldName; });
|
|
4471
|
+
if (!field) return [3 /*break*/, 38];
|
|
4472
|
+
if (fieldData && IsStringValue(fieldData) && field.UIDataType != 'dropdown') {
|
|
4473
|
+
fieldData = fieldData.trim();
|
|
4474
|
+
if (["text", "email", "phone"].includes(field.UIDataType)) {
|
|
4475
|
+
inputFields[fieldName] = fieldData;
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4478
|
+
if (field.IsRequired == true) {
|
|
4479
|
+
if (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add")) {
|
|
4480
|
+
msg = field.DisplayName + ' is required!';
|
|
4481
|
+
return [2 /*return*/, "break"];
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
if (!(field.IsUnique == true)) return [3 /*break*/, 2];
|
|
4485
|
+
if (!(field.UIDataType == "email" && fieldData)) return [3 /*break*/, 2];
|
|
4486
|
+
searchQuery = { IsActive: true };
|
|
4487
|
+
searchQuery[field.Name] = fieldData;
|
|
4488
|
+
if (action == "update") {
|
|
4489
|
+
searchQuery["_id"] = { $ne: documentID };
|
|
4490
|
+
}
|
|
4491
|
+
return [4 /*yield*/, db.collection(objectSchema.Name).findOne(searchQuery)];
|
|
4492
|
+
case 1:
|
|
4493
|
+
result = _c.sent();
|
|
4494
|
+
if (result != null) {
|
|
4495
|
+
msg = 'Email already exists for ' + field.DisplayName + '!';
|
|
4496
|
+
return [2 /*return*/, "break"];
|
|
4497
|
+
}
|
|
4498
|
+
_c.label = 2;
|
|
4499
|
+
case 2:
|
|
4500
|
+
if (!inputField.includes(fieldName)) return [3 /*break*/, 37];
|
|
4501
|
+
if (!fieldData) return [3 /*break*/, 37];
|
|
4502
|
+
_a = field.UIDataType;
|
|
4503
|
+
switch (_a) {
|
|
4504
|
+
case 'int': return [3 /*break*/, 3];
|
|
4505
|
+
case 'decimal': return [3 /*break*/, 3];
|
|
4506
|
+
case 'date': return [3 /*break*/, 4];
|
|
4507
|
+
case 'datetime': return [3 /*break*/, 4];
|
|
4508
|
+
case 'time': return [3 /*break*/, 5];
|
|
4509
|
+
case 'email': return [3 /*break*/, 6];
|
|
4510
|
+
case 'checkbox': return [3 /*break*/, 7];
|
|
4511
|
+
case 'lookup': return [3 /*break*/, 8];
|
|
4512
|
+
case 'multilookup': return [3 /*break*/, 10];
|
|
4513
|
+
case 'dropdown': return [3 /*break*/, 18];
|
|
4514
|
+
case 'multiselect': return [3 /*break*/, 24];
|
|
4515
|
+
case 'url': return [3 /*break*/, 34];
|
|
4516
|
+
case 'phone': return [3 /*break*/, 35];
|
|
4517
|
+
case 'textarea': return [3 /*break*/, 36];
|
|
4518
|
+
case 'text': return [3 /*break*/, 36];
|
|
4519
|
+
case 'texteditor': return [3 /*break*/, 36];
|
|
4520
|
+
}
|
|
4521
|
+
return [3 /*break*/, 37];
|
|
4522
|
+
case 3:
|
|
4523
|
+
{
|
|
4524
|
+
if (IsStringValue(fieldData)) {
|
|
4525
|
+
msg = 'Invalid value for ' + field.DisplayName + '!';
|
|
4526
|
+
}
|
|
4527
|
+
else if (field.UIDataType == 'int' && Number.isInteger(fieldData) == false) {
|
|
4528
|
+
msg = 'Invalid value for ' + field.DisplayName + '!';
|
|
4529
|
+
}
|
|
4530
|
+
else if (field.UIDataType == 'decimal' && isNaN(fieldData)) {
|
|
4531
|
+
msg = 'Invalid value for ' + field.DisplayName + '!';
|
|
4532
|
+
}
|
|
4533
|
+
else if (field.MinValue !== undefined && fieldData < field.MinValue) {
|
|
4534
|
+
msg = field.DisplayName + ' value must be greater then or equal to ' + field.MinValue;
|
|
4535
|
+
}
|
|
4536
|
+
else if (field.MinValue !== undefined && field.MaxValue < fieldData) {
|
|
4537
|
+
msg = field.DisplayName + ' value must be smaller then or equal to ' + field.MaxValue;
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
return [3 /*break*/, 37];
|
|
4541
|
+
case 4:
|
|
4542
|
+
{
|
|
4543
|
+
if ((fieldData instanceof Date && !isNaN(inputFields[fieldName])) == false) {
|
|
4544
|
+
msg = 'Invalid date for ' + field.DisplayName + '!';
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
return [3 /*break*/, 37];
|
|
4548
|
+
case 5:
|
|
4549
|
+
{
|
|
4550
|
+
isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(fieldData);
|
|
4551
|
+
if (!isValid) {
|
|
4552
|
+
msg = 'Invalid time for ' + field.DisplayName + '!';
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
return [3 /*break*/, 37];
|
|
4556
|
+
case 6:
|
|
4557
|
+
{
|
|
4558
|
+
filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
|
4559
|
+
if (!filter.test(fieldData)) {
|
|
4560
|
+
msg = 'Invalid email for ' + field.DisplayName + '!';
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
return [3 /*break*/, 37];
|
|
4564
|
+
case 7:
|
|
4565
|
+
{
|
|
4566
|
+
if (fieldData !== true && fieldData !== false) {
|
|
4567
|
+
msg = 'Invalid user input for ' + field.DisplayName + '!';
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4570
|
+
return [3 /*break*/, 37];
|
|
4571
|
+
case 8:
|
|
4572
|
+
searchObj = { _id: fieldData };
|
|
4573
|
+
if (action == 'add') {
|
|
4574
|
+
searchObj.IsActive = true;
|
|
4575
|
+
}
|
|
4576
|
+
;
|
|
4577
|
+
return [4 /*yield*/, db.collection(field.LookupObject).findOne(searchObj)];
|
|
4578
|
+
case 9:
|
|
4579
|
+
result = _c.sent();
|
|
4580
|
+
if (result == null) {
|
|
4581
|
+
msg = field.DisplayName + ' does not exist!';
|
|
4582
|
+
}
|
|
4583
|
+
return [3 /*break*/, 37];
|
|
4584
|
+
case 10:
|
|
4585
|
+
if (!Array.isArray(fieldData)) return [3 /*break*/, 16];
|
|
4586
|
+
if (!fieldData.length) return [3 /*break*/, 14];
|
|
4587
|
+
searchObj = { _id: { $in: fieldData } };
|
|
4588
|
+
if (action == 'add') {
|
|
4589
|
+
searchObj.IsActive = true;
|
|
4590
|
+
}
|
|
4591
|
+
;
|
|
4592
|
+
return [4 /*yield*/, db.collection(field.LookupObject).find(searchObj).count()];
|
|
4593
|
+
case 11:
|
|
4594
|
+
totalRecord = _c.sent();
|
|
4595
|
+
if (!(objectName == "Activity" && field.Name == 'Attendees')) return [3 /*break*/, 13];
|
|
4596
|
+
_b = totalRecord;
|
|
4597
|
+
return [4 /*yield*/, db.collection('Contact').find(searchObj).count()];
|
|
4598
|
+
case 12:
|
|
4599
|
+
totalRecord = _b + _c.sent();
|
|
4600
|
+
_c.label = 13;
|
|
4601
|
+
case 13:
|
|
4602
|
+
if (totalRecord !== fieldData.length) {
|
|
4603
|
+
msg = field.DisplayName + ' does not exist!';
|
|
4604
|
+
}
|
|
4605
|
+
return [3 /*break*/, 15];
|
|
4606
|
+
case 14:
|
|
4607
|
+
if (field.IsRequired) {
|
|
4608
|
+
msg = field.DisplayName + ' is required!';
|
|
4609
|
+
}
|
|
4610
|
+
_c.label = 15;
|
|
4611
|
+
case 15: return [3 /*break*/, 17];
|
|
4612
|
+
case 16:
|
|
4613
|
+
msg = 'Invalid value for ' + field.DisplayName;
|
|
4614
|
+
_c.label = 17;
|
|
4615
|
+
case 17: return [3 /*break*/, 37];
|
|
4616
|
+
case 18:
|
|
4617
|
+
if (!(field.ListSchemaName !== undefined)) return [3 /*break*/, 21];
|
|
4618
|
+
if (!!field.IsMultipleListSchemaName) return [3 /*break*/, 20];
|
|
4619
|
+
schemaData = null;
|
|
4620
|
+
return [4 /*yield*/, db.collection('ListSchema').findOne({ Name: field.ListSchemaName })];
|
|
4621
|
+
case 19:
|
|
4622
|
+
result = _c.sent();
|
|
4623
|
+
if (result && result.Data)
|
|
4624
|
+
schemaData = result.Data.find(function (x) { return x.Key == fieldData; });
|
|
4625
|
+
if (schemaData == null) {
|
|
4626
|
+
msg = field.DisplayName + ' does not exist!';
|
|
4627
|
+
}
|
|
4628
|
+
_c.label = 20;
|
|
4629
|
+
case 20: return [3 /*break*/, 23];
|
|
4630
|
+
case 21:
|
|
4631
|
+
if (!(field.LookupObject !== undefined)) return [3 /*break*/, 23];
|
|
4632
|
+
searchObj = { _id: fieldData };
|
|
4633
|
+
if (action == 'add') {
|
|
4634
|
+
searchObj.IsActive = true;
|
|
4635
|
+
}
|
|
4636
|
+
;
|
|
4637
|
+
return [4 /*yield*/, db.collection(field.LookupObject).findOne(searchObj)];
|
|
4638
|
+
case 22:
|
|
4639
|
+
result = _c.sent();
|
|
4640
|
+
if (result == null) {
|
|
4641
|
+
msg = field.DisplayName + ' does not exist!';
|
|
4642
|
+
}
|
|
4643
|
+
_c.label = 23;
|
|
4644
|
+
case 23: return [3 /*break*/, 37];
|
|
4645
|
+
case 24:
|
|
4646
|
+
if (!Array.isArray(fieldData)) return [3 /*break*/, 32];
|
|
4647
|
+
if (!fieldData.length) return [3 /*break*/, 30];
|
|
4648
|
+
if (!(field.ListSchemaName !== undefined)) return [3 /*break*/, 27];
|
|
4649
|
+
if (!!field.IsMultipleListSchemaName) return [3 /*break*/, 26];
|
|
4650
|
+
schemaData = [];
|
|
4651
|
+
return [4 /*yield*/, db.collection('ListSchema').findOne({ Name: field.ListSchemaName })];
|
|
4652
|
+
case 25:
|
|
4653
|
+
result = _c.sent();
|
|
4654
|
+
if (result && result.Data)
|
|
4655
|
+
schemaData = result.Data.filter(function (x) { return fieldData.includes(x.Key.toString()); });
|
|
4656
|
+
if (schemaData.length != fieldData.length) {
|
|
4657
|
+
msg = field.DisplayName + ' does not exist!';
|
|
4658
|
+
}
|
|
4659
|
+
_c.label = 26;
|
|
4660
|
+
case 26: return [3 /*break*/, 29];
|
|
4661
|
+
case 27:
|
|
4662
|
+
if (!(field.LookupObject !== undefined)) return [3 /*break*/, 29];
|
|
4663
|
+
searchObj = { _id: { $in: fieldData } };
|
|
4664
|
+
if (action == 'add') {
|
|
4665
|
+
searchObj.IsActive = true;
|
|
4666
|
+
}
|
|
4667
|
+
;
|
|
4668
|
+
return [4 /*yield*/, db.collection(field.LookupObject).find(searchObj).count()];
|
|
4669
|
+
case 28:
|
|
4670
|
+
totalRecord = _c.sent();
|
|
4671
|
+
if (totalRecord !== fieldData.length) {
|
|
4672
|
+
msg = field.DisplayName + ' does not exist!';
|
|
4673
|
+
}
|
|
4674
|
+
_c.label = 29;
|
|
4675
|
+
case 29: return [3 /*break*/, 31];
|
|
4676
|
+
case 30:
|
|
4677
|
+
if (field.IsRequired) {
|
|
4678
|
+
msg = field.DisplayName + ' is required!';
|
|
4679
|
+
}
|
|
4680
|
+
_c.label = 31;
|
|
4681
|
+
case 31: return [3 /*break*/, 33];
|
|
4682
|
+
case 32:
|
|
4683
|
+
msg = 'Invalid value for ' + field.DisplayName;
|
|
4684
|
+
_c.label = 33;
|
|
4685
|
+
case 33: return [3 /*break*/, 37];
|
|
4686
|
+
case 34:
|
|
4687
|
+
{
|
|
4688
|
+
regexpression = new RegExp('^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+@,:=#()]*)*(\\?[;&a-z\\d%_@,.:()~+=-]*)?(\\#[-a-z\\d_]*)?$', 'i');
|
|
4689
|
+
if (!regexpression.test(fieldData)) {
|
|
4690
|
+
msg = 'Invalid URL for ' + field.DisplayName + '!';
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
return [3 /*break*/, 37];
|
|
4694
|
+
case 35:
|
|
4695
|
+
{
|
|
4696
|
+
if (field.IncludeCountryCode) {
|
|
4697
|
+
// phone must begin with '+'
|
|
4698
|
+
if (!fieldData.indexOf("+")) {
|
|
4699
|
+
phone = phoneUtil.parse(fieldData, "");
|
|
4700
|
+
if (!phoneUtil.isValidNumber(phone)) {
|
|
4701
|
+
msg = fieldData + ' is a invalid phone number!';
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4704
|
+
else {
|
|
4705
|
+
msg = fieldData + ' is a invalid phone number!';
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
return [3 /*break*/, 37];
|
|
4710
|
+
case 36:
|
|
4711
|
+
{
|
|
4712
|
+
// Maxlength check;
|
|
4713
|
+
if (field.MaxLength !== undefined && fieldData.length > field.MaxLength) {
|
|
4714
|
+
msg = field.DisplayName + ' can not be greater then ' + field.MaxLength + ' characters!';
|
|
4715
|
+
}
|
|
4716
|
+
if (!IsStringValue(fieldData)) {
|
|
4717
|
+
msg = 'Invalid value for ' + field.DisplayName;
|
|
4718
|
+
}
|
|
4719
|
+
}
|
|
4720
|
+
return [3 /*break*/, 37];
|
|
4721
|
+
case 37: return [3 /*break*/, 39];
|
|
4722
|
+
case 38:
|
|
4723
|
+
if (!IsSystemField(objectName, fieldName) && !IsAnotherObjectField(pageData, fieldName)) {
|
|
4724
|
+
msg = fieldName + " is not valid schema!";
|
|
4725
|
+
return [2 /*return*/, "break"];
|
|
4726
|
+
}
|
|
4727
|
+
_c.label = 39;
|
|
4728
|
+
case 39: return [2 /*return*/];
|
|
4729
|
+
}
|
|
4730
|
+
});
|
|
4731
|
+
};
|
|
4732
|
+
_a = 0, pageFields_1 = pageFields;
|
|
4733
|
+
_b.label = 1;
|
|
4734
|
+
case 1:
|
|
4735
|
+
if (!(_a < pageFields_1.length)) return [3 /*break*/, 4];
|
|
4736
|
+
pageField = pageFields_1[_a];
|
|
4737
|
+
return [5 /*yield**/, _loop_19(pageField)];
|
|
4738
|
+
case 2:
|
|
4739
|
+
state_2 = _b.sent();
|
|
4740
|
+
if (state_2 === "break")
|
|
4741
|
+
return [3 /*break*/, 4];
|
|
4742
|
+
_b.label = 3;
|
|
4743
|
+
case 3:
|
|
4744
|
+
_a++;
|
|
4745
|
+
return [3 /*break*/, 1];
|
|
4746
|
+
case 4: return [2 /*return*/, msg];
|
|
4747
|
+
case 5:
|
|
4748
|
+
err_3 = _b.sent();
|
|
4749
|
+
console.log("Error in ValidateUserInput", err_3);
|
|
4750
|
+
return [3 /*break*/, 6];
|
|
4751
|
+
case 6: return [2 /*return*/];
|
|
4752
|
+
}
|
|
4753
|
+
});
|
|
4754
|
+
});
|
|
4755
|
+
}
|
|
4756
|
+
exports.ValidateUserInput = ValidateUserInput;
|
|
4393
4757
|
/**
|
|
4394
4758
|
* TODO: Create lookup of fields of list schema for Vat Setting data
|
|
4395
4759
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimiser/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.288",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"express": "^4.17.1",
|
|
27
27
|
"express-validator": "^6.9.2",
|
|
28
28
|
"geoip-lite": "^1.4.2",
|
|
29
|
+
"google-libphonenumber": "^3.2.30",
|
|
29
30
|
"ioredis": "^4.17.3",
|
|
30
31
|
"libphonenumber-js": "^1.9.51",
|
|
31
32
|
"moment": "^2.25.3",
|