Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3f77980
inital changes for sha256
RossFaulds171 Jun 4, 2026
b95e224
use node:crypto instead of crypto
RossFaulds171 Jun 4, 2026
2cf4f51
Merge branch 'main' into feature/CCM-12600-add-sha256-hash-on-letters
RossFaulds171 Jun 4, 2026
6e0b2ef
remove blank line in object
RossFaulds171 Jun 4, 2026
1a2361b
temporarily see if Omit fixes test
RossFaulds171 Jun 4, 2026
d353991
removed temporary omit
RossFaulds171 Jun 4, 2026
a76506a
add sha256 test
RossFaulds171 Jun 5, 2026
9253cab
add sha256hash to test
RossFaulds171 Jun 5, 2026
27c745f
add sha256Hash to the getLetters endpoint
RossFaulds171 Jun 5, 2026
b472955
make sure sha256 passed across
RossFaulds171 Jun 5, 2026
18736bd
add sha256Hash generation in tests
RossFaulds171 Jun 8, 2026
d65c5a8
fix test and lint issue
RossFaulds171 Jun 8, 2026
ed10eb3
fix lint issue
RossFaulds171 Jun 8, 2026
ea726ec
fix another lint issue
RossFaulds171 Jun 8, 2026
3db34c7
add hash to tests
RossFaulds171 Jun 8, 2026
85efcec
add hash in more test data
RossFaulds171 Jun 8, 2026
3268427
fix dto issue
RossFaulds171 Jun 8, 2026
d6f65f0
fix uploadFile issue
RossFaulds171 Jun 9, 2026
b03d21e
add sha256 to projection
RossFaulds171 Jun 9, 2026
da529ac
amend sandbox and oas
RossFaulds171 Jun 9, 2026
d9bb54f
amend update letter queue lambda for sha256Hash
RossFaulds171 Jun 9, 2026
37c16a6
use correct hash exmaple
RossFaulds171 Jun 9, 2026
76b53b4
amend sandbox examples to use proper sha256 example
RossFaulds171 Jun 9, 2026
6d3e4bf
add component tests
RossFaulds171 Jun 9, 2026
0076f5d
lint fix
RossFaulds171 Jun 9, 2026
a60cf81
more lint fixes
RossFaulds171 Jun 9, 2026
2d4d790
yet more lint fixes
RossFaulds171 Jun 9, 2026
f65f222
add e2e test to compute hash of pdf and ensure matches
RossFaulds171 Jun 9, 2026
7fd7b55
Merge branch 'main' into feature/CCM-12600-add-sha256-hash-on-letters
RossFaulds171 Jun 10, 2026
2f0a569
Merge branch 'main' into feature/CCM-12600-add-sha256-hash-on-letters
RossFaulds171 Jun 11, 2026
fa5e051
remove hash test that had no real value
RossFaulds171 Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createLetter(
specificationId: "specification1",
groupId: "group1",
priority: 10,
sha256Hash: "hash1",
...overrides,
};
}
Expand Down
2 changes: 2 additions & 0 deletions internal/datastore/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const LetterSchemaBase = z.object({
groupId: z.string(),
reasonCode: z.string().optional(),
reasonText: z.string().optional(),
sha256Hash: z.string().optional(),
});

export const LetterSchema = LetterSchemaBase.extend({
Expand Down Expand Up @@ -87,6 +88,7 @@ export const PendingLetterSchemaBase = z.object({
letterId: idRef(LetterSchema, "id"),
specificationId: z.string(),
groupId: z.string(),
sha256Hash: z.string().optional(),
Comment thread
RossFaulds171 marked this conversation as resolved.
});

export const PendingLetterSchema = PendingLetterSchemaBase.extend({
Expand Down
1 change: 0 additions & 1 deletion internal/event-builders/src/letter-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function mapLetterToCloudEvent(
dataschemaversion,
source,
subject: `letter-origin/letter-rendering/letter/${letter.id}`,

data: {
domainId: letter.id as LetterStatusChangeEvent["data"]["domainId"],
status: letter.status,
Expand Down
2 changes: 2 additions & 0 deletions lambdas/api-handler/src/contracts/letters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const GetLetterResponseResourceSchema = z
groupId: z.string().optional(),
reasonCode: z.string().optional(),
reasonText: z.string().optional(),
sha256Hash: z.string().optional(),
})
.strict(),
})
Expand All @@ -66,6 +67,7 @@ export const GetLettersResponseResourceSchema = z
status: LetterStatusSchema,
specificationId: z.string(),
groupId: z.string().optional(),
sha256Hash: z.string().optional(),
})
.strict(),
})
Expand Down
90 changes: 90 additions & 0 deletions lambdas/api-handler/src/mappers/__tests__/letter-mapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,43 @@ describe("letter-mapper", () => {
});
});

