Skip to content

Commit

Permalink
full res unit types, refactor enum definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Jul 2, 2024
1 parent 8cdd8ad commit 04c0bb9
Show file tree
Hide file tree
Showing 21 changed files with 376 additions and 222 deletions.
17 changes: 17 additions & 0 deletions types/enums/ApplicationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,20 @@ export const ApplicationTypes = {
'wtt.notice':
'Works to trees - Notification of proposed works to a tree in a Conservation Area',
};

type ApplicationTypeKeys = keyof typeof ApplicationTypes;

type GenericApplicationType<TKey extends ApplicationTypeKeys> = {
value: TKey;
description: (typeof ApplicationTypes)[TKey];
};

type ApplicationTypeMap = {
[K in ApplicationTypeKeys]: GenericApplicationType<K>;
};

/**
* @id #ApplicationType
* @description Planning application types
*/
export type ApplicationType = ApplicationTypeMap[keyof ApplicationTypeMap];
26 changes: 26 additions & 0 deletions types/enums/BuildingRegulations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Values of `data.proposal.units.residential`
*/
export const BuildingRegulations = {
m42: "Part M4(2) of the Building Regulations 2010",
m432a: "Part M4(3)(2a) of the Building Regulations 2010",
m432b: "Part M4(3)(2b) of the Building Regulations 2010",
none: "None of these",
};

type BuildingRegulationKeys = keyof typeof BuildingRegulations;

type GenericBuildingRegulation<TKey extends BuildingRegulationKeys> = {
value: TKey;
description: (typeof BuildingRegulations)[TKey];
};

type BuildingRegulationMap = {
[K in BuildingRegulationKeys]: GenericBuildingRegulation<K>;
};

/**
* @id #BuildingRegulation
* @description Building regulations
*/
export type BuildingRegulation = BuildingRegulationMap[keyof BuildingRegulationMap];
17 changes: 17 additions & 0 deletions types/enums/DevelopmentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,20 @@ export const DevelopmentTypes = {
newBuild: 'New build',
notKnown: 'Not known',
};

type DevelopmentTypeKeys = keyof typeof DevelopmentTypes;

type GenericDevelopmentType<TKey extends DevelopmentTypeKeys> = {
value: TKey;
description: (typeof DevelopmentTypes)[TKey];
};

type DevelopmentTypeMap = {
[K in DevelopmentTypeKeys]: GenericDevelopmentType<K>;
};

/**
* @id #DevelopmentType
* @description Development types
*/
export type DevelopmentType = DevelopmentTypeMap[keyof DevelopmentTypeMap];
17 changes: 17 additions & 0 deletions types/enums/FileTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,20 @@ export const FileTypes = {
wasteAndRecyclingStrategy: 'Waste and recycling strategy',
waterEnvironmentAssessment: 'Water environment assessment',
};

type FileTypeKeys = keyof typeof FileTypes;

type GenericFileType<TKey extends FileTypeKeys> = {
value: TKey;
description: (typeof FileTypes)[TKey];
};

type FileTypeMap = {
[K in FileTypeKeys]: GenericFileType<K>;
};

/**
* @id #FileType
* @description Types of planning documents and drawings
*/
export type FileType = FileTypeMap[keyof FileTypeMap];
17 changes: 17 additions & 0 deletions types/enums/Flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,20 @@ export const Flags = {
'Community infrastructure levy / Liable': '',
'Community infrastructure levy / Not liable': '',
};

type FlagKeys = keyof typeof Flags;

type GenericFlag<TKey extends FlagKeys> = {
value: TKey;
description: (typeof Flags)[TKey];
};

type FlagMap = {
[K in FlagKeys]: GenericFlag<K>;
};

/**
* @id #ResultFlag
* @description The result of a single flagset
*/
export type ResultFlag = FlagMap[keyof FlagMap];
17 changes: 17 additions & 0 deletions types/enums/HousingProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ export const GLAHousingProviders = {
publicAuthority: 'Other public authority',
selfBuild: 'Self-build',
};

type GLAHousingProviderKeys = keyof typeof GLAHousingProviders;

type GenericGLAHousingProvider<TKey extends GLAHousingProviderKeys> = {
value: TKey;
description: (typeof GLAHousingProviders)[TKey];
};

type GLAHousingProviderMap = {
[K in GLAHousingProviderKeys]: GenericGLAHousingProvider<K>;
};

