@pdtf/schemas 0.6.0 → 0.6.4
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 +1 -0
- package/index.js +14 -4
- package/package.json +1 -1
- package/src/examples/exampleTransaction.json +6 -2
- package/src/schemas/baspi-a-material-facts.json +1 -1
- package/src/schemas/baspi-b-legal-information.json +1 -1
- package/src/schemas/energy-performance-certificate.json +1 -1
- package/src/schemas/pdtf-transaction.json +130 -18
- package/src/schemas/pdtf-verified-claims.json +2 -2
- package/src/schemas/title-deed.json +1 -1
- package/src/tests/pdtfVerifiedClaims.test.js +14 -0
- package/src/tests/transactionSchema.test.js +21 -0
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://
|
|
14
|
+
"https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json":
|
|
15
15
|
baspiMaterialFacts,
|
|
16
|
-
"https://
|
|
16
|
+
"https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json":
|
|
17
17
|
baspiLegalInformation,
|
|
18
|
-
"https://
|
|
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://
|
|
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]);
|
|
@@ -44,6 +45,14 @@ const getSubschema = (path) => {
|
|
|
44
45
|
}, transactionSchema);
|
|
45
46
|
};
|
|
46
47
|
|
|
48
|
+
const isPathValid = (path) => {
|
|
49
|
+
try {
|
|
50
|
+
return getSubschema(path) !== undefined;
|
|
51
|
+
} catch (err) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
47
56
|
const getSubschemaValidator = (path) => {
|
|
48
57
|
const subSchema = getSubschema(path);
|
|
49
58
|
let validator = ajv.getSchema(path);
|
|
@@ -103,6 +112,7 @@ module.exports = {
|
|
|
103
112
|
transactionSchema,
|
|
104
113
|
validator,
|
|
105
114
|
getSubschema,
|
|
115
|
+
isPathValid,
|
|
106
116
|
getSubschemaValidator,
|
|
107
117
|
getTitleAtPath,
|
|
108
118
|
verifiedClaimsSchema,
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-transaction.json",
|
|
3
3
|
"transactionId": "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a",
|
|
4
|
+
"status": "active",
|
|
4
5
|
"participants": [
|
|
5
6
|
{
|
|
6
|
-
"name": {
|
|
7
|
+
"name": {
|
|
8
|
+
"firstName": "Peter",
|
|
9
|
+
"lastName": "Hetherington-Smythe"
|
|
10
|
+
},
|
|
7
11
|
"dateOfBirth": "1975-12-25",
|
|
8
12
|
"phone": "07777 222333",
|
|
9
|
-
"email": "
|
|
13
|
+
"email": "peter@theseller.com",
|
|
10
14
|
"address": { "address1": "47 Park Road", "postcode": "AL3 5AF" },
|
|
11
15
|
"role": "Seller"
|
|
12
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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,16 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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.",
|
|
7
|
-
"required": [
|
|
7
|
+
"required": [
|
|
8
|
+
"$schema",
|
|
9
|
+
"transactionId",
|
|
10
|
+
"status",
|
|
11
|
+
"participants",
|
|
12
|
+
"propertyPack"
|
|
13
|
+
],
|
|
8
14
|
"properties": {
|
|
15
|
+
"$schema": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
9
18
|
"transactionId": {
|
|
10
19
|
"title": "UUID for the transaction",
|
|
11
20
|
"type": "string",
|
|
12
21
|
"format": "uuid"
|
|
13
22
|
},
|
|
23
|
+
"status": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"enum": ["active", "cancelled", "completed"]
|
|
26
|
+
},
|
|
14
27
|
"participants": {
|
|
15
28
|
"title": "Transaction participants",
|
|
16
29
|
"type": "array",
|
|
@@ -18,31 +31,27 @@
|
|
|
18
31
|
"items": {
|
|
19
32
|
"type": "object",
|
|
20
33
|
"title": "Participant Details",
|
|
21
|
-
"required": [
|
|
22
|
-
"name",
|
|
23
|
-
"dateOfBirth",
|
|
24
|
-
"phone",
|
|
25
|
-
"email",
|
|
26
|
-
"address",
|
|
27
|
-
"role"
|
|
28
|
-
],
|
|
34
|
+
"required": ["name", "email", "role"],
|
|
29
35
|
"properties": {
|
|
30
36
|
"name": {
|
|
31
|
-
"title": "",
|
|
37
|
+
"title": "Name",
|
|
32
38
|
"type": "object",
|
|
33
39
|
"required": ["firstName", "lastName"],
|
|
34
40
|
"properties": {
|
|
35
41
|
"firstName": {
|
|
36
|
-
"RDSRef": "",
|
|
37
42
|
"title": "First name",
|
|
38
43
|
"type": "string"
|
|
39
44
|
},
|
|
40
|
-
"
|
|
45
|
+
"middleName": {
|
|
41
46
|
"title": "Middle name(s)",
|
|
42
47
|
"type": "string"
|
|
43
48
|
},
|
|
44
49
|
"lastName": {
|
|
45
|
-
"title": "
|
|
50
|
+
"title": "lastName",
|
|
51
|
+
"type": "string"
|
|
52
|
+
},
|
|
53
|
+
"preferredName": {
|
|
54
|
+
"title": "Preferred name / known as",
|
|
46
55
|
"type": "string"
|
|
47
56
|
}
|
|
48
57
|
}
|
|
@@ -79,6 +88,7 @@
|
|
|
79
88
|
"enum": [
|
|
80
89
|
"Seller",
|
|
81
90
|
"Seller's Conveyancer",
|
|
91
|
+
"Prospective Buyer",
|
|
82
92
|
"Buyer",
|
|
83
93
|
"Buyer's Conveyancer",
|
|
84
94
|
"Estate Agent"
|
|
@@ -92,10 +102,10 @@
|
|
|
92
102
|
"type": "object",
|
|
93
103
|
"properties": {
|
|
94
104
|
"materialFacts": {
|
|
95
|
-
"$ref": "https://
|
|
105
|
+
"$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json"
|
|
96
106
|
},
|
|
97
107
|
"additionalLegalInfo": {
|
|
98
|
-
"$ref": "https://
|
|
108
|
+
"$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json"
|
|
99
109
|
},
|
|
100
110
|
"titlesToBeSold": {
|
|
101
111
|
"RDSRef": "",
|
|
@@ -121,7 +131,7 @@
|
|
|
121
131
|
},
|
|
122
132
|
"registerExtract": {
|
|
123
133
|
"title": "HMLR Register Extract",
|
|
124
|
-
"$ref": "https://
|
|
134
|
+
"$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json"
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
137
|
}
|
|
@@ -129,7 +139,98 @@
|
|
|
129
139
|
"energyPerformanceCertificate": {
|
|
130
140
|
"RDSRef": "",
|
|
131
141
|
"title": "Energy Performance Certificate",
|
|
132
|
-
"$ref": "https://
|
|
142
|
+
"$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json"
|
|
143
|
+
},
|
|
144
|
+
"risks": {
|
|
145
|
+
"RDSRef": "",
|
|
146
|
+
"title": "Risks",
|
|
147
|
+
"type": "object",
|
|
148
|
+
"properties": {
|
|
149
|
+
"coalMining": {
|
|
150
|
+
"title": "Coal mining",
|
|
151
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
152
|
+
},
|
|
153
|
+
"flood": {
|
|
154
|
+
"title": "Flood",
|
|
155
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
156
|
+
},
|
|
157
|
+
"miningAndGroundStability": {
|
|
158
|
+
"title": "Mining and ground stability",
|
|
159
|
+
"type": "object",
|
|
160
|
+
"properties": {
|
|
161
|
+
"bathStone": {
|
|
162
|
+
"title": "Bath Stone",
|
|
163
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
164
|
+
},
|
|
165
|
+
"metalliferousTin": {
|
|
166
|
+
"title": "Matalliferous (Tin)",
|
|
167
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
168
|
+
},
|
|
169
|
+
"kaolinAndBallClay": {
|
|
170
|
+
"title": "Kaolin and ball clay",
|
|
171
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
172
|
+
},
|
|
173
|
+
"limestone": {
|
|
174
|
+
"title": "Limestone",
|
|
175
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
176
|
+
},
|
|
177
|
+
"brine": {
|
|
178
|
+
"title": "Brine",
|
|
179
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
180
|
+
},
|
|
181
|
+
"groundStability": {
|
|
182
|
+
"title": "Ground stability",
|
|
183
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
184
|
+
},
|
|
185
|
+
"nonCoalMining": {
|
|
186
|
+
"title": "Non coal mining",
|
|
187
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
188
|
+
},
|
|
189
|
+
"groundMovement": {
|
|
190
|
+
"title": "Ground movement",
|
|
191
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
192
|
+
},
|
|
193
|
+
"mineral": {
|
|
194
|
+
"title": "Mineral",
|
|
195
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"energyAndInfrastructure": {
|
|
200
|
+
"title": "Energy and infrastructure",
|
|
201
|
+
"type": "object",
|
|
202
|
+
"properties": {
|
|
203
|
+
"hs2": {
|
|
204
|
+
"title": "HS2",
|
|
205
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
206
|
+
},
|
|
207
|
+
"crossrail": {
|
|
208
|
+
"title": "Crossrail",
|
|
209
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
210
|
+
},
|
|
211
|
+
"londonUnderground": {
|
|
212
|
+
"title": "London Underground",
|
|
213
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
214
|
+
},
|
|
215
|
+
"energyExploration": {
|
|
216
|
+
"title": "Energy exploration",
|
|
217
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
218
|
+
},
|
|
219
|
+
"windFarms": {
|
|
220
|
+
"title": "Wind farms",
|
|
221
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
222
|
+
},
|
|
223
|
+
"solarFarms": {
|
|
224
|
+
"title": "Solar farms",
|
|
225
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
226
|
+
},
|
|
227
|
+
"renewablePowerPlants": {
|
|
228
|
+
"title": "Renewable power plants",
|
|
229
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
133
234
|
}
|
|
134
235
|
}
|
|
135
236
|
}
|
|
@@ -162,6 +263,17 @@
|
|
|
162
263
|
}
|
|
163
264
|
},
|
|
164
265
|
"required": ["address1", "postcode"]
|
|
266
|
+
},
|
|
267
|
+
"riskIndicatorAndSearch": {
|
|
268
|
+
"type": "object",
|
|
269
|
+
"properties": {
|
|
270
|
+
"hasRisk": {
|
|
271
|
+
"title": "",
|
|
272
|
+
"type": "string",
|
|
273
|
+
"enum": ["Yes", "No"]
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"required": ["address1", "postcode"]
|
|
165
277
|
}
|
|
166
278
|
}
|
|
167
279
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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/-]+)+$)": {
|
|
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://
|
|
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;
|
|
@@ -4,6 +4,7 @@ const {
|
|
|
4
4
|
transactionSchema,
|
|
5
5
|
validator,
|
|
6
6
|
getSubschema,
|
|
7
|
+
isPathValid,
|
|
7
8
|
getSubschemaValidator,
|
|
8
9
|
getTitleAtPath,
|
|
9
10
|
} = require("../../index.js");
|
|
@@ -43,6 +44,26 @@ test("correctly gets a top level subschema", () => {
|
|
|
43
44
|
expect(subschema.title).toBe("Property Pack");
|
|
44
45
|
});
|
|
45
46
|
|
|
47
|
+
test("correctly identifies a valid path", () => {
|
|
48
|
+
const isValid = isPathValid("/propertyPack/materialFacts");
|
|
49
|
+
expect(isValid).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("correctly identifies an undefined invalid path", () => {
|
|
53
|
+
const isValid = isPathValid("/propertyPack/materialItems");
|
|
54
|
+
expect(isValid).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("correctly identifies an error generating invalid path", () => {
|
|
58
|
+
const isValid = isPathValid("/propertyPack/materialItems/someProperty/item");
|
|
59
|
+
expect(isValid).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("correctly identifies an array invalid path", () => {
|
|
63
|
+
const isValid = isPathValid("/propertyPack/materialFacts/1/item");
|
|
64
|
+
expect(isValid).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
46
67
|
test("correctly gets a subschema", () => {
|
|
47
68
|
const subschema = getSubschema("/propertyPack/materialFacts/notices");
|
|
48
69
|
expect(subschema.title).toBe("Notices which Affect the Property");
|