@defra/fcp-sfd-frontend-engine 0.36.1 → 0.37.0
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/dist/index.cjs +158 -54
- package/dist/index.js +158 -54
- package/package.json +1 -1
- package/src/utils/build-update-business-address-variables.js +33 -0
- package/src/utils/build-update-business-legal-status-variables.js +15 -0
- package/src/utils/build-update-business-registration-numbers-variables.js +20 -0
- package/src/utils/build-update-customer-address-variables.js +27 -0
- package/src/utils/build-update-customer-dob-variables.js +25 -0
- package/src/utils/build-update-customer-email-variables.js +17 -0
- package/src/utils/build-update-customer-name-variables.js +19 -0
- package/src/utils/build-update-customer-phone-variables.js +19 -0
- package/src/utils/utils.js +17 -1
package/dist/index.cjs
CHANGED
|
@@ -962,11 +962,85 @@ var formatValidationErrors = (errors) => {
|
|
|
962
962
|
return formattedErrors;
|
|
963
963
|
};
|
|
964
964
|
|
|
965
|
+
// src/services/build-address-variables-service.js
|
|
966
|
+
var buildUprnAddress = (change) => {
|
|
967
|
+
return {
|
|
968
|
+
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
969
|
+
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
970
|
+
buildingName: nullIfUndefined(change.buildingName),
|
|
971
|
+
flatName: nullIfUndefined(change.flatName),
|
|
972
|
+
street: nullIfUndefined(change.street),
|
|
973
|
+
city: nullIfUndefined(change.city),
|
|
974
|
+
county: nullIfUndefined(change.county),
|
|
975
|
+
postalCode: nullIfUndefined(change.postcode),
|
|
976
|
+
country: nullIfUndefined(change.country),
|
|
977
|
+
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
978
|
+
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
979
|
+
line1: null,
|
|
980
|
+
line2: null,
|
|
981
|
+
line3: null,
|
|
982
|
+
line4: null,
|
|
983
|
+
line5: null,
|
|
984
|
+
uprn: change.uprn
|
|
985
|
+
// required for DAL/v1
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
var buildManualAddress = (change) => {
|
|
989
|
+
return {
|
|
990
|
+
pafOrganisationName: null,
|
|
991
|
+
buildingNumberRange: null,
|
|
992
|
+
buildingName: null,
|
|
993
|
+
flatName: null,
|
|
994
|
+
street: null,
|
|
995
|
+
dependentLocality: null,
|
|
996
|
+
doubleDependentLocality: null,
|
|
997
|
+
county: null,
|
|
998
|
+
uprn: null,
|
|
999
|
+
line1: change.address1,
|
|
1000
|
+
// required for DAL/v1
|
|
1001
|
+
line2: nullIfUndefined(change.address2),
|
|
1002
|
+
line3: nullIfUndefined(change.address3),
|
|
1003
|
+
line4: nullIfUndefined(change.county),
|
|
1004
|
+
// manual county mapped for validation
|
|
1005
|
+
line5: null,
|
|
1006
|
+
city: change.city,
|
|
1007
|
+
// required for DAL/v1
|
|
1008
|
+
postalCode: change.postcode,
|
|
1009
|
+
// required for DAL/v1
|
|
1010
|
+
country: change.country
|
|
1011
|
+
// required for DAL/v1
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
1014
|
+
var nullIfUndefined = (value) => {
|
|
1015
|
+
return value ?? null;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
// src/utils/build-update-business-address-variables.js
|
|
1019
|
+
var buildUpdateBusinessAddressVariables = (change, sbi) => {
|
|
1020
|
+
const address = change.uprn ? { withUprn: buildUprnAddress(change) } : { withoutUprn: buildManualAddress(change) };
|
|
1021
|
+
return {
|
|
1022
|
+
input: {
|
|
1023
|
+
sbi,
|
|
1024
|
+
address
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
|
|
965
1029
|
// src/utils/build-update-business-email-variables.js
|
|
966
1030
|
var buildUpdateBusinessEmailVariables = (email, sbi) => {
|
|
967
1031
|
return { input: { email: { address: email }, sbi } };
|
|
968
1032
|
};
|
|
969
1033
|
|
|
1034
|
+
// src/utils/build-update-business-legal-status-variables.js
|
|
1035
|
+
var buildUpdateBusinessLegalStatusVariables = (legalStatusCode, sbi) => {
|
|
1036
|
+
return {
|
|
1037
|
+
input: {
|
|
1038
|
+
sbi,
|
|
1039
|
+
legalStatusCode: Number(legalStatusCode)
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
};
|
|
1043
|
+
|
|
970
1044
|
// src/utils/build-update-business-name-variables.js
|
|
971
1045
|
var buildUpdateBusinessNameVariables = (name, sbi) => {
|
|
972
1046
|
return { input: { name, sbi } };
|
|
@@ -985,6 +1059,19 @@ var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobil
|
|
|
985
1059
|
};
|
|
986
1060
|
};
|
|
987
1061
|
|
|
1062
|
+
// src/utils/build-update-business-registration-numbers-variables.js
|
|
1063
|
+
var buildUpdateBusinessRegistrationNumbersVariables = (companiesHouse, charityCommission, sbi) => {
|
|
1064
|
+
return {
|
|
1065
|
+
input: {
|
|
1066
|
+
sbi,
|
|
1067
|
+
registrationNumbers: {
|
|
1068
|
+
companiesHouse: companiesHouse ?? null,
|
|
1069
|
+
charityCommission: charityCommission ?? null
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
|
|
988
1075
|
// src/utils/build-update-business-vat-variables.js
|
|
989
1076
|
var buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
990
1077
|
return {
|
|
@@ -995,14 +1082,84 @@ var buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
|
995
1082
|
};
|
|
996
1083
|
};
|
|
997
1084
|
|
|
1085
|
+
// src/utils/build-update-customer-address-variables.js
|
|
1086
|
+
var buildUpdateCustomerAddressVariables = (change, crn) => {
|
|
1087
|
+
return {
|
|
1088
|
+
input: {
|
|
1089
|
+
crn,
|
|
1090
|
+
address: change.uprn ? buildUprnAddress(change) : buildManualAddress(change)
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
// src/utils/build-update-customer-dob-variables.js
|
|
1096
|
+
var buildUpdateCustomerDobVariables = (day, month, year, crn) => {
|
|
1097
|
+
const dateOfBirth = [
|
|
1098
|
+
String(year).padStart(4, "0"),
|
|
1099
|
+
String(month).padStart(2, "0"),
|
|
1100
|
+
String(day).padStart(2, "0")
|
|
1101
|
+
].join("-");
|
|
1102
|
+
return {
|
|
1103
|
+
input: {
|
|
1104
|
+
dateOfBirth,
|
|
1105
|
+
crn
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// src/utils/build-update-customer-email-variables.js
|
|
1111
|
+
var buildUpdateCustomerEmailVariables = (email, crn) => {
|
|
1112
|
+
return {
|
|
1113
|
+
input: {
|
|
1114
|
+
email: {
|
|
1115
|
+
address: email
|
|
1116
|
+
},
|
|
1117
|
+
crn
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
// src/utils/build-update-customer-name-variables.js
|
|
1123
|
+
var buildUpdateCustomerNameVariables = (first, last, middle, crn) => {
|
|
1124
|
+
return {
|
|
1125
|
+
input: {
|
|
1126
|
+
first,
|
|
1127
|
+
last,
|
|
1128
|
+
middle: middle ?? null,
|
|
1129
|
+
crn
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
// src/utils/build-update-customer-phone-variables.js
|
|
1135
|
+
var buildUpdateCustomerPhoneVariables = (personalTelephone, personalMobile, crn) => {
|
|
1136
|
+
return {
|
|
1137
|
+
input: {
|
|
1138
|
+
phone: {
|
|
1139
|
+
landline: personalTelephone ?? null,
|
|
1140
|
+
mobile: personalMobile ?? null
|
|
1141
|
+
},
|
|
1142
|
+
crn
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
};
|
|
1146
|
+
|
|
998
1147
|
// src/utils/utils.js
|
|
999
1148
|
var utils = {
|
|
1000
1149
|
formatFullName,
|
|
1001
1150
|
formatValidationErrors,
|
|
1151
|
+
buildUpdateBusinessAddressVariables,
|
|
1002
1152
|
buildUpdateBusinessEmailVariables,
|
|
1153
|
+
buildUpdateBusinessLegalStatusVariables,
|
|
1003
1154
|
buildUpdateBusinessNameVariables,
|
|
1004
1155
|
buildUpdateBusinessPhoneNumbersVariables,
|
|
1005
|
-
|
|
1156
|
+
buildUpdateBusinessRegistrationNumbersVariables,
|
|
1157
|
+
buildUpdateBusinessVatVariables,
|
|
1158
|
+
buildUpdateCustomerAddressVariables,
|
|
1159
|
+
buildUpdateCustomerDobVariables,
|
|
1160
|
+
buildUpdateCustomerEmailVariables,
|
|
1161
|
+
buildUpdateCustomerNameVariables,
|
|
1162
|
+
buildUpdateCustomerPhoneVariables
|
|
1006
1163
|
};
|
|
1007
1164
|
|
|
1008
1165
|
// src/mappers/personal-details-mapper.js
|
|
@@ -1544,59 +1701,6 @@ var presenters = {
|
|
|
1544
1701
|
addressChangeLink
|
|
1545
1702
|
};
|
|
1546
1703
|
|
|
1547
|
-
// src/services/build-address-variables-service.js
|
|
1548
|
-
var buildUprnAddress = (change) => {
|
|
1549
|
-
return {
|
|
1550
|
-
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1551
|
-
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1552
|
-
buildingName: nullIfUndefined(change.buildingName),
|
|
1553
|
-
flatName: nullIfUndefined(change.flatName),
|
|
1554
|
-
street: nullIfUndefined(change.street),
|
|
1555
|
-
city: nullIfUndefined(change.city),
|
|
1556
|
-
county: nullIfUndefined(change.county),
|
|
1557
|
-
postalCode: nullIfUndefined(change.postcode),
|
|
1558
|
-
country: nullIfUndefined(change.country),
|
|
1559
|
-
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1560
|
-
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1561
|
-
line1: null,
|
|
1562
|
-
line2: null,
|
|
1563
|
-
line3: null,
|
|
1564
|
-
line4: null,
|
|
1565
|
-
line5: null,
|
|
1566
|
-
uprn: change.uprn
|
|
1567
|
-
// required for DAL/v1
|
|
1568
|
-
};
|
|
1569
|
-
};
|
|
1570
|
-
var buildManualAddress = (change) => {
|
|
1571
|
-
return {
|
|
1572
|
-
pafOrganisationName: null,
|
|
1573
|
-
buildingNumberRange: null,
|
|
1574
|
-
buildingName: null,
|
|
1575
|
-
flatName: null,
|
|
1576
|
-
street: null,
|
|
1577
|
-
dependentLocality: null,
|
|
1578
|
-
doubleDependentLocality: null,
|
|
1579
|
-
county: null,
|
|
1580
|
-
uprn: null,
|
|
1581
|
-
line1: change.address1,
|
|
1582
|
-
// required for DAL/v1
|
|
1583
|
-
line2: nullIfUndefined(change.address2),
|
|
1584
|
-
line3: nullIfUndefined(change.address3),
|
|
1585
|
-
line4: nullIfUndefined(change.county),
|
|
1586
|
-
// manual county mapped for validation
|
|
1587
|
-
line5: null,
|
|
1588
|
-
city: change.city,
|
|
1589
|
-
// required for DAL/v1
|
|
1590
|
-
postalCode: change.postcode,
|
|
1591
|
-
// required for DAL/v1
|
|
1592
|
-
country: change.country
|
|
1593
|
-
// required for DAL/v1
|
|
1594
|
-
};
|
|
1595
|
-
};
|
|
1596
|
-
var nullIfUndefined = (value) => {
|
|
1597
|
-
return value ?? null;
|
|
1598
|
-
};
|
|
1599
|
-
|
|
1600
1704
|
// src/services/build-fix-success-message-service.js
|
|
1601
1705
|
var LABEL_MAPS = {
|
|
1602
1706
|
personal: {
|
package/dist/index.js
CHANGED
|
@@ -921,11 +921,85 @@ var formatValidationErrors = (errors) => {
|
|
|
921
921
|
return formattedErrors;
|
|
922
922
|
};
|
|
923
923
|
|
|
924
|
+
// src/services/build-address-variables-service.js
|
|
925
|
+
var buildUprnAddress = (change) => {
|
|
926
|
+
return {
|
|
927
|
+
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
928
|
+
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
929
|
+
buildingName: nullIfUndefined(change.buildingName),
|
|
930
|
+
flatName: nullIfUndefined(change.flatName),
|
|
931
|
+
street: nullIfUndefined(change.street),
|
|
932
|
+
city: nullIfUndefined(change.city),
|
|
933
|
+
county: nullIfUndefined(change.county),
|
|
934
|
+
postalCode: nullIfUndefined(change.postcode),
|
|
935
|
+
country: nullIfUndefined(change.country),
|
|
936
|
+
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
937
|
+
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
938
|
+
line1: null,
|
|
939
|
+
line2: null,
|
|
940
|
+
line3: null,
|
|
941
|
+
line4: null,
|
|
942
|
+
line5: null,
|
|
943
|
+
uprn: change.uprn
|
|
944
|
+
// required for DAL/v1
|
|
945
|
+
};
|
|
946
|
+
};
|
|
947
|
+
var buildManualAddress = (change) => {
|
|
948
|
+
return {
|
|
949
|
+
pafOrganisationName: null,
|
|
950
|
+
buildingNumberRange: null,
|
|
951
|
+
buildingName: null,
|
|
952
|
+
flatName: null,
|
|
953
|
+
street: null,
|
|
954
|
+
dependentLocality: null,
|
|
955
|
+
doubleDependentLocality: null,
|
|
956
|
+
county: null,
|
|
957
|
+
uprn: null,
|
|
958
|
+
line1: change.address1,
|
|
959
|
+
// required for DAL/v1
|
|
960
|
+
line2: nullIfUndefined(change.address2),
|
|
961
|
+
line3: nullIfUndefined(change.address3),
|
|
962
|
+
line4: nullIfUndefined(change.county),
|
|
963
|
+
// manual county mapped for validation
|
|
964
|
+
line5: null,
|
|
965
|
+
city: change.city,
|
|
966
|
+
// required for DAL/v1
|
|
967
|
+
postalCode: change.postcode,
|
|
968
|
+
// required for DAL/v1
|
|
969
|
+
country: change.country
|
|
970
|
+
// required for DAL/v1
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
var nullIfUndefined = (value) => {
|
|
974
|
+
return value ?? null;
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
// src/utils/build-update-business-address-variables.js
|
|
978
|
+
var buildUpdateBusinessAddressVariables = (change, sbi) => {
|
|
979
|
+
const address = change.uprn ? { withUprn: buildUprnAddress(change) } : { withoutUprn: buildManualAddress(change) };
|
|
980
|
+
return {
|
|
981
|
+
input: {
|
|
982
|
+
sbi,
|
|
983
|
+
address
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
};
|
|
987
|
+
|
|
924
988
|
// src/utils/build-update-business-email-variables.js
|
|
925
989
|
var buildUpdateBusinessEmailVariables = (email, sbi) => {
|
|
926
990
|
return { input: { email: { address: email }, sbi } };
|
|
927
991
|
};
|
|
928
992
|
|
|
993
|
+
// src/utils/build-update-business-legal-status-variables.js
|
|
994
|
+
var buildUpdateBusinessLegalStatusVariables = (legalStatusCode, sbi) => {
|
|
995
|
+
return {
|
|
996
|
+
input: {
|
|
997
|
+
sbi,
|
|
998
|
+
legalStatusCode: Number(legalStatusCode)
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
};
|
|
1002
|
+
|
|
929
1003
|
// src/utils/build-update-business-name-variables.js
|
|
930
1004
|
var buildUpdateBusinessNameVariables = (name, sbi) => {
|
|
931
1005
|
return { input: { name, sbi } };
|
|
@@ -944,6 +1018,19 @@ var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobil
|
|
|
944
1018
|
};
|
|
945
1019
|
};
|
|
946
1020
|
|
|
1021
|
+
// src/utils/build-update-business-registration-numbers-variables.js
|
|
1022
|
+
var buildUpdateBusinessRegistrationNumbersVariables = (companiesHouse, charityCommission, sbi) => {
|
|
1023
|
+
return {
|
|
1024
|
+
input: {
|
|
1025
|
+
sbi,
|
|
1026
|
+
registrationNumbers: {
|
|
1027
|
+
companiesHouse: companiesHouse ?? null,
|
|
1028
|
+
charityCommission: charityCommission ?? null
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
};
|
|
1033
|
+
|
|
947
1034
|
// src/utils/build-update-business-vat-variables.js
|
|
948
1035
|
var buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
949
1036
|
return {
|
|
@@ -954,14 +1041,84 @@ var buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
|
954
1041
|
};
|
|
955
1042
|
};
|
|
956
1043
|
|
|
1044
|
+
// src/utils/build-update-customer-address-variables.js
|
|
1045
|
+
var buildUpdateCustomerAddressVariables = (change, crn) => {
|
|
1046
|
+
return {
|
|
1047
|
+
input: {
|
|
1048
|
+
crn,
|
|
1049
|
+
address: change.uprn ? buildUprnAddress(change) : buildManualAddress(change)
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
// src/utils/build-update-customer-dob-variables.js
|
|
1055
|
+
var buildUpdateCustomerDobVariables = (day, month, year, crn) => {
|
|
1056
|
+
const dateOfBirth = [
|
|
1057
|
+
String(year).padStart(4, "0"),
|
|
1058
|
+
String(month).padStart(2, "0"),
|
|
1059
|
+
String(day).padStart(2, "0")
|
|
1060
|
+
].join("-");
|
|
1061
|
+
return {
|
|
1062
|
+
input: {
|
|
1063
|
+
dateOfBirth,
|
|
1064
|
+
crn
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
// src/utils/build-update-customer-email-variables.js
|
|
1070
|
+
var buildUpdateCustomerEmailVariables = (email, crn) => {
|
|
1071
|
+
return {
|
|
1072
|
+
input: {
|
|
1073
|
+
email: {
|
|
1074
|
+
address: email
|
|
1075
|
+
},
|
|
1076
|
+
crn
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
// src/utils/build-update-customer-name-variables.js
|
|
1082
|
+
var buildUpdateCustomerNameVariables = (first, last, middle, crn) => {
|
|
1083
|
+
return {
|
|
1084
|
+
input: {
|
|
1085
|
+
first,
|
|
1086
|
+
last,
|
|
1087
|
+
middle: middle ?? null,
|
|
1088
|
+
crn
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
// src/utils/build-update-customer-phone-variables.js
|
|
1094
|
+
var buildUpdateCustomerPhoneVariables = (personalTelephone, personalMobile, crn) => {
|
|
1095
|
+
return {
|
|
1096
|
+
input: {
|
|
1097
|
+
phone: {
|
|
1098
|
+
landline: personalTelephone ?? null,
|
|
1099
|
+
mobile: personalMobile ?? null
|
|
1100
|
+
},
|
|
1101
|
+
crn
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
};
|
|
1105
|
+
|
|
957
1106
|
// src/utils/utils.js
|
|
958
1107
|
var utils = {
|
|
959
1108
|
formatFullName,
|
|
960
1109
|
formatValidationErrors,
|
|
1110
|
+
buildUpdateBusinessAddressVariables,
|
|
961
1111
|
buildUpdateBusinessEmailVariables,
|
|
1112
|
+
buildUpdateBusinessLegalStatusVariables,
|
|
962
1113
|
buildUpdateBusinessNameVariables,
|
|
963
1114
|
buildUpdateBusinessPhoneNumbersVariables,
|
|
964
|
-
|
|
1115
|
+
buildUpdateBusinessRegistrationNumbersVariables,
|
|
1116
|
+
buildUpdateBusinessVatVariables,
|
|
1117
|
+
buildUpdateCustomerAddressVariables,
|
|
1118
|
+
buildUpdateCustomerDobVariables,
|
|
1119
|
+
buildUpdateCustomerEmailVariables,
|
|
1120
|
+
buildUpdateCustomerNameVariables,
|
|
1121
|
+
buildUpdateCustomerPhoneVariables
|
|
965
1122
|
};
|
|
966
1123
|
|
|
967
1124
|
// src/mappers/personal-details-mapper.js
|
|
@@ -1503,59 +1660,6 @@ var presenters = {
|
|
|
1503
1660
|
addressChangeLink
|
|
1504
1661
|
};
|
|
1505
1662
|
|
|
1506
|
-
// src/services/build-address-variables-service.js
|
|
1507
|
-
var buildUprnAddress = (change) => {
|
|
1508
|
-
return {
|
|
1509
|
-
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1510
|
-
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1511
|
-
buildingName: nullIfUndefined(change.buildingName),
|
|
1512
|
-
flatName: nullIfUndefined(change.flatName),
|
|
1513
|
-
street: nullIfUndefined(change.street),
|
|
1514
|
-
city: nullIfUndefined(change.city),
|
|
1515
|
-
county: nullIfUndefined(change.county),
|
|
1516
|
-
postalCode: nullIfUndefined(change.postcode),
|
|
1517
|
-
country: nullIfUndefined(change.country),
|
|
1518
|
-
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1519
|
-
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1520
|
-
line1: null,
|
|
1521
|
-
line2: null,
|
|
1522
|
-
line3: null,
|
|
1523
|
-
line4: null,
|
|
1524
|
-
line5: null,
|
|
1525
|
-
uprn: change.uprn
|
|
1526
|
-
// required for DAL/v1
|
|
1527
|
-
};
|
|
1528
|
-
};
|
|
1529
|
-
var buildManualAddress = (change) => {
|
|
1530
|
-
return {
|
|
1531
|
-
pafOrganisationName: null,
|
|
1532
|
-
buildingNumberRange: null,
|
|
1533
|
-
buildingName: null,
|
|
1534
|
-
flatName: null,
|
|
1535
|
-
street: null,
|
|
1536
|
-
dependentLocality: null,
|
|
1537
|
-
doubleDependentLocality: null,
|
|
1538
|
-
county: null,
|
|
1539
|
-
uprn: null,
|
|
1540
|
-
line1: change.address1,
|
|
1541
|
-
// required for DAL/v1
|
|
1542
|
-
line2: nullIfUndefined(change.address2),
|
|
1543
|
-
line3: nullIfUndefined(change.address3),
|
|
1544
|
-
line4: nullIfUndefined(change.county),
|
|
1545
|
-
// manual county mapped for validation
|
|
1546
|
-
line5: null,
|
|
1547
|
-
city: change.city,
|
|
1548
|
-
// required for DAL/v1
|
|
1549
|
-
postalCode: change.postcode,
|
|
1550
|
-
// required for DAL/v1
|
|
1551
|
-
country: change.country
|
|
1552
|
-
// required for DAL/v1
|
|
1553
|
-
};
|
|
1554
|
-
};
|
|
1555
|
-
var nullIfUndefined = (value) => {
|
|
1556
|
-
return value ?? null;
|
|
1557
|
-
};
|
|
1558
|
-
|
|
1559
1663
|
// src/services/build-fix-success-message-service.js
|
|
1560
1664
|
var LABEL_MAPS = {
|
|
1561
1665
|
personal: {
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { buildManualAddress, buildUprnAddress } from '../services/build-address-variables-service.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds the GraphQL variables for the `updateBusinessAddress` mutation.
|
|
5
|
+
*
|
|
6
|
+
* The DAL/v1 supports two address submission modes:
|
|
7
|
+
*
|
|
8
|
+
* 1. Postcode lookup address (with UPRN)
|
|
9
|
+
* If a `uprn` (Unique Property Reference Number) is present, it is the
|
|
10
|
+
* primary identifier for the address. Other address fields are still
|
|
11
|
+
* included but are not strictly validated by the DAL.
|
|
12
|
+
*
|
|
13
|
+
* 2. Manually entered address (without UPRN)
|
|
14
|
+
* If there is no `uprn`, the DAL/v1 requires `line1`, `city`, `postalCode` and `country`.
|
|
15
|
+
*
|
|
16
|
+
* Unlike customer addresses, business addresses are wrapped in either `withUprn` or `withoutUprn`.
|
|
17
|
+
*
|
|
18
|
+
* @param {object} change - The address change object held in the session
|
|
19
|
+
* @param {string} sbi - The Single Business Identifier of the business being updated
|
|
20
|
+
* @returns {object} The mutation variables in the shape `{ input: { sbi, address: { withUprn | withoutUprn } } }`
|
|
21
|
+
*/
|
|
22
|
+
export const buildUpdateBusinessAddressVariables = (change, sbi) => {
|
|
23
|
+
const address = change.uprn
|
|
24
|
+
? { withUprn: buildUprnAddress(change) }
|
|
25
|
+
: { withoutUprn: buildManualAddress(change) }
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
input: {
|
|
29
|
+
sbi,
|
|
30
|
+
address
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateBusinessLegalStatus` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|number} legalStatusCode - The new legal status code for the business
|
|
5
|
+
* @param {string} sbi - The Single Business Identifier of the business being updated
|
|
6
|
+
* @returns {object} The mutation variables in the shape `{ input: { sbi, legalStatusCode } }`
|
|
7
|
+
*/
|
|
8
|
+
export const buildUpdateBusinessLegalStatusVariables = (legalStatusCode, sbi) => {
|
|
9
|
+
return {
|
|
10
|
+
input: {
|
|
11
|
+
sbi,
|
|
12
|
+
legalStatusCode: Number(legalStatusCode)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateBusinessRegistrationNumbers` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|null} companiesHouse - The Companies House registration number
|
|
5
|
+
* @param {string|null} charityCommission - The Charity Commission registration number
|
|
6
|
+
* @param {string} sbi - The Single Business Identifier of the business being updated
|
|
7
|
+
* @returns {object} The mutation variables in the shape
|
|
8
|
+
* `{ input: { sbi, registrationNumbers: { companiesHouse, charityCommission } } }`
|
|
9
|
+
*/
|
|
10
|
+
export const buildUpdateBusinessRegistrationNumbersVariables = (companiesHouse, charityCommission, sbi) => {
|
|
11
|
+
return {
|
|
12
|
+
input: {
|
|
13
|
+
sbi,
|
|
14
|
+
registrationNumbers: {
|
|
15
|
+
companiesHouse: companiesHouse ?? null,
|
|
16
|
+
charityCommission: charityCommission ?? null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { buildManualAddress, buildUprnAddress } from '../services/build-address-variables-service.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds the GraphQL variables for the `updateCustomerAddress` mutation.
|
|
5
|
+
*
|
|
6
|
+
* The DAL/v1 supports two address submission modes:
|
|
7
|
+
*
|
|
8
|
+
* 1. Postcode lookup address (with UPRN)
|
|
9
|
+
* If a `uprn` (Unique Property Reference Number) is present, it is the
|
|
10
|
+
* primary identifier for the address. Other address fields are still
|
|
11
|
+
* included but are not strictly validated by the DAL.
|
|
12
|
+
*
|
|
13
|
+
* 2. Manually entered address (without UPRN)
|
|
14
|
+
* If there is no `uprn`, the DAL/v1 requires `line1`, `city`, `postalCode` and `country`.
|
|
15
|
+
*
|
|
16
|
+
* @param {object} change - The address change object held in the session
|
|
17
|
+
* @param {string} crn - The Customer Reference Number of the customer being updated
|
|
18
|
+
* @returns {object} The mutation variables in the shape `{ input: { crn, address } }`
|
|
19
|
+
*/
|
|
20
|
+
export const buildUpdateCustomerAddressVariables = (change, crn) => {
|
|
21
|
+
return {
|
|
22
|
+
input: {
|
|
23
|
+
crn,
|
|
24
|
+
address: change.uprn ? buildUprnAddress(change) : buildManualAddress(change)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateCustomerDob` mutation.
|
|
3
|
+
*
|
|
4
|
+
* The DAL expects `dateOfBirth` as a zero padded ISO date e.g. '1990-04-05' not '1990-4-5'.
|
|
5
|
+
*
|
|
6
|
+
* @param {string|number} day - The day of the month the customer was born
|
|
7
|
+
* @param {string|number} month - The month the customer was born
|
|
8
|
+
* @param {string|number} year - The year the customer was born
|
|
9
|
+
* @param {string} crn - The Customer Reference Number of the customer being updated
|
|
10
|
+
* @returns {object} The mutation variables in the shape `{ input: { dateOfBirth, crn } }`
|
|
11
|
+
*/
|
|
12
|
+
export const buildUpdateCustomerDobVariables = (day, month, year, crn) => {
|
|
13
|
+
const dateOfBirth = [
|
|
14
|
+
String(year).padStart(4, '0'),
|
|
15
|
+
String(month).padStart(2, '0'),
|
|
16
|
+
String(day).padStart(2, '0')
|
|
17
|
+
].join('-')
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
input: {
|
|
21
|
+
dateOfBirth,
|
|
22
|
+
crn
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateCustomerEmail` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} email - The new personal email address
|
|
5
|
+
* @param {string} crn - The Customer Reference Number of the customer being updated
|
|
6
|
+
* @returns {object} The mutation variables in the shape `{ input: { email: { address }, crn } }`
|
|
7
|
+
*/
|
|
8
|
+
export const buildUpdateCustomerEmailVariables = (email, crn) => {
|
|
9
|
+
return {
|
|
10
|
+
input: {
|
|
11
|
+
email: {
|
|
12
|
+
address: email
|
|
13
|
+
},
|
|
14
|
+
crn
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateCustomerName` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} first - The customer's first name
|
|
5
|
+
* @param {string} last - The customer's last name
|
|
6
|
+
* @param {string|null} middle - The customer's middle name(s)
|
|
7
|
+
* @param {string} crn - The Customer Reference Number of the customer being updated
|
|
8
|
+
* @returns {object} The mutation variables in the shape `{ input: { first, last, middle, crn } }`
|
|
9
|
+
*/
|
|
10
|
+
export const buildUpdateCustomerNameVariables = (first, last, middle, crn) => {
|
|
11
|
+
return {
|
|
12
|
+
input: {
|
|
13
|
+
first,
|
|
14
|
+
last,
|
|
15
|
+
middle: middle ?? null,
|
|
16
|
+
crn
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateCustomerPhone` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|null} personalTelephone - The new personal landline number
|
|
5
|
+
* @param {string|null} personalMobile - The new personal mobile number
|
|
6
|
+
* @param {string} crn - The Customer Reference Number of the customer being updated
|
|
7
|
+
* @returns {object} The mutation variables in the shape `{ input: { phone: { landline, mobile }, crn } }`
|
|
8
|
+
*/
|
|
9
|
+
export const buildUpdateCustomerPhoneVariables = (personalTelephone, personalMobile, crn) => {
|
|
10
|
+
return {
|
|
11
|
+
input: {
|
|
12
|
+
phone: {
|
|
13
|
+
landline: personalTelephone ?? null,
|
|
14
|
+
mobile: personalMobile ?? null
|
|
15
|
+
},
|
|
16
|
+
crn
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { formatFullName } from './format-full-name.js'
|
|
2
2
|
import { formatValidationErrors } from './format-validation-errors.js'
|
|
3
|
+
import { buildUpdateBusinessAddressVariables } from './build-update-business-address-variables.js'
|
|
3
4
|
import { buildUpdateBusinessEmailVariables } from './build-update-business-email-variables.js'
|
|
5
|
+
import { buildUpdateBusinessLegalStatusVariables } from './build-update-business-legal-status-variables.js'
|
|
4
6
|
import { buildUpdateBusinessNameVariables } from './build-update-business-name-variables.js'
|
|
5
7
|
import { buildUpdateBusinessPhoneNumbersVariables } from './build-update-business-phone-numbers-variables.js'
|
|
8
|
+
import { buildUpdateBusinessRegistrationNumbersVariables } from './build-update-business-registration-numbers-variables.js'
|
|
6
9
|
import { buildUpdateBusinessVatVariables } from './build-update-business-vat-variables.js'
|
|
10
|
+
import { buildUpdateCustomerAddressVariables } from './build-update-customer-address-variables.js'
|
|
11
|
+
import { buildUpdateCustomerDobVariables } from './build-update-customer-dob-variables.js'
|
|
12
|
+
import { buildUpdateCustomerEmailVariables } from './build-update-customer-email-variables.js'
|
|
13
|
+
import { buildUpdateCustomerNameVariables } from './build-update-customer-name-variables.js'
|
|
14
|
+
import { buildUpdateCustomerPhoneVariables } from './build-update-customer-phone-variables.js'
|
|
7
15
|
|
|
8
16
|
export const utils = {
|
|
9
17
|
formatFullName,
|
|
10
18
|
formatValidationErrors,
|
|
19
|
+
buildUpdateBusinessAddressVariables,
|
|
11
20
|
buildUpdateBusinessEmailVariables,
|
|
21
|
+
buildUpdateBusinessLegalStatusVariables,
|
|
12
22
|
buildUpdateBusinessNameVariables,
|
|
13
23
|
buildUpdateBusinessPhoneNumbersVariables,
|
|
14
|
-
|
|
24
|
+
buildUpdateBusinessRegistrationNumbersVariables,
|
|
25
|
+
buildUpdateBusinessVatVariables,
|
|
26
|
+
buildUpdateCustomerAddressVariables,
|
|
27
|
+
buildUpdateCustomerDobVariables,
|
|
28
|
+
buildUpdateCustomerEmailVariables,
|
|
29
|
+
buildUpdateCustomerNameVariables,
|
|
30
|
+
buildUpdateCustomerPhoneVariables
|
|
15
31
|
}
|