Skip to content

Commit

Permalink
fix: simplify Metadata type (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Nov 8, 2023
1 parent 05fe2df commit f5b402f
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 131 deletions.
17 changes: 6 additions & 11 deletions examples/data/ldcE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
17 changes: 6 additions & 11 deletions examples/data/ldcP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
17 changes: 6 additions & 11 deletions examples/data/planningPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
17 changes: 6 additions & 11 deletions examples/data/priorApproval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
154 changes: 85 additions & 69 deletions schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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": [
Expand Down
46 changes: 28 additions & 18 deletions types/schema/Metadata.ts
Original file line number Diff line number Diff line change
@@ -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;
};
}

0 comments on commit f5b402f

Please sign in to comment.