@optimiser/common 1.0.338 → 1.0.340

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.
@@ -29,5 +29,7 @@ declare const _default: {
29
29
  SUCCESS: string;
30
30
  FAIL: string;
31
31
  };
32
+ QrPendingAlias: string;
33
+ QrPendingFields: string;
32
34
  };
33
35
  export default _default;
package/dist/constants.js CHANGED
@@ -30,5 +30,7 @@ exports.default = {
30
30
  IN_PROCESS: "2",
31
31
  SUCCESS: "3",
32
32
  FAIL: "4"
33
- }
33
+ },
34
+ QrPendingAlias: "_QRPENDING",
35
+ QrPendingFields: "qrcode"
34
36
  };
@@ -3,7 +3,7 @@ import { NextFunction, Response } from "express";
3
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
- import { AnyObjectInterface, callBackInterface } from "../modals/utility.modal";
6
+ import { AnyObjectInterface, callBackInterface, GetEncryptedURLOptions } from "../modals/utility.modal";
7
7
  import { OPT_Request } from "../modals/connection.modal";
8
8
  import { Redis } from "ioredis";
9
9
  import 'moment-timezone';
@@ -272,4 +272,13 @@ declare function HasFiscalOperator(filter: any): boolean;
272
272
  * @return object[]
273
273
  */
274
274
  declare function GetBulkUpdateURLData(eventIds: ObjectId[], companyId: string, secretKey: string): any[];
275
- export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, UpdateRecentViewFields, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, GetObjectByString, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, FieldsGridHeaderFilters, AddLog, CheckFilterFieldsProjection, VerifyEmailPassword, GetMyTeamUsers, ExtractChildUsersTree, GetMaxKeyValueListSchema, VerifyAWSEmailConfig, GenerateId, SyncUserDetailsWithMasterDB, SignoutUserFromAllDevices, SignoutUsersWithPromise, SignoutMultipleUsersFromAllDevices, UserLicenseConsumeCalculate, sendMailWithUserAccount, GetEmailClientConfigs, GetCompanyEncryptionKey, ExecuteDynamicDMLQuery, ExecuteDynamicDQLQuery, GetUserProfilePermissions, MakeUserPasswordInvalid, ConvertJsonToXLXS, SendResetPasswordMail, SendMailToSupport, MailTemplateStructure, SendMailToCustomer, parseMSPCookie, GetIPDetailsFromReq, isEmptyObj, SyncListSchemaFieldInOtherCollection, UpdateTagCountAfterDelete, SyncTagCountAfterUpdate, ReactivateFieldInOtherCollection, SyncUserLicenceConsumedCount, BroadCastEventToAllCompanyUsers, CheckDataPermission, SyncCompanyLicenceInMasterCompanyAfterAdd, NextServiceDateForDashboard, CheckDateNotInPast, GetWeekDayByDayAndOccurance, GetInterValFromOccurance, GetWeekDayInfoInMonth, GetDayIndex, RemoveFieldsFromFilters, GetUserProfile, CheckPageAuthentication, ErrorHandlerForServices, CheckCaptcha, IsStringValue, ValidateSanitizeUserInput, ValidateUserInput, CheckConditionalField, CheckExpressionOnDateField, AddDaysToDate, CreateBanquetingVATSettingsData, CheckReportFolderAccess, GetMailFromString, InvitationMailReplyContent, HasFiscalOperator, GetBulkUpdateURLData };
275
+ /**
276
+ * TODO: Return Encrypted URL
277
+ *
278
+ * @param recordIds - ObjectId[]
279
+ * @param companyId - string
280
+ * @param secretKey - string
281
+ * @return object
282
+ */
283
+ declare function GetEncryptedURL(options: GetEncryptedURLOptions): any[];
284
+ export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, UpdateRecentViewFields, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, GetObjectByString, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, FieldsGridHeaderFilters, AddLog, CheckFilterFieldsProjection, VerifyEmailPassword, GetMyTeamUsers, ExtractChildUsersTree, GetMaxKeyValueListSchema, VerifyAWSEmailConfig, GenerateId, SyncUserDetailsWithMasterDB, SignoutUserFromAllDevices, SignoutUsersWithPromise, SignoutMultipleUsersFromAllDevices, UserLicenseConsumeCalculate, sendMailWithUserAccount, GetEmailClientConfigs, GetCompanyEncryptionKey, ExecuteDynamicDMLQuery, ExecuteDynamicDQLQuery, GetUserProfilePermissions, MakeUserPasswordInvalid, ConvertJsonToXLXS, SendResetPasswordMail, SendMailToSupport, MailTemplateStructure, SendMailToCustomer, parseMSPCookie, GetIPDetailsFromReq, isEmptyObj, SyncListSchemaFieldInOtherCollection, UpdateTagCountAfterDelete, SyncTagCountAfterUpdate, ReactivateFieldInOtherCollection, SyncUserLicenceConsumedCount, BroadCastEventToAllCompanyUsers, CheckDataPermission, SyncCompanyLicenceInMasterCompanyAfterAdd, NextServiceDateForDashboard, CheckDateNotInPast, GetWeekDayByDayAndOccurance, GetInterValFromOccurance, GetWeekDayInfoInMonth, GetDayIndex, RemoveFieldsFromFilters, GetUserProfile, CheckPageAuthentication, ErrorHandlerForServices, CheckCaptcha, IsStringValue, ValidateSanitizeUserInput, ValidateUserInput, CheckConditionalField, CheckExpressionOnDateField, AddDaysToDate, CreateBanquetingVATSettingsData, CheckReportFolderAccess, GetMailFromString, InvitationMailReplyContent, HasFiscalOperator, GetBulkUpdateURLData, GetEncryptedURL };
@@ -80,7 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
80
80
  return (mod && mod.__esModule) ? mod : { "default": mod };
81
81
  };
82
82
  Object.defineProperty(exports, "__esModule", { value: true });
