@pdtf/schemas 3.0.0-5 → 3.0.0-7

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.
Files changed (32) hide show
  1. package/index.js +14 -13
  2. package/package.json +1 -1
  3. package/src/examples/v3/exampleTransaction.json +1 -0
  4. package/src/schemas/v2/overlays/baspi.json +510 -2331
  5. package/src/schemas/v2/overlays/con29DW.json +36 -125
  6. package/src/schemas/v2/overlays/con29R.json +5 -143
  7. package/src/schemas/v2/overlays/fme1.json +48 -233
  8. package/src/schemas/v2/overlays/lpe1.json +75 -367
  9. package/src/schemas/v2/overlays/nts.json +17 -103
  10. package/src/schemas/v2/overlays/piq.json +146 -693
  11. package/src/schemas/v2/overlays/rds.json +50 -316
  12. package/src/schemas/v2/overlays/ta10.json +540 -1755
  13. package/src/schemas/v2/overlays/ta6.json +241 -1193
  14. package/src/schemas/v2/overlays/ta7.json +106 -440
  15. package/src/schemas/v3/combined.json +80 -64
  16. package/src/schemas/v3/overlays/baspi.json +508 -2289
  17. package/src/schemas/v3/overlays/con29DW.json +36 -125
  18. package/src/schemas/v3/overlays/con29R.json +5 -143
  19. package/src/schemas/v3/overlays/fme1.json +53 -233
  20. package/src/schemas/v3/overlays/lpe1.json +85 -367
  21. package/src/schemas/v3/overlays/nts.json +131 -367
  22. package/src/schemas/v3/overlays/piq.json +146 -686
  23. package/src/schemas/v3/overlays/rds.json +49 -317
  24. package/src/schemas/v3/overlays/ta10.json +540 -1755
  25. package/src/schemas/v3/overlays/ta6.json +264 -1146
  26. package/src/schemas/v3/overlays/ta7.json +220 -462
  27. package/src/schemas/v3/pdtf-transaction.json +74 -98
  28. package/src/tests/v3/transactionSchema.test.js +27 -16
  29. package/src/tests/v3/verifiedClaimsValidator.test.js +2 -2
  30. package/src/utils/extractOverlay.js +11 -27
  31. package/src/tests/v2/transactionSchema.test.js +0 -361
  32. 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(overlaySchema, mergedSchema, {
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
- let validator = ajv.getSchema(schemaId);
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 = ["baspiV4"]) => {
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 discriminator = schema.discriminator?.propertyName;
176
- if (discriminator) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "3.0.0-5",
3
+ "version": "3.0.0-7",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -39,6 +39,7 @@
39
39
  "town": "HARPENDEN",
40
40
  "postcode": "AL3 5AF"
41
41
  },
42
+ "localAuthority": { "localAuthorityName": "Neverland Hook" },
42
43
  "buildInformation": {
43
44
  "building": { "propertyType": "House", "builtForm": "Detached" }
44
45
  },