elasticio-sailor-nodejs 2.6.26 → 2.6.28-dev2
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 +0 -0
- package/CHANGELOG.md +4 -0
- package/lib/sailor.js +39 -41
- package/package.json +9 -7
- package/.vscode/settings.json +0 -7
package/.nsprc
ADDED
|
File without changes
|
package/CHANGELOG.md
CHANGED
package/lib/sailor.js
CHANGED
|
@@ -280,7 +280,10 @@ class Sailor {
|
|
|
280
280
|
logger.info('Going to fetch message body.', { objectId });
|
|
281
281
|
|
|
282
282
|
try {
|
|
283
|
-
object = await this.objectStorage.getAsJSON(
|
|
283
|
+
object = await this.objectStorage.getAsJSON(
|
|
284
|
+
objectId,
|
|
285
|
+
{ jwtPayloadOrToken: this.settings.OBJECT_STORAGE_TOKEN }
|
|
286
|
+
);
|
|
284
287
|
} catch (e) {
|
|
285
288
|
log.error(e);
|
|
286
289
|
throw new Error(`Failed to get message body with id=${objectId}`);
|
|
@@ -292,17 +295,12 @@ class Sailor {
|
|
|
292
295
|
return object;
|
|
293
296
|
}
|
|
294
297
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
} catch (e) {
|
|
302
|
-
log.error(e);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return id;
|
|
298
|
+
uploadMessageBody(bodyBuf) {
|
|
299
|
+
const stream = () => Readable.from(bodyBuf);
|
|
300
|
+
return this.objectStorage.addAsStream(
|
|
301
|
+
stream,
|
|
302
|
+
{ jwtPayloadOrToken: this.settings.OBJECT_STORAGE_TOKEN }
|
|
303
|
+
);
|
|
306
304
|
}
|
|
307
305
|
|
|
308
306
|
async runExec(module, payload, message, outgoingMessageHeaders, stepData, timeStart, logger) {
|
|
@@ -386,38 +384,38 @@ class Sailor {
|
|
|
386
384
|
OBJECT_STORAGE_SIZE_THRESHOLD: settings.OBJECT_STORAGE_SIZE_THRESHOLD
|
|
387
385
|
}
|
|
388
386
|
);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
[OBJECT_ID_HEADER]: bodyId
|
|
404
|
-
};
|
|
405
|
-
} else {
|
|
406
|
-
logger.info('Message body not uploaded');
|
|
387
|
+
|
|
388
|
+
let bodyId;
|
|
389
|
+
let passthroughIds;
|
|
390
|
+
try {
|
|
391
|
+
[bodyId, ...passthroughIds] = await Promise.all([
|
|
392
|
+
that.uploadMessageBody(bodyBuf),
|
|
393
|
+
...passthroughBufs.map(async ({ stepId, body, id }) => {
|
|
394
|
+
const bodyId = id || await that.uploadMessageBody(body);
|
|
395
|
+
return { stepId, bodyId };
|
|
396
|
+
})
|
|
397
|
+
]);
|
|
398
|
+
} catch (e) {
|
|
399
|
+
logger.error(e, 'Error during message/passthrough body upload');
|
|
400
|
+
return onError(new Error('Lightweight message/passthrough body upload error'));
|
|
407
401
|
}
|
|
408
402
|
|
|
403
|
+
logger.info('Message body uploaded', { id: bodyId });
|
|
404
|
+
const { headers } = data;
|
|
405
|
+
data.body = {};
|
|
406
|
+
data.headers = {
|
|
407
|
+
...(headers || {}),
|
|
408
|
+
[OBJECT_ID_HEADER]: bodyId
|
|
409
|
+
};
|
|
410
|
+
|
|
409
411
|
for (const { stepId, bodyId } of passthroughIds) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
};
|
|
418
|
-
} else {
|
|
419
|
-
logger.info('Passtrough Message body not uploaded', { stepId, id: bodyId });
|
|
420
|
-
}
|
|
412
|
+
logger.info('Passthrough Message body uploaded', { stepId, id: bodyId });
|
|
413
|
+
const { [stepId]: { headers } } = passthrough;
|
|
414
|
+
data.passthrough[stepId].body = {};
|
|
415
|
+
data.passthrough[stepId].headers = {
|
|
416
|
+
...(headers || {}),
|
|
417
|
+
[OBJECT_ID_HEADER]: bodyId
|
|
418
|
+
};
|
|
421
419
|
}
|
|
422
420
|
|
|
423
421
|
} 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.
|
|
4
|
+
"version": "2.6.28-dev2",
|
|
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,33 +16,34 @@
|
|
|
15
16
|
"node": ">=12.13.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@elastic.io/object-storage-client": "1.0
|
|
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",
|
|
22
23
|
"debug": "3.1.0",
|
|
23
|
-
"elasticio-rest-node": "1.2.
|
|
24
|
+
"elasticio-rest-node": "1.2.7",
|
|
24
25
|
"event-to-promise": "0.8.0",
|
|
25
|
-
"lodash": "4.17.
|
|
26
|
+
"lodash": "4.17.21",
|
|
26
27
|
"p-throttle": "2.1.0",
|
|
27
28
|
"q": "1.5.1",
|
|
28
29
|
"request-promise-native": "1.0.5",
|
|
29
|
-
"requestretry": "
|
|
30
|
+
"requestretry": "7.0.2",
|
|
30
31
|
"uuid": "3.0.1"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"
|
|
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.
|
|
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"
|