@pdtf/schemas 3.5.1-7 → 3.5.1-9
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 +16 -9
- package/package.json +1 -1
- package/src/schemas/v3/combined.json +16 -8
- package/src/schemas/v3/compactSkeleton.txt +1 -0
- package/src/schemas/v3/overlays/ta7.json +9 -1
- package/src/schemas/v3/pdtf-transaction.json +14 -8
- package/src/schemas/v3/skeleton.json +3 -1
- package/src/tests/v3/transactionSchema.test.js +22 -0
package/index.js
CHANGED
|
@@ -104,7 +104,7 @@ const transactionSchemas = {
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
// Custom array merge function for oneOf arrays
|
|
107
|
-
const arrayMerge = (target, source) => {
|
|
107
|
+
const arrayMerge = (target, source, options) => {
|
|
108
108
|
// For string arrays (enum, required, etc.)
|
|
109
109
|
if (
|
|
110
110
|
target.length > 0 &&
|
|
@@ -114,16 +114,23 @@ const arrayMerge = (target, source) => {
|
|
|
114
114
|
source[0] &&
|
|
115
115
|
typeof source[0] === "string"
|
|
116
116
|
) {
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
|
|
117
|
+
// Detect if this is a required array by checking the parent key
|
|
118
|
+
// Required arrays are property names (camelCase, no spaces)
|
|
119
|
+
// Enum arrays are values (can contain spaces, capitals, etc.)
|
|
120
|
+
const isRequiredArray = target.every(
|
|
120
121
|
(item) =>
|
|
121
122
|
typeof item === "string" &&
|
|
122
123
|
item.length > 0 &&
|
|
123
|
-
|
|
124
|
-
!item.includes("
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
// Required field names are typically camelCase without spaces
|
|
125
|
+
!item.includes(" ") &&
|
|
126
|
+
// First character is usually lowercase for field names
|
|
127
|
+
(item[0] === item[0].toLowerCase() || item.startsWith("is") || item.startsWith("has"))
|
|
128
|
+
) && source.every(
|
|
129
|
+
(item) =>
|
|
130
|
+
typeof item === "string" &&
|
|
131
|
+
item.length > 0 &&
|
|
132
|
+
!item.includes(" ") &&
|
|
133
|
+
(item[0] === item[0].toLowerCase() || item.startsWith("is") || item.startsWith("has"))
|
|
127
134
|
);
|
|
128
135
|
|
|
129
136
|
if (isRequiredArray) {
|
|
@@ -137,7 +144,7 @@ const arrayMerge = (target, source) => {
|
|
|
137
144
|
return combined;
|
|
138
145
|
}
|
|
139
146
|
|
|
140
|
-
// For other string arrays (like enum),
|
|
147
|
+
// For other string arrays (like enum), replace with source
|
|
141
148
|
return source.length > 0 ? source : target;
|
|
142
149
|
}
|
|
143
150
|
|
package/package.json
CHANGED
|
@@ -4246,14 +4246,22 @@
|
|
|
4246
4246
|
"properties": {
|
|
4247
4247
|
"typeOfLeasehold": {
|
|
4248
4248
|
"ta7Ref": "1.1",
|
|
4249
|
-
"title": "
|
|
4250
|
-
"
|
|
4251
|
-
"
|
|
4252
|
-
"
|
|
4253
|
-
"
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4249
|
+
"title": "Type of leasehold property",
|
|
4250
|
+
"type": "object",
|
|
4251
|
+
"ta7Required": ["leaseholdType"],
|
|
4252
|
+
"properties": {
|
|
4253
|
+
"leaseholdType": {
|
|
4254
|
+
"ta7Ref": "1.1.1",
|
|
4255
|
+
"title": "What type of leasehold property does the seller own?",
|
|
4256
|
+
"description": "'Flat'includes maisonette and apartment.",
|
|
4257
|
+
"type": "string",
|
|
4258
|
+
"enum": [
|
|
4259
|
+
"Flat",
|
|
4260
|
+
"Shared ownership",
|
|
4261
|
+
"Long leasehold house"
|
|
4262
|
+
]
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4257
4265
|
},
|
|
4258
4266
|
"sharedOwnership": {
|
|
4259
4267
|
"baspi4Ref": "A1.3.1",
|
|
@@ -86,7 +86,15 @@
|
|
|
86
86
|
],
|
|
87
87
|
"properties": {
|
|
88
88
|
"typeOfLeasehold": {
|
|
89
|
-
"ta7Ref": "1.1"
|
|
89
|
+
"ta7Ref": "1.1",
|
|
90
|
+
"required": [
|
|
91
|
+
"leaseholdType"
|
|
92
|
+
],
|
|
93
|
+
"properties": {
|
|
94
|
+
"leaseholdType": {
|
|
95
|
+
"ta7Ref": "1.1.1"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
90
98
|
},
|
|
91
99
|
"sharedOwnership": {
|
|
92
100
|
"required": [
|
|
@@ -3517,14 +3517,20 @@
|
|
|
3517
3517
|
"type": "object",
|
|
3518
3518
|
"properties": {
|
|
3519
3519
|
"typeOfLeasehold": {
|
|
3520
|
-
"title": "
|
|
3521
|
-
"
|
|
3522
|
-
"
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3520
|
+
"title": "Type of leasehold property",
|
|
3521
|
+
"type": "object",
|
|
3522
|
+
"properties": {
|
|
3523
|
+
"leaseholdType": {
|
|
3524
|
+
"title": "What type of leasehold property does the seller own?",
|
|
3525
|
+
"description": "'Flat'includes maisonette and apartment.",
|
|
3526
|
+
"type": "string",
|
|
3527
|
+
"enum": [
|
|
3528
|
+
"Flat",
|
|
3529
|
+
"Shared ownership",
|
|
3530
|
+
"Long leasehold house"
|
|
3531
|
+
]
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3528
3534
|
},
|
|
3529
3535
|
"sharedOwnership": {
|
|
3530
3536
|
"type": "object",
|
|
@@ -591,3 +591,25 @@ test("waterAndDrainage state with mainsFoulDrainage No missing offMainsDrainageS
|
|
|
591
591
|
);
|
|
592
592
|
expect(relevantError).toBeDefined();
|
|
593
593
|
});
|
|
594
|
+
|
|
595
|
+
test("TA7 overlay organisesBuildingInsurance enum has exactly three items", () => {
|
|
596
|
+
const schema = getTransactionSchema(schemaId, ["ta7ed3"]);
|
|
597
|
+
|
|
598
|
+
// Navigate to the organisesBuildingInsurance property in the merged schema
|
|
599
|
+
const organisesBuildingInsurance =
|
|
600
|
+
schema.properties?.propertyPack?.properties?.ownership?.properties
|
|
601
|
+
?.ownershipsToBeTransferred?.items?.oneOf?.[2]?.properties
|
|
602
|
+
?.leaseholdInformation?.properties?.contactDetails?.properties
|
|
603
|
+
?.serviceContactAssignments?.properties?.organisesBuildingInsurance;
|
|
604
|
+
|
|
605
|
+
expect(organisesBuildingInsurance).toBeDefined();
|
|
606
|
+
expect(organisesBuildingInsurance.enum).toBeDefined();
|
|
607
|
+
|
|
608
|
+
// The TA7 overlay defines exactly 3 enum values, which should replace the base schema's 6 values
|
|
609
|
+
expect(organisesBuildingInsurance.enum).toHaveLength(3);
|
|
610
|
+
expect(organisesBuildingInsurance.enum).toEqual([
|
|
611
|
+
"the Lessees",
|
|
612
|
+
"Management Company",
|
|
613
|
+
"Landlord",
|
|
614
|
+
]);
|
|
615
|
+
});
|