@pdtf/schemas 3.0.0-1 → 3.0.0-10

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 +10 -6
  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 +421 -255
  16. package/src/schemas/v3/overlays/baspi.json +510 -2300
  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 +409 -346
  22. package/src/schemas/v3/overlays/piq.json +149 -689
  23. package/src/schemas/v3/overlays/rds.json +61 -329
  24. package/src/schemas/v3/overlays/ta10.json +540 -1755
  25. package/src/schemas/v3/overlays/ta6.json +261 -1136
  26. package/src/schemas/v3/overlays/ta7.json +220 -462
  27. package/src/schemas/v3/pdtf-transaction.json +355 -268
  28. package/src/schemas/v3/skeleton.json +57 -25
  29. package/src/tests/v3/transactionSchema.test.js +27 -16
  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
@@ -34,7 +34,6 @@
34
34
  "postcode": {}
35
35
  },
36
36
  "uprn": {},
37
- "propertyType": {},
38
37
  "isNewBuild": {
39
38
  "yesNo": {}
40
39
  },
@@ -72,6 +71,18 @@
72
71
  "caption": {}
73
72
  },
74
73
  "buildInformation": {
74
+ "building": {
75
+ "propertyType": {},
76
+ "otherType": {},
77
+ "builtForm": {},
78
+ "numberOfFloors": {},
79
+ "entranceFloor": {},
80
+ "hasLift": {},
81
+ "overCommercialPremises": {
82
+ "isLocatedOverCommercialPremises": {},
83
+ "details": {}
84
+ }
85
+ },
75
86
  "internalArea": {
76
87
  "area": {},
77
88
  "units": {}
@@ -2010,15 +2021,14 @@
2010
2021
  "drainage": {
2011
2022
  "mainsSurfaceWaterDrainage": {
2012
2023
  "yesNo": {},
2013
- "supplier": {},
2014
2024
  "details": {},
2015
2025
  "dateToBeConnected": {}
2016
2026
  },
2017
2027
  "mainsFoulDrainage": {
2018
2028
  "yesNo": {},
2019
- "supplier": {},
2020
2029
  "details": {},
2021
2030
  "dateToBeConnected": {},
2031
+ "supplier": {},
2022
2032
  "sustainableDrainageSystem": {
2023
2033
  "yesNo": {},
2024
2034
  "supplier": {},
@@ -2226,15 +2236,17 @@
2226
2236
  "environmentalIssues": {
2227
2237
  "flooding": {
2228
2238
  "floodRisk": {
2229
- "impactIndicator": {},
2239
+ "riskIndicator": {},
2230
2240
  "actionAlertRating": {},
2241
+ "result": {},
2231
2242
  "summary": {},
2232
2243
  "recommendations": {},
2233
2244
  "datasetAttribution": {},
2234
2245
  "riskSubcategories": {
2235
2246
  "subCategory": {},
2236
- "impactIndicator": {},
2247
+ "riskIndicator": {},
2237
2248
  "actionAlertRating": {},
2249
+ "result": {},
2238
2250
  "summary": {},
2239
2251
  "recommendations": {},
2240
2252
  "datasetAttribution": {}
@@ -2246,15 +2258,17 @@
2246
2258
  },
2247
2259
  "radon": {
2248
2260
  "radonRisk": {
2249
- "impactIndicator": {},
2261
+ "riskIndicator": {},
2250
2262
  "actionAlertRating": {},
2263
+ "result": {},
2251
2264
  "summary": {},
2252
2265
  "recommendations": {},
2253
2266
  "datasetAttribution": {},
2254
2267
  "riskSubcategories": {
2255
2268
  "subCategory": {},
2256
- "impactIndicator": {},
2269
+ "riskIndicator": {},
2257
2270
  "actionAlertRating": {},
2271
+ "result": {},
2258
2272
  "summary": {},
2259
2273
  "recommendations": {},
2260
2274
  "datasetAttribution": {}
@@ -2271,15 +2285,17 @@
2271
2285
  },
2272
2286
  "contaminatedLand": {
2273
2287
  "contaminatedLandRisk": {
2274
- "impactIndicator": {},
2288
+ "riskIndicator": {},
2275
2289
  "actionAlertRating": {},
2290
+ "result": {},
2276
2291
  "summary": {},
2277
2292
  "recommendations": {},
2278
2293
  "datasetAttribution": {},
2279
2294
  "riskSubcategories": {
2280
2295
  "subCategory": {},
2281
- "impactIndicator": {},
2296
+ "riskIndicator": {},
2282
2297
  "actionAlertRating": {},
2298
+ "result": {},
2283
2299
  "summary": {},
2284
2300
  "recommendations": {},
2285
2301
  "datasetAttribution": {}
@@ -2288,15 +2304,17 @@
2288
2304
  },
2289
2305
  "groundStability": {
2290
2306
  "groundStabilityRisk": {
2291
- "impactIndicator": {},
2307
+ "riskIndicator": {},
2292
2308
  "actionAlertRating": {},
2309
+ "result": {},
2293
2310
  "summary": {},
2294
2311
  "recommendations": {},
2295
2312
  "datasetAttribution": {},
2296
2313
  "riskSubcategories": {
2297
2314
  "subCategory": {},
2298
- "impactIndicator": {},
2315
+ "riskIndicator": {},
2299
2316
  "actionAlertRating": {},
2317
+ "result": {},
2300
2318
  "summary": {},
2301
2319
  "recommendations": {},
2302
2320
  "datasetAttribution": {}
@@ -2305,15 +2323,17 @@
2305
2323
  },
2306
2324
  "energy": {
2307
2325
  "energyRisk": {
2308
- "impactIndicator": {},
2326
+ "riskIndicator": {},
2309
2327
  "actionAlertRating": {},
2328
+ "result": {},
2310
2329
  "summary": {},
2311
2330
  "recommendations": {},
2312
2331
  "datasetAttribution": {},
2313
2332
  "riskSubcategories": {
2314
2333
  "subCategory": {},
2315
- "impactIndicator": {},
2334
+ "riskIndicator": {},
2316
2335
  "actionAlertRating": {},
2336
+ "result": {},
2317
2337
  "summary": {},
2318
2338
  "recommendations": {},
2319
2339
  "datasetAttribution": {}
@@ -2322,15 +2342,17 @@
2322
2342
  },
2323
2343
  "transportation": {
2324
2344
  "transportationRisk": {
2325
- "impactIndicator": {},
2345
+ "riskIndicator": {},
2326
2346
  "actionAlertRating": {},
2347
+ "result": {},
2327
2348
  "summary": {},
2328
2349
  "recommendations": {},
2329
2350
  "datasetAttribution": {},
2330
2351
  "riskSubcategories": {
2331
2352
  "subCategory": {},
2332
- "impactIndicator": {},
2353
+ "riskIndicator": {},
2333
2354
  "actionAlertRating": {},
2355
+ "result": {},
2334
2356
  "summary": {},
2335
2357
  "recommendations": {},
2336
2358
  "datasetAttribution": {}
@@ -2339,15 +2361,17 @@
2339
2361
  },
2340
2362
  "planning": {
2341
2363
  "planningRisk": {
2342
- "impactIndicator": {},
2364
+ "riskIndicator": {},
2343
2365
  "actionAlertRating": {},
2366
+ "result": {},
2344
2367
  "summary": {},
2345
2368
  "recommendations": {},
2346
2369
  "datasetAttribution": {},
2347
2370
  "riskSubcategories": {
2348
2371
  "subCategory": {},
2349
- "impactIndicator": {},
2372
+ "riskIndicator": {},
2350
2373
  "actionAlertRating": {},
2374
+ "result": {},
2351
2375
  "summary": {},
2352
2376
  "recommendations": {},
2353
2377
  "datasetAttribution": {}
@@ -2356,15 +2380,17 @@
2356
2380
  },
2357
2381
  "climate": {
2358
2382
  "climateRisk": {
2359
- "impactIndicator": {},
2383
+ "riskIndicator": {},
2360
2384
  "actionAlertRating": {},
2385
+ "result": {},
2361
2386
  "summary": {},
2362
2387
  "recommendations": {},
2363
2388
  "datasetAttribution": {},
2364
2389
  "riskSubcategories": {
2365
2390
  "subCategory": {},
2366
- "impactIndicator": {},
2391
+ "riskIndicator": {},
2367
2392
  "actionAlertRating": {},
2393
+ "result": {},
2368
2394
  "summary": {},
2369
2395
  "recommendations": {},
2370
2396
  "datasetAttribution": {}
@@ -2372,45 +2398,51 @@
2372
2398
  }
2373
2399
  },
2374
2400
  "coalMining": {
2375
- "impactIndicator": {},
2401
+ "riskIndicator": {},
2376
2402
  "actionAlertRating": {},
2403
+ "result": {},
2377
2404
  "summary": {},
2378
2405
  "recommendations": {},
2379
2406
  "datasetAttribution": {},
2380
2407
  "riskSubcategories": {
2381
2408
  "subCategory": {},
2382
- "impactIndicator": {},
2409
+ "riskIndicator": {},
2383
2410
  "actionAlertRating": {},
2411
+ "result": {},
2384
2412
  "summary": {},
2385
2413
  "recommendations": {},
2386
2414
  "datasetAttribution": {}
2387
2415
  }
2388
2416
  },
2389
2417
  "nonCoalMining": {
2390
- "impactIndicator": {},
2418
+ "riskIndicator": {},
2391
2419
  "actionAlertRating": {},
2420
+ "result": {},
2392
2421
  "summary": {},
2393
2422
  "recommendations": {},
2394
2423
  "datasetAttribution": {},
2395
2424
  "riskSubcategories": {
2396
2425
  "subCategory": {},
2397
- "impactIndicator": {},
2426
+ "riskIndicator": {},
2398
2427
  "actionAlertRating": {},
2428
+ "result": {},
2399
2429
  "summary": {},
2400
2430
  "recommendations": {},
2401
2431
  "datasetAttribution": {}
2402
2432
  }
2403
2433
  },
2404
2434
  "coastalErosion": {
2405
- "impactIndicator": {},
2435
+ "riskIndicator": {},
2406
2436
  "actionAlertRating": {},
2437
+ "result": {},
2407
2438
  "summary": {},
2408
2439
  "recommendations": {},
2409
2440
  "datasetAttribution": {},
2410
2441
  "riskSubcategories": {
2411
2442
  "subCategory": {},
2412
- "impactIndicator": {},
2443
+ "riskIndicator": {},
2413
2444
  "actionAlertRating": {},
2445
+ "result": {},
2414
2446
  "summary": {},
2415
2447
  "recommendations": {},
2416
2448
  "datasetAttribution": {}
@@ -11,23 +11,24 @@ const {
11
11
  } = require("../../../index.js");
12
12
 
13
13
  const exampleTransaction = require("../../examples/v3/exampleTransaction.json");
14
+
14
15
  const schemaId =
15
16
  "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json";
16
17
  // const validator = getValidator(schemaId);
17
18
  const v3TransactionSchema = getTransactionSchema(schemaId);
18
19
 
19
- test("exports a property pack schema, v3 with baspi overlay by default", () => {
20
- const testSchema = getTransactionSchema();
21
- expect(testSchema.$id).toEqual(
22
- "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json"
23
- );
20
+ test("exports a property pack schema, v3 with no overlay by default", () => {
21
+ const testSchema = getTransactionSchema(schemaId);
22
+ // expect(testSchema.$id).toEqual(
23
+ // "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json"
24
+ // );
24
25
  expect(
25
26
  testSchema.properties.propertyPack.properties.materialFacts.baspiRef
26
- ).toEqual("A");
27
+ ).toEqual(undefined);
27
28
  });
28
29
 
29
30
  test("sample is valid BASPI", () => {
30
- const testSchema = getTransactionSchema();
31
+ const testSchema = getTransactionSchema(schemaId, ["baspiV4"]);
31
32
  expect(
32
33
  testSchema.properties.propertyPack.properties.materialFacts.baspiRef
33
34
  ).toEqual("A");
@@ -49,7 +50,7 @@ test("invalid sample is invalid", () => {
49
50
  JSON.stringify(exampleTransaction)
50
51
  );
51
52
  delete clonedExampleTransaction.propertyPack.materialFacts.notices;
52
- const validator = getValidator(schemaId);
53
+ const validator = getValidator(schemaId, ["baspiV4"]);
53
54
  const isValid = validator(clonedExampleTransaction);
54
55
  expect(isValid).toBe(false);
55
56
  });
@@ -166,6 +167,15 @@ test("correctly gets yes another subschema but through a non-baspi oneOf structu
166
167
  expect(subschema).toEqual({ type: "string" });
167
168
  });
168
169
 
170
+ test("correctly gets an overlaid enum in a subschema", () => {
171
+ const subschema = getSubschema(
172
+ "/propertyPack/materialFacts/connectedUtilities/mainsElectricity/yesNo",
173
+ schemaId,
174
+ ["nts2023"]
175
+ );
176
+ expect(subschema.enum).toEqual(["Yes", "No"]);
177
+ });
178
+
169
179
  test("correctly gets a subschema with multiple overlays", () => {
170
180
  const subschema = getSubschema(
171
181
  "/propertyPack/materialFacts/parking/parkingArrangements",
@@ -267,14 +277,14 @@ test("correctly gets a subschema validator for an NTS overlay", () => {
267
277
  expect(isValid).toBe(true);
268
278
  });
269
279
 
270
- test("correctly gets a subschema validator for an LPE1 overlay", () => {
280
+ test("correctly gets a subschema validator for an TA7 overlay", () => {
271
281
  const path = "/propertyPack";
272
282
  const clonedExampleTransaction = JSON.parse(
273
283
  JSON.stringify(exampleTransaction)
274
284
  );
275
285
  const data = jp.get(clonedExampleTransaction, path);
276
286
  const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
277
- "lpe1ed4",
287
+ "ta7ed3",
278
288
  ]);
279
289
  let isValid = validator(data);
280
290
  expect(isValid).toBe(false);
@@ -299,48 +309,49 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
299
309
  "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/ownershipType"
300
310
  )
301
311
  ).toBe("What type of ownership is the property?");
312
+
302
313
  expect(
303
314
  getTitleAtPath(
304
315
  v3TransactionSchema,
305
316
  "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
306
317
  )
307
318
  ).toBe("Length of lease (years)");
308
- expect(
309
- getTitleAtPath(
310
- v3TransactionSchema,
311
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/serviceCharge/annualServiceCharge"
312
- )
313
- ).toBe("Amount of current annual service charge (£)");
319
+
314
320
  expect(
315
321
  getTitleAtPath(
316
322
  v3TransactionSchema,
317
323
  "/propertyPack/materialFacts/invalidPath"
318
324
  )
319
325
  ).toBe(undefined);
326
+
320
327
  expect(
321
328
  getTitleAtPath(
322
329
  v3TransactionSchema,
323
330
  "/propertyPack/titlesToBeSold/0/registerExtract"
324
331
  )
325
332
  ).toBe("HMLR Official Copy Register Extract");
333
+
326
334
  expect(
327
335
  getTitleAtPath(
328
336
  v3TransactionSchema,
329
337
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
330
338
  )
331
339
  ).toBe("Property address");
340
+
332
341
  expect(
333
342
  getTitleAtPath(
334
343
  v3TransactionSchema,
335
344
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
336
345
  )
337
346
  ).toBe(undefined);
347
+
338
348
  expect(
339
349
  getTitleAtPath(
340
350
  v3TransactionSchema,
341
351
  "/propertyPack/materialFacts/energyEfficiency/certificate/currentEnergyRating"
342
352
  )
343
353
  ).toBe("Current energy efficiency rating");
354
+
344
355
  expect(
345
356
  getTitleAtPath(
346
357
  v3TransactionSchema,
@@ -27,14 +27,14 @@ test("returns an array with an error stating if path is incorrect", () => {
27
27
  ]);
28
28
  });
29
29
 
30
- test("returns errors if BASPI requirements are not met and BASPI overlay is specified (default)", () => {
30
+ test("returns errors if BASPI requirements are not met and BASPI overlay is specified", () => {
31
31
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
32
32
  clonedVouch.claims = {
33
33
  "/propertyPack/materialFacts/delayFactors": {
34
34
  hasDelayFactors: { yesNo: "Yes" },
35
35
  },
36
36
  };
37
- const errors = validateVerifiedClaims([clonedVouch], v3SchemaId);
37
+ const errors = validateVerifiedClaims([clonedVouch], v3SchemaId, ["baspiV4"]);
38
38
  expect(errors).toEqual([
39
39
  {
40
40
  instancePath: "/hasDelayFactors",
@@ -23,30 +23,15 @@ const extractFields = [
23
23
  ];
24
24
 
25
25
  const overlayIncludeProperties = [
26
- "title",
27
- "description",
28
- "enum",
26
+ // "title",
27
+ // "description",
28
+ // "enum",
29
29
  "discriminator",
30
- "minItems",
30
+ // "minItems",
31
31
  ];
32
32
 
33
- const combineMerge = (target, source, options) => {
34
- const destination = target.slice();
35
- source.forEach((item, index) => {
36
- if (typeof destination[index] === "undefined") {
37
- destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
38
- } else if (options.isMergeableObject(item)) {
39
- destination[index] = merge(target[index], item, options);
40
- } else if (target.indexOf(item) === -1) {
41
- destination.push(item);
42
- }
43
- });
44
- return destination;
45
- };
46
-
47
33
  const flattenSkeleton = (schema) => {
48
34
  if (!schema) return undefined;
49
- // console.log(schema.properties);
50
35
  let returnStructure = {};
51
36
  if (schema.properties) {
52
37
  Object.keys(schema.properties).forEach((key) => {
@@ -55,10 +40,8 @@ const flattenSkeleton = (schema) => {
55
40
  }
56
41
  if (schema.oneOf) {
57
42
  schema.oneOf.forEach((aOneOf) => {
58
- // console.log(aOneOf);
59
43
  if (aOneOf.properties) {
60
44
  Object.entries(aOneOf.properties).forEach(([key, value]) => {
61
- // console.log(aProperty);
62
45
  returnStructure[key] = flattenSkeleton(value);
63
46
  });
64
47
  }
@@ -153,12 +136,7 @@ const deleteProperties = (sourceSchema, propertyNames) => {
153
136
  const overlays = {};
154
137
 
155
138
  extractFields.forEach((key) => {
156
- let overlay = extractOverlay(combinedSchema, key, [
157
- "title",
158
- "description",
159
- "enum",
160
- "discriminator",
161
- ]);
139
+ let overlay = extractOverlay(combinedSchema, key);
162
140
  overlays[key] = overlay;
163
141
  const fileName = `../schemas/v3/overlays/${key}.json`;
164
142
  fs.writeFileSync(fileName, JSON.stringify(overlay, null, 2));