From a403bc204fc9e19acf26eaa96dca8b8d0a2f776e Mon Sep 17 00:00:00 2001 From: Mark Slowey Date: Mon, 17 Aug 2026 09:39:16 +0100 Subject: [PATCH 1/4] add request and toUpdate context --- lambdas/supplier-allocator/src/handler/allocation-config.ts | 5 +++++ lambdas/upsert-letter/src/handler/upsert-handler.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lambdas/supplier-allocator/src/handler/allocation-config.ts b/lambdas/supplier-allocator/src/handler/allocation-config.ts index f9e7f92d1..1f383645e 100644 --- a/lambdas/supplier-allocator/src/handler/allocation-config.ts +++ b/lambdas/supplier-allocator/src/handler/allocation-config.ts @@ -81,11 +81,16 @@ export async function preferredSupplierPack( packSpecificationIds: string[], deps: Deps, ): Promise { + // Constraints const eligiblePacks: string[] = await filterPacksForLetter( letterEvent, packSpecificationIds, deps, ); + + // No eligible packs -> REJECTED + + // Check can a supplier fulfil the pack const preferredSupplierPacks: SupplierPack[] = await getPreferredSupplierPacks(eligiblePacks, suppliers, deps); const preferredPack: PackSpecification = await getPackSpecification( diff --git a/lambdas/upsert-letter/src/handler/upsert-handler.ts b/lambdas/upsert-letter/src/handler/upsert-handler.ts index fa49adb05..6baff1acb 100644 --- a/lambdas/upsert-letter/src/handler/upsert-handler.ts +++ b/lambdas/upsert-letter/src/handler/upsert-handler.ts @@ -56,6 +56,8 @@ function getOperationFromType(type: string): UpsertOperation { eventId: preparedRequest.id, letterId: letterToInsert.id, supplierId: letterToInsert.supplierId, + letterInsertRequest: request, + letterToInsert: letterToInsert, }); // emit success metric emitIndividualMetric( @@ -99,6 +101,8 @@ function getOperationFromType(type: string): UpsertOperation { eventId: supplierEvent.id, letterId: letterToUpdate.id, supplierId: letterToUpdate.supplierId, + letterUpdateRequest: request, + letterToUpdate: letterToUpdate, }); emitIndividualMetric( deps.logger, From 20042ba3944105183ad4129fcbc722d90d762dc2 Mon Sep 17 00:00:00 2001 From: Mark Slowey Date: Mon, 17 Aug 2026 10:00:12 +0100 Subject: [PATCH 2/4] add attributes to update operations --- lambdas/api-handler/src/handlers/patch-letter.ts | 2 +- lambdas/api-handler/src/handlers/post-letters.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lambdas/api-handler/src/handlers/patch-letter.ts b/lambdas/api-handler/src/handlers/patch-letter.ts index 5fc89ee66..cddf49f6a 100644 --- a/lambdas/api-handler/src/handlers/patch-letter.ts +++ b/lambdas/api-handler/src/handlers/patch-letter.ts @@ -70,7 +70,7 @@ export default function createPatchLetterHandler( description: "Received patch letter request", supplierId: commonIds.value.supplierId, letterId, - newStatus: patchLetterRequest.data.attributes.status, + attributes: patchLetterRequest.data.attributes, correlationId: commonIds.value.correlationId, }); diff --git a/lambdas/api-handler/src/handlers/post-letters.ts b/lambdas/api-handler/src/handlers/post-letters.ts index c4d22183a..be87f9b93 100644 --- a/lambdas/api-handler/src/handlers/post-letters.ts +++ b/lambdas/api-handler/src/handlers/post-letters.ts @@ -97,7 +97,7 @@ export default function createPostLettersHandler( deps.logger.info({ description: "Received post letters request", supplierId: commonIds.value.supplierId, - letterIds: postLettersRequest.data.map((letter) => letter.id), + newAttributes: postLettersRequest.data.map((request) => ({ id: request.id, attributes: request.attributes })), correlationId: commonIds.value.correlationId, }); From c75593e9e7d771b2913236ca1a52b6a5bb3ad47b Mon Sep 17 00:00:00 2001 From: Mark Slowey Date: Tue, 18 Aug 2026 09:53:01 +0100 Subject: [PATCH 3/4] linting --- lambdas/api-handler/src/handlers/post-letters.ts | 5 ++++- lambdas/upsert-letter/src/handler/upsert-handler.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lambdas/api-handler/src/handlers/post-letters.ts b/lambdas/api-handler/src/handlers/post-letters.ts index be87f9b93..fe6577128 100644 --- a/lambdas/api-handler/src/handlers/post-letters.ts +++ b/lambdas/api-handler/src/handlers/post-letters.ts @@ -97,7 +97,10 @@ export default function createPostLettersHandler( deps.logger.info({ description: "Received post letters request", supplierId: commonIds.value.supplierId, - newAttributes: postLettersRequest.data.map((request) => ({ id: request.id, attributes: request.attributes })), + newAttributes: postLettersRequest.data.map((request) => ({ + id: request.id, + attributes: request.attributes, + })), correlationId: commonIds.value.correlationId, }); diff --git a/lambdas/upsert-letter/src/handler/upsert-handler.ts b/lambdas/upsert-letter/src/handler/upsert-handler.ts index 6baff1acb..6b5199b92 100644 --- a/lambdas/upsert-letter/src/handler/upsert-handler.ts +++ b/lambdas/upsert-letter/src/handler/upsert-handler.ts @@ -57,7 +57,7 @@ function getOperationFromType(type: string): UpsertOperation { letterId: letterToInsert.id, supplierId: letterToInsert.supplierId, letterInsertRequest: request, - letterToInsert: letterToInsert, + letterToInsert, }); // emit success metric emitIndividualMetric( @@ -102,7 +102,7 @@ function getOperationFromType(type: string): UpsertOperation { letterId: letterToUpdate.id, supplierId: letterToUpdate.supplierId, letterUpdateRequest: request, - letterToUpdate: letterToUpdate, + letterToUpdate, }); emitIndividualMetric( deps.logger, From 5f16aee57d07a12dd6b25748aca4aeb8ad7c8bc4 Mon Sep 17 00:00:00 2001 From: Mark Slowey Date: Tue, 18 Aug 2026 15:06:07 +0100 Subject: [PATCH 4/4] remove erroneous comments --- lambdas/supplier-allocator/src/handler/allocation-config.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lambdas/supplier-allocator/src/handler/allocation-config.ts b/lambdas/supplier-allocator/src/handler/allocation-config.ts index 1f383645e..f9e7f92d1 100644 --- a/lambdas/supplier-allocator/src/handler/allocation-config.ts +++ b/lambdas/supplier-allocator/src/handler/allocation-config.ts @@ -81,16 +81,11 @@ export async function preferredSupplierPack( packSpecificationIds: string[], deps: Deps, ): Promise { - // Constraints const eligiblePacks: string[] = await filterPacksForLetter( letterEvent, packSpecificationIds, deps, ); - - // No eligible packs -> REJECTED - - // Check can a supplier fulfil the pack const preferredSupplierPacks: SupplierPack[] = await getPreferredSupplierPacks(eligiblePacks, suppliers, deps); const preferredPack: PackSpecification = await getPackSpecification(