83
- exports.GetBulkUpdateURLData = exports.HasFiscalOperator = exports.InvitationMailReplyContent = exports.GetMailFromString = exports.CheckReportFolderAccess = exports.CreateBanquetingVATSettingsData = exports.AddDaysToDate = exports.CheckExpressionOnDateField = exports.CheckConditionalField = exports.ValidateUserInput = exports.ValidateSanitizeUserInput = exports.IsStringValue = exports.CheckCaptcha = exports.ErrorHandlerForServices = exports.CheckPageAuthentication = exports.GetUserProfile = exports.RemoveFieldsFromFilters = exports.GetDayIndex = exports.GetWeekDayInfoInMonth = exports.GetInterValFromOccurance = exports.GetWeekDayByDayAndOccurance = exports.CheckDateNotInPast = exports.NextServiceDateForDashboard = exports.SyncCompanyLicenceInMasterCompanyAfterAdd = exports.CheckDataPermission = exports.BroadCastEventToAllCompanyUsers = exports.SyncUserLicenceConsumedCount = exports.ReactivateFieldInOtherCollection = exports.SyncTagCountAfterUpdate = exports.UpdateTagCountAfterDelete = exports.SyncListSchemaFieldInOtherCollection = exports.isEmptyObj = exports.GetIPDetailsFromReq = exports.parseMSPCookie = exports.SendMailToCustomer = exports.MailTemplateStructure = exports.SendMailToSupport = exports.SendResetPasswordMail = exports.ConvertJsonToXLXS = exports.MakeUserPasswordInvalid = exports.GetUserProfilePermissions = exports.ExecuteDynamicDQLQuery = exports.ExecuteDynamicDMLQuery = exports.GetCompanyEncryptionKey = exports.GetEmailClientConfigs = exports.sendMailWithUserAccount = exports.UserLicenseConsumeCalculate = exports.SignoutMultipleUsersFromAllDevices = exports.SignoutUsersWithPromise = exports.SignoutUserFromAllDevices = exports.SyncUserDetailsWithMasterDB = exports.GenerateId = exports.VerifyAWSEmailConfig = exports.GetMaxKeyValueListSchema = exports.ExtractChildUsersTree = exports.GetMyTeamUsers = exports.VerifyEmailPassword = exports.CheckFilterFieldsProjection = exports.AddLog = exports.FieldsGridHeaderFilters = exports.GirdHeaderFilters = exports.FilterConditions = exports.BuildLookupFieldProjection = exports.BuildFieldProjection = exports.BuildGridFieldProjection = exports.CheckDataBeforeUpdate = exports.CheckDataBeforeAdd = exports.BuildLookupDataField = exports.GetObjectByString = exports.SyncUserInOtherCollection = exports.SyncFieldInOtherCollection = exports.SyncFieldInSameCollectionByObjectIDWithPromise = exports.SyncFieldInSameCollectionByObjectID = exports.SyncFieldInSameCollection = exports.DeleteFieldInOtherCollection = exports.SyncParentObjectData = exports.SyncChildObjectData = exports.UpdateRecentViewFields = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
83
+ exports.GetEncryptedURL = exports.GetBulkUpdateURLData = exports.HasFiscalOperator = exports.InvitationMailReplyContent = exports.GetMailFromString = exports.CheckReportFolderAccess = exports.CreateBanquetingVATSettingsData = exports.AddDaysToDate = exports.CheckExpressionOnDateField = exports.CheckConditionalField = exports.ValidateUserInput = exports.ValidateSanitizeUserInput = exports.IsStringValue = exports.CheckCaptcha = exports.ErrorHandlerForServices = exports.CheckPageAuthentication = exports.GetUserProfile = exports.RemoveFieldsFromFilters = exports.GetDayIndex = exports.GetWeekDayInfoInMonth = exports.GetInterValFromOccurance = exports.GetWeekDayByDayAndOccurance = exports.CheckDateNotInPast = exports.NextServiceDateForDashboard = exports.SyncCompanyLicenceInMasterCompanyAfterAdd = exports.CheckDataPermission = exports.BroadCastEventToAllCompanyUsers = exports.SyncUserLicenceConsumedCount = exports.ReactivateFieldInOtherCollection = exports.SyncTagCountAfterUpdate = exports.UpdateTagCountAfterDelete = exports.SyncListSchemaFieldInOtherCollection = exports.isEmptyObj = exports.GetIPDetailsFromReq = exports.parseMSPCookie = exports.SendMailToCustomer = exports.MailTemplateStructure = exports.SendMailToSupport = exports.SendResetPasswordMail = exports.ConvertJsonToXLXS = exports.MakeUserPasswordInvalid = exports.GetUserProfilePermissions = exports.ExecuteDynamicDQLQuery = exports.ExecuteDynamicDMLQuery = exports.GetCompanyEncryptionKey = exports.GetEmailClientConfigs = exports.sendMailWithUserAccount = exports.UserLicenseConsumeCalculate = exports.SignoutMultipleUsersFromAllDevices = exports.SignoutUsersWithPromise = exports.SignoutUserFromAllDevices = exports.SyncUserDetailsWithMasterDB = exports.GenerateId = exports.VerifyAWSEmailConfig = exports.GetMaxKeyValueListSchema = exports.ExtractChildUsersTree = exports.GetMyTeamUsers = exports.VerifyEmailPassword = exports.CheckFilterFieldsProjection = exports.AddLog = exports.FieldsGridHeaderFilters = exports.GirdHeaderFilters = exports.FilterConditions = exports.BuildLookupFieldProjection = exports.BuildFieldProjection = exports.BuildGridFieldProjection = exports.CheckDataBeforeUpdate = exports.CheckDataBeforeAdd = exports.BuildLookupDataField = exports.GetObjectByString = exports.SyncUserInOtherCollection = exports.SyncFieldInOtherCollection = exports.SyncFieldInSameCollectionByObjectIDWithPromise = exports.SyncFieldInSameCollectionByObjectID = exports.SyncFieldInSameCollection = exports.DeleteFieldInOtherCollection = exports.SyncParentObjectData = exports.SyncChildObjectData = exports.UpdateRecentViewFields = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
84
84
  var moment_1 = __importDefault(require("moment"));
