@optimiser/common 1.0.361 → 1.0.363

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/event.js CHANGED
@@ -129,7 +129,7 @@ var Event = /** @class */ (function () {
129
129
  return [3 /*break*/, 6];
130
130
  case 6: return [3 /*break*/, 8];
131
131
  case 7:
132
- console.log('Not able to INITIALISE THE FIREBASE ADMIN APP--');
132
+ console.log('Attention!!-- We are not sending mobile notifications due to lack of FIREBASE ADMIN APP configurations.\n Please provide firebaseSet-up.JSON file.');
133
133
  _a.label = 8;
134
134
  case 8:
135
135
  // if (userId && data.SocketObj && !data.SocketObj.userId) {
@@ -228,14 +228,19 @@ var Event = /** @class */ (function () {
228
228
  accessKeyId: eventConfig.SQS_ACCESSKEY_ID,
229
229
  secretAccessKey: eventConfig.SQS_SECRET_KEY
230
230
  });
231
- this.FCMMobileServiceAccountKey = eventConfig.FCM_NOTIFICATION_SERVICE_ACCOUNT_KEY;
232
- try {
233
- admin.initializeApp({
234
- credential: admin.credential.cert(this.FCMMobileServiceAccountKey)
235
- });
231
+ this.FCMMobileServiceAccountKey = eventConfig === null || eventConfig === void 0 ? void 0 : eventConfig.FCM_NOTIFICATION_SERVICE_ACCOUNT_KEY;
232
+ if (eventConfig === null || eventConfig === void 0 ? void 0 : eventConfig.FCM_NOTIFICATION_SERVICE_ACCOUNT_KEY) { // scope added by komal, to handle the firebase warning,
233
+ try {
234
+ admin.initializeApp({
235
+ credential: admin.credential.cert(this.FCMMobileServiceAccountKey)
236
+ });
237
+ }
238
+ catch (error) {
239
+ console.log('Error while INITIALIZING FIREBASE ADMIN APP\n Please check firebaseSet-up.JSON file.\n This will impact mobile app notifications -----', error);
240
+ }
236
241
  }
237
- catch (error) {
238
- console.log('Error while INITIALIZING FIREBASE ADMIN APP\n Please check service-accountKey.JSON file.\n This will impact mobile app notifications -----', error);
242
+ else {
243
+ console.log('We are not INITIALIZING mobile notifications due to lack of FIREBASE ADMIN APP configurations.\n Please provide firebaseSet-up.JSON file.');
239
244
  }
240
245
  }
241
246
  return Event;
@@ -26,7 +26,7 @@ declare function SyncParentObjectData(pageData: AnyObjectInterface, objectID: Ob
26
26
  */
27
27
  declare function DeleteFieldInOtherCollection(objectName: string, objectIDs: ObjectId, db: Db, params?: AnyObjectInterface): Promise<void>;
28
28
  declare function ReactivateFieldInOtherCollection(objectName: string, objectIDs: ObjectId, db: Db): void;
29
- declare function SyncFieldInSameCollection(objectName: string, objectIDs: ObjectId[], db: Db): Promise<any>;
29
+ declare function SyncFieldInSameCollection(objectName: string, objectIDs: ObjectId[], db: Db, comMasterDb: Db): Promise<any>;
30
30
  declare function SyncFieldInSameCollectionByObjectID(objectName: string, objectID: ObjectId, db: Db): void;
31
31
  declare function SyncFieldInSameCollectionByObjectIDWithPromise(objectName: string, objectID: ObjectId, db: Db): Promise<any>;
32
32
  declare function SyncFieldInOtherCollection(syncFields: AnyObjectInterface[], db: Db): Promise<any>;
@@ -1030,7 +1030,7 @@ function ReactivateFieldInOtherCollection(objectName, objectIDs, db) {
1030
1030
  exports.ReactivateFieldInOtherCollection = ReactivateFieldInOtherCollection;
1031
1031
  //Sync _LookupDataField field in same collection by Ids
1032
1032
  //Note: if pass objectIDs as null or blank arry it will update all data
1033
- function SyncFieldInSameCollection(objectName, objectIDs, db) {
1033
+ function SyncFieldInSameCollection(objectName, objectIDs, db, comMasterDb) {
1034
1034
  var _this = this;
1035
1035
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1036
1036
  return __generator(this, function (_a) {
@@ -1052,7 +1052,8 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
1052
1052
  if (objectIDs && objectIDs.length > 0) {
1053
1053
  findObj = { '_id': { '$in': objectIDs } };
1054
1054
  }
1055
- db.collection(objectName).find(findObj).forEach(function (objectData) {
1055
+ // added by komal, QPC-8260- getting the comMasterDb from dbconnection based on UseMasterDatabase flag for updating the master db also.
1056
+ comMasterDb.collection(objectName).find(findObj).forEach(function (objectData) {
1056
1057
  return __awaiter(this, void 0, void 0, function () {
1057
1058
  var updateObj, i, fieldSchema, lookupData, searchValue, ex_1;
1058
1059
  return __generator(this, function (_a) {
@@ -1084,8 +1085,8 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
1084
1085
  i++;
1085
1086
  return [3 /*break*/, 2];
1086
1087
  case 5:
1087
- if (Object.keys(updateObj).length > 0) {
1088
- db.collection(objectName).updateOne({ _id: objectData._id }, { $set: updateObj });
1088
+ if (Object.keys(updateObj).length > 0) { // added by komal, QPC-8260- getting the comMasterDb from dbconnection based on UseMasterDatabase flag for updating the master db also.
1089
+ comMasterDb.collection(objectName).updateOne({ _id: objectData._id }, { $set: updateObj });
1089
1090
  }
1090
1091
  return [3 /*break*/, 7];
1091
1092
  case 6:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.361",
3
+ "version": "1.0.363",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {