squiss-ts 5.5.0 → 5.6.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/README.md +2 -2
- package/dist/Message.d.ts +6 -7
- package/dist/Message.js +1 -1
- package/dist/Squiss.d.ts +1 -1
- package/dist/Squiss.js +21 -11
- package/dist/TimeoutExtender.d.ts +1 -1
- package/dist/TimeoutExtender.js +4 -1
- package/dist/Types.d.ts +0 -1
- package/dist/messageSizeUtils.d.ts +0 -6
- package/dist/messageSizeUtils.js +1 -1
- package/package.json +26 -25
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/squiss-ts)
|
|
2
2
|
[](https://travis-ci.com/PruvoNet/squiss-ts)
|
|
3
3
|
[](https://travis-ci.com/PruvoNet/squiss-ts)
|
|
4
|
-
[](https://qlty.sh/gh/PruvoNet/projects/squiss-ts)
|
|
5
|
+
[](https://qlty.sh/gh/PruvoNet/projects/squiss-ts)
|
|
6
6
|
[](https://snyk.io/test/github/PruvoNet/squiss-ts?targetFile=package.json)
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
package/dist/Message.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { BatchResultErrorEntry, Message as SQSMessage, SQSServiceException } from '@aws-sdk/client-sqs';
|
|
3
2
|
import { S3 } from '@aws-sdk/client-s3';
|
|
4
3
|
import { BodyFormat, Squiss } from '.';
|
|
@@ -34,7 +33,7 @@ declare const Message_base: new () => MessageEmitter;
|
|
|
34
33
|
export declare class Message extends Message_base {
|
|
35
34
|
private static formatMessage;
|
|
36
35
|
raw: SQSMessage;
|
|
37
|
-
body?:
|
|
36
|
+
body?: any;
|
|
38
37
|
subject?: string;
|
|
39
38
|
topicArn?: string;
|
|
40
39
|
topicName?: string;
|
|
@@ -42,14 +41,14 @@ export declare class Message extends Message_base {
|
|
|
42
41
|
sqsAttributes: {
|
|
43
42
|
[k: string]: string;
|
|
44
43
|
};
|
|
45
|
-
private _squiss;
|
|
44
|
+
private readonly _squiss;
|
|
46
45
|
private _handled;
|
|
47
|
-
private _opts;
|
|
46
|
+
private readonly _opts;
|
|
48
47
|
private _deleteCallback?;
|
|
49
|
-
private _s3Retriever;
|
|
50
|
-
private _s3Retain;
|
|
48
|
+
private readonly _s3Retriever;
|
|
49
|
+
private readonly _s3Retain;
|
|
51
50
|
constructor(opts: IMessageOpts);
|
|
52
|
-
parse(): Promise<
|
|
51
|
+
parse(): Promise<any>;
|
|
53
52
|
isHandled(): boolean;
|
|
54
53
|
del(): Promise<void>;
|
|
55
54
|
keep(): void;
|
package/dist/Message.js
CHANGED
|
@@ -26,7 +26,7 @@ class Message extends events_1.EventEmitter {
|
|
|
26
26
|
this.subject = unwrapped.Subject;
|
|
27
27
|
this.topicArn = unwrapped.TopicArn;
|
|
28
28
|
if (this.topicArn) {
|
|
29
|
-
this.topicName = unwrapped.TopicArn.
|
|
29
|
+
this.topicName = unwrapped.TopicArn.substring(unwrapped.TopicArn.lastIndexOf(':') + 1);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
this._squiss = opts.squiss;
|
package/dist/Squiss.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class Squiss extends Squiss_base {
|
|
|
21
21
|
private _delQueue;
|
|
22
22
|
private _delTimer;
|
|
23
23
|
private _activeReq;
|
|
24
|
-
constructor(opts?: ISquissOptions
|
|
24
|
+
constructor(opts?: ISquissOptions);
|
|
25
25
|
changeMessageVisibility(msg: Message | string, timeoutInSeconds: number): Promise<void>;
|
|
26
26
|
createQueue(): Promise<string>;
|
|
27
27
|
deleteMessage(msg: Message): Promise<void>;
|
package/dist/Squiss.js
CHANGED
|
@@ -30,9 +30,12 @@ class Squiss extends events_1.EventEmitter {
|
|
|
30
30
|
this._queueVisibilityTimeout = 0;
|
|
31
31
|
this._queueMaximumMessageSize = 0;
|
|
32
32
|
this._delQueue = new Map();
|
|
33
|
-
this._opts =
|
|
33
|
+
this._opts = {
|
|
34
|
+
...Types_1.optDefaults,
|
|
35
|
+
...(opts ?? {}),
|
|
36
|
+
};
|
|
34
37
|
this._initOpts();
|
|
35
|
-
this._queueUrl = this._opts.queueUrl
|
|
38
|
+
this._queueUrl = this._opts.queueUrl ?? '';
|
|
36
39
|
this.sqs = this._initSqs();
|
|
37
40
|
}
|
|
38
41
|
changeMessageVisibility(msg, timeoutInSeconds) {
|
|
@@ -164,7 +167,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
164
167
|
QueueUrl: queueUrl,
|
|
165
168
|
});
|
|
166
169
|
}).then((res) => {
|
|
167
|
-
if (!res.Attributes
|
|
170
|
+
if (!res.Attributes?.VisibilityTimeout) {
|
|
168
171
|
throw new Error('SQS.GetQueueAttributes call did not return expected shape. Response: ' +
|
|
169
172
|
JSON.stringify(res));
|
|
170
173
|
}
|
|
@@ -182,7 +185,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
182
185
|
QueueUrl: queueUrl,
|
|
183
186
|
});
|
|
184
187
|
}).then((res) => {
|
|
185
|
-
if (!res.Attributes
|
|
188
|
+
if (!res.Attributes?.MaximumMessageSize) {
|
|
186
189
|
throw new Error('SQS.GetQueueAttributes call did not return expected shape. Response: ' +
|
|
187
190
|
JSON.stringify(res));
|
|
188
191
|
}
|
|
@@ -279,7 +282,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
279
282
|
}
|
|
280
283
|
let resolved = false;
|
|
281
284
|
let timer;
|
|
282
|
-
const result = await new Promise(
|
|
285
|
+
const result = await new Promise((resolve) => {
|
|
283
286
|
this.on('drained', () => {
|
|
284
287
|
if (!resolved) {
|
|
285
288
|
resolved = true;
|
|
@@ -462,8 +465,15 @@ class Squiss extends events_1.EventEmitter {
|
|
|
462
465
|
async _deleteXMessages(x) {
|
|
463
466
|
const delQueue = this._delQueue;
|
|
464
467
|
const iterator = delQueue.entries();
|
|
465
|
-
|
|
468
|
+
let length = x ?? delQueue.size;
|
|
469
|
+
/* istanbul ignore next */
|
|
470
|
+
length = length <= delQueue.size ? length : delQueue.size;
|
|
471
|
+
const delBatch = Array.from({ length }, function () {
|
|
466
472
|
const element = this.next().value;
|
|
473
|
+
/* istanbul ignore next */
|
|
474
|
+
if (!element) {
|
|
475
|
+
throw new Error('Unexpected undefined element in delete queue');
|
|
476
|
+
}
|
|
467
477
|
delQueue.delete(element[0]);
|
|
468
478
|
return element[1];
|
|
469
479
|
}, iterator);
|
|
@@ -482,7 +492,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
482
492
|
_prepareMessageParams(message, delay, attributes) {
|
|
483
493
|
const messageStr = (0, ts_type_guards_1.isString)(message) ? message : JSON.stringify(message);
|
|
484
494
|
const params = { MessageBody: messageStr, DelaySeconds: delay };
|
|
485
|
-
attributes =
|
|
495
|
+
attributes = { ...attributes };
|
|
486
496
|
params.MessageGroupId = attributes.FIFO_MessageGroupId;
|
|
487
497
|
delete attributes.FIFO_MessageGroupId;
|
|
488
498
|
params.MessageDeduplicationId = attributes.FIFO_MessageDeduplicationId;
|
|
@@ -515,7 +525,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
515
525
|
.then((uploadData) => {
|
|
516
526
|
this.emit('s3Upload', uploadData);
|
|
517
527
|
params.MessageBody = JSON.stringify(uploadData);
|
|
518
|
-
params.MessageAttributes = params.MessageAttributes
|
|
528
|
+
params.MessageAttributes = params.MessageAttributes ?? {};
|
|
519
529
|
params.MessageAttributes[s3Utils_1.S3_MARKER] = {
|
|
520
530
|
StringValue: `${uploadData.uploadSize}`,
|
|
521
531
|
DataType: 'Number',
|
|
@@ -525,10 +535,10 @@ class Squiss extends events_1.EventEmitter {
|
|
|
525
535
|
});
|
|
526
536
|
}
|
|
527
537
|
_prepareMessageRequest(message, delay, attributes) {
|
|
528
|
-
if (attributes
|
|
538
|
+
if (attributes?.[gzipUtils_1.GZIP_MARKER]) {
|
|
529
539
|
return Promise.reject(new Error(`Using of internal attribute ${gzipUtils_1.GZIP_MARKER} is not allowed`));
|
|
530
540
|
}
|
|
531
|
-
if (attributes
|
|
541
|
+
if (attributes?.[s3Utils_1.S3_MARKER]) {
|
|
532
542
|
return Promise.reject(new Error(`Using of internal attribute ${s3Utils_1.S3_MARKER} is not allowed`));
|
|
533
543
|
}
|
|
534
544
|
return this._prepareMessageParams(message, delay, attributes)
|
|
@@ -608,7 +618,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
608
618
|
return (data) => {
|
|
609
619
|
let gotMessages = true;
|
|
610
620
|
this._activeReq = undefined;
|
|
611
|
-
if (data
|
|
621
|
+
if (data?.Messages) {
|
|
612
622
|
this.emit('gotMessages', data.Messages.length);
|
|
613
623
|
this._emitMessages(data.Messages);
|
|
614
624
|
}
|
|
@@ -20,7 +20,7 @@ export declare class TimeoutExtender {
|
|
|
20
20
|
readonly _index: MessageIndex;
|
|
21
21
|
_linkedList: LinkedList<Node>;
|
|
22
22
|
_opts: ITimeoutExtenderOptions;
|
|
23
|
-
private _squiss;
|
|
23
|
+
private readonly _squiss;
|
|
24
24
|
private _timer;
|
|
25
25
|
private readonly _visTimeout;
|
|
26
26
|
private readonly _stopAfter;
|
package/dist/TimeoutExtender.js
CHANGED
|
@@ -19,7 +19,10 @@ const optDefaults = {
|
|
|
19
19
|
};
|
|
20
20
|
class TimeoutExtender {
|
|
21
21
|
constructor(squiss, opts) {
|
|
22
|
-
this._opts =
|
|
22
|
+
this._opts = {
|
|
23
|
+
...optDefaults,
|
|
24
|
+
...(opts || {}),
|
|
25
|
+
};
|
|
23
26
|
this._index = {};
|
|
24
27
|
this._timer = undefined;
|
|
25
28
|
this._squiss = squiss;
|
package/dist/Types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Message } from './Message';
|
|
3
2
|
import { SQSClientConfig, BatchResultErrorEntry, SQS, SQSServiceException, MessageAttributeValue, QueueAttributeName } from '@aws-sdk/client-sqs';
|
|
4
3
|
import { S3, S3ClientConfig } from '@aws-sdk/client-s3';
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="mocha" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
/// <reference types="node" />
|
|
7
1
|
import { ISendMessageRequest } from './index';
|
|
8
2
|
export declare const getMessageSize: (message: ISendMessageRequest) => number;
|
|
9
3
|
export declare const getSizeInBytes: (obj?: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer) => number;
|
package/dist/messageSizeUtils.js
CHANGED
|
@@ -15,7 +15,7 @@ const getMsgAttributesSize = (attributes) => {
|
|
|
15
15
|
let totalMsgAttributesSize = 0;
|
|
16
16
|
attributes = attributes || {};
|
|
17
17
|
for (const attribute in attributes) {
|
|
18
|
-
if (
|
|
18
|
+
if (Object.hasOwn(attributes, attribute)) {
|
|
19
19
|
totalMsgAttributesSize += (0, exports.getSizeInBytes)(attribute);
|
|
20
20
|
const val = attributes[attribute];
|
|
21
21
|
totalMsgAttributesSize += (0, exports.getSizeInBytes)(val.DataType);
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiss-ts",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.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": "^18 || ^20 || ^22"
|
|
8
|
+
"node": "^18 || ^20 || ^22 || ^24"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "rm -rf .nyc_output coverage dist",
|
|
12
12
|
"build": "yarn lint && yarn compile",
|
|
13
13
|
"compile": "tsc",
|
|
14
14
|
"test": "yarn lint && yarn mocha",
|
|
15
|
+
"ci": "yarn build && yarn cover",
|
|
15
16
|
"cover": "yarn clean && yarn nyc yarn mocha",
|
|
16
|
-
"lint": "eslint
|
|
17
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
17
18
|
"benchmark": "tsc --extendedDiagnostics --incremental false",
|
|
18
19
|
"e2e:start": "docker compose -f e2e/docker-compose.yml up &",
|
|
19
20
|
"e2e:stop": "docker compose -f e2e/docker-compose.yml down &"
|
|
@@ -48,40 +49,40 @@
|
|
|
48
49
|
},
|
|
49
50
|
"homepage": "https://github.com/PruvoNet/squiss-ts#readme",
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@aws-sdk/client-s3": "^3.
|
|
52
|
-
"@aws-sdk/client-sqs": "^3.
|
|
53
|
-
"@aws-sdk/types": "^3.
|
|
52
|
+
"@aws-sdk/client-s3": "^3.927.0",
|
|
53
|
+
"@aws-sdk/client-sqs": "^3.927.0",
|
|
54
|
+
"@aws-sdk/types": "^3.922.0",
|
|
54
55
|
"linked-list": "2.1.0",
|
|
55
56
|
"ts-type-guards": "^0.7.0",
|
|
56
|
-
"uuid": "
|
|
57
|
+
"uuid": "11.1.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
60
|
-
"@types/chai": "
|
|
61
|
-
"@types/chai-as-promised": "
|
|
62
|
-
"@types/mocha": "^10.0.
|
|
63
|
-
"@types/node": "^
|
|
61
|
+
"@types/chai": "4.3.20",
|
|
62
|
+
"@types/chai-as-promised": "7.1.8",
|
|
63
|
+
"@types/mocha": "^10.0.10",
|
|
64
|
+
"@types/node": "^24.10.0",
|
|
64
65
|
"@types/proxyquire": "^1.3.31",
|
|
65
|
-
"@
|
|
66
|
-
"@typescript-eslint/
|
|
67
|
-
"@typescript-eslint/parser": "^7.3.1",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
|
67
|
+
"@typescript-eslint/parser": "^8.46.3",
|
|
68
68
|
"chai": "4.3.10",
|
|
69
|
-
"chai-as-promised": "
|
|
69
|
+
"chai-as-promised": "7.1.1",
|
|
70
70
|
"delay": "5.0.0",
|
|
71
71
|
"dirty-chai": "^2.0.1",
|
|
72
|
-
"eslint": "^
|
|
73
|
-
"eslint-config-prettier": "^
|
|
74
|
-
"eslint-plugin-import": "^2.
|
|
75
|
-
"eslint-plugin-jsdoc": "
|
|
72
|
+
"eslint": "^9.39.1",
|
|
73
|
+
"eslint-config-prettier": "^10.1.8",
|
|
74
|
+
"eslint-plugin-import": "^2.32.0",
|
|
75
|
+
"eslint-plugin-jsdoc": "50.8.0",
|
|
76
76
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
77
|
-
"mocha": "^
|
|
78
|
-
"nyc": "^
|
|
77
|
+
"mocha": "^11.7.5",
|
|
78
|
+
"nyc": "^17.1.0",
|
|
79
79
|
"proxyquire": "^2.1.3",
|
|
80
|
-
"sinon": "
|
|
81
|
-
"sinon-chai": "
|
|
80
|
+
"sinon": "17.0.1",
|
|
81
|
+
"sinon-chai": "3.7.0",
|
|
82
82
|
"source-map-support": "^0.5.21",
|
|
83
83
|
"ts-node": "^10.9.2",
|
|
84
|
-
"typescript": "^5.
|
|
84
|
+
"typescript": "^5.9.3",
|
|
85
|
+
"typescript-eslint": "^8.46.3"
|
|
85
86
|
},
|
|
86
87
|
"nyc": {
|
|
87
88
|
"extends": "@istanbuljs/nyc-config-typescript",
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
"src/test/**",
|
|
92
93
|
"e2e**",
|
|
93
94
|
"build**",
|
|
94
|
-
".
|
|
95
|
+
"eslint.config.js"
|
|
95
96
|
],
|
|
96
97
|
"reporter": [
|
|
97
98
|
"html",
|