From 11200f33423ad295bd372ebe9b04015ca47f4a1c Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Thu, 19 Sep 2024 23:39:49 +0200 Subject: [PATCH] feat: define optional `overrides` on PlanX service metadata (#240) --- schemas/prototypeApplication.json | 554 +++++++++--------- .../schemas/prototypeApplication/Metadata.ts | 49 ++ .../enums/PlanningDesignation.ts | 2 +- types/schemas/prototypeApplication/index.ts | 27 +- 4 files changed, 321 insertions(+), 311 deletions(-) create mode 100644 types/schemas/prototypeApplication/Metadata.ts diff --git a/schemas/prototypeApplication.json b/schemas/prototypeApplication.json index c94aa5d2..6393a522 100644 --- a/schemas/prototypeApplication.json +++ b/schemas/prototypeApplication.json @@ -540,6 +540,150 @@ ], "type": "object" }, + "BasePlanningDesignation": { + "anyOf": [ + { + "const": "article4", + "description": "Article 4 Direction area", + "type": "string" + }, + { + "const": "article4.caz", + "description": "Central Activities Zone (CAZ)", + "type": "string" + }, + { + "const": "brownfieldSite", + "description": "Brownfield site", + "type": "string" + }, + { + "const": "designated", + "description": "Designated land", + "type": "string" + }, + { + "const": "designated.AONB", + "description": "Area of Outstanding Natural Beauty (AONB)", + "type": "string" + }, + { + "const": "designated.conservationArea", + "description": "Conservation Area", + "type": "string" + }, + { + "const": "designated.nationalPark", + "description": "National Park", + "type": "string" + }, + { + "const": "designated.nationalPark.broads", + "description": "National Park - Broads", + "type": "string" + }, + { + "const": "designated.WHS", + "description": "UNESCO World Heritage Site or buffer zone", + "type": "string" + }, + { + "const": "flood", + "description": "Flood Risk Zone", + "type": "string" + }, + { + "const": "flood.zone.1", + "description": "Flood Risk Zone 1 - Low risk", + "type": "string" + }, + { + "const": "flood.zone.2", + "description": "Flood Risk Zone 2 - Medium risk", + "type": "string" + }, + { + "const": "flood.zone.3", + "description": "Flood Risk Zone 3 - High risk", + "type": "string" + }, + { + "const": "greenBelt", + "description": "Green Belt", + "type": "string" + }, + { + "const": "listed", + "description": "Listed Building", + "type": "string" + }, + { + "const": "listed.grade.I", + "description": "Listed Building - Grade I", + "type": "string" + }, + { + "const": "listed.grade.II", + "description": "Listed Building - Grade II", + "type": "string" + }, + { + "const": "listed.grade.II*", + "description": "Listed Building - Grade II*", + "type": "string" + }, + { + "const": "locallyListed", + "description": "Locally Listed Building", + "type": "string" + }, + { + "const": "monument", + "description": "Site of a Scheduled Monument", + "type": "string" + }, + { + "const": "nature.ASNW", + "description": "Ancient Semi-Natural Woodland (ASNW)", + "type": "string" + }, + { + "const": "nature.ramsarSite", + "description": "Ramsar site", + "type": "string" + }, + { + "const": "nature.SAC", + "description": "Special Area of Conservation (SAC)", + "type": "string" + }, + { + "const": "nature.SPA", + "description": "Special Protection Area (SPA)", + "type": "string" + }, + { + "const": "nature.SSSI", + "description": "Site of Special Scientific Interest (SSSI)", + "type": "string" + }, + { + "const": "registeredPark", + "description": "Historic Park or Garden", + "type": "string" + }, + { + "const": "road.classified", + "description": "Classified Road", + "type": "string" + }, + { + "const": "tpo", + "description": "Tree Preservation Order (TPO) or zone", + "type": "string" + } + ] + }, "BuildingRegulation": { "$id": "#BuildingRegulation", "anyOf": [ @@ -5359,148 +5503,7 @@ "type": "boolean" }, "value": { - "anyOf": [ - { - "const": "article4", - "description": "Article 4 Direction area", - "type": "string" - }, - { - "const": "article4.caz", - "description": "Central Activities Zone (CAZ)", - "type": "string" - }, - { - "const": "brownfieldSite", - "description": "Brownfield site", - "type": "string" - }, - { - "const": "designated", - "description": "Designated land", - "type": "string" - }, - { - "const": "designated.AONB", - "description": "Area of Outstanding Natural Beauty (AONB)", - "type": "string" - }, - { - "const": "designated.conservationArea", - "description": "Conservation Area", - "type": "string" - }, - { - "const": "designated.nationalPark", - "description": "National Park", - "type": "string" - }, - { - "const": "designated.nationalPark.broads", - "description": "National Park - Broads", - "type": "string" - }, - { - "const": "designated.WHS", - "description": "UNESCO World Heritage Site or buffer zone", - "type": "string" - }, - { - "const": "flood", - "description": "Flood Risk Zone", - "type": "string" - }, - { - "const": "flood.zone.1", - "description": "Flood Risk Zone 1 - Low risk", - "type": "string" - }, - { - "const": "flood.zone.2", - "description": "Flood Risk Zone 2 - Medium risk", - "type": "string" - }, - { - "const": "flood.zone.3", - "description": "Flood Risk Zone 3 - High risk", - "type": "string" - }, - { - "const": "greenBelt", - "description": "Green Belt", - "type": "string" - }, - { - "const": "listed", - "description": "Listed Building", - "type": "string" - }, - { - "const": "listed.grade.I", - "description": "Listed Building - Grade I", - "type": "string" - }, - { - "const": "listed.grade.II", - "description": "Listed Building - Grade II", - "type": "string" - }, - { - "const": "listed.grade.II*", - "description": "Listed Building - Grade II*", - "type": "string" - }, - { - "const": "locallyListed", - "description": "Locally Listed Building", - "type": "string" - }, - { - "const": "monument", - "description": "Site of a Scheduled Monument", - "type": "string" - }, - { - "const": "nature.ASNW", - "description": "Ancient Semi-Natural Woodland (ASNW)", - "type": "string" - }, - { - "const": "nature.ramsarSite", - "description": "Ramsar site", - "type": "string" - }, - { - "const": "nature.SAC", - "description": "Special Area of Conservation (SAC)", - "type": "string" - }, - { - "const": "nature.SPA", - "description": "Special Protection Area (SPA)", - "type": "string" - }, - { - "const": "nature.SSSI", - "description": "Site of Special Scientific Interest (SSSI)", - "type": "string" - }, - { - "const": "registeredPark", - "description": "Historic Park or Garden", - "type": "string" - }, - { - "const": "road.classified", - "description": "Classified Road", - "type": "string" - }, - { - "const": "tpo", - "description": "Tree Preservation Order (TPO) or zone", - "type": "string" - } - ] + "$ref": "#/definitions/BasePlanningDesignation" } }, "required": [ @@ -5524,148 +5527,7 @@ "type": "boolean" }, "value": { - "anyOf": [ - { - "const": "article4", - "description": "Article 4 Direction area", - "type": "string" - }, - { - "const": "article4.caz", - "description": "Central Activities Zone (CAZ)", - "type": "string" - }, - { - "const": "brownfieldSite", - "description": "Brownfield site", - "type": "string" - }, - { - "const": "designated", - "description": "Designated land", - "type": "string" - }, - { - "const": "designated.AONB", - "description": "Area of Outstanding Natural Beauty (AONB)", - "type": "string" - }, - { - "const": "designated.conservationArea", - "description": "Conservation Area", - "type": "string" - }, - { - "const": "designated.nationalPark", - "description": "National Park", - "type": "string" - }, - { - "const": "designated.nationalPark.broads", - "description": "National Park - Broads", - "type": "string" - }, - { - "const": "designated.WHS", - "description": "UNESCO World Heritage Site or buffer zone", - "type": "string" - }, - { - "const": "flood", - "description": "Flood Risk Zone", - "type": "string" - }, - { - "const": "flood.zone.1", - "description": "Flood Risk Zone 1 - Low risk", - "type": "string" - }, - { - "const": "flood.zone.2", - "description": "Flood Risk Zone 2 - Medium risk", - "type": "string" - }, - { - "const": "flood.zone.3", - "description": "Flood Risk Zone 3 - High risk", - "type": "string" - }, - { - "const": "greenBelt", - "description": "Green Belt", - "type": "string" - }, - { - "const": "listed", - "description": "Listed Building", - "type": "string" - }, - { - "const": "listed.grade.I", - "description": "Listed Building - Grade I", - "type": "string" - }, - { - "const": "listed.grade.II", - "description": "Listed Building - Grade II", - "type": "string" - }, - { - "const": "listed.grade.II*", - "description": "Listed Building - Grade II*", - "type": "string" - }, - { - "const": "locallyListed", - "description": "Locally Listed Building", - "type": "string" - }, - { - "const": "monument", - "description": "Site of a Scheduled Monument", - "type": "string" - }, - { - "const": "nature.ASNW", - "description": "Ancient Semi-Natural Woodland (ASNW)", - "type": "string" - }, - { - "const": "nature.ramsarSite", - "description": "Ramsar site", - "type": "string" - }, - { - "const": "nature.SAC", - "description": "Special Area of Conservation (SAC)", - "type": "string" - }, - { - "const": "nature.SPA", - "description": "Special Protection Area (SPA)", - "type": "string" - }, - { - "const": "nature.SSSI", - "description": "Site of Special Scientific Interest (SSSI)", - "type": "string" - }, - { - "const": "registeredPark", - "description": "Historic Park or Garden", - "type": "string" - }, - { - "const": "road.classified", - "description": "Classified Road", - "type": "string" - }, - { - "const": "tpo", - "description": "Tree Preservation Order (TPO) or zone", - "type": "string" - } - ] + "$ref": "#/definitions/BasePlanningDesignation" } }, "required": [ @@ -10252,6 +10114,9 @@ "flowId": { "$ref": "#/definitions/UUID" }, + "overrides": { + "$ref": "#/definitions/UserOverrides" + }, "url": { "$ref": "#/definitions/URL" } @@ -10644,6 +10509,127 @@ ], "type": "object" }, + "UserOverrides": { + "additionalProperties": false, + "description": "Administrative data suggested by PlanX which the user overrode or changed", + "properties": { + "property": { + "additionalProperties": false, + "properties": { + "planning": { + "additionalProperties": false, + "properties": { + "designations": { + "items": { + "additionalProperties": false, + "properties": { + "entities": { + "items": { + "additionalProperties": false, + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "text": { + "const": "Planning Data", + "type": "string" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "required": [ + "text", + "url" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "text": { + "const": "Ordnance Survey MasterMap Highways", + "type": "string" + } + }, + "required": [ + "text" + ], + "type": "object" + } + ] + }, + "userReason": { + "type": "string" + } + }, + "required": [ + "name", + "source", + "userReason" + ], + "type": "object" + }, + "type": "array" + }, + "sourceIntersects": { + "const": true, + "type": "boolean" + }, + "userIntersects": { + "const": false, + "type": "boolean" + }, + "value": { + "$ref": "#/definitions/BasePlanningDesignation" + } + }, + "required": [ + "value", + "sourceIntersects", + "userIntersects", + "entities" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "designations" + ], + "type": "object" + }, + "type": { + "additionalProperties": false, + "properties": { + "sourceType": { + "type": "string" + }, + "userType": { + "type": "string" + } + }, + "required": [ + "sourceType", + "userType" + ], + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, "UserRoles": { "enum": [ "applicant", diff --git a/types/schemas/prototypeApplication/Metadata.ts b/types/schemas/prototypeApplication/Metadata.ts new file mode 100644 index 00000000..4e84a832 --- /dev/null +++ b/types/schemas/prototypeApplication/Metadata.ts @@ -0,0 +1,49 @@ +import { + BaseMetadata, + FeeExplanation, + FeeExplanationNotApplicable, +} from '../../shared/Metadata'; +import {URL, UUID} from '../../shared/utils'; +import {Entity} from './data/shared'; +import {PrototypeFileType} from './enums/FileType'; +import {BasePlanningDesignation} from './enums/PlanningDesignation'; + +/** + * @description File types requested by this service. Schema["files"] will be a subset of this list based on the user's journey through the service + */ +export interface PrototypeRequestedFiles { + required: PrototypeFileType[]; + recommended: PrototypeFileType[]; + optional: PrototypeFileType[]; +} + +/** + * @description Administrative data suggested by PlanX which the user overrode or changed + */ +export interface UserOverrides { + property?: { + type?: { + sourceType: string; + userType: string; + }; + planning?: { + designations: { + value: BasePlanningDesignation; + sourceIntersects: true; + userIntersects: false; + entities: Array; + }[]; + }; + }; +} + +export interface PrototypePlanXMetadata extends BaseMetadata { + source: 'PlanX'; + service: { + flowId: UUID; + url: URL; + files: PrototypeRequestedFiles; + fee: FeeExplanation | FeeExplanationNotApplicable; + overrides?: UserOverrides; + }; +} diff --git a/types/schemas/prototypeApplication/enums/PlanningDesignation.ts b/types/schemas/prototypeApplication/enums/PlanningDesignation.ts index 1f7e0355..08f4756e 100644 --- a/types/schemas/prototypeApplication/enums/PlanningDesignation.ts +++ b/types/schemas/prototypeApplication/enums/PlanningDesignation.ts @@ -139,7 +139,7 @@ type RoadClassified = 'road.classified'; */ type TPO = 'tpo'; -type BasePlanningDesignation = +export type BasePlanningDesignation = | Article4 | Article4CAZ | BrownfieldSite diff --git a/types/schemas/prototypeApplication/index.ts b/types/schemas/prototypeApplication/index.ts index 1b07928c..e4e020ca 100644 --- a/types/schemas/prototypeApplication/index.ts +++ b/types/schemas/prototypeApplication/index.ts @@ -1,10 +1,4 @@ -import { - BaseMetadata, - FeeExplanation, - FeeExplanationNotApplicable, -} from '../../shared/Metadata'; import {Responses} from '../../shared/Responses'; -import {UUID, URL} from '../../shared/utils'; import {Applicant} from './data/Applicant'; import {ApplicationData} from './data/ApplicationData'; import {PropertyBase} from './data/Property'; @@ -19,29 +13,10 @@ import { PPApplicationType, PrimaryApplicationType, } from './enums/ApplicationType'; -import {PrototypeFileType} from './enums/FileType'; import {File} from './File'; +import {PrototypePlanXMetadata} from './Metadata'; import {PreAssessment} from './PreAssessment'; -/** - * @description File types requested by this service. Schema["files"] will be a subset of this list based on the user's journey through the service - */ -export interface PrototypeRequestedFiles { - required: PrototypeFileType[]; - recommended: PrototypeFileType[]; - optional: PrototypeFileType[]; -} - -export interface PrototypePlanXMetadata extends BaseMetadata { - source: 'PlanX'; - service: { - flowId: UUID; - url: URL; - files: PrototypeRequestedFiles; - fee: FeeExplanation | FeeExplanationNotApplicable; - }; -} - /** * @internal * The generic base type for all applications