@optimiser/common 1.0.265 → 1.0.268

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.
@@ -423,7 +423,7 @@ var Connection = /** @class */ (function () {
423
423
  Type: "ERROR"
424
424
  })];
425
425
  }
426
- db.collection("User").findOne({ _id: new mongodb_1.ObjectID(req.cookies.msp_d.ui) }).then(function (user) {
426
+ db.collection("User").findOne({ _id: new mongodb_1.ObjectId(req.cookies.msp_d.ui) }).then(function (user) {
427
427
  if (!user) {
428
428
  return _this.ReturnJsonResponse(req, res, {
429
429
  Data: {},
package/dist/lib/event.js CHANGED
@@ -57,7 +57,7 @@ var Event = /** @class */ (function () {
57
57
  switch (_a.label) {
58
58
  case 0:
59
59
  if (!(db && userId && data && data.PushNotificationObj && !data.PushNotificationObj["endpoint"])) return [3 /*break*/, 2];
60
- return [4 /*yield*/, db.collection('UserNotification').findOne({ UserID: new mongodb_1.ObjectID(userId) })];
60
+ return [4 /*yield*/, db.collection('UserNotification').findOne({ UserID: new mongodb_1.ObjectId(userId) })];
61
61
  case 1:
62
62
  userObj = _a.sent();
63
63
  if (userObj && userObj.endpoint && userObj.keys && data.PushNotificationObj) {
@@ -130,8 +130,8 @@ var Event = /** @class */ (function () {
130
130
  CreatedDate: new Date(),
131
131
  Users: [],
132
132
  EventObjectName: data.EventObjectName,
133
- EventID: new mongodb_1.ObjectID(data.EventID),
134
- CreatedBy: new mongodb_1.ObjectID(data.CreatedBy),
133
+ EventID: new mongodb_1.ObjectId(data.EventID),
134
+ CreatedBy: new mongodb_1.ObjectId(data.CreatedBy),
135
135
  Message: data.Message
136
136
  };
137
137
  var Userid = [];
@@ -139,7 +139,7 @@ var Event = /** @class */ (function () {
139
139
  Userid.push({
140
140
  "IsSeen": false,
141
141
  "IsNew": true,
142
- "UserID": new mongodb_1.ObjectID(id)
142
+ "UserID": new mongodb_1.ObjectId(id)
143
143
  });
144
144
  });
145
145
  saveObj.Users = Userid;
@@ -1,4 +1,4 @@
1
- import { Db, ObjectID } from "mongodb";
1
+ import { Db, ObjectId } from "mongodb";
2
2
  import { AnyObjectInterface } from "../modals/utility.modal";
3
3
  declare function GetCompanyDetails(Master_DB: Db, companyId: string): Promise<any>;
4
4
  declare function GetListSchema(db: Db, listName: string): Promise<Error | AnyObjectInterface[] | []>;
@@ -6,7 +6,7 @@ declare function GetEmailwiseUnsubscribeData(db: Db, mailID: string, domainID?:
6
6
  declare function GenerateAutoIncrementFieldValue(db: Db, autoIncrementID: string): Promise<null | string>;
7
7
  declare function GetAccountDetailByName(db: Db, accountName: string): Promise<AnyObjectInterface | null>;
8
8
  declare function GetContactDetailByEmail(db: Db, contactEmail: string): Promise<null | AnyObjectInterface>;
9
- declare function GetSystemEmailTemplate(db: Db, TemplateIDArray: ObjectID[]): Promise<null | AnyObjectInterface>;
9
+ declare function GetSystemEmailTemplate(db: Db, TemplateIDArray: ObjectId[]): Promise<null | AnyObjectInterface>;
10
10
  declare function UpdateContactDetails(db: Db, contactData: AnyObjectInterface): void;
11
11
  declare function CreateContact(db: Db, contactData: AnyObjectInterface): Promise<null | AnyObjectInterface>;
12
12
  declare function MapAccountContact(db: Db, dataObj: AnyObjectInterface): void;
@@ -50,7 +50,7 @@ declare const GetEmailSubscribeStatus: (db: Db, email: string) => Promise<Error
50
50
  * @param {mongodbQueryOptions} object, params to pass on db queries
51
51
  * @returns resolve success | error object
52
52
  */
53
- declare const SubscribeEmailForAllDomains: (db: Db, email: string, isSubscribe: boolean, companyID: ObjectID, comment?: string, mongodbQueryOptions?: any) => Promise<unknown>;
53
+ declare const SubscribeEmailForAllDomains: (db: Db, email: string, isSubscribe: boolean, companyID: ObjectId, comment?: string, mongodbQueryOptions?: any) => Promise<unknown>;
54
54
  /**
55
55
  * checking phone number is valid and has dialing code
56
56
  * if it has dialing code then get country code, get its optimiser country phone code
@@ -45,7 +45,7 @@ var constants_1 = __importDefault(require("../constants"));
45
45
  var moment_1 = __importDefault(require("moment"));
46
46
  var libphonenumber_js_1 = require("libphonenumber-js");
47
47
  function GetCompanyDetails(Master_DB, companyId) {
48
- return Master_DB.collection('Company').findOne({ _id: new mongodb_1.ObjectID(companyId) });
48
+ return Master_DB.collection('Company').findOne({ _id: new mongodb_1.ObjectId(companyId) });
49
49
  }
50
50
  exports.GetCompanyDetails = GetCompanyDetails;
51
51
  function GetListSchema(db, listName) {
@@ -519,7 +519,7 @@ var EmailPrioritySearch = function (params) { return __awaiter(void 0, void 0, v
519
519
  if (!(memoryServerSearchData && Object.keys(memoryServerSearchData.response).length !== 0)) return [3 /*break*/, 4];
520
520
  id = (_b = memoryServerSearchData === null || memoryServerSearchData === void 0 ? void 0 : memoryServerSearchData.response) === null || _b === void 0 ? void 0 : _b._id;
521
521
  if (!(id && id !== '')) return [3 /*break*/, 3];
522
- convertedToObjectID = new mongodb_1.ObjectID(id);
522
+ convertedToObjectID = new mongodb_1.ObjectId(id);
523
523
  return [4 /*yield*/, params.db.collection(params.ProfileType).findOne({ '_id': convertedToObjectID }, mongodbTransactionQueryopts)];
524
524
  case 2:
525
525
  result = _c.sent();
@@ -157,7 +157,7 @@ function GenerateTaskNotifications(req, options, db, event) {
157
157
  if (!tasks_1[0].ListSublist)
158
158
  return [2 /*return*/];
159
159
  return [4 /*yield*/, db.collection('TaskList').findOne({
160
- _id: new mongodb_1.ObjectID(tasks_1[0].ListSublist)
160
+ _id: new mongodb_1.ObjectId(tasks_1[0].ListSublist)
161
161
  })];
162
162
  case 3:
163
163
  list = _b.sent();
@@ -179,12 +179,12 @@ function GenerateTaskNotifications(req, options, db, event) {
179
179
  info['taskBeforeEdit'] = options.taskBeforeEdit;
180
180
  return [3 /*break*/, 8];
181
181
  case 4: return [4 /*yield*/, db.collection('Task').findOne({
182
- _id: new mongodb_1.ObjectID(options.taskID)
182
+ _id: new mongodb_1.ObjectId(options.taskID)
183
183
  })];
184
184
  case 5:
185
185
  task = _b.sent();
186
186
  return [4 /*yield*/, db.collection('TaskList').findOne({
187
- _id: new mongodb_1.ObjectID(task.ListSublist)
187
+ _id: new mongodb_1.ObjectId(task.ListSublist)
188
188
  })];
189
189
  case 6:
190
190
  list = _b.sent();
@@ -262,10 +262,10 @@ function CreateNotificationContent(info, req, db, event) {
262
262
  return __generator(this, function (_b) {
263
263
  switch (_b.label) {
264
264
  case 0:
265
- UserID = new mongodb_1.ObjectID(req.cookies.msp_d.ui);
265
+ UserID = new mongodb_1.ObjectId(req.cookies.msp_d.ui);
266
266
  Payload = {};
267
267
  FetchUsers = function (query) { return db.collection('User').find(query).toArray(); };
268
- ListInfo = function (id) { return db.collection('TaskList').findOne({ _id: new mongodb_1.ObjectID(id) }); };
268
+ ListInfo = function (id) { return db.collection('TaskList').findOne({ _id: new mongodb_1.ObjectId(id) }); };
269
269
  TaskInfo = function (TaskNumber) { return db.collection('Task').findOne({ TaskNumber: TaskNumber }); };
270
270
  NotificationContent = {};
271
271
  _a = info.page;
@@ -354,7 +354,7 @@ function CreateNotificationContent(info, req, db, event) {
354
354
  creator = _b.sent();
355
355
  creator = creator[0];
356
356
  return [3 /*break*/, 13];
357
- case 11: return [4 /*yield*/, FetchUsers({ _id: new mongodb_1.ObjectID(info.receiverId), "UserStatus": { $not: { $eq: "Blocked" } } })];
357
+ case 11: return [4 /*yield*/, FetchUsers({ _id: new mongodb_1.ObjectId(info.receiverId), "UserStatus": { $not: { $eq: "Blocked" } } })];
358
358
  case 12:
359
359
  users = _b.sent();
360
360
  creator = info.senderData[0];
@@ -398,7 +398,7 @@ function CreateNotificationContent(info, req, db, event) {
398
398
  if (!(info.event == 'EDIT_TASK')) return [3 /*break*/, 17];
399
399
  if ((req.body.AssignedTo ? req.body.AssignedTo.$oid : (oldTaskData.AssignedTo).toString()) == (oldTaskData.OwnerID).toString())
400
400
  return [2 /*return*/];
401
- receiverId_1 = new mongodb_1.ObjectID((req.cookies.msp_d.ui == (oldTaskData.AssignedTo).toString()) ? oldTaskData.OwnerID : (oldTaskData.AssignedTo).toString());
401
+ receiverId_1 = new mongodb_1.ObjectId((req.cookies.msp_d.ui == (oldTaskData.AssignedTo).toString()) ? oldTaskData.OwnerID : (oldTaskData.AssignedTo).toString());
402
402
  return [4 /*yield*/, FetchUsers({
403
403
  _id: receiverId_1,
404
404
  "UserStatus": { $not: { $eq: "Blocked" } }
@@ -492,7 +492,7 @@ function CreateNotificationContent(info, req, db, event) {
492
492
  return [3 /*break*/, 20];
493
493
  case 17:
494
494
  if (!(info.event == "EDIT_TASK_INLINE")) return [3 /*break*/, 20];
495
- receiverId_2 = new mongodb_1.ObjectID((req.cookies.msp_d.ui == (oldTaskData.AssignedTo).toString()) ? oldTaskData.OwnerID : (oldTaskData.AssignedTo).toString());
495
+ receiverId_2 = new mongodb_1.ObjectId((req.cookies.msp_d.ui == (oldTaskData.AssignedTo).toString()) ? oldTaskData.OwnerID : (oldTaskData.AssignedTo).toString());
496
496
  return [4 /*yield*/, FetchUsers({ _id: receiverId_2, "UserStatus": { $not: { $eq: "Blocked" } } })];
497
497
  case 18:
498
498
  receiverData_2 = _b.sent();
@@ -1,6 +1,6 @@
1
1
  import { Moment } from "moment";
2
2
  import { NextFunction, Response } from "express";
3
- import { ObjectID, ObjectId, Db } from "mongodb";
3
+ import { ObjectId, Db } from "mongodb";
4
4
  import { ResponseStructure, OPT_ERROR } from "../modals/connection.modal";
5
5
  import { Express } from '../modals/log.modal';
6
6
  import { AnyObjectInterface, callBackInterface } from "../modals/utility.modal";
@@ -14,10 +14,10 @@ declare function CheckUserProfileField(pageData: AnyObjectInterface, profileData
14
14
  declare function GetPageFieldData(pageName: string, db: any, mdb: any, msp_d: any, next: NextFunction, callback: callBackInterface): void;
15
15
  declare function GetPageObjectSchema(pageName: string, db: Db, next: NextFunction, callback: callBackInterface): void;
16
16
  declare function GetFieldDetail(objectName: string, fieldName: string, db: any, callback: callBackInterface, next: NextFunction): void;
17
- declare function UpdateRecentViewObject(objectName: string, objectID: ObjectID, userID: ObjectID, db: Db): void;
18
- declare function UpdateRecentViewFields(objectName: string, fieldID: string, userID: ObjectID, db: Db): void;
19
- declare function SyncChildObjectData(pageData: AnyObjectInterface, objectID: ObjectID, db: Db): Promise<void>;
20
- declare function SyncParentObjectData(pageData: AnyObjectInterface, objectID: ObjectID, db: Db): Promise<void>;
17
+ declare function UpdateRecentViewObject(objectName: string, objectID: ObjectId, userID: ObjectId, db: Db): void;
18
+ declare function UpdateRecentViewFields(objectName: string, fieldID: string, userID: ObjectId, db: Db): void;
19
+ declare function SyncChildObjectData(pageData: AnyObjectInterface, objectID: ObjectId, db: Db): Promise<void>;
20
+ declare function SyncParentObjectData(pageData: AnyObjectInterface, objectID: ObjectId, db: Db): Promise<void>;
21
21
  /**
22
22
  * Delete field in other collection after delete records
23
23
  * @param mongodbTransactionQueryopts to maintain session for transactions
@@ -391,14 +391,15 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
391
391
  Width: 100
392
392
  };
393
393
  pageData.Fields.splice(0, 0, idObject);
394
+ //Code added by Brijesh on 25Apr2022, condition added for objectschema =PromoCodeTransaction and grouped then not condition
394
395
  //By Kashish : To handle System Info Fields in Grid
395
- if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Task' && pageData.ObjectName != 'Session')
396
+ if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction", "Task"].includes(pageData.ObjectName) == false)
396
397
  pageData.Fields.push(createdByObj);
397
- if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Session')
398
+ if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction"].includes(pageData.ObjectName) == false)
398
399
  pageData.Fields.push(createdDateObj);
399
- if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Session')
400
+ if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction"].includes(pageData.ObjectName) == false)
400
401
  pageData.Fields.push(modByObj);
401
- if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Session')
402
+ if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction"].includes(pageData.ObjectName) == false)
402
403
  pageData.Fields.push(modDateObj);
403
404
  }
404
405
  if (pageData.Fields && pageData.Type == "ObjectDetail") {
@@ -1348,7 +1349,7 @@ function SyncUserInOtherCollection(options, db, callback, next) {
1348
1349
  else if (field.UIDataType == "multilookup") {
1349
1350
  query.match = (_b = {}, _b[field.Name] = { "$nin": [null] }, _b[field.Name + constants_1.default.LookupAlias] = { "$nin": [null] }, _b);
1350
1351
  query.set[field.Name + '.$[e]'] = userData["toUserData"]._id;
1351
- query.set["ModifiedBy"] = new mongodb_1.ObjectID(msp_d.ui);
1352
+ query.set["ModifiedBy"] = new mongodb_1.ObjectId(msp_d.ui);
1352
1353
  query.set["ModifiedDate"] = new Date();
1353
1354
  query.arrayFilters = (_c = {}, _c['e._id'] = userData["fromUserData"]._id, _c);
1354
1355
  if (query.set && query.arrayFilters)
@@ -2039,6 +2040,15 @@ function FilterConditions(condition, match, fields) {
2039
2040
  if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2040
2041
  fldName += '_SearchValue';
2041
2042
  }
2043
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2044
+ if (field.Schema.SearchType) {
2045
+ fldName = field.UniqueID;
2046
+ if (field.Schema.SearchType == 'dropdown') {
2047
+ if (field.Schema.LookupObject && obj.Value && (field.Schema.SelectKeyType == undefined || field.Schema.SelectKeyType == 'objectid')) {
2048
+ obj.Value = new mongodb_1.ObjectId(obj.Value);
2049
+ }
2050
+ }
2051
+ }
2042
2052
  switch (field.Schema.UIDataType) {
2043
2053
  case "int":
2044
2054
  obj.Value = parseInt(obj.Value);
@@ -2050,7 +2060,7 @@ function FilterConditions(condition, match, fields) {
2050
2060
  case "multiselect":
2051
2061
  if (field.Schema.LookupObject) {
2052
2062
  for (var i_7 = 0; i_7 < obj.Value.length; i_7++) {
2053
- obj.Value[i_7] = new mongodb_1.ObjectID(obj.Value[i_7]);
2063
+ obj.Value[i_7] = new mongodb_1.ObjectId(obj.Value[i_7]);
2054
2064
  }
2055
2065
  }
2056
2066
  break;
@@ -2078,6 +2088,9 @@ function FilterConditions(condition, match, fields) {
2078
2088
  case "EQUAL":
2079
2089
  if (obj.Value === '')
2080
2090
  matchValue = { '$in': [null, ''] };
2091
+ else if (field.Schema.SearchType == 'dropdown') {
2092
+ matchValue = { '$eq': obj.Value };
2093
+ }
2081
2094
  else if (["date", "datetime"].includes(field.Schema.UIDataType)) {
2082
2095
  matchValue = { '$gte': moment_1.default(obj.Value).startOf('day').toDate(), '$lte': moment_1.default(obj.Value).endOf('day').toDate() };
2083
2096
  }
@@ -2107,6 +2120,9 @@ function FilterConditions(condition, match, fields) {
2107
2120
  case "NOT_EQUAL":
2108
2121
  if (obj.Value === '')
2109
2122
  matchValue = { '$nin': [null, ''] };
2123
+ else if (field.Schema.SearchType == 'dropdown') {
2124
+ matchValue = { '$ne': obj.Value };
2125
+ }
2110
2126
  else if (["int", "decimal", "percent", "time"].includes(field.Schema.UIDataType)) {
2111
2127
  matchValue = { '$ne': obj.Value };
2112
2128
  }
@@ -2170,10 +2186,15 @@ function GirdHeaderFilters(filters, fields) {
2170
2186
  if (field) {
2171
2187
  var matchValue = null;
2172
2188
  var fldName = field.UniqueID;
2173
- if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2189
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2190
+ if (field.Schema.SearchType == 'dropdown') {
2191
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2192
+ }
2193
+ else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2174
2194
  fldName += '_SearchValue';
2195
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2175
2196
  }
2176
- if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2197
+ else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2177
2198
  if (field.Schema.LookupObject) {
2178
2199
  matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2179
2200
  }
@@ -2196,6 +2217,10 @@ function GirdHeaderFilters(filters, fields) {
2196
2217
  else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2197
2218
  matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2198
2219
  else if (field.Schema.UIDataType == 'objectid')
2220
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2221
+ else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2222
+ matchValue = new RegExp('^' + obj.Value + '$', 'i');
2223
+ else if (field.Schema.IsEqualSearch === true)
2199
2224
  matchValue = { '$eq': obj.Value };
2200
2225
  else
2201
2226
  matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
@@ -2276,7 +2301,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
2276
2301
  logObj.Action = logAction;
2277
2302
  if (objLogProp.ObjectID)
2278
2303
  if (objLogProp.ObjectID.$oid) {
2279
- logObj.ObjectID = new mongodb_1.ObjectID(objLogProp.ObjectID.$oid);
2304
+ logObj.ObjectID = new mongodb_1.ObjectId(objLogProp.ObjectID.$oid);
2280
2305
  }
2281
2306
  else {
2282
2307
  logObj.ObjectID = objLogProp.ObjectID;
@@ -2370,7 +2395,7 @@ caledar sharing settings : caledar sharing settings
2370
2395
  function GetMyTeamUsers(options, next) {
2371
2396
  var usersList = [];
2372
2397
  var db = options.db;
2373
- db.collection("Company").findOne({ '_id': new mongodb_1.ObjectID(options.CompanyID) }, function (error, result) {
2398
+ db.collection("Company").findOne({ '_id': new mongodb_1.ObjectId(options.CompanyID) }, function (error, result) {
2374
2399
  if (result) {
2375
2400
  var calendarSetting = result.Setting;
2376
2401
  if (calendarSetting.CalendarShare == "private") {
@@ -2406,8 +2431,8 @@ function GetMyTeamUsers(options, next) {
2406
2431
  pendingCalls_1 = pendingCalls_1 - 1;
2407
2432
  db.collection("User").find({
2408
2433
  $or: [
2409
- { '_id': new mongodb_1.ObjectID(options.SupervisorID) },
2410
- { 'SupervisorID': new mongodb_1.ObjectID(options.SupervisorID) }
2434
+ { '_id': new mongodb_1.ObjectId(options.SupervisorID) },
2435
+ { 'SupervisorID': new mongodb_1.ObjectId(options.SupervisorID) }
2411
2436
  ],
2412
2437
  'IsActive': true,
2413
2438
  "MySettings.IsHideFromAllUsers": { $ne: true }
@@ -2452,7 +2477,7 @@ function GetMyTeamUsers(options, next) {
2452
2477
  counter_2 = counter_2 + 1;
2453
2478
  pendingCalls_2 = pendingCalls_2 - 1;
2454
2479
  db.collection("User").find({
2455
- 'SupervisorID': new mongodb_1.ObjectID(options.SupervisorID),
2480
+ 'SupervisorID': new mongodb_1.ObjectId(options.SupervisorID),
2456
2481
  'IsActive': true,
2457
2482
  "MySettings.IsHideFromAllUsers": { $ne: true }
2458
2483
  }, { projection: { _id: 1, FirstName: 1, LastName: 1, UserStatus: 1 } }).toArray(function (error, result) {
@@ -2501,7 +2526,7 @@ function GetMyTeamUsers(options, next) {
2501
2526
  }
2502
2527
  exports.GetMyTeamUsers = GetMyTeamUsers;
2503
2528
  function ExtractChildUsersTree(userId, childUsersArray, usersTraversed, counter, db, onFetch) {
2504
- db.collection("User").find({ 'IsActive': true, 'SupervisorID': new mongodb_1.ObjectID(userId), "MySettings.IsHideFromAllUsers": { $ne: true } }, { projection: { _id: 1, FirstName: 1, LastName: 1, UserStatus: 1 } }).toArray(function (error, result) {
2529
+ db.collection("User").find({ 'IsActive': true, 'SupervisorID': new mongodb_1.ObjectId(userId), "MySettings.IsHideFromAllUsers": { $ne: true } }, { projection: { _id: 1, FirstName: 1, LastName: 1, UserStatus: 1 } }).toArray(function (error, result) {
2505
2530
  if (error) {
2506
2531
  //res.json({ message: err.message, status: 'failed' })
2507
2532
  }
@@ -2568,7 +2593,7 @@ exports.VerifyAWSEmailConfig = VerifyAWSEmailConfig;
2568
2593
  function GenerateId(obj) {
2569
2594
  Object.keys(obj).forEach(function (key) {
2570
2595
  if (key == "_id" && obj[key] == "$id") {
2571
- obj[key] = new mongodb_1.ObjectID();
2596
+ obj[key] = new mongodb_1.ObjectId();
2572
2597
  }
2573
2598
  else if (Array.isArray(obj[key])) {
2574
2599
  for (var i = 0; i < obj[key].length; i++) {
@@ -3924,15 +3949,16 @@ function GetDayIndex(day) {
3924
3949
  }
3925
3950
  exports.GetDayIndex = GetDayIndex;
3926
3951
  function GetUserProfile(msp_d, db, mdb, next) {
3952
+ var _a;
3927
3953
  return __awaiter(this, void 0, void 0, function () {
3928
3954
  var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, moduleList, _loop_17, i, error_4;
3929
- return __generator(this, function (_a) {
3930
- switch (_a.label) {
3955
+ return __generator(this, function (_b) {
3956
+ switch (_b.label) {
3931
3957
  case 0:
3932
- _a.trys.push([0, 10, , 11]);
3933
- return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectID(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1 } })];
3958
+ _b.trys.push([0, 10, , 11]);
3959
+ return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1 } })];
3934
3960
  case 1:
3935
- userData = _a.sent();
3961
+ userData = _b.sent();
3936
3962
  if (!userData) {
3937
3963
  return [2 /*return*/, { statusCode: 500, message: "User data not found.", data: {} }];
3938
3964
  }
@@ -3940,11 +3966,11 @@ function GetUserProfile(msp_d, db, mdb, next) {
3940
3966
  return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
3941
3967
  }
3942
3968
  userProfile_1 = undefined;
3943
- _a.label = 2;
3969
+ _b.label = 2;
3944
3970
  case 2:
3945
- _a.trys.push([2, 4, , 5]);
3971
+ _b.trys.push([2, 4, , 5]);
3946
3972
  return [4 /*yield*/, db.collection("UserProfile").aggregate([
3947
- { $match: { _id: new mongodb_1.ObjectID(msp_d.upi), IsActive: true } },
3973
+ { $match: { _id: new mongodb_1.ObjectId(msp_d.upi), IsActive: true } },
3948
3974
  {
3949
3975
  $lookup: {
3950
3976
  from: "ModuleMaster",
@@ -3959,10 +3985,10 @@ function GetUserProfile(msp_d, db, mdb, next) {
3959
3985
  { $project: { _id: 1, Name: 1, IsAdmin: 1, UserMenu: 1, Permissions: 1, ModuleList: 1, IsSystemDefine: 1 } },
3960
3986
  ]).toArray()];
3961
3987
  case 3:
3962
- userProfile_1 = _a.sent();
3988
+ userProfile_1 = _b.sent();
3963
3989
  return [3 /*break*/, 5];
3964
3990
  case 4:
3965
- error_3 = _a.sent();
3991
+ error_3 = _b.sent();
3966
3992
  console.log('No Module provided to userprofile');
3967
3993
  return [2 /*return*/, { statusCode: 500, message: "Your profile doesn't have any module access. Please contact your Administrator.", data: {} }];
3968
3994
  case 5:
@@ -3978,7 +4004,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
3978
4004
  modules_1 = [];
3979
4005
  return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
3980
4006
  case 7:
3981
- licenceDetail = _a.sent();
4007
+ licenceDetail = _b.sent();
3982
4008
  if (licenceDetail && licenceDetail.length > 0) {
3983
4009
  licenceDetail.forEach(function (licence) {
3984
4010
  modules_1 = modules_1.concat(licence.Modules);
@@ -3990,7 +4016,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
3990
4016
  if (userProfile_1[0].Permissions) {
3991
4017
  _loop_17 = function (i) {
3992
4018
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
3993
- if (userProfile_1[0].Permissions[i].Operations.includes("Control Panel")) {
4019
+ if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
3994
4020
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
3995
4021
  }
3996
4022
  };
@@ -4011,7 +4037,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4011
4037
  case 8: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4012
4038
  case 9: return [3 /*break*/, 11];
4013
4039
  case 10:
4014
- error_4 = _a.sent();
4040
+ error_4 = _b.sent();
4015
4041
  console.error("Internal Error in GetUserProfile Utility function : " + error_4);
4016
4042
  next(error_4);
4017
4043
  return [3 /*break*/, 11];
@@ -4201,7 +4227,7 @@ function ValidateSanitizeUserInput(inputFields, pageData) {
4201
4227
  if (inputFields.hasOwnProperty(key)) {
4202
4228
  val = inputFields[key];
4203
4229
  //if (val !== null && (typeof val === 'object' || mongodb.ObjectID.isValid(val))) {
4204
- if (val !== null && (typeof val === 'object' || mongodb_1.ObjectID.isValid(val))) {
4230
+ if (val !== null && (typeof val === 'object' || mongodb_1.ObjectId.isValid(val))) {
4205
4231
  inputItem[key] = val;
4206
4232
  }
4207
4233
  else {
@@ -4261,7 +4287,7 @@ function CreateBanquetingVATSettingsData(msp_d, db, sdata, next) {
4261
4287
  switch (_b.label) {
4262
4288
  case 0:
4263
4289
  _b.trys.push([0, 6, , 7]);
4264
- userID = new mongodb_1.ObjectID(msp_d.ui);
4290
+ userID = new mongodb_1.ObjectId(msp_d.ui);
4265
4291
  return [4 /*yield*/, db.collection('ObjectSchema').findOne({ Name: "BanquetingVATSettings" })];
4266
4292
  case 1:
4267
4293
  schemaData = _b.sent();
@@ -4309,7 +4335,7 @@ function CheckReportFolderAccess(report, db, msp_d, folderActiveStatus) {
4309
4335
  switch (_a.label) {
4310
4336
  case 0:
4311
4337
  shareFolderIds = [];
4312
- userID = new mongodb_1.ObjectID(msp_d.ui);
4338
+ userID = new mongodb_1.ObjectId(msp_d.ui);
4313
4339
  FolderList = [];
4314
4340
  return [4 /*yield*/, db.collection('User').findOne({ _id: userID }, { projection: { MySettings: 1 } })];
4315
4341
  case 1:
@@ -569,7 +569,7 @@ var checkForLookupAndListSchema = function (object, key, schema, restoredObject,
569
569
  return __generator(this, function (_a) {
570
570
  switch (_a.label) {
571
571
  case 0:
572
- objectid = mongodb_1.default.ObjectID;
572
+ objectid = mongodb_1.default.ObjectId;
573
573
  if (!(schema.find(function (o) { return o.Name == key && o.LookupFields && o.LookupFields.length > 0; }) && key !== 'Tag')) return [3 /*break*/, 1];
574
574
  objSchema = schema.find(function (o) { return o.Name == key; });
575
575
  schemalookupfieldsDisplayValue_1 = objSchema.LookupFields;
@@ -660,7 +660,7 @@ var checkForLookupAndListSchema = function (object, key, schema, restoredObject,
660
660
  if (!(key == 'CreatedBy' && objectid.isValid(object[key]) || key == 'ModifiedBy' && objectid.isValid(object[key]))) return [3 /*break*/, 11];
661
661
  db = global['dbConnections'][req.DBName];
662
662
  return [4 /*yield*/, db.collection('User').findOne({
663
- _id: new mongodb_1.default.ObjectID(object[key])
663
+ _id: new mongodb_1.default.ObjectId(object[key])
664
664
  })];
665
665
  case 10:
666
666
  UserInfo = _a.sent();
@@ -808,8 +808,8 @@ var mapAttendeToContactAndUser = function (attendee, key, filterdObj, db) {
808
808
  switch (_a.label) {
809
809
  case 0:
810
810
  Users = [];
811
- (attendee.Id) ? Users.push(new mongodb_1.default.ObjectID(attendee.Id)) : '';
812
- (attendee.InvitedBy) ? Users.push(new mongodb_1.default.ObjectID(attendee.InvitedBy)) : '';
811
+ (attendee.Id) ? Users.push(new mongodb_1.default.ObjectId(attendee.Id)) : '';
812
+ (attendee.InvitedBy) ? Users.push(new mongodb_1.default.ObjectId(attendee.InvitedBy)) : '';
813
813
  return [4 /*yield*/, db.collection('ViewAttendee').find({ _id: { $in: Users } }, { projection: { Name: 1 } }).toArray()];
814
814
  case 1:
815
815
  alluserInfo = _a.sent();
@@ -904,7 +904,7 @@ var mapDriveFolderIdToFolderName = function (driveObj, db) {
904
904
  driveObj['FolderName'] = driveObj.FolderId;
905
905
  delete driveObj.FolderId;
906
906
  return [3 /*break*/, 3];
907
- case 1: return [4 /*yield*/, db.collection('Drive').findOne({ _id: new mongodb_1.default.ObjectID(driveObj.FolderId) }, { projection: { FileName: 1, _id: 0 } })];
907
+ case 1: return [4 /*yield*/, db.collection('Drive').findOne({ _id: new mongodb_1.default.ObjectId(driveObj.FolderId) }, { projection: { FileName: 1, _id: 0 } })];
908
908
  case 2:
909
909
  parentFolderName = _a.sent();
910
910
  delete driveObj.FolderId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.265",
3
+ "version": "1.0.268",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -22,12 +22,12 @@
22
22
  "aws-sdk": "^2.786.0",
23
23
  "axios": "^0.21.1",
24
24
  "bson": "^4.2.0",
25
- "exceljs": "^4.2.1",
25
+ "exceljs": "^4.3.0",
26
26
  "express": "^4.17.1",
27
27
  "express-validator": "^6.9.2",
28
28
  "geoip-lite": "^1.4.2",
29
29
  "ioredis": "^4.17.3",
30
- "libphonenumber-js": "^1.9.23",
30
+ "libphonenumber-js": "^1.9.51",
31
31
  "moment": "^2.25.3",
32
32
  "moment-timezone": "^0.5.27",
33
33
  "mongo-sanitize": "^1.1.0",