@pdtf/schemas 3.0.1-5 → 3.0.3-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/index.js +1 -0
- package/package.json +1 -1
- package/src/examples/v3/exampleTransaction.json +5 -1
- package/src/schemas/v3/combined.json +2992 -693
- package/src/schemas/v3/overlays/baspi.json +2 -2
- package/src/schemas/v3/overlays/con29R.json +1 -1
- package/src/schemas/v3/overlays/nts.json +2 -1
- package/src/schemas/v3/overlays/ntsl.json +1641 -0
- package/src/schemas/v3/overlays/piq.json +1 -26
- package/src/schemas/v3/overlays/rds.json +1 -26
- package/src/schemas/v3/overlays/ta10.json +2410 -770
- package/src/schemas/v3/overlays/ta7.json +1 -1
- package/src/schemas/v3/pdtf-transaction.json +2620 -663
- package/src/schemas/v3/skeleton.json +59 -33
- package/src/tests/v3/transactionSchema.test.js +26 -0
- package/src/utils/extractOverlay.js +34 -58
|
@@ -64,6 +64,12 @@
|
|
|
64
64
|
"priceQualifier": {},
|
|
65
65
|
"disposal": {}
|
|
66
66
|
},
|
|
67
|
+
"lettingInformation": {
|
|
68
|
+
"rent": {},
|
|
69
|
+
"rentFrequency": {},
|
|
70
|
+
"securityDeposit": {},
|
|
71
|
+
"holdingDeposit": {}
|
|
72
|
+
},
|
|
67
73
|
"summaryDescription": {},
|
|
68
74
|
"marketingTenure": {},
|
|
69
75
|
"media": {
|
|
@@ -1447,97 +1453,110 @@
|
|
|
1447
1453
|
"otherItems": {
|
|
1448
1454
|
"itemName": {},
|
|
1449
1455
|
"isIncludedOrExcluded": {},
|
|
1456
|
+
"comments": {},
|
|
1450
1457
|
"price": {}
|
|
1451
1458
|
}
|
|
1452
1459
|
},
|
|
1453
1460
|
"kitchen": {
|
|
1454
1461
|
"hob": {
|
|
1455
1462
|
"isIncludedExcludedOrNone": {},
|
|
1456
|
-
"comments": {},
|
|
1457
1463
|
"fittedOrFreestanding": {
|
|
1458
|
-
"
|
|
1464
|
+
"isFittedOrFreestanding": {},
|
|
1465
|
+
"comments": {}
|
|
1459
1466
|
},
|
|
1460
|
-
"price": {}
|
|
1467
|
+
"price": {},
|
|
1468
|
+
"comments": {}
|
|
1461
1469
|
},
|
|
1462
1470
|
"extractorHood": {
|
|
1463
1471
|
"isIncludedExcludedOrNone": {},
|
|
1464
|
-
"comments": {},
|
|
1465
1472
|
"fittedOrFreestanding": {
|
|
1466
|
-
"
|
|
1473
|
+
"isFittedOrFreestanding": {},
|
|
1474
|
+
"comments": {}
|
|
1467
1475
|
},
|
|
1468
|
-
"price": {}
|
|
1476
|
+
"price": {},
|
|
1477
|
+
"comments": {}
|
|
1469
1478
|
},
|
|
1470
1479
|
"ovenGrill": {
|
|
1471
1480
|
"isIncludedExcludedOrNone": {},
|
|
1472
|
-
"comments": {},
|
|
1473
1481
|
"fittedOrFreestanding": {
|
|
1474
|
-
"
|
|
1482
|
+
"isFittedOrFreestanding": {},
|
|
1483
|
+
"comments": {}
|
|
1475
1484
|
},
|
|
1476
|
-
"price": {}
|
|
1485
|
+
"price": {},
|
|
1486
|
+
"comments": {}
|
|
1477
1487
|
},
|
|
1478
1488
|
"cooker": {
|
|
1479
1489
|
"isIncludedExcludedOrNone": {},
|
|
1480
|
-
"comments": {},
|
|
1481
1490
|
"fittedOrFreestanding": {
|
|
1482
|
-
"
|
|
1491
|
+
"isFittedOrFreestanding": {},
|
|
1492
|
+
"comments": {}
|
|
1483
1493
|
},
|
|
1484
|
-
"price": {}
|
|
1494
|
+
"price": {},
|
|
1495
|
+
"comments": {}
|
|
1485
1496
|
},
|
|
1486
1497
|
"microwave": {
|
|
1487
1498
|
"isIncludedExcludedOrNone": {},
|
|
1488
|
-
"comments": {},
|
|
1489
1499
|
"fittedOrFreestanding": {
|
|
1490
|
-
"
|
|
1500
|
+
"isFittedOrFreestanding": {},
|
|
1501
|
+
"comments": {}
|
|
1491
1502
|
},
|
|
1492
|
-
"price": {}
|
|
1503
|
+
"price": {},
|
|
1504
|
+
"comments": {}
|
|
1493
1505
|
},
|
|
1494
1506
|
"refrigeratorFridgeFreezer": {
|
|
1495
1507
|
"isIncludedExcludedOrNone": {},
|
|
1496
|
-
"comments": {},
|
|
1497
1508
|
"fittedOrFreestanding": {
|
|
1498
|
-
"
|
|
1509
|
+
"isFittedOrFreestanding": {},
|
|
1510
|
+
"comments": {}
|
|
1499
1511
|
},
|
|
1500
|
-
"price": {}
|
|
1512
|
+
"price": {},
|
|
1513
|
+
"comments": {}
|
|
1501
1514
|
},
|
|
1502
1515
|
"freezer": {
|
|
1503
1516
|
"isIncludedExcludedOrNone": {},
|
|
1504
|
-
"comments": {},
|
|
1505
1517
|
"fittedOrFreestanding": {
|
|
1506
|
-
"
|
|
1518
|
+
"isFittedOrFreestanding": {},
|
|
1519
|
+
"comments": {}
|
|
1507
1520
|
},
|
|
1508
|
-
"price": {}
|
|
1521
|
+
"price": {},
|
|
1522
|
+
"comments": {}
|
|
1509
1523
|
},
|
|
1510
1524
|
"dishwasher": {
|
|
1511
1525
|
"isIncludedExcludedOrNone": {},
|
|
1512
|
-
"comments": {},
|
|
1513
1526
|
"fittedOrFreestanding": {
|
|
1514
|
-
"
|
|
1527
|
+
"isFittedOrFreestanding": {},
|
|
1528
|
+
"comments": {}
|
|
1515
1529
|
},
|
|
1516
|
-
"price": {}
|
|
1530
|
+
"price": {},
|
|
1531
|
+
"comments": {}
|
|
1517
1532
|
},
|
|
1518
1533
|
"tumbleDryer": {
|
|
1519
1534
|
"isIncludedExcludedOrNone": {},
|
|
1520
|
-
"comments": {},
|
|
1521
1535
|
"fittedOrFreestanding": {
|
|
1522
|
-
"
|
|
1536
|
+
"isFittedOrFreestanding": {},
|
|
1537
|
+
"comments": {}
|
|
1523
1538
|
},
|
|
1524
|
-
"price": {}
|
|
1539
|
+
"price": {},
|
|
1540
|
+
"comments": {}
|
|
1525
1541
|
},
|
|
1526
1542
|
"washingMachine": {
|
|
1527
1543
|
"isIncludedExcludedOrNone": {},
|
|
1528
|
-
"comments": {},
|
|
1529
1544
|
"fittedOrFreestanding": {
|
|
1530
|
-
"
|
|
1545
|
+
"isFittedOrFreestanding": {},
|
|
1546
|
+
"comments": {}
|
|
1531
1547
|
},
|
|
1532
|
-
"price": {}
|
|
1548
|
+
"price": {},
|
|
1549
|
+
"comments": {}
|
|
1533
1550
|
},
|
|
1534
1551
|
"otherItems": {
|
|
1535
1552
|
"itemName": {},
|
|
1536
1553
|
"isIncludedOrExcluded": {},
|
|
1537
1554
|
"fittedOrFreestanding": {
|
|
1538
|
-
"
|
|
1555
|
+
"isFittedOrFreestanding": {},
|
|
1556
|
+
"comments": {}
|
|
1539
1557
|
},
|
|
1540
|
-
"price": {}
|
|
1558
|
+
"price": {},
|
|
1559
|
+
"comments": {}
|
|
1541
1560
|
}
|
|
1542
1561
|
},
|
|
1543
1562
|
"bathroom": {
|
|
@@ -1631,6 +1650,7 @@
|
|
|
1631
1650
|
"otherRooms": {
|
|
1632
1651
|
"itemName": {},
|
|
1633
1652
|
"isIncludedOrExcluded": {},
|
|
1653
|
+
"comments": {},
|
|
1634
1654
|
"price": {}
|
|
1635
1655
|
}
|
|
1636
1656
|
},
|
|
@@ -1674,6 +1694,7 @@
|
|
|
1674
1694
|
"otherRooms": {
|
|
1675
1695
|
"itemName": {},
|
|
1676
1696
|
"isIncludedOrExcluded": {},
|
|
1697
|
+
"comments": {},
|
|
1677
1698
|
"price": {}
|
|
1678
1699
|
}
|
|
1679
1700
|
},
|
|
@@ -1716,6 +1737,7 @@
|
|
|
1716
1737
|
"otherRooms": {
|
|
1717
1738
|
"itemName": {},
|
|
1718
1739
|
"isIncludedOrExcluded": {},
|
|
1740
|
+
"comments": {},
|
|
1719
1741
|
"price": {}
|
|
1720
1742
|
}
|
|
1721
1743
|
}
|
|
@@ -1759,6 +1781,7 @@
|
|
|
1759
1781
|
"otherRooms": {
|
|
1760
1782
|
"itemName": {},
|
|
1761
1783
|
"isIncludedOrExcluded": {},
|
|
1784
|
+
"comments": {},
|
|
1762
1785
|
"price": {}
|
|
1763
1786
|
}
|
|
1764
1787
|
},
|
|
@@ -1801,6 +1824,7 @@
|
|
|
1801
1824
|
"otherRooms": {
|
|
1802
1825
|
"itemName": {},
|
|
1803
1826
|
"isIncludedOrExcluded": {},
|
|
1827
|
+
"comments": {},
|
|
1804
1828
|
"price": {}
|
|
1805
1829
|
}
|
|
1806
1830
|
},
|
|
@@ -1868,6 +1892,7 @@
|
|
|
1868
1892
|
"otherItems": {
|
|
1869
1893
|
"itemName": {},
|
|
1870
1894
|
"isIncludedOrExcluded": {},
|
|
1895
|
+
"comments": {},
|
|
1871
1896
|
"price": {}
|
|
1872
1897
|
}
|
|
1873
1898
|
},
|
|
@@ -1914,6 +1939,7 @@
|
|
|
1914
1939
|
"otherItems": {
|
|
1915
1940
|
"itemName": {},
|
|
1916
1941
|
"isIncludedOrExcluded": {},
|
|
1942
|
+
"comments": {},
|
|
1917
1943
|
"price": {}
|
|
1918
1944
|
}
|
|
1919
1945
|
},
|
|
@@ -3306,7 +3332,7 @@
|
|
|
3306
3332
|
"yesNo": {},
|
|
3307
3333
|
"details": {}
|
|
3308
3334
|
},
|
|
3309
|
-
"
|
|
3335
|
+
"lheLocalAuthorityReceivedANoticeOfDisposal": {
|
|
3310
3336
|
"yesNo": {},
|
|
3311
3337
|
"details": {}
|
|
3312
3338
|
},
|
|
@@ -43,6 +43,32 @@ test("sample is valid NTS", () => {
|
|
|
43
43
|
expect(isValid).toBe(true);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
test("sample is not valid NTSL (lettings)", () => {
|
|
47
|
+
const validator = getValidator(schemaId, ["ntsl2023"]);
|
|
48
|
+
const isValid = validator(exampleTransaction);
|
|
49
|
+
expect(isValid).toBe(false);
|
|
50
|
+
expect(validator.errors[0].message).toBe(
|
|
51
|
+
"must have required property 'lettingInformation'"
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("sample is valid NTSL if we change it accordingly", () => {
|
|
56
|
+
const validator = getValidator(schemaId, ["ntsl2023"]);
|
|
57
|
+
const clonedExampleTransaction = JSON.parse(
|
|
58
|
+
JSON.stringify(exampleTransaction)
|
|
59
|
+
);
|
|
60
|
+
clonedExampleTransaction.propertyPack.lettingInformation = {
|
|
61
|
+
rent: 3500,
|
|
62
|
+
rentFrequency: "Monthly",
|
|
63
|
+
securityDeposit: 5000,
|
|
64
|
+
};
|
|
65
|
+
delete clonedExampleTransaction.propertyPack.priceInformation;
|
|
66
|
+
delete clonedExampleTransaction.propertyPack.ownership;
|
|
67
|
+
const isValid = validator(clonedExampleTransaction);
|
|
68
|
+
if (!isValid) console.log(validator.errors);
|
|
69
|
+
expect(isValid).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
46
72
|
test("invalid sample is invalid", () => {
|
|
47
73
|
const clonedExampleTransaction = JSON.parse(
|
|
48
74
|
JSON.stringify(exampleTransaction)
|
|
@@ -9,6 +9,7 @@ const combinedSchema = require("../schemas/v3/combined.json");
|
|
|
9
9
|
const extractFields = [
|
|
10
10
|
"baspi",
|
|
11
11
|
"nts",
|
|
12
|
+
"ntsl",
|
|
12
13
|
"ta6",
|
|
13
14
|
"ta7",
|
|
14
15
|
"ta10",
|
|
@@ -22,14 +23,6 @@ const extractFields = [
|
|
|
22
23
|
"oc1",
|
|
23
24
|
];
|
|
24
25
|
|
|
25
|
-
const overlayIncludeProperties = [
|
|
26
|
-
// "title",
|
|
27
|
-
// "description",
|
|
28
|
-
// "enum",
|
|
29
|
-
"discriminator",
|
|
30
|
-
// "minItems",
|
|
31
|
-
];
|
|
32
|
-
|
|
33
26
|
const flattenSkeleton = (schema) => {
|
|
34
27
|
if (!schema) return undefined;
|
|
35
28
|
let returnStructure = {};
|
|
@@ -64,60 +57,43 @@ const extractOverlay = (sourceSchema, ref) => {
|
|
|
64
57
|
if (path === "/") path = "";
|
|
65
58
|
if (element[refName]) {
|
|
66
59
|
jp.set(returnSchema, `${path}/${refName}`, element[refName]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
discriminatorEnumPath,
|
|
81
|
-
discriminatorProperty[refEnum]
|
|
82
|
-
);
|
|
83
|
-
} else {
|
|
84
|
-
// use the base enum
|
|
85
|
-
jp.set(
|
|
86
|
-
returnSchema,
|
|
87
|
-
discriminatorEnumPath,
|
|
88
|
-
discriminatorProperty.enum
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// also handle discriminator properties nested in items
|
|
95
|
-
if (element.items?.discriminator) {
|
|
96
|
-
jp.set(
|
|
97
|
-
returnSchema,
|
|
98
|
-
`${path}/items/discriminator`,
|
|
99
|
-
element.items.discriminator
|
|
100
|
-
);
|
|
101
|
-
const { propertyName } = element.items.discriminator;
|
|
102
|
-
element.items.oneOf.forEach((oneOf, index) => {
|
|
103
|
-
const discriminatorProperty = oneOf.properties[propertyName];
|
|
104
|
-
// must be an enum
|
|
105
|
-
const discriminatorEnumPath = `${path}/items/oneOf/${index}/properties/${propertyName}/enum`;
|
|
106
|
-
// if a refEnum use that
|
|
107
|
-
const refEnum = `${ref}Enum`;
|
|
108
|
-
if (discriminatorProperty[refEnum]) {
|
|
60
|
+
overlayIncludeProperties.forEach((property) => {
|
|
61
|
+
if (element[property]) {
|
|
62
|
+
jp.set(returnSchema, `${path}/${property}`, element[property]);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const { discriminator } = element;
|
|
67
|
+
if (discriminator) {
|
|
68
|
+
const { propertyName } = discriminator;
|
|
69
|
+
element.oneOf.forEach((item, index) => {
|
|
70
|
+
const discriminatorProperty = item.properties[propertyName];
|
|
71
|
+
// copy const discriminator as-is
|
|
72
|
+
if (discriminatorProperty.const) {
|
|
109
73
|
jp.set(
|
|
110
74
|
returnSchema,
|
|
111
|
-
|
|
112
|
-
discriminatorProperty
|
|
75
|
+
`${path}/oneOf/${index}/properties/${propertyName}/const`,
|
|
76
|
+
discriminatorProperty.const
|
|
113
77
|
);
|
|
114
78
|
} else {
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
79
|
+
// must be an enum
|
|
80
|
+
const discriminatorEnumPath = `${path}/oneOf/${index}/properties/${propertyName}/enum`;
|
|
81
|
+
// if a refEnum use that
|
|
82
|
+
const refEnum = `${ref}Enum`;
|
|
83
|
+
if (discriminatorProperty[refEnum]) {
|
|
84
|
+
jp.set(
|
|
85
|
+
returnSchema,
|
|
86
|
+
discriminatorEnumPath,
|
|
87
|
+
discriminatorProperty[refEnum]
|
|
88
|
+
);
|
|
89
|
+
} else {
|
|
90
|
+
// use the base enum
|
|
91
|
+
jp.set(
|
|
92
|
+
returnSchema,
|
|
93
|
+
discriminatorEnumPath,
|
|
94
|
+
discriminatorProperty.enum
|
|
95
|
+
);
|
|
96
|
+
}
|
|
121
97
|
}
|
|
122
98
|
});
|
|
123
99
|
}
|