@pdtf/schemas 3.6.0-9 → 3.6.0-dev.10
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/README.md +57 -33
- package/docs/branch-release-workflow.md +138 -0
- package/docs/sef25-extensions-ui-spec.md +355 -0
- package/index.js +131 -75
- package/package.json +14 -2
- package/src/schemas/v3/combined.json +7952 -1721
- package/src/schemas/v3/compactSkeleton.txt +379 -5
- package/src/schemas/v3/overlays/baspi4.json +205 -93
- package/src/schemas/v3/overlays/baspi5.json +210 -95
- package/src/schemas/v3/overlays/extensions/ac.json +334 -0
- package/src/schemas/v3/overlays/extensions/as.json +4 -2
- package/src/schemas/v3/overlays/extensions/dk.json +33 -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 +94 -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 +76 -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 +70 -0
- package/src/schemas/v3/overlays/extensions/nd.json +44 -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 +38 -0
- package/src/schemas/v3/overlays/extensions/ph.json +195 -0
- package/src/schemas/v3/overlays/extensions/rw.json +69 -0
- package/src/schemas/v3/overlays/extensions/sb.json +4 -2
- package/src/schemas/v3/overlays/extensions/sc.json +133 -0
- package/src/schemas/v3/overlays/extensions/sd.json +64 -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 +204 -0
- package/src/schemas/v3/overlays/extensions/tf.json +6 -3
- package/src/schemas/v3/overlays/extensions/tr.json +74 -0
- package/src/schemas/v3/overlays/extensions/wg.json +351 -0
- package/src/schemas/v3/overlays/fme1.json +16 -14
- package/src/schemas/v3/overlays/llc1.json +1 -2
- package/src/schemas/v3/overlays/lpe1.json +61 -31
- package/src/schemas/v3/overlays/nts.json +71 -2
- package/src/schemas/v3/overlays/nts2.json +71 -5
- package/src/schemas/v3/overlays/ntsl.json +71 -2
- package/src/schemas/v3/overlays/ntsl2.json +71 -5
- package/src/schemas/v3/overlays/piq.json +60 -27
- package/src/schemas/v3/overlays/rds.json +139 -57
- package/src/schemas/v3/overlays/sef25.json +1653 -0
- package/src/schemas/v3/overlays/ta10.json +0 -9
- package/src/schemas/v3/overlays/ta6.json +83 -85
- package/src/schemas/v3/overlays/ta6ed6.json +6641 -0
- package/src/schemas/v3/overlays/ta7.json +70 -6
- package/src/schemas/v3/overlays/ta7ed5.json +1597 -0
- package/src/schemas/v3/pdtf-transaction.json +4525 -1013
- package/src/schemas/v3/skeleton.json +512 -40
- package/src/utils/extractExtensionOverlays.js +302 -31
- package/src/utils/extractOverlay.js +114 -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/examples/v1/exampleAddParticipantVouch.json +0 -32
- package/src/examples/v1/exampleDocumentedVouch.json +0 -40
- package/src/examples/v1/exampleElectronicRecord.json +0 -30
- package/src/examples/v1/exampleTransaction.json +0 -878
- package/src/examples/v1/exampleVouch.json +0 -25
- package/src/examples/v2/exampleTransaction.json +0 -901
- package/src/examples/v3/exampleAddParticipantVouch.json +0 -38
- package/src/examples/v3/exampleCustomOverlay.json +0 -55
- package/src/examples/v3/exampleCustomOverlay2.json +0 -93
- package/src/examples/v3/exampleDocumentedVouch.json +0 -47
- package/src/examples/v3/exampleElectronicRecord.json +0 -36
- package/src/examples/v3/exampleTransaction.json +0 -1038
- package/src/examples/v3/exampleVouch.json +0 -32
- package/src/mappings/SendPropertyDetailsRequestSchema.json +0 -1588
- package/src/mappings/adf.js +0 -198
- 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 -688
- 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,33 +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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
|
256
296
|
}
|
|
257
|
-
} catch (e) {
|
|
258
|
-
// Invalid regex pattern - skip
|
|
259
297
|
}
|
|
260
298
|
}
|
|
299
|
+
// Recurse into nested oneOf branches
|
|
300
|
+
if (branch.oneOf) {
|
|
301
|
+
const nested = findInOneOf(branch.oneOf);
|
|
302
|
+
if (nested) return nested;
|
|
303
|
+
}
|
|
261
304
|
}
|
|
262
|
-
|
|
305
|
+
return arrayFallback;
|
|
306
|
+
};
|
|
307
|
+
const matchingProperty = findInOneOf(oneOf);
|
|
263
308
|
if (matchingProperty) return matchingProperty;
|
|
264
309
|
}
|
|
265
310
|
|
|
@@ -270,7 +315,7 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
|
|
|
270
315
|
// Add schema to AJV and get validator
|
|
271
316
|
// Only add valid schemas to AJV
|
|
272
317
|
let validator;
|
|
273
|
-
if (subSchema && typeof subSchema ===
|
|
318
|
+
if (subSchema && typeof subSchema === "object") {
|
|
274
319
|
// Check if schema already exists in AJV to avoid duplicates
|
|
275
320
|
validator = ajv.getSchema(cacheKey);
|
|
276
321
|
if (!validator) {
|
|
@@ -287,7 +332,7 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
|
|
|
287
332
|
subSchema,
|
|
288
333
|
validator,
|
|
289
334
|
cacheKey,
|
|
290
|
-
createdAt: Date.now()
|
|
335
|
+
createdAt: Date.now(),
|
|
291
336
|
};
|
|
292
337
|
schemaCache.set(cacheKey, cached);
|
|
293
338
|
} else {
|
|
@@ -353,13 +398,13 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
353
398
|
if (oneOfs) {
|
|
354
399
|
// only single dependency discriminator, oneOf keyword is supported
|
|
355
400
|
const matchingOneOf = oneOfs.find(
|
|
356
|
-
(oneOf) => oneOf["properties"][propertyName]
|
|
401
|
+
(oneOf) => oneOf["properties"][propertyName],
|
|
357
402
|
);
|
|
358
403
|
if (matchingOneOf)
|
|
359
404
|
return getTitleAtPath(
|
|
360
405
|
matchingOneOf["properties"][propertyName],
|
|
361
406
|
subPath,
|
|
362
|
-
rootPath
|
|
407
|
+
rootPath,
|
|
363
408
|
);
|
|
364
409
|
}
|
|
365
410
|
};
|
|
@@ -392,7 +437,7 @@ const validateVerifiedClaims = (verifiedClaims, schemaId, overlays) => {
|
|
|
392
437
|
}
|
|
393
438
|
} else {
|
|
394
439
|
validationErrorsArr.push(
|
|
395
|
-
`Path ${path} is not a valid PDTF schema path
|
|
440
|
+
`Path ${path} is not a valid PDTF schema path`,
|
|
396
441
|
);
|
|
397
442
|
}
|
|
398
443
|
}
|
|
@@ -404,8 +449,11 @@ const validateVerifiedClaims = (verifiedClaims, schemaId, overlays) => {
|
|
|
404
449
|
// Cache management functions
|
|
405
450
|
const getCacheStats = () => {
|
|
406
451
|
const runtime = Date.now() - cacheStats.cacheStartTime;
|
|
407
|
-
const hitRate =
|
|
408
|
-
|
|
452
|
+
const hitRate =
|
|
453
|
+
cacheStats.totalQueries > 0
|
|
454
|
+
? (cacheStats.hits / cacheStats.totalQueries) * 100
|
|
455
|
+
: 0;
|
|
456
|
+
|
|
409
457
|
return {
|
|
410
458
|
totalEntries: schemaCache.size,
|
|
411
459
|
hits: cacheStats.hits,
|
|
@@ -417,8 +465,8 @@ const getCacheStats = () => {
|
|
|
417
465
|
memoryUsage: {
|
|
418
466
|
entriesCount: schemaCache.size,
|
|
419
467
|
// Rough estimate of memory usage per entry
|
|
420
|
-
estimatedSizeKB: Math.round((schemaCache.size * 2) / 1024 * 100) / 100 // Rough estimate
|
|
421
|
-
}
|
|
468
|
+
estimatedSizeKB: Math.round(((schemaCache.size * 2) / 1024) * 100) / 100, // Rough estimate
|
|
469
|
+
},
|
|
422
470
|
};
|
|
423
471
|
};
|
|
424
472
|
|
|
@@ -428,15 +476,17 @@ const getDetailedCacheStats = () => {
|
|
|
428
476
|
key,
|
|
429
477
|
createdAt: value.createdAt,
|
|
430
478
|
age: Date.now() - value.createdAt,
|
|
431
|
-
hasValidator: typeof value.validator ===
|
|
432
|
-
hasSubSchema: value.subSchema !== undefined
|
|
479
|
+
hasValidator: typeof value.validator === "function",
|
|
480
|
+
hasSubSchema: value.subSchema !== undefined,
|
|
433
481
|
}));
|
|
434
482
|
|
|
435
483
|
return {
|
|
436
484
|
...baseStats,
|
|
437
485
|
entries: entries.sort((a, b) => b.createdAt - a.createdAt), // Most recent first
|
|
438
|
-
oldestEntry:
|
|
439
|
-
|
|
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,
|
|
440
490
|
};
|
|
441
491
|
};
|
|
442
492
|
|
|
@@ -449,17 +499,17 @@ const clearSchemaCache = (pattern) => {
|
|
|
449
499
|
keysToDelete.push(key);
|
|
450
500
|
}
|
|
451
501
|
});
|
|
452
|
-
keysToDelete.forEach(key => schemaCache.delete(key));
|
|
453
|
-
|
|
502
|
+
keysToDelete.forEach((key) => schemaCache.delete(key));
|
|
503
|
+
|
|
454
504
|
// Also remove matching schemas from AJV
|
|
455
|
-
keysToDelete.forEach(key => {
|
|
505
|
+
keysToDelete.forEach((key) => {
|
|
456
506
|
try {
|
|
457
507
|
ajv.removeSchema(key);
|
|
458
508
|
} catch (e) {
|
|
459
509
|
// Schema might not exist in AJV, ignore
|
|
460
510
|
}
|
|
461
511
|
});
|
|
462
|
-
|
|
512
|
+
|
|
463
513
|
return keysToDelete.length;
|
|
464
514
|
} else {
|
|
465
515
|
// Clear all cache
|
|
@@ -470,20 +520,24 @@ const clearSchemaCache = (pattern) => {
|
|
|
470
520
|
cacheStats.misses = 0;
|
|
471
521
|
cacheStats.totalQueries = 0;
|
|
472
522
|
cacheStats.cacheStartTime = Date.now();
|
|
473
|
-
|
|
523
|
+
|
|
474
524
|
// Also clear AJV's internal cache to prevent duplicates
|
|
475
525
|
ajv.removeSchema();
|
|
476
|
-
|
|
526
|
+
|
|
477
527
|
return entriesCleared;
|
|
478
528
|
}
|
|
479
529
|
};
|
|
480
530
|
|
|
481
|
-
const warmupCache = (
|
|
531
|
+
const warmupCache = (
|
|
532
|
+
paths,
|
|
533
|
+
schemaId = "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json",
|
|
534
|
+
overlaysList = [],
|
|
535
|
+
) => {
|
|
482
536
|
const warmupStats = {
|
|
483
537
|
totalAttempted: 0,
|
|
484
538
|
successful: 0,
|
|
485
539
|
failed: 0,
|
|
486
|
-
errors: []
|
|
540
|
+
errors: [],
|
|
487
541
|
};
|
|
488
542
|
|
|
489
543
|
// Default common paths if none provided
|
|
@@ -495,7 +549,7 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
495
549
|
"/propertyPack/valuations",
|
|
496
550
|
"/propertyPack/waterAndDrainage",
|
|
497
551
|
"/propertyPack/ownership",
|
|
498
|
-
"/propertyPack/notices"
|
|
552
|
+
"/propertyPack/notices",
|
|
499
553
|
];
|
|
500
554
|
|
|
501
555
|
// Default common overlays if none provided
|
|
@@ -504,14 +558,15 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
504
558
|
["baspiV5"],
|
|
505
559
|
["ta6ed4"],
|
|
506
560
|
["nts2023"],
|
|
507
|
-
["baspiV5", "ta6ed4"]
|
|
561
|
+
["baspiV5", "ta6ed4"],
|
|
508
562
|
];
|
|
509
563
|
|
|
510
564
|
const pathsToWarm = paths || defaultPaths;
|
|
511
|
-
const overlaysToWarm =
|
|
565
|
+
const overlaysToWarm =
|
|
566
|
+
overlaysList.length > 0 ? overlaysList : defaultOverlays;
|
|
512
567
|
|
|
513
|
-
pathsToWarm.forEach(path => {
|
|
514
|
-
overlaysToWarm.forEach(overlays => {
|
|
568
|
+
pathsToWarm.forEach((path) => {
|
|
569
|
+
overlaysToWarm.forEach((overlays) => {
|
|
515
570
|
warmupStats.totalAttempted++;
|
|
516
571
|
try {
|
|
517
572
|
// This will populate the cache
|
|
@@ -523,7 +578,7 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
523
578
|
warmupStats.errors.push({
|
|
524
579
|
path,
|
|
525
580
|
overlays,
|
|
526
|
-
error: error.message
|
|
581
|
+
error: error.message,
|
|
527
582
|
});
|
|
528
583
|
}
|
|
529
584
|
});
|
|
@@ -535,14 +590,14 @@ const warmupCache = (paths, schemaId = "https://trust.propdata.org.uk/schemas/v3
|
|
|
535
590
|
const pruneCacheByAge = (maxAgeMs) => {
|
|
536
591
|
const now = Date.now();
|
|
537
592
|
const keysToDelete = [];
|
|
538
|
-
|
|
593
|
+
|
|
539
594
|
schemaCache.forEach((value, key) => {
|
|
540
595
|
if (now - value.createdAt > maxAgeMs) {
|
|
541
596
|
keysToDelete.push(key);
|
|
542
597
|
}
|
|
543
598
|
});
|
|
544
|
-
|
|
545
|
-
keysToDelete.forEach(key => {
|
|
599
|
+
|
|
600
|
+
keysToDelete.forEach((key) => {
|
|
546
601
|
schemaCache.delete(key);
|
|
547
602
|
try {
|
|
548
603
|
ajv.removeSchema(key);
|
|
@@ -550,21 +605,22 @@ const pruneCacheByAge = (maxAgeMs) => {
|
|
|
550
605
|
// Schema might not exist in AJV, ignore
|
|
551
606
|
}
|
|
552
607
|
});
|
|
553
|
-
|
|
608
|
+
|
|
554
609
|
return keysToDelete.length;
|
|
555
610
|
};
|
|
556
611
|
|
|
557
612
|
const setCacheMaxSize = (maxSize) => {
|
|
558
613
|
if (schemaCache.size <= maxSize) return 0;
|
|
559
|
-
|
|
614
|
+
|
|
560
615
|
// Get entries sorted by creation time (oldest first)
|
|
561
|
-
const entries = Array.from(schemaCache.entries())
|
|
562
|
-
|
|
563
|
-
|
|
616
|
+
const entries = Array.from(schemaCache.entries()).sort(
|
|
617
|
+
(a, b) => a[1].createdAt - b[1].createdAt,
|
|
618
|
+
);
|
|
619
|
+
|
|
564
620
|
const toRemove = schemaCache.size - maxSize;
|
|
565
621
|
const keysToDelete = entries.slice(0, toRemove).map(([key]) => key);
|
|
566
|
-
|
|
567
|
-
keysToDelete.forEach(key => {
|
|
622
|
+
|
|
623
|
+
keysToDelete.forEach((key) => {
|
|
568
624
|
schemaCache.delete(key);
|
|
569
625
|
try {
|
|
570
626
|
ajv.removeSchema(key);
|
|
@@ -572,7 +628,7 @@ const setCacheMaxSize = (maxSize) => {
|
|
|
572
628
|
// Schema might not exist in AJV, ignore
|
|
573
629
|
}
|
|
574
630
|
});
|
|
575
|
-
|
|
631
|
+
|
|
576
632
|
return keysToDelete.length;
|
|
577
633
|
};
|
|
578
634
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdtf/schemas",
|
|
3
|
-
"version": "3.6.0-
|
|
3
|
+
"version": "3.6.0-dev.10",
|
|
4
4
|
"description": "Property Data Trust Framework Schemas and Utilities",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"src/schemas",
|
|
9
|
+
"src/utils",
|
|
10
|
+
"docs",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
6
14
|
"directories": {
|
|
7
15
|
"doc": "docs"
|
|
8
16
|
},
|
|
9
17
|
"scripts": {
|
|
10
18
|
"test": "jest",
|
|
11
19
|
"test:watch": "jest --watch",
|
|
12
|
-
"extract-overlays": "cd src/utils && node extractOverlay.js"
|
|
20
|
+
"extract-overlays": "cd src/utils && node extractOverlay.js",
|
|
21
|
+
"extract-extension-overlays": "cd src/utils && node extractExtensionOverlays.js",
|
|
22
|
+
"publish:dev": "npm publish --tag dev",
|
|
23
|
+
"publish:next": "npm publish --tag next",
|
|
24
|
+
"publish:latest": "npm publish --tag latest"
|
|
13
25
|
},
|
|
14
26
|
"repository": {
|
|
15
27
|
"type": "git",
|