@@ -2,12 +2,18 @@ import { setTimeout } from 'node:timers/promises'
22import type { SNSClient } from '@aws-sdk/client-sns'
33import type { SQSClient } from '@aws-sdk/client-sqs'
44import type { STSClient } from '@aws-sdk/client-sts'
5- import { ResourceAvailabilityTimeoutError } from '@message-queue-toolkit/core'
5+ import {
6+ MessageHandlerConfigBuilder ,
7+ ResourceAvailabilityTimeoutError ,
8+ } from '@message-queue-toolkit/core'
69import { assertQueue , deleteQueue } from '@message-queue-toolkit/sqs'
710import type { AwilixContainer } from 'awilix'
811import { afterAll , afterEach , beforeAll , beforeEach , describe , expect , it } from 'vitest'
9- import type { SNSSQSConsumerDependencies } from '../../lib/sns/AbstractSnsSqsConsumer.ts'
10- import { AbstractSnsSqsConsumer } from '../../lib/sns/AbstractSnsSqsConsumer.ts'
12+ import {
13+ AbstractSnsSqsConsumer ,
14+ type SNSSQSConsumerDependencies ,
15+ type SNSSQSConsumerOptions ,
16+ } from '../../lib/sns/AbstractSnsSqsConsumer.ts'
1117import { assertTopic , deleteTopic } from '../../lib/utils/snsUtils.ts'
1218import type { Dependencies } from '../utils/testContext.ts'
1319import { registerDependencies } from '../utils/testContext.ts'
@@ -16,42 +22,24 @@ import {
1622 type PERMISSIONS_ADD_MESSAGE_TYPE ,
1723} from './userConsumerSchemas.ts'
1824
25+ type TestConsumerOptions = Pick <
26+ SNSSQSConsumerOptions < PERMISSIONS_ADD_MESSAGE_TYPE , undefined , undefined > ,
27+ 'locatorConfig' | 'creationConfig' | 'resourceAvailabilityConfig'
28+ >
29+
1930// Simple consumer for testing resource availability
2031class TestResourceAvailabilityConsumer extends AbstractSnsSqsConsumer <
2132 PERMISSIONS_ADD_MESSAGE_TYPE ,
2233 undefined ,
2334 undefined
2435> {
25- constructor (
26- dependencies : SNSSQSConsumerDependencies ,
27- options : {
28- locatorConfig ?: {
29- topicArn ?: string
30- topicName ?: string
31- queueUrl ?: string
32- queueName ?: string
33- subscriptionArn ?: string
34- }
35- creationConfig ?: {
36- queue ?: { QueueName : string }
37- topic ?: { Name : string }
38- }
39- resourceAvailabilityConfig ?: {
40- enabled : boolean
41- timeoutMs ?: number
42- pollingIntervalMs ?: number
43- }
44- } ,
45- ) {
36+ constructor ( dependencies : SNSSQSConsumerDependencies , options : TestConsumerOptions ) {
4637 super (
4738 dependencies ,
4839 {
49- handlers : [
50- {
51- schema : PERMISSIONS_ADD_MESSAGE_SCHEMA ,
52- handler : ( ) => Promise . resolve ( { result : 'success' } ) ,
53- } ,
54- ] ,
40+ handlers : new MessageHandlerConfigBuilder < PERMISSIONS_ADD_MESSAGE_TYPE , undefined > ( )
41+ . addConfig ( PERMISSIONS_ADD_MESSAGE_SCHEMA , ( ) => Promise . resolve ( { result : 'success' } ) )
42+ . build ( ) ,
5543 messageTypeResolver : { messageTypePath : 'messageType' } ,
5644 subscriptionConfig : { updateAttributesIfExists : false } ,
5745 ...options ,
0 commit comments