ac-sqs 4.0.3 → 4.0.5
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/.github/CODEOWNERS +9 -0
- package/CHANGELOG.md +18 -0
- package/README.md +0 -1
- package/SECURITY.md +22 -0
- package/eslint.config.js +12 -6
- package/index.js +34 -34
- package/package.json +8 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Code Owners
|
|
2
|
+
#
|
|
3
|
+
# This file defines who is responsible for code in this repository.
|
|
4
|
+
# Reviews from code owners are automatically requested for pull requests.
|
|
5
|
+
#
|
|
6
|
+
# More info: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
|
7
|
+
|
|
8
|
+
# Default owner for everything in the repo
|
|
9
|
+
* @AdmiralCloud/ac-maintainer-backend
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.5](https://github.com/admiralcloud/ac-sqs/compare/v4.0.4..v4.0.5) (2026-03-21 11:11:45)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fix
|
|
6
|
+
|
|
7
|
+
* **Misc:** Package updates | MP | [5d39527151c36c166599414912d2b4266a53385c](https://github.com/admiralcloud/ac-sqs/commit/5d39527151c36c166599414912d2b4266a53385c)
|
|
8
|
+
Package updates
|
|
9
|
+
Related issues:
|
|
10
|
+
|
|
11
|
+
## [4.0.4](https://github.com/admiralcloud/ac-sqs/compare/v4.0.3..v4.0.4) (2026-02-24 19:19:56)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fix
|
|
15
|
+
|
|
16
|
+
* **Misc:** Package updates | MP | [7f3ca8d2845db6ef4dd929b2817982300a9312a7](https://github.com/admiralcloud/ac-sqs/commit/7f3ca8d2845db6ef4dd929b2817982300a9312a7)
|
|
17
|
+
Package updates incl ESLint 9 -> 10 and lint fixes
|
|
18
|
+
Related issues:
|
|
19
|
+
|
|
2
20
|
## [4.0.3](https://github.com/admiralcloud/ac-sqs/compare/v4.0.2..v4.0.3) (2026-02-03 08:28:54)
|
|
3
21
|
|
|
4
22
|
|
package/README.md
CHANGED
|
@@ -134,7 +134,6 @@ See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_Ge
|
|
|
134
134
|
# Misc
|
|
135
135
|
## Links
|
|
136
136
|
- [Website](https://www.admiralcloud.com/)
|
|
137
|
-
- [Facebook](https://www.facebook.com/MediaAssetManagement/)
|
|
138
137
|
|
|
139
138
|
## License
|
|
140
139
|
[MIT License](https://opensource.org/licenses/MIT) Copyright © 2009-present, AdmiralCloud AG, Mark Poepping
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
We only provide security updates for the latest version of this project.
|
|
6
|
+
|
|
7
|
+
If you are using an older version, please upgrade to the latest release to receive security fixes.
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
If you discover a security vulnerability, please report it by creating a GitHub issue in this repository.
|
|
12
|
+
|
|
13
|
+
Please include the following information:
|
|
14
|
+
|
|
15
|
+
- Description of the vulnerability
|
|
16
|
+
- Steps to reproduce the issue
|
|
17
|
+
- Potential impact
|
|
18
|
+
- Any suggested fixes (if you have them)
|
|
19
|
+
|
|
20
|
+
We will review your report and respond as soon as possible.
|
|
21
|
+
|
|
22
|
+
Thank you for helping keep AdmiralCloud and our users safe!
|
package/eslint.config.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
const globals = require('globals')
|
|
1
|
+
const globals = require('globals')
|
|
2
2
|
|
|
3
3
|
module.exports = [
|
|
4
4
|
{
|
|
5
|
+
files: ['index.js', 'test/test.js'],
|
|
5
6
|
languageOptions: {
|
|
6
7
|
ecmaVersion: 2022,
|
|
7
8
|
sourceType: 'module',
|
|
8
9
|
globals: {
|
|
9
10
|
...globals.commonjs,
|
|
10
|
-
...globals.
|
|
11
|
+
...globals.es2015,
|
|
11
12
|
...globals.node,
|
|
12
13
|
expect: 'readonly',
|
|
13
14
|
describe: 'readonly',
|
|
@@ -15,14 +16,19 @@ module.exports = [
|
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
rules: {
|
|
19
|
+
'no-const-assign': 'error',
|
|
18
20
|
'space-before-function-paren': 'off',
|
|
19
21
|
'no-extra-semi': 'off',
|
|
20
22
|
'object-curly-spacing': ['error', 'always'],
|
|
21
23
|
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
24
|
+
'block-spacing': 'error',
|
|
22
25
|
'no-useless-escape': 'off',
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
27
|
+
'no-unused-vars': 'error',
|
|
28
|
+
'eqeqeq': 'error',
|
|
29
|
+
'no-var': 'error',
|
|
30
|
+
'curly': 'error',
|
|
31
|
+
'prefer-const': ['error', { ignoreReadBeforeAssign: true }]
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
|
-
]
|
|
34
|
+
]
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const { SQSClient, SendMessageCommand, SendMessageBatchCommand, ReceiveMessageCo
|
|
|
6
6
|
const { S3Client, GetObjectCommand, PutObjectCommand, DeleteObjectsCommand } = require("@aws-sdk/client-s3")
|
|
7
7
|
|
|
8
8
|
class ACSQS {
|
|
9
|
-
constructor({ region = 'eu-central-1', account, availableLists, useS3 = { enabled: true, bucket: undefined }, messageThreshold = 1000e3,
|
|
9
|
+
constructor({ region = 'eu-central-1', account, availableLists, useS3 = { enabled: true, bucket: undefined }, messageThreshold = 1000e3, logger = console, throwError = false, maxConcurrentMessages = 3000 }) {
|
|
10
10
|
this.region = region
|
|
11
11
|
this.account = account
|
|
12
12
|
this.availableLists = availableLists
|
|
@@ -38,18 +38,18 @@ class ACSQS {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async startBatchExtendTimer() {
|
|
41
|
-
if (this.batchExtendRunning) return
|
|
41
|
+
if (this.batchExtendRunning) { return }
|
|
42
42
|
|
|
43
43
|
this.batchExtendRunning = true
|
|
44
44
|
this.stopBatchExtend = false
|
|
45
45
|
|
|
46
46
|
while (true) {
|
|
47
47
|
try {
|
|
48
|
-
if (this.stopBatchExtend) break
|
|
48
|
+
if (this.stopBatchExtend) { break }
|
|
49
49
|
|
|
50
50
|
await sleep(this.batchExtendInterval)
|
|
51
51
|
|
|
52
|
-
if (this.stopBatchExtend) break
|
|
52
|
+
if (this.stopBatchExtend) { break }
|
|
53
53
|
|
|
54
54
|
await this.processBatchExtensions()
|
|
55
55
|
}
|
|
@@ -68,7 +68,7 @@ class ACSQS {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
async processBatchExtensions() {
|
|
71
|
-
if (this.visibilityManagement.size === 0) return
|
|
71
|
+
if (this.visibilityManagement.size === 0) { return }
|
|
72
72
|
|
|
73
73
|
// Group messages by queue for batch processing
|
|
74
74
|
const queueGroups = new Map()
|
|
@@ -76,7 +76,7 @@ class ACSQS {
|
|
|
76
76
|
|
|
77
77
|
for (const [messageId, messageData] of this.visibilityManagement) {
|
|
78
78
|
// Check if message still exists in tracking (might have been deleted)
|
|
79
|
-
if (!this.visibilityManagement.has(messageId)) continue
|
|
79
|
+
if (!this.visibilityManagement.has(messageId)) { continue }
|
|
80
80
|
|
|
81
81
|
// Check if message needs extension
|
|
82
82
|
if (now >= messageData.nextExtendTime) {
|
|
@@ -101,10 +101,10 @@ class ACSQS {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
async extendVisibilityBatch(queueName, messages) {
|
|
104
|
-
if (messages.length === 0) return
|
|
104
|
+
if (messages.length === 0) { return }
|
|
105
105
|
|
|
106
106
|
const config = _.find(this.availableLists, { name: queueName })
|
|
107
|
-
if (!config) return
|
|
107
|
+
if (!config) { return }
|
|
108
108
|
|
|
109
109
|
const chunks = this.chunkMessages(messages)
|
|
110
110
|
await this.processAllChunks(queueName, chunks, config)
|
|
@@ -129,7 +129,7 @@ class ACSQS {
|
|
|
129
129
|
|
|
130
130
|
async processChunk(queueName, chunk, config, chunkNumber, totalChunks) {
|
|
131
131
|
const validChunk = this.getValidChunk(chunk)
|
|
132
|
-
if (validChunk.length === 0) return
|
|
132
|
+
if (validChunk.length === 0) { return }
|
|
133
133
|
|
|
134
134
|
const sqsParams = await this.buildSQSParams(validChunk, config)
|
|
135
135
|
await this.executeChunkWithRetry(queueName, validChunk, sqsParams, config, chunkNumber, totalChunks)
|
|
@@ -219,7 +219,7 @@ class ACSQS {
|
|
|
219
219
|
|
|
220
220
|
for (const messageData of validChunk) {
|
|
221
221
|
// Check again if message still exists (might have been deleted during AWS call)
|
|
222
|
-
if (!this.visibilityManagement.has(messageData.messageId)) continue
|
|
222
|
+
if (!this.visibilityManagement.has(messageData.messageId)) { continue }
|
|
223
223
|
|
|
224
224
|
if (successful.has(messageData.messageId)) {
|
|
225
225
|
this.updateSuccessfulMessage(messageData, visibilityTimeout, queueName, config)
|
|
@@ -289,7 +289,7 @@ class ACSQS {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// Legacy method for backwards compatibility - now uses batch processing
|
|
292
|
-
async extendVisibility({ name, message
|
|
292
|
+
async extendVisibility({ name, message }) {
|
|
293
293
|
const config = _.find(this.availableLists, { name })
|
|
294
294
|
if (!config) {
|
|
295
295
|
this.logger.error('AWS | extendVisibility | configurationMissing | %s', name)
|
|
@@ -311,7 +311,7 @@ class ACSQS {
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
async getAllLists({ throwError = false } = {}) {
|
|
314
|
-
|
|
314
|
+
const response = []
|
|
315
315
|
for (const list of this.availableLists) {
|
|
316
316
|
const attr = await this.getQueueAttributes({ name: list?.name, attributes: ['QueueArn'], throwError })
|
|
317
317
|
response.push({ name: list?.name, value: attr?.Attributes?.QueueArn })
|
|
@@ -340,18 +340,18 @@ class ACSQS {
|
|
|
340
340
|
throw new Error('configurationForListMissing')
|
|
341
341
|
}
|
|
342
342
|
const { queueUrl } = this.getQueueUrl(config)
|
|
343
|
-
|
|
343
|
+
const sqsParams = {
|
|
344
344
|
QueueUrl: queueUrl,
|
|
345
345
|
AttributeNames: attributes
|
|
346
346
|
}
|
|
347
|
-
if (config.debug) this.logger.debug('ACSQS | getQueueAttributes | Payload %j', sqsParams)
|
|
347
|
+
if (config.debug) { this.logger.debug('ACSQS | getQueueAttributes | Payload %j', sqsParams) }
|
|
348
348
|
const command = new GetQueueAttributesCommand(sqsParams)
|
|
349
349
|
try {
|
|
350
350
|
return await this.sqs.send(command)
|
|
351
351
|
}
|
|
352
352
|
catch(e) {
|
|
353
353
|
this.logger.error('ACSQS | getQueueAttributes | %s | %s', name, e?.message)
|
|
354
|
-
if (this.throwError || throwError) throw e
|
|
354
|
+
if (this.throwError || throwError) { throw e }
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
|
|
@@ -364,7 +364,7 @@ class ACSQS {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
const { queueName } = this.getQueueUrl(config)
|
|
367
|
-
if (debug) this.logger.info('ACSQS | createQueues | %s | %s', list.name, queueName)
|
|
367
|
+
if (debug) { this.logger.info('ACSQS | createQueues | %s | %s', list.name, queueName) }
|
|
368
368
|
const input = {
|
|
369
369
|
QueueName: queueName
|
|
370
370
|
}
|
|
@@ -377,19 +377,19 @@ class ACSQS {
|
|
|
377
377
|
if (!_.isEmpty(_.get(config, 'attributes'))) {
|
|
378
378
|
input.Attributes = config.attributes
|
|
379
379
|
}
|
|
380
|
-
if (config?.fifo) input.Attributes = { ...input.Attributes, FifoQueue: 'true' }
|
|
381
|
-
if (config?.visibilityTimeout) input.Attributes = { ...input.Attributes, VisibilityTimeout: config.visibilityTimeout }
|
|
382
|
-
if (config?.delay) input.Attributes = { ...input.Attributes, DelaySeconds: config.delay }
|
|
380
|
+
if (config?.fifo) { input.Attributes = { ...input.Attributes, FifoQueue: 'true' } }
|
|
381
|
+
if (config?.visibilityTimeout) { input.Attributes = { ...input.Attributes, VisibilityTimeout: config.visibilityTimeout } }
|
|
382
|
+
if (config?.delay) { input.Attributes = { ...input.Attributes, DelaySeconds: config.delay } }
|
|
383
383
|
|
|
384
384
|
|
|
385
385
|
const command = new CreateQueueCommand(input)
|
|
386
386
|
try {
|
|
387
387
|
await this.sqs.send(command)
|
|
388
|
-
if (debug) this.logger.info('ACSQS | createQueues | Created | %s | %s', list.name, queueName)
|
|
388
|
+
if (debug) { this.logger.info('ACSQS | createQueues | Created | %s | %s', list.name, queueName) }
|
|
389
389
|
}
|
|
390
390
|
catch(e) {
|
|
391
391
|
this.logger.error('AWS | createQueue | %s | %s', list.name, e?.message)
|
|
392
|
-
if (this.throwError) throw e
|
|
392
|
+
if (this.throwError) { throw e }
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
}
|
|
@@ -422,11 +422,11 @@ class ACSQS {
|
|
|
422
422
|
QueueUrl: queueUrl,
|
|
423
423
|
MessageBody: message
|
|
424
424
|
}
|
|
425
|
-
if (messageGroupId) _.set(sqsParams, 'MessageGroupId', messageGroupId)
|
|
426
|
-
if (deDuplicationId) _.set(sqsParams, 'MessageDeduplicationId', deDuplicationId)
|
|
427
|
-
if (delay) _.set(sqsParams, 'DelaySeconds', delay)
|
|
425
|
+
if (messageGroupId) { _.set(sqsParams, 'MessageGroupId', messageGroupId) }
|
|
426
|
+
if (deDuplicationId) { _.set(sqsParams, 'MessageDeduplicationId', deDuplicationId) }
|
|
427
|
+
if (delay) { _.set(sqsParams, 'DelaySeconds', delay) }
|
|
428
428
|
|
|
429
|
-
if (debug || config.debug) this.logger.debug('ACSQS | sendSQSMessage | Payload %j', sqsParams)
|
|
429
|
+
if (debug || config.debug) { this.logger.debug('ACSQS | sendSQSMessage | Payload %j', sqsParams) }
|
|
430
430
|
const command = new SendMessageCommand(sqsParams)
|
|
431
431
|
try {
|
|
432
432
|
const response = await this.sqs.send(command)
|
|
@@ -434,7 +434,7 @@ class ACSQS {
|
|
|
434
434
|
}
|
|
435
435
|
catch(e) {
|
|
436
436
|
this.logger.error('ACSQS | sendSQSMessage | %s | %s', name, e?.message)
|
|
437
|
-
if (this.throwError || throwError) throw e
|
|
437
|
+
if (this.throwError || throwError) { throw e }
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
|
|
@@ -498,7 +498,7 @@ class ACSQS {
|
|
|
498
498
|
QueueUrl: queueUrl,
|
|
499
499
|
Entries: entries
|
|
500
500
|
}
|
|
501
|
-
if (debug || config.debug) this.logger.debug('ACSQS | sendSQSMessageBatch | Payload %j', sqsParams)
|
|
501
|
+
if (debug || config.debug) { this.logger.debug('ACSQS | sendSQSMessageBatch | Payload %j', sqsParams) }
|
|
502
502
|
|
|
503
503
|
const command = new SendMessageBatchCommand(sqsParams)
|
|
504
504
|
try {
|
|
@@ -507,7 +507,7 @@ class ACSQS {
|
|
|
507
507
|
}
|
|
508
508
|
catch(e) {
|
|
509
509
|
this.logger.error('ACSQS | sendSQSMessageBatch | %s | %s', name, e?.message)
|
|
510
|
-
if (this.throwError || throwError) throw e
|
|
510
|
+
if (this.throwError || throwError) { throw e }
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
|
|
@@ -526,11 +526,11 @@ class ACSQS {
|
|
|
526
526
|
VisibilityTimeout: _.get(config, 'visibilityTimeout', 30),
|
|
527
527
|
WaitTimeSeconds: _.get(config, 'waitTime', 20)
|
|
528
528
|
}
|
|
529
|
-
if (debug || config.debug) this.logger.debug('ACSQS | receiveSQSMessages | Payload %j', sqsParams)
|
|
529
|
+
if (debug || config.debug) { this.logger.debug('ACSQS | receiveSQSMessages | Payload %j', sqsParams) }
|
|
530
530
|
const command = new ReceiveMessageCommand(sqsParams)
|
|
531
531
|
try {
|
|
532
532
|
const result = await this.sqs.send(command)
|
|
533
|
-
if (!_.size(result.Messages)) return
|
|
533
|
+
if (!_.size(result.Messages)) { return }
|
|
534
534
|
|
|
535
535
|
const messages = await Promise.all(result.Messages.map(async (message) => {
|
|
536
536
|
if (message.Body.startsWith('s3:')) {
|
|
@@ -540,7 +540,7 @@ class ACSQS {
|
|
|
540
540
|
message.Body = objectData
|
|
541
541
|
message.s3key = key
|
|
542
542
|
}
|
|
543
|
-
catch
|
|
543
|
+
catch {
|
|
544
544
|
this.logger.error('ACSQS | receiveSQSMessages | s3KeyInvalid | %s | %s', name, key)
|
|
545
545
|
}
|
|
546
546
|
}
|
|
@@ -557,7 +557,7 @@ class ACSQS {
|
|
|
557
557
|
}
|
|
558
558
|
catch(e) {
|
|
559
559
|
this.logger.error('ACSQS | receiveSQSMessage | %s | %s', name, e?.message)
|
|
560
|
-
if (this.throwError || throwError) throw e
|
|
560
|
+
if (this.throwError || throwError) { throw e }
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
|
|
@@ -591,7 +591,7 @@ class ACSQS {
|
|
|
591
591
|
QueueUrl: queueUrl,
|
|
592
592
|
Entries: entries
|
|
593
593
|
}
|
|
594
|
-
if (debug || config.debug) this.logger.debug('ACSQS | deleteSQSMessages | Payload %j', sqsParams)
|
|
594
|
+
if (debug || config.debug) { this.logger.debug('ACSQS | deleteSQSMessages | Payload %j', sqsParams) }
|
|
595
595
|
const command = new DeleteMessageBatchCommand(sqsParams)
|
|
596
596
|
try {
|
|
597
597
|
const response = await this.sqs.send(command)
|
|
@@ -610,7 +610,7 @@ class ACSQS {
|
|
|
610
610
|
}
|
|
611
611
|
catch(e) {
|
|
612
612
|
this.logger.error('ACSQS | deleteSQSMessage | %s | %s', name, e?.message)
|
|
613
|
-
if (this.throwError || throwError) throw e
|
|
613
|
+
if (this.throwError || throwError) { throw e }
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
|
package/package.json
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "admiralcloud/ac-sqs",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.5",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@aws-sdk/client-s3": "^3.
|
|
9
|
-
"@aws-sdk/client-sqs": "^3.
|
|
8
|
+
"@aws-sdk/client-s3": "^3.1014.0",
|
|
9
|
+
"@aws-sdk/client-sqs": "^3.1014.0",
|
|
10
10
|
"lodash": "^4.17.23",
|
|
11
11
|
"uuid": "^11.1.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"ac-semantic-release": "^0.4.10",
|
|
15
15
|
"chai": "^4.5.0",
|
|
16
|
-
"eslint": "^
|
|
16
|
+
"eslint": "^10.1.0",
|
|
17
|
+
"globals": "^17.4.0",
|
|
17
18
|
"mocha": "^11.7.5"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
@@ -24,7 +25,9 @@
|
|
|
24
25
|
},
|
|
25
26
|
"resolutions": {
|
|
26
27
|
"mocha/chokidar/braces": "^3.0.3",
|
|
27
|
-
"mocha/diff": "^8.0.3"
|
|
28
|
+
"mocha/diff": "^8.0.3",
|
|
29
|
+
"mocha/serialize-javascript": "^7.0.3",
|
|
30
|
+
"minimatch": "^10.2.1"
|
|
28
31
|
},
|
|
29
32
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
30
33
|
}
|