@pdtf/schemas 0.5.15 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -2,7 +2,7 @@ const { dereference } = require("@jdw/jst");
2
2
  const Ajv = require("ajv");
3
3
  const addFormats = require("ajv-formats");
4
4
 
5
- const propertyPack = require("./src/schemas/property-pack.json");
5
+ const pdtfTransaction = require("./src/schemas/pdtf-transaction.json");
6
6
  const baspiMaterialFacts = require("./src/schemas/baspi-a-material-facts.json");
7
7
  const baspiLegalInformation = require("./src/schemas/baspi-b-legal-information.json");
8
8
  const energyPerformanceCertificate = require("./src/schemas/energy-performance-certificate.json");
@@ -21,7 +21,7 @@ const subSchemas = {
21
21
  "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json": titleDeed,
22
22
  };
23
23
 
24
- const propertyPackSchema = dereference(propertyPack, (id) => subSchemas[id]);
24
+ const transactionSchema = dereference(pdtfTransaction, (id) => subSchemas[id]);
25
25
 
26
26
  const ajv = new Ajv({
27
27
  allErrors: true,
@@ -31,17 +31,17 @@ const ajv = new Ajv({
31
31
  // Adds date formats among other types to the validator.
32
32
  addFormats(ajv);
33
33
 
34
- const validator = ajv.compile(propertyPackSchema);
34
+ const validator = ajv.compile(transactionSchema);
35
35
 
36
36
  const getSubschema = (path) => {
37
37
  const pathArray = path.split("/").slice(1);
38
38
  if (pathArray.length < 1) {
39
- return propertyPackSchema;
39
+ return transactionSchema;
40
40
  }
41
41
  return pathArray.reduce((schema, pathElement) => {
42
42
  if (schema.type === "array") return schema.items;
43
43
  return schema.properties[pathElement];
44
- }, propertyPackSchema);
44
+ }, transactionSchema);
45
45
  };
46
46
 
47
47
  const getSubschemaValidator = (path) => {
@@ -100,7 +100,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
100
100
  };
101
101
 
102
102
  module.exports = {
103
- propertyPackSchema,
103
+ transactionSchema,
104
104
  validator,
105
105
  getSubschema,
106
106
  getSubschemaValidator,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "0.5.15",
3
+ "version": "0.6.0",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -31,7 +31,7 @@
31
31
  ]
32
32
  },
33
33
  "claims": {
34
- "/propertyPack/materialFacts/propertyToBeSold/councilTax": {
34
+ "/propertyPack/materialFacts/councilTax": {
35
35
  "councilTaxBand": "D",
36
36
  "councilTaxAffectingAlterations": {
37
37
  "yesNo": "Yes",
@@ -5,9 +5,13 @@
5
5
  "evidence": [
6
6
  {
7
7
  "type": "electronic_record",
8
+ "verifier": {
9
+ "organization": "Property Pack Assembly Software Ltd"
10
+ },
8
11
  "record": {
9
12
  "source": {
10
- "name": "Royal Mail Postcode Address File record via ideal-postcodes.co.uk"
13
+ "name": "Royal Mail Postcode Address File",
14
+ "rights": "(c) Royal Mail"
11
15
  },
12
16
  "type": "postcode_address_file"
13
17
  }
@@ -1,19 +1,19 @@
1
1
  {
2
- "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/property-pack.json",
3
- "uprn": 100000059583,
2
+ "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-transaction.json",
3
+ "transactionId": "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a",
4
+ "participants": [
5
+ {
6
+ "name": { "firstName": "Peter", "lastName": "Hetherington-Smythe" },
7
+ "dateOfBirth": "1975-12-25",
8
+ "phone": "07777 222333",
9
+ "email": "john@theseller.com",
10
+ "address": { "address1": "47 Park Road", "postcode": "AL3 5AF" },
11
+ "role": "Seller"
12
+ }
13
+ ],
4
14
  "propertyPack": {
5
- "sellers": {
6
- "sellerInformation": [
7
- {
8
- "name": { "firstName": "Peter", "lastName": "Hetherington-Smythe" },
9
- "dateOfBirth": "1975-12-25",
10
- "mobileNumber": "07777 222333",
11
- "email": "john@theseller.com",
12
- "address": { "address1": "47 Park Road", "postcode": "AL3 5AF" }
13
- }
14
- ]
15
- },
16
15
  "materialFacts": {
16
+ "uprn": 1241304304,
17
17
  "address": {
18
18
  "address1": "47 Park Road",
19
19
  "address2": "",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "claims": {
21
- "/propertyPack/materialFacts/propertyToBeSold/delayFactors/hasDelayFactors": {
21
+ "/propertyPack/materialFacts/delayFactors/hasDelayFactors": {
22
22
  "yesNo": "No"
23
23
  }
24
24
  }
@@ -6,6 +6,7 @@
6
6
  "description": "BASPI v2.0 Part A - Disclosure of material facts at the point of marketing, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
7
7
  "baspiRef": "A",
8
8
  "required": [
9
+ "uprn",
9
10
  "address",
10
11
  "delayFactors",
11
12
  "ownership",
@@ -31,6 +32,11 @@
31
32
  "consumerProtectionRegulationsDeclaration"
32
33
  ],
33
34
  "properties": {
35
+ "uprn": {
36
+ "RDSRef": "Property/GUID/{name='UPRN',id=?}",
37
+ "title": "Unique Property Reference Number ",
38
+ "type": "integer"
39
+ },
34
40
  "address": {
35
41
  "baspiRef": "A1.1",
36
42
  "RDSRef": "Property/Address/xal:AddressDetails",
@@ -0,0 +1,167 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-transaction.json",
4
+ "type": "object",
5
+ "title": "Property Data Trust Framework Transaction Schema",
6
+ "description": "A schema defining the PDTF transaction data structure, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
7
+ "required": ["transactionId", "participants", "propertyPack"],
8
+ "properties": {
9
+ "transactionId": {
10
+ "title": "UUID for the transaction",
11
+ "type": "string",
12
+ "format": "uuid"
13
+ },
14
+ "participants": {
15
+ "title": "Transaction participants",
16
+ "type": "array",
17
+ "minItems": 1,
18
+ "items": {
19
+ "type": "object",
20
+ "title": "Participant Details",
21
+ "required": [
22
+ "name",
23
+ "dateOfBirth",
24
+ "phone",
25
+ "email",
26
+ "address",
27
+ "role"
28
+ ],
29
+ "properties": {
30
+ "name": {
31
+ "title": "",
32
+ "type": "object",
33
+ "required": ["firstName", "lastName"],
34
+ "properties": {
35
+ "firstName": {
36
+ "RDSRef": "",
37
+ "title": "First name",
38
+ "type": "string"
39
+ },
40
+ "middleNames": {
41
+ "title": "Middle name(s)",
42
+ "type": "string"
43
+ },
44
+ "lastName": {
45
+ "title": "Last name",
46
+ "type": "string"
47
+ }
48
+ }
49
+ },
50
+ "dateOfBirth": {
51
+ "title": "Date of birth",
52
+ "type": "string",
53
+ "format": "date"
54
+ },
55
+ "phone": {
56
+ "title": "Phone number",
57
+ "type": "string"
58
+ },
59
+ "email": {
60
+ "title": "Email address",
61
+ "type": "string",
62
+ "format": "email"
63
+ },
64
+ "address": {
65
+ "title": "Address",
66
+ "$ref": "#/$defs/address"
67
+ },
68
+ "organisation": {
69
+ "title": "Organisation",
70
+ "type": "string"
71
+ },
72
+ "organisationReference": {
73
+ "title": "Reference",
74
+ "type": "string"
75
+ },
76
+ "role": {
77
+ "title": "Role",
78
+ "type": "string",
79
+ "enum": [
80
+ "Seller",
81
+ "Seller's Conveyancer",
82
+ "Buyer",
83
+ "Buyer's Conveyancer",
84
+ "Estate Agent"
85
+ ]
86
+ }
87
+ }
88
+ }
89
+ },
90
+ "propertyPack": {
91
+ "title": "Property Pack",
92
+ "type": "object",
93
+ "properties": {
94
+ "materialFacts": {
95
+ "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json"
96
+ },
97
+ "additionalLegalInfo": {
98
+ "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json"
99
+ },
100
+ "titlesToBeSold": {
101
+ "RDSRef": "",
102
+ "title": "Title(s) as registered with HMLR which are included in the sale",
103
+ "type": "array",
104
+ "items": {
105
+ "type": "object",
106
+ "title": "Registered Title",
107
+ "properties": {
108
+ "titleNumber": {
109
+ "RDSRef": "",
110
+ "title": "Title Number",
111
+ "type": "string"
112
+ },
113
+ "titleExtents": {
114
+ "RDSRef": "",
115
+ "title": "Title Extents",
116
+ "description": "One or more index polygons describing indicative location of registered title from National Polygon Dataset",
117
+ "type": "array",
118
+ "items": {
119
+ "$ref": "https://geojson.org/schema/GeoJSON.json"
120
+ }
121
+ },
122
+ "registerExtract": {
123
+ "title": "HMLR Register Extract",
124
+ "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json"
125
+ }
126
+ }
127
+ }
128
+ },
129
+ "energyPerformanceCertificate": {
130
+ "RDSRef": "",
131
+ "title": "Energy Performance Certificate",
132
+ "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json"
133
+ }
134
+ }
135
+ }
136
+ },
137
+ "$defs": {
138
+ "address": {
139
+ "type": "object",
140
+ "properties": {
141
+ "address1": {
142
+ "title": "Address 1",
143
+ "type": "string",
144
+ "minLength": 1
145
+ },
146
+ "address2": {
147
+ "title": "Address 2",
148
+ "type": "string"
149
+ },
150
+ "town": {
151
+ "title": "Town",
152
+ "type": "string"
153
+ },
154
+ "county": {
155
+ "title": "County",
156
+ "type": "string"
157
+ },
158
+ "postcode": {
159
+ "title": "Postcode",
160
+ "type": "string",
161
+ "minLength": 1
162
+ }
163
+ },
164
+ "required": ["address1", "postcode"]
165
+ }
166
+ }
167
+ }
@@ -134,8 +134,7 @@
134
134
  "$ref": "#/definitions/document_details"
135
135
  }
136
136
  }
137
- },
138
- "else": {}
137
+ }
139
138
  },
140
139
  {
141
140
  "if": {
@@ -155,6 +154,7 @@
155
154
  },
156
155
  "verifier": {
157
156
  "type": "object",
157
+ "required": ["organization"],
158
158
  "properties": {
159
159
  "organization": {
160
160
  "type": "string"
@@ -169,6 +169,7 @@
169
169
  },
170
170
  "record": {
171
171
  "type": "object",
172
+ "required": ["source"],
172
173
  "properties": {
173
174
  "type": {
174
175
  "type": "string"
@@ -184,6 +185,7 @@
184
185
  },
185
186
  "source": {
186
187
  "type": "object",
188
+ "required": ["name"],
187
189
  "properties": {
188
190
  "name": {
189
191
  "type": "string"
@@ -211,14 +213,14 @@
211
213
  },
212
214
  "jurisdiction": {
213
215
  "type": "string"
214
- }
216
+ },
217
+ "rights": { "type": "string" }
215
218
  }
216
219
  }
217
220
  }
218
221
  }
219
222
  }
220
- },
221
- "else": {}
223
+ }
222
224
  },
223
225
  {
224
226
  "if": {
@@ -307,8 +309,7 @@
307
309
  }
308
310
  }
309
311
  }
310
- },
311
- "else": {}
312
+ }
312
313
  }
313
314
  ]
314
315
  },
