@@ -36,6 +36,28 @@ function createSqsRecord(msgId: string, body: string): SQSRecord {
3636 } ;
3737}
3838
39+ function createEventBridgeNotification (
40+ event :
41+ | LetterRequestPreparedEventV2
42+ | LetterRequestPreparedEvent
43+ | LetterEvent ,
44+ ) : Partial < SNSMessage > {
45+ return {
46+ SignatureVersion : "" ,
47+ Timestamp : "" ,
48+ Signature : "" ,
49+ SigningCertUrl : "" ,
50+ MessageId : "" ,
51+ Message : createEventBridgeEvent ( event ) ,
52+ MessageAttributes : { } ,
53+ Type : "Notification" ,
54+ UnsubscribeUrl : "" ,
55+ TopicArn : "" ,
56+ Subject : "" ,
57+ Token : "" ,
58+ } ;
59+ }
60+
3961function createNotification (
4062 event :
4163 | LetterRequestPreparedEventV2
@@ -58,6 +80,22 @@ function createNotification(
5880 } ;
5981}
6082
83+ function createEventBridgeEvent ( event : any ) : string {
84+ const now = new Date ( ) . toISOString ( ) ;
85+ const eventBridgeEnvelope = {
86+ version : "0" ,
87+ id : "4f28e649-6832-18e8-7261-4b63e6dcd3b5" ,
88+ "detail-type" : event . type ,
89+ source : "custom.event" ,
90+ account : "815490582396" ,
91+ time : now ,
92+ region : "eu-west-2" ,
93+ resources : [ ] ,
94+ detail : event ,
95+ } ;
96+ return JSON . stringify ( eventBridgeEnvelope ) ;
97+ }
98+
6199function createPreparedV1Event (
62100 overrides : Partial < any > = { } ,
63101) : LetterRequestPreparedEvent {
@@ -178,7 +216,7 @@ describe("createUpsertLetterHandler", () => {
178216 const evt : SQSEvent = createSQSEvent ( [
179217 createSqsRecord (
180218 "msg1" ,
181- JSON . stringify ( createNotification ( createPreparedV2Event ( ) ) ) ,
219+ JSON . stringify ( createEventBridgeNotification ( createPreparedV2Event ( ) ) ) ,
182220 ) ,
183221 createSqsRecord (
184222 "msg2" ,
0 commit comments