From 2ef35feb0974a935dc01eec29849857a834447ed Mon Sep 17 00:00:00 2001 From: John Fletcher <113134542+john-fletcher-aot@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:02:06 -0700 Subject: [PATCH] feat: Refactor for updated STOS JSON data model (#1630) --- policy-engine/src/_examples/validate-invalid-tros.ts | 2 +- .../src/_test/permit-app/permit-application.type.ts | 9 ++++++++- policy-engine/src/_test/permit-app/test-stos.ts | 5 ++++- policy-engine/src/enum/permit-app-info.ts | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/policy-engine/src/_examples/validate-invalid-tros.ts b/policy-engine/src/_examples/validate-invalid-tros.ts index c9c054a0f..df493bc29 100644 --- a/policy-engine/src/_examples/validate-invalid-tros.ts +++ b/policy-engine/src/_examples/validate-invalid-tros.ts @@ -14,7 +14,7 @@ async function start() { // Set duration to 31 days (an invalid duration) validTros30Day.permitData.permitDuration = 31; - + const validationResult2 = await policy.validate(validTros30Day); console.log(JSON.stringify(validationResult2, null, ' ')); } diff --git a/policy-engine/src/_test/permit-app/permit-application.type.ts b/policy-engine/src/_test/permit-app/permit-application.type.ts index 59b78eccb..8f47ff50f 100644 --- a/policy-engine/src/_test/permit-app/permit-application.type.ts +++ b/policy-engine/src/_test/permit-app/permit-application.type.ts @@ -54,12 +54,17 @@ type PermitData = { feeSummary?: string | null; startDate: string; expiryDate?: string | null; - permittedCommodity?: string | null; + permittedCommodity?: PermittedCommodity | null; vehicleConfiguration?: VehicleConfiguration | null; permittedRoute?: PermittedRoute | null; applicationNotes?: string | null; }; +type PermittedCommodity = { + commodityType: string; + loadDescription: string; +}; + type VehicleInConfiguration = { vehicleSubType: string; }; @@ -82,6 +87,8 @@ type ManualRoute = { highwaySequence: Array; origin: string; destination: string; + exitPoint?: string; + totalDistance?: number; }; type PermitApplication = { diff --git a/policy-engine/src/_test/permit-app/test-stos.ts b/policy-engine/src/_test/permit-app/test-stos.ts index 08b33772a..8905363e8 100644 --- a/policy-engine/src/_test/permit-app/test-stos.ts +++ b/policy-engine/src/_test/permit-app/test-stos.ts @@ -43,7 +43,10 @@ export const testStos: PermitApplication = { countryCode: 'CA', postalCode: 'V8B1A2', }, - permittedCommodity: 'EMPTYXX', + permittedCommodity: { + commodityType: 'EMPTYXX', + loadDescription: 'empty', + }, vehicleConfiguration: { overallLength: 25, overallWidth: 3, diff --git a/policy-engine/src/enum/permit-app-info.ts b/policy-engine/src/enum/permit-app-info.ts index bcea9a542..8d4eb0121 100644 --- a/policy-engine/src/enum/permit-app-info.ts +++ b/policy-engine/src/enum/permit-app-info.ts @@ -12,5 +12,5 @@ export enum PermitAppInfo { PermitDuration = '$.permitDuration', PowerUnitType = '$.vehicleDetails.vehicleSubType', TrailerList = '$.vehicleConfiguration.trailers', - Commodity = '$.permittedCommodity', + Commodity = '$.permittedCommodity.commodityType', }