@@ -32,6 +32,7 @@ import {
3232
3333import { Deps } from "../config/deps" ;
3434import { PreparedEventSchema , PreparedEvents , SupplierDetails } from "./types" ;
35+ import { domain } from "zod/v4/core/regexes.cjs" ;
3536
3637const idempotencyConfig = new IdempotencyConfig ( {
3738 eventKeyJmesPath : "id" ,
@@ -266,13 +267,13 @@ async function saveAllocations(
266267 }
267268}
268269
269- type SupplierAllocationResult = [
270- supplier : string ,
271- priority : string ,
272- AllocationMetrics ,
273- AllocationMetrics ,
274- VolumeGroupAllocation ,
275- ] ;
270+ type SupplierAllocationResult = {
271+ supplier : string ;
272+ priority : string ;
273+ perAllocationSuccess : AllocationMetrics ;
274+ perAllocationFailure : AllocationMetrics ;
275+ volumeGroupAllocations : VolumeGroupAllocation ;
276+ } ;
276277
277278async function processSupplierAllocation (
278279 letterEvent : PreparedEvents ,
@@ -281,6 +282,12 @@ async function processSupplierAllocation(
281282 perAllocationFailure : AllocationMetrics ,
282283 volumeGroupAllocations : VolumeGroupAllocation ,
283284) : Promise < SupplierAllocationResult > {
285+ deps . logger . info ( {
286+ description : "Processing supplier allocation for letter event" ,
287+ eventId : letterEvent . id ,
288+ domainId : letterEvent . data . domainId ,
289+ letterVariantId : letterEvent . data . letterVariantId ,
290+ } ) ;
284291 const supplierDetails : SupplierDetails = await getSupplierFromConfig (
285292 letterEvent ,
286293 deps ,
@@ -332,13 +339,13 @@ async function processSupplierAllocation(
332339 MessageBody : JSON . stringify ( queueMessage ) ,
333340 } ) ,
334341 ) ;
335- return [
342+ return {
336343 supplier,
337344 priority,
338345 perAllocationSuccess,
339346 perAllocationFailure,
340347 volumeGroupAllocations,
341- ] ;
348+ } ;
342349}
343350
344351export default function createSupplierAllocatorHandler ( deps : Deps ) : SQSHandler {
@@ -362,28 +369,46 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
362369 deps . logger . info ( {
363370 description : "Extracted letter event" ,
364371 messageId : record . messageId ,
372+ domainId : letterEvent . data . domainId ,
373+ letterVariantId : letterEvent . data . letterVariantId ,
365374 } ) ;
366375
367376 idempotencyConfig . registerLambdaContext ( context ) ;
368377
369- const [
370- allocatedSupplier ,
371- alocatedPriority ,
372- updatedPerAllocationSuccess ,
373- updatedPerAllocationFailure ,
374- updatedVolumeGroupAllocations ,
375- ] = await getSupplierIdempotently (
376- letterEvent ,
377- deps ,
378- perAllocationSuccess ,
379- perAllocationFailure ,
378+ const supplierAllocationResult : SupplierAllocationResult =
379+ await getSupplierIdempotently (
380+ letterEvent ,
381+ deps ,
382+ perAllocationSuccess ,
383+ perAllocationFailure ,
384+ volumeGroupAllocations ,
385+ ) ;
386+ deps . logger . info ( {
387+ description : "Completed supplier allocation for letter event" ,
388+ eventId : letterEvent . id ,
389+ domainId : letterEvent . data . domainId ,
390+ letterVariantId : letterEvent . data . letterVariantId ,
391+ supplier : supplierAllocationResult . supplier ,
392+ priority : supplierAllocationResult . priority ,
393+ updatedVolumeGroupAllocations :
394+ supplierAllocationResult . volumeGroupAllocations ,
395+ } ) ;
396+ supplier = supplierAllocationResult . supplier ;
397+ priority = supplierAllocationResult . priority ;
398+ perAllocationSuccess = supplierAllocationResult . perAllocationSuccess ;
399+ perAllocationFailure = supplierAllocationResult . perAllocationFailure ;
400+ volumeGroupAllocations =
401+ supplierAllocationResult . volumeGroupAllocations ;
402+ deps . logger . info ( {
403+ description :
404+ "Completed processing supplier allocation for letter event" ,
405+ eventId : letterEvent . id ,
406+ domainId : letterEvent . data . domainId ,
407+ letterVariantId : letterEvent . data . letterVariantId ,
408+ supplier,
409+ priority,
380410 volumeGroupAllocations,
381- ) ;
382- supplier = allocatedSupplier ;
383- priority = alocatedPriority ;
384- perAllocationSuccess = updatedPerAllocationSuccess ;
385- perAllocationFailure = updatedPerAllocationFailure ;
386- volumeGroupAllocations = updatedVolumeGroupAllocations ;
411+ } ) ;
387412 } catch ( error ) {
388413 deps . logger . error ( {
389414 description : "Error processing allocation of record" ,
0 commit comments