@pdtf/schemas 2.0.0-0 → 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 +81 -29
- package/src/schemas/v2/combined.json +6803 -436
- package/src/schemas/v2/overlays/baspi.json +329 -142
- package/src/schemas/v2/overlays/con29R.json +1 -1
- package/src/schemas/v2/overlays/fme1.json +44 -35
- package/src/schemas/v2/overlays/lpe1.json +65 -77
- package/src/schemas/v2/overlays/nts.json +39 -43
- package/src/schemas/v2/overlays/rds.json +10 -18
- 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 +100 -34
- package/src/schemas/v2/{core.json → pdtf-transaction.json} +6365 -339
- 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 +20 -2
- package/src/utils/extractProperties.js +44 -0
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,11 +21,10 @@
|
|
|
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
|
-
|
|
29
28
|
"delayFactors": {
|
|
30
29
|
"hasDelayFactors": { "yesNo": "No" }
|
|
31
30
|
},
|
|
@@ -34,21 +33,66 @@
|
|
|
34
33
|
{
|
|
35
34
|
"titleNumber": "HD221222",
|
|
36
35
|
"ownershipType": "Leasehold",
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
},
|
|
47
|
+
"contactDetails": {
|
|
48
|
+
"contacts": {
|
|
49
|
+
"landlord": {
|
|
50
|
+
"contact": {
|
|
51
|
+
"nameOrOrganisation": "Fleesum Properties",
|
|
52
|
+
"address": {
|
|
53
|
+
"line1": "47 Park Road",
|
|
54
|
+
"postcode": "AL3 5AF"
|
|
55
|
+
},
|
|
56
|
+
"emailAddress": "james@fleesum.com"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"managingAgent": {
|
|
60
|
+
"contact": {
|
|
61
|
+
"nameOrOrganisation": "Pricee Living",
|
|
62
|
+
"address": {
|
|
63
|
+
"line1": "Pricee House",
|
|
64
|
+
"postcode": "AL3 5KK"
|
|
65
|
+
},
|
|
66
|
+
"emailAddress": "marcel@pricee.co.uk"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"groundRent": {
|
|
72
|
+
"isGroundRentPayable": "Yes",
|
|
73
|
+
"annualGroundRent": 1750,
|
|
74
|
+
"rentSubjectToIncrease": {
|
|
75
|
+
"yesNo": "Yes",
|
|
76
|
+
"rentReviewFrequency": "Annually",
|
|
77
|
+
"rentIncreaseCalculated": "RPI"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"transferAndRegistration": {
|
|
81
|
+
"requirementsToBeMemberOfManagementCompany": {
|
|
82
|
+
"yesNoNotApplicable": "No"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"serviceCharge": {
|
|
86
|
+
"sellerContributesToServiceCharge": "Yes",
|
|
87
|
+
"annualServiceCharge": 250.23,
|
|
88
|
+
"largeAdditionalExpense": { "yesNo": "No" },
|
|
89
|
+
"reserveFund": {
|
|
90
|
+
"yesNo": "Yes",
|
|
91
|
+
"details": "There is sinking fund."
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"additionalFeesOnSale": 0
|
|
95
|
+
}
|
|
52
96
|
}
|
|
53
97
|
]
|
|
54
98
|
},
|
|
@@ -75,12 +119,15 @@
|
|
|
75
119
|
"isStandardForm": {
|
|
76
120
|
"yesNo": "Yes"
|
|
77
121
|
},
|
|
78
|
-
"
|
|
122
|
+
"buildingSafetyRemediation": { "yesNo": "No" },
|
|
123
|
+
"sprayFoamInsulation": {
|
|
124
|
+
"hasSprayFoamInstalled": "No"
|
|
125
|
+
}
|
|
79
126
|
},
|
|
80
127
|
"energyEfficiency": {
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
"
|
|
128
|
+
"certificate": {
|
|
129
|
+
"certificateNumber": "12345",
|
|
130
|
+
"currentEnergyRating": "A"
|
|
84
131
|
}
|
|
85
132
|
},
|
|
86
133
|
"councilTax": {
|
|
@@ -260,15 +307,15 @@
|
|
|
260
307
|
}
|
|
261
308
|
}
|
|
262
309
|
},
|
|
263
|
-
"
|
|
264
|
-
"
|
|
310
|
+
"connectedUtilities": {
|
|
311
|
+
"mainsElectricity": {
|
|
265
312
|
"maintenanceAgreements": {
|
|
266
313
|
"yesNo": "No"
|
|
267
314
|
},
|
|
268
315
|
"yesNo": "Yes",
|
|
269
316
|
"supplier": "Octopus Energy"
|
|
270
317
|
},
|
|
271
|
-
"
|
|
318
|
+
"mainsGas": {
|
|
272
319
|
"maintenanceAgreements": {
|
|
273
320
|
"yesNo": "No"
|
|
274
321
|
},
|
|
@@ -384,7 +431,7 @@
|
|
|
384
431
|
}
|
|
385
432
|
}
|
|
386
433
|
},
|
|
387
|
-
"
|
|
434
|
+
"environmentalIssues": {
|
|
388
435
|
"flooding": {
|
|
389
436
|
"floodRiskReport": { "yesNo": "No" },
|
|
390
437
|
"hasBeenFlooded": "Yes",
|
|
@@ -416,7 +463,9 @@
|
|
|
416
463
|
},
|
|
417
464
|
"otherEnvironmental": {
|
|
418
465
|
"yesNo": "No"
|
|
419
|
-
}
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"otherIssues": {
|
|
420
469
|
"excessiveNoise": {
|
|
421
470
|
"yesNo": "No"
|
|
422
471
|
},
|
|
@@ -449,6 +498,12 @@
|
|
|
449
498
|
"ownerType": "Private individual",
|
|
450
499
|
"firstName": "Peter",
|
|
451
500
|
"lastName": "Hetherington-Smythe"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"ownerType": "Private individual",
|
|
504
|
+
"firstName": "Clarissa",
|
|
505
|
+
"middleNames": "Jane",
|
|
506
|
+
"lastName": "Hetherington-Smythe"
|
|
452
507
|
}
|
|
453
508
|
]
|
|
454
509
|
},
|
|
@@ -507,9 +562,6 @@
|
|
|
507
562
|
"confirmInformationIsAccurate": true
|
|
508
563
|
}
|
|
509
564
|
},
|
|
510
|
-
"energyPerformanceCertificate": {
|
|
511
|
-
"certificate": { "currentEnergyRating": "B" }
|
|
512
|
-
},
|
|
513
565
|
"titlesToBeSold": [
|
|
514
566
|
{
|
|
515
567
|
"titleNumber": "HD221222",
|