@optimiser/common 1.0.247 → 1.0.251

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.
@@ -158,7 +158,7 @@ var AwsServices = /** @class */ (function () {
158
158
  case 2:
159
159
  err_1 = _a.sent();
160
160
  console.error("Error While Creating Signed Url:", err_1);
161
- throw new err_1;
161
+ return [3 /*break*/, 3];
162
162
  case 3: return [2 /*return*/];
163
163
  }
164
164
  });
@@ -264,6 +264,11 @@ var AwsServices = /** @class */ (function () {
264
264
  };
265
265
  AwsServices.prototype.GeneratePreSignedUrlNotAccelerated = function (params) {
266
266
  var region = params.region, bucket = params.bucket, path = params.path, _a = params.expires, expires = _a === void 0 ? 60 : _a, _b = params.acl, acl = _b === void 0 ? 'private' : _b, _c = params.contentType, contentType = _c === void 0 ? 'application/octet-stream' : _c, _d = params.accessKeyId, accessKeyId = _d === void 0 ? this.accessKeyId : _d, _e = params.secretAccessKey, secretAccessKey = _e === void 0 ? this.secretAccessKey : _e;
267
+ // added by Mohan ason 28-01-2022. To overwrite acl variable.
268
+ // acl variable will have public-read OR private value. default is private
269
+ if (params.accessType != '' && params.accessType != undefined && params.accessType != null) {
270
+ acl = params.accessType;
271
+ }
267
272
  var S3 = new aws_sdk_1.default.S3({
268
273
  accessKeyId: accessKeyId,
269
274
  secretAccessKey: secretAccessKey,
@@ -7,6 +7,7 @@ declare class MemoryDBConnect {
7
7
  private host;
8
8
  private isConnected;
9
9
  private messages;
10
+ private memBuffObj;
10
11
  /**
11
12
  * @param masterConfig Master Connectivity Object
12
13
  * @param redisClient Redisclient
@@ -59,6 +59,42 @@ exports.MemoryDBConnect = void 0;
59
59
  //var net = require('net');
60
60
  var net = __importStar(require("net"));
61
61
  var crypto = __importStar(require("crypto"));
62
+ var MessageBuffer = /** @class */ (function () {
63
+ function MessageBuffer(delimiter) {
64
+ this.delimiter = delimiter;
65
+ this.buffer = "";
66
+ }
67
+ MessageBuffer.prototype.isFinished = function () {
68
+ if (this.buffer.length === 0 ||
69
+ this.buffer.indexOf(this.delimiter) === -1) {
70
+ return true;
71
+ }
72
+ return false;
73
+ };
74
+ MessageBuffer.prototype.push = function (data) {
75
+ this.buffer += data;
76
+ };
77
+ MessageBuffer.prototype.getMessage = function () {
78
+ var delimiterIndex = this.buffer.indexOf(this.delimiter);
79
+ if (delimiterIndex !== -1) {
80
+ var message = this.buffer.slice(0, delimiterIndex);
81
+ this.buffer = this.buffer.replace(message + this.delimiter, "");
82
+ return message;
83
+ }
84
+ return null;
85
+ };
86
+ MessageBuffer.prototype.handleData = function () {
87
+ /**
88
+ * Try to accumulate the buffer with messages
89
+ *
90
+ * If the server isnt sending delimiters for some reason
91
+ * then nothing will ever come back for these requests
92
+ */
93
+ var message = this.getMessage();
94
+ return message;
95
+ };
96
+ return MessageBuffer;
97
+ }());
62
98
  var MemoryDBConnect = /** @class */ (function () {
63
99
  /**
64
100
  * @param masterConfig Master Connectivity Object
@@ -71,6 +107,7 @@ var MemoryDBConnect = /** @class */ (function () {
71
107
  this.host = "";
72
108
  this.isConnected = false;
73
109
  this.messages = {};
110
+ this.memBuffObj = new MessageBuffer("##message_response##");
74
111
  this.portNo = portNumber;
75
112
  this.host = hostName;
76
113
  // this.Initialize().then(([error, result]) => {
@@ -99,13 +136,25 @@ var MemoryDBConnect = /** @class */ (function () {
99
136
  _this.client.on('data', function (data) {
100
137
  console.log("Data from MemServer", (data || "").toString());
101
138
  //console.log("")
102
- var message = null;
139
+ // let message = null;
103
140
  try {
104
- data = JSON.parse(data);
105
- message = _this.messages[data.id];
106
- if (message) {
107
- delete _this.messages[data.id];
108
- message(data);
141
+ // data = JSON.parse(data);
142
+ // message = this.messages[data.id];
143
+ // if (message) {
144
+ // delete this.messages[data.id];
145
+ // message(data);
146
+ // }
147
+ _this.memBuffObj.push(data);
148
+ while (!_this.memBuffObj.isFinished()) {
149
+ var message = _this.memBuffObj.handleData();
150
+ // console.log(message);
151
+ // console.log(JSON.parse(message))
152
+ if (message) {
153
+ message = JSON.parse(message);
154
+ var messageCallbackFn = _this.messages[message.id];
155
+ delete _this.messages[message.id];
156
+ messageCallbackFn(message);
157
+ }
109
158
  }
110
159
  }
111
160
  catch (error) {
@@ -157,9 +206,9 @@ var MemoryDBConnect = /** @class */ (function () {
157
206
  resolve([new Error("REQUEST_TIMEDOUT"), undefined]);
158
207
  message_1.status = "-1";
159
208
  }
160
- }, 30000);
209
+ }, 60000);
161
210
  if (_this.client && _this.isConnected) {
162
- _this.client.write(JSON.stringify(message_1));
211
+ _this.client.write(JSON.stringify(message_1) + "##message##");
163
212
  }
164
213
  else {
165
214
  //to avoid again resolve by set timeout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.247",
3
+ "version": "1.0.251",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {