@pdtf/schemas 3.0.0-1 → 3.0.0-11

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 +23 -22
  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 +762 -683
  16. package/src/schemas/v3/overlays/baspi.json +662 -2571
  17. package/src/schemas/v3/overlays/con29DW.json +46 -127
  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 +493 -475
  22. package/src/schemas/v3/overlays/piq.json +225 -827
  23. package/src/schemas/v3/overlays/rds.json +172 -541
  24. package/src/schemas/v3/overlays/ta10.json +540 -1755
  25. package/src/schemas/v3/overlays/ta6.json +346 -1271
  26. package/src/schemas/v3/overlays/ta7.json +220 -462
  27. package/src/schemas/v3/pdtf-transaction.json +628 -600
  28. package/src/schemas/v3/skeleton.json +92 -67
  29. package/src/tests/v3/transactionSchema.test.js +27 -17
  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-1",
3
+ "version": "3.0.0-11",
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": { "yesNo": "Yes" }
47
+ }
48
+ },
42
49
  "delayFactors": {
43
50
  "hasDelayFactors": { "yesNo": "No" }
44
51
  },
@@ -112,7 +119,6 @@
112
119
  },
113
120
  "parking": {
114
121
  "parkingArrangements": ["Garage", "Driveway"],
115
-
116
122
  "electricVehicleChargingPoint": { "yesNo": "No" },
117
123
  "controlledParking": { "yesNo": "No" }
118
124
  },
@@ -299,8 +305,8 @@
299
305
  "waterAndDrainage": {
300
306
  "water": {
301
307
  "mainsWater": {
302
- "yesNo": "To be connected",
303
- "dateToBeConnected": "2022-12-15",
308
+ "yesNo": "Yes",
309
+ "isSupplyMetered": "Yes",
304
310
  "supplier": "Northumbria Water"
305
311
  }
306
312
  },
@@ -310,22 +316,17 @@
310
316
  },
311
317
  "mainsFoulDrainage": {
312
318
  "yesNo": "No",
313
- "sustainableDrainageSystem": { "yesNo": "No" },
314
- "septicTank": {
315
- "yesNo": "Yes",
316
- "details": "Last emptied on 1 Jan 2022",
319
+ "offMainsDrainageSystem": {
320
+ "offMainsDrainageSystemType": "Septic tank",
317
321
  "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"
322
+ "dateLastEmptied": "2022-01-01",
323
+ "plantOnOtherLand": { "yesNo": "No" },
324
+ "otherConnectedProperties": { "yesNo": "No" },
325
+ "plantRegistered": { "yesNo": "No" },
326
+ "plantDrainsIntoWaterway": {
327
+ "yesNo": "Yes",
328
+ "dischargeCompliesWithGBR": "Yes"
329
+ }
329
330
  }
330
331
  }
331
332
  },
@@ -462,7 +463,7 @@
462
463
  "environmentalIssues": {
463
464
  "flooding": {
464
465
  "floodRisk": {
465
- "impactIndicator": "Yes",
466
+ "riskIndicator": "Yes",
466
467
  "summary": "Likely to flood from surface water"
467
468
  },
468
469
  "hasBeenFlooded": "Yes",
@@ -474,13 +475,13 @@
474
475
  "remedialMeasuresOnConstruction": { "yesNo": "No" }
475
476
  },
476
477
  "coalMining": {
477
- "impactIndicator": "No"
478
+ "riskIndicator": "No"
478
479
  },
479
480
  "nonCoalMining": {
480
- "impactIndicator": "No"
481
+ "riskIndicator": "No"
481
482
  },
482
483
  "coastalErosion": {
483
- "impactIndicator": "No"
484
+ "riskIndicator": "No"
484
485
  },
485
486
  "otherEnvironmental": {
486
487
  "yesNo": "No"