From 3368494006ebb49edd07561b65b607204b36d318 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Fri, 20 Sep 2024 09:24:15 +0200 Subject: [PATCH 1/3] adjust applicant definitions --- .../data/landDrainageConsent.ts | 85 ++--- .../data/listedBuildingConsent.ts | 64 ++-- .../data/planningPermission/major.ts | 31 +- .../listedBuildingConsent.json | 32 ++ .../planningPermission/major.json | 14 + schemas/prototypeApplication.json | 303 +++++++++++++++++- .../prototypeApplication/data/Applicant.ts | 46 +-- 7 files changed, 455 insertions(+), 120 deletions(-) diff --git a/examples/prototypeApplication/data/landDrainageConsent.ts b/examples/prototypeApplication/data/landDrainageConsent.ts index d7ca6885..77cda5dd 100644 --- a/examples/prototypeApplication/data/landDrainageConsent.ts +++ b/examples/prototypeApplication/data/landDrainageConsent.ts @@ -1,4 +1,5 @@ import {PrototypeApplication} from '../../../types/schemas/prototypeApplication'; +import { MaintenanceContact } from '../../../types/schemas/prototypeApplication/data/Applicant'; const version = process.env['VERSION'] || '@next'; @@ -28,48 +29,48 @@ export const landDrainageConsentPrototype: PrototypeApplication = { siteContact: { role: 'applicant', }, - // ownership: { - // interest: 'other', - // }, - // maintenanceContact: [ - // { - // when: 'duringConstruction', - // address: { - // line1: 'Pevensey Castle', - // town: 'Pevensey', - // postcode: 'PE737SY', - // }, - // contact: { - // name: { - // title: 'Count', - // first: 'Robert', - // last: 'of Mortain', - // }, - // email: 'countbobby@email.org', - // phone: '012345678901', - // }, - // }, - // { - // when: 'afterConstruction', - // address: { - // line1: 'Dover Castle', - // town: 'Dover', - // postcode: 'DO737CA', - // }, - // contact: { - // name: { - // title: 'Baron', - // first: 'Roger', - // last: 'De Leybourne', - // }, - // email: 'baronsarerevolting@email.org', - // phone: '098765432109', - // company: { - // name: "The Barons' Revolt", - // }, - // }, - // }, - // ], + ownership: { + interest: 'other', + }, + maintenanceContact: [ + { + when: 'duringConstruction', + address: { + line1: 'Pevensey Castle', + town: 'Pevensey', + postcode: 'PE737SY', + }, + contact: { + name: { + title: 'Count', + first: 'Robert', + last: 'of Mortain', + }, + email: 'countbobby@email.org', + phone: { primary: '012345678901' }, + }, + }, + { + when: 'afterConstruction', + address: { + line1: 'Dover Castle', + town: 'Dover', + postcode: 'DO737CA', + }, + contact: { + name: { + title: 'Baron', + first: 'Roger', + last: 'De Leybourne', + }, + email: 'baronsarerevolting@email.org', + phone: { primary: '098765432109' }, + company: { + name: "The Barons' Revolt", + }, + }, + }, + ], }, property: { address: { diff --git a/examples/prototypeApplication/data/listedBuildingConsent.ts b/examples/prototypeApplication/data/listedBuildingConsent.ts index ab8a469b..accbc918 100644 --- a/examples/prototypeApplication/data/listedBuildingConsent.ts +++ b/examples/prototypeApplication/data/listedBuildingConsent.ts @@ -30,38 +30,38 @@ export const listedBuildingConsentPrototype: PrototypeApplication = { email: 'gonzo@muppets.org', phone: '987654321', }, - // ownership: { - // interest: 'owner.sole', - // certificate: 'b', - // noticeGiven: true, - // agriculturalTenants: true, - // ownersKnown: 'all', - // owners: [ - // { - // name: 'Rowlf the Dog', - // address: { - // line1: '123 Sesame Street', - // town: 'New York City', - // postcode: '10023', - // country: 'USA', - // }, - // noticeDate: '2024-04-01', - // }, - // { - // name: 'Rizzo the Rat', - // address: { - // line1: '123 Sesame Street', - // town: 'New York City', - // postcode: '10023', - // country: 'USA', - // }, - // noticeDate: '2024-04-01', - // }, - // ], - // declaration: { - // accurate: true, - // }, - // }, + ownership: { + interest: 'owner.sole', + certificate: 'b', + noticeGiven: true, + agriculturalTenants: true, + ownersKnown: 'all', + owners: [ + { + name: 'Rowlf the Dog', + address: { + line1: '123 Sesame Street', + town: 'New York City', + postcode: '10023', + country: 'USA', + }, + noticeDate: '2024-04-01', + }, + { + name: 'Rizzo the Rat', + address: { + line1: '123 Sesame Street', + town: 'New York City', + postcode: '10023', + country: 'USA', + }, + noticeDate: '2024-04-01', + }, + ], + declaration: { + accurate: true, + }, + }, }, property: { address: { diff --git a/examples/prototypeApplication/data/planningPermission/major.ts b/examples/prototypeApplication/data/planningPermission/major.ts index f1657a80..d5609c33 100644 --- a/examples/prototypeApplication/data/planningPermission/major.ts +++ b/examples/prototypeApplication/data/planningPermission/major.ts @@ -1,4 +1,5 @@ import {PrototypeApplication} from '../../../../types/schemas/prototypeApplication'; +import { PPApplicant } from '../../../../types/schemas/prototypeApplication/data/Applicant'; const version = process.env['VERSION'] || '@next'; @@ -35,24 +36,24 @@ export const planningPermissionMajorPrototype: PrototypeApplication = { certificate: 'b', noticeGiven: true, ownersKnown: 'all', - // owners: [ - // { - // name: 'Agamemnon Agricullen', - // address: { - // town: 'Mycenae', - // line1: 'Aggy Avenue', - // line2: '', - // county: '', - // country: 'Greece', - // postcode: '212 00', - // }, - // noticeGiven: true, - // }, - // ], + owners: [ + { + name: 'Agamemnon Agricullen', + address: { + town: 'Mycenae', + line1: 'Aggy Avenue', + line2: '', + county: '', + country: 'Greece', + postcode: '212 00', + }, + noticeDate: '2024-01-01', + }, + ], declaration: { accurate: true, }, - }, + } as PPApplicant["ownership"], agent: { name: { first: 'Andy', diff --git a/examples/prototypeApplication/listedBuildingConsent.json b/examples/prototypeApplication/listedBuildingConsent.json index 585a14e2..5566433d 100644 --- a/examples/prototypeApplication/listedBuildingConsent.json +++ b/examples/prototypeApplication/listedBuildingConsent.json @@ -25,6 +25,38 @@ "name": "Gonzo The Great", "email": "gonzo@muppets.org", "phone": "987654321" + }, + "ownership": { + "interest": "owner.sole", + "certificate": "b", + "noticeGiven": true, + "agriculturalTenants": true, + "ownersKnown": "all", + "owners": [ + { + "name": "Rowlf the Dog", + "address": { + "line1": "123 Sesame Street", + "town": "New York City", + "postcode": "10023", + "country": "USA" + }, + "noticeDate": "2024-04-01" + }, + { + "name": "Rizzo the Rat", + "address": { + "line1": "123 Sesame Street", + "town": "New York City", + "postcode": "10023", + "country": "USA" + }, + "noticeDate": "2024-04-01" + } + ], + "declaration": { + "accurate": true + } } }, "property": { diff --git a/examples/prototypeApplication/planningPermission/major.json b/examples/prototypeApplication/planningPermission/major.json index 9723235d..32ede437 100644 --- a/examples/prototypeApplication/planningPermission/major.json +++ b/examples/prototypeApplication/planningPermission/major.json @@ -31,6 +31,20 @@ "certificate": "b", "noticeGiven": true, "ownersKnown": "all", + "owners": [ + { + "name": "Agamemnon Agricullen", + "address": { + "town": "Mycenae", + "line1": "Aggy Avenue", + "line2": "", + "county": "", + "country": "Greece", + "postcode": "212 00" + }, + "noticeDate": "2024-01-01" + } + ], "declaration": { "accurate": true } diff --git a/schemas/prototypeApplication.json b/schemas/prototypeApplication.json index 6393a522..08c21fd5 100644 --- a/schemas/prototypeApplication.json +++ b/schemas/prototypeApplication.json @@ -2411,7 +2411,7 @@ "additionalProperties": false, "properties": { "applicant": { - "$ref": "#/definitions/ApplicantBase" + "$ref": "#/definitions/LandDrainageConsentApplicant" }, "application": { "$ref": "#/definitions/FeeCarryingApplicationData" @@ -2460,6 +2460,289 @@ ], "type": "object" }, + "LandDrainageConsentApplicant": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "address": { + "$ref": "#/definitions/ApplicantAddress", + "description": "Address information for the applicant" + }, + "company": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "email": { + "$ref": "#/definitions/Email" + }, + "maintenanceContact": { + "$ref": "#/definitions/MaintenanceContacts", + "description": "Contact information for the person(s) responsible for maintenace while the works are carried out" + }, + "name": { + "additionalProperties": false, + "properties": { + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "first", + "last" + ], + "type": "object" + }, + "ownership": { + "additionalProperties": false, + "properties": { + "interest": { + "anyOf": [ + { + "$ref": "#/definitions/OwnershipInterest" + }, + { + "const": "owner.sole", + "type": "string" + }, + { + "const": "owner.co", + "type": "string" + } + ] + } + }, + "required": [ + "interest" + ], + "type": "object" + }, + "phone": { + "additionalProperties": false, + "properties": { + "primary": { + "type": "string" + } + }, + "required": [ + "primary" + ], + "type": "object" + }, + "siteContact": { + "$ref": "#/definitions/SiteContact", + "description": "Contact information for the site visit" + }, + "type": { + "description": "The type of applicant", + "enum": [ + "individual", + "company", + "charity", + "public", + "parishCouncil" + ], + "type": "string" + } + }, + "required": [ + "address", + "email", + "name", + "ownership", + "phone", + "siteContact", + "type" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "address": { + "$ref": "#/definitions/ApplicantAddress", + "description": "Address information for the applicant" + }, + "agent": { + "additionalProperties": false, + "description": "Contact information for the agent or proxy", + "properties": { + "address": { + "$ref": "#/definitions/UserAddress" + }, + "company": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "email": { + "$ref": "#/definitions/Email" + }, + "name": { + "additionalProperties": false, + "properties": { + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "first", + "last" + ], + "type": "object" + }, + "phone": { + "additionalProperties": false, + "properties": { + "primary": { + "type": "string" + } + }, + "required": [ + "primary" + ], + "type": "object" + } + }, + "required": [ + "address", + "email", + "name", + "phone" + ], + "type": "object" + }, + "company": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "email": { + "$ref": "#/definitions/Email" + }, + "maintenanceContact": { + "$ref": "#/definitions/MaintenanceContacts", + "description": "Contact information for the person(s) responsible for maintenace while the works are carried out" + }, + "name": { + "additionalProperties": false, + "properties": { + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "first", + "last" + ], + "type": "object" + }, + "ownership": { + "additionalProperties": false, + "properties": { + "interest": { + "anyOf": [ + { + "$ref": "#/definitions/OwnershipInterest" + }, + { + "const": "owner.sole", + "type": "string" + }, + { + "const": "owner.co", + "type": "string" + } + ] + } + }, + "required": [ + "interest" + ], + "type": "object" + }, + "phone": { + "additionalProperties": false, + "properties": { + "primary": { + "type": "string" + } + }, + "required": [ + "primary" + ], + "type": "object" + }, + "siteContact": { + "$ref": "#/definitions/SiteContact", + "description": "Contact information for the site visit" + }, + "type": { + "description": "The type of applicant", + "enum": [ + "individual", + "company", + "charity", + "public", + "parishCouncil" + ], + "type": "string" + } + }, + "required": [ + "address", + "agent", + "email", + "name", + "ownership", + "phone", + "siteContact", + "type" + ], + "type": "object" + } + ] + }, "LandDrainageConsentApplicationType": { "const": "landDrainageConsent", "description": "Consent to do works affecting ordinary watercourses or land drainage", @@ -2534,7 +2817,7 @@ "additionalProperties": false, "properties": { "applicant": { - "$ref": "#/definitions/ApplicantBase" + "$ref": "#/definitions/PPApplicant" }, "application": { "$ref": "#/definitions/NonFeeCarryingApplicationData" @@ -3938,7 +4221,7 @@ ], "type": "object" }, - "MaintenanceContact": { + "MaintenanceContacts": { "items": { "additionalProperties": false, "properties": { @@ -4816,11 +5099,8 @@ "$ref": "#/definitions/Email" }, "maintenanceContact": { - "description": "Contact information for the person(s) responsible for maintenace while the works are carried out", - "items": { - "$ref": "#/definitions/MaintenanceContact" - }, - "type": "array" + "$ref": "#/definitions/MaintenanceContacts", + "description": "Contact information for the person(s) responsible for maintenace while the works are carried out" }, "name": { "additionalProperties": false, @@ -5057,11 +5337,8 @@ "$ref": "#/definitions/Email" }, "maintenanceContact": { - "description": "Contact information for the person(s) responsible for maintenace while the works are carried out", - "items": { - "$ref": "#/definitions/MaintenanceContact" - }, - "type": "array" + "$ref": "#/definitions/MaintenanceContacts", + "description": "Contact information for the person(s) responsible for maintenace while the works are carried out" }, "name": { "additionalProperties": false, diff --git a/types/schemas/prototypeApplication/data/Applicant.ts b/types/schemas/prototypeApplication/data/Applicant.ts index 72a1e148..204e5594 100644 --- a/types/schemas/prototypeApplication/data/Applicant.ts +++ b/types/schemas/prototypeApplication/data/Applicant.ts @@ -1,6 +1,6 @@ -import {Date, Email} from '../../../shared/utils'; -import {PrimaryApplicationType} from '../enums/ApplicationType'; -import {UserRoles} from './User'; +import { Date, Email } from '../../../shared/utils'; +import { PrimaryApplicationType } from '../enums/ApplicationType'; +import { UserRoles } from './User'; export type ApplicantBase = BaseApplicant | Agent; @@ -23,10 +23,10 @@ export interface Agent extends BaseApplicant { /** * @description Contact information for the agent or proxy */ - agent: ContactDetails & {address: UserAddress}; + agent: ContactDetails & { address: UserAddress }; } -export type SiteContact = {role: UserRoles} | SiteContactOther; +export type SiteContact = { role: UserRoles } | SiteContactOther; export interface SiteContactOther { role: 'other'; @@ -60,7 +60,7 @@ export type UserAddress = { }; export type ApplicantAddress = - | {sameAsSiteAddress: true} + | { sameAsSiteAddress: true } | ApplicantAddressNotSameSite; export interface ApplicantAddressNotSameSite extends UserAddress { @@ -88,11 +88,11 @@ export interface OwnersNoticeDate extends BaseOwners { noticeDate: Date; } -export type MaintenanceContact = { +export type MaintenanceContacts = { when: - | 'duringConstruction' - | 'afterConstruction' - | 'duringAndAfterConstruction'; + | 'duringConstruction' + | 'afterConstruction' + | 'duringAndAfterConstruction'; address: UserAddress; contact: ContactDetails; }[]; @@ -102,11 +102,11 @@ export type LDCApplicant = ApplicantBase & { * @description Information about the property owners, if different than the applicant */ ownership: - | {interest: Extract} - | { - interest: OwnershipInterest; // `Exclude` ? But I think you can be co owner & report other owners? - owners: (OwnersNoticeGiven | OwnersNoNoticeGiven)[]; - }; + | { interest: Extract } + | { + interest: OwnershipInterest; // `Exclude` ? But I think you can be co owner & report other owners? + owners: (OwnersNoticeGiven | OwnersNoNoticeGiven)[]; + }; }; export type PPApplicant = ApplicantBase & { @@ -147,15 +147,25 @@ export type PPApplicant = ApplicantBase & { /** * @description Contact information for the person(s) responsible for maintenace while the works are carried out */ - maintenanceContact?: MaintenanceContact[]; + maintenanceContact?: MaintenanceContacts; }; +export type LandDrainageConsentApplicant = ApplicantBase & { + ownership: { + interest: OwnershipInterest | 'owner.sole' | 'owner.co'; + } + /** @description Contact information for the person(s) responsible for maintenace while the works are carried out */ + maintenanceContact?: MaintenanceContacts; +} + /** * TypeMap of PrimaryApplicationTypes to their specific Applicant models */ interface ApplicantVariants { ldc: LDCApplicant; pp: PPApplicant; + landDrainageConsent: LandDrainageConsentApplicant; + listed: PPApplicant; } /** @@ -163,5 +173,5 @@ interface ApplicantVariants { */ export type Applicant = TPrimary extends keyof ApplicantVariants - ? ApplicantVariants[TPrimary] - : ApplicantBase; + ? ApplicantVariants[TPrimary] + : ApplicantBase; From 5c00a773bac52a1e3a20836093e51ebc60035ba2 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Fri, 20 Sep 2024 09:25:07 +0200 Subject: [PATCH 2/3] remove unused import --- .../data/landDrainageConsent.ts | 5 +- .../data/planningPermission/major.ts | 4 +- .../landDrainageConsent.json | 48 ++++++++++++++++++- .../prototypeApplication/data/Applicant.ts | 36 +++++++------- 4 files changed, 69 insertions(+), 24 deletions(-) diff --git a/examples/prototypeApplication/data/landDrainageConsent.ts b/examples/prototypeApplication/data/landDrainageConsent.ts index 77cda5dd..42273b86 100644 --- a/examples/prototypeApplication/data/landDrainageConsent.ts +++ b/examples/prototypeApplication/data/landDrainageConsent.ts @@ -1,5 +1,4 @@ import {PrototypeApplication} from '../../../types/schemas/prototypeApplication'; -import { MaintenanceContact } from '../../../types/schemas/prototypeApplication/data/Applicant'; const version = process.env['VERSION'] || '@next'; @@ -47,7 +46,7 @@ export const landDrainageConsentPrototype: PrototypeApplication = { last: 'of Mortain', }, email: 'countbobby@email.org', - phone: { primary: '012345678901' }, + phone: {primary: '012345678901'}, }, }, { @@ -64,7 +63,7 @@ export const landDrainageConsentPrototype: PrototypeApplication = { last: 'De Leybourne', }, email: 'baronsarerevolting@email.org', - phone: { primary: '098765432109' }, + phone: {primary: '098765432109'}, company: { name: "The Barons' Revolt", }, diff --git a/examples/prototypeApplication/data/planningPermission/major.ts b/examples/prototypeApplication/data/planningPermission/major.ts index d5609c33..e50d6d51 100644 --- a/examples/prototypeApplication/data/planningPermission/major.ts +++ b/examples/prototypeApplication/data/planningPermission/major.ts @@ -1,5 +1,5 @@ import {PrototypeApplication} from '../../../../types/schemas/prototypeApplication'; -import { PPApplicant } from '../../../../types/schemas/prototypeApplication/data/Applicant'; +import {PPApplicant} from '../../../../types/schemas/prototypeApplication/data/Applicant'; const version = process.env['VERSION'] || '@next'; @@ -53,7 +53,7 @@ export const planningPermissionMajorPrototype: PrototypeApplication = { declaration: { accurate: true, }, - } as PPApplicant["ownership"], + } as PPApplicant['ownership'], agent: { name: { first: 'Andy', diff --git a/examples/prototypeApplication/landDrainageConsent.json b/examples/prototypeApplication/landDrainageConsent.json index 78559b1c..53c4c913 100644 --- a/examples/prototypeApplication/landDrainageConsent.json +++ b/examples/prototypeApplication/landDrainageConsent.json @@ -23,7 +23,53 @@ }, "siteContact": { "role": "applicant" - } + }, + "ownership": { + "interest": "other" + }, + "maintenanceContact": [ + { + "when": "duringConstruction", + "address": { + "line1": "Pevensey Castle", + "town": "Pevensey", + "postcode": "PE737SY" + }, + "contact": { + "name": { + "title": "Count", + "first": "Robert", + "last": "of Mortain" + }, + "email": "countbobby@email.org", + "phone": { + "primary": "012345678901" + } + } + }, + { + "when": "afterConstruction", + "address": { + "line1": "Dover Castle", + "town": "Dover", + "postcode": "DO737CA" + }, + "contact": { + "name": { + "title": "Baron", + "first": "Roger", + "last": "De Leybourne" + }, + "email": "baronsarerevolting@email.org", + "phone": { + "primary": "098765432109" + }, + "company": { + "name": "The Barons' Revolt" + } + } + } + ] }, "property": { "address": { diff --git a/types/schemas/prototypeApplication/data/Applicant.ts b/types/schemas/prototypeApplication/data/Applicant.ts index 204e5594..ce91be28 100644 --- a/types/schemas/prototypeApplication/data/Applicant.ts +++ b/types/schemas/prototypeApplication/data/Applicant.ts @@ -1,6 +1,6 @@ -import { Date, Email } from '../../../shared/utils'; -import { PrimaryApplicationType } from '../enums/ApplicationType'; -import { UserRoles } from './User'; +import {Date, Email} from '../../../shared/utils'; +import {PrimaryApplicationType} from '../enums/ApplicationType'; +import {UserRoles} from './User'; export type ApplicantBase = BaseApplicant | Agent; @@ -23,10 +23,10 @@ export interface Agent extends BaseApplicant { /** * @description Contact information for the agent or proxy */ - agent: ContactDetails & { address: UserAddress }; + agent: ContactDetails & {address: UserAddress}; } -export type SiteContact = { role: UserRoles } | SiteContactOther; +export type SiteContact = {role: UserRoles} | SiteContactOther; export interface SiteContactOther { role: 'other'; @@ -60,7 +60,7 @@ export type UserAddress = { }; export type ApplicantAddress = - | { sameAsSiteAddress: true } + | {sameAsSiteAddress: true} | ApplicantAddressNotSameSite; export interface ApplicantAddressNotSameSite extends UserAddress { @@ -90,9 +90,9 @@ export interface OwnersNoticeDate extends BaseOwners { export type MaintenanceContacts = { when: - | 'duringConstruction' - | 'afterConstruction' - | 'duringAndAfterConstruction'; + | 'duringConstruction' + | 'afterConstruction' + | 'duringAndAfterConstruction'; address: UserAddress; contact: ContactDetails; }[]; @@ -102,11 +102,11 @@ export type LDCApplicant = ApplicantBase & { * @description Information about the property owners, if different than the applicant */ ownership: - | { interest: Extract } - | { - interest: OwnershipInterest; // `Exclude` ? But I think you can be co owner & report other owners? - owners: (OwnersNoticeGiven | OwnersNoNoticeGiven)[]; - }; + | {interest: Extract} + | { + interest: OwnershipInterest; // `Exclude` ? But I think you can be co owner & report other owners? + owners: (OwnersNoticeGiven | OwnersNoNoticeGiven)[]; + }; }; export type PPApplicant = ApplicantBase & { @@ -153,10 +153,10 @@ export type PPApplicant = ApplicantBase & { export type LandDrainageConsentApplicant = ApplicantBase & { ownership: { interest: OwnershipInterest | 'owner.sole' | 'owner.co'; - } + }; /** @description Contact information for the person(s) responsible for maintenace while the works are carried out */ maintenanceContact?: MaintenanceContacts; -} +}; /** * TypeMap of PrimaryApplicationTypes to their specific Applicant models @@ -173,5 +173,5 @@ interface ApplicantVariants { */ export type Applicant = TPrimary extends keyof ApplicantVariants - ? ApplicantVariants[TPrimary] - : ApplicantBase; + ? ApplicantVariants[TPrimary] + : ApplicantBase; From fb35c0ed601d2c45bab95d8eb353e398394739d3 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Fri, 20 Sep 2024 10:08:03 +0200 Subject: [PATCH 3/3] add property and proposal variants --- .../data/planningPermission/major.ts | 6 +- .../data/planningPermission/minor.ts | 6 +- .../planningPermission/major.json | 3 + .../planningPermission/minor.json | 3 + schemas/prototypeApplication.json | 393 +++++++++++++++++- .../prototypeApplication/data/Property.ts | 24 ++ .../prototypeApplication/data/Proposal.ts | 16 +- types/schemas/prototypeApplication/index.ts | 8 +- 8 files changed, 447 insertions(+), 12 deletions(-) diff --git a/examples/prototypeApplication/data/planningPermission/major.ts b/examples/prototypeApplication/data/planningPermission/major.ts index e50d6d51..c443aeea 100644 --- a/examples/prototypeApplication/data/planningPermission/major.ts +++ b/examples/prototypeApplication/data/planningPermission/major.ts @@ -88,9 +88,9 @@ export const planningPermissionMajorPrototype: PrototypeApplication = { localAuthorityDistrict: ['Buckinghamshire', 'South Bucks'], region: 'South East', type: 'other.unsupported', - // use: { - // description: 'Vacant brownfield', - // }, + use: { + description: 'Vacant brownfield', + }, planning: { sources: [ 'https://api.editor.planx.dev/gis/buckinghamshire?geom=POLYGON+%28%28-0.5202563671906586+51.51349326091676%2C+-0.5162271673824664+51.51342965453125%2C+-0.5160930726385158+51.5119189712527%2C+-0.5186025432309797+51.51150473816995%2C+-0.5192921685359919+51.51150076298916%2C+-0.5197391470751718+51.5115882253788%2C+-0.5204032314768795+51.51156039632619%2C+-0.5207544293552119+51.512609937924225%2C+-0.5202563671906586+51.51349326091676%29%29&sessionId=180da003-279d-40dc-b538-a616c8c2a700', diff --git a/examples/prototypeApplication/data/planningPermission/minor.ts b/examples/prototypeApplication/data/planningPermission/minor.ts index 76f16c41..60f39ed7 100644 --- a/examples/prototypeApplication/data/planningPermission/minor.ts +++ b/examples/prototypeApplication/data/planningPermission/minor.ts @@ -149,9 +149,9 @@ export const planningPermissionMinorPrototype: PrototypeApplication = { }, ], }, - // materials: { - // boundary: 'black painted timber', - // }, + materials: { + boundary: 'black painted timber', + }, }, application: { fee: { diff --git a/examples/prototypeApplication/planningPermission/major.json b/examples/prototypeApplication/planningPermission/major.json index 32ede437..94ab8497 100644 --- a/examples/prototypeApplication/planningPermission/major.json +++ b/examples/prototypeApplication/planningPermission/major.json @@ -86,6 +86,9 @@ ], "region": "South East", "type": "other.unsupported", + "use": { + "description": "Vacant brownfield" + }, "planning": { "sources": [ "https://api.editor.planx.dev/gis/buckinghamshire?geom=POLYGON+%28%28-0.5202563671906586+51.51349326091676%2C+-0.5162271673824664+51.51342965453125%2C+-0.5160930726385158+51.5119189712527%2C+-0.5186025432309797+51.51150473816995%2C+-0.5192921685359919+51.51150076298916%2C+-0.5197391470751718+51.5115882253788%2C+-0.5204032314768795+51.51156039632619%2C+-0.5207544293552119+51.512609937924225%2C+-0.5202563671906586+51.51349326091676%29%29&sessionId=180da003-279d-40dc-b538-a616c8c2a700" diff --git a/examples/prototypeApplication/planningPermission/minor.json b/examples/prototypeApplication/planningPermission/minor.json index f30d4dec..c8dd0c09 100644 --- a/examples/prototypeApplication/planningPermission/minor.json +++ b/examples/prototypeApplication/planningPermission/minor.json @@ -146,6 +146,9 @@ ] } ] + }, + "materials": { + "boundary": "black painted timber" } }, "application": { diff --git a/schemas/prototypeApplication.json b/schemas/prototypeApplication.json index 08c21fd5..3483c5b6 100644 --- a/schemas/prototypeApplication.json +++ b/schemas/prototypeApplication.json @@ -5031,7 +5031,7 @@ "$ref": "#/definitions/PPApplicationData" }, "property": { - "$ref": "#/definitions/PropertyBase" + "$ref": "#/definitions/PPProperty" }, "proposal": { "$ref": "#/definitions/ProposalBase" @@ -5698,6 +5698,397 @@ } ] }, + "PPProperty": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "address": { + "anyOf": [ + { + "$ref": "#/definitions/ProposedAddress" + }, + { + "$ref": "#/definitions/OSAddress" + } + ] + }, + "boundary": { + "$ref": "#/definitions/GeoBoundary", + "description": "HM Land Registry Index polygon for this property, commonly referred to as the blue-line or title boundary, sourced from planning.data.gov.uk/dataset/title-boundary" + }, + "localAuthorityDistrict": { + "description": "Current and historic England Local Authority Districts that contain this address sourced from planning.data.gov.uk/dataset/local-authority-district", + "items": { + "type": "string" + }, + "type": "array" + }, + "materials": { + "$ref": "#/definitions/Materials" + }, + "planning": { + "additionalProperties": false, + "description": "Planning constraints and policies that intersect with this site and may impact or restrict development", + "properties": { + "conditions": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + }, + "designations": { + "items": { + "$ref": "#/definitions/PlanningDesignation" + }, + "type": "array" + }, + "guidance": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + }, + "plans": { + "additionalProperties": false, + "properties": { + "local": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + }, + "neighbourhood": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + } + }, + "required": [ + "local", + "neighbourhood" + ], + "type": "object" + }, + "sources": { + "description": "A list of open data requests or websites that explain how these constraints were sourced", + "items": { + "$ref": "#/definitions/URL" + }, + "type": "array" + } + }, + "required": [ + "sources" + ], + "type": "object" + }, + "region": { + "$ref": "#/definitions/Region" + }, + "type": { + "$ref": "#/definitions/PropertyType" + }, + "use": { + "additionalProperties": false, + "properties": { + "description": { + "type": "string" + } + }, + "required": [ + "description" + ], + "type": "object" + } + }, + "required": [ + "address", + "localAuthorityDistrict", + "region", + "type" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "EPC": { + "additionalProperties": false, + "properties": { + "known": { + "enum": [ + "Yes", + "Yes, but only some of the properties have one", + "The property does not have one", + "No" + ], + "type": "string" + }, + "number": { + "type": "string" + } + }, + "required": [ + "known" + ], + "title": "Energy Performance Certificate", + "type": "object" + }, + "address": { + "anyOf": [ + { + "$ref": "#/definitions/ProposedAddress" + }, + { + "$ref": "#/definitions/OSAddress" + } + ] + }, + "boundary": { + "$ref": "#/definitions/GeoBoundary", + "description": "HM Land Registry Index polygon for this property, commonly referred to as the blue-line or title boundary, sourced from planning.data.gov.uk/dataset/title-boundary" + }, + "localAuthorityDistrict": { + "description": "Current and historic England Local Authority Districts that contain this address sourced from planning.data.gov.uk/dataset/local-authority-district", + "items": { + "type": "string" + }, + "type": "array" + }, + "materials": { + "$ref": "#/definitions/Materials" + }, + "parking": { + "additionalProperties": false, + "properties": { + "buses": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "carClub": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "cars": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "cycles": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "disabled": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "motorcycles": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "offStreet": { + "additionalProperties": false, + "properties": { + "residential": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + } + }, + "required": [ + "residential" + ], + "type": "object" + }, + "other": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + }, + "vans": { + "additionalProperties": false, + "properties": { + "count": { + "type": "number" + } + }, + "required": [ + "count" + ], + "type": "object" + } + }, + "type": "object" + }, + "planning": { + "additionalProperties": false, + "description": "Planning constraints and policies that intersect with this site and may impact or restrict development", + "properties": { + "conditions": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + }, + "designations": { + "items": { + "$ref": "#/definitions/PlanningDesignation" + }, + "type": "array" + }, + "guidance": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + }, + "plans": { + "additionalProperties": false, + "properties": { + "local": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + }, + "neighbourhood": { + "items": { + "$ref": "#/definitions/PlanningConstraint" + }, + "type": "array" + } + }, + "required": [ + "local", + "neighbourhood" + ], + "type": "object" + }, + "sources": { + "description": "A list of open data requests or websites that explain how these constraints were sourced", + "items": { + "$ref": "#/definitions/URL" + }, + "type": "array" + } + }, + "required": [ + "sources" + ], + "type": "object" + }, + "region": { + "const": "London", + "type": "string" + }, + "titleNumber": { + "additionalProperties": false, + "properties": { + "known": { + "enum": [ + "Yes", + "No" + ], + "type": "string" + }, + "number": { + "type": "string" + } + }, + "required": [ + "known" + ], + "type": "object" + }, + "type": { + "$ref": "#/definitions/PropertyType" + }, + "use": { + "additionalProperties": false, + "properties": { + "description": { + "type": "string" + } + }, + "required": [ + "description" + ], + "type": "object" + } + }, + "required": [ + "address", + "localAuthorityDistrict", + "region", + "type" + ], + "type": "object" + } + ] + }, "PlanningApplication": { "additionalProperties": false, "description": "Details of the planning application linked to this application, if applicable", diff --git a/types/schemas/prototypeApplication/data/Property.ts b/types/schemas/prototypeApplication/data/Property.ts index 2e3d860f..ee2c182e 100644 --- a/types/schemas/prototypeApplication/data/Property.ts +++ b/types/schemas/prototypeApplication/data/Property.ts @@ -1,10 +1,12 @@ import {URL} from '../../../shared/utils'; import {GeoBoundary} from '../../application/data/shared'; +import {PrimaryApplicationType} from '../enums/ApplicationType'; import { PlanningConstraint, PlanningDesignation, } from '../enums/PlanningDesignation'; import {PropertyType} from '../enums/PropertyTypes'; +import {Materials} from './shared'; export type PropertyBase = EnglandProperty | LondonProperty; @@ -142,3 +144,25 @@ export interface OSAddress extends SiteAddress { singleLine: string; source: 'Ordnance Survey'; } + +export type PPProperty = PropertyBase & { + materials?: Materials; + use?: { + description: string; + }; +}; + +/** + * TypeMap of PrimaryApplicationTypes to their specific Property models + */ +interface PropertyVariants { + pp: PPProperty; +} + +/** + * @internal Conditional type to return a specific or generic Property model, based on PrimaryApplicationType + */ +export type Property = + TPrimary extends keyof PropertyVariants + ? PropertyVariants[TPrimary] + : PropertyBase; diff --git a/types/schemas/prototypeApplication/data/Proposal.ts b/types/schemas/prototypeApplication/data/Proposal.ts index c6043d64..e6d33e1b 100644 --- a/types/schemas/prototypeApplication/data/Proposal.ts +++ b/types/schemas/prototypeApplication/data/Proposal.ts @@ -1,3 +1,5 @@ +import {Area, Date, Integer} from '../../../shared/utils'; +import {PrimaryApplicationType} from '../enums/ApplicationType'; import {BuildingRegulation} from '../enums/BuildingRegulation'; import {DevelopmentType} from '../enums/DevelopmentType'; import {GLAHousingProvider} from '../enums/HousingProvider'; @@ -6,7 +8,6 @@ import {ProjectType} from '../enums/ProjectType'; import {ProtectedSpaceDesignation} from '../enums/ProtectedSpaceDesignation'; import {GLAResidentialUnitType} from '../enums/ResidentialUnitType'; import {GLATenureType} from '../enums/TenureType'; -import {Area, Date, Integer} from '../../../shared/utils'; import {GeoBoundaryPrototype, Materials, ResidentialUnits} from './shared'; /** @@ -304,3 +305,16 @@ interface GLAGainedUnit extends GLALostUnit { development: DevelopmentType; garden: boolean; } + +/** + * TypeMap of PrimaryApplicationTypes to their specific Proposal models + */ +type ProposalVariants = {}; + +/** + * @internal Conditional type to return a specific or generic Proposal model, based on PrimaryApplicationType + */ +export type Proposal = + TPrimary extends keyof ProposalVariants + ? ProposalVariants[TPrimary] + : ProposalBase; diff --git a/types/schemas/prototypeApplication/index.ts b/types/schemas/prototypeApplication/index.ts index e4e020ca..c2b36422 100644 --- a/types/schemas/prototypeApplication/index.ts +++ b/types/schemas/prototypeApplication/index.ts @@ -1,8 +1,8 @@ import {Responses} from '../../shared/Responses'; import {Applicant} from './data/Applicant'; import {ApplicationData} from './data/ApplicationData'; -import {PropertyBase} from './data/Property'; -import {ProposalBase} from './data/Proposal'; +import {Property} from './data/Property'; +import {Proposal} from './data/Proposal'; import {UserBase} from './data/User'; import { ApplicationType, @@ -32,8 +32,8 @@ interface ApplicationSpecification< user: UserBase; applicant: Applicant; application: ApplicationData; - property: PropertyBase; - proposal: ProposalBase; + property: Property; + proposal: Proposal; }; preAssessment?: PreAssessment; responses: Responses;