85
85
  var nodemailer_1 = __importDefault(require("nodemailer"));
86
86
  var mongodb_1 = require("mongodb");
@@ -1503,275 +1503,303 @@ function GetObjectByString(o, s) {
1503
1503
  exports.GetObjectByString = GetObjectByString;
1504
1504
  //Build _LookupDataField before save
1505
1505
  function BuildLookupDataField(fieldSchema, updateObj, db) {
1506
- return new Promise(function (resolve, reject) {
1507
- /**
1508
- * Added By Suraj on 06-Apr-2022,
1509
- * helper function for all below cases to print error log on console.
1510
- * @param fieldValue value of a field
1511
- * @param err error occurred during processing
1512
- */
1513
- var errorHandler = function (fieldValue, err) {
1514
- var fieldValueType = (Array.isArray(fieldValue) ? 'array' : '');
1515
- if (!fieldValueType) {
1516
- fieldValueType = typeof (fieldValue);
1517
- }
1518
- var errorInfo = "##### COMMON MOUDLE ERROR INFO ####";
1519
- errorInfo += "\n Function Name : BuildLookupDataField";
1520
- errorInfo += "\n Error Info: Error while building Lookup Data for Company - " + (db.databaseName) + ", ObjectName - " + (fieldSchema.LookupObject || '') + ", FieldName - " + (fieldSchema.Name || '') + " for value - " + fieldValue + " and data type of values is " + (fieldValueType || '') + " ";
1521
- console.log("Error Information : ", errorInfo);
1522
- console.log("Error Full Object : ", err);
1523
- };
1524
- if (fieldSchema.UIDataType && constants_1.default.LookupTypeFields.includes(fieldSchema.UIDataType)) {
1525
- var fldName = fieldSchema.Name;
1526
- var fldValue_1 = updateObj[fldName];
1527
- var alias_1 = fldName + constants_1.default.LookupAlias;
1528
- var searchAlias_1 = fldName + constants_1.default.SearchValueAlias;
1529
- var fldLookupData_1 = null;
1530
- if (fldValue_1) {
1531
- var aggregateArry = [];
1532
- var project = { '_id': 1, IsActive: 1 };
1533
- if (fieldSchema.ExtraLookupObjects) {
1534
- for (var i = 0; i < fieldSchema.ExtraLookupObjects.length; i++) {
1535
- var obj = fieldSchema.ExtraLookupObjects[i];
1536
- var lookupObj = {};
1537
- lookupObj["from"] = obj.from;
1538
- lookupObj["let"] = { 'fld': '$' + obj.localField };
1539
- lookupObj["pipeline"] = [{ "$match": { "$expr": { "$eq": ["$_id", "$$fld"] } } }];
1540
- lookupObj["as"] = obj.as;
1541
- aggregateArry.push({ $lookup: lookupObj });
1542
- aggregateArry.push({ $unwind: { path: '$' + obj.as, preserveNullAndEmptyArrays: true } });
1543
- project[obj.as + '._id'] = 1;
1544
- project[obj.as + '.IsActive'] = 1;
1506
+ var _a, _b;
1507
+ return __awaiter(this, void 0, void 0, function () {
1508
+ var fldValue, fldName, alias, searchAlias, fldLookupData, aggregateArry, project, i, obj, lookupObj, i, i, data, _c, result, _loop_10, j, i, unionDetail, unionPipeline, unionObj, result, i, lookupRecord, j, result, j, result, i, lookupRecord, j, result, i, lookupRecord, alias, error_2, fieldValueType, errMsg;
1509
+ return __generator(this, function (_d) {
1510
+ switch (_d.label) {
1511
+ case 0:
1512
+ fldValue = null;
1513
+ _d.label = 1;
1514
+ case 1:
1515
+ _d.trys.push([1, 25, , 26]);
1516
+ if (!fieldSchema.UIDataType) return [3 /*break*/, 24];
1517
+ fldName = fieldSchema.Name;
1518
+ fldValue = updateObj[fldName];
1519
+ if (!constants_1.default.LookupTypeFields.includes(fieldSchema.UIDataType)) return [3 /*break*/, 23];
1520
+ alias = fldName + constants_1.default.LookupAlias;
1521
+ searchAlias = fldName + constants_1.default.SearchValueAlias;
1522
+ fldLookupData = null;
1523
+ if (!fldValue) return [3 /*break*/, 21];
1524
+ aggregateArry = [];
1525
+ project = { '_id': 1, IsActive: 1 };
1526
+ if (fieldSchema.ExtraLookupObjects) {
1527
+ for (i = 0; i < fieldSchema.ExtraLookupObjects.length; i++) {
1528
+ obj = fieldSchema.ExtraLookupObjects[i];
1529
+ lookupObj = {};
1530
+ lookupObj["from"] = obj.from;
1531
+ lookupObj["let"] = { 'fld': '$' + obj.localField };
1532
+ lookupObj["pipeline"] = [{ "$match": { "$expr": { "$eq": ["$_id", "$$fld"] } } }];
1533
+ lookupObj["as"] = obj.as;
1534
+ aggregateArry.push({ $lookup: lookupObj });
1535
+ aggregateArry.push({ $unwind: { path: '$' + obj.as, preserveNullAndEmptyArrays: true } });
1536
+ project[obj.as + '._id'] = 1;
1537
+ project[obj.as + '.IsActive'] = 1;
1538
+ }
1545
1539
  }
1546
- }
1547
- if (fieldSchema.LookupFields != undefined) {
1548
- for (var i = 0; i < fieldSchema.LookupFields.length; i++) {
1549
- project[fieldSchema.LookupFields[i]] = 1;
1540
+ if (fieldSchema.LookupFields != undefined) {
1541
+ for (i = 0; i < fieldSchema.LookupFields.length; i++) {
1542
+ project[fieldSchema.LookupFields[i]] = 1;
1543
+ }
1544
+ ;
1550
1545
  }
1551
- ;
1552
- }
1553
- if (fieldSchema.ExtraLookupFields != undefined) {
1554
- for (var i = 0; i < fieldSchema.ExtraLookupFields.length; i++) {
1555
- project[fieldSchema.ExtraLookupFields[i]] = 1;
1546
+ if (fieldSchema.ExtraLookupFields != undefined) {
1547
+ for (i = 0; i < fieldSchema.ExtraLookupFields.length; i++) {
1548
+ project[fieldSchema.ExtraLookupFields[i]] = 1;
1549
+ }
1550
+ ;
1556
1551
  }
1557
- ;
1558
- }
1559
- switch (fieldSchema.UIDataType) {
1560
- case "lookup":
1561
- aggregateArry.push({ $match: { '_id': fldValue_1 } });
1562
- aggregateArry.push({ $project: project });
1563
- db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err, data) {
1564
- if (err) {
1565
- errorHandler(fldValue_1, err);
1566
- }
1567
- else if (data && data.length > 0) {
1568
- fldLookupData_1 = data[0];
1569
- updateObj[alias_1] = fldLookupData_1;
1570
- //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1571
- var result = '';
1572
- if (fieldSchema.LookupFields != undefined) {
1573
- var _loop_10 = function (j) {
1574
- if (fieldSchema.ExcludeLookupFieldsOnSearch && fieldSchema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == fieldSchema.LookupFields[j]; }).length != 0) {
1575
- return "continue";
1576
- }
1577
- if (GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]) != undefined)
1578
- result += GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]).toString() + ' ';
1579
- };
1580
- for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1581
- _loop_10(j);
1582
- }
1583
- }
1584
- updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1585
- //** Ends here */
1586
- }
1587
- resolve();
1588
- });
1589
- break;
1590
- case "multilookup":
1591
- aggregateArry.push({ $match: { '_id': { $in: fldValue_1 } } });
1592
- aggregateArry.push({ $project: project });
1593
- if (fieldSchema.UnionWith && fieldSchema.UnionWith.length > 0) {
1594
- for (var i = 0; i < fieldSchema.UnionWith.length; i++) {
1595
- var unionDetail = fieldSchema.UnionWith[i];
1596
- if (unionDetail) {
1597
- var unionPipeline = [];
1598
- unionPipeline.push({
1599
- $match: { '_id': { $in: fldValue_1 } }
1600
- });
1601
- unionPipeline.push({ $project: project });
1602
- var unionObj = { coll: unionDetail.LookupObject, pipeline: unionPipeline };
1603
- aggregateArry.push({ $unionWith: unionObj });
1552
+ data = null;
1553
+ _c = fieldSchema.UIDataType;
1554
+ switch (_c) {
1555
+ case "lookup": return [3 /*break*/, 2];
1556
+ case "multilookup": return [3 /*break*/, 4];
1557
+ case "dropdown": return [3 /*break*/, 6];
1558
+ case "multiselect": return [3 /*break*/, 11];
1559
+ case "file": return [3 /*break*/, 16];
1560
+ case "image": return [3 /*break*/, 16];
1561
+ }
1562
+ return [3 /*break*/, 19];
1563
+ case 2:
1564
+ aggregateArry.push({ $match: { '_id': fldValue } });
1565
+ aggregateArry.push({ $project: project });
1566
+ return [4 /*yield*/, db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray()];
1567
+ case 3:
1568
+ // db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1569
+ data = _d.sent();
1570
+ // if (err) {
1571
+ // errorHandler(fldValue, err);
1572
+ // }
1573
+ // else
1574
+ if (data && data.length > 0) {
1575
+ fldLookupData = data[0];
1576
+ updateObj[alias] = fldLookupData;
1577
+ result = '';
1578
+ if (fieldSchema.LookupFields != undefined) {
1579
+ _loop_10 = function (j) {
1580
+ if (fieldSchema.ExcludeLookupFieldsOnSearch && fieldSchema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == fieldSchema.LookupFields[j]; }).length != 0) {
1581
+ return "continue";
1604
1582
  }
1583
+ if (GetObjectByString(fldLookupData, fieldSchema.LookupFields[j]) != undefined)
1584
+ result += GetObjectByString(fldLookupData, fieldSchema.LookupFields[j]).toString() + ' ';
1585
+ };
1586
+ for (j = 0; j < fieldSchema.LookupFields.length; j++) {
1587
+ _loop_10(j);
1605
1588
  }
1606
1589
  }
1607
- db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err, data) {
1608
- if (err) {
1609
- // throw new Error(err.toString());
1610
- errorHandler(fldValue_1, err);
1590
+ updateObj[searchAlias] = result === null || result === void 0 ? void 0 : result.trim();
1591
+ //** Ends here */
1592
+ }
1593
+ // resolve()
1594
+ // });
1595
+ return [3 /*break*/, 20];
1596
+ case 4:
1597
+ aggregateArry.push({ $match: { '_id': { $in: fldValue } } });
1598
+ aggregateArry.push({ $project: project });
1599
+ if (fieldSchema.UnionWith && fieldSchema.UnionWith.length > 0) {
1600
+ for (i = 0; i < fieldSchema.UnionWith.length; i++) {
1601
+ unionDetail = fieldSchema.UnionWith[i];
1602
+ if (unionDetail) {
1603
+ unionPipeline = [];
1604
+ unionPipeline.push({
1605
+ $match: { '_id': { $in: fldValue } }
1606
+ });
1607
+ unionPipeline.push({ $project: project });
1608
+ unionObj = { coll: unionDetail.LookupObject, pipeline: unionPipeline };
1609
+ aggregateArry.push({ $unionWith: unionObj });
1611
1610
  }
1612
- else if (data && data.length > 0) {
1613
- fldLookupData_1 = data;
1614
- updateObj[alias_1] = fldLookupData_1;
1615
- //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1616
- var result = '';
1617
- for (var i = 0; i < data.length; i++) {
1618
- var lookupRecord = data[i];
1619
- if (fieldSchema.LookupFields != undefined) {
1620
- for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1621
- if (GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]) != undefined)
1622
- result += GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]).toString() + ' ';
1623
- }
1624
- }
1611
+ }
1612
+ }
1613
+ return [4 /*yield*/, db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray()];
1614
+ case 5:
1615
+ // db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1616
+ data = _d.sent();
1617
+ // if (err) {
1618
+ // // throw new Error(err.toString());
1619
+ // errorHandler(fldValue, err);
1620
+ // } else
1621
+ if (data && data.length > 0) {
1622
+ fldLookupData = data;
1623
+ updateObj[alias] = fldLookupData;
1624
+ result = '';
1625
+ for (i = 0; i < data.length; i++) {
1626
+ lookupRecord = data[i];
1627
+ if (fieldSchema.LookupFields != undefined) {
1628
+ for (j = 0; j < fieldSchema.LookupFields.length; j++) {
1629
+ if (GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]) != undefined)
1630
+ result += GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]).toString() + ' ';
1625
1631
  }
1626
- updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1627
- //** Ends here */
1628
1632
  }
1629
- resolve();
1630
- });
1631
- break;
1632
- case "dropdown":
1633
- if (fieldSchema.LookupObject) {
1634
- aggregateArry.push({ $match: { _id: fldValue_1 } });
1635
- aggregateArry.push({ $project: project });
1636
- db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err, data) {
1637
- if (err) {
1638
- errorHandler(fldValue_1, err);
1639
- }
1640
- else if (data && data.length > 0) {
1641
- fldLookupData_1 = data[0];
1642
- updateObj[alias_1] = fldLookupData_1;
1643
- //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1644
- var result = '';
1645
- if (fieldSchema.LookupFields != undefined) {
1646
- for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1647
- if (GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]) != undefined)
1648
- result += GetObjectByString(fldLookupData_1, fieldSchema.LookupFields[j]).toString() + ' ';
1649
- }
1650
- }
1651
- updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1652
- //** Ends here */
1653
- }
1654
- resolve();
1655
- });
1656
1633
  }
