elasticio-sailor-nodejs 2.6.27 → 2.6.28-dev3
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/lib/sailor.js +40 -41
- package/package.json +6 -4
package/.nsprc
ADDED
|
File without changes
|
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) {
|
|
@@ -369,6 +367,7 @@ class Sailor {
|
|
|
369
367
|
if (settings.EMIT_LIGHTWEIGHT_MESSAGE) {
|
|
370
368
|
logger.trace('Outgoing lightweight is enabled, going to check size.');
|
|
371
369
|
const bodyBuf = Buffer.from(JSON.stringify(body), 'utf-8');
|
|
370
|
+
logger.info('bodyBuf type:', { type: typeof bodyBuf });
|
|
372
371
|
const passthroughBufs = Object.keys(passthrough).map(stepId => ({
|
|
373
372
|
stepId,
|
|
374
373
|
body: Buffer.from(JSON.stringify(passthrough[stepId].body), 'utf-8'),
|
|
@@ -386,38 +385,38 @@ class Sailor {
|
|
|
386
385
|
OBJECT_STORAGE_SIZE_THRESHOLD: settings.OBJECT_STORAGE_SIZE_THRESHOLD
|
|
387
386
|
}
|
|
388
387
|
);
|
|
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');
|
|
388
|
+
|
|
389
|
+
let bodyId;
|
|
390
|
+
let passthroughIds;
|
|
391
|
+
try {
|
|
392
|
+
[bodyId, ...passthroughIds] = await Promise.all([
|
|
393
|
+
that.uploadMessageBody(bodyBuf),
|
|
394
|
+
...passthroughBufs.map(async ({ stepId, body, id }) => {
|
|
395
|
+
const bodyId = id || await that.uploadMessageBody(body);
|
|
396
|
+
return { stepId, bodyId };
|
|
397
|
+
})
|
|
398
|
+
]);
|
|
399
|
+
} catch (e) {
|
|
400
|
+
logger.error(e, 'Error during message/passthrough body upload');
|
|
401
|
+
return onError(new Error('Lightweight message/passthrough body upload error'));
|
|
407
402
|
}
|
|
408
403
|
|
|
404
|
+
logger.info('Message body uploaded', { id: bodyId });
|
|
405
|
+
const { headers } = data;
|
|
406
|
+
data.body = {};
|
|
407
|
+
data.headers = {
|
|
408
|
+
...(headers || {}),
|
|
409
|
+
[OBJECT_ID_HEADER]: bodyId
|
|
410
|
+
};
|
|
411
|
+
|
|
409
412
|
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
|
-
}
|
|
413
|
+
logger.info('Passthrough Message body uploaded', { stepId, id: bodyId });
|
|
414
|
+
const { [stepId]: { headers } } = passthrough;
|
|
415
|
+
data.passthrough[stepId].body = {};
|
|
416
|
+
data.passthrough[stepId].headers = {
|
|
417
|
+
...(headers || {}),
|
|
418
|
+
[OBJECT_ID_HEADER]: bodyId
|
|
419
|
+
};
|
|
421
420
|
}
|
|
422
421
|
|
|
423
422
|
} 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-dev3",
|
|
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
|
|
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
|
-
"
|
|
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"
|