@pdtf/schemas 2.0.0-0 → 2.0.0-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 +12 -9
- package/package.json +1 -1
- package/src/examples/v2/exampleTransaction.json +77 -22
- package/src/schemas/v2/combined.json +99 -47
- package/src/schemas/v2/core.json +12 -13
- package/src/schemas/v2/merged.json +28697 -0
- package/src/schemas/v2/overlays/baspi.json +132 -20
- package/src/schemas/v2/overlays/fme1.json +5 -5
- package/src/schemas/v2/overlays/lpe1.json +17 -22
- package/src/schemas/v2/overlays/nts.json +1 -1
- package/src/schemas/v2/overlays/rds.json +3 -2
- package/src/schemas/v2/overlays/ta7.json +4 -3
- package/src/tests/v2/transactionSchema.test.js +15 -24
- package/src/utils/extractOverlay.js +28 -0
package/index.js
CHANGED
|
@@ -105,7 +105,8 @@ const getValidator = (schemaId, overlay = "baspiV4") => {
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
// common functions for v1 and v2
|
|
108
|
-
const getSubschema = (path,
|
|
108
|
+
const getSubschema = (path, schemaId, overlay) => {
|
|
109
|
+
const sourceSchema = getTransactionSchema(schemaId, overlay);
|
|
109
110
|
const pathArray = path.split("/").slice(1);
|
|
110
111
|
if (pathArray.length < 1) return sourceSchema;
|
|
111
112
|
return pathArray.reduce((schema, pathElement) => {
|
|
@@ -127,23 +128,25 @@ const getSubschema = (path, sourceSchema = transactionSchema) => {
|
|
|
127
128
|
}, sourceSchema);
|
|
128
129
|
};
|
|
129
130
|
|
|
130
|
-
const isPathValid = (path,
|
|
131
|
+
const isPathValid = (path, schemaId, overlay) => {
|
|
132
|
+
const schema = getTransactionSchema(schemaId, overlay);
|
|
131
133
|
try {
|
|
132
|
-
return getSubschema(path,
|
|
134
|
+
return getSubschema(path, schemaId, overlay) !== undefined;
|
|
133
135
|
} catch (err) {
|
|
134
136
|
return false;
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
139
|
|
|
138
|
-
const getSubschemaValidator = (path,
|
|
139
|
-
const subSchema = getSubschema(path,
|
|
140
|
+
const getSubschemaValidator = (path, schemaId, overlay) => {
|
|
141
|
+
const subSchema = getSubschema(path, schemaId, overlay);
|
|
140
142
|
// see if we can retrieve the schema by path
|
|
141
|
-
|
|
143
|
+
const cacheKey = `${path}-${schemaId}`;
|
|
144
|
+
let validator = ajv.getSchema(cacheKey);
|
|
142
145
|
// retrieve whole schema by $id if available
|
|
143
|
-
if (!validator && subSchema.$id) validator = ajv.getSchema(
|
|
146
|
+
if (!validator && subSchema.$id) validator = ajv.getSchema(cacheKey);
|
|
144
147
|
if (!validator) {
|
|
145
|
-
ajv.addSchema(subSchema,
|
|
146
|
-
validator = ajv.getSchema(
|
|
148
|
+
ajv.addSchema(subSchema, cacheKey);
|
|
149
|
+
validator = ajv.getSchema(cacheKey);
|
|
147
150
|
}
|
|
148
151
|
return validator;
|
|
149
152
|
};
|
package/package.json
CHANGED
|
@@ -25,7 +25,6 @@
|
|
|
25
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
|
+
"contactDetails": {
|
|
38
|
+
"contacts": {
|
|
39
|
+
"landlord": {
|
|
40
|
+
"nameOrOrganisation": "Fleesum Properties",
|
|
41
|
+
"address": {
|
|
42
|
+
"line1": "47 Park Road",
|
|
43
|
+
"postcode": "AL3 5AF"
|
|
44
|
+
},
|
|
45
|
+
"emailAddress": "james@fleesum.com"
|
|
46
|
+
},
|
|
47
|
+
"managingAgent": {
|
|
48
|
+
"nameOrOrganisation": "Pricee Living",
|
|
49
|
+
"address": {
|
|
50
|
+
"line1": "Pricee House",
|
|
51
|
+
"postcode": "AL3 5KK"
|
|
52
|
+
},
|
|
53
|
+
"emailAddress": "marcel@pricee.co.uk"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"groundRent": {
|
|
58
|
+
"isGroundRentPayable": "Yes",
|
|
59
|
+
"annualGroundRent": 1750,
|
|
60
|
+
"rentSubjectToIncrease": {
|
|
61
|
+
"yesNo": "Yes",
|
|
62
|
+
"rentReviewFrequency": "Annually",
|
|
63
|
+
"rentIncreaseCalculated": "RPI"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"transferAndRegistration": {
|
|
67
|
+
"requirementsToBeMemberOfManagementCompany": {
|
|
68
|
+
"yesNoNotApplicable": "No"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"serviceCharge": {
|
|
72
|
+
"sellerContributesToServiceCharge": "Yes",
|
|
73
|
+
"annualServiceCharge": 250.23,
|
|
74
|
+
"largeAdditionalExpense": { "yesNo": "No" },
|
|
75
|
+
"reserveFund": {
|
|
76
|
+
"yesNo": "Yes",
|
|
77
|
+
"details": "There is sinking fund."
|
|
78
|
+
}
|
|
79
|
+
},
|
|
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
|
+
"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": {
|
|
@@ -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
|
},
|