@pdtf/schemas 2.0.0-4 → 2.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 CHANGED
@@ -45,7 +45,7 @@ const validator = ajv.compile(transactionSchema);
45
45
 
46
46
  // v2, via accessor functions and overlays
47
47
  const combinedSchema = require("./src/schemas/v2/combined.json");
48
- const coreSchema = require("./src/schemas/v2/core.json");
48
+ const v2CoreSchema = require("./src/schemas/v2/pdtf-transaction.json");
49
49
 
50
50
  const baspiOverlay = require("./src/schemas/v2/overlays/baspi.json");
51
51
  // const ta6Overlay = require("./src/schemas/v2/overlays/ta6.json");
@@ -58,12 +58,13 @@ const baspiOverlay = require("./src/schemas/v2/overlays/baspi.json");
58
58
  // const rdsOverlay = require("./src/schemas/v2/overlays/rds.json");
59
59
  // const oc1Overlay = require("./src/schemas/v2/overlays/oc1.json");
60
60
 
61
- const overlays = { baspiV4: baspiOverlay };
61
+ const overlays = { baspiV4: baspiOverlay, null: {} };
62
62
 
63
63
  const transactionSchemas = {
64
64
  "https://trust.propdata.org.uk/schemas/v1/pdtf-transaction.json":
65
65
  transactionSchema,
66
- "https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json": coreSchema,
66
+ "https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json":
67
+ v2CoreSchema,
67
68
  };
68
69
 
69
70
  const combineMerge = (target, source, options) => {
@@ -139,8 +140,8 @@ const isPathValid = (path, schemaId, overlay) => {
139
140
 
140
141
  const getSubschemaValidator = (path, schemaId, overlay) => {
141
142
  const subSchema = getSubschema(path, schemaId, overlay);
142
- // see if we can retrieve the schema by path
143
- const cacheKey = `${path}-${schemaId}`;
143
+ // see if we can retrieve the schema by path, schemaId and overlay
144
+ const cacheKey = `${path}-${schemaId}-${overlay}`;
144
145
  let validator = ajv.getSchema(cacheKey);
145
146
  // retrieve whole schema by $id if available
146
147
  if (!validator && subSchema.$id) validator = ajv.getSchema(cacheKey);
@@ -195,7 +196,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
195
196
  }
196
197
  };
197
198
 
198
- const validateVerifiedClaims = (verifiedClaims) => {
199
+ const validateVerifiedClaims = (verifiedClaims, schemaId, overlay) => {
199
200
  const validatorVClaims = ajv.compile(verifiedClaimsSchema);
200
201
 
201
202
  const validationErrorsArr = [];
@@ -213,11 +214,10 @@ const validateVerifiedClaims = (verifiedClaims) => {
213
214
 
214
215
  verifiedClaimsArray.forEach((claim) => {
215
216
  const paths = Object.keys(claim.claims);
216
-
217
217
  for (const path of paths) {
218
- const validPath = isPathValid(path);
218
+ const validPath = isPathValid(path, schemaId, overlay);
219
219
  if (validPath) {
220
- const subValidator = getSubschemaValidator(path);
220
+ const subValidator = getSubschemaValidator(path, schemaId, overlay);
221
221
  const isValid = subValidator(claim.claims[path]);
222
222
  if (!isValid) {
223
223
  validationErrorsArr.push(...subValidator.errors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "2.0.0-4",
3
+ "version": "2.0.0-6",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -307,7 +307,7 @@
307
307
  }
308
308
  }
309
309
  },
310
- "utilities": {
310
+ "connectedUtilities": {
311
311
  "electricity": {
312
312
  "maintenanceAgreements": {
313
313
  "yesNo": "No"