@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 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, sourceSchema = transactionSchema) => {
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, schema = transactionSchema) => {
131
+ const isPathValid = (path, schemaId, overlay) => {
132
+ const schema = getTransactionSchema(schemaId, overlay);
131
133
  try {
132
- return getSubschema(path, schema) !== undefined;
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, schema = transactionSchema) => {
139
- const subSchema = getSubschema(path, schema);
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
- let validator = ajv.getSchema(path);
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(subSchema.$id);
146
+ if (!validator && subSchema.$id) validator = ajv.getSchema(cacheKey);
144
147
  if (!validator) {
145
- ajv.addSchema(subSchema, path);
146
- validator = ajv.getSchema(path);
148
+ ajv.addSchema(subSchema, cacheKey);
149
+ validator = ajv.getSchema(cacheKey);
147
150
  }
148
151
  return validator;
149
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "2.0.0-0",
3
+ "version": "2.0.0-2",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -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
- "sharedOwnership": { "isSharedOwnership": "No" },
38
- "startYearOfLease": 1900,
39
- "lengthOfLeaseInYears": 999,
40
- "currentGroundRent": 1750,
41
- "rentIncrease": { "yesNo": "No" },
42
- "annualServiceCharge": 250.23,
43
- "largeAdditionalExpense": { "yesNo": "No" },
44
- "additionalFeesOnSale": 0,
45
- "freeholderContactDetails": {
46
- "nameOrOrganisation": "Fleesum Properties"
47
- },
48
- "managingAgentContactDetails": {
49
- "nameOrOrganisation": "Pricee Living"
50
- },
51
- "managementCompanyDirectorRequirement": { "yesNo": "No" }
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
- "hasFlammableExternalWallSystem": { "yesNo": "No" }
122
+ "buildingSafetyRemediation": { "yesNo": "No" },
123
+ "sprayFoamInsulation": {
124
+ "hasSprayFoamInstalled": "No"
125
+ }
79
126
  },
80
127
  "energyEfficiency": {
81
- "energyEfficiencyRating": "A",
82
- "hasSprayFoamInstalled": {
83
- "yesNo": "No"
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
- "otherIssues": {
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
  },