Skip to content

Commit

Permalink
clean up utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Sep 29, 2023
1 parent 099836b commit 45ce5dd
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 26 deletions.
17 changes: 16 additions & 1 deletion examples/data/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@ export const validProperty: Schema['data']['property'] = {
description: 'HMO Parent',
},
boundary: {
site: {type: 'GeoJSON Features TBD'},
site: {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[
[-0.1186569035053321, 51.465703531871384],
[-0.1185938715934822, 51.465724418998775],
[-0.1184195280075143, 51.46552473766957],
[-0.11848390102387167, 51.4655038504508],
[-0.1186569035053321, 51.465703531871384],
],
],
},
properties: null,
},
area: {
squareMetres: 10000,
hectares: 1,
Expand Down
17 changes: 16 additions & 1 deletion examples/data/Proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ export const validProposal: Schema['data']['proposal'] = {
],
description: 'This is a test application',
boundary: {
site: {type: 'GeoJSON Features TBD'},
site: {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[
[-0.1186569035053321, 51.465703531871384],
[-0.1185938715934822, 51.465724418998775],
[-0.1184195280075143, 51.46552473766957],
[-0.11848390102387167, 51.4655038504508],
[-0.1186569035053321, 51.465703531871384],
],
],
},
properties: null,
},
area: {
squareMetres: 10000,
hectares: 1,
Expand Down
60 changes: 58 additions & 2 deletions examples/validExampleAgent.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,35 @@
},
"boundary": {
"site": {
"type": "GeoJSON Features TBD"
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.1186569035053321,
51.465703531871384
],
[
-0.1185938715934822,
51.465724418998775
],
[
-0.1184195280075143,
51.46552473766957
],
[
-0.11848390102387167,
51.4655038504508
],
[
-0.1186569035053321,
51.465703531871384
]
]
]
},
"properties": null
},
"area": {
"squareMetres": 10000,
Expand Down Expand Up @@ -145,7 +173,35 @@
"description": "This is a test application",
"boundary": {
"site": {
"type": "GeoJSON Features TBD"
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.1186569035053321,
51.465703531871384
],
[
-0.1185938715934822,
51.465724418998775
],
[
-0.1184195280075143,
51.46552473766957
],
[
-0.11848390102387167,
51.4655038504508
],
[
-0.1186569035053321,
51.465703531871384
]
]
]
},
"properties": null
},
"area": {
"squareMetres": 10000,
Expand Down
60 changes: 58 additions & 2 deletions examples/validExampleApplicant.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,35 @@
},
"boundary": {
"site": {
"type": "GeoJSON Features TBD"
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.1186569035053321,
51.465703531871384
],
[
-0.1185938715934822,
51.465724418998775
],
[
-0.1184195280075143,
51.46552473766957
],
[
-0.11848390102387167,
51.4655038504508
],
[
-0.1186569035053321,
51.465703531871384
]
]
]
},
"properties": null
},
"area": {
"squareMetres": 10000,
Expand Down Expand Up @@ -140,7 +168,35 @@
"description": "This is a test application",
"boundary": {
"site": {
"type": "GeoJSON Features TBD"
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.1186569035053321,
51.465703531871384
],
[
-0.1185938715934822,
51.465724418998775
],
[
-0.1184195280075143,
51.46552473766957
],
[
-0.11848390102387167,
51.4655038504508
],
[
-0.1186569035053321,
51.465703531871384
]
]
]
},
"properties": null
},
"area": {
"squareMetres": 10000,
Expand Down
23 changes: 16 additions & 7 deletions schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"type": "string"
},
"noticeDate": {
"type": "string"
"$ref": "#/definitions/Date"
},
"noticeGiven": {
"type": "boolean"
Expand Down Expand Up @@ -938,7 +938,7 @@
"type": "string"
},
"noticeDate": {
"type": "string"
"$ref": "#/definitions/Date"
},
"noticeGiven": {
"type": "boolean"
Expand Down Expand Up @@ -1026,6 +1026,10 @@
},
"type": "object"
},
"Date": {
"format": "date",
"type": "string"
},
"DateTime": {
"format": "date-time",
"type": "string"
Expand Down Expand Up @@ -2511,7 +2515,8 @@
"description": "Details of the pre-application, if applicable",
"properties": {
"date": {
"$ref": "#/definitions/DateTime"
"format": "date-time",
"type": "string"
},
"officer": {
"type": "string"
Expand Down Expand Up @@ -12750,10 +12755,12 @@
"additionalProperties": false,
"properties": {
"completion": {
"$ref": "#/definitions/DateTime"
"format": "date-time",
"type": "string"
},
"start": {
"$ref": "#/definitions/DateTime"
"format": "date-time",
"type": "string"
}
},
"required": [
Expand All @@ -12780,10 +12787,12 @@
"additionalProperties": false,
"properties": {
"completion": {
"$ref": "#/definitions/DateTime"
"format": "date-time",
"type": "string"
},
"start": {
"$ref": "#/definitions/DateTime"
"format": "date-time",
"type": "string"
}
},
"required": [
Expand Down
4 changes: 2 additions & 2 deletions types/schema/data/Applicant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DateTime, Email} from '../../utils';
import {Date, Email} from '../../utils';
import {User} from './User';

/**
Expand All @@ -20,7 +20,7 @@ export interface BaseApplicant {
name: string;
address: AddressInput | string;
noticeGiven: boolean;
noticeDate?: string; // @todo type DateTime throws test error
noticeDate?: Date;
}[];
};
contact: UserContact;
Expand Down
2 changes: 1 addition & 1 deletion types/schema/data/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ApplicationFee {
*/
export interface PreApplication {
reference: string;
date: DateTime;
date: Date;
officer: string;
summary: string;
}
Expand Down
4 changes: 2 additions & 2 deletions types/schema/data/Property.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {PropertyTypes} from '../../enums/PropertyTypes';
import {Area} from '../../utils';
import {Area, GeoJSON} from '../../utils';

/**
* @id #Property
Expand All @@ -17,7 +17,7 @@ export interface UKProperty {
localAuthorityDistrict: string[];
type: PropertyType;
boundary?: {
site: Record<string, any>; // @todo use GeoJSON from utils here, but ajv tests failing
site: GeoJSON;
area: Area;
};
constraints?: {
Expand Down
12 changes: 6 additions & 6 deletions types/schema/data/Proposal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ProjectTypes} from '../../enums/ProjectTypes';
import {VehicleParking} from '../../enums/VehicleParking';
import {Area, DateTime} from '../../utils';
import {Area, DateTime, GeoJSON} from '../../utils';

/**
* @id #Proposal
Expand All @@ -10,17 +10,17 @@ export interface Proposal {
projectType: ProjectType[];
description: string;
boundary?: {
site: Record<string, any>; // @todo use GeoJSON from utils here, but ajv tests failing
site: GeoJSON;
area: Area;
};
date?: {
start: DateTime;
completion?: DateTime;
start: Date;
completion?: Date;
};
retro?: {
date: {
start: DateTime;
completion: DateTime;
start: Date;
completion: Date;
};
};
details?: ProposalDetails;
Expand Down
11 changes: 9 additions & 2 deletions types/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/** see available @format types here https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats */

/**
* @format uuid
*/
Expand All @@ -20,9 +22,14 @@ export type URL = string;
export type DateTime = string;

/**
* @format geojson
* @format date
*/
export type Date = string;

/**
* @id #GeoJSON
*/
export type GeoJSON = string;
export type GeoJSON = Record<string, any>;

/**
* @id #Area
Expand Down

0 comments on commit 45ce5dd

Please sign in to comment.