@@ -36,12 +36,31 @@ function createSqsRecord(msgId: string, body: string): SQSRecord {
3636 } ;
3737}
3838
39- function createNotification (
40- event :
41- | LetterRequestPreparedEventV2
42- | LetterRequestPreparedEvent
43- | LetterEvent ,
39+ type SupportedEvent =
40+ | LetterRequestPreparedEventV2
41+ | LetterRequestPreparedEvent
42+ | LetterEvent ;
43+
44+ function createEventBridgeNotification (
45+ event : SupportedEvent ,
4446) : Partial < SNSMessage > {
47+ return {
48+ SignatureVersion : "" ,
49+ Timestamp : "" ,
50+ Signature : "" ,
51+ SigningCertUrl : "" ,
52+ MessageId : "" ,
53+ Message : createEventBridgeEvent ( event ) ,
54+ MessageAttributes : { } ,
55+ Type : "Notification" ,
56+ UnsubscribeUrl : "" ,
57+ TopicArn : "" ,
58+ Subject : "" ,
59+ Token : "" ,
60+ } ;
61+ }
62+
63+ function createNotification ( event : SupportedEvent ) : Partial < SNSMessage > {
4564 return {
4665 SignatureVersion : "" ,
4766 Timestamp : "" ,
@@ -58,6 +77,22 @@ function createNotification(
5877 } ;
5978}
6079
80+ function createEventBridgeEvent ( event : SupportedEvent ) : string {
81+ const now = new Date ( ) . toISOString ( ) ;
82+ const eventBridgeEnvelope = {
83+ version : "0" ,
84+ id : "4f28e649-6832-18e8-7261-4b63e6dcd3b5" ,
85+ "detail-type" : event . type ,
86+ source : "custom.event" ,
87+ account : "815490582396" ,
88+ time : now ,
89+ region : "eu-west-2" ,
90+ resources : [ ] ,
91+ detail : event ,
92+ } ;
93+ return JSON . stringify ( eventBridgeEnvelope ) ;
94+ }
95+
6196function createPreparedV1Event (
6297 overrides : Partial < any > = { } ,
6398) : LetterRequestPreparedEvent {
@@ -178,7 +213,7 @@ describe("createUpsertLetterHandler", () => {
178213 const evt : SQSEvent = createSQSEvent ( [
179214 createSqsRecord (
180215 "msg1" ,
181- JSON . stringify ( createNotification ( createPreparedV2Event ( ) ) ) ,
216+ JSON . stringify ( createEventBridgeNotification ( createPreparedV2Event ( ) ) ) ,
182217 ) ,
183218 createSqsRecord (
184219 "msg2" ,
0 commit comments