@pdtf/schemas 2.0.0-21 → 2.0.0-23

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
@@ -60,7 +60,7 @@ const con29DWOverlay = require("./src/schemas/v2/overlays/con29DW.json");
60
60
  const rdsOverlay = require("./src/schemas/v2/overlays/rds.json");
61
61
  const oc1Overlay = require("./src/schemas/v2/overlays/oc1.json");
62
62
 
63
- const overlays = { baspiV4: baspiOverlay, null: {} };
63
+ const overlaysMap = { baspiV4: baspiOverlay, ta6ed4: ta6Overlay, null: {} };
64
64
 
65
65
  const transactionSchemas = {
66
66
  "https://trust.propdata.org.uk/schemas/v1/pdtf-transaction.json":
@@ -85,22 +85,25 @@ const combineMerge = (target, source, options) => {
85
85
 
86
86
  const getTransactionSchema = (
87
87
  schemaId = "https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json",
88
- overlay = "baspiV4"
88
+ overlays = ["baspiV4"]
89
89
  ) => {
90
90
  const sourceSchema = transactionSchemas[schemaId];
91
- const overlaySchema = overlays[overlay];
92
- if (!overlaySchema) return sourceSchema;
93
- const mergedSchema = merge(overlaySchema, sourceSchema, {
94
- arrayMerge: combineMerge,
91
+ if (!overlays || overlays.length < 1) return sourceSchema;
92
+ let mergedSchema = sourceSchema;
93
+ overlays.forEach((overlay) => {
94
+ const overlaySchema = overlaysMap[overlay] || {};
95
+ mergedSchema = merge(overlaySchema, mergedSchema, {
96
+ arrayMerge: combineMerge,
97
+ });
95
98
  });
96
99
  // console.log("mergedSchema", mergedSchema);
97
100
  return mergedSchema;
98
101
  };
99
102
 
100
- const getValidator = (schemaId, overlay = "baspiV4") => {
103
+ const getValidator = (schemaId, overlays) => {
101
104
  let validator = ajv.getSchema(schemaId);
102
105
  if (!validator) {
103
- const schema = getTransactionSchema(schemaId, overlay);
106
+ const schema = getTransactionSchema(schemaId, overlays);
104
107
  ajv.addSchema(schema, schemaId);
105
108
  validator = ajv.getSchema(schemaId);
106
109
  }
@@ -108,8 +111,8 @@ const getValidator = (schemaId, overlay = "baspiV4") => {
108
111
  };
109
112
 
110
113
  // common functions for v1 and v2
111
- const getSubschema = (path, schemaId, overlay) => {
112
- const sourceSchema = getTransactionSchema(schemaId, overlay);
114
+ const getSubschema = (path, schemaId, overlays) => {
115
+ const sourceSchema = getTransactionSchema(schemaId, overlays);
113
116
  const pathArray = path.split("/").slice(1);
114
117
  if (pathArray.length < 1) return sourceSchema;
115
118
  return pathArray.reduce((schema, pathElement) => {
@@ -131,19 +134,21 @@ const getSubschema = (path, schemaId, overlay) => {
131
134
  }, sourceSchema);
132
135
  };
133
136
 
134
- const isPathValid = (path, schemaId, overlay) => {
135
- const schema = getTransactionSchema(schemaId, overlay);
137
+ const isPathValid = (path, schemaId, overlays) => {
138
+ const schema = getTransactionSchema(schemaId, overlays);
136
139
  try {
137
- return getSubschema(path, schemaId, overlay) !== undefined;
140
+ return getSubschema(path, schemaId, overlays) !== undefined;
138
141
  } catch (err) {
139
142
  return false;
140
143
  }
141
144
  };
142
145
 
143
- const getSubschemaValidator = (path, schemaId, overlay) => {
144
- const subSchema = getSubschema(path, schemaId, overlay);
145
- // see if we can retrieve the schema by path, schemaId and overlay
146
- const cacheKey = `${path}-${schemaId}-${overlay}`;
146
+ const getSubschemaValidator = (path, schemaId, overlays = ["baspiV4"]) => {
147
+ const subSchema = getSubschema(path, schemaId, overlays);
148
+ const overlayKey = (overlays || []).join(".");
149
+ // see if we can retrieve the schema by path, schemaId and overlays
150
+ const cacheKey = `${path}-${schemaId}-${overlayKey}`;
151
+ console.log("cacheKey", cacheKey);
147
152
  let validator = ajv.getSchema(cacheKey);
148
153
  // retrieve whole schema by $id if available
149
154
  if (!validator && subSchema.$id) validator = ajv.getSchema(cacheKey);
@@ -198,7 +203,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
198
203
  }
199
204
  };
200
205
 
201
- const validateVerifiedClaims = (verifiedClaims, schemaId, overlay) => {
206
+ const validateVerifiedClaims = (verifiedClaims, schemaId, overlays) => {
202
207
  const validatorVClaims = ajv.compile(verifiedClaimsSchema);
203
208
 
204
209
  const validationErrorsArr = [];
@@ -217,9 +222,10 @@ const validateVerifiedClaims = (verifiedClaims, schemaId, overlay) => {
217
222
  verifiedClaimsArray.forEach((claim) => {
218
223
  const paths = Object.keys(claim.claims);
219
224
  for (const path of paths) {
220
- const validPath = isPathValid(path, schemaId, overlay);
225
+ const validPath = isPathValid(path, schemaId, overlays);
221
226
  if (validPath) {
222
- const subValidator = getSubschemaValidator(path, schemaId, overlay);
227
+ console.log("overlays", path, overlays);
228
+ const subValidator = getSubschemaValidator(path, schemaId, overlays);
223
229
  const isValid = subValidator(claim.claims[path]);
224
230
  if (!isValid) {
225
231
  validationErrorsArr.push(...subValidator.errors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "2.0.0-21",
3
+ "version": "2.0.0-23",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -321,6 +321,64 @@
321
321
  }
322
322
  }
323
323
  },
324
+ "connectivity": {
325
+ "title": "Connectivity",
326
+ "type": "object",
327
+ "properties": {
328
+ "broadband": {
329
+ "title": "Broadband predicted speed per Ofcom Connected Nations",
330
+ "type": "object",
331
+ "properties": {
332
+ "MaxBbPredictedDown": { "type": "number" },
333
+ "MaxBbPredictedUp": { "type": "number" },
334
+ "MaxSfbbPredictedDown": { "type": "number" },
335
+ "MaxSfbbPredictedUp": { "type": "number" },
336
+ "MaxUfbbPredictedDown": { "type": "number" },
337
+ "MaxUfbbPredictedUp": { "type": "number" },
338
+ "MaxPredictedDown": { "type": "number" },
339
+ "MaxPredictedUp": { "type": "number" }
340
+ }
341
+ },
342
+ "mobile": {
343
+ "title": "Mobile predicted coverage per Ofcom Connected Nations",
344
+ "type": "object",
345
+ "properties": {
346
+ "EEVoiceOutdoor": { "type": "integer" },
347
+ "EEVoiceOutdoorNo4g": { "type": "integer" },
348
+ "EEVoiceIndoor": { "type": "integer" },
349
+ "EEVoiceIndoorNo4g": { "type": "integer" },
350
+ "EEDataOutdoor": { "type": "integer" },
351
+ "EEDataOutdoorNo4g": { "type": "integer" },
352
+ "EEDataIndoor": { "type": "integer" },
353
+ "EEDataIndoorNo4g": { "type": "integer" },
354
+ "H3VoiceOutdoor": { "type": "integer" },
355
+ "H3VoiceOutdoorNo4g": { "type": "integer" },
356
+ "H3VoiceIndoor": { "type": "integer" },
357
+ "H3VoiceIndoorNo4g": { "type": "integer" },
358
+ "H3DataOutdoor": { "type": "integer" },
359
+ "H3DataOutdoorNo4g": { "type": "integer" },
360
+ "H3DataIndoor": { "type": "integer" },
361
+ "H3DataIndoorNo4g": { "type": "integer" },
362
+ "TFVoiceOutdoor": { "type": "integer" },
363
+ "TFVoiceOutdoorNo4g": { "type": "integer" },
364
+ "TFVoiceIndoor": { "type": "integer" },
365
+ "TFVoiceIndoorNo4g": { "type": "integer" },
366
+ "TFDataOutdoor": { "type": "integer" },
367
+ "TFDataOutdoorNo4g": { "type": "integer" },
368
+ "TFDataIndoor": { "type": "integer" },
369
+ "TFDataIndoorNo4g": { "type": "integer" },
370
+ "VOVoiceOutdoor": { "type": "integer" },
371
+ "VOVoiceOutdoorNo4g": { "type": "integer" },
372
+ "VOVoiceIndoor": { "type": "integer" },
373
+ "VOVoiceIndoorNo4g": { "type": "integer" },
374
+ "VODataOutdoor": { "type": "integer" },
375
+ "VODataOutdoorNo4g": { "type": "integer" },
376
+ "VODataIndoor": { "type": "integer" },
377
+ "VODataIndoorNo4g": { "type": "integer" }
378
+ }
379
+ }
380
+ }
381
+ },
324
382
  "delayFactors": {
325
383
  "baspiRef": "A1.2",
326
384
  "title": "Delay factors",
@@ -17364,7 +17422,7 @@
17364
17422
  "centralHeatingFuelType": {
17365
17423
  "baspiRef": "A7.4.0.2",
17366
17424
  "ta6Ref": "12.3a",
17367
- "title": "What type of fuel does the system and boiler run on?",
17425
+ "title": "What type of fuel does the system run on?",
17368
17426
  "type": "string",
17369
17427
  "enum": [
17370
17428
  "Gas",
@@ -17407,7 +17465,7 @@
17407
17465
  "baspiRef": "A7.4.1",
17408
17466
  "rdsRef": "Objects/Installed",
17409
17467
  "ta6Ref": "12.3b",
17410
- "title": "When was the heating system and boiler installed?",
17468
+ "title": "When was the heating system installed?",
17411
17469
  "type": "string",
17412
17470
  "format": "date"
17413
17471
  },
@@ -17457,7 +17515,7 @@
17457
17515
  "baspiRef": "A7.4.2.1",
17458
17516
  "rdsRef": "Objects/Maintenance",
17459
17517
  "ta6Ref": "12.3d",
17460
- "title": "When was the heating system and boiler last serviced or maintained?",
17518
+ "title": "When was the heating system last serviced or maintained?",
17461
17519
  "type": "string",
17462
17520
  "format": "date"
17463
17521
  },
@@ -5537,7 +5537,7 @@
5537
5537
  "properties": {
5538
5538
  "centralHeatingFuelType": {
5539
5539
  "baspiRef": "A7.4.0.2",
5540
- "title": "What type of fuel does the system and boiler run on?",
5540
+ "title": "What type of fuel does the system run on?",
5541
5541
  "enum": [
5542
5542
  "Gas",
5543
5543
  "Electricity",
@@ -5550,7 +5550,7 @@
5550
5550
  },
5551
5551
  "centralHeatingInstalled": {
5552
5552
  "baspiRef": "A7.4.1",
5553
- "title": "When was the heating system and boiler installed?"
5553
+ "title": "When was the heating system installed?"
5554
5554
  },
5555
5555
  "boilerInstallationCertificate": {
5556
5556
  "baspiRef": "A7.4.1.1",
@@ -5604,7 +5604,7 @@
5604
5604
  },
5605
5605
  "heatingLastServicedDate": {
5606
5606
  "baspiRef": "A7.4.2.1",
5607
- "title": "When was the heating system and boiler last serviced or maintained?"
5607
+ "title": "When was the heating system last serviced or maintained?"
5608
5608
  },
5609
5609
  "heatingLastServicedReport": {
5610
5610
  "baspiRef": "A7.4.2.2",
@@ -2148,7 +2148,7 @@
2148
2148
  },
2149
2149
  "centralHeatingInstalled": {
2150
2150
  "rdsRef": "Objects/Installed",
2151
- "title": "When was the heating system and boiler installed?"
2151
+ "title": "When was the heating system installed?"
2152
2152
  },
2153
2153
  "boilerInstallationCertificate": {
2154
2154
  "rdsRef": "Objects/Installation,Objects/Certificates",
@@ -2179,7 +2179,7 @@
2179
2179
  },
2180
2180
  "heatingLastServicedDate": {
2181
2181
  "rdsRef": "Objects/Maintenance",
2182
- "title": "When was the heating system and boiler last serviced or maintained?"
2182
+ "title": "When was the heating system last serviced or maintained?"
2183
2183
  },
2184
2184
  "heatingInGoodWorkingOrder": {
2185
2185
  "rdsRef": "Objects/Condition=?",
@@ -1732,7 +1732,7 @@
1732
1732
  "properties": {
1733
1733
  "centralHeatingFuelType": {
1734
1734
  "ta6Ref": "12.3a",
1735
- "title": "What type of fuel does the system and boiler run on?",
1735
+ "title": "What type of fuel does the system run on?",
1736
1736
  "enum": [
1737
1737
  "Gas",
1738
1738
  "Electricity",
@@ -1756,7 +1756,7 @@
1756
1756
  },
1757
1757
  "centralHeatingInstalled": {
1758
1758
  "ta6Ref": "12.3b",
1759
- "title": "When was the heating system and boiler installed?"
1759
+ "title": "When was the heating system installed?"
1760
1760
  },
1761
1761
  "boilerInstallationCertificate": {
1762
1762
  "ta6Ref": "12.3b",
@@ -1787,7 +1787,7 @@
1787
1787
  },
1788
1788
  "heatingLastServicedDate": {
1789
1789
  "ta6Ref": "12.3d",
1790
- "title": "When was the heating system and boiler last serviced or maintained?"
1790
+ "title": "When was the heating system last serviced or maintained?"
1791
1791
  },
1792
1792
  "heatingInGoodWorkingOrder": {
1793
1793
  "ta6Ref": "12.3c",
@@ -276,6 +276,144 @@
276
276
  }
277
277
  }
278
278
  },
279
+ "connectivity": {
280
+ "title": "Connectivity",
281
+ "type": "object",
282
+ "properties": {
283
+ "broadband": {
284
+ "title": "Broadband predicted speed per Ofcom Connected Nations",
285
+ "type": "object",
286
+ "properties": {
287
+ "MaxBbPredictedDown": {
288
+ "type": "number"
289
+ },
290
+ "MaxBbPredictedUp": {
291
+ "type": "number"
292
+ },
293
+ "MaxSfbbPredictedDown": {
294
+ "type": "number"
295
+ },
296
+ "MaxSfbbPredictedUp": {
297
+ "type": "number"
298
+ },
299
+ "MaxUfbbPredictedDown": {
300
+ "type": "number"
301
+ },
302
+ "MaxUfbbPredictedUp": {
303
+ "type": "number"
304
+ },
305
+ "MaxPredictedDown": {
306
+ "type": "number"
307
+ },
308
+ "MaxPredictedUp": {
309
+ "type": "number"
310
+ }
311
+ }
312
+ },
313
+ "mobile": {
314
+ "title": "Mobile predicted coverage per Ofcom Connected Nations",
315
+ "type": "object",
316
+ "properties": {
317
+ "EEVoiceOutdoor": {
318
+ "type": "integer"
319
+ },
320
+ "EEVoiceOutdoorNo4g": {
321
+ "type": "integer"
322
+ },
323
+ "EEVoiceIndoor": {
324
+ "type": "integer"
325
+ },
326
+ "EEVoiceIndoorNo4g": {
327
+ "type": "integer"
328
+ },
329
+ "EEDataOutdoor": {
330
+ "type": "integer"
331
+ },
332
+ "EEDataOutdoorNo4g": {
333
+ "type": "integer"
334
+ },
335
+ "EEDataIndoor": {
336
+ "type": "integer"
337
+ },
338
+ "EEDataIndoorNo4g": {
339
+ "type": "integer"
340
+ },
341
+ "H3VoiceOutdoor": {
342
+ "type": "integer"
343
+ },
344
+ "H3VoiceOutdoorNo4g": {
345
+ "type": "integer"
346
+ },
347
+ "H3VoiceIndoor": {
348
+ "type": "integer"
349
+ },
350
+ "H3VoiceIndoorNo4g": {
351
+ "type": "integer"
352
+ },
353
+ "H3DataOutdoor": {
354
+ "type": "integer"
355
+ },
356
+ "H3DataOutdoorNo4g": {
357
+ "type": "integer"
358
+ },
359
+ "H3DataIndoor": {
360
+ "type": "integer"
361
+ },
362
+ "H3DataIndoorNo4g": {
363
+ "type": "integer"
364
+ },
365
+ "TFVoiceOutdoor": {
366
+ "type": "integer"
367
+ },
368
+ "TFVoiceOutdoorNo4g": {
369
+ "type": "integer"
370
+ },
371
+ "TFVoiceIndoor": {
372
+ "type": "integer"
373
+ },
374
+ "TFVoiceIndoorNo4g": {
375
+ "type": "integer"
376
+ },
377
+ "TFDataOutdoor": {
378
+ "type": "integer"
379
+ },
380
+ "TFDataOutdoorNo4g": {
381
+ "type": "integer"
382
+ },
383
+ "TFDataIndoor": {
384
+ "type": "integer"
385
+ },
386
+ "TFDataIndoorNo4g": {
387
+ "type": "integer"
388
+ },
389
+ "VOVoiceOutdoor": {
390
+ "type": "integer"
391
+ },
392
+ "VOVoiceOutdoorNo4g": {
393
+ "type": "integer"
394
+ },
395
+ "VOVoiceIndoor": {
396
+ "type": "integer"
397
+ },
398
+ "VOVoiceIndoorNo4g": {
399
+ "type": "integer"
400
+ },
401
+ "VODataOutdoor": {
402
+ "type": "integer"
403
+ },
404
+ "VODataOutdoorNo4g": {
405
+ "type": "integer"
406
+ },
407
+ "VODataIndoor": {
408
+ "type": "integer"
409
+ },
410
+ "VODataIndoorNo4g": {
411
+ "type": "integer"
412
+ }
413
+ }
414
+ }
415
+ }
416
+ },
279
417
  "delayFactors": {
280
418
  "title": "Delay factors",
281
419
  "type": "object",
@@ -16175,7 +16313,7 @@
16175
16313
  "title": "Central Heating Fuel",
16176
16314
  "properties": {
16177
16315
  "centralHeatingFuelType": {
16178
- "title": "What type of fuel does the system and boiler run on?",
16316
+ "title": "What type of fuel does the system run on?",
16179
16317
  "type": "string",
16180
16318
  "enum": [
16181
16319
  "Gas",
@@ -16216,7 +16354,7 @@
16216
16354
  ]
16217
16355
  },
16218
16356
  "centralHeatingInstalled": {
16219
- "title": "When was the heating system and boiler installed?",
16357
+ "title": "When was the heating system installed?",
16220
16358
  "type": "string",
16221
16359
  "format": "date"
16222
16360
  },
@@ -16263,7 +16401,7 @@
16263
16401
  ]
16264
16402
  },
16265
16403
  "heatingLastServicedDate": {
16266
- "title": "When was the heating system and boiler last serviced or maintained?",
16404
+ "title": "When was the heating system last serviced or maintained?",
16267
16405
  "type": "string",
16268
16406
  "format": "date"
16269
16407
  },
@@ -56,6 +56,52 @@
56
56
  "mediaUrl": {},
57
57
  "caption": {}
58
58
  },
59
+ "connectivity": {
60
+ "broadband": {
61
+ "MaxBbPredictedDown": {},
62
+ "MaxBbPredictedUp": {},
63
+ "MaxSfbbPredictedDown": {},
64
+ "MaxSfbbPredictedUp": {},
65
+ "MaxUfbbPredictedDown": {},
66
+ "MaxUfbbPredictedUp": {},
67
+ "MaxPredictedDown": {},
68
+ "MaxPredictedUp": {}
69
+ },
70
+ "mobile": {
71
+ "EEVoiceOutdoor": {},
72
+ "EEVoiceOutdoorNo4g": {},
73
+ "EEVoiceIndoor": {},
74
+ "EEVoiceIndoorNo4g": {},
75
+ "EEDataOutdoor": {},
76
+ "EEDataOutdoorNo4g": {},
77
+ "EEDataIndoor": {},
78
+ "EEDataIndoorNo4g": {},
79
+ "H3VoiceOutdoor": {},
80
+ "H3VoiceOutdoorNo4g": {},
81
+ "H3VoiceIndoor": {},
82
+ "H3VoiceIndoorNo4g": {},
83
+ "H3DataOutdoor": {},
84
+ "H3DataOutdoorNo4g": {},
85
+ "H3DataIndoor": {},
86
+ "H3DataIndoorNo4g": {},
87
+ "TFVoiceOutdoor": {},
88
+ "TFVoiceOutdoorNo4g": {},
89
+ "TFVoiceIndoor": {},
90
+ "TFVoiceIndoorNo4g": {},
91
+ "TFDataOutdoor": {},
92
+ "TFDataOutdoorNo4g": {},
93
+ "TFDataIndoor": {},
94
+ "TFDataIndoorNo4g": {},
95
+ "VOVoiceOutdoor": {},
96
+ "VOVoiceOutdoorNo4g": {},
97
+ "VOVoiceIndoor": {},
98
+ "VOVoiceIndoorNo4g": {},
99
+ "VODataOutdoor": {},
100
+ "VODataOutdoorNo4g": {},
101
+ "VODataIndoor": {},
102
+ "VODataIndoorNo4g": {}
103
+ }
104
+ },
59
105
  "delayFactors": {
60
106
  "hasDelayFactors": {
61
107
  "yesNo": {},