@pdtf/schemas 3.6.0-8 → 3.6.0-dev.1
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/CLAUDE.md +101 -0
- package/README.md +57 -33
- package/docs/backend-lms-profile-filtering-spec.md +180 -0
- package/docs/branch-release-workflow.md +138 -0
- package/docs/sef25-extensions-ui-spec.md +355 -0
- package/index.js +134 -66
- package/package.json +6 -2
- package/src/examples/v3/exampleTransaction.json +3 -3
- package/src/schemas/v3/combined.json +6981 -1234
- package/src/schemas/v3/compactSkeleton.txt +316 -5
- package/src/schemas/v3/overlays/baspi4.json +162 -20
- package/src/schemas/v3/overlays/baspi5.json +167 -22
- package/src/schemas/v3/overlays/extensions/ac.json +333 -0
- package/src/schemas/v3/overlays/extensions/as.json +4 -2
- package/src/schemas/v3/overlays/extensions/dk.json +32 -0
- package/src/schemas/v3/overlays/extensions/dr.json +9 -9
- package/src/schemas/v3/overlays/extensions/er.json +4 -2
- package/src/schemas/v3/overlays/extensions/fd.json +6 -3
- package/src/schemas/v3/overlays/extensions/hi.json +6 -3
- package/src/schemas/v3/overlays/extensions/hs.json +4 -2
- package/src/schemas/v3/overlays/extensions/ic.json +59 -0
- package/src/schemas/v3/overlays/extensions/jk.json +28 -8
- package/src/schemas/v3/overlays/extensions/la.json +4 -2
- package/src/schemas/v3/overlays/extensions/lc.json +75 -0
- package/src/schemas/v3/overlays/extensions/ma.json +6 -3
- package/src/schemas/v3/overlays/extensions/mc.json +4 -2
- package/src/schemas/v3/overlays/extensions/mi.json +69 -0
- package/src/schemas/v3/overlays/extensions/nd.json +43 -0
- package/src/schemas/v3/overlays/extensions/oa.json +4 -2
- package/src/schemas/v3/overlays/extensions/oc.json +4 -2
- package/src/schemas/v3/overlays/extensions/pc.json +37 -0
- package/src/schemas/v3/overlays/extensions/ph.json +194 -0
- package/src/schemas/v3/overlays/extensions/rw.json +68 -0
- package/src/schemas/v3/overlays/extensions/sb.json +4 -2
- package/src/schemas/v3/overlays/extensions/sc.json +129 -0
- package/src/schemas/v3/overlays/extensions/sd.json +63 -0
- package/src/schemas/v3/overlays/extensions/sf.json +4 -2
- package/src/schemas/v3/overlays/extensions/sl.json +4 -2
- package/src/schemas/v3/overlays/extensions/ta.json +252 -0
- package/src/schemas/v3/overlays/extensions/tf.json +6 -3
- package/src/schemas/v3/overlays/extensions/tr.json +73 -0
- package/src/schemas/v3/overlays/extensions/wg.json +350 -0
- package/src/schemas/v3/overlays/fme1.json +16 -14
- package/src/schemas/v3/overlays/lpe1.json +60 -30
- package/src/schemas/v3/overlays/nts.json +68 -1
- package/src/schemas/v3/overlays/nts2.json +68 -4
- package/src/schemas/v3/overlays/ntsl.json +68 -1
- package/src/schemas/v3/overlays/ntsl2.json +68 -4
- package/src/schemas/v3/overlays/piq.json +37 -3
- package/src/schemas/v3/overlays/rds.json +117 -8
- package/src/schemas/v3/overlays/sef25.json +1639 -0
- package/src/schemas/v3/overlays/ta6.json +46 -16
- package/src/schemas/v3/overlays/ta6ed6.json +6533 -0
- package/src/schemas/v3/overlays/ta7.json +70 -6
- package/src/schemas/v3/overlays/ta7ed5.json +1551 -0
- package/src/schemas/v3/pdtf-transaction.json +3896 -686
- package/src/schemas/v3/skeleton.json +442 -35
- package/src/utils/extractExtensionOverlays.js +293 -31
- package/src/utils/extractOverlay.js +94 -27
- package/src/utils/pathSkeleton.js +1 -1
- package/.claude/settings.local.json +0 -42
- package/.github/workflows/pages.yml +0 -50
- package/CNAME +0 -1
- package/_config.yml +0 -1
- package/src/tests/v3/caching.test.js +0 -591
- package/src/tests/v3/enquiries.test.js +0 -1096
- package/src/tests/v3/extensionOverlays.test.js +0 -525
- package/src/tests/v3/offers.test.js +0 -823
- package/src/tests/v3/patternProperties.test.js +0 -565
- package/src/tests/v3/transactionSchema.test.js +0 -615
- package/src/tests/v3/verifiedClaimsValidator.test.js +0 -195
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ const cacheStats = {
|
|
|
18
18
|
hits: 0,
|
|
19
19
|
misses: 0,
|
|
20
20
|
totalQueries: 0,
|
|
21
|
-
cacheStartTime: Date.now()
|
|
21
|
+
cacheStartTime: Date.now(),
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const verifiedClaimsSchema = require("./src/schemas/verifiedClaims/pdtf-verified-claims.json");
|
|
@@ -52,6 +52,24 @@ const extensionOverlays = {
|
|
|
52
52
|
|
|
53
53
|
// Transaction Extensions
|
|
54
54
|
oc: require("./src/schemas/v3/overlays/extensions/oc.json"),
|
|
55
|
+
|
|
56
|
+
// SEF25 Extensions
|
|
57
|
+
sc: require("./src/schemas/v3/overlays/extensions/sc.json"),
|
|
58
|
+
pc: require("./src/schemas/v3/overlays/extensions/pc.json"),
|
|
59
|
+
ph: require("./src/schemas/v3/overlays/extensions/ph.json"),
|
|
60
|
+
dk: require("./src/schemas/v3/overlays/extensions/dk.json"),
|
|
61
|
+
rw: require("./src/schemas/v3/overlays/extensions/rw.json"),
|
|
62
|
+
sd: require("./src/schemas/v3/overlays/extensions/sd.json"),
|
|
63
|
+
lc: require("./src/schemas/v3/overlays/extensions/lc.json"),
|
|
64
|
+
wg: require("./src/schemas/v3/overlays/extensions/wg.json"),
|
|
65
|
+
ic: require("./src/schemas/v3/overlays/extensions/ic.json"),
|
|
66
|
+
nd: require("./src/schemas/v3/overlays/extensions/nd.json"),
|
|
67
|
+
mi: require("./src/schemas/v3/overlays/extensions/mi.json"),
|
|
68
|
+
tr: require("./src/schemas/v3/overlays/extensions/tr.json"),
|
|
69
|
+
ac: require("./src/schemas/v3/overlays/extensions/ac.json"),
|
|
70
|
+
|
|
71
|
+
// Compatibility Extensions
|
|
72
|
+
ta: require("./src/schemas/v3/overlays/extensions/ta.json"),
|
|
55
73
|
};
|
|
56
74
|
|
|
57
75
|
const overlaysMap = {
|
|
@@ -75,7 +93,9 @@ const overlaysMap = {
|
|
|
75
93
|
baspiV4: require("./src/schemas/v3/overlays/baspi4.json"),
|
|
76
94
|
baspiV5: require("./src/schemas/v3/overlays/baspi5.json"),
|
|
77
95
|
ta6ed4: require("./src/schemas/v3/overlays/ta6.json"),
|
|
96
|
+
ta6ed6: require("./src/schemas/v3/overlays/ta6ed6.json"),
|
|
78
97
|
ta7ed3: require("./src/schemas/v3/overlays/ta7.json"),
|
|
98
|
+
ta7ed5: require("./src/schemas/v3/overlays/ta7ed5.json"),
|
|
79
99
|
ta10ed3: require("./src/schemas/v3/overlays/ta10.json"),
|
|
80
100
|
lpe1ed4: require("./src/schemas/v3/overlays/lpe1.json"),
|
|
81
101
|
fme1ed2: require("./src/schemas/v3/overlays/fme1.json"),
|
|
@@ -117,21 +137,27 @@ const arrayMerge = (target, source, options) => {
|
|
|
117
137
|
// Detect if this is a required array by checking the parent key
|
|
118
138
|
// Required arrays are property names (camelCase, no spaces)
|
|
119
139
|
// Enum arrays are values (can contain spaces, capitals, etc.)
|
|
120
|
-
const isRequiredArray =
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
(item
|
|
134
|
-
|
|
140
|
+
const isRequiredArray =
|
|
141
|
+
target.every(
|
|
142
|
+
(item) =>
|
|
143
|
+
typeof item === "string" &&
|
|
144
|
+
item.length > 0 &&
|
|
145
|
+
// Required field names are typically camelCase without spaces
|
|
146
|
+
!item.includes(" ") &&
|
|
147
|
+
// First character is usually lowercase for field names
|
|
148
|
+
(item[0] === item[0].toLowerCase() ||
|
|
149
|
+
item.startsWith("is") ||
|
|
150
|
+
item.startsWith("has")),
|
|
151
|
+
) &&
|
|
152
|
+
source.every(
|
|
153
|
+
(item) =>
|
|
154
|
+
typeof item === "string" &&
|
|
155
|
+
item.length > 0 &&
|
|
156
|
+
!item.includes(" ") &&
|
|
157
|
+
(item[0] === item[0].toLowerCase() ||
|
|
158
|
+
item.startsWith("is") ||
|
|
159
|
+
item.startsWith("has")),
|
|
160
|
+
);
|
|
135
161
|
|
|
136
162
|
if (isRequiredArray) {
|
|
137
163
|
// Combine required arrays
|
|
@@ -176,7 +202,7 @@ const arrayMerge = (target, source, options) => {
|
|
|
176
202
|
|
|
177
203
|
const getTransactionSchema = (
|
|
178
204
|
schemaId = "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json",
|
|
179
|
-
overlays
|
|
205
|
+
overlays,
|
|
180
206
|
) => {
|
|
181
207
|
const sourceSchema = transactionSchemas[schemaId];
|
|
182
208
|
if (!overlays || overlays.length < 1) return sourceSchema;
|
|
@@ -184,7 +210,7 @@ const getTransactionSchema = (
|
|
|
184
210
|
let mergedSchema = JSON.parse(JSON.stringify(sourceSchema)); // Deep copy
|
|
185
211
|
overlays.forEach((overlay) => {
|
|
186
212
|
const overlaySchema = JSON.parse(
|
|
187
|
-
JSON.stringify(overlaysMap[schemaId][overlay] || {})
|
|
213
|
+
JSON.stringify(overlaysMap[schemaId][overlay] || {}),
|
|
188
214
|
); // Deep copy
|
|
189
215
|
mergedSchema = merge(mergedSchema, overlaySchema, { arrayMerge });
|
|
190
216
|
});
|
|
@@ -211,7 +237,7 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
|
|
|
211
237
|
const sourceSchema = getTransactionSchema(schemaId, overlays);
|
|
212
238
|
const pathArray = path.split("/").slice(1);
|
|
213
239
|
let subSchema = sourceSchema;
|
|
214
|
-
|
|
240
|
+
|
|
215
241
|
if (pathArray.length >= 1) {
|
|
216
242
|
subSchema = pathArray.reduce((schema, pathElement) => {
|
|
217
243
|
if (!schema) return undefined;
|
|
@@ -233,21 +259,52 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
|
|
|
233
259
|
}
|
|
234
260
|
} catch (e) {
|
|
235
261
|
// Invalid regex pattern in schema - skip it
|
|
236
|
-
console.warn(
|
|
262
|
+
console.warn(
|
|
263
|
+
`Invalid regex pattern in patternProperties: ${pattern}`,
|
|
264
|
+
e,
|
|
265
|
+
);
|
|
237
266
|
}
|
|
238
267
|
}
|
|
239
268
|
}
|
|
240
269
|
|
|
241
|
-
// Check oneOf discriminators
|
|
270
|
+
// Check oneOf discriminators (recursively for nested oneOf)
|
|
242
271
|
if (oneOf) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
272
|
+
const findInOneOf = (branches) => {
|
|
273
|
+
let arrayFallback;
|
|
274
|
+
for (const branch of branches) {
|
|
275
|
+
if (!branch) continue;
|
|
276
|
+
// Track array matches as fallback (prefer property matches)
|
|
277
|
+
if (
|
|
278
|
+
branch.type === "array" &&
|
|
279
|
+
!Number.isNaN(pathElement) &&
|
|
280
|
+
!arrayFallback
|
|
281
|
+
) {
|
|
282
|
+
arrayFallback = branch.items;
|
|
283
|
+
}
|
|
284
|
+
if (branch.properties?.[pathElement]) {
|
|
285
|
+
return branch.properties[pathElement];
|
|
286
|
+
}
|
|
287
|
+
if (branch.patternProperties) {
|
|
288
|
+
for (const pattern in branch.patternProperties) {
|
|
289
|
+
try {
|
|
290
|
+
const regex = new RegExp(pattern);
|
|
291
|
+
if (regex.test(pathElement)) {
|
|
292
|
+
return branch.patternProperties[pattern];
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
// Invalid regex pattern - skip
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// Recurse into nested oneOf branches
|
|
300
|
+
if (branch.oneOf) {
|
|
301
|
+
const nested = findInOneOf(branch.oneOf);
|
|
302
|
+
if (nested) return nested;
|
|
303
|
+
}
|
|
249
304
|
}
|
|
250
|
-
|
|
305
|
+
return arrayFallback;
|
|
306
|
+
};
|
|
307
|
+
const matchingProperty = findInOneOf(oneOf);
|
|
251
308
|
if (matchingProperty) return matchingProperty;
|
|
252
309
|
}
|
|
253
310
|
|
|
@@ -258,7 +315,7 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
|
|
|
258
315
|
// Add schema to AJV and get validator
|
|
259
316
|
// Only add valid schemas to AJV
|
|
260
317
|
let validator;
|
|
261
|
-
if (subSchema && typeof subSchema ===
|
|
318
|
+
if (subSchema && typeof subSchema === "object") {
|
|
262
319
|
// Check if schema already exists in AJV to avoid duplicates
|
|
263
320
|
validator = ajv.getSchema(cacheKey);
|
|
264
321
|
if (!validator) {
|
|
@@ -275,7 +332,7 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
|
|
|
275
332
|
subSchema,
|
|
276
333
|
validator,
|
|
277
334
|
cacheKey,
|
|
278
|
-
createdAt: Date.now()
|
|
335
|
+
createdAt: Date.now(),
|
|
279
336
|
};
|
|
280
337
|
schemaCache.set(cacheKey, cached);
|
|
281
338
|
} else {
|
|
@@ -341,13 +398,13 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
341
398
|
if (oneOfs) {
|
|
342
399
|
// only single dependency discriminator, oneOf keyword is supported
|
|
343
400
|
const matchingOneOf = oneOfs.find(
|
|
344
|
-
(oneOf) => oneOf["properties"][propertyName]
|
|
401
|
+
(oneOf) => oneOf["properties"][propertyName],
|
|
345
402
|
);
|
|
346
403
|
if (matchingOneOf)
|
|
347
404
|
return getTitleAtPath(
|
|
348
405
|
matchingOneOf["properties"][propertyName],
|
|
349
406
|
subPath,
|
|
350
|
-
rootPath
|
|
407
|
+
rootPath,
|
|
351
408
|
);
|
|
352
409
|
}
|
|
353
410
|
};
|
|
@@ -380,7 +437,7 @@ const validateVerifiedClaims = (verifiedClaims, schemaId, overlays) => {
|
|
|
380
437
|
}
|
|
381
438
|
} else {
|
|
382
439
|
validationErrorsArr.push(
|
|
383
|
-
`Path ${path} is not a valid PDTF schema path
|
|
440
|
+
`Path ${path} is not a valid PDTF schema path`,
|
|
384
441
|
);
|
|
385
442
|
}
|
|
386
443
|
}
|
|
@@ -392,8 +449,11 @@ const validateVerifiedClaims = (verifiedClaims, schemaId, overlays) => {
|
|
|
392
449
|
// Cache management functions
|
|
393
450
|
const getCacheStats = () => {
|
|
394
451
|
const runtime = Date.now() - cacheStats.cacheStartTime;
|
|
395
|
-
const hitRate =
|
|
396
|
-
|
|
452
|
+
const hitRate =
|
|
453
|
+
cacheStats.totalQueries > 0
|
|
454
|
+
? (cacheStats.hits / cacheStats.totalQueries) * 100
|
|
455
|
+
: 0;
|
|
456
|
+
|
|
397
457
|
return {
|
|
398
458
|
totalEntries: schemaCache.size,
|
|
399
459
|
hits: cacheStats.hits,
|
|
@@ -405,8 +465,8 @@ const getCacheStats = () => {
|
|
|
405
465
|
memoryUsage: {
|
|
406
466
|
entriesCount: schemaCache.size,
|
|
407
467
|
// Rough estimate of memory usage per entry
|
|
408
|
-
estimatedSizeKB: Math.round((schemaCache.size * 2) / 1024 * 100) / 100 // Rough estimate
|
|
409
|
-
}
|
|
468
|
+
estimatedSizeKB: Math.round(((schemaCache.size * 2) / 1024) * 100) / 100, // Rough estimate
|
|
469
|
+
},
|
|
410
470
|
};
|
|
411
471
|
};
|
|
412
472
|
|
|
@@ -416,15 +476,17 @@ const getDetailedCacheStats = () => {
|
|
|
416
476
|
key,
|
|
417
477
|
createdAt: value.createdAt,
|
|
418
478
|
age: Date.now() - value.createdAt,
|
|
419
|
-
hasValidator: typeof value.validator ===
|
|
420
|
-
hasSubSchema: value.subSchema !== undefined
|
|
479
|
+
hasValidator: typeof value.validator === "function",
|
|
480
|
+
hasSubSchema: value.subSchema !== undefined,
|
|
421
481
|
}));
|
|
422
482
|
|
|
423
483
|
return {
|
|
424
484
|
...baseStats,
|
|
425
485
|
entries: entries.sort((a, b) => b.createdAt - a.createdAt), // Most recent first
|
|
426
|
-
oldestEntry:
|
|
427
|
-
|
|
486
|
+
oldestEntry:
|
|
487
|
+
entries.length > 0 ? Math.max(...entries.map((e) => e.age)) : 0,
|
|
488
|
+
newestEntry:
|
|
489
|
+
entries.length > 0 ? Math.min(...entries.map((e) => e.age)) : 0,
|
|
428
490
|
};
|
|
429
491
|
};
|
|
430
492
|
|
|
@@ -437,17 +499,17 @@ const clearSchemaCache = (pattern) => {
|
|
|
437
499
|
keysToDelete.push(key);
|
|
438
500
|
}
|
|
439
501
|
});
|
|
440
|
-
keysToDelete.forEach(key => schemaCache.delete(key));
|
|
441
|
-
|
|
502
|
+
keysToDelete.forEach((key) => schemaCache.delete(key));
|
|
503
|
+
|
|
442
504
|
// Also remove matching schemas from AJV
|
|
443
|
-
keysToDelete.forEach(key => {
|
|
505
|
+
keysToDelete.forEach((key) => {
|
|
444
506
|
try {
|
|
445
507
|
ajv.removeSchema(key);
|
|
446
508
|
} catch (e) {
|
|
447
509
|
// Schema might not exist in AJV, ignore
|
|
448
510
|
}
|
|
449
511
|
});
|
|
450
|
-
|
|
512
|
+
|
|
451
513
|
return keysToDelete.length;
|
|
452
514
|
} else {
|
|
453
515
|
// Clear all cache
|
|
@@ -458,20 +520,24 @@ const clearSchemaCache = (pattern) => {
|
|
|
458
520
|
cacheStats.misses = 0;
|
|
459
521
|
cacheStats.totalQueries = 0;
|
|
460
522
|
cacheStats.cacheStartTime = Date.now();
|
|
461
|
-
|
|
523
|
+
|
|
462
524
|
// Also clear AJV's internal cache to prevent duplicates
|
|
463
525
|
ajv.removeSchema();
|
|
464
|
-
|
|
526
|
+
|
|
465
527
|
return entriesCleared;
|
|
466
528
|
}
|
|
467
529
|
};
|
|
468
530
|
|
|
469
|
-
const warmupCache = (
|
|
531
|
+
const warmupCache = (
|
|
532
|
+
paths,
|
|
533
|
+
schemaId = "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json",
|
|
534
|
+
overlaysList = [],
|
|
535
|
+
) => {
|
|
470
536
|
const warmupStats = {
|
|
471
537
|
totalAttempted: 0,
|
|
472
538
|
successful: 0,
|
|
473
539
|
failed: 0,
|
|
474
|
-
errors: []
|
|
540
|
+
errors: [],
|
|
475
541
|
};
|
|
476
542
|
|
|
477
543
|
// Default common paths if none provided
|
|
@@ -483,7 +549,7 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
483
549
|
"/propertyPack/valuations",
|
|
484
550
|
"/propertyPack/waterAndDrainage",
|
|
485
551
|
"/propertyPack/ownership",
|
|
486
|
-
"/propertyPack/notices"
|
|
552
|
+
"/propertyPack/notices",
|
|
487
553
|
];
|
|
488
554
|
|
|
489
555
|
// Default common overlays if none provided
|
|
@@ -492,14 +558,15 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
492
558
|
["baspiV5"],
|
|
493
559
|
["ta6ed4"],
|
|
494
560
|
["nts2023"],
|
|
495
|
-
["baspiV5", "ta6ed4"]
|
|
561
|
+
["baspiV5", "ta6ed4"],
|
|
496
562
|
];
|
|
497
563
|
|
|
498
564
|
const pathsToWarm = paths || defaultPaths;
|
|
499
|
-
const overlaysToWarm =
|
|
565
|
+
const overlaysToWarm =
|
|
566
|
+
overlaysList.length > 0 ? overlaysList : defaultOverlays;
|
|
500
567
|
|
|
501
|
-
pathsToWarm.forEach(path => {
|
|
502
|
-
overlaysToWarm.forEach(overlays => {
|
|
568
|
+
pathsToWarm.forEach((path) => {
|
|
569
|
+
overlaysToWarm.forEach((overlays) => {
|
|
503
570
|
warmupStats.totalAttempted++;
|
|
504
571
|
try {
|
|
505
572
|
// This will populate the cache
|
|
@@ -511,7 +578,7 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
511
578
|
warmupStats.errors.push({
|
|
512
579
|
path,
|
|
513
580
|
overlays,
|
|
514
|
-
error: error.message
|
|
581
|
+
error: error.message,
|
|
515
582
|
});
|
|
516
583
|
}
|
|
517
584
|
});
|
|
@@ -523,14 +590,14 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
523
590
|
const pruneCacheByAge = (maxAgeMs) => {
|
|
524
591
|
const now = Date.now();
|
|
525
592
|
const keysToDelete = [];
|
|
526
|
-
|
|
593
|
+
|
|
527
594
|
schemaCache.forEach((value, key) => {
|
|
528
595
|
if (now - value.createdAt > maxAgeMs) {
|
|
529
596
|
keysToDelete.push(key);
|
|
530
597
|
}
|
|
531
598
|
});
|
|
532
|
-
|
|
533
|
-
keysToDelete.forEach(key => {
|
|
599
|
+
|
|
600
|
+
keysToDelete.forEach((key) => {
|
|
534
601
|
schemaCache.delete(key);
|
|
535
602
|
try {
|
|
536
603
|
ajv.removeSchema(key);
|
|
@@ -538,21 +605,22 @@ const pruneCacheByAge = (maxAgeMs) => {
|
|
|
538
605
|
// Schema might not exist in AJV, ignore
|
|
539
606
|
}
|
|
540
607
|
});
|
|
541
|
-
|
|
608
|
+
|
|
542
609
|
return keysToDelete.length;
|
|
543
610
|
};
|
|
544
611
|
|
|
545
612
|
const setCacheMaxSize = (maxSize) => {
|
|
546
613
|
if (schemaCache.size <= maxSize) return 0;
|
|
547
|
-
|
|
614
|
+
|
|
548
615
|
// Get entries sorted by creation time (oldest first)
|
|
549
|
-
const entries = Array.from(schemaCache.entries())
|
|
550
|
-
|
|
551
|
-
|
|
616
|
+
const entries = Array.from(schemaCache.entries()).sort(
|
|
617
|
+
(a, b) => a[1].createdAt - b[1].createdAt,
|
|
618
|
+
);
|
|
619
|
+
|
|
552
620
|
const toRemove = schemaCache.size - maxSize;
|
|
553
621
|
const keysToDelete = entries.slice(0, toRemove).map(([key]) => key);
|
|
554
|
-
|
|
555
|
-
keysToDelete.forEach(key => {
|
|
622
|
+
|
|
623
|
+
keysToDelete.forEach((key) => {
|
|
556
624
|
schemaCache.delete(key);
|
|
557
625
|
try {
|
|
558
626
|
ajv.removeSchema(key);
|
|
@@ -560,7 +628,7 @@ const setCacheMaxSize = (maxSize) => {
|
|
|
560
628
|
// Schema might not exist in AJV, ignore
|
|
561
629
|
}
|
|
562
630
|
});
|
|
563
|
-
|
|
631
|
+
|
|
564
632
|
return keysToDelete.length;
|
|
565
633
|
};
|
|
566
634
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdtf/schemas",
|
|
3
|
-
"version": "3.6.0-
|
|
3
|
+
"version": "3.6.0-dev.1",
|
|
4
4
|
"description": "Property Data Trust Framework Schemas and Utilities",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "jest",
|
|
11
11
|
"test:watch": "jest --watch",
|
|
12
|
-
"extract-overlays": "cd src/utils && node extractOverlay.js"
|
|
12
|
+
"extract-overlays": "cd src/utils && node extractOverlay.js",
|
|
13
|
+
"extract-extension-overlays": "cd src/utils && node extractExtensionOverlays.js",
|
|
14
|
+
"publish:dev": "npm publish --tag dev",
|
|
15
|
+
"publish:next": "npm publish --tag next",
|
|
16
|
+
"publish:latest": "npm publish --tag latest"
|
|
13
17
|
},
|
|
14
18
|
"repository": {
|
|
15
19
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"role": "Seller",
|
|
21
21
|
"sellersCapacity": { "capacity": "Legal Owner" },
|
|
22
|
-
"externalIds": { "
|
|
22
|
+
"externalIds": { "Platform": "123434" }
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"role": "Seller's Conveyancer",
|
|
@@ -988,7 +988,7 @@
|
|
|
988
988
|
"name": "Example Agency Agreement",
|
|
989
989
|
"url": "https://example.com/example-agency-agreement",
|
|
990
990
|
"externalIds": {
|
|
991
|
-
"
|
|
991
|
+
"Platform": "file123"
|
|
992
992
|
},
|
|
993
993
|
"requiredSignatories": [
|
|
994
994
|
{
|
|
@@ -1027,7 +1027,7 @@
|
|
|
1027
1027
|
"name": "Peter Ronald Hetherington-Smythe",
|
|
1028
1028
|
"signedOn": "2024-11-29T16:15:02.735Z",
|
|
1029
1029
|
"externalIds": {
|
|
1030
|
-
"
|
|
1030
|
+
"Platform": "123434"
|
|
1031
1031
|
},
|
|
1032
1032
|
"role": "Seller",
|
|
1033
1033
|
"contractHash": "IYnBjUI8TauXFop6WCvnPA=="
|