@@ -1,40 +1,40 @@
1
1
  const jp = require("jsonpointer");
2
2
 
3
3
  const {
4
- propertyPackSchema,
4
+ transactionSchema,
5
5
  validator,
6
6
  getSubschema,
7
7
  getSubschemaValidator,
8
8
  getTitleAtPath,
9
9
  } = require("../../index.js");
10
- const examplePropertyPack = require("../examples/examplePropertyPack.json");
10
+ const exampleTransaction = require("../examples/exampleTransaction.json");
11
11
 
12
12
  test("exports a property pack schema", () => {
13
- expect(propertyPackSchema).not.toBeNull();
13
+ expect(transactionSchema).not.toBeNull();
14
14
  });
15
15
 
16
16
  test("sample is valid", () => {
17
- const isValid = validator(examplePropertyPack);
17
+ const isValid = validator(exampleTransaction);
18
18
  if (!isValid) console.log(validator.errors);
19
19
  expect(isValid).toBe(true);
20
20
  });
21
21
 
22
22
  test("invalid sample is invalid", () => {
23
- const clonedExamplePropertyPack = JSON.parse(
24
- JSON.stringify(examplePropertyPack)
23
+ const clonedExampleTransaction = JSON.parse(
24
+ JSON.stringify(exampleTransaction)
25
25
  );
26
- delete clonedExamplePropertyPack.propertyPack.materialFacts.notices;
27
- const isValid = validator(clonedExamplePropertyPack);
26
+ delete clonedExampleTransaction.propertyPack.materialFacts.notices;
27
+ const isValid = validator(clonedExampleTransaction);
28
28
  expect(isValid).toBe(false);
29
29
  });
30
30
 
31
31
  test("sample with missing dependent required fields is invalid", () => {
32
- const clonedExamplePropertyPack = JSON.parse(
33
- JSON.stringify(examplePropertyPack)
32
+ const clonedExampleTransaction = JSON.parse(
33
+ JSON.stringify(exampleTransaction)
34
34
  );
35
- clonedExamplePropertyPack.propertyPack.materialFacts.ownership.ownershipType =
35
+ clonedExampleTransaction.propertyPack.materialFacts.ownership.ownershipType =
36
36
  "leashold";
37
- const isValid = validator(clonedExamplePropertyPack);
37
+ const isValid = validator(clonedExampleTransaction);
38
38
  expect(isValid).toBe(false);
39
39
  });
40
40
 
@@ -56,9 +56,7 @@ test("correctly gets a subschema through an arrays element", () => {
56
56
  });
57
57
 
58
58
  test("correctly gets another subschema through an arrays element", () => {
59
- const subschema = getSubschema(
60
- "/propertyPack/sellers/sellerInformation/0/name/firstName"
61
- );
59
+ const subschema = getSubschema("/participants/0/name/firstName");
62
60
  expect(subschema.title).toBe("First name");
63
61
  });
64
62
 
@@ -76,7 +74,7 @@ test("correctly gets a subschema validator which is already cached", () => {
76
74
  test("correctly gets a subschema validator which validates", () => {
77
75
  const path = "/propertyPack/materialFacts/notices";
78
76
  const validator = getSubschemaValidator(path);
79
- const data = jp.get(examplePropertyPack, path);
77
+ const data = jp.get(exampleTransaction, path);
80
78
  expect(data.neighbourDevelopment.yesNo).toBe("No");
81
79
  let isValid = validator(data);
82
80
  expect(isValid).toBe(true);
@@ -88,51 +86,48 @@ test("correctly gets a subschema validator which validates", () => {
88
86
  test("correctly gets titles across schemas, arrays and non-existient title properties", () => {
89
87
  expect(
90
88
  getTitleAtPath(
91
- propertyPackSchema,
89
+ transactionSchema,
92
90
  "/propertyPack/materialFacts/ownership/ownershipType"
93
91
  )
94
92
  ).toBe("What type of ownership is the property?");
95
93
  expect(
96
94
  getTitleAtPath(
97
- propertyPackSchema,
95
+ transactionSchema,
98
96
  "/propertyPack/materialFacts/ownership/leaseholdDetails/lengthOfLeaseInYears"
99
97
  )
100
98
  ).toBe("Length of lease (years)");
101
99
  expect(
102
100
  getTitleAtPath(
103
- propertyPackSchema,
101
+ transactionSchema,
104
102
  "/propertyPack/materialFacts/ownership/managedFreeholdOrCommonhold/annualServiceCharge"
105
103
  )
106
104
  ).toBe(
107
105
  "Amount of current annual service charge/estate rentcharge/maintenance contribution (£)"
108
106
  );
109
107
  expect(
110
- getTitleAtPath(
111
- propertyPackSchema,
112
- "/propertyPack/materialFacts/invalidPath"
113
- )
108
+ getTitleAtPath(transactionSchema, "/propertyPack/materialFacts/invalidPath")
114
109
  ).toBe(undefined);
115
110
  expect(
116
111
  getTitleAtPath(
117
- propertyPackSchema,
112
+ transactionSchema,
118
113
  "/propertyPack/titlesToBeSold/0/registerExtract"
119
114
  )
120
115
  ).toBe("HMLR Official Copy Register Extract");
121
116
  expect(
122
117
  getTitleAtPath(
123
- propertyPackSchema,
118
+ transactionSchema,
124
119
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
125
120
  )
126
121
  ).toBe("Property address");
127
122
  expect(
128
123
  getTitleAtPath(
129
- propertyPackSchema,
124
+ transactionSchema,
130
125
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
131
126
  )
132
127
  ).toBe(undefined);
133
128
  expect(
134
129
  getTitleAtPath(
135
- propertyPackSchema,
130
+ transactionSchema,
136
131
  "/propertyPack/energyPerformanceCertificate/certificate/currentEnergyRating"
137
132
  )
138
133
  ).toBe("Current energy rating");
@@ -1,159 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/property-pack.json",
4
- "type": "object",
5
- "title": "Property Data Trust Framework Schema",
6
- "description": "A schema defining the PDTF Property Pack data structure, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
7
- "required": ["$schema", "uprn", "propertyPack"],
8
- "properties": {
9
- "$schema": {
10
- "title": "The version reference ($id) of the PDTF Schema used",
11
- "type": "string"
12
- },
13
- "uprn": {
14
- "RDSRef": "Property/GUID/{name='UPRN',id=?}",
15
- "title": "Unique Property Reference Number ",
16
- "type": "integer"
17
- },
18
- "propertyPack": {
19
- "title": "Property Pack",
20
- "type": "object",
21
- "properties": {
22
- "sellers": {
23
- "RDSRef": "",
24
- "title": "Information about the sellers",
25
- "type": "object",
26
- "required": ["sellerInformation"],
27
- "properties": {
28
- "sellerInformation": {
29
- "title": "",
30
- "type": "array",
31
- "minItems": 1,
32
- "items": {
33
- "type": "object",
34
- "title": "Seller Details",
35
- "required": [
36
- "name",
37
- "dateOfBirth",
38
- "mobileNumber",
39
- "email",
40
- "address"
41
- ],
42
- "properties": {
43
- "name": {
44
- "title": "",
45
- "type": "object",
46
- "required": ["firstName", "lastName"],
47
- "properties": {
48
- "firstName": {
49
- "RDSRef": "",
50
- "title": "First name",
51
- "type": "string"
52
- },
53
- "middleNames": {
54
- "title": "Middle name(s)",
55
- "type": "string"
56
- },
57
- "lastName": {
58
- "title": "Last name",
59
- "type": "string"
60
- }
61
- }
62
- },
63
- "dateOfBirth": {
64
- "title": "Date of birth",
65
- "type": "string",
66
- "format": "date"
67
- },
68
- "mobileNumber": {
69
- "title": "Mobile number",
70
- "type": "string"
71
- },
72
- "email": {
73
- "title": "Email address",
74
- "type": "string",
75
- "format": "email"
76
- },
77
- "address": {
78
- "title": "Address",
79
- "$ref": "#/$defs/address"
80
- }
81
- }
82
- }
83
- }
84
- }
85
- },
86
- "materialFacts": {
87
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json"
88
- },
89
- "additionalLegalInfo": {
90
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json"
91
- },
92
- "titlesToBeSold": {
93
- "RDSRef": "",
94
- "title": "Title(s) as registered with HMLR which are included in the sale",
95
- "type": "array",
96
- "items": {
97
- "type": "object",
98
- "title": "Registered Title",
99
- "properties": {
100
- "titleNumber": {
101
- "RDSRef": "",
102
- "title": "Title Number",
103
- "type": "string"
104
- },
105
- "titleExtents": {
106
- "RDSRef": "",
107
- "title": "Title Extents",
108
- "description": "One or more index polygons describing indicative location of registered title from National Polygon Dataset",
109
- "type": "array",
110
- "items": {
111
- "$ref": "https://geojson.org/schema/GeoJSON.json"
112
- }
113
- },
114
- "registerExtract": {
115
- "title": "HMLR Register Extract",
116
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json"
117
- }
118
- }
119
- }
120
- },
121
- "energyPerformanceCertificate": {
122
- "RDSRef": "",
123
- "title": "Energy Performance Certificate",
124
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json"
125
- }
126
- }
127
- }
128
- },
129
- "$defs": {
130
- "address": {
131
- "type": "object",
132
- "properties": {
133
- "address1": {
134
- "title": "Address 1",
135
- "type": "string",
136
- "minLength": 1
137
- },
138
- "address2": {
139
- "title": "Address 2",
140
- "type": "string"
141
- },
142
- "town": {
143
- "title": "Town",
144
- "type": "string"
145
- },
146
- "county": {
147
- "title": "County",
148
- "type": "string"
149
- },
150
- "postcode": {
151
- "title": "Postcode",
152
- "type": "string",
153
- "minLength": 1
154
- }
155
- },
156
- "required": ["address1", "postcode"]
157
- }
158
- }
159
- }