Skip to content

Commit fef239e

Browse files
committed
Update event schema envelope generation
1 parent c934c3c commit fef239e

25 files changed

+1338
-944
lines changed

internal/events/schemas/events/letter.ACCEPTED.schema.json

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,8 @@
2525
"format": "uuid",
2626
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
2727
},
28-
"source": {
29-
"title": "Event Source",
30-
"description": "Logical event producer path within the supplier-api domain",
31-
"type": "string",
32-
"pattern": "^\\/data-plane\\/supplier-api(?:\\/.*)?$"
33-
},
34-
"subject": {
35-
"title": "Event Subject",
36-
"description": "Resource path (no leading slash) within the source made of segments separated by '/'.",
37-
"examples": [
38-
"letter-origin/letter-rendering/letter/f47ac10b-58cc-4372-a567-0e02b2c3d479"
39-
],
40-
"type": "string",
41-
"pattern": "^letter-origin\\/[a-z0-9-]+\\/letter\\/[^/]+(?:\\/.*)?"
42-
},
4328
"type": {
44-
"title": "Letter ACCEPTED event type",
29+
"title": "letter.ACCEPTED event type",
4530
"description": "Event type using reverse-DNS style",
4631
"examples": [
4732
"uk.nhs.notify.supplier-api.letter.ACCEPTED.v1"
@@ -51,35 +36,29 @@
5136
"uk.nhs.notify.supplier-api.letter.ACCEPTED.v1"
5237
]
5338
},
54-
"time": {
55-
"title": "Event Time",
56-
"description": "Timestamp when the event occurred (RFC 3339).",
39+
"dataschema": {
40+
"title": "Data Schema URI",
41+
"description": "URI of a schema that describes the event data\n\nData schema version must match the major version indicated by the type",
5742
"examples": [
58-
"2025-10-01T10:15:30.000Z"
43+
"https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.ACCEPTED.1.0.0.schema.json"
5944
],
6045
"type": "string",
61-
"format": "date-time",
62-
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
46+
"pattern": "^https:\\/\\/notify\\.nhs\\.uk\\/cloudevents\\/schemas\\/supplier-api\\/letter\\.(?<status>ACCEPTED)\\.1\\.\\d+\\.\\d+\\.schema.json$"
6347
},
64-
"datacontenttype": {
65-
"title": "Data Content Type",
66-
"description": "Media type for the data field (fixed to application/json).",
67-
"examples": [
68-
"application/json"
69-
],
48+
"source": {
49+
"title": "Event Source",
50+
"description": "Logical event producer path within the supplier-api domain",
7051
"type": "string",
71-
"enum": [
72-
"application/json"
73-
]
52+
"pattern": "^\\/data-plane\\/supplier-api(?:\\/.*)?$"
7453
},
75-
"dataschema": {
76-
"title": "Data Schema URI",
77-
"description": "URI of a schema that describes the event data\n\nData schema version must match the major version indicated by the type",
54+
"subject": {
55+
"title": "Event Subject",
56+
"description": "Resource path (no leading slash) within the source made of segments separated by '/'.",
7857
"examples": [
79-
"https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.ACCEPTED.1.0.0.schema.json"
58+
"letter-origin/letter-rendering/letter/f47ac10b-58cc-4372-a567-0e02b2c3d479"
8059
],
8160
"type": "string",
82-
"pattern": "^https:\\/\\/notify\\.nhs\\.uk\\/cloudevents\\/schemas\\/supplier-api\\/letter.ACCEPTED.1\\.\\d+\\.\\d+\\.schema.json$"
61+
"pattern": "^letter-origin\\/[a-z0-9-]+\\/letter\\/[a-z0-9-]+$"
8362
},
8463
"data": {
8564
"type": "object",
@@ -145,9 +124,26 @@
145124
"type": "string"
146125
},
147126
"status": {
127+
"title": "Letter Status",
128+
"description": "The status of a letter in the supplier-api domain.",
129+
"examples": [
130+
"ACCEPTED",
131+
"REJECTED",
132+
"PRINTED"
133+
],
148134
"type": "string",
149135
"enum": [
150-
"ACCEPTED"
136+
"PENDING",
137+
"ACCEPTED",
138+
"REJECTED",
139+
"PRINTED",
140+
"ENCLOSED",
141+
"CANCELLED",
142+
"DISPATCHED",
143+
"FAILED",
144+
"RETURNED",
145+
"FORWARDED",
146+
"DELIVERED"
151147
]
152148
},
153149
"reasonCode": {
@@ -177,6 +173,27 @@
177173
"status"
178174
]
179175
},
176+
"time": {
177+
"title": "Event Time",
178+
"description": "Timestamp when the event occurred (RFC 3339).",
179+
"examples": [
180+
"2025-10-01T10:15:30.000Z"
181+
],
182+
"type": "string",
183+
"format": "date-time",
184+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
185+
},
186+
"datacontenttype": {
187+
"title": "Data Content Type",
188+
"description": "Media type for the data field (fixed to application/json).",
189+
"examples": [
190+
"application/json"
191+
],
192+
"type": "string",
193+
"enum": [
194+
"application/json"
195+
]
196+
},
180197
"traceparent": {
181198
"title": "Traceparent",
182199
"description": "W3C Trace Context traceparent header value.",
@@ -304,26 +321,19 @@
304321
"sensitive",
305322
"special-category"
306323
]
307-
},
308-
"dataschemaversion": {
309-
"title": "Data Schema Version",
310-
"description": "Matches semantic versioning format with fixed major version (Not part of cloudevents spec?)",
311-
"type": "string",
312-
"pattern": "^1\\.\\d+\\.\\d+$"
313324
}
314325
},
315326
"required": [
316327
"specversion",
317328
"id",
318-
"source",
319-
"subject",
320329
"type",
321-
"time",
322330
"dataschema",
331+
"source",
332+
"subject",
323333
"data",
334+
"time",
324335
"traceparent",
325336
"recordedtime",
326-
"severitynumber",
327-
"dataschemaversion"
337+
"severitynumber"
328338
]
329339
}

