@optimiser/common 1.0.434 → 1.0.435

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.
Files changed (2) hide show
  1. package/dist/lib/utility.js +68 -57
  2. package/package.json +60 -60
@@ -3973,35 +3973,51 @@ function UpdateTagCount(tagids, objectName, db, params) {
3973
3973
  }
3974
3974
  function SyncUserLicenceConsumedCount(msp_d, db, dbMaster) {
3975
3975
  return __awaiter(this, void 0, void 0, function () {
3976
- var companySetting, companyLicencesData, i, companyLicenceType, j, userLicenceData, u, licenceType, licenceName, licenceTotal, i, companyLicenceType, j, comLicenceInUserLicence, bulkLicenceOps, u, licenceID, licenceTotal, err_1;
3976
+ var companySetting, companyLicencesData, companyLevelLicences, _loop_17, i, userLicenceData, u, licenceType, licenceName, licenceTotal, i, companyLicenceType, j, comLicenceInUserLicence, bulkLicenceOps, u, licenceID, licenceTotal, err_1;
3977
3977
  return __generator(this, function (_a) {
3978
3978
  switch (_a.label) {
3979
3979
  case 0:
3980
- _a.trys.push([0, 8, , 9]);
3980
+ _a.trys.push([0, 9, , 10]);
3981
3981
  return [4 /*yield*/, dbMaster.collection("Company").findOne({ _id: new mongodb_1.ObjectId(msp_d.ci), 'IsActive': true }, { projection: { "Setting.Licences": 1 } })];
3982
3982
  case 1:
3983
3983
  companySetting = _a.sent();
3984
- if (!(companySetting && companySetting.Setting)) return [3 /*break*/, 6];
3984
+ if (!(companySetting && companySetting.Setting)) return [3 /*break*/, 7];
3985
3985
  companyLicencesData = (companySetting.Setting.Licences) ? companySetting.Setting.Licences : {};
3986
- if (!(isEmptyObj(companyLicencesData) == false)) return [3 /*break*/, 4];
3987
- for (i in companyLicencesData) {
3986
+ if (!(isEmptyObj(companyLicencesData) == false)) return [3 /*break*/, 5];
3987
+ return [4 /*yield*/, dbMaster.collection("Licences").find({ IsCompanyLevelLicence: true, "Status": "active", IsActive: true }).toArray()];
3988
+ case 2:
3989
+ companyLevelLicences = _a.sent();
3990
+ _loop_17 = function (i) {
3988
3991
  /*Added by Chetan on 07-Mar-2022, Not necessary for Domain Licence*/
3989
3992
  if (i != "Domain") {
3990
- companyLicenceType = companyLicencesData[i];
3991
- for (j in companyLicenceType) {
3992
- /*Added by Ashish to stop resetting App.Reception.NoOfLicenceConsumed to "0" QPC-7011 */
3993
- if (i == "App" && j == 'Reception') {
3994
- continue;
3993
+ var companyLicenceType = companyLicencesData[i];
3994
+ var _loop_18 = function (j) {
3995
+ //Commented by SurajWasan on 27-May-2025, for story QPC-10970, now this will handle by IsCompanyLevelLicence property, its consumed count will be handle by its own module.
3996
+ // /*Added by Ashish to stop resetting App.Reception.NoOfLicenceConsumed to "0" QPC-7011 */
3997
+ // if (i == "App" && j == 'Reception') {
3998
+ // continue;
3999
+ // }
4000
+ //End
4001
+ if (companyLevelLicences && companyLevelLicences.length) {
4002
+ if (companyLevelLicences.some(function (x) { x.LicenceType == i && x.LicenceName == j; })) {
4003
+ return "continue";
4004
+ }
3995
4005
  }
3996
4006
  companyLicenceType[j].NoOfLicenceConsumed = 0;
4007
+ };
4008
+ for (var j in companyLicenceType) {
4009
+ _loop_18(j);
3997
4010
  }
3998
4011
  }
4012
+ };
4013
+ for (i in companyLicencesData) {
4014
+ _loop_17(i);
3999
4015
  }
4000
4016
  return [4 /*yield*/, db.collection('UserLicence').aggregate([
4001
4017
  { $match: { Status: 'active', IsActive: true } },
4002
4018
  { $group: { _id: { "LicenceType": "$LicenceType", "LicenceName": "$LicenceName" }, Total: { $sum: 1 } } }
4003
4019
  ]).toArray()];
4004
- case 2:
4020
+ case 3:
4005
4021
  userLicenceData = _a.sent();
4006
4022
  if (userLicenceData) {
4007
4023
  for (u = 0; u < userLicenceData.length; u++) {
@@ -4032,7 +4048,7 @@ function SyncUserLicenceConsumedCount(msp_d, db, dbMaster) {
4032
4048
  { $match: { Status: 'active', IsActive: true } },
4033
4049
  { $group: { _id: { "CompanyLicenceID": "$CompanyLicenceID" }, Total: { $sum: 1 } } }
4034
4050
  ]).toArray()];
4035
- case 3:
4051
+ case 4:
4036
4052
  comLicenceInUserLicence = _a.sent();
4037
4053
  if (comLicenceInUserLicence && comLicenceInUserLicence.length) {
4038
4054
  bulkLicenceOps = [{
@@ -4064,20 +4080,20 @@ function SyncUserLicenceConsumedCount(msp_d, db, dbMaster) {
4064
4080
  else {
4065
4081
  console.log('In company (' + msp_d.ci + '), copmany licence data not found in user licence while syncing user licence consumed count.');
4066
4082
  }
4067
- return [3 /*break*/, 5];
4068
- case 4:
4083
+ return [3 /*break*/, 6];
4084
+ case 5:
4069
4085
  console.log('Licence data not found in company (' + msp_d.ci + ') setting while syncing user licence consumed count.');
4070
- _a.label = 5;
4071
- case 5: return [3 /*break*/, 7];
4072
- case 6:
4086
+ _a.label = 6;
4087
+ case 6: return [3 /*break*/, 8];
4088
+ case 7:
4073
4089
  console.log('Company (' + msp_d.ci + ') data not found while syncing user licence consumed count.');
4074
- _a.label = 7;
4075
- case 7: return [3 /*break*/, 9];
4076
- case 8:
4090
+ _a.label = 8;
4091
+ case 8: return [3 /*break*/, 10];
4092
+ case 9:
4077
4093
  err_1 = _a.sent();
4078
4094
  console.log('Error occurred while syncing user licence consumed count.', err_1);
4079
- return [3 /*break*/, 9];
4080
- case 9: return [2 /*return*/];
4095
+ return [3 /*break*/, 10];
4096
+ case 10: return [2 /*return*/];
4081
4097
  }
4082
4098
  });
4083
4099
  });
@@ -4439,11 +4455,11 @@ exports.GetDayIndex = GetDayIndex;
4439
4455
  function GetUserProfile(msp_d, db, mdb, next) {
4440
4456
  var _a;
4441
4457
  return __awaiter(this, void 0, void 0, function () {
4442
- var userData, userProfile_1, error_4, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_5;
4458
+ var userData, userProfile_1, error_4, objectIDs_1, modules_1, licenceDetail_1, companyLevelLicenceDetail, moduleList, _loop_19, i, error_5;
4443
4459
  return __generator(this, function (_b) {
4444
4460
  switch (_b.label) {
4445
4461
  case 0:
4446
- _b.trys.push([0, 12, , 13]);
4462
+ _b.trys.push([0, 11, , 12]);
4447
4463
  return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1, 'CompanyID': 1 } })];
4448
4464
  case 1:
4449
4465
  userData = _b.sent();
@@ -4483,7 +4499,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4483
4499
  if (!(!userProfile_1 || userProfile_1.length <= 0)) return [3 /*break*/, 6];
4484
4500
  return [2 /*return*/, { statusCode: 500, message: "User's profile data not found.", data: {} }];
4485
4501
  case 6:
4486
- if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 10];
4502
+ if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 9];
4487
4503
  objectIDs_1 = [];
4488
4504
  userData.LicenceDetail.forEach(function (licenceDetail) {
4489
4505
  if (licenceDetail.Status == "active")
@@ -4492,25 +4508,20 @@ function GetUserProfile(msp_d, db, mdb, next) {
4492
4508
  modules_1 = [];
4493
4509
  return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
4494
4510
  case 7:
4495
- licenceDetail = _b.sent();
4496
- if (!(userData && userData.CompanyID)) return [3 /*break*/, 9];
4497
- return [4 /*yield*/, mdb.collection("CompanyLicence").find({ 'CompanyID': userData.CompanyID, 'Status': 'active', 'IsActive': true }).toArray()];
4511
+ licenceDetail_1 = _b.sent();
4512
+ return [4 /*yield*/, mdb.collection("Licences").find({ "IsCompanyLevelLicence": true, "Status": "active", "IsActive": true }, { projection: { Modules: 1 } }).toArray()];
4498
4513
  case 8:
4499
- companylicenceDetail = _b.sent();
4500
- if (companylicenceDetail && companylicenceDetail.length > 0) {
4501
- receptionLicense = companylicenceDetail.find(function (licence) { return licence.LicenceName === "Reception" && licence.LicenceType === "App"; });
4502
- if (receptionLicense) {
4503
- licenceDetail.push({
4504
- "Modules": [
4505
- "reception"
4506
- ]
4507
- });
4508
- }
4514
+ companyLevelLicenceDetail = _b.sent();
4515
+ if (companyLevelLicenceDetail && companyLevelLicenceDetail.length > 0) {
4516
+ companyLevelLicenceDetail.map(function (x) {
4517
+ var _a;
4518
+ if (((_a = x.Modules) === null || _a === void 0 ? void 0 : _a.length) > 0) {
4519
+ licenceDetail_1.push({ "Modules": x.Modules });
4520
+ }
4521
+ });
4509
4522
  }
4510
- _b.label = 9;
4511
- case 9:
4512
- if (licenceDetail && licenceDetail.length > 0) {
4513
- licenceDetail.forEach(function (licence) {
4523
+ if (licenceDetail_1 && licenceDetail_1.length > 0) {
4524
+ licenceDetail_1.forEach(function (licence) {
4514
4525
  modules_1 = modules_1.concat(licence.Modules);
4515
4526
  });
4516
4527
  userProfile_1[0].UserMenu = userProfile_1[0].UserMenu.filter(function (m) { return modules_1.includes(m.ModuleID); });
@@ -4518,14 +4529,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
4518
4529
  moduleList = userProfile_1[0].ModuleList;
4519
4530
  userProfile_1[0].HasControlPanelAccess = [];
4520
4531
  if (userProfile_1[0].Permissions) {
4521
- _loop_17 = function (i) {
4532
+ _loop_19 = function (i) {
4522
4533
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
4523
4534
  if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
4524
4535
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
4525
4536
  }
4526
4537
  };
4527
4538
  for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
4528
- _loop_17(i);
4539
+ _loop_19(i);
4529
4540
  }
4530
4541
  }
4531
4542
  if (moduleList.length == 0) {
@@ -4537,15 +4548,15 @@ function GetUserProfile(msp_d, db, mdb, next) {
4537
4548
  else {
4538
4549
  return [2 /*return*/, { statusCode: 200, message: "Licence data is not found in Master database.", data: {} }];
4539
4550
  }
4540
- return [3 /*break*/, 11];
4541
- case 10: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4542
- case 11: return [3 /*break*/, 13];
4543
- case 12:
4551
+ return [3 /*break*/, 10];
4552
+ case 9: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4553
+ case 10: return [3 /*break*/, 12];
4554
+ case 11:
4544
4555
  error_5 = _b.sent();
4545
4556
  console.error("Internal Error in GetUserProfile Utility function : ".concat(error_5));
4546
4557
  next(error_5);
4547
- return [3 /*break*/, 13];
4548
- case 13: return [2 /*return*/];
4558
+ return [3 /*break*/, 12];
4559
+ case 12: return [2 /*return*/];
4549
4560
  }
4550
4561
  });
4551
4562
  });
@@ -4847,7 +4858,7 @@ var CustomSanitizeHtml = function (dirtyHtml, uiDataType) {
4847
4858
  function ValidateUserInput(options) {
4848
4859
  var _a, _b, _c;
4849
4860
  return __awaiter(this, void 0, void 0, function () {
4850
- var inputFields, fieldsJsonData, pageData, documentID, db, mdb, fiscalSettingData, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_18, _i, inputField_1, name_1, state_1, _d, _e, grp, _loop_19, _f, _g, fld, state_2, _loop_20, isValid, isValid, validateResp, _h, pageFields_1, pageField, state_3, countryData, err_3;
4861
+ var inputFields, fieldsJsonData, pageData, documentID, db, mdb, fiscalSettingData, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_20, _i, inputField_1, name_1, state_1, _d, _e, grp, _loop_21, _f, _g, fld, state_2, _loop_22, isValid, isValid, validateResp, _h, pageFields_1, pageField, state_3, countryData, err_3;
4851
4862
  return __generator(this, function (_j) {
4852
4863
  switch (_j.label) {
4853
4864
  case 0:
@@ -4876,7 +4887,7 @@ function ValidateUserInput(options) {
4876
4887
  inputField = Object.keys(inputFields);
4877
4888
  msg = '';
4878
4889
  if (inputField && inputField.length) {
4879
- _loop_18 = function (name_1) {
4890
+ _loop_20 = function (name_1) {
4880
4891
  var field = pageFields.find(function (x) { return x.Name == name_1; });
4881
4892
  if (field == undefined && !IsSystemField(objectName, name_1)) {
4882
4893
  msg = name_1 + " is not valid field!";
@@ -4885,7 +4896,7 @@ function ValidateUserInput(options) {
4885
4896
  };
4886
4897
  for (_i = 0, inputField_1 = inputField; _i < inputField_1.length; _i++) {
4887
4898
  name_1 = inputField_1[_i];
4888
- state_1 = _loop_18(name_1);
4899
+ state_1 = _loop_20(name_1);
4889
4900
  if (state_1 === "break")
4890
4901
  break;
4891
4902
  }
@@ -4894,7 +4905,7 @@ function ValidateUserInput(options) {
4894
4905
  for (_d = 0, _e = pageData.Groups; _d < _e.length; _d++) {
4895
4906
  grp = _e[_d];
4896
4907
  if (grp.IsConditionalGroup) {
4897
- _loop_19 = function (fld) {
4908
+ _loop_21 = function (fld) {
4898
4909
  fld = JSON.parse(JSON.stringify(fld));
4899
4910
  var schemafld = schemaFields.find(function (x) { return x.Name == fld.Name; });
4900
4911
  fld.Schema = schemafld;
@@ -4904,14 +4915,14 @@ function ValidateUserInput(options) {
4904
4915
  };
4905
4916
  for (_f = 0, _g = grp.Fields; _f < _g.length; _f++) {
4906
4917
  fld = _g[_f];
4907
- state_2 = _loop_19(fld);
4918
+ state_2 = _loop_21(fld);
4908
4919
  if (state_2 === "break")
4909
4920
  break;
4910
4921
  }
4911
4922
  }
4912
4923
  }
4913
4924
  }
4914
- _loop_20 = function (pageField) {
4925
+ _loop_22 = function (pageField) {
4915
4926
  var fieldName, fieldData, field, parentData, oldValue, newValue, isSame, searchQuery, result, fld, _k, minValue, maxValue, filter, searchObj, dbConnection, result, searchObj, totalRecord, _l, schemaData, result, searchObj, result, schemaData, result, searchObj, totalRecord, regexpression, phone, files, _m, fieldData_1, obj, searchObj, totalRecord, searchObj, result, searchVideoObj, videoPromise, thumbnailPromise, searchThumbnailObj, _o, videoResult, thumbnailResult, text, _p, fieldData_2, obj;
4916
4927
  return __generator(this, function (_q) {
4917
4928
  switch (_q.label) {
@@ -5387,7 +5398,7 @@ function ValidateUserInput(options) {
5387
5398
  case 2:
5388
5399
  if (!(_h < pageFields_1.length)) return [3 /*break*/, 5];
5389
5400
  pageField = pageFields_1[_h];
5390
- return [5 /*yield**/, _loop_20(pageField)];
5401
+ return [5 /*yield**/, _loop_22(pageField)];
5391
5402
  case 3:
5392
5403
  state_3 = _j.sent();
5393
5404
  if (state_3 === "break")
package/package.json CHANGED
@@ -1,60 +1,60 @@
1
- {
2
- "name": "@optimiser/common",
3
- "version": "1.0.434",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "compile": "tsc",
8
- "push": "tsc && npm version patch -git-tag-version false && npm publish"
9
- },
10
- "files": [
11
- "dist/*"
12
- ],
13
- "author": "",
14
- "license": "ISC",
15
- "dependencies": {
16
- "@types/geoip-lite": "^1.4.0",
17
- "@types/promise.allsettled": "^1.0.3",
18
- "@types/request": "^2.48.5",
19
- "@types/sanitize-html": "^2.11.0",
20
- "@types/sequelize": "^4.28.9",
21
- "@types/unzipper": "^0.10.3",
22
- "@types/uuid": "^8.3.0",
23
- "aws-sdk": "^2.786.0",
24
- "axios": "^0.21.4",
25
- "bson": "^4.2.0",
26
- "exceljs": "^4.3.0",
27
- "express": "^4.17.1",
28
- "express-validator": "^6.9.2",
29
- "firebase-admin": "^12.0.0",
30
- "geoip-lite": "^1.4.2",
31
- "google-libphonenumber": "^3.2.30",
32
- "html-to-text": "^8.2.0",
33
- "ioredis": "^4.17.3",
34
- "libphonenumber-js": "^1.9.51",
35
- "moment": "^2.25.3",
36
- "moment-timezone": "^0.5.27",
37
- "mongo-sanitize": "^1.1.0",
38
- "mongodb": "^3.6.2",
39
- "nodemailer": "^6.4.11",
40
- "promise.allsettled": "^1.0.2",
41
- "qrcode": "^1.5.3",
42
- "request": "^2.88.2",
43
- "sanitize-html": "^2.13.0",
44
- "sequelize": "^6.3.5",
45
- "typescript": "^5.3.3",
46
- "unzipper": "^0.10.11",
47
- "uuid": "^8.3.1"
48
- },
49
- "devDependencies": {
50
- "@types/aws-sdk": "^2.7.0",
51
- "@types/bson": "^4.0.2",
52
- "@types/exceljs": "^1.3.0",
53
- "@types/express": "^4.17.8",
54
- "@types/ioredis": "^4.17.4",
55
- "@types/moment": "^2.13.0",
56
- "@types/moment-timezone": "^0.5.30",
57
- "@types/mongodb": "^3.5.27",
58
- "@types/nodemailer": "^6.4.0"
59
- }
60
- }
1
+ {
2
+ "name": "@optimiser/common",
3
+ "version": "1.0.435",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "compile": "tsc",
8
+ "push": "tsc && npm version patch -git-tag-version false && npm publish"
9
+ },
10
+ "files": [
11
+ "dist/*"
12
+ ],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "@types/geoip-lite": "^1.4.0",
17
+ "@types/promise.allsettled": "^1.0.3",
18
+ "@types/request": "^2.48.5",
19
+ "@types/sanitize-html": "^2.11.0",
20
+ "@types/sequelize": "^4.28.9",
21
+ "@types/unzipper": "^0.10.3",
22
+ "@types/uuid": "^8.3.0",
23
+ "aws-sdk": "^2.786.0",
24
+ "axios": "^0.21.4",
25
+ "bson": "^4.2.0",
26
+ "exceljs": "^4.3.0",
27
+ "express": "^4.17.1",
28
+ "express-validator": "^6.9.2",
29
+ "firebase-admin": "^12.0.0",
30
+ "geoip-lite": "^1.4.2",
31
+ "google-libphonenumber": "^3.2.30",
32
+ "html-to-text": "^8.2.0",
33
+ "ioredis": "^4.17.3",
34
+ "libphonenumber-js": "^1.9.51",
35
+ "moment": "^2.25.3",
36
+ "moment-timezone": "^0.5.27",
37
+ "mongo-sanitize": "^1.1.0",
38
+ "mongodb": "^3.6.2",
39
+ "nodemailer": "^6.4.11",
40
+ "promise.allsettled": "^1.0.2",
41
+ "qrcode": "^1.5.3",
42
+ "request": "^2.88.2",
43
+ "sanitize-html": "^2.13.0",
44
+ "sequelize": "^6.3.5",
45
+ "typescript": "^5.3.3",
46
+ "unzipper": "^0.10.11",
47
+ "uuid": "^8.3.1"
48
+ },
49
+ "devDependencies": {
50
+ "@types/aws-sdk": "^2.7.0",
51
+ "@types/bson": "^4.0.2",
52
+ "@types/exceljs": "^1.3.0",
53
+ "@types/express": "^4.17.8",
54
+ "@types/ioredis": "^4.17.4",
55
+ "@types/moment": "^2.13.0",
56
+ "@types/moment-timezone": "^0.5.30",
57
+ "@types/mongodb": "^3.5.27",
58
+ "@types/nodemailer": "^6.4.0"
59
+ }
60
+ }