11import { z } from 'zod' ;
22import { SelectObjectContentEventStream } from '@aws-sdk/client-s3' ;
33import {
4+ $RoutingConfigCompletedEventV1 ,
5+ $RoutingConfigDeletedEventV1 ,
6+ $RoutingConfigDraftedEventV1 ,
47 $TemplateCompletedEventV1 ,
58 $TemplateDeletedEventV1 ,
69 $TemplateDraftedEventV1 ,
@@ -13,21 +16,21 @@ import {
1316} from 'date-fns' ;
1417import { S3Helper } from '../s3-helper' ;
1518
16- const $NHSNotifyTemplateEvent = z . discriminatedUnion ( 'type' , [
19+ const $NHSNotifyEvent = z . discriminatedUnion ( 'type' , [
1720 $TemplateCompletedEventV1 ,
1821 $TemplateDraftedEventV1 ,
1922 $TemplateDeletedEventV1 ,
23+ $RoutingConfigCompletedEventV1 ,
24+ $RoutingConfigDraftedEventV1 ,
25+ $RoutingConfigDeletedEventV1 ,
2026] ) ;
2127
22- type NHSNotifyTemplateEvent = z . infer < typeof $NHSNotifyTemplateEvent > ;
28+ type NHSNotifyEvent = z . infer < typeof $NHSNotifyEvent > ;
2329
2430export class EventCacheHelper {
2531 private readonly bucketName = process . env . EVENT_CACHE_BUCKET_NAME ;
2632
27- async findEvents (
28- from : Date ,
29- ids : string [ ]
30- ) : Promise < NHSNotifyTemplateEvent [ ] > {
33+ async findEvents ( from : Date , ids : string [ ] ) : Promise < NHSNotifyEvent [ ] > {
3134 if ( ids . length === 0 ) {
3235 return [ ] ;
3336 }
@@ -52,7 +55,7 @@ export class EventCacheHelper {
5255 private async queryFileForEvents (
5356 fileName : string ,
5457 ids : string [ ]
55- ) : Promise < NHSNotifyTemplateEvent [ ] > {
58+ ) : Promise < NHSNotifyEvent [ ] > {
5659 const formattedIds = ids . map ( ( r ) => `'${ r } '` ) ;
5760
5861 const response = await S3Helper . queryJSONLFile (
@@ -71,8 +74,8 @@ export class EventCacheHelper {
7174 private async parse (
7275 fileName : string ,
7376 payload : AsyncIterable < SelectObjectContentEventStream >
74- ) : Promise < NHSNotifyTemplateEvent [ ] > {
75- const events : NHSNotifyTemplateEvent [ ] = [ ] ;
77+ ) : Promise < NHSNotifyEvent [ ] > {
78+ const events : NHSNotifyEvent [ ] = [ ] ;
7679
7780 for await ( const event of payload ) {
7881 if ( ! event . Records ?. Payload ) continue ;
@@ -83,7 +86,7 @@ export class EventCacheHelper {
8386 . split ( '\n' )
8487 . filter ( ( line ) => line . trim ( ) )
8588 . map ( ( line ) => {
86- const { data, success, error } = $NHSNotifyTemplateEvent . safeParse (
89+ const { data, success, error } = $NHSNotifyEvent . safeParse (
8790 JSON . parse ( line )
8891 ) ;
8992
0 commit comments