ac-sqs 3.3.1 → 3.3.2
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/CHANGELOG.md +8 -0
- package/index.js +52 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.3.2](https://github.com/admiralcloud/ac-sqs/compare/v3.3.1..v3.3.2) (2025-09-26 20:15:26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fix
|
|
6
|
+
|
|
7
|
+
* **App:** Several minor improvement for createQueues | MP | [ef2abc7c6bc2f08e1328cb1c94be479362836323](https://github.com/admiralcloud/ac-sqs/commit/ef2abc7c6bc2f08e1328cb1c94be479362836323)
|
|
8
|
+
Several minor improvement for createQueues
|
|
9
|
+
|
|
2
10
|
## [3.3.1](https://github.com/admiralcloud/ac-sqs/compare/v3.3.0..v3.3.1) (2025-09-26 17:45:21)
|
|
3
11
|
|
|
4
12
|
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const _ = require('lodash')
|
|
|
2
2
|
const { v4: uuidV4 } = require('uuid')
|
|
3
3
|
const { setTimeout: sleep } = require('timers/promises')
|
|
4
4
|
|
|
5
|
-
const { SQSClient, SendMessageCommand, SendMessageBatchCommand, ReceiveMessageCommand, DeleteMessageBatchCommand, GetQueueAttributesCommand, ChangeMessageVisibilityBatchCommand, CreateQueueCommand } = require('@aws-sdk/client-sqs')
|
|
5
|
+
const { SQSClient, SendMessageCommand, SendMessageBatchCommand, ReceiveMessageCommand, DeleteMessageBatchCommand, GetQueueAttributesCommand, ChangeMessageVisibilityBatchCommand, GetQueueUrlCommand, CreateQueueCommand } = require('@aws-sdk/client-sqs')
|
|
6
6
|
const { S3Client, GetObjectCommand, PutObjectCommand, DeleteObjectsCommand } = require("@aws-sdk/client-s3")
|
|
7
7
|
|
|
8
8
|
class ACSQS {
|
|
@@ -146,9 +146,10 @@ class ACSQS {
|
|
|
146
146
|
ReceiptHandle: messageData.receiptHandle,
|
|
147
147
|
VisibilityTimeout: visibilityTimeout
|
|
148
148
|
}))
|
|
149
|
+
const { queueUrl } = this.getQueueUrl(config)
|
|
149
150
|
|
|
150
151
|
return {
|
|
151
|
-
QueueUrl:
|
|
152
|
+
QueueUrl: queueUrl,
|
|
152
153
|
Entries: entries
|
|
153
154
|
}
|
|
154
155
|
}
|
|
@@ -318,14 +319,18 @@ class ACSQS {
|
|
|
318
319
|
return response
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
322
|
+
getQueueUrl({ name, fifo, localPrefix, suffix }) {
|
|
323
|
+
// Build queue name using array filtering for cleaner concatenation
|
|
324
|
+
const queueName = [
|
|
325
|
+
localPrefix && `local_${localPrefix}_`,
|
|
326
|
+
process.env['NODE_ENV'] === 'test' && 'test_',
|
|
327
|
+
name,
|
|
328
|
+
suffix,
|
|
329
|
+
fifo && '.fifo'
|
|
330
|
+
].filter(Boolean).join('')
|
|
331
|
+
|
|
332
|
+
const queueUrl = `https://sqs.${this.region}.amazonaws.com/${this.account}/${queueName}`
|
|
333
|
+
return { queueName, queueUrl }
|
|
329
334
|
}
|
|
330
335
|
|
|
331
336
|
async getQueueAttributes({ name, attributes = ['ApproximateNumberOfMessages'], throwError }) {
|
|
@@ -334,8 +339,9 @@ class ACSQS {
|
|
|
334
339
|
this.logger.error('ACSQS | getQueueAttributes | configurationMissing | %s', name)
|
|
335
340
|
throw new Error('configurationForListMissing')
|
|
336
341
|
}
|
|
342
|
+
const { queueUrl } = this.getQueueUrl(config)
|
|
337
343
|
let sqsParams = {
|
|
338
|
-
QueueUrl:
|
|
344
|
+
QueueUrl: queueUrl,
|
|
339
345
|
AttributeNames: attributes
|
|
340
346
|
}
|
|
341
347
|
if (config.debug) this.logger.debug('ACSQS | getQueueAttributes | Payload %j', sqsParams)
|
|
@@ -357,15 +363,34 @@ class ACSQS {
|
|
|
357
363
|
throw new Error('configurationForListMissing')
|
|
358
364
|
}
|
|
359
365
|
|
|
360
|
-
const
|
|
361
|
-
|
|
366
|
+
const { queueName } = this.getQueueUrl(config)
|
|
367
|
+
if (debug) this.logger.info('ACSQS | createQueues | %s | %s', list.name, queueName)
|
|
368
|
+
const input = {
|
|
369
|
+
QueueName: queueName
|
|
370
|
+
}
|
|
371
|
+
const checkCommand = new GetQueueUrlCommand(input)
|
|
362
372
|
try {
|
|
363
|
-
await this.sqs.send(
|
|
364
|
-
|
|
373
|
+
await this.sqs.send(checkCommand)
|
|
374
|
+
continue
|
|
365
375
|
}
|
|
366
|
-
catch
|
|
367
|
-
|
|
368
|
-
|
|
376
|
+
catch {
|
|
377
|
+
if (!_.isEmpty(_.get(config, 'attributes'))) {
|
|
378
|
+
input.Attributes = config.attributes
|
|
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 }
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
const command = new CreateQueueCommand(input)
|
|
386
|
+
try {
|
|
387
|
+
await this.sqs.send(command)
|
|
388
|
+
if (debug) this.logger.info('ACSQS | createQueues | Created | %s | %s', list.name, queueName)
|
|
389
|
+
}
|
|
390
|
+
catch(e) {
|
|
391
|
+
this.logger.error('AWS | createQueue | %s | %s', list.name, e?.message)
|
|
392
|
+
if (this.throwError) throw e
|
|
393
|
+
}
|
|
369
394
|
}
|
|
370
395
|
}
|
|
371
396
|
}
|
|
@@ -391,8 +416,9 @@ class ACSQS {
|
|
|
391
416
|
message = `s3:${key}`
|
|
392
417
|
}
|
|
393
418
|
|
|
419
|
+
const { queueUrl } = this.getQueueUrl(config)
|
|
394
420
|
const sqsParams = {
|
|
395
|
-
QueueUrl:
|
|
421
|
+
QueueUrl: queueUrl,
|
|
396
422
|
MessageBody: message
|
|
397
423
|
}
|
|
398
424
|
if (messageGroupId) _.set(sqsParams, 'MessageGroupId', messageGroupId)
|
|
@@ -449,8 +475,9 @@ class ACSQS {
|
|
|
449
475
|
return item
|
|
450
476
|
})
|
|
451
477
|
|
|
478
|
+
const { queueUrl } = this.getQueueUrl(config)
|
|
452
479
|
const sqsParams = {
|
|
453
|
-
QueueUrl:
|
|
480
|
+
QueueUrl: queueUrl,
|
|
454
481
|
Entries: entries
|
|
455
482
|
}
|
|
456
483
|
if (debug || config.debug) this.logger.error('ACSQS | sendSQSMessageBatch | Payload %j', sqsParams)
|
|
@@ -474,8 +501,9 @@ class ACSQS {
|
|
|
474
501
|
}
|
|
475
502
|
const visibilityTimeout = _.get(config, 'visibilityTimeout') // if set, will activate visibilityTimeout management
|
|
476
503
|
|
|
504
|
+
const { queueUrl } = this.getQueueUrl(config)
|
|
477
505
|
const sqsParams = {
|
|
478
|
-
QueueUrl:
|
|
506
|
+
QueueUrl: queueUrl,
|
|
479
507
|
MaxNumberOfMessages: _.get(config, 'batchSize', 10),
|
|
480
508
|
VisibilityTimeout: _.get(config, 'visibilityTimeout', 30),
|
|
481
509
|
WaitTimeSeconds: _.get(config, 'waitTime', 20)
|
|
@@ -540,8 +568,9 @@ class ACSQS {
|
|
|
540
568
|
this.removeVisibilityTracking(messageId)
|
|
541
569
|
}
|
|
542
570
|
|
|
543
|
-
|
|
544
|
-
|
|
571
|
+
const { queueUrl } = this.getQueueUrl(config)
|
|
572
|
+
const sqsParams = {
|
|
573
|
+
QueueUrl: queueUrl,
|
|
545
574
|
Entries: entries
|
|
546
575
|
}
|
|
547
576
|
if (debug || config.debug) this.logger.debug('ACSQS | deleteSQSMessages | Payload %j', sqsParams)
|
package/package.json
CHANGED