Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: simplify Metadata type #68

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions examples/data/ldcE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1596,20 +1596,16 @@ export const validLDCE: Schema = {
},
],
metadata: {
source: 'PlanX',
organisation: 'Buckinghamshire',
id: '95f90e21-93f5-4761-90b3-815c673e041f',
service: {
flowId: '824628b2-deeb-48b0-92b1-2ca7f3b17163',
name: 'Apply for a lawful development certificate',
owner: 'Buckinghamshire',
url: 'https://www.editor.planx.dev/buckinghamshire/apply-for-a-lawful-development-certificate/preview',
},
session: {
source: 'PlanX',
id: '95f90e21-93f5-4761-90b3-815c673e041f',
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
},
schema: {
url: 'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
jessicamcinchak marked this conversation as resolved.
Show resolved Hide resolved
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
};
18 changes: 7 additions & 11 deletions examples/data/ldcP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,20 +1112,16 @@ export const validLDCP: Schema = {
},
],
metadata: {
source: 'PlanX',
organisation: 'Buckinghamshire',
id: '8da51c5b-a2a0-4386-a15d-29d66f9c121c',
service: {
flowId: '824628b2-deeb-48b0-92b1-2ca7f3b17163',
name: 'Apply for a lawful development certificate',
owner: 'Buckinghamshire',
url: 'https://www.editor.planx.dev/buckinghamshire/apply-for-a-lawful-development-certificate/preview',
},
session: {
source: 'PlanX',
id: '8da51c5b-a2a0-4386-a15d-29d66f9c121c',
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
},
schema: {
url: 'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
};
18 changes: 7 additions & 11 deletions examples/data/planningPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1690,20 +1690,16 @@ export const validPlanningPermission: Schema = {
},
],
metadata: {
source: 'PlanX',
organisation: 'Lambeth',
id: '81bcaa0f-baf5-4573-ba0a-ea868c573faf',
service: {
flowId: '01e38c5d-e701-4e44-acdc-4d6b5cc3b854',
name: 'Apply for planning permission',
owner: 'Lambeth',
url: 'https://www.editor.planx.dev/lambeth/apply-for-planning-permission/preview',
},
session: {
source: 'PlanX',
id: '81bcaa0f-baf5-4573-ba0a-ea868c573faf',
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
},
schema: {
url: 'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
};
18 changes: 7 additions & 11 deletions examples/data/priorApproval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,20 +1028,16 @@ export const validPriorApproval: Schema = {
},
],
metadata: {
source: 'PlanX',
organisation: 'Southwark',
id: 'b18c301b-9d44-4c6c-8d27-5b5bf33c570b',
service: {
flowId: 'c6628103-c648-4663-81e1-bfa0a1a18340',
name: 'Apply for prior approval',
owner: 'Southwark',
url: 'https://www.editor.planx.dev/southwark/apply-for-prior-approval/preview',
},
session: {
source: 'PlanX',
id: 'b18c301b-9d44-4c6c-8d27-5b5bf33c570b',
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
},
schema: {
url: 'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
createdAt: '2023-10-01 00:00:00',
submittedAt: '2023-10-02 00:00:00',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json',
},
};
162 changes: 93 additions & 69 deletions schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,39 @@
},
"type": "object"
},
"BaseMetadata": {
"$id": "#BaseMetadata",
"additionalProperties": false,
"description": "Minimum metadata expected for any application",
"properties": {
"createdAt": {
"$ref": "#/definitions/DateTime"
},
"id": {
"$ref": "#/definitions/UUID",
"description": "Unique identifier for this application"
},
"organisation": {
"type": "string"
},
"schema": {
"$ref": "#/definitions/URL"
},
"source": {
"const": "PlanX",
"default": "PlanX",
"type": "string"
}
},
"required": [
"source",
"organisation",
"id",
"createdAt",
"schema"
],
"type": "object"
},
"Date": {
"format": "date",
"type": "string"
Expand Down Expand Up @@ -2837,78 +2870,16 @@
"type": "object"
},
"Metadata": {
"additionalProperties": false,
"properties": {
"schema": {
"additionalProperties": false,
"properties": {
"url": {
"$ref": "#/definitions/URL"
}
},
"required": [
"url"
],
"type": "object"
},
"service": {
"$id": "#DigitalPlanningMetadata",
"additionalProperties": false,
"description": "Details of the digital planning service which sent the application",
"properties": {
"flowId": {
"$ref": "#/definitions/UUID"
},
"name": {
"type": "string"
},
"owner": {
"type": "string"
},
"url": {
"$ref": "#/definitions/URL"
}
},
"required": [
"flowId",
"name",
"owner",
"url"
],
"type": "object"
"$id": "#DigitalPlanningMetadata",
"anyOf": [
{
"$ref": "#/definitions/BaseMetadata"
},
"session": {
"additionalProperties": false,
"properties": {
"createdAt": {
"$ref": "#/definitions/DateTime"
},
"id": {
"$ref": "#/definitions/UUID"
},
"source": {
"const": "PlanX",
"default": "PlanX",
"type": "string"
},
"submittedAt": {
"$ref": "#/definitions/DateTime"
}
},
"required": [
"source",
"id",
"createdAt"
],
"type": "object"
{
"$ref": "#/definitions/PlanxMetadata"
}
},
"required": [
"service",
"session",
"schema"
],
"type": "object"
"description": "Details of the digital planning service which sent this application"
},
"MultiLineString": {
"additionalProperties": false,
Expand Down Expand Up @@ -5263,6 +5234,59 @@
],
"description": "Planning constraints that overlap with the property site boundary determined by spatial queries against Planning Data (planning.data.gov.uk) and Ordnance Survey"
},
"PlanxMetadata": {
"$id": "#PlanxMetadata",
"additionalProperties": false,
"description": "Additional metadata associated with applications submitted via PlanX",
"properties": {
"createdAt": {
"$ref": "#/definitions/DateTime"
},
"id": {
"$ref": "#/definitions/UUID",
"description": "Unique identifier for this application"
},
"organisation": {
"type": "string"
},
"schema": {
"$ref": "#/definitions/URL"
},
"service": {
"additionalProperties": false,
"properties": {
"flowId": {
"$ref": "#/definitions/UUID"
},
"url": {
"$ref": "#/definitions/URL"
}
},
"required": [
"flowId",
"url"
],
"type": "object"
},
"source": {
"const": "PlanX",
"default": "PlanX",
"type": "string"
},
"submittedAt": {
"$ref": "#/definitions/DateTime"
}
},
"required": [
"createdAt",
"id",
"organisation",
"schema",
"service",
"source"
],
"type": "object"
},
"Point": {
"additionalProperties": false,
"description": "Point geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.2",
Expand Down
47 changes: 29 additions & 18 deletions types/schema/Metadata.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import {DateTime, URL, UUID} from './../utils';

export interface Metadata {
/**
* @id #DigitalPlanningMetadata
* @description Details of the digital planning service which sent this application
*/
export type Metadata = BaseMetadata | PlanxMetadata;

/**
* @id #BaseMetadata
* @description Minimum metadata expected for any application
*/
export interface BaseMetadata {
/**
* @default PlanX
*/
source: 'PlanX';
organisation: string; // @todo align to DLUHC Planning Application API curie
/**
* @id #DigitalPlanningMetadata
* @description Details of the digital planning service which sent the application
* @description Unique identifier for this application
*/
id: UUID; // @todo align to DLUHC Planning Application API reference
createdAt: DateTime;
schema: URL;
}

/**
* @id #PlanxMetadata
* @description Additional metadata associated with applications submitted via PlanX
*/
export interface PlanxMetadata extends BaseMetadata {
jessicamcinchak marked this conversation as resolved.
Show resolved Hide resolved
service: {
flowId: UUID | string; // @todo temp fix for failing UUID validation, sort out and tighten
name: string;
owner: string;
url: URL;
};
session: {
/**
* @default PlanX
*/
source: 'PlanX';
id: UUID | string;
createdAt: DateTime;
submittedAt?: DateTime;
};
schema: {
flowId: UUID;
url: URL;
};
submittedAt?: DateTime;
}
Loading