@pdtf/schemas 0.6.0 → 0.6.2
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
|
@@ -44,6 +44,13 @@ const getSubschema = (path) => {
|
|
|
44
44
|
}, transactionSchema);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
const isPathValid = (path) => {
|
|
48
|
+
try {
|
|
49
|
+
return getSubschema(path) !== undefined;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
47
54
|
const getSubschemaValidator = (path) => {
|
|
48
55
|
const subSchema = getSubschema(path);
|
|
49
56
|
let validator = ajv.getSchema(path);
|
|
@@ -103,6 +110,7 @@ module.exports = {
|
|
|
103
110
|
transactionSchema,
|
|
104
111
|
validator,
|
|
105
112
|
getSubschema,
|
|
113
|
+
isPathValid,
|
|
106
114
|
getSubschemaValidator,
|
|
107
115
|
getTitleAtPath,
|
|
108
116
|
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
|
+
"forenames": "Peter Ronald",
|
|
9
|
+
"surname": "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
|
}
|
|
@@ -4,13 +4,26 @@
|
|
|
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,23 @@
|
|
|
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
37
|
"title": "",
|
|
32
38
|
"type": "object",
|
|
33
|
-
"required": ["
|
|
39
|
+
"required": ["forenames", "surname"],
|
|
34
40
|
"properties": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"title": "First name",
|
|
41
|
+
"forenames": {
|
|
42
|
+
"title": "Forenames",
|
|
38
43
|
"type": "string"
|
|
39
44
|
},
|
|
40
|
-
"
|
|
41
|
-
"title": "
|
|
45
|
+
"preferredName": {
|
|
46
|
+
"title": "Preferred name / known as",
|
|
42
47
|
"type": "string"
|
|
43
48
|
},
|
|
44
|
-
"
|
|
45
|
-
"title": "
|
|
49
|
+
"surname": {
|
|
50
|
+
"title": "Surname",
|
|
46
51
|
"type": "string"
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -79,6 +84,7 @@
|
|
|
79
84
|
"enum": [
|
|
80
85
|
"Seller",
|
|
81
86
|
"Seller's Conveyancer",
|
|
87
|
+
"Prospective Buyer",
|
|
82
88
|
"Buyer",
|
|
83
89
|
"Buyer's Conveyancer",
|
|
84
90
|
"Estate Agent"
|
|
@@ -130,6 +136,97 @@
|
|
|
130
136
|
"RDSRef": "",
|
|
131
137
|
"title": "Energy Performance Certificate",
|
|
132
138
|
"$ref": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json"
|
|
139
|
+
},
|
|
140
|
+
"risks": {
|
|
141
|
+
"RDSRef": "",
|
|
142
|
+
"title": "Risks",
|
|
143
|
+
"type": "object",
|
|
144
|
+
"properties": {
|
|
145
|
+
"coalMining": {
|
|
146
|
+
"title": "Coal mining",
|
|
147
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
148
|
+
},
|
|
149
|
+
"flood": {
|
|
150
|
+
"title": "Flood",
|
|
151
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
152
|
+
},
|
|
153
|
+
"miningAndGroundStability": {
|
|
154
|
+
"title": "Mining and ground stability",
|
|
155
|
+
"type": "object",
|
|
156
|
+
"properties": {
|
|
157
|
+
"bathStone": {
|
|
158
|
+
"title": "Bath Stone",
|
|
159
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
160
|
+
},
|
|
161
|
+
"metalliferousTin": {
|
|
162
|
+
"title": "Matalliferous (Tin)",
|
|
163
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
164
|
+
},
|
|
165
|
+
"kaolinAndBallClay": {
|
|
166
|
+
"title": "Kaolin and ball clay",
|
|
167
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
168
|
+
},
|
|
169
|
+
"limestone": {
|
|
170
|
+
"title": "Limestone",
|
|
171
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
172
|
+
},
|
|
173
|
+
"brine": {
|
|
174
|
+
"title": "Brine",
|
|
175
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
176
|
+
},
|
|
177
|
+
"groundStability": {
|
|
178
|
+
"title": "Ground stability",
|
|
179
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
180
|
+
},
|
|
181
|
+
"nonCoalMining": {
|
|
182
|
+
"title": "Non coal mining",
|
|
183
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
184
|
+
},
|
|
185
|
+
"groundMovement": {
|
|
186
|
+
"title": "Ground movement",
|
|
187
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
188
|
+
},
|
|
189
|
+
"mineral": {
|
|
190
|
+
"title": "Mineral",
|
|
191
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"energyAndInfrastructure": {
|
|
196
|
+
"title": "Energy and infrastructure",
|
|
197
|
+
"type": "object",
|
|
198
|
+
"properties": {
|
|
199
|
+
"hs2": {
|
|
200
|
+
"title": "HS2",
|
|
201
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
202
|
+
},
|
|
203
|
+
"crossrail": {
|
|
204
|
+
"title": "Crossrail",
|
|
205
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
206
|
+
},
|
|
207
|
+
"londonUnderground": {
|
|
208
|
+
"title": "London Underground",
|
|
209
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
210
|
+
},
|
|
211
|
+
"energyExploration": {
|
|
212
|
+
"title": "Energy exploration",
|
|
213
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
214
|
+
},
|
|
215
|
+
"windFarms": {
|
|
216
|
+
"title": "Wind farms",
|
|
217
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
218
|
+
},
|
|
219
|
+
"solarFarms": {
|
|
220
|
+
"title": "Solar farms",
|
|
221
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
222
|
+
},
|
|
223
|
+
"renewablePowerPlants": {
|
|
224
|
+
"title": "Renewable power plants",
|
|
225
|
+
"$ref": "#/$defs/riskIndicatorAndSearch"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
133
230
|
}
|
|
134
231
|
}
|
|
135
232
|
}
|
|
@@ -162,6 +259,17 @@
|
|
|
162
259
|
}
|
|
163
260
|
},
|
|
164
261
|
"required": ["address1", "postcode"]
|
|
262
|
+
},
|
|
263
|
+
"riskIndicatorAndSearch": {
|
|
264
|
+
"type": "object",
|
|
265
|
+
"properties": {
|
|
266
|
+
"hasRisk": {
|
|
267
|
+
"title": "",
|
|
268
|
+
"type": "string",
|
|
269
|
+
"enum": ["Yes", "No"]
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"required": ["address1", "postcode"]
|
|
165
273
|
}
|
|
166
274
|
}
|
|
167
275
|
}
|
|
@@ -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");
|
|
@@ -56,8 +77,8 @@ test("correctly gets a subschema through an arrays element", () => {
|
|
|
56
77
|
});
|
|
57
78
|
|
|
58
79
|
test("correctly gets another subschema through an arrays element", () => {
|
|
59
|
-
const subschema = getSubschema("/participants/0/name/
|
|
60
|
-
expect(subschema.title).toBe("
|
|
80
|
+
const subschema = getSubschema("/participants/0/name/forenames");
|
|
81
|
+
expect(subschema.title).toBe("Forenames");
|
|
61
82
|
});
|
|
62
83
|
|
|
63
84
|
test("correctly gets a subschema validator which is already cached", () => {
|