Skip to content

Commit

Permalink
feat: Simplify enums, try using JSON for descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jul 26, 2024
1 parent 20e5e4e commit 8b6acb8
Show file tree
Hide file tree
Showing 6 changed files with 661 additions and 105 deletions.
242 changes: 162 additions & 80 deletions schemas/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/PlanningPermissionApplication"
"$ref": "#/definitions/PPApplication"
},
{
"$ref": "#/definitions/PriorApprovalApplication"
"$ref": "#/definitions/PAApplication"
},
{
"$ref": "#/definitions/WorksToTreesApplications"
"$ref": "#/definitions/WTTApplication"
}
],
"definitions": {
Expand All @@ -26,59 +26,20 @@
],
"type": "object"
},
"PPApplicationData": {
"additionalProperties": false,
"description": "Specific ApplicationData required for \"Planning Permission\" applications",
"properties": {
"ppSpecificProperty": {
"type": "number"
},
"somethingShared": {
"type": "string"
}
},
"required": [
"ppSpecificProperty",
"somethingShared"
],
"type": "object"
},
"PPUser": {
"additionalProperties": false,
"properties": {
"ppSpecificProperty": {
"type": "boolean"
},
"role": {
"enum": [
"applicant",
"agent",
"proxy"
],
"type": "string"
}
},
"required": [
"ppSpecificProperty",
"role"
],
"type": "object"
},
"PlanningPermissionApplication": {
"PAApplication": {
"additionalProperties": false,
"properties": {
"applicationType": {
"const": "pp",
"type": "string"
"$ref": "#/definitions/PAApplicationType"
},
"data": {
"additionalProperties": false,
"properties": {
"application": {
"$ref": "#/definitions/PPApplicationData"
"$ref": "#/definitions/ApplicationDataBase"
},
"user": {
"$ref": "#/definitions/PPUser"
"$ref": "#/definitions/UserBase"
}
},
"required": [
Expand All @@ -94,21 +55,67 @@
],
"type": "object"
},
"PriorApprovalApplication": {
"PAApplicationType": {
"enum": [
"pa",
"pa.part1.classA",
"pa.part1.classAA",
"pa.part3.classG",
"pa.part3.classM",
"pa.part3.classMA",
"pa.part3.classN",
"pa.part3.classQ",
"pa.part3.classR",
"pa.part3.classS",
"pa.part3.classT",
"pa.part3.classV",
"pa.part4.classBB",
"pa.part4.classBC",
"pa.part4.classCA",
"pa.part4.classE",
"pa.part6",
"pa.part6.classA",
"pa.part6.classB",
"pa.part6.classE",
"pa.part7.classC",
"pa.part7.classM",
"pa.part9.classD",
"pa.part11.classB",
"pa.part14.classA",
"pa.part14.classB",
"pa.part14.classJ",
"pa.part14.classK",
"pa.part14.classOA",
"pa.part16.classA",
"pa.part17",
"pa.part17.classB",
"pa.part17.classC",
"pa.part17.classG",
"pa.part18.classA",
"pa.part19.classTA",
"pa.part20.classA",
"pa.part20.classAA",
"pa.part20.classAB",
"pa.part20.classAC",
"pa.part20.classAD",
"pa.part20.classZA"
],
"type": "string"
},
"PPApplication": {
"additionalProperties": false,
"properties": {
"applicationType": {
"const": "pa",
"type": "string"
"$ref": "#/definitions/PPApplicationType"
},
"data": {
"additionalProperties": false,
"properties": {
"application": {
"$ref": "#/definitions/ApplicationDataBase"
"$ref": "#/definitions/PPApplicationData"
},
"user": {
"$ref": "#/definitions/UserBase"
"$ref": "#/definitions/PPUser"
}
},
"required": [
Expand All @@ -124,41 +131,78 @@
],
"type": "object"
},
"UserBase": {
"PPApplicationData": {
"additionalProperties": false,
"description": "Specific ApplicationData required for \"Planning Permission\" applications",
"properties": {
"role": {
"enum": [
"applicant",
"agent",
"proxy"
],
"ppSpecificProperty": {
"type": "number"
},
"somethingShared": {
"type": "string"
}
},
"required": [
"role"
"ppSpecificProperty",
"somethingShared"
],
"type": "object"
},
"WTTApplicationData": {
"PPApplicationType": {
"enum": [
"pp",
"pp.full",
"pp.full.advertConsent",
"pp.full.demolition",
"pp.full.fastTrack.affordable",
"pp.full.householder",
"pp.full.householder.listed",
"pp.full.householder.retro",
"pp.full.major",
"pp.full.major.technicalDetails",
"pp.full.major.technicalDetails.waste",
"pp.full.major.waste",
"pp.full.minor",
"pp.full.minor.listed",
"pp.full.minor.technicalDetails",
"pp.mineralExtraction",
"pp.outline",
"pp.outline.all",
"pp.outline.some",
"pp.outline.minor",
"pp.outline.minor.all",
"pp.outline.minor.some",
"pp.outline.major",
"pp.outline.major.all",
"pp.outline.major.all.waste",
"pp.outline.major.some",
"pp.outline.major.some.waste",
"pp.pip"
],
"type": "string"
},
"PPUser": {
"additionalProperties": false,
"description": "Specific ApplicationData required for \"Works to trees\" applications",
"properties": {
"somethingShared": {
"type": "string"
"ppSpecificProperty": {
"type": "boolean"
},
"wttSpecificProperty": {
"type": "number"
"role": {
"enum": [
"applicant",
"agent",
"proxy"
],
"type": "string"
}
},
"required": [
"somethingShared",
"wttSpecificProperty"
"ppSpecificProperty",
"role"
],
"type": "object"
},
"WTTUser": {
"UserBase": {
"additionalProperties": false,
"properties": {
"role": {
Expand All @@ -168,27 +212,18 @@
"proxy"
],
"type": "string"
},
"wttSpecificProperty": {
"type": "boolean"
}
},
"required": [
"role",
"wttSpecificProperty"
"role"
],
"type": "object"
},
"WorksToTreesApplications": {
"WTTApplication": {
"additionalProperties": false,
"properties": {
"applicationType": {
"enum": [
"wtt",
"wtt.consent",
"wtt.notice"
],
"type": "string"
"$ref": "#/definitions/WTTApplicationType"
},
"data": {
"additionalProperties": false,
Expand All @@ -212,6 +247,53 @@
"data"
],
"type": "object"
},
"WTTApplicationData": {
"additionalProperties": false,
"description": "Specific ApplicationData required for \"Works to trees\" applications",
"properties": {
"somethingShared": {
"type": "string"
},
"wttSpecificProperty": {
"type": "number"
}
},
"required": [
"somethingShared",
"wttSpecificProperty"
],
"type": "object"
},
"WTTApplicationType": {
"description": "{\n \"wtt\": \"Works to trees\",\n \"wtt.consent\": \"Consent to carry out works to a tree with a Tree Preservation Order\",\n \"wtt.notice\": \"Notification of proposed works to a tree in a Conservation Area\"\n}",
"enum": [
"wtt",
"wtt.consent",
"wtt.notice"
],
"type": "string"
},
"WTTUser": {
"additionalProperties": false,
"properties": {
"role": {
"enum": [
"applicant",
"agent",
"proxy"
],
"type": "string"
},
"wttSpecificProperty": {
"type": "boolean"
}
},
"required": [
"role",
"wttSpecificProperty"
],
"type": "object"
}
},
"description": "(Temporary name to not clash with the existing `Application` type)\nThe root specification for a planning application in England generated by a digital planning service",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PrimaryApplicationType} from '../application/enums/ApplicationTypes';
import {PrimaryApplicationType} from '../enums/ApplicationType';

/**
* Base type for ApplicationData. Contains all shared properties across all application types
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PrimaryApplicationType} from '../application/enums/ApplicationTypes';
import {PrimaryApplicationType} from '../enums/ApplicationType';

export interface UserBase {
role: 'applicant' | 'agent' | 'proxy';
Expand Down
Loading

0 comments on commit 8b6acb8

Please sign in to comment.