@optimiser/common 1.0.446 → 1.0.448
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.
- package/dist/lib/helper.js +5 -4
- package/dist/lib/utility.js +15 -11
- package/package.json +1 -1
package/dist/lib/helper.js
CHANGED
|
@@ -135,7 +135,7 @@ exports.GetEmailwiseUnsubscribeData = GetEmailwiseUnsubscribeData;
|
|
|
135
135
|
function GenerateAutoIncrementFieldValue(db, autoIncrementID) {
|
|
136
136
|
var _this = this;
|
|
137
137
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
138
|
-
var sequenceDocument, val, j, item, num, ex_1;
|
|
138
|
+
var sequenceDocument, val, doc, j, item, num, ex_1;
|
|
139
139
|
return __generator(this, function (_a) {
|
|
140
140
|
switch (_a.label) {
|
|
141
141
|
case 0:
|
|
@@ -144,13 +144,14 @@ function GenerateAutoIncrementFieldValue(db, autoIncrementID) {
|
|
|
144
144
|
case 1:
|
|
145
145
|
sequenceDocument = _a.sent();
|
|
146
146
|
val = "";
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
doc = sequenceDocument.value ? sequenceDocument.value : sequenceDocument;
|
|
148
|
+
for (j = 0; j < doc.Formats.length; j++) {
|
|
149
|
+
item = doc.Formats[j];
|
|
149
150
|
if (item.Type == "Constant") {
|
|
150
151
|
val += item.Value;
|
|
151
152
|
}
|
|
152
153
|
else if (item.Type == "AutoIncrement") {
|
|
153
|
-
num =
|
|
154
|
+
num = doc.SequenceValue.toString();
|
|
154
155
|
if (item.MinimumLength && item.MinimumLength > 0) {
|
|
155
156
|
num = ("0000000000").substring(0, item.MinimumLength - num.length) + num;
|
|
156
157
|
}
|
package/dist/lib/utility.js
CHANGED
|
@@ -4661,11 +4661,11 @@ exports.GetDayIndex = GetDayIndex;
|
|
|
4661
4661
|
function GetUserProfile(msp_d, db, mdb, next) {
|
|
4662
4662
|
var _a;
|
|
4663
4663
|
return __awaiter(this, void 0, void 0, function () {
|
|
4664
|
-
var userData, userProfile_1, error_5, objectIDs_1, modules_1, licenceDetail_1, companyLevelLicenceDetail, moduleList, _loop_17, i, error_6;
|
|
4664
|
+
var userData, userProfile_1, error_5, objectIDs_1, modules_1, licenceDetail_1, companyLevelLicenceAll, companylicenceDetail_1, companyLevelLicenceDetail, moduleList, _loop_17, i, error_6;
|
|
4665
4665
|
return __generator(this, function (_b) {
|
|
4666
4666
|
switch (_b.label) {
|
|
4667
4667
|
case 0:
|
|
4668
|
-
_b.trys.push([0,
|
|
4668
|
+
_b.trys.push([0, 12, , 13]);
|
|
4669
4669
|
return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1, 'CompanyID': 1 } })];
|
|
4670
4670
|
case 1:
|
|
4671
4671
|
userData = _b.sent();
|
|
@@ -4705,7 +4705,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
4705
4705
|
if (!(!userProfile_1 || userProfile_1.length <= 0)) return [3 /*break*/, 6];
|
|
4706
4706
|
return [2 /*return*/, { statusCode: 500, message: "User's profile data not found.", data: {} }];
|
|
4707
4707
|
case 6:
|
|
4708
|
-
if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/,
|
|
4708
|
+
if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 10];
|
|
4709
4709
|
objectIDs_1 = [];
|
|
4710
4710
|
userData.LicenceDetail.forEach(function (licenceDetail) {
|
|
4711
4711
|
if (licenceDetail.Status == "active")
|
|
@@ -4715,9 +4715,13 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
4715
4715
|
return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
|
|
4716
4716
|
case 7:
|
|
4717
4717
|
licenceDetail_1 = _b.sent();
|
|
4718
|
-
return [4 /*yield*/, mdb.collection("Licences").find({ "IsCompanyLevelLicence": true, "Status": "active", "IsActive": true }, { projection: { Modules: 1 } }).toArray()];
|
|
4718
|
+
return [4 /*yield*/, mdb.collection("Licences").find({ "IsCompanyLevelLicence": true, "Status": "active", "IsActive": true }, { projection: { Modules: 1, LicenceName: 1, LicenceType: 1 } }).toArray()];
|
|
4719
4719
|
case 8:
|
|
4720
|
-
|
|
4720
|
+
companyLevelLicenceAll = _b.sent();
|
|
4721
|
+
return [4 /*yield*/, mdb.collection("CompanyLicence").find({ 'CompanyID': userData.CompanyID, 'Status': 'active', 'IsActive': true }).toArray()];
|
|
4722
|
+
case 9:
|
|
4723
|
+
companylicenceDetail_1 = _b.sent();
|
|
4724
|
+
companyLevelLicenceDetail = companyLevelLicenceAll.filter(function (x) { return companylicenceDetail_1.some(function (y) { return x.LicenceName === y.LicenceName && x.LicenceType === y.LicenceType; }); });
|
|
4721
4725
|
if (companyLevelLicenceDetail && companyLevelLicenceDetail.length > 0) {
|
|
4722
4726
|
companyLevelLicenceDetail.map(function (x) {
|
|
4723
4727
|
var _a;
|
|
@@ -4754,15 +4758,15 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
4754
4758
|
else {
|
|
4755
4759
|
return [2 /*return*/, { statusCode: 200, message: "Licence data is not found in Master database.", data: {} }];
|
|
4756
4760
|
}
|
|
4757
|
-
return [3 /*break*/,
|
|
4758
|
-
case
|
|
4759
|
-
case
|
|
4760
|
-
case
|
|
4761
|
+
return [3 /*break*/, 11];
|
|
4762
|
+
case 10: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
|
|
4763
|
+
case 11: return [3 /*break*/, 13];
|
|
4764
|
+
case 12:
|
|
4761
4765
|
error_6 = _b.sent();
|
|
4762
4766
|
console.error("Internal Error in GetUserProfile Utility function : ".concat(error_6));
|
|
4763
4767
|
next(error_6);
|
|
4764
|
-
return [3 /*break*/,
|
|
4765
|
-
case
|
|
4768
|
+
return [3 /*break*/, 13];
|
|
4769
|
+
case 13: return [2 /*return*/];
|
|
4766
4770
|
}
|
|
4767
4771
|
});
|
|
4768
4772
|
});
|