elasticio-sailor-nodejs 2.6.26-dev1 → 2.6.28-dev1

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/.nsprc ADDED
File without changes
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.6.27 (March 10, 2022)
2
+
3
+ * Added npm audit to CI and fixed all dependencies
4
+
1
5
  ## 2.6.26 (June 24, 2021)
2
6
 
3
7
  * Replaced exit on "unhandledRejection" with error logging
package/lib/sailor.js CHANGED
@@ -293,16 +293,8 @@ class Sailor {
293
293
  }
294
294
 
295
295
  async uploadMessageBody(bodyBuf) {
296
- let id;
297
-
298
- try {
299
- const stream = () => Readable.from(bodyBuf);
300
- id = await this.objectStorage.addAsStream(stream, this.settings.OBJECT_STORAGE_TOKEN);
301
- } catch (e) {
302
- log.error(e);
303
- }
304
-
305
- return id;
296
+ const stream = () => Readable.from(bodyBuf);
297
+ return await this.objectStorage.addAsStream(stream, this.settings.OBJECT_STORAGE_TOKEN);
306
298
  }
307
299
 
308
300
  async runExec(module, payload, message, outgoingMessageHeaders, stepData, timeStart, logger) {
@@ -386,38 +378,38 @@ class Sailor {
386
378
  OBJECT_STORAGE_SIZE_THRESHOLD: settings.OBJECT_STORAGE_SIZE_THRESHOLD
387
379
  }
388
380
  );
389
- const [bodyId, ...passthroughIds] = await Promise.all([
390
- that.uploadMessageBody(bodyBuf),
391
- ...passthroughBufs.map(async ({ stepId, body, id }) => {
392
- const bodyId = id || await that.uploadMessageBody(body);
393
- return { stepId, bodyId };
394
- })
395
- ]);
396
-
397
- if (bodyId) {
398
- logger.info('Message body uploaded', { id: bodyId });
399
- const { headers } = data;
400
- data.body = {};
401
- data.headers = {
402
- ...(headers || {}),
403
- [OBJECT_ID_HEADER]: bodyId
404
- };
405
- } else {
406
- logger.info('Message body not uploaded');
381
+
382
+ let bodyId;
383
+ let passthroughIds;
384
+ try {
385
+ [bodyId, ...passthroughIds] = await Promise.all([
386
+ that.uploadMessageBody(bodyBuf),
387
+ ...passthroughBufs.map(async ({ stepId, body, id }) => {
388
+ const bodyId = id || await that.uploadMessageBody(body);
389
+ return { stepId, bodyId };
390
+ })
391
+ ]);
392
+ } catch (e) {
393
+ logger.error(e, 'Error during message/passthrough body upload');
394
+ return onError(new Error('Lightweight message/passthrough body upload error'));
407
395
  }
408
396
 
397
+ logger.info('Message body uploaded', { id: bodyId });
398
+ const { headers } = data;
399
+ data.body = {};
400
+ data.headers = {
401
+ ...(headers || {}),
402
+ [OBJECT_ID_HEADER]: bodyId
403
+ };
404
+
409
405
  for (const { stepId, bodyId } of passthroughIds) {
410
- if (bodyId) {
411
- logger.info('Passthrough Message body uploaded', { stepId, id: bodyId });
412
- const { [stepId]: { headers } } = passthrough;
413
- data.passthrough[stepId].body = {};
414
- data.passthrough[stepId].headers = {
415
- ...(headers || {}),
416
- [OBJECT_ID_HEADER]: bodyId
417
- };
418
- } else {
419
- logger.info('Passtrough Message body not uploaded', { stepId, id: bodyId });
420
- }
406
+ logger.info('Passthrough Message body uploaded', { stepId, id: bodyId });
407
+ const { [stepId]: { headers } } = passthrough;
408
+ data.passthrough[stepId].body = {};
409
+ data.passthrough[stepId].headers = {
410
+ ...(headers || {}),
411
+ [OBJECT_ID_HEADER]: bodyId
412
+ };
421
413
  }
422
414
 
423
415
  } else {
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "elasticio-sailor-nodejs",
3
3
  "description": "The official elastic.io library for bootstrapping and executing for Node.js connectors",
4
- "version": "2.6.26-dev1",
4
+ "version": "2.6.28-dev1",
5
5
  "main": "run.js",
6
6
  "scripts": {
7
+ "audit": "better-npm-audit audit --level high --production",
7
8
  "lint": "./node_modules/.bin/eslint lib spec mocha_spec lib run.js runService.js",
8
9
  "pretest": "npm run lint",
9
10
  "test": "npm run test:jasmine && npm run test:mocha",
@@ -15,7 +16,7 @@
15
16
  "node": ">=12.13.0"
16
17
  },
17
18
  "dependencies": {
18
- "@elastic.io/object-storage-client": "1.0.1",
19
+ "@elastic.io/object-storage-client": "2.1.0",
19
20
  "amqplib": "0.8.0",
20
21
  "bunyan": "1.8.10",
21
22
  "co": "4.6.0",
@@ -30,18 +31,19 @@
30
31
  "uuid": "3.0.1"
31
32
  },
32
33
  "devDependencies": {
33
- "rabbitmq-stats": "1.2.3",
34
+ "better-npm-audit": "3.7.3",
34
35
  "chai": "4.2.0",
35
36
  "del": "2.2.2",
36
37
  "eslint": "4.19.1",
37
38
  "eslint-plugin-mocha": "4.12.1",
38
39
  "express": "4.16.4",
39
40
  "gulp": "3.9.1",
40
- "gulp-istanbul": "1.1.1",
41
+ "gulp-istanbul": "1.1.3",
41
42
  "gulp-jasmine": "0.2.0",
42
43
  "jasmine-node": "3.0.0",
43
44
  "mocha": "7.1.2",
44
45
  "nock": "12.0.3",
46
+ "rabbitmq-stats": "1.2.4",
45
47
  "request": "2.88.0",
46
48
  "sinon": "9.0.2",
47
49
  "sinon-chai": "3.5.0"