@pdtf/schemas 2.0.0-1 → 2.0.0-10
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 +20 -17
- package/package.json +1 -1
- package/src/examples/v2/exampleTransaction.json +47 -39
- package/src/schemas/v2/combined.json +6748 -431
- package/src/schemas/v2/overlays/baspi.json +223 -144
- package/src/schemas/v2/overlays/con29R.json +1 -1
- package/src/schemas/v2/overlays/fme1.json +41 -32
- package/src/schemas/v2/overlays/lpe1.json +57 -64
- package/src/schemas/v2/overlays/nts.json +38 -42
- package/src/schemas/v2/overlays/rds.json +7 -16
- package/src/schemas/v2/overlays/ta10.json +844 -1
- package/src/schemas/v2/overlays/ta6.json +14 -6
- package/src/schemas/v2/overlays/ta7.json +97 -32
- package/src/schemas/v2/{core.json → pdtf-transaction.json} +6361 -335
- package/src/tests/v1/transactionSchema.test.js +21 -13
- package/src/tests/v2/transactionSchema.test.js +20 -27
- package/src/tests/v2/verifiedClaimsValidator.test.js +128 -0
- package/src/utils/extractOverlay.js +2 -12
- package/src/utils/extractProperties.js +44 -0
- package/src/schemas/v2/merged.json +0 -28693
package/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const validator = ajv.compile(transactionSchema);
|
|
|
45
45
|
|
|
46
46
|
// v2, via accessor functions and overlays
|
|
47
47
|
const combinedSchema = require("./src/schemas/v2/combined.json");
|
|
48
|
-
const
|
|
48
|
+
const v2CoreSchema = require("./src/schemas/v2/pdtf-transaction.json");
|
|
49
49
|
|
|
50
50
|
const baspiOverlay = require("./src/schemas/v2/overlays/baspi.json");
|
|
51
51
|
// const ta6Overlay = require("./src/schemas/v2/overlays/ta6.json");
|
|
@@ -58,12 +58,13 @@ const baspiOverlay = require("./src/schemas/v2/overlays/baspi.json");
|
|
|
58
58
|
// const rdsOverlay = require("./src/schemas/v2/overlays/rds.json");
|
|
59
59
|
// const oc1Overlay = require("./src/schemas/v2/overlays/oc1.json");
|
|
60
60
|
|
|
61
|
-
const overlays = { baspiV4: baspiOverlay };
|
|
61
|
+
const overlays = { baspiV4: baspiOverlay, null: {} };
|
|
62
62
|
|
|
63
63
|
const transactionSchemas = {
|
|
64
64
|
"https://trust.propdata.org.uk/schemas/v1/pdtf-transaction.json":
|
|
65
65
|
transactionSchema,
|
|
66
|
-
"https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json":
|
|
66
|
+
"https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json":
|
|
67
|
+
v2CoreSchema,
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
const combineMerge = (target, source, options) => {
|
|
@@ -105,7 +106,8 @@ const getValidator = (schemaId, overlay = "baspiV4") => {
|
|
|
105
106
|
};
|
|
106
107
|
|
|
107
108
|
// common functions for v1 and v2
|
|
108
|
-
const getSubschema = (path,
|
|
109
|
+
const getSubschema = (path, schemaId, overlay) => {
|
|
110
|
+
const sourceSchema = getTransactionSchema(schemaId, overlay);
|
|
109
111
|
const pathArray = path.split("/").slice(1);
|
|
110
112
|
if (pathArray.length < 1) return sourceSchema;
|
|
111
113
|
return pathArray.reduce((schema, pathElement) => {
|
|
@@ -127,23 +129,25 @@ const getSubschema = (path, sourceSchema = transactionSchema) => {
|
|
|
127
129
|
}, sourceSchema);
|
|
128
130
|
};
|
|
129
131
|
|
|
130
|
-
const isPathValid = (path,
|
|
132
|
+
const isPathValid = (path, schemaId, overlay) => {
|
|
133
|
+
const schema = getTransactionSchema(schemaId, overlay);
|
|
131
134
|
try {
|
|
132
|
-
return getSubschema(path,
|
|
135
|
+
return getSubschema(path, schemaId, overlay) !== undefined;
|
|
133
136
|
} catch (err) {
|
|
134
137
|
return false;
|
|
135
138
|
}
|
|
136
139
|
};
|
|
137
140
|
|
|
138
|
-
const getSubschemaValidator = (path,
|
|
139
|
-
const subSchema = getSubschema(path,
|
|
140
|
-
// see if we can retrieve the schema by path
|
|
141
|
-
|
|
141
|
+
const getSubschemaValidator = (path, schemaId, overlay) => {
|
|
142
|
+
const subSchema = getSubschema(path, schemaId, overlay);
|
|
143
|
+
// see if we can retrieve the schema by path, schemaId and overlay
|
|
144
|
+
const cacheKey = `${path}-${schemaId}-${overlay}`;
|
|
145
|
+
let validator = ajv.getSchema(cacheKey);
|
|
142
146
|
// retrieve whole schema by $id if available
|
|
143
|
-
if (!validator && subSchema.$id) validator = ajv.getSchema(
|
|
147
|
+
if (!validator && subSchema.$id) validator = ajv.getSchema(cacheKey);
|
|
144
148
|
if (!validator) {
|
|
145
|
-
ajv.addSchema(subSchema,
|
|
146
|
-
validator = ajv.getSchema(
|
|
149
|
+
ajv.addSchema(subSchema, cacheKey);
|
|
150
|
+
validator = ajv.getSchema(cacheKey);
|
|
147
151
|
}
|
|
148
152
|
return validator;
|
|
149
153
|
};
|
|
@@ -192,7 +196,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
192
196
|
}
|
|
193
197
|
};
|
|
194
198
|
|
|
195
|
-
const validateVerifiedClaims = (verifiedClaims) => {
|
|
199
|
+
const validateVerifiedClaims = (verifiedClaims, schemaId, overlay) => {
|
|
196
200
|
const validatorVClaims = ajv.compile(verifiedClaimsSchema);
|
|
197
201
|
|
|
198
202
|
const validationErrorsArr = [];
|
|
@@ -210,11 +214,10 @@ const validateVerifiedClaims = (verifiedClaims) => {
|
|
|
210
214
|
|
|
211
215
|
verifiedClaimsArray.forEach((claim) => {
|
|
212
216
|
const paths = Object.keys(claim.claims);
|
|
213
|
-
|
|
214
217
|
for (const path of paths) {
|
|
215
|
-
const validPath = isPathValid(path);
|
|
218
|
+
const validPath = isPathValid(path, schemaId, overlay);
|
|
216
219
|
if (validPath) {
|
|
217
|
-
const subValidator = getSubschemaValidator(path);
|
|
220
|
+
const subValidator = getSubschemaValidator(path, schemaId, overlay);
|
|
218
221
|
const isValid = subValidator(claim.claims[path]);
|
|
219
222
|
if (!isValid) {
|
|
220
223
|
validationErrorsArr.push(...subValidator.errors);
|
package/package.json
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"address": {
|
|
22
22
|
"line1": "47 Park Road",
|
|
23
23
|
"line2": "",
|
|
24
|
+
"line3": "",
|
|
24
25
|
"town": "HARPENDEN",
|
|
25
|
-
"county": "Herts",
|
|
26
26
|
"postcode": "AL3 5AF"
|
|
27
27
|
},
|
|
28
28
|
"delayFactors": {
|
|
@@ -34,23 +34,37 @@
|
|
|
34
34
|
"titleNumber": "HD221222",
|
|
35
35
|
"ownershipType": "Leasehold",
|
|
36
36
|
"leaseholdInformation": {
|
|
37
|
+
"typeOfLeasehold": {
|
|
38
|
+
"leaseholdType": "Shared ownership",
|
|
39
|
+
"sharedOwnershipPercentage": 50,
|
|
40
|
+
"sharedOwnershipRent": 200,
|
|
41
|
+
"sharedOwnershipRentFrequency": "Monthly"
|
|
42
|
+
},
|
|
43
|
+
"leaseTerm": {
|
|
44
|
+
"startYearOfLease": 1900,
|
|
45
|
+
"lengthOfLeaseInYears": 999
|
|
46
|
+
},
|
|
37
47
|
"contactDetails": {
|
|
38
48
|
"contacts": {
|
|
39
49
|
"landlord": {
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
"contact": {
|
|
51
|
+
"nameOrOrganisation": "Fleesum Properties",
|
|
52
|
+
"address": {
|
|
53
|
+
"line1": "47 Park Road",
|
|
54
|
+
"postcode": "AL3 5AF"
|
|
55
|
+
},
|
|
56
|
+
"emailAddress": "james@fleesum.com"
|
|
57
|
+
}
|
|
46
58
|
},
|
|
47
59
|
"managingAgent": {
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
"contact": {
|
|
61
|
+
"nameOrOrganisation": "Pricee Living",
|
|
62
|
+
"address": {
|
|
63
|
+
"line1": "Pricee House",
|
|
64
|
+
"postcode": "AL3 5KK"
|
|
65
|
+
},
|
|
66
|
+
"emailAddress": "marcel@pricee.co.uk"
|
|
67
|
+
}
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
70
|
},
|
|
@@ -77,20 +91,6 @@
|
|
|
77
91
|
"details": "There is sinking fund."
|
|
78
92
|
}
|
|
79
93
|
},
|
|
80
|
-
"general": {
|
|
81
|
-
"typeOfLeasehold": {
|
|
82
|
-
"leaseholdType": "Shared ownership",
|
|
83
|
-
"sharedOwnershipPercentage": 50,
|
|
84
|
-
"sharedOwnershipRent": 200,
|
|
85
|
-
"sharedOwnershipRentFrequency": "Monthly"
|
|
86
|
-
},
|
|
87
|
-
"leaseTerm": {
|
|
88
|
-
"startYearOfLease": 1900,
|
|
89
|
-
"lengthOfLeaseInYears": 999
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
"largeAdditionalExpense": { "yesNo": "No" },
|
|
94
94
|
"additionalFeesOnSale": 0
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -119,12 +119,15 @@
|
|
|
119
119
|
"isStandardForm": {
|
|
120
120
|
"yesNo": "Yes"
|
|
121
121
|
},
|
|
122
|
-
"
|
|
122
|
+
"buildingSafetyRemediation": { "yesNo": "No" },
|
|
123
|
+
"sprayFoamInsulation": {
|
|
124
|
+
"hasSprayFoamInstalled": "No"
|
|
125
|
+
}
|
|
123
126
|
},
|
|
124
127
|
"energyEfficiency": {
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
"
|
|
128
|
+
"certificate": {
|
|
129
|
+
"certificateNumber": "12345",
|
|
130
|
+
"currentEnergyRating": "A"
|
|
128
131
|
}
|
|
129
132
|
},
|
|
130
133
|
"councilTax": {
|
|
@@ -304,15 +307,15 @@
|
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
309
|
},
|
|
307
|
-
"
|
|
308
|
-
"
|
|
310
|
+
"connectedUtilities": {
|
|
311
|
+
"mainsElectricity": {
|
|
309
312
|
"maintenanceAgreements": {
|
|
310
313
|
"yesNo": "No"
|
|
311
314
|
},
|
|
312
315
|
"yesNo": "Yes",
|
|
313
316
|
"supplier": "Octopus Energy"
|
|
314
317
|
},
|
|
315
|
-
"
|
|
318
|
+
"mainsGas": {
|
|
316
319
|
"maintenanceAgreements": {
|
|
317
320
|
"yesNo": "No"
|
|
318
321
|
},
|
|
@@ -428,7 +431,7 @@
|
|
|
428
431
|
}
|
|
429
432
|
}
|
|
430
433
|
},
|
|
431
|
-
"
|
|
434
|
+
"environmentalIssues": {
|
|
432
435
|
"flooding": {
|
|
433
436
|
"floodRiskReport": { "yesNo": "No" },
|
|
434
437
|
"hasBeenFlooded": "Yes",
|
|
@@ -460,7 +463,9 @@
|
|
|
460
463
|
},
|
|
461
464
|
"otherEnvironmental": {
|
|
462
465
|
"yesNo": "No"
|
|
463
|
-
}
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"otherIssues": {
|
|
464
469
|
"excessiveNoise": {
|
|
465
470
|
"yesNo": "No"
|
|
466
471
|
},
|
|
@@ -493,6 +498,12 @@
|
|
|
493
498
|
"ownerType": "Private individual",
|
|
494
499
|
"firstName": "Peter",
|
|
495
500
|
"lastName": "Hetherington-Smythe"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"ownerType": "Private individual",
|
|
504
|
+
"firstName": "Clarissa",
|
|
505
|
+
"middleNames": "Jane",
|
|
506
|
+
"lastName": "Hetherington-Smythe"
|
|
496
507
|
}
|
|
497
508
|
]
|
|
498
509
|
},
|
|
@@ -551,9 +562,6 @@
|
|
|
551
562
|
"confirmInformationIsAccurate": true
|
|
552
563
|
}
|
|
553
564
|
},
|
|
554
|
-
"energyPerformanceCertificate": {
|
|
555
|
-
"certificate": { "currentEnergyRating": "B" }
|
|
556
|
-
},
|
|
557
565
|
"titlesToBeSold": [
|
|
558
566
|
{
|
|
559
567
|
"titleNumber": "HD221222",
|