@pdtf/schemas 3.0.0-3 → 3.0.0-31

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 (39) hide show
  1. package/index.js +15 -13
  2. package/package.json +1 -1
  3. package/src/examples/v3/exampleAddParticipantVouch.json +32 -0
  4. package/src/examples/v3/exampleDocumentedVouch.json +40 -0
  5. package/src/examples/v3/exampleElectronicRecord.json +30 -0
  6. package/src/examples/v3/exampleTransaction.json +713 -665
  7. package/src/examples/v3/exampleVouch.json +25 -0
  8. package/src/schemas/v2/overlays/baspi.json +510 -2331
  9. package/src/schemas/v2/overlays/con29DW.json +36 -125
  10. package/src/schemas/v2/overlays/con29R.json +5 -143
  11. package/src/schemas/v2/overlays/fme1.json +48 -233
  12. package/src/schemas/v2/overlays/lpe1.json +75 -367
  13. package/src/schemas/v2/overlays/nts.json +17 -103
  14. package/src/schemas/v2/overlays/piq.json +146 -693
  15. package/src/schemas/v2/overlays/rds.json +50 -316
  16. package/src/schemas/v2/overlays/ta10.json +540 -1755
  17. package/src/schemas/v2/overlays/ta6.json +241 -1193
  18. package/src/schemas/v2/overlays/ta7.json +106 -440
  19. package/src/schemas/v3/combined.json +22591 -22479
  20. package/src/schemas/v3/overlays/baspi.json +5358 -7480
  21. package/src/schemas/v3/overlays/con29DW.json +537 -615
  22. package/src/schemas/v3/overlays/con29R.json +5 -143
  23. package/src/schemas/v3/overlays/fme1.json +1035 -1215
  24. package/src/schemas/v3/overlays/llc1.json +5 -5
  25. package/src/schemas/v3/overlays/lpe1.json +1782 -2024
  26. package/src/schemas/v3/overlays/nts.json +1393 -1329
  27. package/src/schemas/v3/overlays/oc1.json +821 -821
  28. package/src/schemas/v3/overlays/piq.json +2134 -2884
  29. package/src/schemas/v3/overlays/rds.json +2713 -3284
  30. package/src/schemas/v3/overlays/ta10.json +5286 -5530
  31. package/src/schemas/v3/overlays/ta6.json +2987 -3798
  32. package/src/schemas/v3/overlays/ta7.json +942 -1033
  33. package/src/schemas/v3/pdtf-transaction.json +19590 -18979
  34. package/src/schemas/v3/skeleton.json +2792 -2749
  35. package/src/tests/v3/transactionSchema.test.js +61 -59
  36. package/src/tests/v3/verifiedClaimsValidator.test.js +15 -15
  37. package/src/utils/extractOverlay.js +10 -27
  38. package/src/tests/v2/transactionSchema.test.js +0 -361
  39. 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
  );
@@ -235,4 +236,5 @@ module.exports = {
235
236
  getTitleAtPath,
236
237
  verifiedClaimsSchema,
237
238
  validateVerifiedClaims,
239
+ overlaysMap,
238
240
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "3.0.0-3",
3
+ "version": "3.0.0-31",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,32 @@
1
+ {
2
+ "verification": {
3
+ "trust_framework": "uk_pdtf",
4
+ "time": "2022-01-25T13:05:03.108Z",
5
+ "evidence": [
6
+ {
7
+ "type": "vouch",
8
+ "attestation": {
9
+ "type": "digital_attestation",
10
+ "voucher": {
11
+ "name": "Martin Abode"
12
+ }
13
+ },
14
+ "verification_method": {
15
+ "type": "auth"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ "claims": {
21
+ "/participants/-": {
22
+ "name": {
23
+ "firstName": "Martin",
24
+ "lastName": "Abode"
25
+ },
26
+ "email": "martin@abode.co.uk",
27
+ "organisation": "Abode and Floggit Estate Agents",
28
+ "organisationReference": "MAR/12243/22",
29
+ "role": "Estate Agent"
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "verification": {
3
+ "trust_framework": "uk_pdtf",
4
+ "time": "2022-01-25T13:16:44.527Z",
5
+ "evidence": [
6
+ {
7
+ "type": "vouch",
8
+ "attachments": [
9
+ {
10
+ "digest": {
11
+ "alg": "md5",
12
+ "value": "randomHashValue"
13
+ },
14
+ "url": "https://fakeFileStore.com/some/kind/of/file",
15
+ "desc": "proofOfAddress.pdf",
16
+ "pdtfSchemaPath": "/propertyPack/materialFacts/councilTax/councilTaxAffectingAlterations/details"
17
+ }
18
+ ],
19
+ "verification_method": {
20
+ "type": "auth"
21
+ },
22
+ "attestation": {
23
+ "voucher": {
24
+ "name": "Maria Harris"
25
+ },
26
+ "type": "digital_attestation"
27
+ }
28
+ }
29
+ ]
30
+ },
31
+ "claims": {
32
+ "/propertyPack/councilTax": {
33
+ "councilTaxBand": "D",
34
+ "councilTaxAffectingAlterations": {
35
+ "yesNo": "Yes",
36
+ "details": "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated"
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "verification": {
3
+ "time": "2022-01-25T07:52:14.318Z",
4
+ "trust_framework": "uk_pdtf",
5
+ "evidence": [
6
+ {
7
+ "type": "electronic_record",
8
+ "verifier": {
9
+ "organization": "Property Pack Assembly Software Ltd"
10
+ },
11
+ "record": {
12
+ "source": {
13
+ "name": "Royal Mail Postcode Address File",
14
+ "rights": "(c) Royal Mail"
15
+ },
16
+ "type": "postcode_address_file"
17
+ }
18
+ }
19
+ ]
20
+ },
21
+ "claims": {
22
+ "/propertyPack/address": {
23
+ "line1": "3 The Hollys",
24
+ "line2": "Birtley",
25
+ "town": "CHESTER LE STREET",
26
+ "county": "County Durham",
27
+ "postcode": "DH3 1QN"
28
+ }
29
+ }
30
+ }