File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
internal/events/src/events
lambdas/letter-updates-transformer/src/mappers Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ export function EventEnvelope<TData extends z.ZodTypeAny>(
5050 examples : typeStrings ,
5151 } ) ,
5252
53+ plane : z . literal ( "data-plane" ) . meta ( {
54+ title : "plane" ,
55+ description : "Fixed as data-plane" ,
56+ examples : [ "data-plane" ] ,
57+ } ) ,
58+
5359 dataschema : z
5460 . string ( )
5561 . regex (
@@ -64,6 +70,15 @@ export function EventEnvelope<TData extends z.ZodTypeAny>(
6470 examples : schemaExamples ,
6571 } ) ,
6672
73+ dataschemaversion : z
74+ . string ( )
75+ . regex ( / ^ 1 .\d + .\d + $ / )
76+ . meta ( {
77+ title : "Data Schema URI" ,
78+ description : `Version of the schema that describes the event data\n\nMust match the version in dataschema` ,
79+ examples :[ "1.0.0" ] ,
80+ } ) ,
81+
6782 source : z
6883 . string ( )
6984 . regex ( / ^ \/ d a t a - p l a n e \/ s u p p l i e r - a p i (?: \/ .* ) ? $ / )
@@ -94,13 +109,13 @@ export function EventEnvelope<TData extends z.ZodTypeAny>(
94109 examples : [ "2025-10-01T10:15:30.000Z" ] ,
95110 } ) ,
96111
97- datacontenttype : z . optional (
112+ datacontenttype :
98113 z . literal ( "application/json" ) . meta ( {
99114 title : "Data Content Type" ,
100115 description :
101116 "Media type for the data field (fixed to application/json)." ,
102117 examples : [ "application/json" ] ,
103- } ) ,
118+ } ,
104119 ) ,
105120
106121 traceparent : z
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ describe("letter-mapper", () => {
2020 $LetterEvent . parse ( event ) ;
2121 expect ( event . type ) . toBe ( "uk.nhs.notify.supplier-api.letter.PRINTED.v1" ) ;
2222 expect ( event . dataschema ) . toBe ( "https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.PRINTED.1.0.0.schema.json" ) ;
23+ expect ( event . dataschemaversion ) . toBe ( "1.0.0" ) ;
2324 expect ( event . subject ) . toBe ( "letter-origin/supplier-api/letter/id1" ) ;
2425 expect ( event . time ) . toBe ( "2025-11-24T15:55:18.000Z" ) ;
2526 expect ( event . recordedtime ) . toBe ( "2025-11-24T15:55:18.000Z" ) ;
Original file line number Diff line number Diff line change @@ -5,11 +5,14 @@ import { randomUUID, randomBytes } from "crypto";
55export function mapLetterToCloudEvent ( letter : LetterBase ) : LetterEvent {
66 const now = new Date ( ) . toISOString ( ) ;
77 const eventId = randomUUID ( ) ;
8+ const dataschemaversion = '1.0.0' ;
89 return {
910 specversion : "1.0" ,
1011 id : eventId ,
1112 type : `uk.nhs.notify.supplier-api.letter.${ letter . status } .v1` ,
12- dataschema : `https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.${ letter . status } .1.0.0.schema.json` ,
13+ plane : 'data-plane' ,
14+ dataschema : `https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.${ letter . status } .${ dataschemaversion } .schema.json` ,
15+ dataschemaversion,
1316 source : "/data-plane/supplier-api/letters" ,
1417 subject : "letter-origin/supplier-api/letter/" + letter . id ,
1518
@@ -28,6 +31,7 @@ export function mapLetterToCloudEvent(letter: LetterBase): LetterEvent {
2831 }
2932 } ,
3033 time : now ,
34+ datacontenttype : 'application/json' ,
3135 traceparent : `00-${ randomBytes ( 16 ) . toString ( "hex" ) } -${ randomBytes ( 8 ) . toString ( "hex" ) } -01` ,
3236 recordedtime : now ,
3337 severitynumber : 2 ,
You can’t perform that action at this time.
0 commit comments