Skip to content

Commit 862afe3

Browse files
committed
Merge branch 'main' into dependabotCombined
2 parents 077c96e + 4545aa0 commit 862afe3

33 files changed

Lines changed: 9711 additions & 9235 deletions

File tree

.github/actions/acceptance-tests/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ runs:
3737
- name: "Repo setup"
3838
uses: ./.github/actions/node-install
3939
with:
40-
node-version: ${{ steps.nodejs_version.outputs.nodejs_version }}
4140
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
4241

4342
- name: "Set PR NUMBER"

.github/actions/node-install/action.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: 'npm install and setup'
22
description: 'Setup node, authenticate github package repository and perform clean npm install'
33

44
inputs:
5-
node-version:
6-
description: 'Node.js version'
7-
required: true
85
GITHUB_TOKEN:
96
description: "Token for access to github package registry"
107
required: true
@@ -15,7 +12,7 @@ runs:
1512
- name: 'Use Node.js'
1613
uses: actions/setup-node@v6
1714
with:
18-
node-version: '${{ inputs.node-version }}'
15+
node-version-file: '.tool-versions'
1916
registry-url: 'https://npm.pkg.github.com'
2017
scope: '@nhsdigital'
2118

.github/workflows/pr_closed.yaml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
- name: Setup NodeJS
8181
uses: actions/setup-node@v4
8282
with:
83-
node-version: ${{ inputs.nodejs_version }}
83+
node-version-file: '.tool-versions'
8484
registry-url: 'https://npm.pkg.github.com'
8585

8686
- name: check if local version differs from latest published version
@@ -113,19 +113,14 @@ jobs:
113113
steps:
114114
- name: "Checkout code"
115115
uses: actions/checkout@v5.0.0
116-
- name: Setup NodeJS
117-
uses: actions/setup-node@v4
116+
- name: "Repo setup"
117+
uses: ./.github/actions/node-install
118118
with:
119-
node-version: ${{ inputs.nodejs_version }}
120-
registry-url: 'https://npm.pkg.github.com'
121-
- name: "Install dependencies"
122-
env:
123-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124-
run: npm ci
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125120
- name: "Run provider contract tests"
126121
run: make test-contract
127122
env:
128-
GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129124

130125
publish-event-schemas:
131126
name: Publish event schemas package to GitHub package registry
@@ -145,7 +140,7 @@ jobs:
145140
- name: Setup NodeJS
146141
uses: actions/setup-node@v4
147142
with:
148-
node-version: ${{ inputs.nodejs_version }}
143+
node-version-file: '.tool-versions'
149144
registry-url: 'https://npm.pkg.github.com'
150145

151146
- name: Install dependencies

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ test-component:
106106
test-performance:
107107
(cd tests && npm install && npm run test:performance)
108108

109+
test-contract: # Run provider contract tests @Testing
110+
npm run test:contracts --workspace tests/contracts/provider
111+
109112
version:
110113
rm -f .version
111114
make version-create-effective-file dir=.

internal/datastore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
3-
"@aws-sdk/client-dynamodb": "^3.858.0",
4-
"@aws-sdk/lib-dynamodb": "^3.858.0",
3+
"@aws-sdk/client-dynamodb": "^3.981.0",
4+
"@aws-sdk/lib-dynamodb": "^3.981.0",
55
"@internal/helpers": "*",
66
"pino": "^9.7.0",
77
"zod": "^4.1.11",

lambdas/api-handler/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"dependencies": {
3-
"@aws-sdk/client-dynamodb": "^3.925.0",
3+
"@aws-sdk/client-dynamodb": "^3.981.0",
44
"@aws-sdk/client-s3": "^3.925.0",
55
"@aws-sdk/client-sqs": "^3.925.0",
66
"@aws-sdk/lib-dynamodb": "^3.925.0",
77
"@aws-sdk/s3-request-presigner": "^3.925.0",
88
"@internal/datastore": "*",
99
"@internal/helpers": "*",
10-
"aws-lambda": "^1.0.7",
11-
"esbuild": "^0.25.11",
10+
"aws-embedded-metrics": "^4.2.1",
11+
"aws-lambda": "^1.0.6",
12+
"esbuild": "0.27.2",
1213
"pino": "^9.7.0",
1314
"zod": "^4.1.11"
1415
},
Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,66 @@
11
import { APIGatewayProxyHandler } from "aws-lambda";
2+
import { MetricsLogger, metricScope } from "aws-embedded-metrics";
23
import { assertNotEmpty } from "../utils/validation";
34
import { extractCommonIds } from "../utils/common-ids";
45
import { ApiErrorDetail } from "../contracts/errors";
56
import { processError } from "../mappers/error-mapper";
67
import ValidationError from "../errors/validation-error";
78
import { getLetterDataUrl } from "../services/letter-operations";
89
import type { Deps } from "../config/deps";
10+
import { MetricStatus, emitForSingleSupplier } from "../utils/metrics";
911