1657
- else {
1658
- if (fieldSchema.IsMultipleListSchemaName) {
1659
- aggregateArry.push({ $match: { 'Name': { $in: fieldSchema.ListSchemaName } } });
1660
- }
1661
- else {
1662
- aggregateArry.push({ $match: { 'Name': fieldSchema.ListSchemaName } });
1634
+ updateObj[searchAlias] = result === null || result === void 0 ? void 0 : result.trim();
1635
+ //** Ends here */
1636
+ }
1637
+ // resolve()
1638
+ // });
1639
+ return [3 /*break*/, 20];
1640
+ case 6:
1641
+ if (!fieldSchema.LookupObject) return [3 /*break*/, 8];
1642
+ aggregateArry.push({ $match: { _id: fldValue } });
1643
+ aggregateArry.push({ $project: project });
1644
+ return [4 /*yield*/, db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray()];
1645
+ case 7:
1646
+ // db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1647
+ data = _d.sent();
1648
+ // if (err) {
1649
+ // errorHandler(fldValue, err);
1650
+ // } else
1651
+ if (data && data.length > 0) {
1652
+ fldLookupData = data[0];
1653
+ updateObj[alias] = fldLookupData;
1654
+ result = '';
1655
+ if (fieldSchema.LookupFields != undefined) {
1656
+ for (j = 0; j < fieldSchema.LookupFields.length; j++) {
1657
+ if (GetObjectByString(fldLookupData, fieldSchema.LookupFields[j]) != undefined)
1658
+ result += GetObjectByString(fldLookupData, fieldSchema.LookupFields[j]).toString() + ' ';
1663
1659
  }
1664
- aggregateArry.push({ $unwind: { path: '$Data' } });
1665
- aggregateArry.push({ $project: { _id: 0, Key: '$Data.Key', Value: '$Data.Value', IsActive: '$Data.IsActive' } });
1666
- aggregateArry.push({ $match: { 'Key': fldValue_1 } });
1667
- db.collection('ListSchema').aggregate(aggregateArry).toArray(function (err, data) {
1668
- var _a;
1669
- if (err) {
1670
- errorHandler(fldValue_1, err);
1671
- }
1672
- else if (data && data.length > 0) {
1673
- fldLookupData_1 = data[0];
1674
- updateObj[alias_1] = fldLookupData_1;
1675
- //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1676
- updateObj[searchAlias_1] = (_a = fldLookupData_1.Value) === null || _a === void 0 ? void 0 : _a.trim();
1677
- //** Ends here */
1678
- }
1679
- resolve();
1680
- });
1681
1660
  }
1682
- break;
1683
- case "multiselect":
1684
- if (fieldSchema.LookupObject) {
1685
- aggregateArry.push({ $match: { '_id': { $in: fldValue_1 } } });
1686
- aggregateArry.push({ $project: project });
1687
- db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err, data) {
1688
- if (err) {
1689
- errorHandler(fldValue_1, err);
1690
- }
1691
- else if (data && data.length > 0) {
1692
- fldLookupData_1 = data;
1693
- updateObj[alias_1] = fldLookupData_1;
1694
- //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1695
- var result = '';
1696
- for (var i = 0; i < data.length; i++) {
1697
- var lookupRecord = data[i];
1698
- if (fieldSchema.LookupFields != undefined) {
1699
- for (var j = 0; j < fieldSchema.LookupFields.length; j++) {
1700
- if (GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]) != undefined)
1701
- result += GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]).toString() + ' ';
1702
- }
1703
- }
1704
- }
1705
- updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1706
- //** Ends here */
1707
- }
1708
- resolve();
1709
- });
1710
- }
1711
- else {
1712
- aggregateArry.push({ $match: { 'Name': fieldSchema.ListSchemaName } });
1713
- aggregateArry.push({ $unwind: { path: '$Data' } });
1714
- aggregateArry.push({ $project: { _id: 0, Key: '$Data.Key', Value: '$Data.Value', IsActive: '$Data.IsActive' } });
1715
- aggregateArry.push({ $match: { 'Key': { $in: fldValue_1 } } });
1716
- db.collection('ListSchema').aggregate(aggregateArry).toArray(function (err, data) {
1717
- var _a;
1718
- if (err) {
1719
- errorHandler(fldValue_1, err);
1720
- }
1721
- else if (data && data.length > 0) {
1722
- fldLookupData_1 = data;
1723
- updateObj[alias_1] = fldLookupData_1;
1724
- //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1725
- var result = '';
1726
- for (var i = 0; i < data.length; i++) {
1727
- var lookupRecord = data[i];
1728
- result += ((_a = lookupRecord.Value) === null || _a === void 0 ? void 0 : _a.toString()) + ' ';
1729
- }
1730
- updateObj[searchAlias_1] = result === null || result === void 0 ? void 0 : result.trim();
1731
- //** Ends here */
1661
+ updateObj[searchAlias] = result === null || result === void 0 ? void 0 : result.trim();
1662
+ //** Ends here */
1663
+ }
1664
+ return [3 /*break*/, 10];
1665
+ case 8:
1666
+ if (fieldSchema.IsMultipleListSchemaName) {
1667
+ aggregateArry.push({ $match: { 'Name': { $in: fieldSchema.ListSchemaName } } });
1668
+ }
1669
+ else {
1670
+ aggregateArry.push({ $match: { 'Name': fieldSchema.ListSchemaName } });
1671
+ }
1672
+ aggregateArry.push({ $unwind: { path: '$Data' } });
1673
+ aggregateArry.push({ $project: { _id: 0, Key: '$Data.Key', Value: '$Data.Value', IsActive: '$Data.IsActive' } });
1674
+ aggregateArry.push({ $match: { 'Key': fldValue } });
1675
+ return [4 /*yield*/, db.collection('ListSchema').aggregate(aggregateArry).toArray()];
1676
+ case 9:
1677
+ // db.collection('ListSchema').aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1678
+ data = _d.sent();
1679
+ // if (err) {
1680
+ // errorHandler(fldValue, err);
1681
+ // }
1682
+ // else
1683
+ if (data && data.length > 0) {
1684
+ fldLookupData = data[0];
1685
+ updateObj[alias] = fldLookupData;
1686
+ //** Below code is added by Shahzaib on 05/09/2022 to create SearchValue */
1687
+ updateObj[searchAlias] = (_a = fldLookupData.Value) === null || _a === void 0 ? void 0 : _a.trim();
1688
+ //** Ends here */
1689
+ }
1690
+ _d.label = 10;
1691
+ case 10: return [3 /*break*/, 20];
1692
+ case 11:
1693
+ if (!fieldSchema.LookupObject) return [3 /*break*/, 13];
1694
+ aggregateArry.push({ $match: { '_id': { $in: fldValue } } });
1695
+ aggregateArry.push({ $project: project });
1696
+ return [4 /*yield*/, db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray()];
1697
+ case 12:
1698
+ // db.collection(fieldSchema.LookupObject).aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1699
+ data = _d.sent();
1700
+ // if (err) {
1701
+ // errorHandler(fldValue, err);
1702
+ // }
1703
+ // else
1704
+ if (data && data.length > 0) {
1705
+ fldLookupData = data;
1706
+ updateObj[alias] = fldLookupData;
1707
+ result = '';
1708
+ for (i = 0; i < data.length; i++) {
1709
+ lookupRecord = data[i];
1710
+ if (fieldSchema.LookupFields != undefined) {
1711
+ for (j = 0; j < fieldSchema.LookupFields.length; j++) {
1712
+ if (GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]) != undefined)
1713
+ result += GetObjectByString(lookupRecord, fieldSchema.LookupFields[j]).toString() + ' ';
1732
1714
  }
1733
- resolve();
1734
- });
1715
+ }
1735
1716
  }
