@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.
- package/index.js +15 -13
- package/package.json +1 -1
- package/src/examples/v3/exampleTransaction.json +10 -6
- 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 +421 -255
- package/src/schemas/v3/overlays/baspi.json +510 -2300
- package/src/schemas/v3/overlays/con29DW.json +36 -125
- package/src/schemas/v3/overlays/con29R.json +5 -143
- package/src/schemas/v3/overlays/fme1.json +53 -233
- package/src/schemas/v3/overlays/lpe1.json +85 -367
- package/src/schemas/v3/overlays/nts.json +409 -346
- package/src/schemas/v3/overlays/piq.json +149 -689
- package/src/schemas/v3/overlays/rds.json +61 -329
- package/src/schemas/v3/overlays/ta10.json +540 -1755
- package/src/schemas/v3/overlays/ta6.json +261 -1136
- package/src/schemas/v3/overlays/ta7.json +220 -462
- package/src/schemas/v3/pdtf-transaction.json +355 -268
- package/src/schemas/v3/skeleton.json +57 -25
- package/src/tests/v3/transactionSchema.test.js +27 -16
- package/src/tests/v3/verifiedClaimsValidator.test.js +2 -2
- package/src/utils/extractOverlay.js +5 -27
- package/src/tests/v2/transactionSchema.test.js +0 -361
- package/src/tests/v2/verifiedClaimsValidator.test.js +0 -128
package/index.js
CHANGED
|
@@ -71,16 +71,23 @@ const combineMerge = (target, source, options) => {
|
|
|
71
71
|
return destination;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
const mergeEnums = (target, source) => source;
|
|
75
|
+
|
|
74
76
|
const getTransactionSchema = (
|
|
75
77
|
schemaId = "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json",
|
|
76
|
-
overlays = ["baspiV4"]
|
|
78
|
+
overlays // = ["baspiV4"]
|
|
77
79
|
) => {
|
|
78
80
|
const sourceSchema = transactionSchemas[schemaId];
|
|
79
81
|
if (!overlays || overlays.length < 1) return sourceSchema;
|
|
80
82
|
let mergedSchema = sourceSchema;
|
|
81
83
|
overlays.forEach((overlay) => {
|
|
82
84
|
const overlaySchema = overlaysMap[schemaId][overlay] || {};
|
|
83
|
-
mergedSchema = merge(
|
|
85
|
+
mergedSchema = merge(mergedSchema, overlaySchema, {
|
|
86
|
+
customMerge: (key) => {
|
|
87
|
+
if (key === "enum") {
|
|
88
|
+
return mergeEnums;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
84
91
|
arrayMerge: combineMerge,
|
|
85
92
|
});
|
|
86
93
|
});
|
|
@@ -88,13 +95,7 @@ const getTransactionSchema = (
|
|
|
88
95
|
};
|
|
89
96
|
|
|
90
97
|
const getValidator = (schemaId, overlays) => {
|
|
91
|
-
|
|
92
|
-
if (!validator) {
|
|
93
|
-
const schema = getTransactionSchema(schemaId, overlays);
|
|
94
|
-
ajv.addSchema(schema, schemaId);
|
|
95
|
-
validator = ajv.getSchema(schemaId);
|
|
96
|
-
}
|
|
97
|
-
return validator;
|
|
98
|
+
return getSubschemaValidator("", schemaId, overlays);
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
// common functions for v1 and v2
|
|
@@ -129,7 +130,7 @@ const isPathValid = (path, schemaId, overlays) => {
|
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
132
|
|
|
132
|
-
const getSubschemaValidator = (path, schemaId, overlays
|
|
133
|
+
const getSubschemaValidator = (path, schemaId, overlays) => {
|
|
133
134
|
const subSchema = getSubschema(path, schemaId, overlays);
|
|
134
135
|
const overlayKey = (overlays || []).join(".");
|
|
135
136
|
// see if we can retrieve the schema by path, schemaId and overlays
|
|
@@ -162,6 +163,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
162
163
|
}
|
|
163
164
|
const propertyName = pathArray.shift();
|
|
164
165
|
const subPath = "/" + pathArray.join("/");
|
|
166
|
+
|
|
165
167
|
let subSchema = schema.properties
|
|
166
168
|
? schema.properties[propertyName]
|
|
167
169
|
: undefined;
|
|
@@ -172,10 +174,9 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
172
174
|
subSchema = schema.items;
|
|
173
175
|
return getTitleAtPath(subSchema, subPath, rootPath);
|
|
174
176
|
}
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
+
const oneOfs = schema.oneOf;
|
|
178
|
+
if (oneOfs) {
|
|
177
179
|
// only single dependency discriminator, oneOf keyword is supported
|
|
178
|
-
const oneOfs = schema.oneOf;
|
|
179
180
|
const matchingOneOf = oneOfs.find(
|
|
180
181
|
(oneOf) => oneOf["properties"][propertyName]
|
|
181
182
|
);
|
|
@@ -235,4 +236,5 @@ module.exports = {
|
|
|
235
236
|
getTitleAtPath,
|
|
236
237
|
verifiedClaimsSchema,
|
|
237
238
|
validateVerifiedClaims,
|
|
239
|
+
overlaysMap,
|
|
238
240
|
};
|
package/package.json
CHANGED
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"town": "HARPENDEN",
|
|
40
40
|
"postcode": "AL3 5AF"
|
|
41
41
|
},
|
|
42
|
+
"localAuthority": { "localAuthorityName": "Neverland Hook" },
|
|
43
|
+
"buildInformation": {
|
|
44
|
+
"building": { "propertyType": "House", "builtForm": "Detached" }
|
|
45
|
+
},
|
|
42
46
|
"delayFactors": {
|
|
43
47
|
"hasDelayFactors": { "yesNo": "No" }
|
|
44
48
|
},
|
|
@@ -299,8 +303,8 @@
|
|
|
299
303
|
"waterAndDrainage": {
|
|
300
304
|
"water": {
|
|
301
305
|
"mainsWater": {
|
|
302
|
-
"yesNo": "
|
|
303
|
-
"
|
|
306
|
+
"yesNo": "Yes",
|
|
307
|
+
"isSupplyMetered": "Yes",
|
|
304
308
|
"supplier": "Northumbria Water"
|
|
305
309
|
}
|
|
306
310
|
},
|
|
@@ -462,7 +466,7 @@
|
|
|
462
466
|
"environmentalIssues": {
|
|
463
467
|
"flooding": {
|
|
464
468
|
"floodRisk": {
|
|
465
|
-
"
|
|
469
|
+
"riskIndicator": "Yes",
|
|
466
470
|
"summary": "Likely to flood from surface water"
|
|
467
471
|
},
|
|
468
472
|
"hasBeenFlooded": "Yes",
|
|
@@ -474,13 +478,13 @@
|
|
|
474
478
|
"remedialMeasuresOnConstruction": { "yesNo": "No" }
|
|
475
479
|
},
|
|
476
480
|
"coalMining": {
|
|
477
|
-
"
|
|
481
|
+
"riskIndicator": "No"
|
|
478
482
|
},
|
|
479
483
|
"nonCoalMining": {
|
|
480
|
-
"
|
|
484
|
+
"riskIndicator": "No"
|
|
481
485
|
},
|
|
482
486
|
"coastalErosion": {
|
|
483
|
-
"
|
|
487
|
+
"riskIndicator": "No"
|
|
484
488
|
},
|
|
485
489
|
"otherEnvironmental": {
|
|
486
490
|
"yesNo": "No"
|