@optimiser/common 1.0.284 → 1.0.287

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.
@@ -1,6 +1,7 @@
1
1
  declare const _default: {
2
2
  LookupAlias: string;
3
3
  LookupTypeFields: string[];
4
+ SearchValueAlias: string;
4
5
  USER_STATUS: {
5
6
  ACTIVE: string;
6
7
  SUSPEND: string;
package/dist/constants.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  LookupAlias: '_LookupData',
5
5
  LookupTypeFields: ["lookup", "multilookup", "dropdown", "multiselect", "file", "image"],
6
+ SearchValueAlias: '_SearchValue',
6
7
  USER_STATUS: {
7
8
  ACTIVE: 'Active',
8
9
  SUSPEND: 'Suspend',
@@ -28,6 +28,9 @@ declare function SyncFieldInSameCollection(objectName: string, objectIDs: Object
28
28
  declare function SyncFieldInSameCollectionByObjectID(objectName: string, objectID: ObjectId, db: Db): void;
29
29
  declare function SyncFieldInSameCollectionByObjectIDWithPromise(objectName: string, objectID: ObjectId, db: Db): Promise<any>;
30
30
  declare function SyncFieldInOtherCollection(syncFields: AnyObjectInterface[], db: Db): Promise<any>;
31
+ /** Special Note: Need to create seachValue for it in QPC-6169.
32
+ I've not done yet, cause it was not calling from anywhere.
33
+ */
31
34
  declare function SyncUserInOtherCollection(options: AnyObjectInterface, db: Db, callback: callBackInterface, next: NextFunction): void;
32
35
  declare function BuildLookupDataField(fieldSchema: AnyObjectInterface, updateObj: AnyObjectInterface, db: Db): Promise<void>;
33
36
  declare function CheckDataBeforeAdd(updateObj: AnyObjectInterface, objectSchema: AnyObjectInterface, db: Db): Promise<void>;
@@ -1020,7 +1020,7 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
1020
1020
  }
1021
1021
  db.collection(objectName).find(findObj).forEach(function (objectData) {
1022
1022
  return __awaiter(this, void 0, void 0, function () {
1023
- var updateObj, i, fieldSchema, lookupData, ex_1;
1023
+ var updateObj, i, fieldSchema, lookupData, searchValue, ex_1;
1024
1024
  return __generator(this, function (_a) {
1025
1025
  switch (_a.label) {
1026
1026
  case 0:
@@ -1038,8 +1038,13 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
1038
1038
  case 3:
1039
1039
  _a.sent();
1040
1040
  lookupData = objectData[fieldSchema.Name + constants_1.default.LookupAlias];
1041
- if (lookupData !== undefined)
1041
+ if (lookupData !== undefined) {
1042
1042
  updateObj[fieldSchema.Name + constants_1.default.LookupAlias] = lookupData;
1043
+ }
1044
+ searchValue = objectData[fieldSchema.Name + constants_1.default.SearchValueAlias];
1045
+ if (searchValue !== undefined) {
1046
+ updateObj[fieldSchema.Name + constants_1.default.SearchValueAlias] = searchValue;
1047
+ }
1043
1048
  _a.label = 4;
1044
1049
  case 4:
1045
1050
  i++;
@@ -1095,7 +1100,7 @@ function SyncFieldInSameCollectionByObjectID(objectName, objectID, db) {
1095
1100
  if (fieldArr_2) {
1096
1101
  db.collection(objectName).findOne({ '_id': objectID }, function (err, objectData) {
1097
1102
  return __awaiter(this, void 0, void 0, function () {
1098
- var updateObj, i, fieldSchema, lookupData;
1103
+ var updateObj, i, fieldSchema, lookupData, searchValue;
1099
1104
  return __generator(this, function (_a) {
1100
1105
  switch (_a.label) {
1101
1106
  case 0:
@@ -1110,8 +1115,13 @@ function SyncFieldInSameCollectionByObjectID(objectName, objectID, db) {
1110
1115
  case 2:
1111
1116
  _a.sent();
1112
1117
  lookupData = objectData[fieldSchema.Name + constants_1.default.LookupAlias];
1113
- if (lookupData !== undefined)
1118
+ if (lookupData !== undefined) {
1114
1119
  updateObj[fieldSchema.Name + constants_1.default.LookupAlias] = lookupData;
1120
+ }
1121
+ searchValue = objectData[fieldSchema.Name + constants_1.default.SearchValueAlias];
1122
+ if (searchValue !== undefined) {
1123
+ updateObj[fieldSchema.Name + constants_1.default.SearchValueAlias] = searchValue;
1124
+ }
1115
1125
  _a.label = 3;
1116
1126
  case 3:
1117
1127
  i++;
@@ -1140,7 +1150,7 @@ function SyncFieldInSameCollectionByObjectIDWithPromise(objectName, objectID, db
1140
1150
  if (fieldArr_3) {
1141
1151
  db.collection(objectName).findOne({ '_id': objectID }, function (err, objectData) {
1142
1152
  return __awaiter(this, void 0, void 0, function () {
1143
- var updateObj, i, fieldSchema, lookupData;
1153
+ var updateObj, i, fieldSchema, lookupData, searchValue;
1144
1154
  return __generator(this, function (_a) {
1145
1155
  switch (_a.label) {
1146
1156
  case 0:
@@ -1155,8 +1165,13 @@ function SyncFieldInSameCollectionByObjectIDWithPromise(objectName, objectID, db
1155
1165
  case 2:
1156
1166
  _a.sent();
1157
1167
  lookupData = objectData[fieldSchema.Name + constants_1.default.LookupAlias];
1158
- if (lookupData !== undefined)
1168
+ if (lookupData !== undefined) {
1159
1169
  updateObj[fieldSchema.Name + constants_1.default.LookupAlias] = lookupData;
1170
+ }
1171
+ searchValue = objectData[fieldSchema.Name + constants_1.default.SearchValueAlias];
1172
+ if (searchValue !== undefined) {
1173
+ updateObj[fieldSchema.Name + constants_1.default.SearchValueAlias] = searchValue;
1174
+ }
1160
1175
  _a.label = 3;
1161
1176
  case 3:
1162
1177
  i++;
@@ -1188,6 +1203,7 @@ function SyncFieldInSameCollectionByObjectIDWithPromise(objectName, objectID, db
1188
1203
  });
1189
1204
  }
1190
1205
  exports.SyncFieldInSameCollectionByObjectIDWithPromise = SyncFieldInSameCollectionByObjectIDWithPromise;
1206
+ //** SyncFieldInOtherCollection function is moved in fieldlistener service by Satyam */
1191
1207
  //Sync field in other collection after update
1192
1208
  function SyncFieldInOtherCollection(syncFields, db) {
1193
1209
  var _this = this;
@@ -1306,6 +1322,9 @@ exports.SyncFieldInOtherCollection = SyncFieldInOtherCollection;
1306
1322
  /*Sync user in other collection after replace user
1307
1323
  *this function is used in /replaceuser api
1308
1324
  */
1325
+ /** Special Note: Need to create seachValue for it in QPC-6169.
1326
+ I've not done yet, cause it was not calling from anywhere.
1327
+ */
1309
1328
  function SyncUserInOtherCollection(options, db, callback, next) {
1310
1329
  var userData = options.userData;
1311
1330
  var msp_d = options.msp_d;
@@ -1454,6 +1473,7 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1454
1473
  var fldName = fieldSchema.Name;
1455
1474
  var fldValue_1 = updateObj[fldName];
1456
1475
  var alias_1 = fldName + constants_1.default.LookupAlias;
1476
+ var searchAlias_1 = fldName + constants_1.default.SearchValueAlias;
1457
1477
  var fldLookupData_1 = null;
1458
1478
  if (fldValue_1) {
1459
1479
  var aggregateArry = [];
@@ -1495,6 +1515,22 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1495
1515
  else if (data && data.length > 0) {
1496
1516
  fldLookupData_1 = data[0];
1497
1517
  updateObj[alias_1] = fldLookupData_1;
1518
+ //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1519
+ var result = '';
1520
+ if (fieldSchema.LookupFields != undefined) {
1521
+ var _loop_10 = function (j) {
1522
+ if (fieldSchema.ExcludeLookupFieldsOnSearch && fieldSchema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == fieldSchema.LookupFields[j]; }).length != 0) {
1523
+ return "continue";
1524
+ }
1525
+ if (fldLookupData_1[fieldSchema.LookupFields[j]] != undefined)
1526
+ result += fldLookupData_1[fieldSchema.LookupFields[j]].toString() + ' ';
1527
+ };
1528
+ for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1529
+ _loop_10(j);
1530
+ }
1531
+ }
1532
+ updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1533
+ //** Ends here */
1498
1534
  }
1499
1535
  resolve();
1500
1536
  });
@@ -1524,6 +1560,19 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1524
1560
  else if (data && data.length > 0) {
1525
1561
  fldLookupData_1 = data;
1526
1562
  updateObj[alias_1] = fldLookupData_1;
1563
+ //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1564
+ var result = '';
1565
+ for (var i = 0; i < data.length; i++) {
1566
+ var lookupRecord = data[i];
1567
+ if (fieldSchema.LookupFields != undefined) {
1568
+ for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1569
+ if (lookupRecord[fieldSchema.LookupFields[j]] != undefined)
1570
+ result += lookupRecord[fieldSchema.LookupFields[j]].toString() + ' ';
1571
+ }
1572
+ }
1573
+ }
1574
+ updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1575
+ //** Ends here */
1527
1576
  }
1528
1577
  resolve();
1529
1578
  });
@@ -1625,6 +1674,10 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
1625
1674
  }
1626
1675
  else {
1627
1676
  updateObj[alias_1] = fldLookupData_1;
1677
+ // Below if cond was added by Shahzaib on 05/09/2022
1678
+ if (fieldSchema.UIDataType == 'lookup' || fieldSchema.UIDataType == 'multilookup') {
1679
+ updateObj[searchAlias_1] = fldLookupData_1;
1680
+ }
1628
1681
  resolve();
1629
1682
  }
1630
1683
  }
@@ -1637,11 +1690,11 @@ exports.BuildLookupDataField = BuildLookupDataField;
1637
1690
  //CheckDataBeforeAdd it sync object before add
1638
1691
  function CheckDataBeforeAdd(updateObj, objectSchema, db) {
1639
1692
  return __awaiter(this, void 0, void 0, function () {
1640
- var _loop_10, _i, _a, fldName;
1693
+ var _loop_11, _i, _a, fldName;
1641
1694
  return __generator(this, function (_b) {
1642
1695
  switch (_b.label) {
1643
1696
  case 0:
1644
- _loop_10 = function (fldName) {
1697
+ _loop_11 = function (fldName) {
1645
1698
  var fieldSchema, sequenceDocument, val, j, item, num;
1646
1699
  return __generator(this, function (_a) {
1647
1700
  switch (_a.label) {
@@ -1687,7 +1740,7 @@ function CheckDataBeforeAdd(updateObj, objectSchema, db) {
1687
1740
  case 1:
1688
1741
  if (!(_i < _a.length)) return [3 /*break*/, 4];
1689
1742
  fldName = _a[_i];
1690
- return [5 /*yield**/, _loop_10(fldName)];
1743
+ return [5 /*yield**/, _loop_11(fldName)];
1691
1744
  case 2:
1692
1745
  _b.sent();
1693
1746
  _b.label = 3;
@@ -1703,11 +1756,11 @@ exports.CheckDataBeforeAdd = CheckDataBeforeAdd;
1703
1756
  //CheckDataBeforeAdd it sync object before update
1704
1757
  function CheckDataBeforeUpdate(updateObj, objectData, objectSchema, db) {
1705
1758
  return __awaiter(this, void 0, void 0, function () {
1706
- var _loop_11, _i, _a, fldName;
1759
+ var _loop_12, _i, _a, fldName;
1707
1760
  return __generator(this, function (_b) {
1708
1761
  switch (_b.label) {
1709
1762
  case 0:
1710
- _loop_11 = function (fldName) {
1763
+ _loop_12 = function (fldName) {
1711
1764
  var fieldSchema, oldValue, newValue, isSame;
1712
1765
  return __generator(this, function (_a) {
1713
1766
  switch (_a.label) {
@@ -1750,7 +1803,7 @@ function CheckDataBeforeUpdate(updateObj, objectData, objectSchema, db) {
1750
1803
  case 1:
1751
1804
  if (!(_i < _a.length)) return [3 /*break*/, 4];
1752
1805
  fldName = _a[_i];
1753
- return [5 /*yield**/, _loop_11(fldName)];
1806
+ return [5 /*yield**/, _loop_12(fldName)];
1754
1807
  case 2:
1755
1808
  _b.sent();
1756
1809
  _b.label = 3;
@@ -1769,13 +1822,23 @@ function BuildGridFieldProjection(project, field, group) {
1769
1822
  if (group && group.IsRealLookup)
1770
1823
  fldName = group.Name + '.' + fldName;
1771
1824
  var alias;
1825
+ var searchAlias = fldName + constants_1.default.SearchValueAlias;
1772
1826
  var searchConcatArry = [];
1773
1827
  switch (field.Schema.UIDataType) {
1828
+ // below code was added by Shahzaib on 05/09/2022
1829
+ // case "lookup":
1830
+ // case "multilookup":
1831
+ // alias = fldName + constants.LookupAlias;
1832
+ // project[fldName] = 1;
1833
+ // project[alias] = 1;
1834
+ // project[searchAlias] = 1;
1835
+ // break;
1836
+ // Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
1774
1837
  case "lookup":
1775
1838
  alias = fldName + constants_1.default.LookupAlias;
1776
1839
  project[fldName] = 1;
1777
1840
  project[alias] = 1;
1778
- var _loop_12 = function (i) {
1841
+ var _loop_13 = function (i) {
1779
1842
  if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == field.Schema.LookupFields[i]; }).length != 0) {
1780
1843
  return "continue";
1781
1844
  }
@@ -1787,7 +1850,7 @@ function BuildGridFieldProjection(project, field, group) {
1787
1850
  }
1788
1851
  };
1789
1852
  for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1790
- _loop_12(i);
1853
+ _loop_13(i);
1791
1854
  }
1792
1855
  ;
1793
1856
  project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
@@ -2036,7 +2099,7 @@ function FilterConditions(condition, match, fields) {
2036
2099
  match.$or = new Array();
2037
2100
  sets = match.$or;
2038
2101
  }
2039
- var _loop_13 = function (i) {
2102
+ var _loop_14 = function (i) {
2040
2103
  var obj = condition.Filters[i];
2041
2104
  if (obj.Type == "Child") {
2042
2105
  var childMatch = {};
@@ -2205,7 +2268,7 @@ function FilterConditions(condition, match, fields) {
2205
2268
  }
2206
2269
  };
2207
2270
  for (var i = 0; i < condition.Filters.length; i++) {
2208
- _loop_13(i);
2271
+ _loop_14(i);
2209
2272
  }
2210
2273
  }
2211
2274
  }
@@ -2213,7 +2276,7 @@ exports.FilterConditions = FilterConditions;
2213
2276
  function GirdHeaderFilters(filters, fields) {
2214
2277
  try {
2215
2278
  var sets = [];
2216
- var _loop_14 = function (i) {
2279
+ var _loop_15 = function (i) {
2217
2280
  var obj = filters[i];
2218
2281
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2219
2282
  if (field) {
@@ -2266,7 +2329,7 @@ function GirdHeaderFilters(filters, fields) {
2266
2329
  }
2267
2330
  };
2268
2331
  for (var i = 0; i < filters.length; i++) {
2269
- _loop_14(i);
2332
+ _loop_15(i);
2270
2333
  }
2271
2334
  return { '$and': sets };
2272
2335
  }
@@ -2278,7 +2341,7 @@ exports.GirdHeaderFilters = GirdHeaderFilters;
2278
2341
  function FieldsGridHeaderFilters(filters, fields) {
2279
2342
  var sets = [];
2280
2343
  var lookupFieldsSets = [];
2281
- var _loop_15 = function (i) {
2344
+ var _loop_16 = function (i) {
2282
2345
  var _a;
2283
2346
  var obj = filters[i];
2284
2347
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
@@ -2322,7 +2385,7 @@ function FieldsGridHeaderFilters(filters, fields) {
2322
2385
  }
2323
2386
  };
2324
2387
  for (var i = 0; i < filters.length; i++) {
2325
- _loop_15(i);
2388
+ _loop_16(i);
2326
2389
  }
2327
2390
  return { '$and': sets, 'lookupConditions': lookupFieldsSets };
2328
2391
  }
@@ -2360,7 +2423,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
2360
2423
  exports.AddLog = AddLog;
2361
2424
  function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2362
2425
  if (condition != undefined && condition.Filters.length > 0) {
2363
- var _loop_16 = function (i) {
2426
+ var _loop_17 = function (i) {
2364
2427
  var objFilter = condition.Filters[i];
2365
2428
  if (objFilter.Type == "Child") {
2366
2429
  CheckFilterFieldsProjection(objFilter, fields, pageData, project);
@@ -2378,7 +2441,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2378
2441
  }
2379
2442
  };
2380
2443
  for (var i = 0; i < condition.Filters.length; i++) {
2381
- _loop_16(i);
2444
+ _loop_17(i);
2382
2445
  }
2383
2446
  }
2384
2447
  }
@@ -3991,7 +4054,7 @@ exports.GetDayIndex = GetDayIndex;
3991
4054
  function GetUserProfile(msp_d, db, mdb, next) {
3992
4055
  var _a;
3993
4056
  return __awaiter(this, void 0, void 0, function () {
3994
- var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
4057
+ var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_18, i, error_4;
3995
4058
  return __generator(this, function (_b) {
3996
4059
  switch (_b.label) {
3997
4060
  case 0:
@@ -4070,14 +4133,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
4070
4133
  moduleList = userProfile_1[0].ModuleList;
4071
4134
  userProfile_1[0].HasControlPanelAccess = [];
4072
4135
  if (userProfile_1[0].Permissions) {
4073
- _loop_17 = function (i) {
4136
+ _loop_18 = function (i) {
4074
4137
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
4075
4138
  if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
4076
4139
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
4077
4140
  }
4078
4141
  };
4079
4142
  for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
4080
- _loop_17(i);
4143
+ _loop_18(i);
4081
4144
  }
4082
4145
  }
4083
4146
  if (moduleList.length == 0) {
@@ -4439,6 +4502,6 @@ exports.GetMailFromString = GetMailFromString;
4439
4502
  * @returns string
4440
4503
  */
4441
4504
  function InvitationMailReplyContent(fromUser, fromEmail) {
4442
- return "Please do not 'reply' to this email as it is an automated message and replies are routed to an unmonitored mailbox. If you wish to propose an alternative time, or send a message, please contact " + fromUser + " at " + fromEmail + " directly.";
4505
+ return "Please do not 'reply' to this email as it is an automated message and replies are routed to an unmonitored mailbox. If you wish to propose an alternative time or send a message, please contact " + fromUser + " at " + fromEmail + " directly.";
4443
4506
  }
4444
4507
  exports.InvitationMailReplyContent = InvitationMailReplyContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.284",
3
+ "version": "1.0.287",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {