@pdtf/schemas 3.6.0-dev.3 → 3.6.0-dev.30

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 (192) hide show
  1. package/docs/ta6-certificate-permit-contract.md +51 -0
  2. package/docs/v4-mapping-and-recomposition.md +419 -0
  3. package/index.js +210 -0
  4. package/package.json +10 -1
  5. package/src/schemas/v3/combined.json +2261 -657
  6. package/src/schemas/v3/compactSkeleton.txt +120 -51
  7. package/src/schemas/v3/overlays/baspi4.json +54 -74
  8. package/src/schemas/v3/overlays/baspi5.json +54 -74
  9. package/src/schemas/v3/overlays/extensions/ac.json +2 -1
  10. package/src/schemas/v3/overlays/extensions/dk.json +3 -2
  11. package/src/schemas/v3/overlays/extensions/fd.json +2 -1
  12. package/src/schemas/v3/overlays/extensions/ic.json +44 -9
  13. package/src/schemas/v3/overlays/extensions/lc.json +3 -2
  14. package/src/schemas/v3/overlays/extensions/mi.json +2 -1
  15. package/src/schemas/v3/overlays/extensions/nd.json +3 -2
  16. package/src/schemas/v3/overlays/extensions/pc.json +3 -2
  17. package/src/schemas/v3/overlays/extensions/ph.json +2 -1
  18. package/src/schemas/v3/overlays/extensions/rw.json +4 -3
  19. package/src/schemas/v3/overlays/extensions/sc.json +8 -4
  20. package/src/schemas/v3/overlays/extensions/sd.json +3 -2
  21. package/src/schemas/v3/overlays/extensions/tr.json +3 -2
  22. package/src/schemas/v3/overlays/extensions/wg.json +2 -1
  23. package/src/schemas/v3/overlays/llc1.json +1 -2
  24. package/src/schemas/v3/overlays/lpe1.json +3 -2
  25. package/src/schemas/v3/overlays/nts.json +7 -3
  26. package/src/schemas/v3/overlays/nts2.json +9 -4
  27. package/src/schemas/v3/overlays/ntsl.json +5 -2
  28. package/src/schemas/v3/overlays/ntsl2.json +7 -3
  29. package/src/schemas/v3/overlays/piq.json +34 -25
  30. package/src/schemas/v3/overlays/rds.json +24 -50
  31. package/src/schemas/v3/overlays/sef25.json +16 -2
  32. package/src/schemas/v3/overlays/ta10.json +0 -9
  33. package/src/schemas/v3/overlays/ta6.json +39 -70
  34. package/src/schemas/v3/overlays/ta6ed6.json +331 -307
  35. package/{pensive-tesla-d0d355/src/schemas/v3/overlays/ta6.json → src/schemas/v3/overlays/ta6ed6v2.json} +1574 -1464
  36. package/src/schemas/v3/overlays/ta7.json +2 -1
  37. package/src/schemas/v3/overlays/ta7ed5.json +68 -21
  38. package/src/schemas/v3/pdtf-transaction.json +1030 -492
  39. package/src/schemas/v3/skeleton.json +163 -57
  40. package/src/schemas/v4/Gift.json +88 -0
  41. package/src/schemas/v4/Offer.json +425 -0
  42. package/src/schemas/v4/Organisation.json +167 -0
  43. package/src/schemas/v4/Person.json +321 -0
  44. package/src/schemas/v4/Property.json +27813 -0
  45. package/src/schemas/v4/Representation.json +67 -0
  46. package/src/schemas/v4/SellerCapacity.json +193 -0
  47. package/src/schemas/v4/Title.json +14660 -0
  48. package/src/schemas/v4/Transaction.json +1612 -0
  49. package/src/schemas/v4/TransactionRole.json +59 -0
  50. package/src/schemas/v4/mapping.json +1161 -0
  51. package/src/utils/checkTa6OmissionCompatibility.js +146 -0
  52. package/src/utils/extractExtensionOverlays.js +11 -2
  53. package/src/utils/extractOverlay.js +21 -0
  54. package/src/utils/generateV4Schemas.js +1358 -0
  55. package/src/utils/syncTa6ed6v2Markers.js +92 -0
  56. package/src/utils/v4.js +838 -0
  57. package/CLAUDE.md +0 -101
  58. package/pensive-tesla-d0d355/CLAUDE.md +0 -101
  59. package/pensive-tesla-d0d355/LICENSE +0 -21
  60. package/pensive-tesla-d0d355/README.md +0 -435
  61. package/pensive-tesla-d0d355/docs/branch-release-workflow.md +0 -138
  62. package/pensive-tesla-d0d355/docs/sef25-extensions-ui-spec.md +0 -355
  63. package/pensive-tesla-d0d355/index.js +0 -654
  64. package/pensive-tesla-d0d355/package-lock.json +0 -7297
  65. package/pensive-tesla-d0d355/package.json +0 -44
  66. package/pensive-tesla-d0d355/src/examples/v1/exampleAddParticipantVouch.json +0 -32
  67. package/pensive-tesla-d0d355/src/examples/v1/exampleDocumentedVouch.json +0 -40
  68. package/pensive-tesla-d0d355/src/examples/v1/exampleElectronicRecord.json +0 -30
  69. package/pensive-tesla-d0d355/src/examples/v1/exampleTransaction.json +0 -878
  70. package/pensive-tesla-d0d355/src/examples/v1/exampleVouch.json +0 -25
  71. package/pensive-tesla-d0d355/src/examples/v2/exampleTransaction.json +0 -901
  72. package/pensive-tesla-d0d355/src/examples/v3/exampleAddParticipantVouch.json +0 -38
  73. package/pensive-tesla-d0d355/src/examples/v3/exampleCustomOverlay.json +0 -55
  74. package/pensive-tesla-d0d355/src/examples/v3/exampleCustomOverlay2.json +0 -93
  75. package/pensive-tesla-d0d355/src/examples/v3/exampleDocumentedVouch.json +0 -47
  76. package/pensive-tesla-d0d355/src/examples/v3/exampleElectronicRecord.json +0 -36
  77. package/pensive-tesla-d0d355/src/examples/v3/exampleTransaction.json +0 -1038
  78. package/pensive-tesla-d0d355/src/examples/v3/exampleVouch.json +0 -32
  79. package/pensive-tesla-d0d355/src/mappings/SendPropertyDetailsRequestSchema.json +0 -1588
  80. package/pensive-tesla-d0d355/src/mappings/adf.js +0 -198
  81. package/pensive-tesla-d0d355/src/schemas/v1/GeoJSON.json +0 -1279
  82. package/pensive-tesla-d0d355/src/schemas/v1/baspiNotes.html +0 -102
  83. package/pensive-tesla-d0d355/src/schemas/v1/energy-performance-certificate.json +0 -124
  84. package/pensive-tesla-d0d355/src/schemas/v1/freehold-information.json +0 -2051
  85. package/pensive-tesla-d0d355/src/schemas/v1/leasehold-information.json +0 -2064
  86. package/pensive-tesla-d0d355/src/schemas/v1/legal-information.json +0 -1045
  87. package/pensive-tesla-d0d355/src/schemas/v1/material-facts.json +0 -2109
  88. package/pensive-tesla-d0d355/src/schemas/v1/pdtf-transaction-search-results.json +0 -40
  89. package/pensive-tesla-d0d355/src/schemas/v1/pdtf-transaction.json +0 -191
  90. package/pensive-tesla-d0d355/src/schemas/v1/searches/drainage-and-water.json +0 -261
  91. package/pensive-tesla-d0d355/src/schemas/v1/searches/local-land-charges.json +0 -69
  92. package/pensive-tesla-d0d355/src/schemas/v1/searches/local-searches-required.json +0 -857
  93. package/pensive-tesla-d0d355/src/schemas/v1/searches.json +0 -237
  94. package/pensive-tesla-d0d355/src/schemas/v1/title-deed.json +0 -841
  95. package/pensive-tesla-d0d355/src/schemas/v2/baspiNotes.html +0 -102
  96. package/pensive-tesla-d0d355/src/schemas/v2/combined.json +0 -37731
  97. package/pensive-tesla-d0d355/src/schemas/v2/overlays/baspi.json +0 -8132
  98. package/pensive-tesla-d0d355/src/schemas/v2/overlays/con29DW.json +0 -705
  99. package/pensive-tesla-d0d355/src/schemas/v2/overlays/con29R.json +0 -2956
  100. package/pensive-tesla-d0d355/src/schemas/v2/overlays/fme1.json +0 -1259
  101. package/pensive-tesla-d0d355/src/schemas/v2/overlays/llc1.json +0 -25
  102. package/pensive-tesla-d0d355/src/schemas/v2/overlays/lpe1.json +0 -2171
  103. package/pensive-tesla-d0d355/src/schemas/v2/overlays/nts.json +0 -326
  104. package/pensive-tesla-d0d355/src/schemas/v2/overlays/oc1.json +0 -2799
  105. package/pensive-tesla-d0d355/src/schemas/v2/overlays/piq.json +0 -3419
  106. package/pensive-tesla-d0d355/src/schemas/v2/overlays/rds.json +0 -3736
  107. package/pensive-tesla-d0d355/src/schemas/v2/overlays/ta10.json +0 -5306
  108. package/pensive-tesla-d0d355/src/schemas/v2/overlays/ta6.json +0 -4533
  109. package/pensive-tesla-d0d355/src/schemas/v2/overlays/ta7.json +0 -1045
  110. package/pensive-tesla-d0d355/src/schemas/v2/pdtf-transaction.json +0 -34351
  111. package/pensive-tesla-d0d355/src/schemas/v2/skeleton.json +0 -3973
  112. package/pensive-tesla-d0d355/src/schemas/v3/combined.json +0 -48469
  113. package/pensive-tesla-d0d355/src/schemas/v3/compactSkeleton.txt +0 -4519
  114. package/pensive-tesla-d0d355/src/schemas/v3/overlays/README.md +0 -299
  115. package/pensive-tesla-d0d355/src/schemas/v3/overlays/baspi4.json +0 -8025
  116. package/pensive-tesla-d0d355/src/schemas/v3/overlays/baspi5.json +0 -8175
  117. package/pensive-tesla-d0d355/src/schemas/v3/overlays/con29DW.json +0 -716
  118. package/pensive-tesla-d0d355/src/schemas/v3/overlays/con29R.json +0 -2981
  119. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/ac.json +0 -333
  120. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/as.json +0 -74
  121. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/dk.json +0 -32
  122. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/dr.json +0 -73
  123. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/er.json +0 -85
  124. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/fd.json +0 -75
  125. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/hi.json +0 -51
  126. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/hs.json +0 -73
  127. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/ic.json +0 -59
  128. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/jk.json +0 -96
  129. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/la.json +0 -85
  130. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/lc.json +0 -75
  131. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/ma.json +0 -90
  132. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/mc.json +0 -38
  133. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/mi.json +0 -69
  134. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/nd.json +0 -43
  135. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/oa.json +0 -24
  136. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/oc.json +0 -57
  137. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/pc.json +0 -37
  138. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/ph.json +0 -194
  139. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/rw.json +0 -68
  140. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/sb.json +0 -73
  141. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/sc.json +0 -129
  142. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/sd.json +0 -63
  143. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/sf.json +0 -74
  144. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/sl.json +0 -68
  145. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/ta.json +0 -252
  146. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/tf.json +0 -103
  147. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/tr.json +0 -73
  148. package/pensive-tesla-d0d355/src/schemas/v3/overlays/extensions/wg.json +0 -350
  149. package/pensive-tesla-d0d355/src/schemas/v3/overlays/fme1.json +0 -1266
  150. package/pensive-tesla-d0d355/src/schemas/v3/overlays/llc1.json +0 -25
  151. package/pensive-tesla-d0d355/src/schemas/v3/overlays/lpe1.json +0 -2199
  152. package/pensive-tesla-d0d355/src/schemas/v3/overlays/nts.json +0 -2157
  153. package/pensive-tesla-d0d355/src/schemas/v3/overlays/nts2.json +0 -2742
  154. package/pensive-tesla-d0d355/src/schemas/v3/overlays/ntsl.json +0 -1813
  155. package/pensive-tesla-d0d355/src/schemas/v3/overlays/ntsl2.json +0 -2217
  156. package/pensive-tesla-d0d355/src/schemas/v3/overlays/oc1.json +0 -2817
  157. package/pensive-tesla-d0d355/src/schemas/v3/overlays/piq.json +0 -3322
  158. package/pensive-tesla-d0d355/src/schemas/v3/overlays/rds.json +0 -3665
  159. package/pensive-tesla-d0d355/src/schemas/v3/overlays/sef25.json +0 -1639
  160. package/pensive-tesla-d0d355/src/schemas/v3/overlays/sr24.json +0 -38
  161. package/pensive-tesla-d0d355/src/schemas/v3/overlays/ta10.json +0 -4654
  162. package/pensive-tesla-d0d355/src/schemas/v3/overlays/ta6ed6.json +0 -6534
  163. package/pensive-tesla-d0d355/src/schemas/v3/overlays/ta7.json +0 -1537
  164. package/pensive-tesla-d0d355/src/schemas/v3/overlays/ta7ed5.json +0 -1551
  165. package/pensive-tesla-d0d355/src/schemas/v3/pdtf-transaction.json +0 -41573
  166. package/pensive-tesla-d0d355/src/schemas/v3/skeleton.json +0 -5767
  167. package/pensive-tesla-d0d355/src/schemas/verifiedClaims/README.md +0 -21
  168. package/pensive-tesla-d0d355/src/schemas/verifiedClaims/pdtf-verified-claims.json +0 -447
  169. package/pensive-tesla-d0d355/src/utils/compactSkeleton.js +0 -84
  170. package/pensive-tesla-d0d355/src/utils/countTokens.js +0 -67
  171. package/pensive-tesla-d0d355/src/utils/extractExtensionOverlays.js +0 -624
  172. package/pensive-tesla-d0d355/src/utils/extractOverlay.js +0 -381
  173. package/pensive-tesla-d0d355/src/utils/extractProperties.js +0 -44
  174. package/pensive-tesla-d0d355/src/utils/listPathTitles.js +0 -36
  175. package/pensive-tesla-d0d355/src/utils/minimalSkeleton.js +0 -85
  176. package/pensive-tesla-d0d355/src/utils/pathList.csv +0 -903
  177. package/pensive-tesla-d0d355/src/utils/pathSkeleton.js +0 -181
  178. package/src/examples/v1/exampleAddParticipantVouch.json +0 -32
  179. package/src/examples/v1/exampleDocumentedVouch.json +0 -40
  180. package/src/examples/v1/exampleElectronicRecord.json +0 -30
  181. package/src/examples/v1/exampleTransaction.json +0 -878
  182. package/src/examples/v1/exampleVouch.json +0 -25
  183. package/src/examples/v2/exampleTransaction.json +0 -901
  184. package/src/examples/v3/exampleAddParticipantVouch.json +0 -38
  185. package/src/examples/v3/exampleCustomOverlay.json +0 -55
  186. package/src/examples/v3/exampleCustomOverlay2.json +0 -93
  187. package/src/examples/v3/exampleDocumentedVouch.json +0 -47
  188. package/src/examples/v3/exampleElectronicRecord.json +0 -36
  189. package/src/examples/v3/exampleTransaction.json +0 -1038
  190. package/src/examples/v3/exampleVouch.json +0 -32
  191. package/src/mappings/SendPropertyDetailsRequestSchema.json +0 -1588
  192. package/src/mappings/adf.js +0 -198
package/index.js CHANGED
@@ -94,6 +94,7 @@ const overlaysMap = {
94
94
  baspiV5: require("./src/schemas/v3/overlays/baspi5.json"),
95
95
  ta6ed4: require("./src/schemas/v3/overlays/ta6.json"),
96
96
  ta6ed6: require("./src/schemas/v3/overlays/ta6ed6.json"),
97
+ ta6ed6v2: require("./src/schemas/v3/overlays/ta6ed6v2.json"),
97
98
  ta7ed3: require("./src/schemas/v3/overlays/ta7.json"),
98
99
  ta7ed5: require("./src/schemas/v3/overlays/ta7ed5.json"),
99
100
  ta10ed3: require("./src/schemas/v3/overlays/ta10.json"),
@@ -224,6 +225,183 @@ const generateOverlayKey = (overlays) => {
224
225
  return overlays.join(".");
225
226
  };
226
227
 
228
+
229
+ // ---------------------------------------------------------------------------
230
+ // Overlay scoping
231
+ //
232
+ // A composed subschema is the CORE schema merged with the requested overlays,
233
+ // so it carries every field the core schema knows about — including questions
234
+ // the requested overlays never ask. Validating that full shape makes a form's
235
+ // completeness depend on questions it does not render: e.g. the NTS Material
236
+ // Information "Ownership" section validated the TA7 leasehold
237
+ // `ownershipAndManagement` node, so a seller who part-answered TA7 could never
238
+ // complete Material Information, with no field named in the error (the core
239
+ // schema keeps the `oneOf` but `extractOverlay` strips the `discriminator` that
240
+ // disambiguated it, so an absent tag matches EVERY branch: "must match exactly
241
+ // one schema in oneOf", passingSchemas [0,1]).
242
+ //
243
+ // Scoping prunes the composed subschema to the fields the requested overlays
244
+ // actually reference, so a form is validated against exactly what it asks.
245
+ //
246
+ // Discriminator tags are preserved even when unreferenced: they are structural,
247
+ // and removing one leaves AJV compiling a `discriminator` whose tag is gone
248
+ // ("oneOf subschemas must have properties/<tag>"). Tags are inherited into
249
+ // `oneOf` branches and `items`, because that is where the tag property lives.
250
+ // ---------------------------------------------------------------------------
251
+
252
+ // Every form overlay id -> the marker `extractOverlay` stamps for it. This must
253
+ // cover EVERY id in `overlaysMap`: an id missing here contributes no ref key, so
254
+ // its fields would look unreferenced and be pruned away. `getOverlayRefKeys`
255
+ // returns null if it sees an unknown id, which disables scoping altogether —
256
+ // under-scoping merely preserves today's behaviour, over-scoping would mark
257
+ // sections complete that are not.
258
+ const overlayToRefMapping = {
259
+ baspiV4: "baspi4Ref",
260
+ baspiV5: "baspi5Ref",
261
+ nts2023: "ntsRef",
262
+ nts2025: "nts2Ref",
263
+ ntsl2023: "ntslRef",
264
+ ntsl2025: "ntsl2Ref",
265
+ ta6ed4: "ta6Ref",
266
+ ta6ed6: "ta6ed6Ref",
267
+ ta6ed6v2: "ta6ed6v2Ref",
268
+ ta7ed3: "ta7Ref",
269
+ ta7ed5: "ta7ed5Ref",
270
+ ta10ed3: "ta10Ref",
271
+ lpe1ed4: "lpe1Ref",
272
+ fme1ed2: "fme1Ref",
273
+ llc1v2: "llc1Ref",
274
+ con29R2019: "con29RRef",
275
+ con29DW: "con29DWRef",
276
+ rdsV333: "rdsRef",
277
+ oc1v21: "oc1Ref",
278
+ piqV3: "piqRef",
279
+ sr24: "sr24Ref",
280
+ };
281
+
282
+ // Extension overlays contribute their host form's ref key(s). `ta` is the TA6
283
+ // compatibility overlay: it exists so TA6 answers can never invalidate the NTS
284
+ // sections, and its marker must therefore count as visible here too — otherwise
285
+ // scoping would prune away the very fields that overlay was added to protect.
286
+ const extensionOverlayToRefs = {
287
+ as: ["ntsRef"],
288
+ dr: ["ntsRef"],
289
+ er: ["ntsRef"],
290
+ fd: ["ntsRef"],
291
+ hi: ["ntsRef"],
292
+ hs: ["ntsRef"],
293
+ jk: ["ntsRef"],
294
+ la: ["ntsRef"],
295
+ ma: ["ntsRef"],
296
+ mc: ["ntsRef"],
297
+ oa: ["ntsRef"],
298
+ oc: ["ntsRef"],
299
+ sb: ["ntsRef"],
300
+ sf: ["ntsRef"],
301
+ sl: ["ntsRef"],
302
+ tf: ["ntsRef"],
303
+ dk: ["ntsRef", "sef25Ref"],
304
+ ic: ["ntsRef", "sef25Ref"],
305
+ lc: ["ntsRef", "sef25Ref"],
306
+ mi: ["ntsRef", "sef25Ref"],
307
+ nd: ["ntsRef", "sef25Ref"],
308
+ pc: ["ntsRef", "sef25Ref"],
309
+ ph: ["ntsRef", "sef25Ref"],
310
+ rw: ["ntsRef", "sef25Ref"],
311
+ sc: ["ntsRef", "sef25Ref"],
312
+ sd: ["ntsRef", "sef25Ref"],
313
+ tr: ["ntsRef", "sef25Ref"],
314
+ wg: ["ntsRef", "sef25Ref"],
315
+ ac: ["ntsRef", "sef25Ref"],
316
+ ta: ["ta6ed6CompatRef"],
317
+ };
318
+
319
+ // Returns the ref keys these overlays reference, or null when scoping must be
320
+ // skipped: an unrecognised overlay id (whose markers we therefore cannot
321
+ // identify) would otherwise have all of its fields pruned as unreferenced.
322
+ const getOverlayRefKeys = (overlays = []) => {
323
+ const overlayIds = (Array.isArray(overlays) ? overlays : [overlays]).filter(
324
+ (id) => id !== null && id !== undefined,
325
+ );
326
+ const refKeys = new Set();
327
+ for (const overlay of overlayIds) {
328
+ const refKey = overlayToRefMapping[overlay];
329
+ const extensionRefs = extensionOverlayToRefs[overlay];
330
+ if (!refKey && !extensionRefs) return null; // unknown id -> do not scope
331
+ if (refKey) refKeys.add(refKey);
332
+ (extensionRefs || []).forEach((k) => refKeys.add(k));
333
+ }
334
+ return [...refKeys];
335
+ };
336
+
337
+ // True when this node, or anything beneath it, is referenced by the overlays.
338
+ const schemaHasVisibleOverlayRef = (schema, refKeys = []) => {
339
+ if (!schema || typeof schema !== "object") return false;
340
+ if (refKeys.some((refKey) => !!schema[refKey])) return true;
341
+ if (schema.items && schemaHasVisibleOverlayRef(schema.items, refKeys))
342
+ return true;
343
+ if (schema.properties) {
344
+ if (
345
+ Object.values(schema.properties).some((p) =>
346
+ schemaHasVisibleOverlayRef(p, refKeys),
347
+ )
348
+ )
349
+ return true;
350
+ }
351
+ if (Array.isArray(schema.oneOf)) {
352
+ return schema.oneOf.some((b) => schemaHasVisibleOverlayRef(b, refKeys));
353
+ }
354
+ return false;
355
+ };
356
+
357
+ // The property names that discriminate this node's `oneOf`: the declared
358
+ // `discriminator`, plus — for a `oneOf` whose discriminator was stripped when
359
+ // the core schema was built — the enum key every branch constrains.
360
+ const discriminatingTags = (node) => {
361
+ const tags = new Set();
362
+ if (node.discriminator?.propertyName) tags.add(node.discriminator.propertyName);
363
+ if (Array.isArray(node.oneOf)) {
364
+ const branchKeys = node.oneOf.map(
365
+ (b) => new Set(Object.keys(b?.properties || {})),
366
+ );
367
+ const common = [...(branchKeys[0] || [])].filter((k) =>
368
+ branchKeys.every((s) => s.has(k)),
369
+ );
370
+ const inferred = common.find((k) =>
371
+ node.oneOf.every((b) => Array.isArray(b.properties[k]?.enum)),
372
+ );
373
+ if (inferred) tags.add(inferred);
374
+ }
375
+ return tags;
376
+ };
377
+
378
+ const pruneToOverlayScope = (node, refKeys, inheritedTags = new Set()) => {
379
+ if (!node || typeof node !== "object") return node;
380
+ const ownTags = discriminatingTags(node);
381
+ const keep = new Set([...ownTags, ...inheritedTags]);
382
+
383
+ if (node.properties) {
384
+ for (const [key, propertySchema] of Object.entries(node.properties)) {
385
+ if (!keep.has(key) && !schemaHasVisibleOverlayRef(propertySchema, refKeys)) {
386
+ delete node.properties[key];
387
+ if (Array.isArray(node.required)) {
388
+ node.required = node.required.filter((r) => r !== key);
389
+ }
390
+ } else {
391
+ pruneToOverlayScope(propertySchema, refKeys, new Set());
392
+ }
393
+ }
394
+ }
395
+ // Tags live inside branches and array items, so they must be inherited there.
396
+ if (node.items) pruneToOverlayScope(node.items, refKeys, ownTags);
397
+ if (Array.isArray(node.oneOf)) {
398
+ for (const branch of node.oneOf) {
399
+ pruneToOverlayScope(branch, refKeys, ownTags);
400
+ }
401
+ }
402
+ return node;
403
+ };
404
+
227
405
  // Enhanced caching function that stores both subschemas and validators
228
406
  const getCachedSchemaData = (path, schemaId, overlays) => {
229
407
  const overlayKey = generateOverlayKey(overlays);
@@ -312,6 +490,17 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
312
490
  }, sourceSchema);
313
491
  }
314
492
 
493
+ // Scope the composed subschema to what these overlays actually ask, so a
494
+ // form's completeness never depends on questions it does not render.
495
+ // No overlays (or none carrying ref keys) => no scoping, shape unchanged.
496
+ const refKeys = getOverlayRefKeys(overlays);
497
+ if (refKeys && refKeys.length > 0 && subSchema && typeof subSchema === "object") {
498
+ subSchema = pruneToOverlayScope(
499
+ JSON.parse(JSON.stringify(subSchema)),
500
+ refKeys,
501
+ );
502
+ }
503
+
315
504
  // Add schema to AJV and get validator
316
505
  // Only add valid schemas to AJV
317
506
  let validator;
@@ -632,6 +821,16 @@ const setCacheMaxSize = (maxSize) => {
632
821
  return keysToDelete.length;
633
822
  };
634
823
 
824
+ const {
825
+ mapping: v4Mapping,
826
+ decompose: decomposeToV4,
827
+ recompose: recomposeFromV4,
828
+ arrayKeyFor: v4ArrayKeyFor,
829
+ identifyV3Pointer,
830
+ resolveV3Pointer,
831
+ resolveV3PointerAll,
832
+ } = require("./src/utils/v4");
833
+
635
834
  module.exports = {
636
835
  ajv,
637
836
  getTransactionSchema,
@@ -640,6 +839,9 @@ module.exports = {
640
839
  isPathValid,
641
840
  getSubschemaValidator,
642
841
  getTitleAtPath,
842
+ getOverlayRefKeys,
843
+ schemaHasVisibleOverlayRef,
844
+ pruneToOverlayScope,
643
845
  verifiedClaimsSchema,
644
846
  validateVerifiedClaims,
645
847
  overlaysMap,
@@ -651,4 +853,12 @@ module.exports = {
651
853
  warmupCache,
652
854
  pruneCacheByAge,
653
855
  setCacheMaxSize,
856
+ // V3 <-> V4 entity decomposition (see src/schemas/v4/mapping.json)
857
+ v4Mapping,
858
+ decomposeToV4,
859
+ recomposeFromV4,
860
+ v4ArrayKeyFor,
861
+ identifyV3Pointer,
862
+ resolveV3Pointer,
863
+ resolveV3PointerAll,
654
864
  };
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "3.6.0-dev.3",
3
+ "version": "3.6.0-dev.30",
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
  },
@@ -11,6 +19,7 @@
11
19
  "test:watch": "jest --watch",
12
20
  "extract-overlays": "cd src/utils && node extractOverlay.js",
13
21
  "extract-extension-overlays": "cd src/utils && node extractExtensionOverlays.js",
22
+ "generate:v4": "node src/utils/generateV4Schemas.js",
14
23
  "publish:dev": "npm publish --tag dev",
15
24
  "publish:next": "npm publish --tag next",
16
25
  "publish:latest": "npm publish --tag latest"