diff --git a/examples/data/ldcE.ts b/examples/data/ldcE.ts index 34b4a34a..c8ba933c 100644 --- a/examples/data/ldcE.ts +++ b/examples/data/ldcE.ts @@ -1596,20 +1596,15 @@ export const validLDCE: Schema = { }, ], metadata: { + organisation: 'Buckinghamshire', + id: '95f90e21-93f5-4761-90b3-815c673e041f', + source: 'PlanX', 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', - }, + 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 8b401c82..67b04c91 100644 --- a/examples/data/ldcP.ts +++ b/examples/data/ldcP.ts @@ -1112,20 +1112,15 @@ export const validLDCP: Schema = { }, ], metadata: { + organisation: 'Buckinghamshire', + id: '8da51c5b-a2a0-4386-a15d-29d66f9c121c', + source: 'PlanX', 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', - }, + 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 92e7b286..626cb6fd 100644 --- a/examples/data/planningPermission.ts +++ b/examples/data/planningPermission.ts @@ -1690,20 +1690,15 @@ export const validPlanningPermission: Schema = { }, ], metadata: { + organisation: 'Lambeth', + id: '81bcaa0f-baf5-4573-ba0a-ea868c573faf', + source: 'PlanX', 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', - }, + 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 36494082..8afe6820 100644 --- a/examples/data/priorApproval.ts +++ b/examples/data/priorApproval.ts @@ -1028,20 +1028,15 @@ export const validPriorApproval: Schema = { }, ], metadata: { + organisation: 'Southwark', + id: 'b18c301b-9d44-4c6c-8d27-5b5bf33c570b', + source: 'PlanX', 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', - }, + 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 bc30b573..2053574c 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -1157,6 +1157,34 @@ }, "type": "object" }, + "BaseMetadata": { + "$id": "#BaseMetadata", + "additionalProperties": false, + "description": "Minimum metadata expected for any application", + "properties": { + "id": { + "$ref": "#/definitions/UUID", + "description": "Unique identifier for this application" + }, + "organisation": { + "description": "UK Local Authority that this application is being submitted to", + "type": "string" + }, + "schema": { + "$ref": "#/definitions/URL" + }, + "submittedAt": { + "$ref": "#/definitions/DateTime" + } + }, + "required": [ + "organisation", + "id", + "submittedAt", + "schema" + ], + "type": "object" + }, "Date": { "format": "date", "type": "string" @@ -2837,78 +2865,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, @@ -3123,6 +3089,56 @@ ], "type": "object" }, + "PlanXMetadata": { + "$id": "#PlanXMetadata", + "additionalProperties": false, + "description": "Additional metadata associated with applications submitted via PlanX", + "properties": { + "id": { + "$ref": "#/definitions/UUID", + "description": "Unique identifier for this application" + }, + "organisation": { + "description": "UK Local Authority that this application is being submitted to", + "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", + "type": "string" + }, + "submittedAt": { + "$ref": "#/definitions/DateTime" + } + }, + "required": [ + "id", + "organisation", + "schema", + "service", + "source", + "submittedAt" + ], + "type": "object" + }, "PlanningConstraint": { "$id": "#PlanningConstraint", "anyOf": [ diff --git a/types/schema/Metadata.ts b/types/schema/Metadata.ts index 47b1813a..c0dbfa13 100644 --- a/types/schema/Metadata.ts +++ b/types/schema/Metadata.ts @@ -1,26 +1,36 @@ 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 { + /** + * @description UK Local Authority that this application is being submitted to + */ + 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 + submittedAt: DateTime; + schema: URL; +} + +/** + * @id #PlanXMetadata + * @description Additional metadata associated with applications submitted via PlanX + */ +export interface PlanXMetadata extends BaseMetadata { + source: 'PlanX'; 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; }; }