From 5c0c30e67b9211837d598e016c9478b535844541 Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 26 Jan 2024 13:56:46 +0000 Subject: [PATCH 01/12] rectifying data type mismatches, add un-defined Enums and attributes, adding in-line comments --- src/models/adr-details.ts | 103 +++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 25 deletions(-) diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index 7767fee..6ed3593 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -1,6 +1,7 @@ import { DynamoDbImage, parseStringArray } from "../services/dynamodb-images"; import { Maybe } from "./optionals"; +// define AdrDetails' high-level attributes data types export interface AdrDetails { vehicleDetails?: VehicleDetails; listStatementApplicable?: boolean; @@ -9,12 +10,13 @@ export interface AdrDetails { brakeDeclarationsSeen?: boolean; brakeDeclarationIssuer?: string; brakeEndurance?: boolean; - weight?: string; - compatibilityGroupJ?: boolean; + weight?: number; + compatibilityGroupJ?: string; documents?: string[]; permittedDangerousGoods?: string[]; - additionalExaminerNotes?: string; + additionalExaminerNotes?: AdditionalExaminerNotes; applicantDetails?: ApplicantDetails; + dangerousGoods?: boolean; memosApply?: string[]; additionalNotes?: AdditionalNotes; adrTypeApprovalNo?: string; @@ -22,11 +24,45 @@ export interface AdrDetails { tank?: Tank; } +// define Enums +export type VehicleDetailsTypeEnum = "Artic tractor" | "Rigid box body" | "Rigid sheeted load" | "Rigid tank" | + "Rigid skeletal" | "Rigid battery" | "Full drawbar box body" | + "Full drawbar sheeted load" | "Full drawbar tank" | "Full drawbar skeletal" | + "Full drawbar battery" | "Centre axle box body" | "Centre axle sheeted load" | + "Centre axle tank" | "Centre axle skeletal" | "Centre axle battery" | + "Semi trailer box body" | "Semi trailer sheeted load" | "Semi trailer tank" | + "Semi trailer skeletal" | "Semi trailer battery Enum" + +export type Tc2TypeEnum = "initial"; + +export type Tc3TypeEnum = "intermediate" | "periodic" | "exceptional"; + +export type permittedDangerousGoodsEnum = "FP <61 (FL)" | "AT" | "Class 5.1 Hydrogen Peroxide (OX)" | "MEMU" | + "Carbon Disulphide" | "Hydrogen" | "Explosives (type 2)" | "Explosives (type 3)" + +export type compatibilityGroupJEnum = "I" | "E" + +export type additionalNotesNumberEnum = "1" | "1A" | "2" | "3" | "V1B" | "T1B" + +export type substancesPermittedEnum = "Substances permitted under the tank code and any special provisions specified in 9 may be carried" | + "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried" + +export type memosApplyEnum = "07/09 3mth leak ext" + +// define AdrDetails' sub-attributes data types export interface VehicleDetails { - type?: string; + type?: VehicleDetailsTypeEnum; approvalDate?: string; } +export type AdditionalExaminerNotes = AdditionalExaminerNotesItems[]; + +export interface AdditionalExaminerNotesItems { + note?: string; + createdAtDate?: string; + lastUpdatedBy?: string; +} + export interface ApplicantDetails { name?: string; street?: string; @@ -36,8 +72,8 @@ export interface ApplicantDetails { } export interface AdditionalNotes { - number?: string[]; - guidanceNotes?: string[]; + number?: additionalNotesNumberEnum[]; + // guidanceNotes?: string[]; } export interface Tank { @@ -58,6 +94,7 @@ export interface TankDetails { export interface TankStatement { substancesPermitted?: string; + select?: string; statement?: string; productListRefNo?: string; productListUnNo?: string[]; @@ -65,23 +102,21 @@ export interface TankStatement { } export interface Tc2Details { - tc2Type?: Tc2Type; + tc2Type?: Tc2TypeEnum; tc2IntermediateApprovalNo?: string; tc2IntermediateExpiryDate?: string; } -export type Tc2Type = "initial"; export type Tc3Details = Tc3DetailsItem[]; export interface Tc3DetailsItem { - tc3Type?: Tc3Type; + tc3Type?: Tc3TypeEnum; tc3PeriodicNumber?: string; tc3PeriodicExpiryDate?: string; } -export type Tc3Type = "intermediate" | "periodic" | "exceptional"; - +// function to parse AdrDetails' high-level and sub attributes + return AdrDetails object export const parseAdrDetails = ( adrDetails?: DynamoDbImage ): Maybe => { @@ -93,10 +128,10 @@ export const parseAdrDetails = ( "additionalNotes" )!; const additionalNotes: AdditionalNotes = { - number: parseStringArray(additionalNotesImage.getList("number")), - guidanceNotes: parseStringArray( - additionalNotesImage.getList("guidanceNotes") - ), + number: parseStringArray(additionalNotesImage.getList("number")) as additionalNotesNumberEnum[], + // guidanceNotes: parseStringArray( + // additionalNotesImage.getList("guidanceNotes") + // ), }; const applicantDetailsImage: DynamoDbImage = adrDetails.getMap( @@ -114,7 +149,7 @@ export const parseAdrDetails = ( "vehicleDetails" )!; const vehicleDetails: VehicleDetails = { - type: vehicleDetailsImage.getString("type"), + type: vehicleDetailsImage.getString("type") as VehicleDetailsTypeEnum, approvalDate: vehicleDetailsImage.getString("approvalDate"), }; @@ -124,7 +159,7 @@ export const parseAdrDetails = ( const tc2DetailsImage: DynamoDbImage = tankDetailsImage.getMap("tc2Details")!; const tc2Details: Tc2Details = { - tc2Type: tc2DetailsImage.getString("tc2Type") as Tc2Type, + tc2Type: tc2DetailsImage.getString("tc2Type") as Tc2TypeEnum, tc2IntermediateApprovalNo: tc2DetailsImage.getString( "tc2IntermediateApprovalNo" ), @@ -141,7 +176,7 @@ export const parseAdrDetails = ( for (const key of tc3DetailsImage.getKeys()) { const tc3DetailsItemImage = tc3DetailsImage.getMap(key)!; tc3Details.push({ - tc3Type: tc3DetailsItemImage.getString("tc3Type") as Tc3Type, + tc3Type: tc3DetailsItemImage.getString("tc3Type") as Tc3TypeEnum, tc3PeriodicNumber: tc3DetailsItemImage.getString("tc3PeriodicNumber"), tc3PeriodicExpiryDate: tc3DetailsItemImage.getString( "tc3PeriodicExpiryDate" @@ -151,7 +186,7 @@ export const parseAdrDetails = ( const tankDetails: TankDetails = { tankManufacturer: tankDetailsImage.getString("tankManufacturer"), - yearOfManufacture: 0, + yearOfManufacture: tankDetailsImage.getNumber("yearOfManufacture"), tankCode: tankDetailsImage.getString("tankCode"), specialProvisions: tankDetailsImage.getString("specialProvisions"), tankManufacturerSerialNo: tankDetailsImage.getString( @@ -164,7 +199,8 @@ export const parseAdrDetails = ( const tankStatementImage: DynamoDbImage = tankImage.getMap("tankStatement")!; const tankStatement: TankStatement = { - substancesPermitted: tankStatementImage.getString("substancesPermitted"), + substancesPermitted: tankStatementImage.getString("substancesPermitted") as substancesPermittedEnum, + select: tankStatementImage.getString("select"), statement: tankStatementImage.getString("statement"), productListRefNo: tankStatementImage.getString("productListRefNo"), productListUnNo: parseStringArray( @@ -178,6 +214,22 @@ export const parseAdrDetails = ( tankStatement, }; + + const additionalExaminerNotesImage: DynamoDbImage = adrDetails.getList( + "additionalExaminerNotes" + )!; + const additionalExaminerNotes: AdditionalExaminerNotes = []; + + for (const key of additionalExaminerNotesImage.getKeys()) { + const additionalExaminerNotesItemImage = additionalExaminerNotesImage.getMap(key)!; + additionalExaminerNotes.push({ + note: additionalExaminerNotesItemImage.getString("note"), + createdAtDate: additionalExaminerNotesItemImage.getString("createdAtDate"), + lastUpdatedBy: additionalExaminerNotesItemImage.getString("lastUpdatedBy"), + }); + }; + + return { vehicleDetails, listStatementApplicable: adrDetails.getBoolean("listStatementApplicable"), @@ -186,15 +238,16 @@ export const parseAdrDetails = ( brakeDeclarationsSeen: adrDetails.getBoolean("brakeDeclarationsSeen"), brakeDeclarationIssuer: adrDetails.getString("brakeDeclarationIssuer"), brakeEndurance: adrDetails.getBoolean("brakeEndurance"), - weight: adrDetails.getString("weight"), - compatibilityGroupJ: adrDetails.getBoolean("compatibilityGroupJ"), + weight: adrDetails.getNumber("weight"), + compatibilityGroupJ: adrDetails.getString("compatibilityGroupJ") as compatibilityGroupJEnum, documents: parseStringArray(adrDetails.getList("documents")), permittedDangerousGoods: parseStringArray( adrDetails.getList("permittedDangerousGoods") - ), - additionalExaminerNotes: adrDetails.getString("additionalExaminerNotes"), + ) as permittedDangerousGoodsEnum[], + additionalExaminerNotes: additionalExaminerNotes, applicantDetails, - memosApply: parseStringArray(adrDetails.getList("memosApply")), + dangerousGoods: adrDetails.getBoolean("dangerousGoods"), + memosApply: parseStringArray(adrDetails.getList("memosApply")) as memosApplyEnum[], additionalNotes, adrTypeApprovalNo: adrDetails.getString("adrTypeApprovalNo"), adrCertificateNotes: adrDetails.getString("adrCertificateNotes"), From 96b894ec39954074951c087e7c873468e1464cd0 Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 26 Jan 2024 13:57:57 +0000 Subject: [PATCH 02/12] add AdrCertificateDetails interface and parsing function --- src/models/adr-certificate-details.ts | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/models/adr-certificate-details.ts diff --git a/src/models/adr-certificate-details.ts b/src/models/adr-certificate-details.ts new file mode 100644 index 0000000..b3ebca2 --- /dev/null +++ b/src/models/adr-certificate-details.ts @@ -0,0 +1,49 @@ +import { DynamoDbImage } from "../services/dynamodb-images"; +import { Maybe } from "./optionals"; + +// define AdrCertificateDetails' high-level attributes data types +export interface AdrCertificateDetails { + adrPassCertificateDetails?: AdrPassCertificateDetails; +} + +// define Enums +export type certificateIdEnum = "PASS" | "REPLACEMENT" + +// define AdrCertificateDetails' sub-attributes data types +export type AdrPassCertificateDetails = AdrPassCertificateDetailsItems[]; + +export interface AdrPassCertificateDetailsItems { + createdByName?: string; + certificateType?: string; + generatedTimestamp?: string; + certificateId?: string; + } + +// function to parse AdrCertificateDetails' high-level and sub attributes + return AdrCertificateDetails object +export const parseAdrCertificateDetails = ( + certificateDetails?: DynamoDbImage + ): Maybe => { + if (!certificateDetails) { + return undefined; + } + + const adrPassCertificateDetailsImage: DynamoDbImage = certificateDetails.getList( + "adrPassCertificateDetails" + )!; + const adrPassCertificateDetails: AdrPassCertificateDetails = []; + + for (const key of adrPassCertificateDetailsImage.getKeys()) { + const adrPassCertificateDetailsItemImage = adrPassCertificateDetailsImage.getMap(key)!; + adrPassCertificateDetails.push({ + createdByName: adrPassCertificateDetailsItemImage.getString("createdByName"), + certificateType: adrPassCertificateDetailsItemImage.getString("certificateType"), + generatedTimestamp: adrPassCertificateDetailsItemImage.getString("generatedTimestamp"), + certificateId: adrPassCertificateDetailsItemImage.getString("certificateId") as certificateIdEnum, + }); + } + + + return { + adrPassCertificateDetails + }; +}; \ No newline at end of file From 722ebfdb4b07a892402bb51e75d7eccee431174a Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 26 Jan 2024 16:35:21 +0000 Subject: [PATCH 03/12] adding guidanceNotes Enum --- src/models/adr-details.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index 6ed3593..fcb8480 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -44,6 +44,8 @@ export type compatibilityGroupJEnum = "I" | "E" export type additionalNotesNumberEnum = "1" | "1A" | "2" | "3" | "V1B" | "T1B" +export type additionalNotesguidanceNotesEnum = "New certificate requested" | "M145 Statement" + export type substancesPermittedEnum = "Substances permitted under the tank code and any special provisions specified in 9 may be carried" | "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried" @@ -73,7 +75,7 @@ export interface ApplicantDetails { export interface AdditionalNotes { number?: additionalNotesNumberEnum[]; - // guidanceNotes?: string[]; + guidanceNotes?: additionalNotesguidanceNotesEnum[]; } export interface Tank { @@ -129,9 +131,9 @@ export const parseAdrDetails = ( )!; const additionalNotes: AdditionalNotes = { number: parseStringArray(additionalNotesImage.getList("number")) as additionalNotesNumberEnum[], - // guidanceNotes: parseStringArray( - // additionalNotesImage.getList("guidanceNotes") - // ), + guidanceNotes: parseStringArray( + additionalNotesImage.getList("guidanceNotes") + ) as additionalNotesguidanceNotesEnum[], }; const applicantDetailsImage: DynamoDbImage = adrDetails.getMap( From f373b0a3cf1d60affc1031234565d1706e7cbccb Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Mon, 29 Jan 2024 10:36:55 +0000 Subject: [PATCH 04/12] adding m145 attribute as per documentation change --- src/models/adr-details.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index fcb8480..ba1a65d 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -18,6 +18,7 @@ export interface AdrDetails { applicantDetails?: ApplicantDetails; dangerousGoods?: boolean; memosApply?: string[]; + m145?: boolean; additionalNotes?: AdditionalNotes; adrTypeApprovalNo?: string; adrCertificateNotes?: string; @@ -44,7 +45,7 @@ export type compatibilityGroupJEnum = "I" | "E" export type additionalNotesNumberEnum = "1" | "1A" | "2" | "3" | "V1B" | "T1B" -export type additionalNotesguidanceNotesEnum = "New certificate requested" | "M145 Statement" +// export type additionalNotesguidanceNotesEnum = "New certificate requested" | "M145 Statement" export type substancesPermittedEnum = "Substances permitted under the tank code and any special provisions specified in 9 may be carried" | "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried" @@ -75,7 +76,7 @@ export interface ApplicantDetails { export interface AdditionalNotes { number?: additionalNotesNumberEnum[]; - guidanceNotes?: additionalNotesguidanceNotesEnum[]; + // guidanceNotes?: additionalNotesguidanceNotesEnum[]; } export interface Tank { @@ -131,9 +132,9 @@ export const parseAdrDetails = ( )!; const additionalNotes: AdditionalNotes = { number: parseStringArray(additionalNotesImage.getList("number")) as additionalNotesNumberEnum[], - guidanceNotes: parseStringArray( - additionalNotesImage.getList("guidanceNotes") - ) as additionalNotesguidanceNotesEnum[], + // guidanceNotes: parseStringArray( + // additionalNotesImage.getList("guidanceNotes") + // ) as additionalNotesguidanceNotesEnum[], }; const applicantDetailsImage: DynamoDbImage = adrDetails.getMap( @@ -250,6 +251,7 @@ export const parseAdrDetails = ( applicantDetails, dangerousGoods: adrDetails.getBoolean("dangerousGoods"), memosApply: parseStringArray(adrDetails.getList("memosApply")) as memosApplyEnum[], + m145: adrDetails.getBoolean("m145"), additionalNotes, adrTypeApprovalNo: adrDetails.getString("adrTypeApprovalNo"), adrCertificateNotes: adrDetails.getString("adrCertificateNotes"), From e8eb8275699e98fadf5fe68ddd3d7f7158926cc5 Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Thu, 1 Feb 2024 16:00:33 +0000 Subject: [PATCH 05/12] feat: adr details added, test resource for technoical record added, unit test added --- src/models/adr-certificate-details.ts | 14 +- src/models/adr-details.ts | 46 +- src/models/tech-record.ts | 7 +- tests/resources/Dockerfile | 2 +- ...amodb-image-technical-record-with-adr.json | 847 ++++++++++++++++++ .../models/tech-record-document.unitTest.ts | 132 ++- tsconfig.json | 2 +- 7 files changed, 1013 insertions(+), 37 deletions(-) create mode 100644 tests/resources/dynamodb-image-technical-record-with-adr.json diff --git a/src/models/adr-certificate-details.ts b/src/models/adr-certificate-details.ts index b3ebca2..f4c8c56 100644 --- a/src/models/adr-certificate-details.ts +++ b/src/models/adr-certificate-details.ts @@ -7,9 +7,9 @@ export interface AdrCertificateDetails { } // define Enums -export type certificateIdEnum = "PASS" | "REPLACEMENT" +export type certificateIdEnum = "PASS" | "REPLACEMENT"; -// define AdrCertificateDetails' sub-attributes data types +// define AdrCertificateDetails' sub-attributes data types export type AdrPassCertificateDetails = AdrPassCertificateDetailsItems[]; export interface AdrPassCertificateDetailsItems { @@ -41,9 +41,7 @@ export const parseAdrCertificateDetails = ( certificateId: adrPassCertificateDetailsItemImage.getString("certificateId") as certificateIdEnum, }); } - - - return { - adrPassCertificateDetails - }; -}; \ No newline at end of file + return { + adrPassCertificateDetails + }; +}; diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index ba1a65d..f9dbde3 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -11,13 +11,13 @@ export interface AdrDetails { brakeDeclarationIssuer?: string; brakeEndurance?: boolean; weight?: number; - compatibilityGroupJ?: string; + compatibilityGroupJ?: compatibilityGroupJEnum; documents?: string[]; - permittedDangerousGoods?: string[]; + permittedDangerousGoods?: permittedDangerousGoodsEnum[]; additionalExaminerNotes?: AdditionalExaminerNotes; applicantDetails?: ApplicantDetails; dangerousGoods?: boolean; - memosApply?: string[]; + memosApply?: memosApplyEnum[]; m145?: boolean; additionalNotes?: AdditionalNotes; adrTypeApprovalNo?: string; @@ -26,33 +26,35 @@ export interface AdrDetails { } // define Enums -export type VehicleDetailsTypeEnum = "Artic tractor" | "Rigid box body" | "Rigid sheeted load" | "Rigid tank" | - "Rigid skeletal" | "Rigid battery" | "Full drawbar box body" | - "Full drawbar sheeted load" | "Full drawbar tank" | "Full drawbar skeletal" | - "Full drawbar battery" | "Centre axle box body" | "Centre axle sheeted load" | - "Centre axle tank" | "Centre axle skeletal" | "Centre axle battery" | - "Semi trailer box body" | "Semi trailer sheeted load" | "Semi trailer tank" | - "Semi trailer skeletal" | "Semi trailer battery Enum" +export type VehicleDetailsTypeEnum = "Artic tractor" | "Rigid box body" | "Rigid sheeted load" | "Rigid tank" | + "Rigid skeletal" | "Rigid battery" | "Full drawbar box body" | + "Full drawbar sheeted load" | "Full drawbar tank" | "Full drawbar skeletal" | + "Full drawbar battery" | "Centre axle box body" | "Centre axle sheeted load" | + "Centre axle tank" | "Centre axle skeletal" | "Centre axle battery" | + "Semi trailer box body" | "Semi trailer sheeted load" | "Semi trailer tank" | + "Semi trailer skeletal" | "Semi trailer battery Enum"; export type Tc2TypeEnum = "initial"; export type Tc3TypeEnum = "intermediate" | "periodic" | "exceptional"; export type permittedDangerousGoodsEnum = "FP <61 (FL)" | "AT" | "Class 5.1 Hydrogen Peroxide (OX)" | "MEMU" | - "Carbon Disulphide" | "Hydrogen" | "Explosives (type 2)" | "Explosives (type 3)" + "Carbon Disulphide" | "Hydrogen" | "Explosives (type 2)" | "Explosives (type 3)"; -export type compatibilityGroupJEnum = "I" | "E" +export type compatibilityGroupJEnum = "I" | "E"; -export type additionalNotesNumberEnum = "1" | "1A" | "2" | "3" | "V1B" | "T1B" +export type additionalNotesNumberEnum = "1" | "1A" | "2" | "3" | "V1B" | "T1B"; // export type additionalNotesguidanceNotesEnum = "New certificate requested" | "M145 Statement" export type substancesPermittedEnum = "Substances permitted under the tank code and any special provisions specified in 9 may be carried" | - "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried" + "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried"; -export type memosApplyEnum = "07/09 3mth leak ext" +export type memosApplyEnum = "07/09 3mth leak ext"; -// define AdrDetails' sub-attributes data types +export type tankStatementSelectEnum = "Statement" | "Product list"; + +// define AdrDetails' sub-attributes data types export interface VehicleDetails { type?: VehicleDetailsTypeEnum; approvalDate?: string; @@ -96,8 +98,8 @@ export interface TankDetails { } export interface TankStatement { - substancesPermitted?: string; - select?: string; + select?: tankStatementSelectEnum; + substancesPermitted?: substancesPermittedEnum; statement?: string; productListRefNo?: string; productListUnNo?: string[]; @@ -119,7 +121,7 @@ export interface Tc3DetailsItem { tc3PeriodicExpiryDate?: string; } -// function to parse AdrDetails' high-level and sub attributes + return AdrDetails object +// function to parse AdrDetails' high-level and sub attributes + return AdrDetails object export const parseAdrDetails = ( adrDetails?: DynamoDbImage ): Maybe => { @@ -203,7 +205,7 @@ export const parseAdrDetails = ( const tankStatementImage: DynamoDbImage = tankImage.getMap("tankStatement")!; const tankStatement: TankStatement = { substancesPermitted: tankStatementImage.getString("substancesPermitted") as substancesPermittedEnum, - select: tankStatementImage.getString("select"), + select: tankStatementImage.getString("select") as tankStatementSelectEnum, statement: tankStatementImage.getString("statement"), productListRefNo: tankStatementImage.getString("productListRefNo"), productListUnNo: parseStringArray( @@ -230,7 +232,7 @@ export const parseAdrDetails = ( createdAtDate: additionalExaminerNotesItemImage.getString("createdAtDate"), lastUpdatedBy: additionalExaminerNotesItemImage.getString("lastUpdatedBy"), }); - }; + } return { @@ -247,7 +249,7 @@ export const parseAdrDetails = ( permittedDangerousGoods: parseStringArray( adrDetails.getList("permittedDangerousGoods") ) as permittedDangerousGoodsEnum[], - additionalExaminerNotes: additionalExaminerNotes, + additionalExaminerNotes, applicantDetails, dangerousGoods: adrDetails.getBoolean("dangerousGoods"), memosApply: parseStringArray(adrDetails.getList("memosApply")) as memosApplyEnum[], diff --git a/src/models/tech-record.ts b/src/models/tech-record.ts index 29aa1c0..063b73f 100644 --- a/src/models/tech-record.ts +++ b/src/models/tech-record.ts @@ -14,7 +14,8 @@ import { Microfilm, parseMicrofilm } from "./microfilm"; import { parsePlates, Plates } from "./plates"; import { BodyType, parseBodyType } from "./body-type"; import { Dimensions, parseDimensions } from "./dimensions"; -import { AdrDetails } from "./adr-details"; +import { AdrDetails, parseAdrDetails } from "./adr-details"; +import { AdrCertificateDetails, parseAdrCertificateDetails } from "./adr-certificate-details"; import { parseVehicleClass, VehicleClass } from "./vehicle-class"; import { Brakes, parseBrakes } from "./brakes"; import { Axles, parseAxles } from "./axles"; @@ -114,6 +115,7 @@ export interface TechRecord { noOfAxles?: number; brakeCode?: string; adrDetails?: AdrDetails; + adrCertificateDetails?: AdrCertificateDetails; createdByName?: string; createdById?: string; lastUpdatedByName?: string; @@ -270,7 +272,8 @@ const parseTechRecord = (image: DynamoDbImage): TechRecord => { notes: image.getString("notes"), noOfAxles: image.getNumber("noOfAxles"), brakeCode: image.getString("brakeCode"), - adrDetails: undefined, // intentional - not implemented. parseAdrDetails(image.getMap("adrDetails")) + adrDetails: parseAdrDetails(image.getMap("adrDetails")), + adrCertificateDetails: parseAdrCertificateDetails(image.getMap("certificateDetails")), createdByName: image.getString("createdByName"), createdById: image.getString("createdById"), lastUpdatedByName: image.getString("lastUpdatedByName"), diff --git a/tests/resources/Dockerfile b/tests/resources/Dockerfile index b6d6a32..25ca559 100644 --- a/tests/resources/Dockerfile +++ b/tests/resources/Dockerfile @@ -1,5 +1,5 @@ # Match Aurora MySQL version as closely as possible -FROM mysql:5.7.12 +FROM mysql:8.2.0 ENV MYSQL_DATABASE=CVSBNOP \ MYSQL_ROOT_PASSWORD=12345 diff --git a/tests/resources/dynamodb-image-technical-record-with-adr.json b/tests/resources/dynamodb-image-technical-record-with-adr.json new file mode 100644 index 0000000..48dceaf --- /dev/null +++ b/tests/resources/dynamodb-image-technical-record-with-adr.json @@ -0,0 +1,847 @@ +{ + "systemNumber": { + "S": "SYSTEM-NUMBER-1" + }, + "partialVin": { + "S": "PARTIAL-VIN" + }, + "primaryVrm": { + "S": "VRM-1" + }, + "secondaryVrms": { + "L": [ + { + "S": "SECONDARY-VRM" + } + ] + }, + "vin": { + "S": "VIN-1" + }, + "trailerId": { + "S": "TRL-1" + }, + "techRecord": { + "L": [ + { + "M": { + "adrDetails": { + "M": { + "additionalExaminerNotes": { + "L": [ + { + "M": { + "note": { + "S": "additionalExaminerNotes_note_1" + }, + "createdAtDate": { + "S": "2023-05-30" + }, + "lastUpdatedBy": { + "S": "additionalExaminerNotes_lastUpdatedBy_1" + } + } + } + ] + }, + "additionalNotes": { + "M": { + "number": { + "L": [ + {"S": "1"}, + {"S": "T1B"} + ] + } + } + }, + "adrCertificateNotes": { + "S": "adrCertificateNotes_1" + }, + "adrTypeApprovalNo": { + "S": "adrTypeApprovalNo_1" + }, + "applicantDetails": { + "M": { + "name": { + "S": "adrDetails_applicantDetails_name_1" + }, + "street": { + "S": "adrDetails_applicantDetails_street_1" + }, + "town": { + "S": "adrDetails_applicantDetails_town_1" + }, + "city": { + "S": "adrDetails_applicantDetails_city_1" + }, + "postcode": { + "S": "adrDetails_applicantDetails_postcode_1" + } + } + }, + "batteryListNumber": { + "S": "batteryListNumber_1" + }, + "brakeDeclarationIssuer": { + "S": "brakeDeclarationIssuer_1" + }, + "brakeDeclarationsSeen": { + "BOOL": true + }, + "brakeEndurance": { + "BOOL": false + }, + "compatibilityGroupJ": { + "S": "I" + }, + "dangerousGoods": { + "BOOL": false + }, + "declarationsSeen": { + "BOOL": false + }, + "documents": { + "L": [ + { + "S": "documents_1" + }, + { + "S": "documents_2" + }, + { + "S": "documents_3" + } + ] + }, + "listStatementApplicable": { + "BOOL": true + }, + "m145": { + "BOOL": true + }, + "memosApply": { + "L": [ + { + "S": "07/09 3mth leak ext" + } + ] + }, + "permittedDangerousGoods": { + "L": [ + { + "S": "FP <61 (FL)" + }, + { + "S": "Carbon Disulphide" + }, + { + "S": "Hydrogen" + } + ] + }, + "tank": { + "M": { + "tankDetails": { + "M": { + "tankManufacturer": { + "S": "tankManufacturer_1" + }, + "yearOfManufacture": { + "N": "1234" + }, + "tankCode": { + "S": "tankCode_1" + }, + "specialProvisions": { + "S": "specialProvisions_1" + }, + "tankManufacturerSerialNo": { + "S": "1234" + }, + "tankTypeAppNo": { + "S": "9876" + }, + "tc2Details": { + "M": { + "tc2Type": { + "S": "initial" + }, + "tc2IntermediateApprovalNo": { + "S": "12345" + }, + "tc2IntermediateExpiryDate": { + "S": "2024-06-01" + } + } + }, + "tc3Details": { + "L": [ + { + "M": { + "tc3Type": { + "S": "intermediate" + }, + "tc3PeriodicNumber": { + "S": "98765" + }, + "tc3PeriodicExpiryDate": { + "S": "2024-06-01" + } + } + } + ] + } + } + }, + "tankStatement": { + "M": { + "select":{ + "S": "Product list" + }, + "substancesPermitted": { + "S": "Substances permitted under the tank code and any special provisions specified in 9 may be carried" + }, + "statement": { + "S": "statement_1" + }, + "productListRefNo": { + "S": "123456" + }, + "productListUnNo": { + "L": [ + { + "S": "123123" + }, + { + "S": "987987" + }, + { + "S": "135790" + } + ] + }, + "productList": { + "S": "productList_1" + } + } + } + } + }, + "vehicleDetails": { + "M": { + "type": { + "S": "Artic tractor" + }, + "approvalDate": { + "S": "2023-06-12" + } + } + }, + "weight": { + "N": "6789" + } + } + }, + "recordCompleteness": { + "S": "88888888" + }, + "createdAt": { + "S": "2020-01-01T00:00:00.055Z" + }, + "lastUpdatedAt": { + "S": "2020-01-01T00:00:00.000000Z" + }, + "make": { + "S": "MAKE" + }, + "model": { + "S": "MODEL" + }, + "functionCode": { + "S": "1" + }, + "fuelPropulsionSystem": { + "S": "DieselPetrol" + }, + "offRoad": { + "BOOL": true + }, + "numberOfWheelsDriven": { + "N": "1" + }, + "euVehicleCategory": { + "S": "m1" + }, + "emissionsLimit": { + "N": "1" + }, + "departmentalVehicleMarker": { + "BOOL": true + }, + "authIntoService": { + "M": { + "cocIssueDate": { + "S": "2020-01-01" + }, + "dateAuthorised": { + "S": "2020-02-02" + }, + "datePending": { + "S": "2020-03-03" + }, + "dateReceived": { + "S": "2020-04-04" + }, + "dateRejected": { + "S": "2020-05-05" + } + } + }, + "lettersOfAuth": { + "M": { + "letterType": { + "S": "Trailer authorization" + }, + "letterDateRequested": { + "S": "2020-01-01" + }, + "letterContents": { + "S": "LETTER-CONTENTS" + } + } + }, + "alterationMarker": { + "BOOL": true + }, + "approvalType": { + "S": "NTA" + }, + "approvalTypeNumber": { + "S": "1" + }, + "variantNumber": { + "S": "1" + }, + "variantVersionNumber": { + "S": "1" + }, + "grossEecWeight": { + "N": "1" + }, + "trainEecWeight": { + "N": "1" + }, + "maxTrainEecWeight": { + "N": "1" + }, + "applicantDetails": { + "M": { + "name": { + "S": "NAME" + }, + "address1": { + "S": "ADDRESS-1" + }, + "address2": { + "S": "ADDRESS-2" + }, + "postTown": { + "S": "POST-TOWN" + }, + "address3": { + "S": "ADDRESS-3" + }, + "postCode": { + "S": "POST-CODE" + }, + "emailAddress": { + "S": "EMAIL-ADDRESS" + }, + "telephoneNumber": { + "S": "TELEPHONE-NUMBER" + } + } + }, + "purchaserDetails": { + "M": { + "name": { + "S": "NAME" + }, + "address1": { + "S": "ADDRESS-1" + }, + "address2": { + "S": "ADDRESS-2" + }, + "postTown": { + "S": "POST-TOWN" + }, + "address3": { + "S": "ADDRESS-3" + }, + "postCode": { + "S": "POST-CODE" + }, + "emailAddress": { + "S": "EMAIL-ADDRESS" + }, + "telephoneNumber": { + "S": "TELEPHONE-NUMBER" + }, + "faxNumber": { + "S": "FAX-NUMBER" + }, + "purchaserNotes": { + "S": "PURCHASER-NOTES" + } + } + }, + "manufacturerDetails": { + "M": { + "name": { + "S": "NAME" + }, + "address1": { + "S": "ADDRESS-1" + }, + "address2": { + "S": "ADDRESS-2" + }, + "postTown": { + "S": "POST-TOWN" + }, + "address3": { + "S": "ADDRESS-3" + }, + "postCode": { + "S": "POST-CODE" + }, + "emailAddress": { + "S": "EMAIL-ADDRESS" + }, + "telephoneNumber": { + "S": "TELEPHONE-NUMBER" + }, + "faxNumber": { + "S": "FAX-NUMBER" + }, + "manufacturerNotes": { + "S": "MANUFACTURER-NOTES" + } + } + }, + "microfilm": { + "M": { + "microfilmDocumentType": { + "S": "PSV Miscellaneous" + }, + "microfilmRollNumber": { + "S": "1" + }, + "microfilmSerialNumber": { + "S": "1" + } + } + }, + "plates": { + "L": [ + { + "M": { + "plateSerialNumber": { + "S": "1" + }, + "plateIssueDate": { + "S": "2020-01-01" + }, + "plateReasonForIssue": { + "S": "Free replacement" + }, + "plateIssuer": { + "S": "PLATE-ISSUER" + }, + "toEmailAddress": { + "S": "TO-EMAIL-ADDRESS" + } + } + } + ] + }, + "chassisMake": { + "S": "CHASSIS-MAKE" + }, + "chassisModel": { + "S": "CHASSIS-MODEL" + }, + "bodyMake": { + "S": "BODY-MAKE" + }, + "bodyModel": { + "S": "BODY-MODEL" + }, + "modelLiteral": { + "S": "MODEL-LITERAL" + }, + "bodyType": { + "M": { + "code": { + "S": "a" + }, + "description": { + "S": "articulated" + } + } + }, + "manufactureYear": { + "N": "2020" + }, + "regnDate": { + "S": "2020-01-01" + }, + "firstUseDate": { + "S": "2020-01-01" + }, + "coifDate": { + "S": "2020-01-01" + }, + "ntaNumber": { + "S": "NTA-NUMBER" + }, + "coifSerialNumber": { + "S": "88888888" + }, + "coifCertifierName": { + "S": "COIF-CERTIFIER-NAME" + }, + "conversionRefNo": { + "S": "1010101010" + }, + "seatsLowerDeck": { + "N": "1" + }, + "seatsUpperDeck": { + "N": "1" + }, + "standingCapacity": { + "N": "1" + }, + "speedRestriction": { + "N": "1" + }, + "speedLimiterMrk": { + "BOOL": true + }, + "tachoExemptMrk": { + "BOOL": true + }, + "dispensations": { + "S": "DISPENSATIONS" + }, + "remarks": { + "S": "REMARKS" + }, + "reasonForCreation": { + "S": "REASON-FOR-CREATION" + }, + "statusCode": { + "S": "STATUS-CODE" + }, + "unladenWeight": { + "N": "1" + }, + "grossKerbWeight": { + "N": "1" + }, + "grossLadenWeight": { + "N": "1" + }, + "grossGbWeight": { + "N": "1" + }, + "grossDesignWeight": { + "N": "1" + }, + "trainGbWeight": { + "N": "1" + }, + "trainDesignWeight": { + "N": "1" + }, + "maxTrainGbWeight": { + "N": "1" + }, + "maxTrainDesignWeight": { + "N": "1" + }, + "maxLoadOnCoupling": { + "N": "1" + }, + "frameDescription": { + "S": "Channel section" + }, + "tyreUseCode": { + "S": "22" + }, + "roadFriendly": { + "BOOL": true + }, + "drawbarCouplingFitted": { + "BOOL": true + }, + "euroStandard": { + "S": "euroStd" + }, + "suspensionType": { + "S": "1" + }, + "couplingType": { + "S": "1" + }, + "dimensions": { + "M": { + "axleSpacing": { + "L": [ + { + "M": { + "axles": { + "S": "1-2" + }, + "value": { + "N": "1" + } + } + } + ] + }, + "length": { + "N": "1" + }, + "height": { + "N": "1" + }, + "width": { + "N": "1" + } + } + }, + "frontAxleTo5thWheelMin": { + "N": "1" + }, + "frontAxleTo5thWheelMax": { + "N": "1" + }, + "frontVehicleTo5thWheelCouplingMin": { + "N": "1" + }, + "frontVehicleTo5thWheelCouplingMax": { + "N": "1" + }, + "frontAxleToRearAxle": { + "N": "1" + }, + "rearAxleToRearTrl": { + "N": "1" + }, + "couplingCenterToRearAxleMin": { + "N": "1" + }, + "couplingCenterToRearAxleMax": { + "N": "1" + }, + "couplingCenterToRearTrlMin": { + "N": "1" + }, + "couplingCenterToRearTrlMax": { + "N": "1" + }, + "centreOfRearmostAxleToRearOfTrl": { + "N": "1" + }, + "notes": { + "S": "NOTES" + }, + "noOfAxles": { + "N": "1" + }, + "brakeCode": { + "S": "1" + }, + "createdByName": { + "S": "CREATED-BY-NAME-2" + }, + "createdById": { + "S": "CREATED-BY-ID-2" + }, + "lastUpdatedByName": { + "S": "LAST-UPDATED-BY-NAME-2" + }, + "lastUpdatedById": { + "S": "LAST-UPDATED-BY-ID-2" + }, + "updateType": { + "S": "adrUpdate" + }, + "vehicleClass": { + "M": { + "code": { + "S": "2" + }, + "description": { + "S": "motorbikes over 200cc or with a sidecar" + } + } + }, + "vehicleSubclass": { + "L": [ + { + "S": "1" + } + ] + }, + "vehicleType": { + "S": "psv" + }, + "vehicleSize": { + "S": "small" + }, + "numberOfSeatbelts": { + "S": "NUMBER-OF-SEATBELTS" + }, + "seatbeltInstallationApprovalDate": { + "S": "2020-01-01" + }, + "vehicleConfiguration": { + "S": "rigid" + }, + "brakes": { + "M": { + "brakeCodeOriginal": { + "S": "333" + }, + "brakeCode": { + "S": "666666" + }, + "dataTrBrakeOne": { + "S": "DATA-TR-BRAKE-ONE" + }, + "dataTrBrakeTwo": { + "S": "DATA-TR-BRAKE-TWO" + }, + "dataTrBrakeThree": { + "S": "DATA-TR-BRAKE-THREE" + }, + "retarderBrakeOne": { + "S": "electric" + }, + "retarderBrakeTwo": { + "S": "electric" + }, + "dtpNumber": { + "S": "666666" + }, + "brakeForceWheelsNotLocked": { + "M": { + "serviceBrakeForceA": { + "N": "1" + }, + "secondaryBrakeForceA": { + "N": "1" + }, + "parkingBrakeForceA": { + "N": "1" + } + } + }, + "brakeForceWheelsUpToHalfLocked": { + "M": { + "serviceBrakeForceB": { + "N": "1" + }, + "secondaryBrakeForceB": { + "N": "1" + }, + "parkingBrakeForceB": { + "N": "1" + } + } + }, + "loadSensingValve": { + "BOOL": true + }, + "antilockBrakingSystem": { + "BOOL": true + } + } + }, + "axles": { + "L": [ + { + "M": { + "axleNumber": { + "N": "1" + }, + "parkingBrakeMrk": { + "BOOL": true + }, + "weights": { + "M": { + "kerbWeight": { + "N": "1" + }, + "ladenWeight": { + "N": "1" + }, + "gbWeight": { + "N": "1" + }, + "eecWeight": { + "N": "1" + }, + "designWeight": { + "N": "1" + } + } + }, + "tyres": { + "M": { + "tyreSize": { + "S": "TYRE-SIZE" + }, + "plyRating": { + "S": "22" + }, + "fitmentCode": { + "S": "double" + }, + "dataTrAxles": { + "N": "1" + }, + "speedCategorySymbol": { + "S": "a7" + }, + "tyreCode": { + "N": "1" + } + } + }, + "brakes": { + "M": { + "brakeActuator": { + "N": "1" + }, + "leverLength": { + "N": "1" + }, + "springBrakeParking": { + "BOOL": true + } + } + } + } + } + ] + } + } + } + ] + } +} diff --git a/tests/unit/models/tech-record-document.unitTest.ts b/tests/unit/models/tech-record-document.unitTest.ts index c6db6fd..526a491 100644 --- a/tests/unit/models/tech-record-document.unitTest.ts +++ b/tests/unit/models/tech-record-document.unitTest.ts @@ -3,11 +3,11 @@ import { TechRecordDocument, } from "../../../src/models/tech-record-document"; import { DynamoDbImage } from "../../../src/services/dynamodb-images"; -import { default as techRecordDocumentJson } from "../../resources/dynamodb-image-technical-record.json"; +import { default as techRecordDocumentJson } from "../../resources/dynamodb-image-technical-record-with-adr.json"; import { castToImageShape } from "../../utils"; describe("parseTechRecordDocument()", () => { - it("should successfully parse a DynamoDB image into a TechRecordDocument", () => { + it("should successfully parse a DynamoDB image with ADR into a TechRecordDocument", () => { const image = DynamoDbImage.parse(castToImageShape(techRecordDocumentJson)); const techRecordDocument: TechRecordDocument = parseTechRecordDocument( @@ -52,9 +52,72 @@ describe("parseTechRecordDocument()", () => { "333" ); expect(techRecordDocument.techRecord![0].axles![0].axleNumber).toEqual(1); + + // ADR Details attributes + expect(techRecordDocument.techRecord![0].adrDetails?.additionalExaminerNotes![0].note).toEqual("additionalExaminerNotes_note_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.additionalExaminerNotes![0].createdAtDate).toEqual("2023-05-30"); + expect(techRecordDocument.techRecord![0].adrDetails?.additionalExaminerNotes![0].lastUpdatedBy).toEqual("additionalExaminerNotes_lastUpdatedBy_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.additionalNotes?.number![0]).toEqual("1"); + expect(techRecordDocument.techRecord![0].adrDetails?.additionalNotes?.number![1]).toEqual("T1B"); + + expect(techRecordDocument.techRecord![0].adrDetails?.adrCertificateNotes).toEqual("adrCertificateNotes_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.adrTypeApprovalNo).toEqual("adrTypeApprovalNo_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.applicantDetails!.name).toEqual("adrDetails_applicantDetails_name_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.batteryListNumber).toEqual("batteryListNumber_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.brakeDeclarationIssuer).toEqual("brakeDeclarationIssuer_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.brakeDeclarationsSeen).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.brakeEndurance).toEqual(false); + expect(techRecordDocument.techRecord![0].adrDetails?.compatibilityGroupJ).toEqual("I"); + expect(techRecordDocument.techRecord![0].adrDetails?.dangerousGoods).toEqual(false); + expect(techRecordDocument.techRecord![0].adrDetails?.declarationsSeen).toEqual(false); + + expect(techRecordDocument.techRecord![0].adrDetails?.documents![0]).toEqual("documents_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.documents![1]).toEqual("documents_2"); + + expect(techRecordDocument.techRecord![0].adrDetails?.listStatementApplicable).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.m145).toEqual(true); + + expect(techRecordDocument.techRecord![0].adrDetails?.memosApply![0]).toEqual("07/09 3mth leak ext"); + + expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![0]).toEqual("FP <61 (FL)"); + expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![1]).toEqual("Carbon Disulphide"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturer).toEqual("tankManufacturer_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.yearOfManufacture).toEqual(1234); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankCode).toEqual("tankCode_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.specialProvisions).toEqual("specialProvisions_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturerSerialNo).toEqual("1234"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankTypeAppNo).toEqual("9876"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2Type).toEqual("initial"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateApprovalNo).toEqual("12345"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateExpiryDate).toEqual("2024-06-01"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3Type).toEqual("intermediate"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicNumber).toEqual("98765"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicExpiryDate).toEqual("2024-06-01"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.select).toEqual("Product list"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.statement).toEqual("statement_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListRefNo).toEqual("123456"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productList).toEqual("productList_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![0]).toEqual("123123"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![1]).toEqual("987987"); + + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.type).toEqual("Artic tractor"); + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.approvalDate).toEqual("2023-06-12"); + + expect(techRecordDocument.techRecord![0].adrDetails?.weight).toEqual(6789); + }); - it("should successfully parse a DynamoDB image, with no authIntoService, into a TechRecordDocument", () => { + it("should successfully parse a DynamoDB image, with ADR, with no authIntoService, into a TechRecordDocument", () => { // @ts-ignore delete techRecordDocumentJson.techRecord.L[0].M.authIntoService; const image = DynamoDbImage.parse(castToImageShape(techRecordDocumentJson)); @@ -99,5 +162,68 @@ describe("parseTechRecordDocument()", () => { "333" ); expect(techRecordDocument.techRecord![0].axles![0].axleNumber).toEqual(1); + + // ADR Details attributes + expect(techRecordDocument.techRecord![0].adrDetails?.additionalExaminerNotes![0].note).toEqual("additionalExaminerNotes_note_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.additionalExaminerNotes![0].createdAtDate).toEqual("2023-05-30"); + expect(techRecordDocument.techRecord![0].adrDetails?.additionalExaminerNotes![0].lastUpdatedBy).toEqual("additionalExaminerNotes_lastUpdatedBy_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.additionalNotes?.number![0]).toEqual("1"); + expect(techRecordDocument.techRecord![0].adrDetails?.additionalNotes?.number![1]).toEqual("T1B"); + + expect(techRecordDocument.techRecord![0].adrDetails?.adrCertificateNotes).toEqual("adrCertificateNotes_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.adrTypeApprovalNo).toEqual("adrTypeApprovalNo_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.applicantDetails!.name).toEqual("adrDetails_applicantDetails_name_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.batteryListNumber).toEqual("batteryListNumber_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.brakeDeclarationIssuer).toEqual("brakeDeclarationIssuer_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.brakeDeclarationsSeen).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.brakeEndurance).toEqual(false); + expect(techRecordDocument.techRecord![0].adrDetails?.compatibilityGroupJ).toEqual("I"); + expect(techRecordDocument.techRecord![0].adrDetails?.dangerousGoods).toEqual(false); + expect(techRecordDocument.techRecord![0].adrDetails?.declarationsSeen).toEqual(false); + + expect(techRecordDocument.techRecord![0].adrDetails?.documents![0]).toEqual("documents_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.documents![1]).toEqual("documents_2"); + + expect(techRecordDocument.techRecord![0].adrDetails?.listStatementApplicable).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.m145).toEqual(true); + + expect(techRecordDocument.techRecord![0].adrDetails?.memosApply![0]).toEqual("07/09 3mth leak ext"); + + expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![0]).toEqual("FP <61 (FL)"); + expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![1]).toEqual("Carbon Disulphide"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturer).toEqual("tankManufacturer_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.yearOfManufacture).toEqual(1234); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankCode).toEqual("tankCode_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.specialProvisions).toEqual("specialProvisions_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturerSerialNo).toEqual("1234"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankTypeAppNo).toEqual("9876"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2Type).toEqual("initial"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateApprovalNo).toEqual("12345"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateExpiryDate).toEqual("2024-06-01"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3Type).toEqual("intermediate"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicNumber).toEqual("98765"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicExpiryDate).toEqual("2024-06-01"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.select).toEqual("Product list"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.statement).toEqual("statement_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListRefNo).toEqual("123456"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productList).toEqual("productList_1"); + + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![0]).toEqual("123123"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![1]).toEqual("987987"); + + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.type).toEqual("Artic tractor"); + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.approvalDate).toEqual("2023-06-12"); + + expect(techRecordDocument.techRecord![0].adrDetails?.weight).toEqual(6789); + }); }); diff --git a/tsconfig.json b/tsconfig.json index cf02692..b5af863 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -61,6 +61,6 @@ "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, "resolveJsonModule": true, - "types": [] + "types": ["jest", "node"] } } From a5488b48ba9f8575944aeb0fbfe6a3d4557188ca Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 2 Feb 2024 10:07:31 +0000 Subject: [PATCH 06/12] style: rearrange enums --- src/models/adr-certificate-details.ts | 4 +- src/models/adr-details.ts | 72 ++++++++++++++++++++------- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/models/adr-certificate-details.ts b/src/models/adr-certificate-details.ts index f4c8c56..bad6f37 100644 --- a/src/models/adr-certificate-details.ts +++ b/src/models/adr-certificate-details.ts @@ -7,7 +7,9 @@ export interface AdrCertificateDetails { } // define Enums -export type certificateIdEnum = "PASS" | "REPLACEMENT"; +export type certificateIdEnum = + | "PASS" + | "REPLACEMENT"; // define AdrCertificateDetails' sub-attributes data types export type AdrPassCertificateDetails = AdrPassCertificateDetailsItems[]; diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index f9dbde3..aca0ecf 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -26,33 +26,69 @@ export interface AdrDetails { } // define Enums -export type VehicleDetailsTypeEnum = "Artic tractor" | "Rigid box body" | "Rigid sheeted load" | "Rigid tank" | - "Rigid skeletal" | "Rigid battery" | "Full drawbar box body" | - "Full drawbar sheeted load" | "Full drawbar tank" | "Full drawbar skeletal" | - "Full drawbar battery" | "Centre axle box body" | "Centre axle sheeted load" | - "Centre axle tank" | "Centre axle skeletal" | "Centre axle battery" | - "Semi trailer box body" | "Semi trailer sheeted load" | "Semi trailer tank" | - "Semi trailer skeletal" | "Semi trailer battery Enum"; +export type VehicleDetailsTypeEnum = + | "Artic tractor" + | "Rigid box body" + | "Rigid sheeted load" + | "Rigid tank" + | "Rigid skeletal" + | "Rigid battery" + | "Full drawbar box body" + | "Full drawbar sheeted load" + | "Full drawbar tank" + | "Full drawbar skeletal" + | "Full drawbar battery" + | "Centre axle box body" + | "Centre axle sheeted load" + | "Centre axle tank" + | "Centre axle skeletal" + | "Centre axle battery" + | "Semi trailer box body" + | "Semi trailer sheeted load" + | "Semi trailer tank" + | "Semi trailer skeletal" + | "Semi trailer battery Enum"; export type Tc2TypeEnum = "initial"; -export type Tc3TypeEnum = "intermediate" | "periodic" | "exceptional"; - -export type permittedDangerousGoodsEnum = "FP <61 (FL)" | "AT" | "Class 5.1 Hydrogen Peroxide (OX)" | "MEMU" | - "Carbon Disulphide" | "Hydrogen" | "Explosives (type 2)" | "Explosives (type 3)"; - -export type compatibilityGroupJEnum = "I" | "E"; - -export type additionalNotesNumberEnum = "1" | "1A" | "2" | "3" | "V1B" | "T1B"; +export type Tc3TypeEnum = + | "intermediate" + | "periodic" + | "exceptional"; + +export type permittedDangerousGoodsEnum = + | "FP <61 (FL)" + | "AT" + | "Class 5.1 Hydrogen Peroxide (OX)" + | "MEMU" + | "Carbon Disulphide" + | "Hydrogen" + | "Explosives (type 2)" + | "Explosives (type 3)"; + +export type compatibilityGroupJEnum = + | "I" + | "E"; + +export type additionalNotesNumberEnum = + | "1" + | "1A" + | "2" + | "3" + | "V1B" + | "T1B"; // export type additionalNotesguidanceNotesEnum = "New certificate requested" | "M145 Statement" -export type substancesPermittedEnum = "Substances permitted under the tank code and any special provisions specified in 9 may be carried" | - "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried"; +export type substancesPermittedEnum = + | "Substances permitted under the tank code and any special provisions specified in 9 may be carried" + | "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried"; export type memosApplyEnum = "07/09 3mth leak ext"; -export type tankStatementSelectEnum = "Statement" | "Product list"; +export type tankStatementSelectEnum = + | "Statement" + | "Product list"; // define AdrDetails' sub-attributes data types export interface VehicleDetails { From e456415952da1a3167ec0ed5a1bd105acf05077d Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 2 Feb 2024 10:09:02 +0000 Subject: [PATCH 07/12] fix: replace ! with ? for optional attributes --- .../models/tech-record-document.unitTest.ts | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/unit/models/tech-record-document.unitTest.ts b/tests/unit/models/tech-record-document.unitTest.ts index 526a491..f15b332 100644 --- a/tests/unit/models/tech-record-document.unitTest.ts +++ b/tests/unit/models/tech-record-document.unitTest.ts @@ -65,7 +65,7 @@ describe("parseTechRecordDocument()", () => { expect(techRecordDocument.techRecord![0].adrDetails?.adrTypeApprovalNo).toEqual("adrTypeApprovalNo_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.applicantDetails!.name).toEqual("adrDetails_applicantDetails_name_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.applicantDetails?.name).toEqual("adrDetails_applicantDetails_name_1"); expect(techRecordDocument.techRecord![0].adrDetails?.batteryListNumber).toEqual("batteryListNumber_1"); expect(techRecordDocument.techRecord![0].adrDetails?.brakeDeclarationIssuer).toEqual("brakeDeclarationIssuer_1"); @@ -87,31 +87,31 @@ describe("parseTechRecordDocument()", () => { expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![0]).toEqual("FP <61 (FL)"); expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![1]).toEqual("Carbon Disulphide"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturer).toEqual("tankManufacturer_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.yearOfManufacture).toEqual(1234); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankCode).toEqual("tankCode_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.specialProvisions).toEqual("specialProvisions_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturerSerialNo).toEqual("1234"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankTypeAppNo).toEqual("9876"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankManufacturer).toEqual("tankManufacturer_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.yearOfManufacture).toEqual(1234); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankCode).toEqual("tankCode_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.specialProvisions).toEqual("specialProvisions_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankManufacturerSerialNo).toEqual("1234"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankTypeAppNo).toEqual("9876"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2Type).toEqual("initial"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateApprovalNo).toEqual("12345"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateExpiryDate).toEqual("2024-06-01"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc2Details?.tc2Type).toEqual("initial"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc2Details?.tc2IntermediateApprovalNo).toEqual("12345"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc2Details?.tc2IntermediateExpiryDate).toEqual("2024-06-01"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3Type).toEqual("intermediate"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicNumber).toEqual("98765"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicExpiryDate).toEqual("2024-06-01"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc3Details![0].tc3Type).toEqual("intermediate"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc3Details![0].tc3PeriodicNumber).toEqual("98765"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc3Details![0].tc3PeriodicExpiryDate).toEqual("2024-06-01"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.select).toEqual("Product list"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.statement).toEqual("statement_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListRefNo).toEqual("123456"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productList).toEqual("productList_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.select).toEqual("Product list"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.statement).toEqual("statement_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productListRefNo).toEqual("123456"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productList).toEqual("productList_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![0]).toEqual("123123"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![1]).toEqual("987987"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productListUnNo![0]).toEqual("123123"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productListUnNo![1]).toEqual("987987"); - expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.type).toEqual("Artic tractor"); - expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.approvalDate).toEqual("2023-06-12"); + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails?.type).toEqual("Artic tractor"); + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails?.approvalDate).toEqual("2023-06-12"); expect(techRecordDocument.techRecord![0].adrDetails?.weight).toEqual(6789); @@ -175,7 +175,7 @@ describe("parseTechRecordDocument()", () => { expect(techRecordDocument.techRecord![0].adrDetails?.adrTypeApprovalNo).toEqual("adrTypeApprovalNo_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.applicantDetails!.name).toEqual("adrDetails_applicantDetails_name_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.applicantDetails?.name).toEqual("adrDetails_applicantDetails_name_1"); expect(techRecordDocument.techRecord![0].adrDetails?.batteryListNumber).toEqual("batteryListNumber_1"); expect(techRecordDocument.techRecord![0].adrDetails?.brakeDeclarationIssuer).toEqual("brakeDeclarationIssuer_1"); @@ -197,31 +197,31 @@ describe("parseTechRecordDocument()", () => { expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![0]).toEqual("FP <61 (FL)"); expect(techRecordDocument.techRecord![0].adrDetails?.permittedDangerousGoods![1]).toEqual("Carbon Disulphide"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturer).toEqual("tankManufacturer_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.yearOfManufacture).toEqual(1234); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankCode).toEqual("tankCode_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.specialProvisions).toEqual("specialProvisions_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankManufacturerSerialNo).toEqual("1234"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tankTypeAppNo).toEqual("9876"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankManufacturer).toEqual("tankManufacturer_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.yearOfManufacture).toEqual(1234); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankCode).toEqual("tankCode_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.specialProvisions).toEqual("specialProvisions_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankManufacturerSerialNo).toEqual("1234"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tankTypeAppNo).toEqual("9876"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2Type).toEqual("initial"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateApprovalNo).toEqual("12345"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc2Details!.tc2IntermediateExpiryDate).toEqual("2024-06-01"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc2Details?.tc2Type).toEqual("initial"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc2Details?.tc2IntermediateApprovalNo).toEqual("12345"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc2Details?.tc2IntermediateExpiryDate).toEqual("2024-06-01"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3Type).toEqual("intermediate"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicNumber).toEqual("98765"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankDetails!.tc3Details![0].tc3PeriodicExpiryDate).toEqual("2024-06-01"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc3Details![0].tc3Type).toEqual("intermediate"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc3Details![0].tc3PeriodicNumber).toEqual("98765"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankDetails?.tc3Details![0].tc3PeriodicExpiryDate).toEqual("2024-06-01"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.select).toEqual("Product list"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.statement).toEqual("statement_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListRefNo).toEqual("123456"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productList).toEqual("productList_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.select).toEqual("Product list"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.statement).toEqual("statement_1"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productListRefNo).toEqual("123456"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productList).toEqual("productList_1"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![0]).toEqual("123123"); - expect(techRecordDocument.techRecord![0].adrDetails?.tank!.tankStatement!.productListUnNo![1]).toEqual("987987"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productListUnNo![0]).toEqual("123123"); + expect(techRecordDocument.techRecord![0].adrDetails?.tank?.tankStatement?.productListUnNo![1]).toEqual("987987"); - expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.type).toEqual("Artic tractor"); - expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails!.approvalDate).toEqual("2023-06-12"); + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails?.type).toEqual("Artic tractor"); + expect(techRecordDocument.techRecord![0].adrDetails?.vehicleDetails?.approvalDate).toEqual("2023-06-12"); expect(techRecordDocument.techRecord![0].adrDetails?.weight).toEqual(6789); From c9025ce900993a8eb422d0adeda83da7ee85916a Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 2 Feb 2024 11:11:29 +0000 Subject: [PATCH 08/12] fix: memosApplyEnum value updated --- src/models/adr-details.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index aca0ecf..8f25de8 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -84,7 +84,7 @@ export type substancesPermittedEnum = | "Substances permitted under the tank code and any special provisions specified in 9 may be carried" | "Substances (Class UN number and if necessary packing group and proper shipping name) may be carried"; -export type memosApplyEnum = "07/09 3mth leak ext"; +export type memosApplyEnum = "07/09 3mth leak ext "; export type tankStatementSelectEnum = | "Statement" From 43ed027a0b3861b704daad5f5f8c606a48314a70 Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 2 Feb 2024 11:54:43 +0000 Subject: [PATCH 09/12] fix: 2 new attributes added to adrDetails, as per documentation --- src/models/adr-details.ts | 6 ++++-- .../resources/dynamodb-image-technical-record-with-adr.json | 6 +++++- tests/unit/models/tech-record-document.unitTest.ts | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index 8f25de8..d685a91 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -11,6 +11,7 @@ export interface AdrDetails { brakeDeclarationIssuer?: string; brakeEndurance?: boolean; weight?: number; + newCertificateRequested?: boolean; compatibilityGroupJ?: compatibilityGroupJEnum; documents?: string[]; permittedDangerousGoods?: permittedDangerousGoodsEnum[]; @@ -18,7 +19,7 @@ export interface AdrDetails { applicantDetails?: ApplicantDetails; dangerousGoods?: boolean; memosApply?: memosApplyEnum[]; - m145?: boolean; + m145Statement?: boolean; additionalNotes?: AdditionalNotes; adrTypeApprovalNo?: string; adrCertificateNotes?: string; @@ -280,6 +281,7 @@ export const parseAdrDetails = ( brakeDeclarationIssuer: adrDetails.getString("brakeDeclarationIssuer"), brakeEndurance: adrDetails.getBoolean("brakeEndurance"), weight: adrDetails.getNumber("weight"), + newCertificateRequested: adrDetails.getBoolean("newCertificateRequested"), compatibilityGroupJ: adrDetails.getString("compatibilityGroupJ") as compatibilityGroupJEnum, documents: parseStringArray(adrDetails.getList("documents")), permittedDangerousGoods: parseStringArray( @@ -289,7 +291,7 @@ export const parseAdrDetails = ( applicantDetails, dangerousGoods: adrDetails.getBoolean("dangerousGoods"), memosApply: parseStringArray(adrDetails.getList("memosApply")) as memosApplyEnum[], - m145: adrDetails.getBoolean("m145"), + m145Statement: adrDetails.getBoolean("m145Statement"), additionalNotes, adrTypeApprovalNo: adrDetails.getString("adrTypeApprovalNo"), adrCertificateNotes: adrDetails.getString("adrCertificateNotes"), diff --git a/tests/resources/dynamodb-image-technical-record-with-adr.json b/tests/resources/dynamodb-image-technical-record-with-adr.json index 48dceaf..f1dcf71 100644 --- a/tests/resources/dynamodb-image-technical-record-with-adr.json +++ b/tests/resources/dynamodb-image-technical-record-with-adr.json @@ -116,9 +116,13 @@ "listStatementApplicable": { "BOOL": true }, - "m145": { + "m145Statement": { "BOOL": true }, + "newCertificateRequested": { + "BOOL": false + }, + "memosApply": { "L": [ { diff --git a/tests/unit/models/tech-record-document.unitTest.ts b/tests/unit/models/tech-record-document.unitTest.ts index f15b332..d610b88 100644 --- a/tests/unit/models/tech-record-document.unitTest.ts +++ b/tests/unit/models/tech-record-document.unitTest.ts @@ -80,7 +80,8 @@ describe("parseTechRecordDocument()", () => { expect(techRecordDocument.techRecord![0].adrDetails?.documents![1]).toEqual("documents_2"); expect(techRecordDocument.techRecord![0].adrDetails?.listStatementApplicable).toEqual(true); - expect(techRecordDocument.techRecord![0].adrDetails?.m145).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.m145Statement).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.newCertificateRequested).toEqual(false); expect(techRecordDocument.techRecord![0].adrDetails?.memosApply![0]).toEqual("07/09 3mth leak ext"); @@ -190,7 +191,8 @@ describe("parseTechRecordDocument()", () => { expect(techRecordDocument.techRecord![0].adrDetails?.documents![1]).toEqual("documents_2"); expect(techRecordDocument.techRecord![0].adrDetails?.listStatementApplicable).toEqual(true); - expect(techRecordDocument.techRecord![0].adrDetails?.m145).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.m145Statement).toEqual(true); + expect(techRecordDocument.techRecord![0].adrDetails?.newCertificateRequested).toEqual(false); expect(techRecordDocument.techRecord![0].adrDetails?.memosApply![0]).toEqual("07/09 3mth leak ext"); From 3b20a999295ccf44e7efaad4e9ed826f71b3912e Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Fri, 2 Feb 2024 15:33:17 +0000 Subject: [PATCH 10/12] fix: enum updated --- src/models/adr-details.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/adr-details.ts b/src/models/adr-details.ts index d685a91..36db7db 100644 --- a/src/models/adr-details.ts +++ b/src/models/adr-details.ts @@ -48,7 +48,7 @@ export type VehicleDetailsTypeEnum = | "Semi trailer sheeted load" | "Semi trailer tank" | "Semi trailer skeletal" - | "Semi trailer battery Enum"; + | "Semi trailer battery"; export type Tc2TypeEnum = "initial"; From 7ac372fa28b82d0573c21a9cade97184e08a1bef Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Wed, 7 Feb 2024 10:25:14 +0000 Subject: [PATCH 11/12] docker image version for mysql updated to match NOP on PROD --- tests/resources/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/Dockerfile b/tests/resources/Dockerfile index 25ca559..a655315 100644 --- a/tests/resources/Dockerfile +++ b/tests/resources/Dockerfile @@ -1,5 +1,5 @@ # Match Aurora MySQL version as closely as possible -FROM mysql:8.2.0 +FROM mysql:8.0.32 ENV MYSQL_DATABASE=CVSBNOP \ MYSQL_ROOT_PASSWORD=12345 From ca71d09586cefd983c59a3bae4a7cc815b55616a Mon Sep 17 00:00:00 2001 From: Meys Torkaman Date: Wed, 7 Feb 2024 10:27:30 +0000 Subject: [PATCH 12/12] tsconfig types back to normal --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index b5af863..cf02692 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -61,6 +61,6 @@ "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, "resolveJsonModule": true, - "types": ["jest", "node"] + "types": [] } }