1012
export default function createGetLetterDataHandler(
1113
deps: Deps,
1214
): APIGatewayProxyHandler {
13-
return async (event) => {
14-
const commonIds = extractCommonIds(
15-
event.headers,
16-
event.requestContext,
17-
deps,
18-
);
19-
20-
if (!commonIds.ok) {
21-
return processError(
22-
commonIds.error,
23-
commonIds.correlationId,
24-
deps.logger,
15+
return metricScope((metrics: MetricsLogger) => {
16+
return async (event) => {
17+
const commonIds = extractCommonIds(
18+
event.headers,
19+
event.requestContext,
20+
deps,
2521
);
26-
}
2722

28-
try {
29-
const letterId = assertNotEmpty(
30-
event.pathParameters?.id,
31-
new ValidationError(
32-
ApiErrorDetail.InvalidRequestMissingLetterIdPathParameter,
33-
),
34-
);
23+
if (!commonIds.ok) {
24+
return processError(
25+
commonIds.error,
26+
commonIds.correlationId,
27+
deps.logger,
28+
);
29+
}
3530

36-
return {
37-
statusCode: 303,
38-
headers: {
39-
Location: await getLetterDataUrl(
40-
commonIds.value.supplierId,
41-
letterId,
42-
deps,
31+
const { supplierId } = commonIds.value;
32+
try {
33+
const letterId = assertNotEmpty(
34+
event.pathParameters?.id,
35+
new ValidationError(
36+
ApiErrorDetail.InvalidRequestMissingLetterIdPathParameter,
4337
),
44-
},
45-
body: "",
46-
};
47-
} catch (error) {
48-
return processError(error, commonIds.value.correlationId, deps.logger);
49-
}
50-
};
38+
);
39+
40+
emitForSingleSupplier(
41+
metrics,
42+
"getLetterData",
43+
supplierId,
44+
1,
45+
MetricStatus.Success,
46+
);
47+
return {
48+
statusCode: 303,
49+
headers: {
50+
Location: await getLetterDataUrl(supplierId, letterId, deps),
51+
},
52+
body: "",
53+
};
54+
} catch (error) {
55+
emitForSingleSupplier(
56+
metrics,
57+
"getLetterData",
58+
supplierId,
59+
1,
60+
MetricStatus.Failure,
61+
);
62+
return processError(error, commonIds.value.correlationId, deps.logger);
63+
}
64+
};
65+
});
5166
}
Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { APIGatewayProxyHandler } from "aws-lambda";
2+
import { MetricsLogger, metricScope } from "aws-embedded-metrics";
23
import { assertNotEmpty } from "../utils/validation";
34
import { extractCommonIds } from "../utils/common-ids";
45
import ValidationError from "../errors/validation-error";
@@ -7,53 +8,72 @@ import { getLetterById } from "../services/letter-operations";
78
import { processError } from "../mappers/error-mapper";
89
import { mapToGetLetterResponse } from "../mappers/letter-mapper";
910
import { Deps } from "../config/deps";
11+
import { MetricStatus, emitForSingleSupplier } from "../utils/metrics";
1012

13+
// Get letter data
1114
export default function createGetLetterHandler(
1215
deps: Deps,
1316
): APIGatewayProxyHandler {
14-
return async (event) => {
15-
const commonIds = extractCommonIds(
16-
event.headers,
17-
event.requestContext,
18-
deps,
19-
);
20-
21-
if (!commonIds.ok) {
22-
return processError(
23-
commonIds.error,
24-
commonIds.correlationId,
25-
deps.logger,
17+
return metricScope((metrics: MetricsLogger) => {
18+
return async (event) => {
19+
const commonIds = extractCommonIds(
20+
event.headers,
21+
event.requestContext,
22+
deps,
2623
);
27-
}
2824

29-
try {
30-
const letterId = assertNotEmpty(
31-
event.pathParameters?.id,
32-
new ValidationError(
33-
ApiErrorDetail.InvalidRequestMissingLetterIdPathParameter,
34-
),
35-
);
25+
if (!commonIds.ok) {
26+
return processError(
27+
commonIds.error,
28+
commonIds.correlationId,
29+
deps.logger,
30+
);
31+
}
3632

37-
const letter = await getLetterById(
38-
commonIds.value.supplierId,
39-
letterId,
40-
deps.letterRepo,
41-
);
33+
const { supplierId } = commonIds.value;
34+
try {
35+
const letterId = assertNotEmpty(
36+
event.pathParameters?.id,
37+
new ValidationError(
38+
ApiErrorDetail.InvalidRequestMissingLetterIdPathParameter,
39+
),
40+
);
41+
42+
const letter = await getLetterById(
43+
supplierId,
44+
letterId,
45+
deps.letterRepo,
46+
);
4247

43-
const response = mapToGetLetterResponse(letter);
48+
const response = mapToGetLetterResponse(letter);
4449

45-
deps.logger.info({
46-
description: "Letter successfully fetched by id",
47-
supplierId: commonIds.value.supplierId,
48-
letterId,
49-
});
50+
deps.logger.info({
51+
description: "Letter successfully fetched by id",
52+
supplierId,
53+
letterId,
54+
});
5055

51-
return {
52-
statusCode: 200,
53-
body: JSON.stringify(response, null, 2),
54-
};
55-
} catch (error) {
56-
return processError(error, commonIds.value.correlationId, deps.logger);
57-
}
58-
};
56+
emitForSingleSupplier(
57+
metrics,
58+
"getLetter",
59+
supplierId,
60+
1,
61+
MetricStatus.Success,
62+
);
63+
return {
64+
statusCode: 200,
65+
body: JSON.stringify(response, null, 2),
66+
};
67+
} catch (error) {
68+
emitForSingleSupplier(
69+
metrics,
70+
"getLetter",
71+
supplierId,
72+
1,
73+
MetricStatus.Failure,
74+
);
75+
return processError(error, commonIds.value.correlationId, deps.logger);
76+
}
77+
};
78+
});
5979
}

0 commit comments

Comments
 (0)