From 697354690d9ac39a448f5807b64be255e66bd495 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 7 Nov 2023 22:50:43 +0100 Subject: [PATCH] simplify metadata type --- examples/data/ldcE.ts | 18 ++- examples/data/ldcP.ts | 18 ++- examples/data/planningPermission.ts | 18 ++- examples/data/priorApproval.ts | 18 ++- schema/schema.json | 176 +++++++++++++++------------- types/schema/Metadata.ts | 47 +++++--- 6 files changed, 150 insertions(+), 145 deletions(-) diff --git a/examples/data/ldcE.ts b/examples/data/ldcE.ts index 4e59f2d4..68414575 100644 --- a/examples/data/ldcE.ts +++ b/examples/data/ldcE.ts @@ -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', + schema: + 'https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json', }, }; diff --git a/examples/data/ldcP.ts b/examples/data/ldcP.ts index 3134e7af..afae8e7b 100644 --- a/examples/data/ldcP.ts +++ b/examples/data/ldcP.ts @@ -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', }, }; diff --git a/examples/data/planningPermission.ts b/examples/data/planningPermission.ts index 56f06773..da60100f 100644 --- a/examples/data/planningPermission.ts +++ b/examples/data/planningPermission.ts @@ -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', }, }; diff --git a/examples/data/priorApproval.ts b/examples/data/priorApproval.ts index 6855cd21..69b3c828 100644 --- a/examples/data/priorApproval.ts +++ b/examples/data/priorApproval.ts @@ -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', }, }; diff --git a/schema/schema.json b/schema/schema.json index 9bfb8dc6..9ebb95cb 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -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" @@ -2837,92 +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": { - "anyOf": [ - { - "$ref": "#/definitions/UUID" - }, - { - "type": "string" - } - ] - }, - "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": { - "anyOf": [ - { - "$ref": "#/definitions/UUID" - }, - { - "type": "string" - } - ] - }, - "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, @@ -5277,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", diff --git a/types/schema/Metadata.ts b/types/schema/Metadata.ts index 47b1813a..ef6a8e1c 100644 --- a/types/schema/Metadata.ts +++ b/types/schema/Metadata.ts @@ -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 { 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; }