internal/events/schemas/events/letter.CANCELLED.schema.json

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,8 @@
2525
"format": "uuid",
2626
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
2727
},
28-
"source": {
29-
"title": "Event Source",
30-
"description": "Logical event producer path within the supplier-api domain",
31-
"type": "string",
32-
"pattern": "^\\/data-plane\\/supplier-api(?:\\/.*)?$"
33-
},
34-
"subject": {
35-
"title": "Event Subject",
36-
"description": "Resource path (no leading slash) within the source made of segments separated by '/'.",
37-
"examples": [
38-
"letter-origin/letter-rendering/letter/f47ac10b-58cc-4372-a567-0e02b2c3d479"
39-
],
40-
"type": "string",
41-
"pattern": "^letter-origin\\/[a-z0-9-]+\\/letter\\/[^/]+(?:\\/.*)?"
42-
},
4328
"type": {
44-
"title": "Letter CANCELLED event type",
29+
"title": "letter.CANCELLED event type",
4530
"description": "Event type using reverse-DNS style",
4631
"examples": [
4732
"uk.nhs.notify.supplier-api.letter.CANCELLED.v1"
@@ -51,35 +36,29 @@
5136
"uk.nhs.notify.supplier-api.letter.CANCELLED.v1"
5237
]
5338
},
54-
"time": {
55-
"title": "Event Time",
56-
"description": "Timestamp when the event occurred (RFC 3339).",
39+
"dataschema": {
40+
"title": "Data Schema URI",
41+
"description": "URI of a schema that describes the event data\n\nData schema version must match the major version indicated by the type",
5742
"examples": [
58-
"2025-10-01T10:15:30.000Z"
43+
"https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.CANCELLED.1.0.0.schema.json"
5944
],
6045
"type": "string",
61-
"format": "date-time",
62-
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
46+
"pattern": "^https:\\/\\/notify\\.nhs\\.uk\\/cloudevents\\/schemas\\/supplier-api\\/letter\\.(?<status>CANCELLED)\\.1\\.\\d+\\.\\d+\\.schema.json$"
6347
},
64-
"datacontenttype": {
65-
"title": "Data Content Type",
66-
"description": "Media type for the data field (fixed to application/json).",
67-
"examples": [
68-
"application/json"
69-
],
48+
"source": {
49+
"title": "Event Source",
50+
"description": "Logical event producer path within the supplier-api domain",
7051
"type": "string",
71-
"enum": [
72-
"application/json"
73-
]
52+
"pattern": "^\\/data-plane\\/supplier-api(?:\\/.*)?$"
7453
},
75-
"dataschema": {
76-
"title": "Data Schema URI",
77-
"description": "URI of a schema that describes the event data\n\nData schema version must match the major version indicated by the type",
54+
"subject": {
55+
"title": "Event Subject",
56+
"description": "Resource path (no leading slash) within the source made of segments separated by '/'.",
7857
"examples": [
79-
"https://notify.nhs.uk/cloudevents/schemas/supplier-api/letter.ACCEPTED.1.0.0.schema.json"
58+
"letter-origin/letter-rendering/letter/f47ac10b-58cc-4372-a567-0e02b2c3d479"
8059
],
8160
"type": "string",
82-
"pattern": "^https:\\/\\/notify\\.nhs\\.uk\\/cloudevents\\/schemas\\/supplier-api\\/letter.CANCELLED.1\\.\\d+\\.\\d+\\.schema.json$"
61+
"pattern": "^letter-origin\\/[a-z0-9-]+\\/letter\\/[a-z0-9-]+$"
8362
},
8463
"data": {
8564
"type": "object",
@@ -145,9 +124,26 @@
145124
"type": "string"
146125
},
147126
"status": {
127+
"title": "Letter Status",
128+
"description": "The status of a letter in the supplier-api domain.",
129+
"examples": [
130+
"ACCEPTED",
131+
"REJECTED",
132+
"PRINTED"
133+
],
148134
"type": "string",
149135
"enum": [
150-
"CANCELLED"
136+
"PENDING",
137+
"ACCEPTED",
138+
"REJECTED",
139+
"PRINTED",
140+
"ENCLOSED",
141+
"CANCELLED",
142+
"DISPATCHED",
143+
"FAILED",
144+
"RETURNED",
145+
"FORWARDED",
146+
"DELIVERED"
151147
]
152148
},
153149
"reasonCode": {
@@ -177,6 +173,27 @@
177173
"status"
178174
]
179175
},
176+
"time": {
177+
"title": "Event Time",
178+
"description": "Timestamp when the event occurred (RFC 3339).",
179+
"examples": [
180+
"2025-10-01T10:15:30.000Z"
181+
],
182+
"type": "string",
183+
"format": "date-time",
184+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
185+
},
186+
"datacontenttype": {
187+
"title": "Data Content Type",
188+
"description": "Media type for the data field (fixed to application/json).",
189+
"examples": [
190+
"application/json"
191+
],
192+
"type": "string",
193+
"enum": [
194+
"application/json"
195+
]
196+
},
180197
"traceparent": {
181198
"title": "Traceparent",
182199
"description": "W3C Trace Context traceparent header value.",
@@ -304,26 +321,19 @@
304321
"sensitive",
305322
"special-category"
306323
]
307-
},
308-
"dataschemaversion": {
309-
"title": "Data Schema Version",
310-
"description": "Matches semantic versioning format with fixed major version (Not part of cloudevents spec?)",
311-
"type": "string",
312-
"pattern": "^1\\.\\d+\\.\\d+$"
313324
}
314325
},
315326
"required": [
316327
"specversion",
317328
"id",
318-
"source",
319-
"subject",
320329
"type",
321-
"time",
322330
"dataschema",
331+
"source",
332+
"subject",
323333
"data",
334+
"time",
324335
"traceparent",
325336
"recordedtime",
326-
"severitynumber",
327-
"dataschemaversion"
337+
"severitynumber"
328338
]
329339
}

0 commit comments

Comments
 (0)