squiss-ts 4.2.1 → 4.4.0
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/Message.d.ts +3 -1
- package/dist/Message.js +4 -4
- package/dist/Squiss.d.ts +2 -1
- package/dist/Squiss.js +13 -12
- package/dist/Types.d.ts +3 -1
- package/dist/attributeUtils.d.ts +1 -1
- package/dist/attributeUtils.js +3 -3
- package/dist/gzipUtils.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -3
- package/dist/messageSizeUtils.js +5 -5
- package/dist/s3Utils.d.ts +1 -1
- package/dist/s3Utils.js +2 -2
- package/package.json +16 -14
package/dist/Message.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import * as SQS from 'aws-sdk/clients/sqs';
|
|
3
|
+
import * as S3 from 'aws-sdk/clients/s3';
|
|
4
|
+
import { AWSError } from 'aws-sdk/lib/error';
|
|
3
5
|
import { BodyFormat, Squiss } from '.';
|
|
4
6
|
import { IMessageAttributes } from './attributeUtils';
|
|
5
7
|
import { EventEmitter } from 'events';
|
package/dist/Message.js
CHANGED
|
@@ -23,7 +23,7 @@ class Message extends events_1.EventEmitter {
|
|
|
23
23
|
}
|
|
24
24
|
this._squiss = opts.squiss;
|
|
25
25
|
this._handled = false;
|
|
26
|
-
this.attributes = attributeUtils_1.parseMessageAttributes(opts.msg.MessageAttributes);
|
|
26
|
+
this.attributes = (0, attributeUtils_1.parseMessageAttributes)(opts.msg.MessageAttributes);
|
|
27
27
|
this.sqsAttributes = opts.msg.Attributes || {};
|
|
28
28
|
this._s3Retriever = opts.s3Retriever;
|
|
29
29
|
this._s3Retain = opts.s3Retain;
|
|
@@ -49,7 +49,7 @@ class Message extends events_1.EventEmitter {
|
|
|
49
49
|
.then((resolvedBody) => {
|
|
50
50
|
if (this.attributes[gzipUtils_1.GZIP_MARKER] === 1) {
|
|
51
51
|
delete this.attributes[gzipUtils_1.GZIP_MARKER];
|
|
52
|
-
return gzipUtils_1.decompressMessage(resolvedBody);
|
|
52
|
+
return (0, gzipUtils_1.decompressMessage)(resolvedBody);
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
return Promise.resolve(resolvedBody);
|
|
@@ -107,13 +107,13 @@ class Message extends events_1.EventEmitter {
|
|
|
107
107
|
_getBlobMessage() {
|
|
108
108
|
const uploadData = JSON.parse(this.body);
|
|
109
109
|
const s3 = this._s3Retriever();
|
|
110
|
-
return s3Utils_1.getBlob(s3, uploadData)
|
|
110
|
+
return (0, s3Utils_1.getBlob)(s3, uploadData)
|
|
111
111
|
.then((resolvedBody) => {
|
|
112
112
|
this.emit('s3Download', uploadData);
|
|
113
113
|
this._squiss.emit('s3Download', { data: uploadData, message: this });
|
|
114
114
|
if (!this._s3Retain) {
|
|
115
115
|
this._deleteCallback = () => {
|
|
116
|
-
return s3Utils_1.deleteBlob(s3, uploadData)
|
|
116
|
+
return (0, s3Utils_1.deleteBlob)(s3, uploadData)
|
|
117
117
|
.then(() => {
|
|
118
118
|
this.emit('s3Delete', uploadData);
|
|
119
119
|
this._squiss.emit('s3Delete', { data: uploadData, message: this });
|
package/dist/Squiss.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Message } from './Message';
|
|
2
2
|
import { TimeoutExtender } from './TimeoutExtender';
|
|
3
3
|
import { IMessageAttributes } from './attributeUtils';
|
|
4
|
-
import
|
|
4
|
+
import * as SQS from 'aws-sdk/clients/sqs';
|
|
5
|
+
import * as S3 from 'aws-sdk/clients/s3';
|
|
5
6
|
import { IMessageToSend, SquissEmitter, ISquissOptions } from './Types';
|
|
6
7
|
declare const Squiss_base: new () => SquissEmitter;
|
|
7
8
|
export declare class Squiss extends Squiss_base {
|
package/dist/Squiss.js
CHANGED
|
@@ -7,7 +7,8 @@ const Message_1 = require("./Message");
|
|
|
7
7
|
const TimeoutExtender_1 = require("./TimeoutExtender");
|
|
8
8
|
const attributeUtils_1 = require("./attributeUtils");
|
|
9
9
|
const ts_type_guards_1 = require("ts-type-guards");
|
|
10
|
-
const
|
|
10
|
+
const SQS = require("aws-sdk/clients/sqs");
|
|
11
|
+
const S3 = require("aws-sdk/clients/s3");
|
|
11
12
|
const gzipUtils_1 = require("./gzipUtils");
|
|
12
13
|
const s3Utils_1 = require("./s3Utils");
|
|
13
14
|
const messageSizeUtils_1 = require("./messageSizeUtils");
|
|
@@ -281,7 +282,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
281
282
|
}
|
|
282
283
|
}
|
|
283
284
|
else {
|
|
284
|
-
return new
|
|
285
|
+
return new S3(this._opts.awsConfig);
|
|
285
286
|
}
|
|
286
287
|
}
|
|
287
288
|
_initOpts() {
|
|
@@ -341,7 +342,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
341
342
|
this._paused = true;
|
|
342
343
|
return;
|
|
343
344
|
}
|
|
344
|
-
const params = Utils_1.removeEmptyKeys({
|
|
345
|
+
const params = (0, Utils_1.removeEmptyKeys)({
|
|
345
346
|
QueueUrl: queueUrl, MaxNumberOfMessages: maxMessagesToGet,
|
|
346
347
|
WaitTimeSeconds: this._opts.receiveWaitTimeSecs,
|
|
347
348
|
MessageAttributeNames: this._opts.receiveAttributes,
|
|
@@ -420,7 +421,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
420
421
|
this._deleteMessages(delBatch);
|
|
421
422
|
}
|
|
422
423
|
_isLargeMessage(message, minSize) {
|
|
423
|
-
const messageSize = messageSizeUtils_1.getMessageSize(message);
|
|
424
|
+
const messageSize = (0, messageSizeUtils_1.getMessageSize)(message);
|
|
424
425
|
if (minSize) {
|
|
425
426
|
return Promise.resolve(messageSize > minSize);
|
|
426
427
|
}
|
|
@@ -430,17 +431,17 @@ class Squiss extends events_1.EventEmitter {
|
|
|
430
431
|
});
|
|
431
432
|
}
|
|
432
433
|
_prepareMessageParams(message, delay, attributes) {
|
|
433
|
-
const messageStr = ts_type_guards_1.isString(message) ? message : JSON.stringify(message);
|
|
434
|
+
const messageStr = (0, ts_type_guards_1.isString)(message) ? message : JSON.stringify(message);
|
|
434
435
|
const params = { MessageBody: messageStr, DelaySeconds: delay };
|
|
435
436
|
attributes = Object.assign({}, attributes);
|
|
436
437
|
params.MessageGroupId = attributes.FIFO_MessageGroupId;
|
|
437
438
|
delete attributes.FIFO_MessageGroupId;
|
|
438
439
|
params.MessageDeduplicationId = attributes.FIFO_MessageDeduplicationId;
|
|
439
440
|
delete attributes.FIFO_MessageDeduplicationId;
|
|
440
|
-
params.MessageAttributes = attributeUtils_1.createMessageAttributes(attributes);
|
|
441
|
+
params.MessageAttributes = (0, attributeUtils_1.createMessageAttributes)(attributes);
|
|
441
442
|
let getMessagePromise = Promise.resolve(messageStr);
|
|
442
|
-
if (this._opts.gzip && (!this._opts.minGzipSize || messageSizeUtils_1.getMessageSize(params) >= this._opts.minGzipSize)) {
|
|
443
|
-
getMessagePromise = gzipUtils_1.compressMessage(messageStr);
|
|
443
|
+
if (this._opts.gzip && (!this._opts.minGzipSize || (0, messageSizeUtils_1.getMessageSize)(params) >= this._opts.minGzipSize)) {
|
|
444
|
+
getMessagePromise = (0, gzipUtils_1.compressMessage)(messageStr);
|
|
444
445
|
params.MessageAttributes = params.MessageAttributes || {};
|
|
445
446
|
params.MessageAttributes[gzipUtils_1.GZIP_MARKER] = {
|
|
446
447
|
StringValue: `1`,
|
|
@@ -461,7 +462,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
461
462
|
if (!isLarge) {
|
|
462
463
|
return Promise.resolve(params);
|
|
463
464
|
}
|
|
464
|
-
return s3Utils_1.uploadBlob(this.getS3(), this._opts.s3Bucket, finalMessage, this._opts.s3Prefix || '')
|
|
465
|
+
return (0, s3Utils_1.uploadBlob)(this.getS3(), this._opts.s3Bucket, finalMessage, this._opts.s3Prefix || '')
|
|
465
466
|
.then((uploadData) => {
|
|
466
467
|
this.emit('s3Upload', uploadData);
|
|
467
468
|
params.MessageBody = JSON.stringify(uploadData);
|
|
@@ -484,7 +485,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
484
485
|
return this._prepareMessageParams(message, delay, attributes)
|
|
485
486
|
.then(this._handleLargeMessagePrepare.bind(this))
|
|
486
487
|
.then((params) => {
|
|
487
|
-
return Utils_1.removeEmptyKeys(params);
|
|
488
|
+
return (0, Utils_1.removeEmptyKeys)(params);
|
|
488
489
|
});
|
|
489
490
|
}
|
|
490
491
|
_initSqs() {
|
|
@@ -497,7 +498,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
497
498
|
}
|
|
498
499
|
}
|
|
499
500
|
else {
|
|
500
|
-
return new
|
|
501
|
+
return new SQS(this._opts.awsConfig);
|
|
501
502
|
}
|
|
502
503
|
}
|
|
503
504
|
_handleBatchDeleteResults(batch) {
|
|
@@ -536,7 +537,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
536
537
|
let currentBatchSize = 0;
|
|
537
538
|
let currentBatchLength = 0;
|
|
538
539
|
requests.forEach((message) => {
|
|
539
|
-
const messageSize = messageSizeUtils_1.getMessageSize(message);
|
|
540
|
+
const messageSize = (0, messageSizeUtils_1.getMessageSize)(message);
|
|
540
541
|
if (currentBatchLength % AWS_MAX_SEND_BATCH === 0 ||
|
|
541
542
|
currentBatchSize + messageSize >= queueMaximumMessageSize) {
|
|
542
543
|
currentBatchLength = currentBatchSize = 0;
|
package/dist/Types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Message } from './Message';
|
|
3
|
-
import
|
|
3
|
+
import * as SQS from 'aws-sdk/clients/sqs';
|
|
4
|
+
import * as S3 from 'aws-sdk/clients/s3';
|
|
5
|
+
import { AWSError } from 'aws-sdk/lib/error';
|
|
4
6
|
import { BatchResultErrorEntry } from 'aws-sdk/clients/sqs';
|
|
5
7
|
import { IS3Upload } from './s3Utils';
|
|
6
8
|
import { StrictEventEmitter } from './EventEmitterTypesHelper';
|
package/dist/attributeUtils.d.ts
CHANGED
package/dist/attributeUtils.js
CHANGED
|
@@ -42,19 +42,19 @@ const createAttributeValue = (unparsedAttribute) => {
|
|
|
42
42
|
if (unparsedAttribute === undefined || unparsedAttribute === null) {
|
|
43
43
|
unparsedAttribute = '';
|
|
44
44
|
}
|
|
45
|
-
if (ts_type_guards_1.isNumber(unparsedAttribute)) {
|
|
45
|
+
if ((0, ts_type_guards_1.isNumber)(unparsedAttribute)) {
|
|
46
46
|
return {
|
|
47
47
|
DataType: NUMBER_TYPE,
|
|
48
48
|
StringValue: String(unparsedAttribute),
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
else if (ts_type_guards_1.isString(unparsedAttribute)) {
|
|
51
|
+
else if ((0, ts_type_guards_1.isString)(unparsedAttribute)) {
|
|
52
52
|
return {
|
|
53
53
|
DataType: STRING_TYPE,
|
|
54
54
|
StringValue: unparsedAttribute,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
else if (ts_type_guards_1.isBoolean(unparsedAttribute)) {
|
|
57
|
+
else if ((0, ts_type_guards_1.isBoolean)(unparsedAttribute)) {
|
|
58
58
|
return {
|
|
59
59
|
DataType: STRING_TYPE,
|
|
60
60
|
StringValue: `${unparsedAttribute}`,
|
package/dist/gzipUtils.js
CHANGED
|
@@ -6,7 +6,7 @@ const semver_1 = require("semver");
|
|
|
6
6
|
let compress;
|
|
7
7
|
let decompress;
|
|
8
8
|
/* istanbul ignore next */
|
|
9
|
-
if (semver_1.gte(process.version, '10.16.0')) {
|
|
9
|
+
if ((0, semver_1.gte)(process.version, '10.16.0')) {
|
|
10
10
|
const { brotliCompress, brotliDecompress } = require('zlib');
|
|
11
11
|
const { promisify } = require('util');
|
|
12
12
|
compress = promisify(brotliCompress);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import * as SQS from 'aws-sdk/clients/sqs';
|
|
2
|
+
export { SQS };
|
|
3
|
+
import * as S3 from 'aws-sdk/clients/s3';
|
|
4
|
+
export { S3 };
|
|
2
5
|
export { Squiss } from './Squiss';
|
|
3
6
|
export { BodyFormat, IMessageDeletedEventPayload, IMessageDeleteErrorEventPayload, IMessageErrorEventPayload, IMessageS3EventPayload, IMessageToSend, IObject, ISendMessageRequest, ISquissOptions, } from './Types';
|
|
4
7
|
export { IMessageAttributes } from './attributeUtils';
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Message = exports.Squiss = exports.S3 = exports.SQS = void 0;
|
|
4
4
|
/* istanbul ignore file */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const SQS = require("aws-sdk/clients/sqs");
|
|
6
|
+
exports.SQS = SQS;
|
|
7
|
+
const S3 = require("aws-sdk/clients/s3");
|
|
8
|
+
exports.S3 = S3;
|
|
8
9
|
var Squiss_1 = require("./Squiss");
|
|
9
10
|
Object.defineProperty(exports, "Squiss", { enumerable: true, get: function () { return Squiss_1.Squiss; } });
|
|
10
11
|
var Message_1 = require("./Message");
|
package/dist/messageSizeUtils.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSizeInBytes = exports.getMessageSize = void 0;
|
|
4
4
|
const getMessageSize = (message) => {
|
|
5
5
|
const msgAttributesSize = getMsgAttributesSize(message.MessageAttributes);
|
|
6
|
-
const msgBodySize = exports.getSizeInBytes(message.MessageBody);
|
|
6
|
+
const msgBodySize = (0, exports.getSizeInBytes)(message.MessageBody);
|
|
7
7
|
return msgAttributesSize + msgBodySize;
|
|
8
8
|
};
|
|
9
9
|
exports.getMessageSize = getMessageSize;
|
|
@@ -16,12 +16,12 @@ const getMsgAttributesSize = (attributes) => {
|
|
|
16
16
|
attributes = attributes || {};
|
|
17
17
|
for (const attribute in attributes) {
|
|
18
18
|
if (attributes.hasOwnProperty(attribute)) {
|
|
19
|
-
totalMsgAttributesSize += exports.getSizeInBytes(attribute);
|
|
19
|
+
totalMsgAttributesSize += (0, exports.getSizeInBytes)(attribute);
|
|
20
20
|
const val = attributes[attribute];
|
|
21
|
-
totalMsgAttributesSize += exports.getSizeInBytes(val.DataType);
|
|
22
|
-
totalMsgAttributesSize += exports.getSizeInBytes(val.StringValue);
|
|
21
|
+
totalMsgAttributesSize += (0, exports.getSizeInBytes)(val.DataType);
|
|
22
|
+
totalMsgAttributesSize += (0, exports.getSizeInBytes)(val.StringValue);
|
|
23
23
|
// @ts-ignore
|
|
24
|
-
totalMsgAttributesSize += exports.getSizeInBytes(val.BinaryValue);
|
|
24
|
+
totalMsgAttributesSize += (0, exports.getSizeInBytes)(val.BinaryValue);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return totalMsgAttributesSize;
|
package/dist/s3Utils.d.ts
CHANGED
package/dist/s3Utils.js
CHANGED
|
@@ -5,8 +5,8 @@ const uuid_1 = require("uuid");
|
|
|
5
5
|
const messageSizeUtils_1 = require("./messageSizeUtils");
|
|
6
6
|
exports.S3_MARKER = '__SQS_S3__';
|
|
7
7
|
const uploadBlob = (s3, bucket, blob, prefix) => {
|
|
8
|
-
const key = `${prefix}${uuid_1.v4()}`;
|
|
9
|
-
const size = messageSizeUtils_1.getSizeInBytes(blob);
|
|
8
|
+
const key = `${prefix}${(0, uuid_1.v4)()}`;
|
|
9
|
+
const size = (0, messageSizeUtils_1.getSizeInBytes)(blob);
|
|
10
10
|
return s3.putObject({
|
|
11
11
|
Body: blob,
|
|
12
12
|
Bucket: bucket,
|
package/package.json
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiss-ts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "High-volume SQS poller",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "^6 || ^8 || ^10 || ^12 || ^14 || ^16"
|
|
8
|
+
"node": "^6 || ^8 || ^10 || ^12 || ^14 || ^16 || ^18"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"postinstall": "node -e \"const semver = require('semver');
|
|
11
|
+
"postinstall": " node -e \"const semver = require('semver');const relevant = semver.lt(process.version, '10.16.0');if (relevant == false) {process.exit(0);}try {require('iltorb'); process.exit(0);} catch (err){process.exit(1);}\" || yarn add --pure-lockfile --ignore-engines iltorb@2.4.3",
|
|
12
12
|
"clean": "rm -rf node_modules build coverage dist",
|
|
13
|
-
"build": "
|
|
13
|
+
"build": "yarn lint && yarn compile",
|
|
14
14
|
"compile": "tsc",
|
|
15
|
-
"test": "
|
|
15
|
+
"test": "yarn lint && yarn mocha",
|
|
16
16
|
"mocha": "_mocha --opts src/test/mocha.opts",
|
|
17
|
-
"cover": "nyc --reporter=lcov --reporter=text-summary npm run
|
|
18
|
-
"lint": "tslint -c tslint.json \"src/**/*.ts\" \"test/**/*.ts\""
|
|
17
|
+
"cover": "nyc --reporter=lcov --reporter=text-summary npm run mocha",
|
|
18
|
+
"lint": "tslint -c tslint.json \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
19
|
+
"benchmark": "tsc --extendedDiagnostics --incremental false"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
@@ -47,9 +48,10 @@
|
|
|
47
48
|
},
|
|
48
49
|
"homepage": "https://github.com/PruvoNet/squiss-ts#readme",
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"aws-sdk": "
|
|
51
|
+
"aws-sdk": "2.814.0",
|
|
52
|
+
"iltorb": "2.4.3",
|
|
51
53
|
"linked-list": "^2.1.0",
|
|
52
|
-
"semver": "
|
|
54
|
+
"semver": "6.3.0",
|
|
53
55
|
"ts-type-guards": "^0.7.0",
|
|
54
56
|
"uuid": "^8.3.2"
|
|
55
57
|
},
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
"@types/mocha": "^8.0.0",
|
|
62
64
|
"@types/node": "^14.0.26",
|
|
63
65
|
"@types/proxyquire": "^1.3.28",
|
|
64
|
-
"@types/semver": "
|
|
66
|
+
"@types/semver": "7.3.1",
|
|
65
67
|
"@types/uuid": "^8.0.0",
|
|
66
68
|
"chai": "^4.2.0",
|
|
67
69
|
"chai-as-promised": "^7.1.1",
|
|
@@ -70,11 +72,11 @@
|
|
|
70
72
|
"mocha": "6.2.2",
|
|
71
73
|
"nyc": "14.1.1",
|
|
72
74
|
"proxyquire": "^2.1.3",
|
|
73
|
-
"sinon": "^
|
|
75
|
+
"sinon": "^7.5.0",
|
|
74
76
|
"sinon-chai": "^3.5.0",
|
|
75
77
|
"source-map-support": "^0.5.19",
|
|
76
|
-
"ts-node": "^
|
|
77
|
-
"tslint": "^6.1.
|
|
78
|
-
"typescript": "
|
|
78
|
+
"ts-node": "^8.10.2",
|
|
79
|
+
"tslint": "^6.1.3",
|
|
80
|
+
"typescript": "4.6.4"
|
|
79
81
|
}
|
|
80
82
|
}
|