/**
* @id #GLAHousingProvider
* @description Housing provider categories tracked by the Greater London Authority (GLA)
*/
export type GLAHousingProvider = GLAHousingProviderMap[keyof GLAHousingProviderMap];
36 changes: 36 additions & 0 deletions types/enums/OpenSpaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,39 @@ export const GLAOpenSpaceDesignations = {
none: 'Not designated',
other: 'Other designation',
};

type OpenSpaceTypeKeys = keyof typeof GLAOpenSpaceTypes;

type GenericOpenSpaceType<TKey extends OpenSpaceTypeKeys> = {
value: TKey;
description: (typeof GLAOpenSpaceTypes)[TKey];
};

type OpenSpaceTypeMap = {
[K in OpenSpaceTypeKeys]: GenericOpenSpaceType<K>;
};

/**
* @id #OpenSpaceType
* @description Types of natural open spaces
*/
export type OpenSpaceType = OpenSpaceTypeMap[keyof OpenSpaceTypeMap];

type OpenSpaceDesignationKeys = keyof typeof GLAOpenSpaceDesignations;

type GenericOpenSpaceDesignation<TKey extends OpenSpaceDesignationKeys> = {
value: TKey;
description: (typeof GLAOpenSpaceDesignations)[TKey];
};

type OpenSpaceDesignationMap = {
[K in OpenSpaceDesignationKeys]: GenericOpenSpaceDesignation<K>;
};

/**
* @id #OpenSpaceDesignation
* @description Designations of natural open spaces
*/
export type OpenSpaceDesignation =
OpenSpaceDesignationMap[keyof OpenSpaceDesignationMap];

39 changes: 39 additions & 0 deletions types/enums/PlanningConstraints.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Entity } from "../schema/data/shared";

/**
* Values for `data.property.planning.designations`
*/
Expand Down Expand Up @@ -31,3 +33,40 @@ export const PlanningDesignations = {
'road.classified': 'Classified Road',
tpo: 'Tree Preservation Order (TPO) or zone',
};

type PlanningDesigationKeys = keyof typeof PlanningDesignations;

type GenericPlanningDesignation<TKey extends PlanningDesigationKeys> = {
value: TKey;
description: (typeof PlanningDesignations)[TKey];
};

type PlanningDesignationMap = {
[K in PlanningDesigationKeys]: GenericPlanningDesignation<K>;
};

type BasePlanningDesignation =
PlanningDesignationMap[keyof PlanningDesignationMap];

/**
* @description A planning designation that does not intersect with the proposed site, per the DE-9IM spatial relationship definition of intersects
*/
type NonIntersectingPlanningDesignation = {
intersects: false;
} & BasePlanningDesignation;

/**
* @description A planning designation that does intersect with the proposed site, per the DE-9IM spatial relationship definition of intersects
*/
type IntersectingPlanningDesignation = {
intersects: true;
entities: Entity[] | [];
} & BasePlanningDesignation;

/**
* @id #PlanningDesignation
* @description Planning designations that may intersect with the proposed site determined by spatial queries against Planning Data (planning.data.gov.uk) and Ordnance Survey
*/
export type PlanningDesignation =
| NonIntersectingPlanningDesignation
| IntersectingPlanningDesignation;
17 changes: 17 additions & 0 deletions types/enums/ProjectTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,20 @@ export const ProjectTypes = {
'unit.merge': 'Convert two or more properties into one',
'unit.subdivide': 'Convert a home or part of a home into flats',
};

type ProjectTypeKeys = keyof typeof ProjectTypes;

type GenericProjectType<TKey extends ProjectTypeKeys> = {
value: TKey;
description: (typeof ProjectTypes)[TKey];
};

type ProjectTypeMap = {
[K in ProjectTypeKeys]: GenericProjectType<K>;
};

/**
* @id #ProjectType
* @description Planning project types
*/
export type ProjectType = ProjectTypeMap[keyof ProjectTypeMap];
17 changes: 17 additions & 0 deletions types/enums/PropertyTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,20 @@ export const PropertyTypes = {
'object.religious.building.synagogue': 'Synagogue',
'object.religious.building.temple': 'Temple',
};

type PropertyTypeKeys = keyof typeof PropertyTypes;

type GenericPropertyType<TKey extends PropertyTypeKeys> = {
value: TKey;
description: (typeof PropertyTypes)[TKey];
};

type PropertyTypeMap = {
[K in PropertyTypeKeys]: GenericPropertyType<K>;
};

