@optimiser/common 1.0.266 → 1.0.269

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
@@ -38,7 +38,7 @@ declare function BuildLookupFieldProjection(field: AnyObjectInterface, group: An
38
38
  declare function FilterConditions(condition: AnyObjectInterface, match: AnyObjectInterface, fields: AnyObjectInterface): void;
39
39
  declare function GirdHeaderFilters(filters: AnyObjectInterface, fields: AnyObjectInterface): {
40
40
  $and: AnyObjectInterface[];
41
- };
41
+ } | undefined;
42
42
  declare function FieldsGridHeaderFilters(filters: AnyObjectInterface, fields: AnyObjectInterface): {
43
43
  $and: AnyObjectInterface[];
44
44
  lookupConditions: {
@@ -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
  }
@@ -2163,65 +2179,65 @@ function FilterConditions(condition, match, fields) {
2163
2179
  }
2164
2180
  exports.FilterConditions = FilterConditions;
2165
2181
  function GirdHeaderFilters(filters, fields) {
2166
- var sets = [];
2167
- var _loop_14 = function (i) {
2168
- var obj = filters[i];
2169
- var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2170
- if (field) {
2171
- var matchValue = null;
2172
- var fldName = field.UniqueID;
2173
- if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2174
- //added by nirbhay on 12 apr 2022, added dropdown and multiselect for lookup and multilookup field
2182
+ try {
2183
+ var sets = [];
2184
+ var _loop_14 = function (i) {
2185
+ var obj = filters[i];
2186
+ var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2187
+ if (field) {
2188
+ var matchValue = null;
2189
+ var fldName = field.UniqueID;
2190
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2175
2191
  if (field.Schema.SearchType == 'dropdown') {
2176
2192
  matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2177
2193
  }
2178
- else if (field.Schema.SearchType == 'multiselect') {
2179
- matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2180
- }
2181
- else {
2194
+ else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2182
2195
  fldName += '_SearchValue';
2183
2196
  matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2184
2197
  }
2185
- }
2186
- else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2187
- if (field.Schema.LookupObject) {
2188
- matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2198
+ else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2199
+ if (field.Schema.LookupObject) {
2200
+ matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2201
+ }
2202
+ else {
2203
+ matchValue = { '$in': obj.Value };
2204
+ }
2189
2205
  }
2190
- else {
2191
- matchValue = { '$in': obj.Value };
2206
+ else if (["date", "datetime"].includes(field.Schema.UIDataType))
2207
+ matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2208
+ // else if (field.Schema.UIDataType == 'time')
2209
+ // matchValue = (obj.Value == 'true');
2210
+ else if (field.Schema.UIDataType == 'checkbox') {
2211
+ if (obj.Value == 'true')
2212
+ matchValue = true;
2213
+ else
2214
+ matchValue = { $ne: true };
2192
2215
  }
2193
- }
2194
- else if (["date", "datetime"].includes(field.Schema.UIDataType))
2195
- matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2196
- // else if (field.Schema.UIDataType == 'time')
2197
- // matchValue = (obj.Value == 'true');
2198
- else if (field.Schema.UIDataType == 'checkbox') {
2199
- if (obj.Value == 'true')
2200
- matchValue = true;
2216
+ else if (field.Schema.UIDataType == 'int')
2217
+ matchValue = { '$eq': parseInt(obj.Value) };
2218
+ else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2219
+ matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2220
+ else if (field.Schema.UIDataType == 'objectid')
2221
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2222
+ else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2223
+ matchValue = new RegExp('^' + obj.Value + '$', 'i');
2224
+ else if (field.Schema.IsEqualSearch === true)
2225
+ matchValue = { '$eq': obj.Value };
2201
2226
  else
2202
- matchValue = { $ne: true };
2227
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2228
+ var fieldMatch = {};
2229
+ fieldMatch[fldName] = matchValue;
2230
+ sets.push(fieldMatch);
2203
2231
  }
2204
- else if (field.Schema.UIDataType == 'int')
2205
- matchValue = { '$eq': parseInt(obj.Value) };
2206
- else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2207
- matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2208
- else if (field.Schema.UIDataType == 'objectid')
2209
- matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2210
- else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2211
- matchValue = new RegExp('^' + obj.Value + '$', 'i');
2212
- else if (field.Schema.IsEqualSearch === true)
2213
- matchValue = { '$eq': obj.Value };
2214
- else
2215
- matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2216
- var fieldMatch = {};
2217
- fieldMatch[fldName] = matchValue;
2218
- sets.push(fieldMatch);
2232
+ };
2233
+ for (var i = 0; i < filters.length; i++) {
2234
+ _loop_14(i);
2219
2235
  }
2220
- };
2221
- for (var i = 0; i < filters.length; i++) {
2222
- _loop_14(i);
2236
+ return { '$and': sets };
2237
+ }
2238
+ catch (error) {
2239
+ console.error("Internal Error in GirdHeaderFilters : " + error);
2223
2240
  }
2224
- return { '$and': sets };
2225
2241
  }
2226
2242
  exports.GirdHeaderFilters = GirdHeaderFilters;
2227
2243
  function FieldsGridHeaderFilters(filters, fields) {
@@ -2290,7 +2306,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
2290
2306
  logObj.Action = logAction;
2291
2307
  if (objLogProp.ObjectID)
2292
2308
  if (objLogProp.ObjectID.$oid) {
2293
- logObj.ObjectID = new mongodb_1.ObjectID(objLogProp.ObjectID.$oid);
2309
+ logObj.ObjectID = new mongodb_1.ObjectId(objLogProp.ObjectID.$oid);
2294
2310
  }
2295
2311
  else {
2296
2312
  logObj.ObjectID = objLogProp.ObjectID;
@@ -2384,7 +2400,7 @@ caledar sharing settings : caledar sharing settings
2384
2400
  function GetMyTeamUsers(options, next) {
2385
2401
  var usersList = [];
2386
2402
  var db = options.db;
2387
- db.collection("Company").findOne({ '_id': new mongodb_1.ObjectID(options.CompanyID) }, function (error, result) {
2403
+ db.collection("Company").findOne({ '_id': new mongodb_1.ObjectId(options.CompanyID) }, function (error, result) {
2388
2404
  if (result) {
2389
2405
  var calendarSetting = result.Setting;
2390
2406
  if (calendarSetting.CalendarShare == "private") {
@@ -2420,8 +2436,8 @@ function GetMyTeamUsers(options, next) {
2420
2436
  pendingCalls_1 = pendingCalls_1 - 1;
2421
2437
  db.collection("User").find({
2422
2438
  $or: [
2423
- { '_id': new mongodb_1.ObjectID(options.SupervisorID) },
2424
- { 'SupervisorID': new mongodb_1.ObjectID(options.SupervisorID) }
2439
+ { '_id': new mongodb_1.ObjectId(options.SupervisorID) },
2440
+ { 'SupervisorID': new mongodb_1.ObjectId(options.SupervisorID) }
2425
2441
  ],
2426
2442
  'IsActive': true,
2427
2443
  "MySettings.IsHideFromAllUsers": { $ne: true }
@@ -2466,7 +2482,7 @@ function GetMyTeamUsers(options, next) {
2466
2482
  counter_2 = counter_2 + 1;
2467
2483
  pendingCalls_2 = pendingCalls_2 - 1;
2468
2484
  db.collection("User").find({
2469
- 'SupervisorID': new mongodb_1.ObjectID(options.SupervisorID),
2485
+ 'SupervisorID': new mongodb_1.ObjectId(options.SupervisorID),
2470
2486
  'IsActive': true,
2471
2487
  "MySettings.IsHideFromAllUsers": { $ne: true }
2472
2488
  }, { projection: { _id: 1, FirstName: 1, LastName: 1, UserStatus: 1 } }).toArray(function (error, result) {
@@ -2515,7 +2531,7 @@ function GetMyTeamUsers(options, next) {
2515
2531
  }
2516
2532
  exports.GetMyTeamUsers = GetMyTeamUsers;
2517
2533
  function ExtractChildUsersTree(userId, childUsersArray, usersTraversed, counter, db, onFetch) {
2518
- 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) {
2534
+ 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) {
2519
2535
  if (error) {
2520
2536
  //res.json({ message: err.message, status: 'failed' })
2521
2537
  }
@@ -2582,7 +2598,7 @@ exports.VerifyAWSEmailConfig = VerifyAWSEmailConfig;
2582
2598
  function GenerateId(obj) {
2583
2599
  Object.keys(obj).forEach(function (key) {
2584
2600
  if (key == "_id" && obj[key] == "$id") {
2585
- obj[key] = new mongodb_1.ObjectID();
2601
+ obj[key] = new mongodb_1.ObjectId();
2586
2602
  }
2587
2603
  else if (Array.isArray(obj[key])) {
2588
2604
  for (var i = 0; i < obj[key].length; i++) {
@@ -3938,15 +3954,16 @@ function GetDayIndex(day) {
3938
3954
  }
3939
3955
  exports.GetDayIndex = GetDayIndex;
3940
3956
  function GetUserProfile(msp_d, db, mdb, next) {
3957
+ var _a;
3941
3958
  return __awaiter(this, void 0, void 0, function () {
3942
3959
  var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, moduleList, _loop_17, i, error_4;
3943
- return __generator(this, function (_a) {
3944
- switch (_a.label) {
3960
+ return __generator(this, function (_b) {
3961
+ switch (_b.label) {
3945
3962
  case 0:
3946
- _a.trys.push([0, 10, , 11]);
3947
- return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectID(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1 } })];
3963
+ _b.trys.push([0, 10, , 11]);
3964
+ return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1 } })];
3948
3965
  case 1:
3949
- userData = _a.sent();
3966
+ userData = _b.sent();
3950
3967
  if (!userData) {
3951
3968
  return [2 /*return*/, { statusCode: 500, message: "User data not found.", data: {} }];
3952
3969
  }
@@ -3954,11 +3971,11 @@ function GetUserProfile(msp_d, db, mdb, next) {
3954
3971
  return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
3955
3972
  }
3956
3973
  userProfile_1 = undefined;
3957
- _a.label = 2;
3974
+ _b.label = 2;
3958
3975
  case 2:
3959
- _a.trys.push([2, 4, , 5]);
3976
+ _b.trys.push([2, 4, , 5]);
3960
3977
  return [4 /*yield*/, db.collection("UserProfile").aggregate([
3961
- { $match: { _id: new mongodb_1.ObjectID(msp_d.upi), IsActive: true } },
3978
+ { $match: { _id: new mongodb_1.ObjectId(msp_d.upi), IsActive: true } },
3962
3979
  {
3963
3980
  $lookup: {
3964
3981
  from: "ModuleMaster",
@@ -3973,10 +3990,10 @@ function GetUserProfile(msp_d, db, mdb, next) {
3973
3990
  { $project: { _id: 1, Name: 1, IsAdmin: 1, UserMenu: 1, Permissions: 1, ModuleList: 1, IsSystemDefine: 1 } },
3974
3991
  ]).toArray()];
3975
3992
  case 3:
3976
- userProfile_1 = _a.sent();
3993
+ userProfile_1 = _b.sent();
3977
3994
  return [3 /*break*/, 5];
3978
3995
  case 4:
3979
- error_3 = _a.sent();
3996
+ error_3 = _b.sent();
3980
3997
  console.log('No Module provided to userprofile');
3981
3998
  return [2 /*return*/, { statusCode: 500, message: "Your profile doesn't have any module access. Please contact your Administrator.", data: {} }];
3982
3999
  case 5:
@@ -3992,7 +4009,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
3992
4009
  modules_1 = [];
3993
4010
  return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
3994
4011
  case 7:
3995
- licenceDetail = _a.sent();
4012
+ licenceDetail = _b.sent();
3996
4013
  if (licenceDetail && licenceDetail.length > 0) {
3997
4014
  licenceDetail.forEach(function (licence) {
3998
4015
  modules_1 = modules_1.concat(licence.Modules);
@@ -4004,7 +4021,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4004
4021
  if (userProfile_1[0].Permissions) {
4005
4022
  _loop_17 = function (i) {
4006
4023
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
4007
- if (userProfile_1[0].Permissions[i].Operations.includes("Control Panel")) {
4024
+ if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
4008
4025
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
4009
4026
  }
4010
4027
  };
@@ -4025,7 +4042,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4025
4042
  case 8: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4026
4043
  case 9: return [3 /*break*/, 11];
4027
4044
  case 10:
4028
- error_4 = _a.sent();
4045
+ error_4 = _b.sent();
4029
4046
  console.error("Internal Error in GetUserProfile Utility function : " + error_4);
4030
4047
  next(error_4);
4031
4048
  return [3 /*break*/, 11];
@@ -4215,7 +4232,7 @@ function ValidateSanitizeUserInput(inputFields, pageData) {
4215
4232
  if (inputFields.hasOwnProperty(key)) {
4216
4233
  val = inputFields[key];
4217
4234
  //if (val !== null && (typeof val === 'object' || mongodb.ObjectID.isValid(val))) {
4218
- if (val !== null && (typeof val === 'object' || mongodb_1.ObjectID.isValid(val))) {
4235
+ if (val !== null && (typeof val === 'object' || mongodb_1.ObjectId.isValid(val))) {
4219
4236
  inputItem[key] = val;
4220
4237
  }
4221
4238
  else {
@@ -4275,7 +4292,7 @@ function CreateBanquetingVATSettingsData(msp_d, db, sdata, next) {
4275
4292
  switch (_b.label) {
4276
4293
  case 0:
4277
4294
  _b.trys.push([0, 6, , 7]);
4278
- userID = new mongodb_1.ObjectID(msp_d.ui);
4295
+ userID = new mongodb_1.ObjectId(msp_d.ui);
4279
4296
  return [4 /*yield*/, db.collection('ObjectSchema').findOne({ Name: "BanquetingVATSettings" })];
4280
4297
  case 1:
4281
4298
  schemaData = _b.sent();
@@ -4323,7 +4340,7 @@ function CheckReportFolderAccess(report, db, msp_d, folderActiveStatus) {
4323
4340
  switch (_a.label) {
4324
4341
  case 0:
4325
4342
  shareFolderIds = [];
4326
- userID = new mongodb_1.ObjectID(msp_d.ui);
4343
+ userID = new mongodb_1.ObjectId(msp_d.ui);
4327
4344
  FolderList = [];
4328
4345
  return [4 /*yield*/, db.collection('User').findOne({ _id: userID }, { projection: { MySettings: 1 } })];
4329
4346
  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.266",
3
+ "version": "1.0.269",
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",