1736
- break;
1737
- case "file":
1738
- case "image":
1739
- if (!fieldSchema.IsMultiple) {
1740
- aggregateArry.push({ $match: { '_id': fldValue_1 } });
1741
- project['FileName'] = 1;
1742
- aggregateArry.push({ $project: project });
1743
- db.collection('Drive').aggregate(aggregateArry).toArray(function (err, data) {
1744
- if (err) {
1745
- errorHandler(fldValue_1, err);
1746
- }
1747
- else if (data && data.length > 0) {
1748
- fldLookupData_1 = data[0];
1749
- updateObj[alias_1] = fldLookupData_1;
1750
- }
1751
- resolve();
1752
- });
1717
+ updateObj[searchAlias] = result === null || result === void 0 ? void 0 : result.trim();
1718
+ //** Ends here */
1719
+ }
1720
+ return [3 /*break*/, 15];
1721
+ case 13:
1722
+ aggregateArry.push({ $match: { 'Name': fieldSchema.ListSchemaName } });
1723
+ aggregateArry.push({ $unwind: { path: '$Data' } });
1724
+ aggregateArry.push({ $project: { _id: 0, Key: '$Data.Key', Value: '$Data.Value', IsActive: '$Data.IsActive' } });
1725
+ aggregateArry.push({ $match: { 'Key': { $in: fldValue } } });
1726
+ return [4 /*yield*/, db.collection('ListSchema').aggregate(aggregateArry).toArray()];
1727
+ case 14:
1728
+ // db.collection('ListSchema').aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1729
+ data = _d.sent();
1730
+ // if (err) {
1731
+ // errorHandler(fldValue, err);
1732
+ // }
1733
+ // else
1734
+ if (data && data.length > 0) {
1735
+ fldLookupData = data;
1736
+ updateObj[alias] = fldLookupData;
1737
+ result = '';
1738
+ for (i = 0; i < data.length; i++) {
1739
+ lookupRecord = data[i];
1740
+ result += ((_b = lookupRecord.Value) === null || _b === void 0 ? void 0 : _b.toString()) + ' ';
1753
1741
  }
1754
- else {
1755
- resolve();
1742
+ updateObj[searchAlias] = result === null || result === void 0 ? void 0 : result.trim();
1743
+ //** Ends here */
1744
+ }
1745
+ _d.label = 15;
1746
+ case 15: return [3 /*break*/, 20];
1747
+ case 16:
1748
+ if (!!fieldSchema.IsMultiple) return [3 /*break*/, 18];
1749
+ aggregateArry.push({ $match: { '_id': fldValue } });
1750
+ project['FileName'] = 1;
1751
+ aggregateArry.push({ $project: project });
1752
+ return [4 /*yield*/, db.collection('Drive').aggregate(aggregateArry).toArray()];
1753
+ case 17:
1754
+ // db.collection('Drive').aggregate(aggregateArry).toArray(function (err: Error, data: AnyObjectInterface[]) {
1755
+ data = _d.sent();
1756
+ // if (err) {
1757
+ // errorHandler(fldValue, err);
1758
+ // }
1759
+ // else
1760
+ if (data && data.length > 0) {
1761
+ fldLookupData = data[0];
1762
+ updateObj[alias] = fldLookupData;
1763
+ }
1764
+ _d.label = 18;
1765
+ case 18:
1766
+ // else {
1767
+ // resolve();
1768
+ // }
1769
+ return [3 /*break*/, 20];
1770
+ case 19:
1771
+ // resolve()
1772
+ return [3 /*break*/, 20];
1773
+ case 20: return [3 /*break*/, 22];
1774
+ case 21:
1775
+ updateObj[alias] = fldLookupData;
1776
+ // Below if cond was added by Shahzaib on 05/09/2022
1777
+ if (['dropdown', 'lookup', 'multilookup', 'multiselect'].includes(fieldSchema.UIDataType)) {
1778
+ updateObj[searchAlias] = "";
1779
+ }
1780
+ _d.label = 22;
1781
+ case 22: return [3 /*break*/, 24];
1782
+ case 23:
1783
+ if (constants_1.default.QrPendingFields === fieldSchema.UIDataType) {
1784
+ alias = fldName + constants_1.default.QrPendingAlias;
1785
+ if (fldValue) {
1786
+ updateObj[alias] = true;
1756
1787
  }
1757
- break;
1758
- default:
1759
- resolve();
1760
- break;
1761
- }
1762
- }
1763
- else {
1764
- updateObj[alias_1] = fldLookupData_1;
1765
- // Below if cond was added by Shahzaib on 05/09/2022
1766
- if (['dropdown', 'lookup', 'multilookup', 'multiselect'].includes(fieldSchema.UIDataType)) {
1767
- updateObj[searchAlias_1] = "";
1768
- }
1769
- resolve();
1788
+ }
1789
+ _d.label = 24;
1790
+ case 24: return [3 /*break*/, 26];
1791
+ case 25:
1792
+ error_2 = _d.sent();
1793
+ fieldValueType = (Array.isArray(fldValue) ? 'array' : '');
1794
+ if (!fieldValueType) {
1795
+ fieldValueType = typeof (fldValue);
1796
+ }
1797
+ errMsg = "Error Info: Error in Function BuildLookupDataField in Common Module for Company - " + (db.databaseName) + ", ObjectName - " + (fieldSchema.LookupObject || '') + ", FieldName - " + (fieldSchema.Name || '') + " for value - " + fldValue + " and data type of values is " + (fieldValueType || '') + " ";
1798
+ console.error(errMsg, '\n', error_2);
1799
+ return [3 /*break*/, 26];
1800
+ case 26: return [2 /*return*/];
1770
1801
  }