it("maps an internal Letter to a GetLetterResponse with sha256Hash when present", () => {
const date = new Date().toISOString();
const letter: Letter = {
id: "abc123",
status: "PENDING",
supplierId: "supplier1",
specificationId: "spec123",
billingRef: "spec123",
groupId: "group123",
url: "https://example.com/letter/abc123",
createdAt: date,
updatedAt: date,
supplierStatus: "supplier1#PENDING",
supplierStatusSk: date,
ttl: 123,
sha256Hash: "abc123hash",
source: "/data-plane/letter-rendering/pdf",
subject: "letter-rendering/source/letter/letter-id",
specificationBillingId: "billing123",
};

const result: GetLetterResponse = mapToGetLetterResponse(letter);

expect(result).toEqual({
data: {
id: "abc123",
type: "Letter",
attributes: {
specificationId: "spec123",
status: "PENDING",
groupId: "group123",
sha256Hash: "abc123hash",
},
},
});
});

it("maps an internal Letter to a GetLetterResponse with reasonCode and reasonText when present", () => {
const date = new Date().toISOString();
const letter: Letter = {
Expand Down Expand Up @@ -209,4 +246,57 @@ describe("letter-mapper", () => {
],
});
});
it("maps an internal Letter collection to a GetLettersResponse with sha256Hash when present", () => {
const date = new Date().toISOString();
const letter: Letter = {
id: "abc123",
status: "PENDING",
supplierId: "supplier1",
specificationId: "spec123",
billingRef: "spec123",
groupId: "group123",
url: "https://example.com/letter/abc123",
createdAt: date,
updatedAt: date,
supplierStatus: "supplier1#PENDING",
supplierStatusSk: date,
ttl: 123,
reasonCode: "R01",
reasonText: "Reason text",
sha256Hash: "abc123hash",
source: "/data-plane/letter-rendering/pdf",
subject: "letter-rendering/source/letter/letter-id",
specificationBillingId: "billing123",
};

const result: GetLettersResponse = mapToGetLettersResponse([
letter,
letter,
]);

expect(result).toEqual({
data: [
{
id: "abc123",
type: "Letter",
attributes: {
specificationId: "spec123",
status: "PENDING",
groupId: "group123",
sha256Hash: "abc123hash",
},
},
{
id: "abc123",
type: "Letter",
attributes: {
specificationId: "spec123",
status: "PENDING",
groupId: "group123",
sha256Hash: "abc123hash",
},
},
],
});
});
});
2 changes: 2 additions & 0 deletions lambdas/api-handler/src/mappers/letter-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function letterToResourceResponse(letter: LetterBase) {
groupId: letter.groupId,
...(letter.reasonCode != null && { reasonCode: letter.reasonCode }),
...(letter.reasonText != null && { reasonText: letter.reasonText }),
...(letter.sha256Hash != null && { sha256Hash: letter.sha256Hash }),
},
};
}
Expand All @@ -34,6 +35,7 @@ function letterToGetLettersResourceResponse(letter: LetterBase) {
status: letter.status,
specificationId: letter.specificationId,
groupId: letter.groupId,
...(letter.sha256Hash != null && { sha256Hash: letter.sha256Hash }),
},
};
}
Expand Down
1 change: 1 addition & 0 deletions lambdas/api-handler/src/services/letter-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function mapPendingLetterToLetterBase(pending: PendingLetterBase): LetterBase {
status: "PENDING",
specificationId: pending.specificationId,
groupId: pending.groupId,
sha256Hash: pending.sha256Hash,
};
}

Expand Down
1 change: 1 addition & 0 deletions lambdas/update-letter-queue/src/update-letter-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ function mapLetterToPendingLetter(letter: Letter): InsertPendingLetter {
specificationId: letter.specificationId,
groupId: letter.groupId,
priority: letter.priority,
sha256Hash: letter.sha256Hash,
};
}

Expand Down
1 change: 1 addition & 0 deletions lambdas/upsert-letter/src/handler/upsert-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function mapToInsertLetter(
upsertRequest.data.templateId,
),
url: upsertRequest.data.url,
sha256Hash: upsertRequest.data.sha256Hash,
source: upsertRequest.source,
subject: upsertRequest.subject,
createdAt: now,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "PENDING"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "ACCEPTED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "PRINTED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "ENCLOSED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "DISPATCHED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "DELIVERED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": "R01",
"reasonText": "failed validation",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "REJECTED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": "R01",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "CANCELLED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": "R01",
"reasonText": "failed validation",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "FAILED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": "R01",
"reasonText": "failed validation",
"sha256Hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c8f2f1d2d1e4f6e8f7e6e8f7e6",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "RETURNED"
},
Expand Down
Loading
Loading