@optimiser/common 1.0.243 → 1.0.247
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/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/lib/connection.d.ts +13 -1
- package/dist/lib/connection.js +96 -0
- package/dist/lib/helper.d.ts +3 -1
- package/dist/lib/helper.js +16 -6
- package/dist/lib/memoryserverclient.d.ts +39 -0
- package/dist/lib/memoryserverclient.js +203 -0
- package/dist/lib/operautilitycommon.d.ts +60 -1
- package/dist/lib/operautilitycommon.js +512 -1
- package/dist/lib/utility.d.ts +8 -1
- package/dist/lib/utility.js +89 -22
- package/package.json +1 -1
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.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.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;
|
|
83
|
+
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;
|
|
84
84
|
var moment_1 = __importDefault(require("moment"));
|
|
85
85
|
var nodemailer_1 = __importDefault(require("nodemailer"));
|
|
86
86
|
var mongodb_1 = require("mongodb");
|
|
@@ -206,7 +206,7 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
206
206
|
else {
|
|
207
207
|
db.collection("ObjectSchema").findOne({ 'Name': pageData.ObjectName }, function (err, objectData) {
|
|
208
208
|
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
-
var removeFieldsFromFilter, j, filterData, _loop_2, i, createdByObj,
|
|
209
|
+
var removeFieldsFromFilter, j, filterData, _loop_2, i, createdByObj, createdDateObj, modByObj, modDateObj, g, group, childObjectSchema, _loop_3, i, _loop_4, i, idObject, idObject_1;
|
|
210
210
|
return __generator(this, function (_a) {
|
|
211
211
|
switch (_a.label) {
|
|
212
212
|
case 0:
|
|
@@ -260,12 +260,26 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
260
260
|
]
|
|
261
261
|
}
|
|
262
262
|
};
|
|
263
|
+
createdDateObj = {
|
|
264
|
+
Name: "CreatedDate",
|
|
265
|
+
DisplayName: "Created Date",
|
|
266
|
+
UniqueID: "CreatedDate",
|
|
267
|
+
Sequence: 101,
|
|
268
|
+
HideON: "both",
|
|
269
|
+
Schema: {
|
|
270
|
+
Name: "CreatedDate",
|
|
271
|
+
HideON: "both",
|
|
272
|
+
DisplayName: "Created Date",
|
|
273
|
+
ApiName: "CreatedDate",
|
|
274
|
+
UIDataType: "datetime"
|
|
275
|
+
}
|
|
276
|
+
};
|
|
263
277
|
modByObj = {
|
|
264
278
|
Name: "ModifiedBy",
|
|
265
279
|
DisplayName: "Modified By",
|
|
266
280
|
ApiName: "ModifiedBy",
|
|
267
281
|
HideON: "both",
|
|
268
|
-
Sequence:
|
|
282
|
+
Sequence: 102,
|
|
269
283
|
UniqueID: "ModifiedBy",
|
|
270
284
|
Schema: {
|
|
271
285
|
Name: "ModifiedBy",
|
|
@@ -284,20 +298,6 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
284
298
|
]
|
|
285
299
|
}
|
|
286
300
|
};
|
|
287
|
-
createdDateObj = {
|
|
288
|
-
Name: "CreatedDate",
|
|
289
|
-
DisplayName: "Created Date",
|
|
290
|
-
UniqueID: "CreatedDate",
|
|
291
|
-
Sequence: 102,
|
|
292
|
-
HideON: "both",
|
|
293
|
-
Schema: {
|
|
294
|
-
Name: "CreatedDate",
|
|
295
|
-
HideON: "both",
|
|
296
|
-
DisplayName: "Created Date",
|
|
297
|
-
ApiName: "CreatedDate",
|
|
298
|
-
UIDataType: "datetime"
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
301
|
modDateObj = {
|
|
302
302
|
Name: "ModifiedDate",
|
|
303
303
|
DisplayName: "Modified Date",
|
|
@@ -486,6 +486,21 @@ function UpdateRecentViewObject(objectName, objectID, userID, db) {
|
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
exports.UpdateRecentViewObject = UpdateRecentViewObject;
|
|
489
|
+
function UpdateRecentViewFields(objectName, fieldID, userID, db) {
|
|
490
|
+
db.collection('RecentViewObject').findOne({ 'ObjectName': objectName, 'FieldID': fieldID, 'ViewedBy': userID }, { projection: { _id: 1 } }, function (err, viewedData) {
|
|
491
|
+
if (viewedData)
|
|
492
|
+
db.collection('RecentViewObject').updateOne({ '_id': viewedData._id }, { $set: { 'ViewedDate': new Date() } });
|
|
493
|
+
else
|
|
494
|
+
db.collection("RecentViewObject").insertOne({ 'ObjectName': objectName, 'FieldID': fieldID, 'ViewedBy': userID, 'ViewedDate': new Date() });
|
|
495
|
+
db.collection("RecentViewObject").find({ 'ObjectName': objectName, 'ViewedBy': userID }, { projection: { _id: 1 } }).sort({ 'ViewedDate': -1 }).skip(10).toArray(function (err, data) {
|
|
496
|
+
if (data && data.length > 0) {
|
|
497
|
+
var idsArry = data.map(function (i) { return i._id; });
|
|
498
|
+
db.collection("RecentViewObject").deleteMany({ _id: { $in: idsArry } });
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
exports.UpdateRecentViewFields = UpdateRecentViewFields;
|
|
489
504
|
//Sync child object
|
|
490
505
|
function SyncChildObjectData(pageData, objectID, db) {
|
|
491
506
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2173,6 +2188,58 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2173
2188
|
return { '$and': sets };
|
|
2174
2189
|
}
|
|
2175
2190
|
exports.GirdHeaderFilters = GirdHeaderFilters;
|
|
2191
|
+
function FieldsGridHeaderFilters(filters, fields) {
|
|
2192
|
+
var sets = [];
|
|
2193
|
+
var lookupFieldsSets = [];
|
|
2194
|
+
var _loop_15 = function (i) {
|
|
2195
|
+
var _a;
|
|
2196
|
+
var obj = filters[i];
|
|
2197
|
+
var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
|
|
2198
|
+
if (field) {
|
|
2199
|
+
var matchValue = null;
|
|
2200
|
+
var fldName = field.UniqueID;
|
|
2201
|
+
if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
|
|
2202
|
+
fldName += '_SearchValue';
|
|
2203
|
+
lookupFieldsSets.push((_a = {}, _a[fldName] = new RegExp(obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), 'i'), _a));
|
|
2204
|
+
return "continue";
|
|
2205
|
+
}
|
|
2206
|
+
if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
|
|
2207
|
+
if (field.Schema.LookupObject) {
|
|
2208
|
+
matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2209
|
+
}
|
|
2210
|
+
else {
|
|
2211
|
+
matchValue = { '$in': obj.Value };
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
else if (["date", "datetime"].includes(field.Schema.UIDataType))
|
|
2215
|
+
matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
|
|
2216
|
+
// else if (field.Schema.UIDataType == 'time')
|
|
2217
|
+
// matchValue = (obj.Value == 'true');
|
|
2218
|
+
else if (field.Schema.UIDataType == 'checkbox') {
|
|
2219
|
+
if (obj.Value == 'true')
|
|
2220
|
+
matchValue = true;
|
|
2221
|
+
else
|
|
2222
|
+
matchValue = { $ne: true };
|
|
2223
|
+
}
|
|
2224
|
+
else if (field.Schema.UIDataType == 'int')
|
|
2225
|
+
matchValue = { '$eq': parseInt(obj.Value) };
|
|
2226
|
+
else if (["decimal", "percent"].includes(field.Schema.UIDataType))
|
|
2227
|
+
matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
|
|
2228
|
+
else if (field.Schema.UIDataType == 'objectid')
|
|
2229
|
+
matchValue = { '$eq': obj.Value };
|
|
2230
|
+
else
|
|
2231
|
+
matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
|
|
2232
|
+
var fieldMatch = {};
|
|
2233
|
+
fieldMatch['Fields.' + fldName] = matchValue;
|
|
2234
|
+
sets.push(fieldMatch);
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
for (var i = 0; i < filters.length; i++) {
|
|
2238
|
+
_loop_15(i);
|
|
2239
|
+
}
|
|
2240
|
+
return { '$and': sets, 'lookupConditions': lookupFieldsSets };
|
|
2241
|
+
}
|
|
2242
|
+
exports.FieldsGridHeaderFilters = FieldsGridHeaderFilters;
|
|
2176
2243
|
/** @desc:{
|
|
2177
2244
|
objectName: It's a name of Collection.
|
|
2178
2245
|
logAction: Add | Modify | Delete
|
|
@@ -2206,7 +2273,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
|
|
|
2206
2273
|
exports.AddLog = AddLog;
|
|
2207
2274
|
function CheckFilterFieldsProjection(condition, fields, pageData, project) {
|
|
2208
2275
|
if (condition != undefined && condition.Filters.length > 0) {
|
|
2209
|
-
var
|
|
2276
|
+
var _loop_16 = function (i) {
|
|
2210
2277
|
var objFilter = condition.Filters[i];
|
|
2211
2278
|
if (objFilter.Type == "Child") {
|
|
2212
2279
|
CheckFilterFieldsProjection(objFilter, fields, pageData, project);
|
|
@@ -2224,7 +2291,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
|
|
|
2224
2291
|
}
|
|
2225
2292
|
};
|
|
2226
2293
|
for (var i = 0; i < condition.Filters.length; i++) {
|
|
2227
|
-
|
|
2294
|
+
_loop_16(i);
|
|
2228
2295
|
}
|
|
2229
2296
|
}
|
|
2230
2297
|
}
|
|
@@ -3813,7 +3880,7 @@ function GetDayIndex(day) {
|
|
|
3813
3880
|
exports.GetDayIndex = GetDayIndex;
|
|
3814
3881
|
function GetUserProfile(msp_d, db, mdb, next) {
|
|
3815
3882
|
return __awaiter(this, void 0, void 0, function () {
|
|
3816
|
-
var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, moduleList,
|
|
3883
|
+
var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, moduleList, _loop_17, i, error_4;
|
|
3817
3884
|
return __generator(this, function (_a) {
|
|
3818
3885
|
switch (_a.label) {
|
|
3819
3886
|
case 0:
|
|
@@ -3876,14 +3943,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
3876
3943
|
moduleList = userProfile_1[0].ModuleList;
|
|
3877
3944
|
userProfile_1[0].HasControlPanelAccess = [];
|
|
3878
3945
|
if (userProfile_1[0].Permissions) {
|
|
3879
|
-
|
|
3946
|
+
_loop_17 = function (i) {
|
|
3880
3947
|
userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
|
|
3881
3948
|
if (userProfile_1[0].Permissions[i].Operations.includes("Control Panel")) {
|
|
3882
3949
|
userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
|
|
3883
3950
|
}
|
|
3884
3951
|
};
|
|
3885
3952
|
for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
|
|
3886
|
-
|
|
3953
|
+
_loop_17(i);
|
|
3887
3954
|
}
|
|
3888
3955
|
}
|
|
3889
3956
|
if (moduleList.length == 0) {
|