-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cb2 10593 - update parseAdrDetails function #78
base: develop
Are you sure you want to change the base?
Changes from 10 commits
5c0c30e
96b894e
722ebfd
f373b0a
e8eb827
a5488b4
e456415
c9025ce
43ed027
3b20a99
7ac372f
ca71d09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AdrCertificateDetails> => { | ||
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 | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,24 +10,101 @@ export interface AdrDetails { | |
brakeDeclarationsSeen?: boolean; | ||
brakeDeclarationIssuer?: string; | ||
brakeEndurance?: boolean; | ||
weight?: string; | ||
compatibilityGroupJ?: boolean; | ||
weight?: number; | ||
newCertificateRequested?: boolean; | ||
compatibilityGroupJ?: compatibilityGroupJEnum; | ||
documents?: string[]; | ||
permittedDangerousGoods?: string[]; | ||
additionalExaminerNotes?: string; | ||
permittedDangerousGoods?: permittedDangerousGoodsEnum[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ADR documentation states that this shouldn't be an enum in the backend due to the historic data containing erroneous values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As previously discussed with @reisedawson-bjss, at this stage, we are going to keep them as Enums. After the first round of remediation (hopefully in pre-prod), if this creates a massive issue, we can always turn them into |
||
additionalExaminerNotes?: AdditionalExaminerNotes; | ||
applicantDetails?: ApplicantDetails; | ||
memosApply?: string[]; | ||
dangerousGoods?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not required as it is a front end field for UX There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as |
||
memosApply?: memosApplyEnum[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ADR documentation states that this shouldn't be an enum in the backend due to the historic data containing erroneous values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as |
||
m145Statement?: boolean; | ||
additionalNotes?: AdditionalNotes; | ||
adrTypeApprovalNo?: string; | ||
adrCertificateNotes?: string; | ||
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"; | ||
|
||
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 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 memosApplyEnum = "07/09 3mth leak ext "; | ||
|
||
export type tankStatementSelectEnum = | ||
| "Statement" | ||
| "Product list"; | ||
|
||
// define AdrDetails' sub-attributes data types | ||
export interface VehicleDetails { | ||
type?: string; | ||
type?: VehicleDetailsTypeEnum; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be a string in the backend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as permittedDangerousGoodsEnum case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ADR documentation states that this shouldn't be an enum in the backend due to the historic data containing erroneous values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as permittedDangerousGoodsEnum case |
||
approvalDate?: string; | ||
} | ||
|
||
export type AdditionalExaminerNotes = AdditionalExaminerNotesItems[]; | ||
|
||
export interface AdditionalExaminerNotesItems { | ||
note?: string; | ||
createdAtDate?: string; | ||
lastUpdatedBy?: string; | ||
} | ||
|
||
export interface ApplicantDetails { | ||
name?: string; | ||
street?: string; | ||
|
@@ -36,8 +114,8 @@ export interface ApplicantDetails { | |
} | ||
|
||
export interface AdditionalNotes { | ||
number?: string[]; | ||
guidanceNotes?: string[]; | ||
number?: additionalNotesNumberEnum[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be array of strings in backend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ADR documentation states that this shouldn't be an enum in the backend due to the historic data containing erroneous values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as permittedDangerousGoodsEnum case |
||
// guidanceNotes?: additionalNotesguidanceNotesEnum[]; | ||
} | ||
|
||
export interface Tank { | ||
|
@@ -57,31 +135,30 @@ export interface TankDetails { | |
} | ||
|
||
export interface TankStatement { | ||
substancesPermitted?: string; | ||
select?: tankStatementSelectEnum; | ||
substancesPermitted?: substancesPermittedEnum; | ||
statement?: string; | ||
productListRefNo?: string; | ||
productListUnNo?: string[]; | ||
productList?: string; | ||
} | ||
|
||
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<AdrDetails> => { | ||
|
@@ -93,10 +170,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") | ||
// ) as additionalNotesguidanceNotesEnum[], | ||
}; | ||
|
||
const applicantDetailsImage: DynamoDbImage = adrDetails.getMap( | ||
|
@@ -114,7 +191,7 @@ export const parseAdrDetails = ( | |
"vehicleDetails" | ||
)!; | ||
const vehicleDetails: VehicleDetails = { | ||
type: vehicleDetailsImage.getString("type"), | ||
type: vehicleDetailsImage.getString("type") as VehicleDetailsTypeEnum, | ||
approvalDate: vehicleDetailsImage.getString("approvalDate"), | ||
}; | ||
|
||
|
@@ -124,7 +201,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 +218,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 +228,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 +241,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") as tankStatementSelectEnum, | ||
statement: tankStatementImage.getString("statement"), | ||
productListRefNo: tankStatementImage.getString("productListRefNo"), | ||
productListUnNo: parseStringArray( | ||
|
@@ -178,6 +256,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 +280,18 @@ 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"), | ||
newCertificateRequested: adrDetails.getBoolean("newCertificateRequested"), | ||
compatibilityGroupJ: adrDetails.getString("compatibilityGroupJ") as compatibilityGroupJEnum, | ||
documents: parseStringArray(adrDetails.getList("documents")), | ||
permittedDangerousGoods: parseStringArray( | ||
adrDetails.getList("permittedDangerousGoods") | ||
), | ||
additionalExaminerNotes: adrDetails.getString("additionalExaminerNotes"), | ||
) as permittedDangerousGoodsEnum[], | ||
additionalExaminerNotes, | ||
applicantDetails, | ||
memosApply: parseStringArray(adrDetails.getList("memosApply")), | ||
dangerousGoods: adrDetails.getBoolean("dangerousGoods"), | ||
memosApply: parseStringArray(adrDetails.getList("memosApply")) as memosApplyEnum[], | ||
m145Statement: adrDetails.getBoolean("m145Statement"), | ||
additionalNotes, | ||
adrTypeApprovalNo: adrDetails.getString("adrTypeApprovalNo"), | ||
adrCertificateNotes: adrDetails.getString("adrCertificateNotes"), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Match Aurora MySQL version as closely as possible | ||
FROM mysql:5.7.12 | ||
FROM mysql:8.2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we OK to change this? I was just wondering if it's best to leave it as is and you just change the version locally |
||
|
||
ENV MYSQL_DATABASE=CVSBNOP \ | ||
MYSQL_ROOT_PASSWORD=12345 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not required as it is a front end field for UX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weight is listed as a number in ADR section, so I would presume that is required, it's how I've done it in Pydantic. CompatibilityGroupJ should still be listed though no? NewCertificateRequested is also in the ADR section documentation that should also be needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simontindallbjss,
newCertificateRequested
is removed from the final upsert function for now, so it wouldn't end up in NOP. we can always add it whenever needed. Note that all the attributes are defined as 'optional', so fine if they don't exist in the payload.