@pdtf/schemas 3.0.0-22 → 3.0.0-24

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.
@@ -22,16 +22,14 @@ test("exports a property pack schema, v3 with no overlay by default", () => {
22
22
  // expect(testSchema.$id).toEqual(
23
23
  // "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json"
24
24
  // );
25
- expect(
26
- testSchema.properties.propertyPack.properties.materialFacts.baspiRef
27
- ).toEqual(undefined);
25
+ expect(testSchema.properties.propertyPack.properties.baspiRef).toEqual(
26
+ undefined
27
+ );
28
28
  });
29
29
 
30
30
  test("sample is valid BASPI", () => {
31
31
  const testSchema = getTransactionSchema(schemaId, ["baspiV4"]);
32
- expect(
33
- testSchema.properties.propertyPack.properties.materialFacts.baspiRef
34
- ).toEqual("A");
32
+ expect(testSchema.properties.propertyPack.baspiRef).toEqual("0");
35
33
  const validator = getValidator(schemaId);
36
34
  const isValid = validator(exampleTransaction);
37
35
  if (!isValid) console.log(validator.errors);
@@ -49,7 +47,7 @@ test("invalid sample is invalid", () => {
49
47
  const clonedExampleTransaction = JSON.parse(
50
48
  JSON.stringify(exampleTransaction)
51
49
  );
52
- delete clonedExampleTransaction.propertyPack.materialFacts.notices;
50
+ delete clonedExampleTransaction.propertyPack.notices;
53
51
  const validator = getValidator(schemaId, ["baspiV4"]);
54
52
  const isValid = validator(clonedExampleTransaction);
55
53
  expect(isValid).toBe(false);
@@ -59,7 +57,7 @@ test("sample with missing dependent required fields is invalid", () => {
59
57
  const clonedExampleTransaction = JSON.parse(
60
58
  JSON.stringify(exampleTransaction)
61
59
  );
62
- clonedExampleTransaction.propertyPack.materialFacts.ownership.ownershipsToBeTransferred[0].ownershipType =
60
+ clonedExampleTransaction.propertyPack.ownership.ownershipsToBeTransferred[0].ownershipType =
63
61
  "leasehold";
64
62
  const validator = getValidator(schemaId);
65
63
  const isValid = validator(clonedExampleTransaction);
@@ -72,7 +70,7 @@ test("correctly gets a top level subschema", () => {
72
70
  });
73
71
 
74
72
  test("correctly identifies a valid path", () => {
75
- const isValid = isPathValid("/propertyPack/materialFacts");
73
+ const isValid = isPathValid("/propertyPack");
76
74
  expect(isValid).toBe(true);
77
75
  });
78
76
 
@@ -90,15 +88,12 @@ test("correctly identifies an error generating invalid path", () => {
90
88
  });
91
89
 
92
90
  test("correctly identifies an array invalid path", () => {
93
- const isValid = isPathValid("/propertyPack/materialFacts/1/item");
91
+ const isValid = isPathValid("/propertyPack/1/item");
94
92
  expect(isValid).toBe(false);
95
93
  });
96
94
 
97
95
  test("correctly gets a subschema", () => {
98
- const subschema = getSubschema(
99
- "/propertyPack/materialFacts/notices",
100
- schemaId
101
- );
96
+ const subschema = getSubschema("/propertyPack/notices", schemaId);
102
97
  expect(subschema.title).toBe("Notices which Affect the Property");
103
98
  });
104
99
 
@@ -108,14 +103,14 @@ test("correctly gets a subschema through an arrays element", () => {
108
103
  schemaId
109
104
  );
110
105
  expect(Object.keys(subschema.properties)).toEqual([
111
- "OCSummaryData",
112
- "OCRegisterData",
106
+ "ocSummaryData",
107
+ "ocRegisterData",
113
108
  ]);
114
109
  });
115
110
 
116
111
  test("correctly gets a subschema through a dependency", () => {
117
112
  const subschema = getSubschema(
118
- "/propertyPack/materialFacts/delayFactors/hasDelayFactors/details",
113
+ "/propertyPack/delayFactors/hasDelayFactors/details",
119
114
  schemaId
120
115
  );
121
116
  expect(subschema.title).toBe(
@@ -125,7 +120,7 @@ test("correctly gets a subschema through a dependency", () => {
125
120
 
126
121
  test("correctly gets another subschema through a dependency", () => {
127
122
  const subschema = getSubschema(
128
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears",
123
+ "/propertyPack/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears",
129
124
  schemaId
130
125
  );
131
126
  expect(subschema.title).toBe("Length of lease (years)");
@@ -133,14 +128,14 @@ test("correctly gets another subschema through a dependency", () => {
133
128
 
134
129
  test("correctly gets yet another subschema through a dependency", () => {
135
130
  const subschema = getSubschema(
136
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/groundRent/rentSubjectToIncrease/rentIncreaseCalculated"
131
+ "/propertyPack/ownership/ownershipsToBeTransferred/0/leaseholdInformation/groundRent/rentSubjectToIncrease/rentIncreaseCalculated"
137
132
  );
138
133
  expect(subschema.title).toBe("How is the increase calculated?");
139
134
  });
140
135
 
141
136
  test("correctly gets yet, yet another subschema through a dependency", () => {
142
137
  const subschema = getSubschema(
143
- "/propertyPack/materialFacts/listingAndConservation/isConservationArea/yesNo"
138
+ "/propertyPack/listingAndConservation/isConservationArea/yesNo"
144
139
  );
145
140
  expect(subschema.type).toBe("string");
146
141
  expect(subschema.enum).toStrictEqual(["Yes", "No", "Not known"]);
@@ -148,28 +143,28 @@ test("correctly gets yet, yet another subschema through a dependency", () => {
148
143
 
149
144
  test("correctly gets yet, yet, yet another subschema through a second item dependency", () => {
150
145
  const subschema = getSubschema(
151
- "/propertyPack/materialFacts/environmentalIssues/flooding/historicalFlooding/typeOfFlooding"
146
+ "/propertyPack/environmentalIssues/flooding/historicalFlooding/typeOfFlooding"
152
147
  );
153
148
  expect(subschema.type).toBe("array");
154
149
  });
155
150
 
156
151
  test("correctly gets yes another subschema but through a non-baspi oneOf structure", () => {
157
152
  const subschema = getSubschema(
158
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/RestrictionDetails/RestrictionEntry/ChargeRestriction/EntryDetails/EntryText"
153
+ "/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/restrictionDetails/restrictionEntry/chargeRestriction/entryDetails/entryText"
159
154
  );
160
155
  expect(subschema).toEqual({ type: "string" });
161
156
  });
162
157
 
163
158
  test("correctly gets yes another subschema but through a non-baspi oneOf structure with array option", () => {
164
159
  const subschema = getSubschema(
165
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/RestrictionDetails/RestrictionEntry/0/ChargeRestriction/EntryDetails/EntryText"
160
+ "/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/restrictionDetails/restrictionEntry/0/chargeRestriction/entryDetails/entryText"
166
161
  );
167
162
  expect(subschema).toEqual({ type: "string" });
168
163
  });
169
164
 
170
165
  test("correctly gets an overlaid enum in a subschema", () => {
171
166
  const subschema = getSubschema(
172
- "/propertyPack/materialFacts/electricity/mainsElectricity/yesNo",
167
+ "/propertyPack/electricity/mainsElectricity/yesNo",
173
168
  schemaId,
174
169
  ["nts2023"]
175
170
  );
@@ -178,7 +173,7 @@ test("correctly gets an overlaid enum in a subschema", () => {
178
173
 
179
174
  test("correctly gets a subschema with multiple overlays", () => {
180
175
  const subschema = getSubschema(
181
- "/propertyPack/materialFacts/parking/parkingArrangements",
176
+ "/propertyPack/parking/parkingArrangements",
182
177
  schemaId,
183
178
  ["baspiV4", "ta6ed4"]
184
179
  );
@@ -188,11 +183,11 @@ test("correctly gets a subschema with multiple overlays", () => {
188
183
 
189
184
  test("correctly gets a subschema validator which is already cached", () => {
190
185
  const validator = getSubschemaValidator(
191
- "/propertyPack/materialFacts/energyEfficiency/certificate"
186
+ "/propertyPack/energyEfficiency/certificate"
192
187
  );
193
188
  expect(validator).not.toBeNull();
194
189
  const anotherValidator = getSubschemaValidator(
195
- "/propertyPack/materialFacts/energyEfficiency/certificate"
190
+ "/propertyPack/energyEfficiency/certificate"
196
191
  );
197
192
  expect(anotherValidator).not.toBeNull();
198
193
  });
@@ -209,7 +204,7 @@ test("correctly gets a subschema validator for a TA6 overlay", () => {
209
204
 
210
205
  test("correctly gets a subschema validator for a TA6 overlay which validates", () => {
211
206
  const path =
212
- "/propertyPack/additionalLegalInfo/guaranteesWarrantiesAndIndemnityInsurances/subsidenceWork";
207
+ "/propertyPack/guaranteesWarrantiesAndIndemnityInsurances/subsidenceWork";
213
208
  const data = { yesNo: "Yes" };
214
209
  const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
215
210
  "ta6ed4",
@@ -227,7 +222,7 @@ test("correctly gets a subschema validator for a TA6 overlay which validates wit
227
222
  JSON.stringify(exampleTransaction)
228
223
  );
229
224
  const data = jp.get(exampleTransaction, path);
230
- data.materialFacts.uprn = undefined;
225
+ data.uprn = undefined;
231
226
  const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
232
227
  "ta6ed4",
233
228
  ]);
@@ -241,7 +236,7 @@ test("correctly gets a subschema validator for a TA6 overlay which validates wit
241
236
  JSON.stringify(exampleTransaction)
242
237
  );
243
238
  const data = jp.get(clonedExampleTransaction, path);
244
- data.additionalLegalInfo.smartHomeSystems = undefined;
239
+ data.smartHomeSystems = undefined;
245
240
  const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
246
241
  "ta6ed4",
247
242
  ]);
@@ -255,7 +250,7 @@ test("correctly gets a subschema validator for a TA6 overlay which fails to vali
255
250
  JSON.stringify(exampleTransaction)
256
251
  );
257
252
  const data = jp.get(clonedExampleTransaction, path);
258
- data.materialFacts.waterAndDrainage = {};
253
+ data.waterAndDrainage = {};
259
254
  const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
260
255
  "ta6ed4",
261
256
  ]);
@@ -290,7 +285,7 @@ test("correctly gets a subschema validator for an TA7 overlay", () => {
290
285
  });
291
286
 
292
287
  test("correctly gets a subschema validator which validates", () => {
293
- const path = "/propertyPack/materialFacts/notices";
288
+ const path = "/propertyPack/notices";
294
289
  const validator = getSubschemaValidator(path);
295
290
  const data = jp.get(exampleTransaction, path);
296
291
  expect(data.neighbourDevelopment.yesNo).toBe("No");
@@ -305,23 +300,20 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
305
300
  expect(
306
301
  getTitleAtPath(
307
302
  v3TransactionSchema,
308
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/ownershipType"
303
+ "/propertyPack/ownership/ownershipsToBeTransferred/0/ownershipType"
309
304
  )
310
305
  ).toBe("What type of ownership is the property?");
311
306
 
312
307
  expect(
313
308
  getTitleAtPath(
314
309
  v3TransactionSchema,
315
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
310
+ "/propertyPack/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
316
311
  )
317
312
  ).toBe("Length of lease (years)");
318
313
 
319
- expect(
320
- getTitleAtPath(
321
- v3TransactionSchema,
322
- "/propertyPack/materialFacts/invalidPath"
323
- )
324
- ).toBe(undefined);
314
+ expect(getTitleAtPath(v3TransactionSchema, "/propertyPack/invalidPath")).toBe(
315
+ undefined
316
+ );
325
317
 
326
318
  expect(
327
319
  getTitleAtPath(
@@ -333,28 +325,28 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
333
325
  expect(
334
326
  getTitleAtPath(
335
327
  v3TransactionSchema,
336
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
328
+ "/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/propertyAddress"
337
329
  )
338
330
  ).toBe("Property address");
339
331
 
340
332
  expect(
341
333
  getTitleAtPath(
342
334
  v3TransactionSchema,
343
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
335
+ "/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/invalidProp"
344
336
  )
345
337
  ).toBe(undefined);
346
338
 
347
339
  expect(
348
340
  getTitleAtPath(
349
341
  v3TransactionSchema,
350
- "/propertyPack/materialFacts/energyEfficiency/certificate/currentEnergyRating"
342
+ "/propertyPack/energyEfficiency/certificate/currentEnergyRating"
351
343
  )
352
344
  ).toBe("Current energy efficiency rating");
353
345
 
354
346
  expect(
355
347
  getTitleAtPath(
356
348
  v3TransactionSchema,
357
- "/propertyPack/additionalLegalInfo/occupiers/othersAged17OrOver/aged17OrOverNames"
349
+ "/propertyPack/occupiers/othersAged17OrOver/aged17OrOverNames"
358
350
  )
359
351
  ).toBe("Please provide their full names and ages.");
360
352
  });
@@ -1,7 +1,7 @@
1
1
  const { validateVerifiedClaims } = require("../../../index.js");
2
2
 
3
- const exampleVouch = require("../../examples/v1/exampleVouch.json");
4
- const exampleDocumentedVouch = require("../../examples/v1/exampleDocumentedVouch.json");
3
+ const exampleVouch = require("../../examples/v3/exampleVouch.json");
4
+ const exampleDocumentedVouch = require("../../examples/v3/exampleDocumentedVouch.json");
5
5
  const v3SchemaId =
6
6
  "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json";
7
7
 
@@ -19,18 +19,18 @@ test("returns an array with an error stating if path is incorrect", () => {
19
19
  const originalPath = Object.keys(clonedVouch.claims)[0];
20
20
  const data = clonedVouch.claims[originalPath];
21
21
  clonedVouch.claims = {
22
- "/propertyPack/INVALID/materialFacts/councilTax": data,
22
+ "/propertyPack/INVALID/councilTax": data,
23
23
  };
24
24
  // v3 schema, no overlay
25
25
  expect(validateVerifiedClaims([clonedVouch], v3SchemaId, null)).toEqual([
26
- "Path /propertyPack/INVALID/materialFacts/councilTax is not a valid PDTF schema path",
26
+ "Path /propertyPack/INVALID/councilTax is not a valid PDTF schema path",
27
27
  ]);
28
28
  });
29
29
 
30
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
- "/propertyPack/materialFacts/delayFactors": {
33
+ "/propertyPack/delayFactors": {
34
34
  hasDelayFactors: { yesNo: "Yes" },
35
35
  },
36
36
  };
@@ -56,7 +56,7 @@ test("returns errors if BASPI requirements are not met and BASPI overlay is spec
56
56
  test("returns no errors if BASPI requirements are not met and null overlay is specified", () => {
57
57
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
58
58
  clonedVouch.claims = {
59
- "/propertyPack/materialFacts/delayFactors": {
59
+ "/propertyPack/delayFactors": {
60
60
  hasDelayFactors: { yesNo: "Yes" },
61
61
  },
62
62
  };
@@ -67,7 +67,7 @@ test("returns no errors if BASPI requirements are not met and null overlay is sp
67
67
  test("returns errors for invalid fields even if null overlay is specified", () => {
68
68
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
69
69
  clonedVouch.claims = {
70
- "/propertyPack/materialFacts/delayFactors": {
70
+ "/propertyPack/delayFactors": {
71
71
  hasDelayFactors: { yesNo: "Maybe" },
72
72
  },
73
73
  };
@@ -78,7 +78,7 @@ test("returns errors for invalid fields even if null overlay is specified", () =
78
78
  test("returns an array of errors for verified claim with multiple paths", () => {
79
79
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
80
80
  clonedVouch.claims = {
81
- "/propertyPack/materialFacts/cousncilTaxBad": {
81
+ "/propertyPack/cousncilTaxBad": {
82
82
  councilTaxBand: "D",
83
83
  councilTaxAffectingAlterations: {
84
84
  yesNo: "Yes",
@@ -86,7 +86,7 @@ test("returns an array of errors for verified claim with multiple paths", () =>
86
86
  "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
87
87
  },
88
88
  },
89
- "/propertyPack/materialFacts/councilTaxBadTwo": {
89
+ "/propertyPack/councilTaxBadTwo": {
90
90
  councilTaxBand: "D",
91
91
  councilTaxAffectingAlterations: {
92
92
  yesNo: "Yes",
@@ -96,8 +96,8 @@ test("returns an array of errors for verified claim with multiple paths", () =>
96
96
  },
97
97
  };
98
98
  expect(validateVerifiedClaims([clonedVouch], v3SchemaId, null)).toEqual([
99
- "Path /propertyPack/materialFacts/cousncilTaxBad is not a valid PDTF schema path",
100
- "Path /propertyPack/materialFacts/councilTaxBadTwo is not a valid PDTF schema path",
99
+ "Path /propertyPack/cousncilTaxBad is not a valid PDTF schema path",
100
+ "Path /propertyPack/councilTaxBadTwo is not a valid PDTF schema path",
101
101
  ]);
102
102
  });
103
103
 
@@ -108,7 +108,7 @@ test("returns an empty array of errors for verified claim with multiple valid pa
108
108
  null
109
109
  );
110
110
  clonedVouch.claims = {
111
- "/propertyPack/materialFacts/councilTax": {
111
+ "/propertyPack/councilTax": {
112
112
  councilTaxBand: "D",
113
113
  councilTaxAffectingAlterations: {
114
114
  yesNo: "Yes",
@@ -116,7 +116,7 @@ test("returns an empty array of errors for verified claim with multiple valid pa
116
116
  "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
117
117
  },
118
118
  },
119
- "/propertyPack/materialFacts/address": {
119
+ "/propertyPack/address": {
120
120
  line1: "property.line1",
121
121
  line2: "property.line2",
122
122
  town: "property.city",