@pdtf/schemas 3.0.0-3 → 3.0.0-31
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 +15 -13
- package/package.json +1 -1
- package/src/examples/v3/exampleAddParticipantVouch.json +32 -0
- package/src/examples/v3/exampleDocumentedVouch.json +40 -0
- package/src/examples/v3/exampleElectronicRecord.json +30 -0
- package/src/examples/v3/exampleTransaction.json +713 -665
- package/src/examples/v3/exampleVouch.json +25 -0
- package/src/schemas/v2/overlays/baspi.json +510 -2331
- package/src/schemas/v2/overlays/con29DW.json +36 -125
- package/src/schemas/v2/overlays/con29R.json +5 -143
- package/src/schemas/v2/overlays/fme1.json +48 -233
- package/src/schemas/v2/overlays/lpe1.json +75 -367
- package/src/schemas/v2/overlays/nts.json +17 -103
- package/src/schemas/v2/overlays/piq.json +146 -693
- package/src/schemas/v2/overlays/rds.json +50 -316
- package/src/schemas/v2/overlays/ta10.json +540 -1755
- package/src/schemas/v2/overlays/ta6.json +241 -1193
- package/src/schemas/v2/overlays/ta7.json +106 -440
- package/src/schemas/v3/combined.json +22591 -22479
- package/src/schemas/v3/overlays/baspi.json +5358 -7480
- package/src/schemas/v3/overlays/con29DW.json +537 -615
- package/src/schemas/v3/overlays/con29R.json +5 -143
- package/src/schemas/v3/overlays/fme1.json +1035 -1215
- package/src/schemas/v3/overlays/llc1.json +5 -5
- package/src/schemas/v3/overlays/lpe1.json +1782 -2024
- package/src/schemas/v3/overlays/nts.json +1393 -1329
- package/src/schemas/v3/overlays/oc1.json +821 -821
- package/src/schemas/v3/overlays/piq.json +2134 -2884
- package/src/schemas/v3/overlays/rds.json +2713 -3284
- package/src/schemas/v3/overlays/ta10.json +5286 -5530
- package/src/schemas/v3/overlays/ta6.json +2987 -3798
- package/src/schemas/v3/overlays/ta7.json +942 -1033
- package/src/schemas/v3/pdtf-transaction.json +19590 -18979
- package/src/schemas/v3/skeleton.json +2792 -2749
- package/src/tests/v3/transactionSchema.test.js +61 -59
- package/src/tests/v3/verifiedClaimsValidator.test.js +15 -15
- package/src/utils/extractOverlay.js +10 -27
- package/src/tests/v2/transactionSchema.test.js +0 -361
- package/src/tests/v2/verifiedClaimsValidator.test.js +0 -128
|
@@ -11,27 +11,26 @@ 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
|
|
20
|
-
const testSchema = getTransactionSchema();
|
|
21
|
-
expect(testSchema.$id).toEqual(
|
|
22
|
-
|
|
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
|
+
// );
|
|
25
|
+
expect(testSchema.properties.propertyPack.properties.baspiRef).toEqual(
|
|
26
|
+
undefined
|
|
23
27
|
);
|
|
24
|
-
expect(
|
|
25
|
-
testSchema.properties.propertyPack.properties.materialFacts.baspiRef
|
|
26
|
-
).toEqual("A");
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
test("sample is valid BASPI", () => {
|
|
30
|
-
const testSchema = getTransactionSchema();
|
|
31
|
-
expect(
|
|
32
|
-
|
|
33
|
-
).toEqual("A");
|
|
34
|
-
const validator = getValidator(schemaId);
|
|
31
|
+
const testSchema = getTransactionSchema(schemaId, ["baspiV4"]);
|
|
32
|
+
expect(testSchema.properties.propertyPack.baspiRef).toEqual("0");
|
|
33
|
+
const validator = getValidator(schemaId, ["baspiV4"]);
|
|
35
34
|
const isValid = validator(exampleTransaction);
|
|
36
35
|
if (!isValid) console.log(validator.errors);
|
|
37
36
|
expect(isValid).toBe(true);
|
|
@@ -48,8 +47,8 @@ test("invalid sample is invalid", () => {
|
|
|
48
47
|
const clonedExampleTransaction = JSON.parse(
|
|
49
48
|
JSON.stringify(exampleTransaction)
|
|
50
49
|
);
|
|
51
|
-
delete clonedExampleTransaction.propertyPack.
|
|
52
|
-
const validator = getValidator(schemaId);
|
|
50
|
+
delete clonedExampleTransaction.propertyPack.notices;
|
|
51
|
+
const validator = getValidator(schemaId, ["baspiV4"]);
|
|
53
52
|
const isValid = validator(clonedExampleTransaction);
|
|
54
53
|
expect(isValid).toBe(false);
|
|
55
54
|
});
|
|
@@ -58,7 +57,7 @@ test("sample with missing dependent required fields is invalid", () => {
|
|
|
58
57
|
const clonedExampleTransaction = JSON.parse(
|
|
59
58
|
JSON.stringify(exampleTransaction)
|
|
60
59
|
);
|
|
61
|
-
clonedExampleTransaction.propertyPack.
|
|
60
|
+
clonedExampleTransaction.propertyPack.ownership.ownershipsToBeTransferred[0].ownershipType =
|
|
62
61
|
"leasehold";
|
|
63
62
|
const validator = getValidator(schemaId);
|
|
64
63
|
const isValid = validator(clonedExampleTransaction);
|
|
@@ -71,7 +70,7 @@ test("correctly gets a top level subschema", () => {
|
|
|
71
70
|
});
|
|
72
71
|
|
|
73
72
|
test("correctly identifies a valid path", () => {
|
|
74
|
-
const isValid = isPathValid("/propertyPack
|
|
73
|
+
const isValid = isPathValid("/propertyPack");
|
|
75
74
|
expect(isValid).toBe(true);
|
|
76
75
|
});
|
|
77
76
|
|
|
@@ -89,15 +88,12 @@ test("correctly identifies an error generating invalid path", () => {
|
|
|
89
88
|
});
|
|
90
89
|
|
|
91
90
|
test("correctly identifies an array invalid path", () => {
|
|
92
|
-
const isValid = isPathValid("/propertyPack/
|
|
91
|
+
const isValid = isPathValid("/propertyPack/1/item");
|
|
93
92
|
expect(isValid).toBe(false);
|
|
94
93
|
});
|
|
95
94
|
|
|
96
95
|
test("correctly gets a subschema", () => {
|
|
97
|
-
const subschema = getSubschema(
|
|
98
|
-
"/propertyPack/materialFacts/notices",
|
|
99
|
-
schemaId
|
|
100
|
-
);
|
|
96
|
+
const subschema = getSubschema("/propertyPack/notices", schemaId);
|
|
101
97
|
expect(subschema.title).toBe("Notices which Affect the Property");
|
|
102
98
|
});
|
|
103
99
|
|
|
@@ -107,14 +103,14 @@ test("correctly gets a subschema through an arrays element", () => {
|
|
|
107
103
|
schemaId
|
|
108
104
|
);
|
|
109
105
|
expect(Object.keys(subschema.properties)).toEqual([
|
|
110
|
-
"
|
|
111
|
-
"
|
|
106
|
+
"ocSummaryData",
|
|
107
|
+
"ocRegisterData",
|
|
112
108
|
]);
|
|
113
109
|
});
|
|
114
110
|
|
|
115
111
|
test("correctly gets a subschema through a dependency", () => {
|
|
116
112
|
const subschema = getSubschema(
|
|
117
|
-
"/propertyPack/
|
|
113
|
+
"/propertyPack/delayFactors/hasDelayFactors/details",
|
|
118
114
|
schemaId
|
|
119
115
|
);
|
|
120
116
|
expect(subschema.title).toBe(
|
|
@@ -124,7 +120,7 @@ test("correctly gets a subschema through a dependency", () => {
|
|
|
124
120
|
|
|
125
121
|
test("correctly gets another subschema through a dependency", () => {
|
|
126
122
|
const subschema = getSubschema(
|
|
127
|
-
"/propertyPack/
|
|
123
|
+
"/propertyPack/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears",
|
|
128
124
|
schemaId
|
|
129
125
|
);
|
|
130
126
|
expect(subschema.title).toBe("Length of lease (years)");
|
|
@@ -132,14 +128,14 @@ test("correctly gets another subschema through a dependency", () => {
|
|
|
132
128
|
|
|
133
129
|
test("correctly gets yet another subschema through a dependency", () => {
|
|
134
130
|
const subschema = getSubschema(
|
|
135
|
-
"/propertyPack/
|
|
131
|
+
"/propertyPack/ownership/ownershipsToBeTransferred/0/leaseholdInformation/groundRent/rentSubjectToIncrease/rentIncreaseCalculated"
|
|
136
132
|
);
|
|
137
133
|
expect(subschema.title).toBe("How is the increase calculated?");
|
|
138
134
|
});
|
|
139
135
|
|
|
140
136
|
test("correctly gets yet, yet another subschema through a dependency", () => {
|
|
141
137
|
const subschema = getSubschema(
|
|
142
|
-
"/propertyPack/
|
|
138
|
+
"/propertyPack/listingAndConservation/isConservationArea/yesNo"
|
|
143
139
|
);
|
|
144
140
|
expect(subschema.type).toBe("string");
|
|
145
141
|
expect(subschema.enum).toStrictEqual(["Yes", "No", "Not known"]);
|
|
@@ -147,28 +143,37 @@ test("correctly gets yet, yet another subschema through a dependency", () => {
|
|
|
147
143
|
|
|
148
144
|
test("correctly gets yet, yet, yet another subschema through a second item dependency", () => {
|
|
149
145
|
const subschema = getSubschema(
|
|
150
|
-
"/propertyPack/
|
|
146
|
+
"/propertyPack/environmentalIssues/flooding/historicalFlooding/typeOfFlooding"
|
|
151
147
|
);
|
|
152
148
|
expect(subschema.type).toBe("array");
|
|
153
149
|
});
|
|
154
150
|
|
|
155
151
|
test("correctly gets yes another subschema but through a non-baspi oneOf structure", () => {
|
|
156
152
|
const subschema = getSubschema(
|
|
157
|
-
"/propertyPack/titlesToBeSold/0/registerExtract/
|
|
153
|
+
"/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/restrictionDetails/restrictionEntry/chargeRestriction/entryDetails/entryText"
|
|
158
154
|
);
|
|
159
155
|
expect(subschema).toEqual({ type: "string" });
|
|
160
156
|
});
|
|
161
157
|
|
|
162
158
|
test("correctly gets yes another subschema but through a non-baspi oneOf structure with array option", () => {
|
|
163
159
|
const subschema = getSubschema(
|
|
164
|
-
"/propertyPack/titlesToBeSold/0/registerExtract/
|
|
160
|
+
"/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/restrictionDetails/restrictionEntry/0/chargeRestriction/entryDetails/entryText"
|
|
165
161
|
);
|
|
166
162
|
expect(subschema).toEqual({ type: "string" });
|
|
167
163
|
});
|
|
168
164
|
|
|
165
|
+
test("correctly gets an overlaid enum in a subschema", () => {
|
|
166
|
+
const subschema = getSubschema(
|
|
167
|
+
"/propertyPack/electricity/mainsElectricity/yesNo",
|
|
168
|
+
schemaId,
|
|
169
|
+
["nts2023"]
|
|
170
|
+
);
|
|
171
|
+
expect(subschema.enum).toEqual(["Yes", "No"]);
|
|
172
|
+
});
|
|
173
|
+
|
|
169
174
|
test("correctly gets a subschema with multiple overlays", () => {
|
|
170
175
|
const subschema = getSubschema(
|
|
171
|
-
"/propertyPack/
|
|
176
|
+
"/propertyPack/parking/parkingArrangements",
|
|
172
177
|
schemaId,
|
|
173
178
|
["baspiV4", "ta6ed4"]
|
|
174
179
|
);
|
|
@@ -178,11 +183,11 @@ test("correctly gets a subschema with multiple overlays", () => {
|
|
|
178
183
|
|
|
179
184
|
test("correctly gets a subschema validator which is already cached", () => {
|
|
180
185
|
const validator = getSubschemaValidator(
|
|
181
|
-
"/propertyPack/
|
|
186
|
+
"/propertyPack/energyEfficiency/certificate"
|
|
182
187
|
);
|
|
183
188
|
expect(validator).not.toBeNull();
|
|
184
189
|
const anotherValidator = getSubschemaValidator(
|
|
185
|
-
"/propertyPack/
|
|
190
|
+
"/propertyPack/energyEfficiency/certificate"
|
|
186
191
|
);
|
|
187
192
|
expect(anotherValidator).not.toBeNull();
|
|
188
193
|
});
|
|
@@ -194,13 +199,12 @@ test("correctly gets a subschema validator for a TA6 overlay", () => {
|
|
|
194
199
|
"ta6ed4",
|
|
195
200
|
]);
|
|
196
201
|
let isValid = validator(data);
|
|
197
|
-
// console.log(validator.errors);
|
|
198
202
|
expect(isValid).toBe(true);
|
|
199
203
|
});
|
|
200
204
|
|
|
201
205
|
test("correctly gets a subschema validator for a TA6 overlay which validates", () => {
|
|
202
206
|
const path =
|
|
203
|
-
"/propertyPack/
|
|
207
|
+
"/propertyPack/guaranteesWarrantiesAndIndemnityInsurances/subsidenceWork";
|
|
204
208
|
const data = { yesNo: "Yes" };
|
|
205
209
|
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
206
210
|
"ta6ed4",
|
|
@@ -218,7 +222,7 @@ test("correctly gets a subschema validator for a TA6 overlay which validates wit
|
|
|
218
222
|
JSON.stringify(exampleTransaction)
|
|
219
223
|
);
|
|
220
224
|
const data = jp.get(exampleTransaction, path);
|
|
221
|
-
data.
|
|
225
|
+
data.uprn = undefined;
|
|
222
226
|
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
223
227
|
"ta6ed4",
|
|
224
228
|
]);
|
|
@@ -232,7 +236,7 @@ test("correctly gets a subschema validator for a TA6 overlay which validates wit
|
|
|
232
236
|
JSON.stringify(exampleTransaction)
|
|
233
237
|
);
|
|
234
238
|
const data = jp.get(clonedExampleTransaction, path);
|
|
235
|
-
data.
|
|
239
|
+
data.smartHomeSystems = undefined;
|
|
236
240
|
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
237
241
|
"ta6ed4",
|
|
238
242
|
]);
|
|
@@ -246,7 +250,7 @@ test("correctly gets a subschema validator for a TA6 overlay which fails to vali
|
|
|
246
250
|
JSON.stringify(exampleTransaction)
|
|
247
251
|
);
|
|
248
252
|
const data = jp.get(clonedExampleTransaction, path);
|
|
249
|
-
data.
|
|
253
|
+
data.waterAndDrainage = {};
|
|
250
254
|
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
251
255
|
"ta6ed4",
|
|
252
256
|
]);
|
|
@@ -267,21 +271,21 @@ test("correctly gets a subschema validator for an NTS overlay", () => {
|
|
|
267
271
|
expect(isValid).toBe(true);
|
|
268
272
|
});
|
|
269
273
|
|
|
270
|
-
test("correctly gets a subschema validator for an
|
|
274
|
+
test("correctly gets a subschema validator for an TA7 overlay", () => {
|
|
271
275
|
const path = "/propertyPack";
|
|
272
276
|
const clonedExampleTransaction = JSON.parse(
|
|
273
277
|
JSON.stringify(exampleTransaction)
|
|
274
278
|
);
|
|
275
279
|
const data = jp.get(clonedExampleTransaction, path);
|
|
276
280
|
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
277
|
-
"
|
|
281
|
+
"ta7ed3",
|
|
278
282
|
]);
|
|
279
283
|
let isValid = validator(data);
|
|
280
284
|
expect(isValid).toBe(false);
|
|
281
285
|
});
|
|
282
286
|
|
|
283
287
|
test("correctly gets a subschema validator which validates", () => {
|
|
284
|
-
const path = "/propertyPack/
|
|
288
|
+
const path = "/propertyPack/notices";
|
|
285
289
|
const validator = getSubschemaValidator(path);
|
|
286
290
|
const data = jp.get(exampleTransaction, path);
|
|
287
291
|
expect(data.neighbourDevelopment.yesNo).toBe("No");
|
|
@@ -296,55 +300,53 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
|
|
|
296
300
|
expect(
|
|
297
301
|
getTitleAtPath(
|
|
298
302
|
v3TransactionSchema,
|
|
299
|
-
"/propertyPack/
|
|
303
|
+
"/propertyPack/ownership/ownershipsToBeTransferred/0/ownershipType"
|
|
300
304
|
)
|
|
301
305
|
).toBe("What type of ownership is the property?");
|
|
306
|
+
|
|
302
307
|
expect(
|
|
303
308
|
getTitleAtPath(
|
|
304
309
|
v3TransactionSchema,
|
|
305
|
-
"/propertyPack/
|
|
310
|
+
"/propertyPack/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
|
|
306
311
|
)
|
|
307
312
|
).toBe("Length of lease (years)");
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
).toBe("Amount of current annual service charge (£)");
|
|
314
|
-
expect(
|
|
315
|
-
getTitleAtPath(
|
|
316
|
-
v3TransactionSchema,
|
|
317
|
-
"/propertyPack/materialFacts/invalidPath"
|
|
318
|
-
)
|
|
319
|
-
).toBe(undefined);
|
|
313
|
+
|
|
314
|
+
expect(getTitleAtPath(v3TransactionSchema, "/propertyPack/invalidPath")).toBe(
|
|
315
|
+
undefined
|
|
316
|
+
);
|
|
317
|
+
|
|
320
318
|
expect(
|
|
321
319
|
getTitleAtPath(
|
|
322
320
|
v3TransactionSchema,
|
|
323
321
|
"/propertyPack/titlesToBeSold/0/registerExtract"
|
|
324
322
|
)
|
|
325
323
|
).toBe("HMLR Official Copy Register Extract");
|
|
324
|
+
|
|
326
325
|
expect(
|
|
327
326
|
getTitleAtPath(
|
|
328
327
|
v3TransactionSchema,
|
|
329
|
-
"/propertyPack/titlesToBeSold/0/registerExtract/
|
|
328
|
+
"/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/propertyAddress"
|
|
330
329
|
)
|
|
331
330
|
).toBe("Property address");
|
|
331
|
+
|
|
332
332
|
expect(
|
|
333
333
|
getTitleAtPath(
|
|
334
334
|
v3TransactionSchema,
|
|
335
|
-
"/propertyPack/titlesToBeSold/0/registerExtract/
|
|
335
|
+
"/propertyPack/titlesToBeSold/0/registerExtract/ocSummaryData/invalidProp"
|
|
336
336
|
)
|
|
337
337
|
).toBe(undefined);
|
|
338
|
+
|
|
338
339
|
expect(
|
|
339
340
|
getTitleAtPath(
|
|
340
341
|
v3TransactionSchema,
|
|
341
|
-
"/propertyPack/
|
|
342
|
+
"/propertyPack/energyEfficiency/certificate/currentEnergyRating"
|
|
342
343
|
)
|
|
343
344
|
).toBe("Current energy efficiency rating");
|
|
345
|
+
|
|
344
346
|
expect(
|
|
345
347
|
getTitleAtPath(
|
|
346
348
|
v3TransactionSchema,
|
|
347
|
-
"/propertyPack/
|
|
349
|
+
"/propertyPack/occupiers/othersAged17OrOver/aged17OrOverNames"
|
|
348
350
|
)
|
|
349
351
|
).toBe("Please provide their full names and ages.");
|
|
350
352
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { validateVerifiedClaims } = require("../../../index.js");
|
|
2
2
|
|
|
3
|
-
const exampleVouch = require("../../examples/
|
|
4
|
-
const exampleDocumentedVouch = require("../../examples/
|
|
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,22 +19,22 @@ 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/
|
|
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/
|
|
26
|
+
"Path /propertyPack/INVALID/councilTax is not a valid PDTF schema path",
|
|
27
27
|
]);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test("returns errors if BASPI requirements are not met and BASPI overlay is specified
|
|
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/
|
|
33
|
+
"/propertyPack/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",
|
|
@@ -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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
100
|
-
"Path /propertyPack/
|
|
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/
|
|
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/
|
|
119
|
+
"/propertyPack/address": {
|
|
120
120
|
line1: "property.line1",
|
|
121
121
|
line2: "property.line2",
|
|
122
122
|
town: "property.city",
|
|
@@ -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
|
}
|
|
@@ -133,6 +116,11 @@ const extractOverlay = (sourceSchema, ref) => {
|
|
|
133
116
|
jp.set(returnSchema, `${path}/title`, element[refTitle]);
|
|
134
117
|
}
|
|
135
118
|
|
|
119
|
+
const refDescription = `${ref}Description`;
|
|
120
|
+
if (element[refDescription]) {
|
|
121
|
+
jp.set(returnSchema, `${path}/description`, element[refDescription]);
|
|
122
|
+
}
|
|
123
|
+
|
|
136
124
|
const refEnum = `${ref}Enum`;
|
|
137
125
|
if (element[refEnum]) {
|
|
138
126
|
jp.set(returnSchema, `${path}/enum`, element[refEnum]);
|
|
@@ -153,12 +141,7 @@ const deleteProperties = (sourceSchema, propertyNames) => {
|
|
|
153
141
|
const overlays = {};
|
|
154
142
|
|
|
155
143
|
extractFields.forEach((key) => {
|
|
156
|
-
let overlay = extractOverlay(combinedSchema, key
|
|
157
|
-
"title",
|
|
158
|
-
"description",
|
|
159
|
-
"enum",
|
|
160
|
-
"discriminator",
|
|
161
|
-
]);
|
|
144
|
+
let overlay = extractOverlay(combinedSchema, key);
|
|
162
145
|
overlays[key] = overlay;
|
|
163
146
|
const fileName = `../schemas/v3/overlays/${key}.json`;
|
|
164
147
|
fs.writeFileSync(fileName, JSON.stringify(overlay, null, 2));
|