@pdtf/schemas 0.6.2 → 0.6.5

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/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-minimal
package/index.js CHANGED
@@ -11,14 +11,15 @@ const geoJson = require("./src/schemas/GeoJSON.json");
11
11
  const verifiedClaimsSchema = require("./src/schemas/pdtf-verified-claims.json");
12
12
 
13
13
  const subSchemas = {
14
- "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json":
14
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json":
15
15
  baspiMaterialFacts,
16
- "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json":
16
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json":
17
17
  baspiLegalInformation,
18
- "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json":
18
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json":
19
19
  energyPerformanceCertificate,
20
20
  "https://geojson.org/schema/GeoJSON.json": geoJson,
21
- "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json": titleDeed,
21
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json":
22
+ titleDeed,
22
23
  };
23
24
 
24
25
  const transactionSchema = dereference(pdtfTransaction, (id) => subSchemas[id]);
@@ -51,6 +52,7 @@ const isPathValid = (path) => {
51
52
  return false;
52
53
  }
53
54
  };
55
+
54
56
  const getSubschemaValidator = (path) => {
55
57
  const subSchema = getSubschema(path);
56
58
  let validator = ajv.getSchema(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "0.6.2",
3
+ "version": "0.6.5",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "claims": {
22
22
  "/propertyPack/materialFacts/address": {
23
- "address1": "3 The Hollys",
24
- "address2": "Birtley",
23
+ "line1": "3 The Hollys",
24
+ "line2": "Birtley",
25
25
  "town": "CHESTER LE STREET",
26
26
  "county": "County Durham",
27
27
  "postcode": "DH3 1QN"
@@ -1,17 +1,17 @@
1
1
  {
2
- "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-transaction.json",
2
+ "$schema": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/pdtf-transaction.json",
3
3
  "transactionId": "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a",
4
4
  "status": "active",
5
5
  "participants": [
6
6
  {
7
7
  "name": {
8
- "forenames": "Peter Ronald",
9
- "surname": "Hetherington-Smythe"
8
+ "firstName": "Peter",
9
+ "lastName": "Hetherington-Smythe"
10
10
  },
11
11
  "dateOfBirth": "1975-12-25",
12
12
  "phone": "07777 222333",
13
13
  "email": "peter@theseller.com",
14
- "address": { "address1": "47 Park Road", "postcode": "AL3 5AF" },
14
+ "address": { "line1": "47 Park Road", "postcode": "AL3 5AF" },
15
15
  "role": "Seller"
16
16
  }
17
17
  ],
@@ -19,8 +19,8 @@
19
19
  "materialFacts": {
20
20
  "uprn": 1241304304,
21
21
  "address": {
22
- "address1": "47 Park Road",
23
- "address2": "",
22
+ "line1": "47 Park Road",
23
+ "line2": "",
24
24
  "town": "HARPENDEN",
25
25
  "county": "Herts",
26
26
  "postcode": "AL3 5AF"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json",
4
4
  "type": "object",
5
5
  "title": "Material facts at the point of marketing",
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.",
@@ -1625,12 +1625,12 @@
1625
1625
  "address": {
1626
1626
  "type": "object",
1627
1627
  "properties": {
1628
- "address1": {
1628
+ "line1": {
1629
1629
  "title": "Address 1",
1630
1630
  "type": "string",
1631
1631
  "minLength": 1
1632
1632
  },
1633
- "address2": {
1633
+ "line2": {
1634
1634
  "title": "Address 2",
1635
1635
  "type": "string"
1636
1636
  },
@@ -1648,7 +1648,7 @@
1648
1648
  "minLength": 1
1649
1649
  }
1650
1650
  },
1651
- "required": ["address1", "postcode"]
1651
+ "required": ["line1", "postcode"]
1652
1652
  },
1653
1653
  "contactDetails": {
1654
1654
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json",
4
4
  "type": "object",
5
5
  "title": "Additional information required for the legal process",
6
6
  "description": "A schema defining Part B of BASPI v2.0 spporting mapping to BASPI, Law Society and RICS Data Schema elements.",
@@ -917,11 +917,11 @@
917
917
  "address": {
918
918
  "type": "object",
919
919
  "properties": {
920
- "address1": {
920
+ "line1": {
921
921
  "title": "Address 1",
922
922
  "type": "string"
923
923
  },
924
- "address2": {
924
+ "line2": {
925
925
  "title": "Address 2",
926
926
  "type": "string"
927
927
  },
@@ -938,7 +938,7 @@
938
938
  "type": "string"
939
939
  }
940
940
  },
941
- "required": ["address1", "postcode"]
941
+ "required": ["line1", "postcode"]
942
942
  }
943
943
  }
944
944
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json",
4
4
  "type": "object",
5
5
  "title": "Energy Performance Certificate and Recommendations Schema, supporting data retrieved from https://epc.opendatacommunities.org ",
6
6
  "description": "Mirrors the Domestic EPC Glossary at https://epc.opendatacommunities.org/docs/guidance#glossary",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-transaction.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/pdtf-transaction.json",
4
4
  "type": "object",
5
5
  "title": "Property Data Trust Framework Transaction Schema",
6
6
  "description": "A schema defining the PDTF transaction data structure, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
@@ -34,20 +34,24 @@
34
34
  "required": ["name", "email", "role"],
35
35
  "properties": {
36
36
  "name": {
37
- "title": "",
37
+ "title": "Name",
38
38
  "type": "object",
39
- "required": ["forenames", "surname"],
39
+ "required": ["firstName", "lastName"],
40
40
  "properties": {
41
- "forenames": {
42
- "title": "Forenames",
41
+ "firstName": {
42
+ "title": "First name",
43
43
  "type": "string"
44
44
  },
45
- "preferredName": {
46
- "title": "Preferred name / known as",
45
+ "middleName": {
46
+ "title": "Middle name(s)",
47
+ "type": "string"
48
+ },
49
+ "lastName": {
50
+ "title": "lastName",
47
51
  "type": "string"
48
52
  },
49
- "surname": {
50
- "title": "Surname",
53
+ "preferredName": {
54
+ "title": "Preferred name / known as",
51
55
  "type": "string"
52
56
  }
53
57
  }
@@ -98,10 +102,10 @@
98
102
  "type": "object",
99
103
  "properties": {
100
104
  "materialFacts": {
101
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json"
105
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json"
102
106
  },
103
107
  "additionalLegalInfo": {
104
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json"
108
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json"
105
109
  },
106
110
  "titlesToBeSold": {
107
111
  "RDSRef": "",
@@ -127,7 +131,7 @@
127
131
  },
128
132
  "registerExtract": {
129
133
  "title": "HMLR Register Extract",
130
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json"
134
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json"
131
135
  }
132
136
  }
133
137
  }
@@ -135,7 +139,7 @@
135
139
  "energyPerformanceCertificate": {
136
140
  "RDSRef": "",
137
141
  "title": "Energy Performance Certificate",
138
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json"
142
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json"
139
143
  },
140
144
  "risks": {
141
145
  "RDSRef": "",
@@ -235,12 +239,12 @@
235
239
  "address": {
236
240
  "type": "object",
237
241
  "properties": {
238
- "address1": {
242
+ "line1": {
239
243
  "title": "Address 1",
240
244
  "type": "string",
241
245
  "minLength": 1
242
246
  },
243
- "address2": {
247
+ "line2": {
244
248
  "title": "Address 2",
245
249
  "type": "string"
246
250
  },
@@ -258,7 +262,7 @@
258
262
  "minLength": 1
259
263
  }
260
264
  },
261
- "required": ["address1", "postcode"]
265
+ "required": ["line1", "postcode"]
262
266
  },
263
267
  "riskIndicatorAndSearch": {
264
268
  "type": "object",
@@ -269,7 +273,7 @@
269
273
  "enum": ["Yes", "No"]
270
274
  }
271
275
  },
272
- "required": ["address1", "postcode"]
276
+ "required": ["hasRisk"]
273
277
  }
274
278
  }
275
279
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-verified-claims.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/pdtf-verified-claims.json",
4
4
  "definitions": {
5
5
  "date_type": {
6
6
  "type": "string",
@@ -387,7 +387,7 @@
387
387
  "claims": {
388
388
  "type": "object",
389
389
  "patternProperties": {
390
- "^(/|([a-zA-Z0-9/-]+)+$)": { "type": "object" }
390
+ "^(/|([a-zA-Z0-9/-]+)+$)": {}
391
391
  },
392
392
  "minProperties": 1,
393
393
  "additionalProperties": false
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json",
4
4
  "title": "HMLR Official Copy Register Extract",
5
5
  "description": "A schema mirroring the V2_1 XML version of the HMLR Register Extract web service.",
6
6
  "definitions": {
@@ -29,6 +29,20 @@ test("valid documented vouch sample is valid", () => {
29
29
  expect(isValid).toBe(true);
30
30
  });
31
31
 
32
+ test("sample with primitive claims value is valid", () => {
33
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
34
+ clonedVouch.claims = { "/propertyPack/uprn": 123456 };
35
+ const isValid = validator({ verified_claims: clonedVouch });
36
+ expect(isValid).toBe(true);
37
+ });
38
+
39
+ test("sample with undefined claims value is also valid, but this would fail when the payload is validated", () => {
40
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
41
+ clonedVouch.claims = { "/propertyPack/uprn": undefined };
42
+ const isValid = validator({ verified_claims: clonedVouch });
43
+ expect(isValid).toBe(true);
44
+ });
45
+
32
46
  test("claim with missing claims is invalid", () => {
33
47
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
34
48
  delete clonedVouch.claims;
@@ -77,8 +77,8 @@ test("correctly gets a subschema through an arrays element", () => {
77
77
  });
78
78
 
79
79
  test("correctly gets another subschema through an arrays element", () => {
80
- const subschema = getSubschema("/participants/0/name/forenames");
81
- expect(subschema.title).toBe("Forenames");
80
+ const subschema = getSubschema("/participants/0/name/firstName");
81
+ expect(subschema.title).toBe("First name");
82
82
  });
83
83
 
84
84
  test("correctly gets a subschema validator which is already cached", () => {