@pdtf/schemas 3.0.0-5 → 3.0.0-6
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 +14 -13
- package/package.json +1 -1
- package/src/examples/v3/exampleTransaction.json +1 -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 +58 -56
- package/src/schemas/v3/overlays/baspi.json +507 -2288
- 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 +81 -367
- package/src/schemas/v3/overlays/piq.json +146 -686
- package/src/schemas/v3/overlays/rds.json +48 -316
- package/src/schemas/v3/overlays/ta10.json +540 -1755
- package/src/schemas/v3/overlays/ta6.json +263 -1145
- package/src/schemas/v3/overlays/ta7.json +220 -462
- package/src/schemas/v3/pdtf-transaction.json +67 -92
- package/src/tests/v3/transactionSchema.test.js +27 -16
- package/src/tests/v3/verifiedClaimsValidator.test.js +2 -2
- package/src/utils/extractOverlay.js +11 -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
|
);
|
package/package.json
CHANGED