squiss-ts 5.5.1 → 5.7.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  [![Npm Version](https://img.shields.io/npm/v/squiss-ts.svg?style=popout)](https://www.npmjs.com/package/squiss-ts)
2
2
  [![node](https://img.shields.io/node/v-lts/squiss-ts)](https://travis-ci.com/PruvoNet/squiss-ts)
3
3
  [![Build Status](https://github.com/PruvoNet/squiss-ts/actions/workflows/ci.yml/badge.svg?branch=master)](https://travis-ci.com/PruvoNet/squiss-ts)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/177b18abdb55fdf90cf8/test_coverage)](https://codeclimate.com/github/PruvoNet/squiss-ts/test_coverage)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/177b18abdb55fdf90cf8/maintainability)](https://codeclimate.com/github/PruvoNet/squiss-ts/maintainability)
4
+ [![Code Coverage](https://qlty.sh/gh/PruvoNet/projects/squiss-ts/coverage.svg)](https://qlty.sh/gh/PruvoNet/projects/squiss-ts)
5
+ [![Maintainability](https://qlty.sh/gh/PruvoNet/projects/squiss-ts/maintainability.svg)](https://qlty.sh/gh/PruvoNet/projects/squiss-ts)
6
6
  [![Known Vulnerabilities](https://snyk.io/test/github/PruvoNet/squiss-ts/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PruvoNet/squiss-ts?targetFile=package.json)
7
7
 
8
8
  <p align="center">
package/dist/Message.d.ts CHANGED
@@ -33,7 +33,7 @@ declare const Message_base: new () => MessageEmitter;
33
33
  export declare class Message extends Message_base {
34
34
  private static formatMessage;
35
35
  raw: SQSMessage;
36
- body?: string | any;
36
+ body?: any;
37
37
  subject?: string;
38
38
  topicArn?: string;
39
39
  topicName?: string;
@@ -41,14 +41,14 @@ export declare class Message extends Message_base {
41
41
  sqsAttributes: {
42
42
  [k: string]: string;
43
43
  };
44
- private _squiss;
44
+ private readonly _squiss;
45
45
  private _handled;
46
- private _opts;
46
+ private readonly _opts;
47
47
  private _deleteCallback?;
48
- private _s3Retriever;
49
- private _s3Retain;
48
+ private readonly _s3Retriever;
49
+ private readonly _s3Retain;
50
50
  constructor(opts: IMessageOpts);
51
- parse(): Promise<string | any>;
51
+ parse(): Promise<any>;
52
52
  isHandled(): boolean;
53
53
  del(): Promise<void>;
54
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.substr(unwrapped.TopicArn.lastIndexOf(':') + 1);
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 | undefined);
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 = Object.assign({}, Types_1.optDefaults, 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 || !res.Attributes.VisibilityTimeout) {
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 || !res.Attributes.MaximumMessageSize) {
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(async (resolve) => {
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
- const delBatch = Array.from({ length: x || delQueue.size }, function () {
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 = Object.assign({}, 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 && attributes[gzipUtils_1.GZIP_MARKER]) {
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 && attributes[s3Utils_1.S3_MARKER]) {
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 && data.Messages) {
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;
@@ -19,7 +19,10 @@ const optDefaults = {
19
19
  };
20
20
  class TimeoutExtender {
21
21
  constructor(squiss, opts) {
22
- this._opts = Object.assign({}, optDefaults, opts || {});
22
+ this._opts = {
23
+ ...optDefaults,
24
+ ...(opts || {}),
25
+ };
23
26
  this._index = {};
24
27
  this._timer = undefined;
25
28
  this._squiss = squiss;
@@ -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 (attributes.hasOwnProperty(attribute)) {
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.5.1",
3
+ "version": "5.7.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": "^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 -c .eslintrc.js --ext .ts \"src/**/*.ts\"",
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.621.0",
52
- "@aws-sdk/client-sqs": "^3.621.0",
53
- "@aws-sdk/types": "^3.609.0",
52
+ "@aws-sdk/client-s3": "^3.974.0",
53
+ "@aws-sdk/client-sqs": "^3.974.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": "^10.0.0"
57
+ "uuid": "11.1.1"
57
58
  },
58
59
  "devDependencies": {
59
60
  "@istanbuljs/nyc-config-typescript": "1.0.2",
60
- "@types/chai": "^4.3.16",
61
- "@types/chai-as-promised": "^7.1.8",
62
- "@types/mocha": "^10.0.7",
63
- "@types/node": "^18.19.42",
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
- "@types/uuid": "^10.0.0",
66
- "@typescript-eslint/eslint-plugin": "^7.18.0",
67
- "@typescript-eslint/parser": "^7.18.0",
66
+ "@typescript-eslint/eslint-plugin": "^8.46.3",
67
+ "@typescript-eslint/parser": "^8.46.3",
68
68
  "chai": "4.3.10",
69
69
  "chai-as-promised": "7.1.1",
70
70
  "delay": "5.0.0",
71
71
  "dirty-chai": "^2.0.1",
72
- "eslint": "^8.57.0",
73
- "eslint-config-prettier": "^9.1.0",
74
- "eslint-plugin-import": "^2.29.1",
75
- "eslint-plugin-jsdoc": "^48.9.3",
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": "^10.7.0",
78
- "nyc": "^17.0.0",
77
+ "mocha": "^11.7.5",
78
+ "nyc": "^17.1.0",
79
79
  "proxyquire": "^2.1.3",
80
80
  "sinon": "17.0.1",
81
81
  "sinon-chai": "3.7.0",
82
82
  "source-map-support": "^0.5.21",
83
83
  "ts-node": "^10.9.2",
84
- "typescript": "^5.5.4"
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
- ".eslintrc.js"
95
+ "eslint.config.js"
95
96
  ],
96
97
  "reporter": [
97
98
  "html",