@pdtf/schemas 2.0.0-9 → 2.0.0
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 +47 -30
- package/package.json +1 -1
- package/src/examples/v2/exampleTransaction.json +152 -109
- package/src/schemas/v2/combined.json +9070 -1384
- package/src/schemas/v2/overlays/baspi.json +1864 -947
- package/src/schemas/v2/overlays/con29DW.json +256 -127
- package/src/schemas/v2/overlays/fme1.json +46 -212
- package/src/schemas/v2/overlays/lpe1.json +77 -48
- package/src/schemas/v2/overlays/nts.json +1 -1
- package/src/schemas/v2/overlays/piq.json +3103 -0
- package/src/schemas/v2/overlays/rds.json +680 -448
- package/src/schemas/v2/overlays/ta10.json +847 -1
- package/src/schemas/v2/overlays/ta6.json +3719 -560
- package/src/schemas/v2/overlays/ta7.json +77 -12
- package/src/schemas/v2/pdtf-transaction.json +7752 -1121
- package/src/schemas/v2/skeleton.json +3647 -0
- package/src/tests/v2/transactionSchema.test.js +80 -3
- package/src/utils/extractOverlay.js +50 -1
- package/src/utils/hmlrLLC1.json +275 -0
|
@@ -111,7 +111,7 @@ test("correctly gets a subschema through a dependency", () => {
|
|
|
111
111
|
schemaId
|
|
112
112
|
);
|
|
113
113
|
expect(subschema.title).toBe(
|
|
114
|
-
"Provide details and likely timescale for delay
|
|
114
|
+
"Provide details and likely timescale for delay"
|
|
115
115
|
);
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -135,12 +135,12 @@ test("correctly gets yet, yet another subschema through a dependency", () => {
|
|
|
135
135
|
"/propertyPack/materialFacts/listingAndConservation/isConservationArea/yesNo"
|
|
136
136
|
);
|
|
137
137
|
expect(subschema.type).toBe("string");
|
|
138
|
-
expect(subschema.enum).toStrictEqual(["Yes", "No"]);
|
|
138
|
+
expect(subschema.enum).toStrictEqual(["Yes", "No", "Not known"]);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
test("correctly gets yet, yet, yet another subschema through a dependency", () => {
|
|
142
142
|
const subschema = getSubschema(
|
|
143
|
-
"/propertyPack/materialFacts/environmentalIssues/flooding/typeOfFlooding/
|
|
143
|
+
"/propertyPack/materialFacts/environmentalIssues/flooding/typeOfFlooding/other/yesNo"
|
|
144
144
|
);
|
|
145
145
|
expect(subschema.type).toBe("string");
|
|
146
146
|
expect(subschema.enum).toStrictEqual(["Yes", "No"]);
|
|
@@ -167,6 +167,16 @@ test("correctly gets yes another subschema but through a non-baspi oneOf structu
|
|
|
167
167
|
expect(subschema).toEqual({ type: "string" });
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
+
test("correctly gets a subschema with multiple overlays", () => {
|
|
171
|
+
const subschema = getSubschema(
|
|
172
|
+
"/propertyPack/materialFacts/parking/parkingArrangements",
|
|
173
|
+
schemaId,
|
|
174
|
+
["baspiV4", "ta6ed4"]
|
|
175
|
+
);
|
|
176
|
+
expect(subschema.baspiRef).toBe("A1.6.0");
|
|
177
|
+
expect(subschema.ta6Ref).toBe("9.1");
|
|
178
|
+
});
|
|
179
|
+
|
|
170
180
|
test("correctly gets a subschema validator which is already cached", () => {
|
|
171
181
|
const validator = getSubschemaValidator(
|
|
172
182
|
"/propertyPack/materialFacts/energyEfficiency/certificate"
|
|
@@ -178,6 +188,73 @@ test("correctly gets a subschema validator which is already cached", () => {
|
|
|
178
188
|
expect(anotherValidator).not.toBeNull();
|
|
179
189
|
});
|
|
180
190
|
|
|
191
|
+
test("correctly gets a subschema validator for a TA6 overlay", () => {
|
|
192
|
+
const path = "/propertyPack";
|
|
193
|
+
const data = jp.get(exampleTransaction, path);
|
|
194
|
+
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
195
|
+
"ta6ed4",
|
|
196
|
+
]);
|
|
197
|
+
let isValid = validator(data);
|
|
198
|
+
// console.log(validator.errors);
|
|
199
|
+
expect(isValid).toBe(true);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("correctly gets a subschema validator for a TA6 overlay which validates", () => {
|
|
203
|
+
const path =
|
|
204
|
+
"/propertyPack/additionalLegalInfo/guaranteesWarrantiesAndIndemnityInsurances/subsidenceWork";
|
|
205
|
+
const data = { yesNo: "Yes" };
|
|
206
|
+
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
207
|
+
"ta6ed4",
|
|
208
|
+
]);
|
|
209
|
+
let isValid = validator(data);
|
|
210
|
+
expect(isValid).toBe(false);
|
|
211
|
+
expect(validator.errors[0].message).toBe(
|
|
212
|
+
"must have required property 'attachments'"
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test("correctly gets a subschema validator for a TA6 overlay which validates with non-TA6 field missing", () => {
|
|
217
|
+
const path = "/propertyPack";
|
|
218
|
+
const clonedExampleTransaction = JSON.parse(
|
|
219
|
+
JSON.stringify(exampleTransaction)
|
|
220
|
+
);
|
|
221
|
+
const data = jp.get(exampleTransaction, path);
|
|
222
|
+
data.materialFacts.uprn = undefined;
|
|
223
|
+
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
224
|
+
"ta6ed4",
|
|
225
|
+
]);
|
|
226
|
+
let isValid = validator(data);
|
|
227
|
+
expect(isValid).toBe(true);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("correctly gets a subschema validator for a TA6 overlay which validates with non-TA6 section missing", () => {
|
|
231
|
+
const path = "/propertyPack";
|
|
232
|
+
const clonedExampleTransaction = JSON.parse(
|
|
233
|
+
JSON.stringify(exampleTransaction)
|
|
234
|
+
);
|
|
235
|
+
const data = jp.get(clonedExampleTransaction, path);
|
|
236
|
+
data.additionalLegalInfo.smartHomeSystems = undefined;
|
|
237
|
+
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
238
|
+
"ta6ed4",
|
|
239
|
+
]);
|
|
240
|
+
let isValid = validator(data);
|
|
241
|
+
expect(isValid).toBe(true);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("correctly gets a subschema validator for a TA6 overlay which fails to validate with BASPI/TA6 section missing", () => {
|
|
245
|
+
const path = "/propertyPack";
|
|
246
|
+
const clonedExampleTransaction = JSON.parse(
|
|
247
|
+
JSON.stringify(exampleTransaction)
|
|
248
|
+
);
|
|
249
|
+
const data = jp.get(clonedExampleTransaction, path);
|
|
250
|
+
data.materialFacts.waterAndDrainage = {};
|
|
251
|
+
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
252
|
+
"ta6ed4",
|
|
253
|
+
]);
|
|
254
|
+
let isValid = validator(data);
|
|
255
|
+
expect(isValid).toBe(false);
|
|
256
|
+
});
|
|
257
|
+
|
|
181
258
|
test("correctly gets a subschema validator which validates", () => {
|
|
182
259
|
const path = "/propertyPack/materialFacts/notices";
|
|
183
260
|
const validator = getSubschemaValidator(path);
|
|
@@ -14,6 +14,7 @@ const extractFields = [
|
|
|
14
14
|
"ta10",
|
|
15
15
|
"lpe1",
|
|
16
16
|
"fme1",
|
|
17
|
+
"piq",
|
|
17
18
|
"con29R",
|
|
18
19
|
"con29DW",
|
|
19
20
|
"llc1",
|
|
@@ -43,9 +44,34 @@ const combineMerge = (target, source, options) => {
|
|
|
43
44
|
return destination;
|
|
44
45
|
};
|
|
45
46
|
|
|
47
|
+
const flattenSkeleton = (schema) => {
|
|
48
|
+
if (!schema) return undefined;
|
|
49
|
+
// console.log(schema.properties);
|
|
50
|
+
let returnStructure = {};
|
|
51
|
+
if (schema.properties) {
|
|
52
|
+
Object.keys(schema.properties).forEach((key) => {
|
|
53
|
+
returnStructure[key] = flattenSkeleton(schema.properties[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (schema.oneOf) {
|
|
57
|
+
schema.oneOf.forEach((aOneOf) => {
|
|
58
|
+
// console.log(aOneOf);
|
|
59
|
+
if (aOneOf.properties) {
|
|
60
|
+
Object.entries(aOneOf.properties).forEach(([key, value]) => {
|
|
61
|
+
// console.log(aProperty);
|
|
62
|
+
returnStructure[key] = flattenSkeleton(value);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (schema.items) {
|
|
68
|
+
returnStructure = flattenSkeleton(schema.items);
|
|
69
|
+
}
|
|
70
|
+
return returnStructure;
|
|
71
|
+
};
|
|
72
|
+
|
|
46
73
|
const extractOverlay = (sourceSchema, ref) => {
|
|
47
74
|
const refName = `${ref}Ref`;
|
|
48
|
-
const refRequired = `${ref}Required`;
|
|
49
75
|
const returnSchema = {
|
|
50
76
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
51
77
|
$id: `https://trust.propdata.org.uk/schemas/v2/overlays/${ref}.json`,
|
|
@@ -74,6 +100,7 @@ const extractOverlay = (sourceSchema, ref) => {
|
|
|
74
100
|
});
|
|
75
101
|
}
|
|
76
102
|
}
|
|
103
|
+
const refRequired = `${ref}Required`;
|
|
77
104
|
if (element[refRequired]) {
|
|
78
105
|
jp.set(returnSchema, `${path}/required`, element[refRequired]);
|
|
79
106
|
}
|
|
@@ -116,3 +143,25 @@ fs.writeFileSync(
|
|
|
116
143
|
JSON.stringify(coreSchema, null, 2)
|
|
117
144
|
);
|
|
118
145
|
console.log("Core schema written to ../schemas/v2/pdtf-transaction.json");
|
|
146
|
+
|
|
147
|
+
const skeletonSchema = deleteProperties(coreSchema, [
|
|
148
|
+
"$schema",
|
|
149
|
+
"$id",
|
|
150
|
+
"title",
|
|
151
|
+
"description",
|
|
152
|
+
"required",
|
|
153
|
+
"enum",
|
|
154
|
+
"minItems",
|
|
155
|
+
"minLength",
|
|
156
|
+
"format",
|
|
157
|
+
"minimum",
|
|
158
|
+
"maximum",
|
|
159
|
+
]);
|
|
160
|
+
|
|
161
|
+
const skeletonSchemaFlattened = flattenSkeleton(skeletonSchema);
|
|
162
|
+
|
|
163
|
+
fs.writeFileSync(
|
|
164
|
+
"../schemas/v2/skeleton.json",
|
|
165
|
+
JSON.stringify(skeletonSchemaFlattened, null, 2)
|
|
166
|
+
);
|
|
167
|
+
console.log("Flat Skeleton schema written to ../schemas/v2/skeleton.json");
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "http://www.landregistry.gov.uk/LLC/LLCSearchResponseV2_0#",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"LocalLandCharge": {
|
|
7
|
+
"type": "array",
|
|
8
|
+
"items": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"required": [
|
|
11
|
+
"HMLRReference",
|
|
12
|
+
"RegistrationDate",
|
|
13
|
+
"Category",
|
|
14
|
+
"Location",
|
|
15
|
+
"LocationDominantBuilding"
|
|
16
|
+
],
|
|
17
|
+
"properties": {
|
|
18
|
+
"HMLRReference": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"OriginatingAuthority": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"AuthorityReference": {
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"CreationDate": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"Value": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "date"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"RegistrationDate": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"Value": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"format": "date"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"Category": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
},
|
|
48
|
+
"ChargeSubCategory": {
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
"Law": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"LegalDocument": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"Location": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": ["AddressLine"],
|
|
60
|
+
"properties": {
|
|
61
|
+
"PostcodeZone": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"required": ["Postcode"],
|
|
64
|
+
"properties": {
|
|
65
|
+
"Postcode": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"AddressLine": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": {
|
|
73
|
+
"IndexNumeric": {
|
|
74
|
+
"type": "array",
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"properties": {
|
|
78
|
+
"Value": {
|
|
79
|
+
"type": "number"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"minItems": 0
|
|
84
|
+
},
|
|
85
|
+
"Line": {
|
|
86
|
+
"type": "array",
|
|
87
|
+
"items": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"minItems": 0
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"LocationDominantBuilding": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"required": ["AddressLine"],
|
|
99
|
+
"properties": {
|
|
100
|
+
"PostcodeZone": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"required": ["Postcode"],
|
|
103
|
+
"properties": {
|
|
104
|
+
"Postcode": {
|
|
105
|
+
"type": "string"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"AddressLine": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": {
|
|
112
|
+
"IndexNumeric": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"items": {
|
|
115
|
+
"type": "number"
|
|
116
|
+
},
|
|
117
|
+
"minItems": 0
|
|
118
|
+
},
|
|
119
|
+
"Line": {
|
|
120
|
+
"type": "array",
|
|
121
|
+
"items": {
|
|
122
|
+
"type": "string"
|
|
123
|
+
},
|
|
124
|
+
"minItems": 0
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"Description": {
|
|
131
|
+
"type": "string"
|
|
132
|
+
},
|
|
133
|
+
"SourceOfInformation": {
|
|
134
|
+
"type": "string"
|
|
135
|
+
},
|
|
136
|
+
"AvailableDocument": {
|
|
137
|
+
"type": "array",
|
|
138
|
+
"items": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"required": ["Document"],
|
|
141
|
+
"properties": {
|
|
142
|
+
"Document": {
|
|
143
|
+
"type": "string"
|
|
144
|
+
},
|
|
145
|
+
"StartDate": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"format": "date"
|
|
148
|
+
},
|
|
149
|
+
"EndDate": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"format": "date"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"minItems": 0
|
|
156
|
+
},
|
|
157
|
+
"InterestInLand": {
|
|
158
|
+
"type": "string"
|
|
159
|
+
},
|
|
160
|
+
"ApplicantName": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
},
|
|
163
|
+
"ApplicantAddress": {
|
|
164
|
+
"type": "object",
|
|
165
|
+
"required": ["AddressLine"],
|
|
166
|
+
"properties": {
|
|
167
|
+
"PostcodeZone": {
|
|
168
|
+
"type": "object",
|
|
169
|
+
"required": ["Postcode"],
|
|
170
|
+
"properties": {
|
|
171
|
+
"Postcode": {
|
|
172
|
+
"type": "string"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"AddressLine": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"properties": {
|
|
179
|
+
"IndexNumeric": {
|
|
180
|
+
"type": "array",
|
|
181
|
+
"items": {
|
|
182
|
+
"type": "object",
|
|
183
|
+
"properties": {
|
|
184
|
+
"Value": {
|
|
185
|
+
"type": "number"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"minItems": 0
|
|
190
|
+
},
|
|
191
|
+
"Line": {
|
|
192
|
+
"type": "array",
|
|
193
|
+
"items": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"properties": {
|
|
196
|
+
"Value": {
|
|
197
|
+
"type": "string"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"minItems": 0
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"ServientLandDevelopment": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"required": ["Height", "CoversAllOrPartOfExtent"],
|
|
210
|
+
"properties": {
|
|
211
|
+
"Height": {
|
|
212
|
+
"type": "string"
|
|
213
|
+
},
|
|
214
|
+
"CoversAllOrPartOfExtent": {
|
|
215
|
+
"type": "string"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"Amount": {
|
|
220
|
+
"type": "string"
|
|
221
|
+
},
|
|
222
|
+
"InterestRate": {
|
|
223
|
+
"type": "string"
|
|
224
|
+
},
|
|
225
|
+
"LandSold": {
|
|
226
|
+
"type": "string"
|
|
227
|
+
},
|
|
228
|
+
"WorksDone": {
|
|
229
|
+
"type": "string"
|
|
230
|
+
},
|
|
231
|
+
"AdvancePayment": {
|
|
232
|
+
"type": "string"
|
|
233
|
+
},
|
|
234
|
+
"TotalCompensation": {
|
|
235
|
+
"type": "string"
|
|
236
|
+
},
|
|
237
|
+
"AgreedOrEstimated": {
|
|
238
|
+
"type": "string"
|
|
239
|
+
},
|
|
240
|
+
"Adjoining": {
|
|
241
|
+
"type": "boolean"
|
|
242
|
+
},
|
|
243
|
+
"OtherData": {
|
|
244
|
+
"type": "array",
|
|
245
|
+
"items": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"required": ["DataLabel", "Data"],
|
|
248
|
+
"properties": {
|
|
249
|
+
"DataLabel": {
|
|
250
|
+
"type": "string"
|
|
251
|
+
},
|
|
252
|
+
"Data": {
|
|
253
|
+
"type": "string"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"minItems": 0
|
|
258
|
+
},
|
|
259
|
+
"ChargeExtent": {
|
|
260
|
+
"type": "object",
|
|
261
|
+
"properties": {
|
|
262
|
+
"Value": {
|
|
263
|
+
"type": "string"
|
|
264
|
+
},
|
|
265
|
+
"format": {
|
|
266
|
+
"type": "string"
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"minItems": 0
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|