-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1eb3357
commit e688726
Showing
4 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
{ | ||
"$id": "@next", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/PlanningPermissionApplication" | ||
}, | ||
{ | ||
"$ref": "#/definitions/PriorApprovalApplication" | ||
}, | ||
{ | ||
"$ref": "#/definitions/WorksToTreesApplications" | ||
} | ||
], | ||
"definitions": { | ||
"ApplicationDataBase": { | ||
"additionalProperties": false, | ||
"description": "Base type for ApplicationData. Contains all shared properties across all application types", | ||
"properties": { | ||
"somethingShared": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"somethingShared" | ||
], | ||
"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": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"applicationType": { | ||
"const": "pp", | ||
"type": "string" | ||
}, | ||
"data": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"application": { | ||
"$ref": "#/definitions/PPApplicationData" | ||
}, | ||
"user": { | ||
"$ref": "#/definitions/PPUser" | ||
} | ||
}, | ||
"required": [ | ||
"user", | ||
"application" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"required": [ | ||
"applicationType", | ||
"data" | ||
], | ||
"type": "object" | ||
}, | ||
"PriorApprovalApplication": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"applicationType": { | ||
"const": "pa", | ||
"type": "string" | ||
}, | ||
"data": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"application": { | ||
"$ref": "#/definitions/ApplicationDataBase" | ||
}, | ||
"user": { | ||
"$ref": "#/definitions/UserBase" | ||
} | ||
}, | ||
"required": [ | ||
"user", | ||
"application" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"required": [ | ||
"applicationType", | ||
"data" | ||
], | ||
"type": "object" | ||
}, | ||
"UserBase": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"role": { | ||
"enum": [ | ||
"applicant", | ||
"agent", | ||
"proxy" | ||
], | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"role" | ||
], | ||
"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" | ||
}, | ||
"WTTUser": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"role": { | ||
"enum": [ | ||
"applicant", | ||
"agent", | ||
"proxy" | ||
], | ||
"type": "string" | ||
}, | ||
"wttSpecificProperty": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"role", | ||
"wttSpecificProperty" | ||
], | ||
"type": "object" | ||
}, | ||
"WorksToTreesApplications": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"applicationType": { | ||
"enum": [ | ||
"wtt", | ||
"wtt.consent", | ||
"wtt.notice" | ||
], | ||
"type": "string" | ||
}, | ||
"data": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"application": { | ||
"$ref": "#/definitions/WTTApplicationData" | ||
}, | ||
"user": { | ||
"$ref": "#/definitions/WTTUser" | ||
} | ||
}, | ||
"required": [ | ||
"user", | ||
"application" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"required": [ | ||
"applicationType", | ||
"data" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"description": "The root specification for a planning application in England generated by a digital planning service (prototype)", | ||
"title": "PrototypeApplication" | ||
} |
39 changes: 39 additions & 0 deletions
39
@next/types/schemas/prototypeApplication/ApplicationData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {PrimaryApplicationType} from '../application/enums/ApplicationTypes'; | ||
|
||
/** | ||
* Base type for ApplicationData. Contains all shared properties across all application types | ||
*/ | ||
export interface ApplicationDataBase { | ||
somethingShared: string; | ||
} | ||
|
||
/** | ||
* @description Specific ApplicationData required for "Works to trees" applications | ||
*/ | ||
export interface WTTApplicationData extends ApplicationDataBase { | ||
wttSpecificProperty: number; | ||
} | ||
|
||
/** | ||
* @description Specific ApplicationData required for "Planning Permission" applications | ||
*/ | ||
export interface PPApplicationData extends ApplicationDataBase { | ||
ppSpecificProperty: number; | ||
} | ||
|
||
/** | ||
* TypeMap of PrimaryApplicationTypes to their specific ApplicationData models | ||
*/ | ||
export interface ApplicationDataVariants { | ||
wtt: WTTApplicationData; | ||
pp: PPApplicationData; | ||
} | ||
|
||
/** | ||
* @internal | ||
* Conditional type to return a specific or generic ApplicationData model, based on PrimaryApplicationType | ||
*/ | ||
export type ApplicationData<TPrimary extends PrimaryApplicationType> = | ||
TPrimary extends keyof ApplicationDataVariants | ||
? ApplicationDataVariants[TPrimary] | ||
: ApplicationDataBase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {PrimaryApplicationType} from '../application/enums/ApplicationTypes'; | ||
|
||
export interface UserBase { | ||
role: 'applicant' | 'agent' | 'proxy'; | ||
} | ||
|
||
export interface WTTUser extends UserBase { | ||
wttSpecificProperty: boolean; | ||
} | ||
|
||
export interface PPUser extends UserBase { | ||
ppSpecificProperty: boolean; | ||
} | ||
|
||
/** | ||
* TypeMap of PrimaryApplicationTypes to their specific User models | ||
*/ | ||
interface UserVariants { | ||
wtt: WTTUser; | ||
pp: PPUser; | ||
} | ||
|
||
/** | ||
* @internal | ||
* Conditional type to return a specific or generic User model, based on PrimaryApplicationType | ||
*/ | ||
export type User<TPrimary extends PrimaryApplicationType> = | ||
TPrimary extends keyof UserVariants ? UserVariants[TPrimary] : UserBase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
ApplicationTypeKeys, | ||
PrimaryApplicationType, | ||
} from '../application/enums/ApplicationTypes'; | ||
import {ApplicationData} from './ApplicationData'; | ||
import {User} from './User'; | ||
|
||
/** | ||
* @internal | ||
* The generic base type for all applications | ||
* Takes a primary and granular application type which allows child properties to differ based on these inputs | ||
* Deriving `TPrimary` from `TGranular` is possible in TS, but not in a way which is currently compatible with ts-json-schema-generator | ||
*/ | ||
interface ApplicationSpecification< | ||
TPrimary extends PrimaryApplicationType, | ||
TGranular extends ApplicationTypeKeys, | ||
> { | ||
applicationType: TGranular; | ||
data: { | ||
user: User<TPrimary>; | ||
application: ApplicationData<TPrimary>; | ||
}; | ||
} | ||
|
||
export type PlanningPermissionApplication = ApplicationSpecification< | ||
'pp', | ||
'pp' | ||
>; | ||
// TODO: All granular types | ||
|
||
export type PriorApprovalApplication = ApplicationSpecification<'pa', 'pa'>; | ||
// TODO: All granular types | ||
|
||
export type WorksToTreesApplications = ApplicationSpecification< | ||
'wtt', | ||
Extract<ApplicationTypeKeys, 'wtt' | 'wtt.consent' | 'wtt.notice'> | ||
>; | ||
|
||
/** | ||
* @title PrototypeApplication | ||
* @description | ||
* The root specification for a planning application in England generated by a digital planning service (prototype) | ||
*/ | ||
export type PrototypeApplication = | ||
| PlanningPermissionApplication | ||
| PriorApprovalApplication | ||
| WorksToTreesApplications; | ||
// TODO: All the rest! | ||
|
||
// const test: App = { | ||
// applicationType: 'wtt.consent', | ||
// data: { | ||
// user: { | ||
// role: 'agent', | ||
// wttSpecificProperty: true, | ||
// }, | ||
// application: { | ||
// wttSpecificProperty: 123, | ||
// somethingShared: 'abc', | ||
// }, | ||
// }, | ||
// }; |