1771
- }
1772
- else {
1773
- resolve();
1774
- }
1802
+ });
1775
1803
  });
1776
1804
  }
1777
1805
  exports.BuildLookupDataField = BuildLookupDataField;
@@ -3683,7 +3711,7 @@ function UpdateTagCountAfterDelete(objectids, objectName, db, params) {
3683
3711
  }
3684
3712
  if (params && params.isBuiltOnPromise === true) {
3685
3713
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
3686
- var records, tags, i, field, error_2;
3714
+ var records, tags, i, field, error_3;
3687
3715
  return __generator(this, function (_a) {
3688
3716
  switch (_a.label) {
3689
3717
  case 0:
@@ -3703,8 +3731,8 @@ function UpdateTagCountAfterDelete(objectids, objectName, db, params) {
3703
3731
  resolve();
3704
3732
  return [3 /*break*/, 4];
3705
3733
  case 3:
3706
- error_2 = _a.sent();
3707
- reject(error_2);
3734
+ error_3 = _a.sent();
3735
+ reject(error_3);
3708
3736
  return [3 /*break*/, 4];
3709
3737
  case 4: return [2 /*return*/];
3710
3738
  }
@@ -4243,7 +4271,7 @@ exports.GetDayIndex = GetDayIndex;
4243
4271
  function GetUserProfile(msp_d, db, mdb, next) {
4244
4272
  var _a;
4245
4273
  return __awaiter(this, void 0, void 0, function () {
4246
- var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
4274
+ var userData, userProfile_1, error_4, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_5;
4247
4275
  return __generator(this, function (_b) {
4248
4276
  switch (_b.label) {
4249
4277
  case 0:
@@ -4280,7 +4308,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4280
4308
  userProfile_1 = _b.sent();
4281
4309
  return [3 /*break*/, 5];
4282
4310
  case 4:
4283
- error_3 = _b.sent();
4311
+ error_4 = _b.sent();
4284
4312
  console.log('No Module provided to userprofile');
4285
4313
  return [2 /*return*/, { statusCode: 500, message: "Your profile doesn't have any module access. Please contact your Administrator.", data: {} }];
4286
4314
  case 5:
@@ -4345,9 +4373,9 @@ function GetUserProfile(msp_d, db, mdb, next) {
4345
4373
  case 10: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4346
4374
  case 11: return [3 /*break*/, 13];
4347
4375
  case 12:
4348
- error_4 = _b.sent();
4349
- console.error("Internal Error in GetUserProfile Utility function : " + error_4);
4350
- next(error_4);
4376
+ error_5 = _b.sent();
4377
+ console.error("Internal Error in GetUserProfile Utility function : " + error_5);
4378
+ next(error_5);
4351
4379
  return [3 /*break*/, 13];
4352
4380
  case 13: return [2 /*return*/];
4353
4381
  }
@@ -4425,7 +4453,7 @@ exports.RemoveFieldsFromFilters = RemoveFieldsFromFilters;
4425
4453
  */
4426
4454
  function ErrorHandlerForServices(Error, ServiceOrigin, EmailConfig, Module, db) {
4427
4455
  return __awaiter(this, void 0, void 0, function () {
4428
- var _a, mailObj, errorObj, sendMailResult, ErrorOrigin, ErrorData, error_5;
4456
+ var _a, mailObj, errorObj, sendMailResult, ErrorOrigin, ErrorData, error_6;
4429
4457
  return __generator(this, function (_b) {
4430
4458
  switch (_b.label) {
4431
4459
  case 0:
@@ -4448,8 +4476,8 @@ function ErrorHandlerForServices(Error, ServiceOrigin, EmailConfig, Module, db)
4448
4476
  _b.label = 4;
4449
4477
  case 4: return [3 /*break*/, 6];
4450
4478
  case 5:
4451
- error_5 = _b.sent();
4452
- console.log("Error While connectin to Master DB", error_5);
4479
+ error_6 = _b.sent();
4480
+ console.log("Error While connectin to Master DB", error_6);
4453
4481
  return [3 /*break*/, 6];
4454
4482
  case 6: return [2 /*return*/];
4455
4483
  }
@@ -5199,7 +5227,7 @@ exports.CheckExpressionOnDateField = CheckExpressionOnDateField;
5199
5227
  */
5200
5228
  function CreateBanquetingVATSettingsData(msp_d, db, sdata, next) {
5201
5229
  return __awaiter(this, void 0, void 0, function () {
5202
- var userID, schemaData, _i, _a, field, error_6;
5230
+ var userID, schemaData, _i, _a, field, error_7;
5203
5231
  return __generator(this, function (_b) {
5204
5232
  switch (_b.label) {
5205
5233
  case 0:
@@ -5226,8 +5254,8 @@ function CreateBanquetingVATSettingsData(msp_d, db, sdata, next) {
5226
5254
  return [3 /*break*/, 2];
5227
5255
  case 5: return [3 /*break*/, 7];
5228
5256
  case 6:
5229
- error_6 = _b.sent();
5230
- next(error_6);
5257
+ error_7 = _b.sent();
5258
+ next(error_7);
5231
5259
  return [3 /*break*/, 7];
5232
5260
  case 7: return [2 /*return*/];
5233
5261
  }
@@ -5364,3 +5392,32 @@ function GetBulkUpdateURLData(eventIds, companyId, secretKey) {
5364
5392
  return bulkOps;
5365
5393
  }
5366
5394
  exports.GetBulkUpdateURLData = GetBulkUpdateURLData;
5395
+ /**
5396
+ * TODO: Return Encrypted URL
5397
+ *
5398
+ * @param recordIds - ObjectId[]
5399
+ * @param companyId - string
5400
+ * @param secretKey - string
5401
+ * @return object
5402
+ */
5403
+ function GetEncryptedURL(options) {
5404
+ var recordIds = options.recordIds, companyId = options.companyId, secretKey = options.secretKey, prefixUrl = options.prefixUrl, apiUrl = options.apiUrl, fieldName = options.fieldName, filterKey = options.filterKey;
5405
+ var bulkOps = [];
5406
+ recordIds.forEach(function (record) {
5407
+ var _a, _b;
5408
+ // Process each value in the array
5409
+ var recordIdStr = record.toString();
5410
+ var url = cryptoService.encrypt(secretKey, companyId + "-" + recordIdStr).cipherText;
5411
+ var apiEncryptedURL = "" + prefixUrl + apiUrl + url;
5412
+ bulkOps.push({
5413
+ updateOne: {
5414
+ filter: (_a = {},
5415
+ _a[filterKey] = record,
5416
+ _a),
5417
+ update: { $set: (_b = {}, _b[fieldName] = apiEncryptedURL, _b) }
5418
+ }
5419
+ });
5420
+ });
5421
+ return bulkOps;
5422
+ }
5423
+ exports.GetEncryptedURL = GetEncryptedURL;
@@ -1,7 +1,17 @@
1
+ import { ObjectId } from "mongodb";
1
2
  interface AnyObjectInterface {
2
3
  [key: string]: any;
3
4
  }
4
5
  interface callBackInterface {
5
6
  (name: any): void;
6
7
  }
7
- export { AnyObjectInterface, callBackInterface };
8
+ interface GetEncryptedURLOptions {
9
+ recordIds: ObjectId[];
10
+ companyId: string;
11
+ secretKey: string;
12
+ prefixUrl: string;
13
+ apiUrl: string;
14
+ fieldName: string;
15
+ filterKey: string;
16
+ }
17
+ export { AnyObjectInterface, callBackInterface, GetEncryptedURLOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.338",
3
+ "version": "1.0.340",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {