@pdtf/schemas 3.0.0-2 → 3.0.0-20

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.
Files changed (33) hide show
  1. package/index.js +15 -13
  2. package/package.json +1 -1
  3. package/src/examples/v3/exampleTransaction.json +71 -71
  4. package/src/schemas/v2/overlays/baspi.json +510 -2331
  5. package/src/schemas/v2/overlays/con29DW.json +36 -125
  6. package/src/schemas/v2/overlays/con29R.json +5 -143
  7. package/src/schemas/v2/overlays/fme1.json +48 -233
  8. package/src/schemas/v2/overlays/lpe1.json +75 -367
  9. package/src/schemas/v2/overlays/nts.json +17 -103
  10. package/src/schemas/v2/overlays/piq.json +146 -693
  11. package/src/schemas/v2/overlays/rds.json +50 -316
  12. package/src/schemas/v2/overlays/ta10.json +540 -1755
  13. package/src/schemas/v2/overlays/ta6.json +241 -1193
  14. package/src/schemas/v2/overlays/ta7.json +106 -440
  15. package/src/schemas/v3/combined.json +2073 -2229
  16. package/src/schemas/v3/overlays/baspi.json +1065 -3215
  17. package/src/schemas/v3/overlays/con29DW.json +36 -125
  18. package/src/schemas/v3/overlays/con29R.json +5 -143
  19. package/src/schemas/v3/overlays/fme1.json +53 -233
  20. package/src/schemas/v3/overlays/lpe1.json +85 -367
  21. package/src/schemas/v3/overlays/nts.json +674 -644
  22. package/src/schemas/v3/overlays/piq.json +369 -1076
  23. package/src/schemas/v3/overlays/rds.json +299 -866
  24. package/src/schemas/v3/overlays/ta10.json +540 -1755
  25. package/src/schemas/v3/overlays/ta6.json +712 -1669
  26. package/src/schemas/v3/overlays/ta7.json +220 -462
  27. package/src/schemas/v3/pdtf-transaction.json +1469 -1788
  28. package/src/schemas/v3/skeleton.json +216 -180
  29. package/src/tests/v3/transactionSchema.test.js +28 -18
  30. package/src/tests/v3/verifiedClaimsValidator.test.js +2 -2
  31. package/src/utils/extractOverlay.js +5 -27
  32. package/src/tests/v2/transactionSchema.test.js +0 -361
  33. package/src/tests/v2/verifiedClaimsValidator.test.js +0 -128
package/index.js CHANGED
@@ -71,16 +71,23 @@ const combineMerge = (target, source, options) => {
71
71
  return destination;
72
72
  };
73
73
 
74
+ const mergeEnums = (target, source) => source;
75
+
74
76
  const getTransactionSchema = (
75
77
  schemaId = "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json",
76
- overlays = ["baspiV4"]
78
+ overlays // = ["baspiV4"]
77
79
  ) => {
78
80
  const sourceSchema = transactionSchemas[schemaId];
79
81
  if (!overlays || overlays.length < 1) return sourceSchema;
80
82
  let mergedSchema = sourceSchema;
81
83
  overlays.forEach((overlay) => {
82
84
  const overlaySchema = overlaysMap[schemaId][overlay] || {};
83
- mergedSchema = merge(overlaySchema, mergedSchema, {
85
+ mergedSchema = merge(mergedSchema, overlaySchema, {
86
+ customMerge: (key) => {
87
+ if (key === "enum") {
88
+ return mergeEnums;
89
+ }
90
+ },
84
91
  arrayMerge: combineMerge,
85
92
  });
86
93
  });
@@ -88,13 +95,7 @@ const getTransactionSchema = (
88
95
  };
89
96
 
90
97
  const getValidator = (schemaId, overlays) => {
91
- let validator = ajv.getSchema(schemaId);
92
- if (!validator) {
93
- const schema = getTransactionSchema(schemaId, overlays);
94
- ajv.addSchema(schema, schemaId);
95
- validator = ajv.getSchema(schemaId);
96
- }
97
- return validator;
98
+ return getSubschemaValidator("", schemaId, overlays);
98
99
  };
99
100
 
100
101
  // common functions for v1 and v2
@@ -129,7 +130,7 @@ const isPathValid = (path, schemaId, overlays) => {
129
130
  }
130
131
  };
131
132
 
132
- const getSubschemaValidator = (path, schemaId, overlays = ["baspiV4"]) => {
133
+ const getSubschemaValidator = (path, schemaId, overlays) => {
133
134
  const subSchema = getSubschema(path, schemaId, overlays);
134
135
  const overlayKey = (overlays || []).join(".");
135
136
  // see if we can retrieve the schema by path, schemaId and overlays
@@ -162,6 +163,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
162
163
  }
163
164
  const propertyName = pathArray.shift();
164
165
  const subPath = "/" + pathArray.join("/");
166
+
165
167
  let subSchema = schema.properties
166
168
  ? schema.properties[propertyName]
167
169
  : undefined;
@@ -172,10 +174,9 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
172
174
  subSchema = schema.items;
173
175
  return getTitleAtPath(subSchema, subPath, rootPath);
174
176
  }
175
- const discriminator = schema.discriminator?.propertyName;
176
- if (discriminator) {
177
+ const oneOfs = schema.oneOf;
178
+ if (oneOfs) {
177
179
  // only single dependency discriminator, oneOf keyword is supported
178
- const oneOfs = schema.oneOf;
179
180
  const matchingOneOf = oneOfs.find(
180
181
  (oneOf) => oneOf["properties"][propertyName]
181
182
  );
@@ -235,4 +236,5 @@ module.exports = {
235
236
  getTitleAtPath,
236
237
  verifiedClaimsSchema,
237
238
  validateVerifiedClaims,
239
+ overlaysMap,
238
240
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "3.0.0-2",
3
+ "version": "3.0.0-20",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -39,6 +39,13 @@
39
39
  "town": "HARPENDEN",
40
40
  "postcode": "AL3 5AF"
41
41
  },
42
+ "localAuthority": { "localAuthorityName": "Neverland Hook" },
43
+ "buildInformation": {
44
+ "building": { "propertyType": "House", "builtForm": "Detached" },
45
+ "roomDimensions": {
46
+ "hasFloorplan": "Yes"
47
+ }
48
+ },
42
49
  "delayFactors": {
43
50
  "hasDelayFactors": { "yesNo": "No" }
44
51
  },
@@ -112,7 +119,7 @@
112
119
  },
113
120
  "parking": {
114
121
  "parkingArrangements": ["Garage", "Driveway"],
115
-
122
+ "disabledParking": { "yesNo": "No" },
116
123
  "electricVehicleChargingPoint": { "yesNo": "No" },
117
124
  "controlledParking": { "yesNo": "No" }
118
125
  },
@@ -296,11 +303,47 @@
296
303
  "yesNo": "No"
297
304
  }
298
305
  },
306
+
307
+ "electricity": {
308
+ "mainsElectricity": {
309
+ "yesNo": "Yes",
310
+ "supplier": "Octopus Energy"
311
+ },
312
+ "solarPanels": {
313
+ "yesNo": "No"
314
+ },
315
+ "otherSources": {
316
+ "yesNo": "No"
317
+ }
318
+ },
319
+ "heating": {
320
+ "heatingSystem": {
321
+ "heatingType": "Central heating",
322
+ "centralHeatingDetails": {
323
+ "boilerInstallationCertificate": {
324
+ "yesNo": "Yes",
325
+ "details": "Certified installation",
326
+ "attachments": "To follow"
327
+ },
328
+ "heatingInGoodWorkingOrder": {
329
+ "yesNo": "Yes"
330
+ },
331
+ "centralHeatingFuel": {
332
+ "centralHeatingFuelType": "Other",
333
+ "otherCentralHeatingFuelType": "Ground-source Heat Pump"
334
+ },
335
+ "centralHeatingInstalled": "2016-04-20",
336
+ "heatingLastServicedDate": "2021-03-26",
337
+ "heatingLastServicedReport": "To follow"
338
+ }
339
+ },
340
+ "otherHeatingFeatures": ["Underfloor heating"]
341
+ },
299
342
  "waterAndDrainage": {
300
343
  "water": {
301
344
  "mainsWater": {
302
- "yesNo": "To be connected",
303
- "dateToBeConnected": "2022-12-15",
345
+ "yesNo": "Yes",
346
+ "isSupplyMetered": "Yes",
304
347
  "supplier": "Northumbria Water"
305
348
  }
306
349
  },
@@ -310,22 +353,17 @@
310
353
  },
311
354
  "mainsFoulDrainage": {
312
355
  "yesNo": "No",
313
- "sustainableDrainageSystem": { "yesNo": "No" },
314
- "septicTank": {
315
- "yesNo": "Yes",
316
- "details": "Last emptied on 1 Jan 2022",
356
+ "offMainsDrainageSystem": {
357
+ "offMainsDrainageSystemType": "Septic tank",
317
358
  "dateReplaced": "2022-01-01",
318
- "dateLastEmptied": "2022-01-01"
319
- },
320
- "cesspit": { "yesNo": "No" },
321
- "sewerageTreatmentPlant": { "yesNo": "No" },
322
- "otherConnectedProperties": { "yesNo": "No" },
323
- "yearSystemInstalled": 1980,
324
- "plantOnOtherLand": { "yesNo": "No" },
325
- "plantRegistered": { "yesNo": "No" },
326
- "plantDrainsIntoWaterway": {
327
- "yesNo": "Yes",
328
- "dischargeCompliesWithGBR": "Yes"
359
+ "dateLastEmptied": "2022-01-01",
360
+ "plantOnOtherLand": { "yesNo": "No" },
361
+ "otherConnectedProperties": { "yesNo": "No" },
362
+ "plantRegistered": { "yesNo": "No" },
363
+ "plantDrainsIntoWaterway": {
364
+ "yesNo": "Yes",
365
+ "dischargeCompliesWithGBR": "Yes"
366
+ }
329
367
  }
330
368
  }
331
369
  },
@@ -333,21 +371,7 @@
333
371
  "yesNo": "No"
334
372
  }
335
373
  },
336
- "connectedUtilities": {
337
- "mainsElectricity": {
338
- "yesNo": "Yes",
339
- "supplier": "Octopus Energy"
340
- },
341
- "mainsGas": {
342
- "yesNo": "Yes",
343
- "supplier": "Octopus Energy"
344
- },
345
- "lpg": {
346
- "yesNo": "No"
347
- },
348
- "oil": {
349
- "yesNo": "No"
350
- },
374
+ "connectivity": {
351
375
  "telephone": {
352
376
  "yesNo": "Yes",
353
377
  "supplier": "EE"
@@ -357,39 +381,13 @@
357
381
  "supplier": "Sky"
358
382
  },
359
383
  "broadband": {
360
- "yesNo": "Yes",
361
384
  "supplier": "BT",
362
385
  "typeOfConnection": "FTTC (Fibre to the Cabinet)"
363
386
  },
364
- "solarPanels": {
365
- "yesNo": "No"
366
- },
367
- "otherServices": {
368
- "yesNo": "No"
369
- },
370
- "maintenanceAgreements": {
371
- "yesNo": "No"
372
- }
373
- },
374
- "heating": {
375
- "heatingType": "Central heating",
376
- "otherHeatingFeatures": ["Underfloor Heating"],
377
- "centralHeatingDetails": {
378
- "boilerInstallationCertificate": {
379
- "yesNo": "Yes",
380
- "details": "Certified installation",
381
- "attachments": "To follow"
382
- },
383
- "heatingInGoodWorkingOrder": {
384
- "yesNo": "Yes"
385
- },
386
- "centralHeatingFuel": {
387
- "centralHeatingFuelType": "Other",
388
- "otherCentralHeatingFuelType": "Ground-source Heat Pump"
389
- },
390
- "centralHeatingInstalled": "2016-04-20",
391
- "heatingLastServicedDate": "2021-03-26",
392
- "heatingLastServicedReport": "To follow"
387
+ "mobilePhone": {
388
+ "knownSignalIssues": {
389
+ "yesNo": "No"
390
+ }
393
391
  }
394
392
  },
395
393
  "insurance": {
@@ -462,28 +460,30 @@
462
460
  "environmentalIssues": {
463
461
  "flooding": {
464
462
  "floodRisk": {
465
- "impactIndicator": "Yes",
463
+ "riskIndicator": "Yes",
466
464
  "summary": "Likely to flood from surface water"
467
465
  },
468
- "hasBeenFlooded": "Yes",
469
- "details": "Minor basement flood",
470
- "typeOfFlooding": ["Surface water"]
466
+ "historicalFlooding": {
467
+ "hasBeenFlooded": "Yes",
468
+ "details": "Minor basement flood",
469
+ "typeOfFlooding": ["Surface water"]
470
+ }
471
471
  },
472
472
  "radon": {
473
473
  "radonTest": { "yesNo": "No" },
474
474
  "remedialMeasuresOnConstruction": { "yesNo": "No" }
475
475
  },
476
476
  "coalMining": {
477
- "impactIndicator": "No"
477
+ "riskIndicator": "No"
478
478
  },
479
479
  "nonCoalMining": {
480
- "impactIndicator": "No"
480
+ "riskIndicator": "No"
481
481
  },
482
482
  "coastalErosion": {
483
- "impactIndicator": "No"
483
+ "riskIndicator": "No"
484
484
  },
485
485
  "otherEnvironmental": {
486
- "yesNo": "No"
486
+ "riskIndicator": "No"
487
487
  }
488
488
  },
489
489
  "otherIssues": {