/**
* @id #PropertyType
* @description Property types derived from Basic Land and Property Unit (BLPU) classification codes
*/
export type PropertyType = PropertyTypeMap[keyof PropertyTypeMap];
20 changes: 20 additions & 0 deletions types/enums/ProtectedSpaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@ export const GLAProtectedSpaceDesignations = {
none: 'Not designated',
SSSI: 'Sites of Special Scientific Interest',
};

type ProtectedSpaceDesignationKeys = keyof typeof GLAProtectedSpaceDesignations;

type GenericProtectedSpaceDesignation<
TKey extends ProtectedSpaceDesignationKeys,
> = {
value: TKey;
description: (typeof GLAProtectedSpaceDesignations)[TKey];
};

type ProtectedSpaceDesignationMap = {
[K in ProtectedSpaceDesignationKeys]: GenericProtectedSpaceDesignation<K>;
};

/**
* @id #ProtectedSpaceDesignation
* @description Designations of natural protected spaces
*/
export type ProtectedSpaceDesignation =
ProtectedSpaceDesignationMap[keyof ProtectedSpaceDesignationMap];
38 changes: 36 additions & 2 deletions types/enums/ResidentialUnitTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const NationalResidentialUnitTypes = {
export const UKResidentialUnitTypes = {
cluster: 'Cluster flat',
flat: 'Flat',
house: 'House',
Expand All @@ -23,6 +23,40 @@ export const GLAResidentialUnitTypes = {
};

export const ResidentialUnitTypes = {
...NationalResidentialUnitTypes,
...UKResidentialUnitTypes,
...GLAResidentialUnitTypes,
};

type UKResidentialUnitTypeKeys = keyof typeof UKResidentialUnitTypes;

type GenericUKResidentialUnitType<TKey extends UKResidentialUnitTypeKeys> = {
value: TKey;
description: (typeof UKResidentialUnitTypes)[TKey];
};

type UKResidentialUnitTypeMap = {
[K in UKResidentialUnitTypeKeys]: GenericUKResidentialUnitType<K>;
};

/**
* @id #UKResidentialUnitType
* @description Residential unit types tracked throughout the UK
*/
export type UKResidentialUnitType = UKResidentialUnitTypeMap[keyof UKResidentialUnitTypeMap];

type GLAResidentialUnitTypeKeys = keyof typeof GLAResidentialUnitTypes;

type GenericGLAResidentialUnitType<TKey extends GLAResidentialUnitTypeKeys> = {
value: TKey;
description: (typeof GLAResidentialUnitTypes)[TKey];
};

type GLAResidentialUnitTypeMap = {
[K in GLAResidentialUnitTypeKeys]: GenericGLAResidentialUnitType<K>;
};

/**
* @id #GLAResidentialUnitType
* @description Residential unit types tracked by the Greater London Authority (GLA)
*/
export type GLAResidentialUnitType = GLAResidentialUnitTypeMap[keyof GLAResidentialUnitTypeMap];
38 changes: 36 additions & 2 deletions types/enums/TenureTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const NationalTenureTypes = {
export const UKTenureTypes = {
AHO: 'Affordable home ownership',
MH: 'Market housing',
other: 'Other',
Expand All @@ -25,6 +25,40 @@ export const GLATenureTypes = {
};

export const TenureTypes = {
...NationalTenureTypes,
...UKTenureTypes,
...GLATenureTypes,
};

type UKTenureTypeKeys = keyof typeof UKTenureTypes;

type GenericUKTenureType<TKey extends UKTenureTypeKeys> = {
value: TKey;
description: (typeof UKTenureTypes)[TKey];
};

type UKTenureTypeMap = {
[K in UKTenureTypeKeys]: GenericUKTenureType<K>;
};

/**
* @id #UKTenureType
* @description Tenure types tracked throughout the UK
*/
export type UKTenureType = UKTenureTypeMap[keyof UKTenureTypeMap];

type GLATenureTypeKeys = keyof typeof GLATenureTypes;

type GenericGLATenureType<TKey extends GLATenureTypeKeys> = {
value: TKey;
description: (typeof GLATenureTypes)[TKey];
};

type GLATenureTypeMap = {
[K in GLATenureTypeKeys]: GenericGLATenureType<K>;
};

/**
* @id #GLATenureType
* @description Tenure types tracked by the Greater London Authority (GLA)
*/
export type GLATenureType = GLATenureTypeMap[keyof GLATenureTypeMap];
Loading

0 comments on commit 04c0bb9

Please sign in to comment.