Skip to content

Commit

Permalink
chore(cb2-12275): update packages (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruairidh-BJSS authored May 28, 2024
1 parent 5556fd6 commit a787a56
Show file tree
Hide file tree
Showing 8 changed files with 13,161 additions and 28,649 deletions.
41,659 changes: 13,075 additions & 28,584 deletions package-lock.json

Large diffs are not rendered by default.

85 changes: 43 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test:integration": "cross-env NODE_ENV=test echo 'integration tests to be added'",
"test:integration:watch": "echo 'integration tests --watch to be added'",
"test:integration:coverage": "cross-env echo 'integration tests coverage to be added'",
"test": "npm-run-all lint test:unit:coverage test:integration:coverage",
"test": "npm-run-all test:unit:coverage test:integration:coverage",
"audit": "npm audit --prod",
"lint:analyse": "eslint . --ext js,ts --fix",
"lint:report": "npm run lint:analyse -- -f json -o reports/eslint/eslint-report.json",
Expand All @@ -40,49 +40,50 @@
"tools-setup": "echo 'nothing to do for now'"
},
"dependencies": {
"@aws-sdk/client-eventbridge": "3.556.0",
"@aws-sdk/util-dynamodb": "3.556.0",
"aws-lambda": "1.0.6",
"dateformat": "4.6.3",
"joi": "^14.3.1",
"luxon": "3.2.1",
"winston": "3.8.2"
"@aws-sdk/client-eventbridge": "^3.577.0",
"@aws-sdk/util-dynamodb": "^3.577.0",
"aws-lambda": "^1.0.7",
"dateformat": "^5.0.3",
"joi": "^17.13.1",
"luxon": "^3.4.4",
"winston": "^3.13.0"
},
"devDependencies": {
"@commitlint/cli": "14.1.0",
"@commitlint/config-conventional": "11.0.0",
"@dvsa/eslint-config-ts": "2.2.0",
"@types/aws-lambda": "8.10.70",
"@types/jest": "27.0.2",
"@types/luxon": "3.0.2",
"@types/node": "14.18.16",
"@types/supertest": "2.0.10",
"@typescript-eslint/eslint-plugin": "5.3.1",
"@typescript-eslint/parser": "5.3.1",
"aws-sdk-client-mock": "4.0.0",
"commitlint-plugin-function-rules": "1.1.20",
"concurrently": "6.3.0",
"cross-env": "7.0.3",
"eslint": "7.32.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-jest": "24.3.2",
"eslint-plugin-prettier": "3.3.1",
"husky": "8.0.1",
"jest": "27.3.1",
"npm-run-all": "4.1.5",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"semantic-release": "19.0.3",
"serverless": "3.22.0",
"serverless-offline": "11.0.1",
"serverless-offline-aws-eventbridge": "2.0.3",
"serverless-plugin-typescript": "2.1.5",
"sonar-scanner": "3.1.0",
"supertest": "6.0.1",
"ts-jest": "27.0.7",
"ts-loader": "8.0.14",
"ts-node": "9.1.1",
"typescript": "4.4.4"
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@dvsa/eslint-config-ts": "^3.0.1",
"@types/aws-lambda": "^8.10.138",
"@types/jest": "^29.5.12",
"@types/luxon": "^3.4.2",
"@types/node": "^20.12.12",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"aws-sdk-client-mock": "^4.0.0",
"commitlint-plugin-function-rules": "^4.0.0",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"rimraf": "^5.0.7",
"semantic-release": "^23.1.1",
"serverless": "^3.22.0",
"serverless-offline": "^13.6.0",
"serverless-offline-aws-eventbridge": "^2.1.0",
"serverless-plugin-typescript": "^2.1.5",
"sonar-scanner": "^3.1.0",
"supertest": "^7.0.0",
"ts-jest": "^29.1.3",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
"author": "",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions src/eventbridge/Send.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable security/detect-object-injection */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
Expand Down
1 change: 1 addition & 0 deletions src/utils/ExtractTestResults.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
Expand Down
3 changes: 2 additions & 1 deletion src/utils/HTTPError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

/**
Expand All @@ -13,7 +14,7 @@ export class HTTPError extends Error {
* @param statusCode the HTTP status code
* @param body - the response body
*/
constructor( statusCode: number, body: any) {
constructor(statusCode: number, body: any) {
super();
this.statusCode = statusCode;
this.body = body;
Expand Down
32 changes: 23 additions & 9 deletions src/utils/validators/McRequestSchema.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
/* eslint-disable */

import * as Joi from 'joi';
import Joi from 'joi';

export const mcRequestSchema = Joi.array().items({
vehicleIdentifier: Joi.string().required().max(8),
testDate: Joi.string().required(),
vin: Joi.string().required(),
testResult: Joi.string().required(),
hgvPsvTrailFlag: Joi.string().required(),
testResultId: Joi.string().required(),
});
export const mcRequestSchema = Joi.array().items(
Joi.object({
vehicleIdentifier: Joi.string().required().max(8).messages({
'any.required': '"vehicleIdentifier" is required',
'string.max': '"vehicleIdentifier" must be at most 8 characters long'
}),
testDate: Joi.string().required().messages({
'any.required': '"testDate" is required'
}),
vin: Joi.string().required().messages({
'any.required': '"vin" is required'
}),
testResult: Joi.string().required().messages({
'any.required': '"testResult" is required'
}),
hgvPsvTrailFlag: Joi.string().required().messages({
'any.required': '"hgvPsvTrailFlag" is required'
}),
testResultId: Joi.string().required().messages({
'any.required': '"testResultId" is required'
}),
}));
26 changes: 13 additions & 13 deletions tests/unit/Handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable no-underscore-dangle */
/* eslint-disable @typescript-eslint/ban-ts-comment */

import { mocked } from 'ts-jest/utils';
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable import/no-unresolved */
import { DynamoDBRecord, DynamoDBStreamEvent } from 'aws-lambda';
import { sendMCProhibition } from '../../src/eventbridge/Send';
import { SendResponse } from '../../src/eventbridge/SendResponse';
Expand All @@ -18,7 +18,7 @@ jest.mock('../../src/utils/ExtractTestResults');

describe('Application entry', () => {
let event: DynamoDBStreamEvent;
mocked(extractMCTestResults).mockReturnValue(Array<MCRequest>());
jest.mocked(extractMCTestResults).mockReturnValue(Array<MCRequest>());
afterEach(() => {
jest.clearAllMocks();
});
Expand All @@ -32,11 +32,11 @@ describe('Application entry', () => {
SuccessCount: 1,
FailCount: 0,
};
mocked(sendMCProhibition).mockResolvedValue(sendResponse);
jest.mocked(sendMCProhibition).mockResolvedValue(sendResponse);
await handler(event, null, (error: string | Error, result: string) => {
expect(result).toEqual('Data processed successfully.');
expect(result).toBe('Data processed successfully.');
expect(error).toBeNull();
expect(sendMCProhibition).toBeCalledTimes(1);
expect(sendMCProhibition).toHaveBeenCalledTimes(1);
});
});
it('When there is an event that gets processed successfully in proper case then no errors are produced', async () => {
Expand All @@ -48,23 +48,23 @@ describe('Application entry', () => {
SuccessCount: 1,
FailCount: 0,
};
mocked(sendMCProhibition).mockResolvedValue(sendResponse);
jest.mocked(sendMCProhibition).mockResolvedValue(sendResponse);
await handler(event, null, (error: string | Error, result: string) => {
expect(result).toEqual('Data processed successfully.');
expect(result).toBe('Data processed successfully.');
expect(error).toBeNull();
expect(sendMCProhibition).toBeCalledTimes(1);
expect(sendMCProhibition).toHaveBeenCalledTimes(1);
});
});
it('When there is an error when sending the object and error is produced', async () => {
process.env.SEND_TO_SMC = 'True';
event = {
Records: [dynamoRecordFiltered as DynamoDBRecord],
};
mocked(sendMCProhibition).mockRejectedValue(new Error('Oh no!'));
jest.mocked(sendMCProhibition).mockRejectedValue(new Error('Oh no!'));
await handler(event, null, (error: string | Error, result: string) => {
expect(error).toBeNull();
expect(result).toEqual('Data processed unsuccessfully: Error: Oh no!');
expect(sendMCProhibition).toBeCalledTimes(1);
expect(result).toBe('Data processed unsuccessfully: Error: Oh no!');
expect(sendMCProhibition).toHaveBeenCalledTimes(1);
});
});
it('When there is an invalid environment variable a log is produced', async () => {
Expand All @@ -76,7 +76,7 @@ describe('Application entry', () => {

await handler(event, null, (error: string | Error, result: string) => {
expect(error).toBeNull();
expect(result).toEqual('Function not triggered, Missing or not true environment variable present');
expect(result).toBe('Function not triggered, Missing or not true environment variable present');
});
});
});
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable no-underscore-dangle */
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable import/no-unresolved */

import { EOL } from 'os';
import logger from '../../src/observability/Logger';

Expand Down

0 comments on commit a787a56

Please sign in to comment.