@defra/fcp-sfd-frontend-engine 0.35.0 → 0.36.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 +417 -382
- package/dist/index.js +417 -382
- package/package.json +1 -1
- package/src/mutations/business/update-business-details.js +11 -0
- package/src/mutations/mutations.js +18 -16
- package/src/mutations/personal/update-customer-details.js +4 -33
- package/src/services/business/build-business-fix-update-variables-service.js +81 -0
- package/src/services/initialise-fix-journey-service.js +1 -0
- package/src/services/services.js +11 -9
package/dist/index.cjs
CHANGED
|
@@ -1058,6 +1058,43 @@ var mappers = {
|
|
|
1058
1058
|
personalDetails: mapPersonalDetails
|
|
1059
1059
|
};
|
|
1060
1060
|
|
|
1061
|
+
// src/mutations/business/update-business-address.js
|
|
1062
|
+
var updateBusinessAddressMutation = `
|
|
1063
|
+
mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
|
|
1064
|
+
updateBusinessAddress(input: $input) {
|
|
1065
|
+
business {
|
|
1066
|
+
info {
|
|
1067
|
+
address {
|
|
1068
|
+
line1
|
|
1069
|
+
line2
|
|
1070
|
+
line3
|
|
1071
|
+
line4
|
|
1072
|
+
line5
|
|
1073
|
+
postalCode
|
|
1074
|
+
country
|
|
1075
|
+
city
|
|
1076
|
+
buildingNumberRange
|
|
1077
|
+
buildingName
|
|
1078
|
+
flatName
|
|
1079
|
+
street
|
|
1080
|
+
county
|
|
1081
|
+
uprn
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
`;
|
|
1088
|
+
|
|
1089
|
+
// src/mutations/business/update-business-details.js
|
|
1090
|
+
var updateBusinessDetailsMutation = `
|
|
1091
|
+
mutation UpdateBusinessAllFields($input: UpdateBusinessAllFieldsInput!) {
|
|
1092
|
+
updateBusinessAllFields(input: $input) {
|
|
1093
|
+
success
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
`;
|
|
1097
|
+
|
|
1061
1098
|
// src/mutations/business/update-business-email.js
|
|
1062
1099
|
var updateBusinessEmailMutation = `
|
|
1063
1100
|
mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
|
|
@@ -1074,6 +1111,23 @@ var updateBusinessEmailMutation = `
|
|
|
1074
1111
|
}
|
|
1075
1112
|
`;
|
|
1076
1113
|
|
|
1114
|
+
// src/mutations/business/update-business-legal-status.js
|
|
1115
|
+
var updateBusinessLegalStatusMutation = `
|
|
1116
|
+
mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
|
|
1117
|
+
updateBusinessLegalStatus(input: $input) {
|
|
1118
|
+
business {
|
|
1119
|
+
info {
|
|
1120
|
+
legalStatus {
|
|
1121
|
+
code
|
|
1122
|
+
type
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
success
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
`;
|
|
1130
|
+
|
|
1077
1131
|
// src/mutations/business/update-business-name.js
|
|
1078
1132
|
var updateBusinessNameMutation = `
|
|
1079
1133
|
mutation UpdateBusinessName($input: UpdateBusinessNameInput!) {
|
|
@@ -1104,65 +1158,35 @@ var updateBusinessPhoneNumbersMutation = `
|
|
|
1104
1158
|
}
|
|
1105
1159
|
`;
|
|
1106
1160
|
|
|
1107
|
-
// src/mutations/
|
|
1108
|
-
var
|
|
1109
|
-
mutation
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
info {
|
|
1113
|
-
name {
|
|
1114
|
-
first
|
|
1115
|
-
last
|
|
1116
|
-
middle
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
`;
|
|
1123
|
-
|
|
1124
|
-
// src/mutations/personal/update-customer-dob.js
|
|
1125
|
-
var updateCustomerDobMutation = `
|
|
1126
|
-
mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
|
|
1127
|
-
updateCustomerDateOfBirth(input: $input) {
|
|
1128
|
-
customer {
|
|
1129
|
-
info {
|
|
1130
|
-
dateOfBirth
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
`;
|
|
1136
|
-
|
|
1137
|
-
// src/mutations/personal/update-customer-phone.js
|
|
1138
|
-
var updateCustomerPhoneMutation = `
|
|
1139
|
-
mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
|
|
1140
|
-
updateCustomerPhone(input: $input) {
|
|
1141
|
-
customer {
|
|
1161
|
+
// src/mutations/business/update-business-registration-numbers.js
|
|
1162
|
+
var updateBusinessRegistrationNumbersMutation = `
|
|
1163
|
+
mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
|
|
1164
|
+
updateBusinessRegistrationNumbers(input: $input) {
|
|
1165
|
+
business {
|
|
1142
1166
|
info {
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1167
|
+
registrationNumbers {
|
|
1168
|
+
companiesHouse
|
|
1169
|
+
charityCommission
|
|
1146
1170
|
}
|
|
1147
1171
|
}
|
|
1148
1172
|
}
|
|
1173
|
+
success
|
|
1149
1174
|
}
|
|
1150
1175
|
}
|
|
1151
1176
|
`;
|
|
1152
1177
|
|
|
1153
|
-
// src/mutations/
|
|
1154
|
-
var
|
|
1155
|
-
mutation
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
address
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1178
|
+
// src/mutations/business/update-business-vat.js
|
|
1179
|
+
var updateBusinessVatMutation = `
|
|
1180
|
+
mutation UpdateBusinessVAT($input: UpdateBusinessVATInput!) {
|
|
1181
|
+
updateBusinessVAT(input: $input) {
|
|
1182
|
+
business {
|
|
1183
|
+
info {
|
|
1184
|
+
vat
|
|
1163
1185
|
}
|
|
1164
1186
|
}
|
|
1187
|
+
success
|
|
1165
1188
|
}
|
|
1189
|
+
}
|
|
1166
1190
|
`;
|
|
1167
1191
|
|
|
1168
1192
|
// src/mutations/personal/update-customer-address.js
|
|
@@ -1193,139 +1217,92 @@ var updateCustomerAddressMutation = `
|
|
|
1193
1217
|
}
|
|
1194
1218
|
`;
|
|
1195
1219
|
|
|
1196
|
-
// src/mutations/
|
|
1197
|
-
var
|
|
1198
|
-
mutation
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
info {
|
|
1202
|
-
address {
|
|
1203
|
-
line1
|
|
1204
|
-
line2
|
|
1205
|
-
line3
|
|
1206
|
-
line4
|
|
1207
|
-
line5
|
|
1208
|
-
postalCode
|
|
1209
|
-
country
|
|
1210
|
-
city
|
|
1211
|
-
buildingNumberRange
|
|
1212
|
-
buildingName
|
|
1213
|
-
flatName
|
|
1214
|
-
street
|
|
1215
|
-
county
|
|
1216
|
-
uprn
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
+
// src/mutations/personal/update-customer-details.js
|
|
1221
|
+
var updateCustomerDetailsMutation = `
|
|
1222
|
+
mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
|
|
1223
|
+
updateCustomerAllFields(input: $input) {
|
|
1224
|
+
success
|
|
1220
1225
|
}
|
|
1221
1226
|
}
|
|
1222
1227
|
`;
|
|
1223
1228
|
|
|
1224
|
-
// src/mutations/
|
|
1225
|
-
var
|
|
1226
|
-
mutation
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1229
|
+
// src/mutations/personal/update-customer-dob.js
|
|
1230
|
+
var updateCustomerDobMutation = `
|
|
1231
|
+
mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
|
|
1232
|
+
updateCustomerDateOfBirth(input: $input) {
|
|
1233
|
+
customer {
|
|
1234
|
+
info {
|
|
1235
|
+
dateOfBirth
|
|
1236
|
+
}
|
|
1231
1237
|
}
|
|
1232
1238
|
}
|
|
1233
|
-
success
|
|
1234
1239
|
}
|
|
1235
|
-
}
|
|
1236
1240
|
`;
|
|
1237
1241
|
|
|
1238
|
-
// src/mutations/personal/update-customer-
|
|
1239
|
-
var
|
|
1240
|
-
mutation
|
|
1241
|
-
|
|
1242
|
-
success
|
|
1242
|
+
// src/mutations/personal/update-customer-email.js
|
|
1243
|
+
var updateCustomerEmailMutation = `
|
|
1244
|
+
mutation UpdateCustomerEmail($input: UpdateCustomerEmailInput!) {
|
|
1245
|
+
updateCustomerEmail(input: $input) {
|
|
1243
1246
|
customer {
|
|
1244
1247
|
info {
|
|
1245
|
-
name {
|
|
1246
|
-
first
|
|
1247
|
-
middle
|
|
1248
|
-
last
|
|
1249
|
-
}
|
|
1250
|
-
dateOfBirth
|
|
1251
|
-
phone {
|
|
1252
|
-
mobile
|
|
1253
|
-
landline
|
|
1254
|
-
}
|
|
1255
1248
|
email {
|
|
1256
1249
|
address
|
|
1257
1250
|
}
|
|
1258
|
-
address {
|
|
1259
|
-
line1
|
|
1260
|
-
line2
|
|
1261
|
-
line3
|
|
1262
|
-
line4
|
|
1263
|
-
line5
|
|
1264
|
-
buildingNumberRange
|
|
1265
|
-
buildingName
|
|
1266
|
-
flatName
|
|
1267
|
-
street
|
|
1268
|
-
city
|
|
1269
|
-
county
|
|
1270
|
-
postalCode
|
|
1271
|
-
country
|
|
1272
|
-
uprn
|
|
1273
|
-
}
|
|
1274
1251
|
}
|
|
1275
1252
|
}
|
|
1276
1253
|
}
|
|
1277
1254
|
}
|
|
1278
1255
|
`;
|
|
1279
1256
|
|
|
1280
|
-
// src/mutations/
|
|
1281
|
-
var
|
|
1282
|
-
mutation
|
|
1283
|
-
|
|
1284
|
-
|
|
1257
|
+
// src/mutations/personal/update-customer-name.js
|
|
1258
|
+
var updateCustomerNameMutation = `
|
|
1259
|
+
mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
|
|
1260
|
+
updateCustomerName(input: $input) {
|
|
1261
|
+
customer {
|
|
1285
1262
|
info {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1263
|
+
name {
|
|
1264
|
+
first
|
|
1265
|
+
last
|
|
1266
|
+
middle
|
|
1289
1267
|
}
|
|
1290
1268
|
}
|
|
1291
1269
|
}
|
|
1292
|
-
success
|
|
1293
1270
|
}
|
|
1294
1271
|
}
|
|
1295
1272
|
`;
|
|
1296
1273
|
|
|
1297
|
-
// src/mutations/
|
|
1298
|
-
var
|
|
1299
|
-
mutation
|
|
1300
|
-
|
|
1301
|
-
|
|
1274
|
+
// src/mutations/personal/update-customer-phone.js
|
|
1275
|
+
var updateCustomerPhoneMutation = `
|
|
1276
|
+
mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
|
|
1277
|
+
updateCustomerPhone(input: $input) {
|
|
1278
|
+
customer {
|
|
1302
1279
|
info {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1280
|
+
phone {
|
|
1281
|
+
landline
|
|
1282
|
+
mobile
|
|
1306
1283
|
}
|
|
1307
1284
|
}
|
|
1308
1285
|
}
|
|
1309
|
-
success
|
|
1310
1286
|
}
|
|
1311
1287
|
}
|
|
1312
1288
|
`;
|
|
1313
1289
|
|
|
1314
1290
|
// src/mutations/mutations.js
|
|
1315
1291
|
var mutations = {
|
|
1292
|
+
updateBusinessAddress: updateBusinessAddressMutation,
|
|
1293
|
+
updateBusinessDetails: updateBusinessDetailsMutation,
|
|
1316
1294
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
1295
|
+
updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
|
|
1317
1296
|
updateBusinessName: updateBusinessNameMutation,
|
|
1318
1297
|
updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
|
|
1319
|
-
|
|
1320
|
-
updateCustomerName: updateCustomerNameMutation,
|
|
1321
|
-
updateCustomerDob: updateCustomerDobMutation,
|
|
1322
|
-
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
1323
|
-
updateCustomerEmail: updateCustomerEmailMutation,
|
|
1324
|
-
updateCustomerAddress: updateCustomerAddressMutation,
|
|
1298
|
+
updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation,
|
|
1325
1299
|
updateBusinessVat: updateBusinessVatMutation,
|
|
1300
|
+
updateCustomerAddress: updateCustomerAddressMutation,
|
|
1326
1301
|
updateCustomerDetails: updateCustomerDetailsMutation,
|
|
1327
|
-
|
|
1328
|
-
|
|
1302
|
+
updateCustomerDob: updateCustomerDobMutation,
|
|
1303
|
+
updateCustomerEmail: updateCustomerEmailMutation,
|
|
1304
|
+
updateCustomerName: updateCustomerNameMutation,
|
|
1305
|
+
updateCustomerPhone: updateCustomerPhoneMutation
|
|
1329
1306
|
};
|
|
1330
1307
|
|
|
1331
1308
|
// src/presenters/base-presenter.js
|
|
@@ -1567,18 +1544,259 @@ var presenters = {
|
|
|
1567
1544
|
addressChangeLink
|
|
1568
1545
|
};
|
|
1569
1546
|
|
|
1570
|
-
// src/services/
|
|
1571
|
-
var
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
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
|
+
// src/services/build-fix-success-message-service.js
|
|
1601
|
+
var LABEL_MAPS = {
|
|
1602
|
+
personal: {
|
|
1603
|
+
name: "full name",
|
|
1604
|
+
email: "personal email address",
|
|
1605
|
+
phone: "personal phone numbers",
|
|
1606
|
+
dob: "date of birth",
|
|
1607
|
+
address: "personal address"
|
|
1608
|
+
},
|
|
1609
|
+
business: {
|
|
1610
|
+
name: "business name",
|
|
1611
|
+
email: "business email address",
|
|
1612
|
+
phone: "business phone numbers",
|
|
1613
|
+
vat: "business vat number",
|
|
1614
|
+
address: "business address"
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
var PROPERTY_MAPS = {
|
|
1618
|
+
personal: {
|
|
1619
|
+
name: "changePersonalName",
|
|
1620
|
+
email: "changePersonalEmail",
|
|
1621
|
+
phone: "changePersonalPhoneNumbers",
|
|
1622
|
+
dob: "changePersonalDob",
|
|
1623
|
+
address: "changePersonalAddress"
|
|
1624
|
+
},
|
|
1625
|
+
business: {
|
|
1626
|
+
name: "changeBusinessName",
|
|
1627
|
+
email: "changeBusinessEmail",
|
|
1628
|
+
phone: "changeBusinessPhoneNumbers",
|
|
1629
|
+
vat: "changeBusinessVat",
|
|
1630
|
+
address: "changeBusinessAddress"
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
var buildFixSuccessMessageService = (type, details) => {
|
|
1634
|
+
const { orderedSectionsToFix } = details;
|
|
1635
|
+
const changes = loopThroughSections(type, details, orderedSectionsToFix);
|
|
1636
|
+
if (changes.length === 0) {
|
|
1637
|
+
return null;
|
|
1638
|
+
}
|
|
1639
|
+
if (changes.length === 1) {
|
|
1640
|
+
return {
|
|
1641
|
+
type: "text",
|
|
1642
|
+
value: `You have updated your ${changes[0]}`
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
return {
|
|
1646
|
+
type: "html",
|
|
1647
|
+
value: `
|
|
1648
|
+
<h3 class="govuk-notification-banner__heading">
|
|
1649
|
+
You have updated your:
|
|
1650
|
+
</h3>
|
|
1651
|
+
<ul class="govuk-list govuk-list--bullet">
|
|
1652
|
+
${changes.map((change) => `<li>${change}</li>`).join("")}
|
|
1653
|
+
</ul>
|
|
1654
|
+
`
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
var loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
1658
|
+
const changes = [];
|
|
1659
|
+
const labelMap = LABEL_MAPS[type];
|
|
1660
|
+
const propertyMap = PROPERTY_MAPS[type];
|
|
1661
|
+
for (const section of orderedSectionsToFix) {
|
|
1662
|
+
if (details[propertyMap[section]]) {
|
|
1663
|
+
changes.push(labelMap[section]);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return changes;
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
// src/services/business/build-business-fix-update-variables-service.js
|
|
1670
|
+
var buildBusinessFixUpdateVariablesService = (businessDetails) => {
|
|
1671
|
+
const { orderedSectionsToFix, sbi } = businessDetails;
|
|
1672
|
+
const input = { sbi };
|
|
1673
|
+
for (const applySection of sectionAppliers) {
|
|
1674
|
+
applySection(input, businessDetails, orderedSectionsToFix);
|
|
1675
|
+
}
|
|
1676
|
+
return { input };
|
|
1677
|
+
};
|
|
1678
|
+
var applyAddressSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1679
|
+
if (orderedSectionsToFix.includes("address") && businessDetails.changeBusinessAddress) {
|
|
1680
|
+
input.address = { withoutUprn: buildManualAddress(businessDetails.changeBusinessAddress) };
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
var applyEmailSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1684
|
+
if (orderedSectionsToFix.includes("email") && businessDetails.changeBusinessEmail) {
|
|
1685
|
+
Object.assign(input, buildEmailInput(businessDetails.changeBusinessEmail));
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
var applyNameSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1689
|
+
if (orderedSectionsToFix.includes("name") && businessDetails.changeBusinessName) {
|
|
1690
|
+
input.name = businessDetails.changeBusinessName.businessName;
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
var applyPhoneSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1694
|
+
if (orderedSectionsToFix.includes("phone") && businessDetails.changeBusinessPhoneNumbers) {
|
|
1695
|
+
Object.assign(input, buildPhoneInput(businessDetails.changeBusinessPhoneNumbers));
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
var applyVatSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1699
|
+
if (orderedSectionsToFix.includes("vat") && businessDetails.changeBusinessVat) {
|
|
1700
|
+
input.vat = businessDetails.changeBusinessVat.vatNumber ?? "";
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
var sectionAppliers = [
|
|
1704
|
+
applyAddressSection,
|
|
1705
|
+
applyEmailSection,
|
|
1706
|
+
applyNameSection,
|
|
1707
|
+
applyPhoneSection,
|
|
1708
|
+
applyVatSection
|
|
1709
|
+
];
|
|
1710
|
+
var buildEmailInput = (change) => {
|
|
1711
|
+
return {
|
|
1712
|
+
email: {
|
|
1713
|
+
address: change.businessEmail
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
};
|
|
1717
|
+
var buildPhoneInput = (change) => {
|
|
1718
|
+
return {
|
|
1719
|
+
phone: {
|
|
1720
|
+
landline: change.businessTelephone ?? null,
|
|
1721
|
+
mobile: change.businessMobile ?? null
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
};
|
|
1725
|
+
|
|
1726
|
+
// src/services/check-interrupter-journey-session-service.js
|
|
1727
|
+
var checkInterrupterJourneySessionService = (yar, journeyKey) => {
|
|
1728
|
+
const sessionData = yar.get(journeyKey);
|
|
1729
|
+
if (!sessionData) {
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1732
|
+
if (Array.isArray(sessionData.orderedSectionsToFix)) {
|
|
1733
|
+
return true;
|
|
1734
|
+
}
|
|
1735
|
+
return false;
|
|
1736
|
+
};
|
|
1737
|
+
|
|
1738
|
+
// src/services/initialise-fix-journey-service.js
|
|
1739
|
+
var initialiseFixJourneyService = (yar, source, journeyType) => {
|
|
1740
|
+
let sessionKey;
|
|
1741
|
+
let sectionOrder = [];
|
|
1742
|
+
if (journeyType === "business") {
|
|
1743
|
+
sessionKey = "businessDetailsValidation";
|
|
1744
|
+
sectionOrder = BUSINESS_SECTION_ORDER;
|
|
1745
|
+
}
|
|
1746
|
+
if (journeyType === "personal") {
|
|
1747
|
+
sessionKey = "personalDetailsValidation";
|
|
1748
|
+
sectionOrder = PERSONAL_SECTION_ORDER;
|
|
1749
|
+
}
|
|
1750
|
+
const sessionData = yar.get(sessionKey);
|
|
1751
|
+
if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
|
|
1752
|
+
return sessionData;
|
|
1753
|
+
}
|
|
1754
|
+
const orderedSectionsToFix = orderSectionsToFix(
|
|
1755
|
+
sessionData.sectionsNeedingUpdate,
|
|
1756
|
+
source,
|
|
1757
|
+
sectionOrder
|
|
1758
|
+
);
|
|
1759
|
+
updateSessionData(sessionData, source, orderedSectionsToFix);
|
|
1760
|
+
yar.set(sessionKey, sessionData);
|
|
1761
|
+
return sessionData;
|
|
1762
|
+
};
|
|
1763
|
+
var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
|
|
1764
|
+
sessionData.orderedSectionsToFix = orderedSectionsToFix;
|
|
1765
|
+
delete sessionData.sectionsNeedingUpdate;
|
|
1766
|
+
delete sessionData.personalFixUpdates;
|
|
1767
|
+
delete sessionData.businessFixUpdates;
|
|
1768
|
+
if (source) {
|
|
1769
|
+
sessionData.source = source;
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
|
|
1773
|
+
const sections = SECTION_ORDER.filter((section) => {
|
|
1774
|
+
return sectionsNeedingUpdate.includes(section);
|
|
1775
|
+
});
|
|
1776
|
+
if (!source) {
|
|
1777
|
+
return sections;
|
|
1778
|
+
}
|
|
1779
|
+
if (!SECTION_ORDER.includes(source)) {
|
|
1780
|
+
return sections;
|
|
1781
|
+
}
|
|
1782
|
+
return [
|
|
1783
|
+
source,
|
|
1784
|
+
...sections.filter((section) => section !== source)
|
|
1785
|
+
];
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
// src/services/os-places/address-lookup-service.js
|
|
1789
|
+
var import_osdatahub = require("osdatahub");
|
|
1790
|
+
|
|
1791
|
+
// src/mock-data/mock-os-places-addresses.js
|
|
1792
|
+
var mockAddresses = [
|
|
1793
|
+
{
|
|
1794
|
+
properties: {
|
|
1795
|
+
UPRN: "10000001",
|
|
1796
|
+
ADDRESS: "APARTMENT 1, REDBRIDGE HOUSE, 1 ROSE COURT, LONDON, SW1A 1AA",
|
|
1797
|
+
SUB_BUILDING_NAME: "APARTMENT 1",
|
|
1798
|
+
BUILDING_NAME: "REDBRIDGE HOUSE",
|
|
1799
|
+
BUILDING_NUMBER: "1",
|
|
1582
1800
|
THOROUGHFARE_NAME: "ROSE COURT",
|
|
1583
1801
|
POST_TOWN: "LONDON",
|
|
1584
1802
|
POSTCODE: "SW1A 1AA",
|
|
@@ -1809,230 +2027,6 @@ var isRetryable = (error) => {
|
|
|
1809
2027
|
return false;
|
|
1810
2028
|
};
|
|
1811
2029
|
|
|
1812
|
-
// src/services/build-address-variables-service.js
|
|
1813
|
-
var buildUprnAddress = (change) => {
|
|
1814
|
-
return {
|
|
1815
|
-
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1816
|
-
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1817
|
-
buildingName: nullIfUndefined(change.buildingName),
|
|
1818
|
-
flatName: nullIfUndefined(change.flatName),
|
|
1819
|
-
street: nullIfUndefined(change.street),
|
|
1820
|
-
city: nullIfUndefined(change.city),
|
|
1821
|
-
county: nullIfUndefined(change.county),
|
|
1822
|
-
postalCode: nullIfUndefined(change.postcode),
|
|
1823
|
-
country: nullIfUndefined(change.country),
|
|
1824
|
-
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1825
|
-
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1826
|
-
line1: null,
|
|
1827
|
-
line2: null,
|
|
1828
|
-
line3: null,
|
|
1829
|
-
line4: null,
|
|
1830
|
-
line5: null,
|
|
1831
|
-
uprn: change.uprn
|
|
1832
|
-
// required for DAL/v1
|
|
1833
|
-
};
|
|
1834
|
-
};
|
|
1835
|
-
var buildManualAddress = (change) => {
|
|
1836
|
-
return {
|
|
1837
|
-
pafOrganisationName: null,
|
|
1838
|
-
buildingNumberRange: null,
|
|
1839
|
-
buildingName: null,
|
|
1840
|
-
flatName: null,
|
|
1841
|
-
street: null,
|
|
1842
|
-
dependentLocality: null,
|
|
1843
|
-
doubleDependentLocality: null,
|
|
1844
|
-
county: null,
|
|
1845
|
-
uprn: null,
|
|
1846
|
-
line1: change.address1,
|
|
1847
|
-
// required for DAL/v1
|
|
1848
|
-
line2: nullIfUndefined(change.address2),
|
|
1849
|
-
line3: nullIfUndefined(change.address3),
|
|
1850
|
-
line4: nullIfUndefined(change.county),
|
|
1851
|
-
// manual county mapped for validation
|
|
1852
|
-
line5: null,
|
|
1853
|
-
city: change.city,
|
|
1854
|
-
// required for DAL/v1
|
|
1855
|
-
postalCode: change.postcode,
|
|
1856
|
-
// required for DAL/v1
|
|
1857
|
-
country: change.country
|
|
1858
|
-
// required for DAL/v1
|
|
1859
|
-
};
|
|
1860
|
-
};
|
|
1861
|
-
var nullIfUndefined = (value) => {
|
|
1862
|
-
return value ?? null;
|
|
1863
|
-
};
|
|
1864
|
-
|
|
1865
|
-
// src/services/check-interrupter-journey-session-service.js
|
|
1866
|
-
var checkInterrupterJourneySessionService = (yar, journeyKey) => {
|
|
1867
|
-
const sessionData = yar.get(journeyKey);
|
|
1868
|
-
if (!sessionData) {
|
|
1869
|
-
return false;
|
|
1870
|
-
}
|
|
1871
|
-
if (Array.isArray(sessionData.orderedSectionsToFix)) {
|
|
1872
|
-
return true;
|
|
1873
|
-
}
|
|
1874
|
-
return false;
|
|
1875
|
-
};
|
|
1876
|
-
|
|
1877
|
-
// src/services/initialise-fix-journey-service.js
|
|
1878
|
-
var initialiseFixJourneyService = (yar, source, journeyType) => {
|
|
1879
|
-
let sessionKey;
|
|
1880
|
-
let sectionOrder = [];
|
|
1881
|
-
if (journeyType === "business") {
|
|
1882
|
-
sessionKey = "businessDetailsValidation";
|
|
1883
|
-
sectionOrder = BUSINESS_SECTION_ORDER;
|
|
1884
|
-
}
|
|
1885
|
-
if (journeyType === "personal") {
|
|
1886
|
-
sessionKey = "personalDetailsValidation";
|
|
1887
|
-
sectionOrder = PERSONAL_SECTION_ORDER;
|
|
1888
|
-
}
|
|
1889
|
-
const sessionData = yar.get(sessionKey);
|
|
1890
|
-
if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
|
|
1891
|
-
return sessionData;
|
|
1892
|
-
}
|
|
1893
|
-
const orderedSectionsToFix = orderSectionsToFix(
|
|
1894
|
-
sessionData.sectionsNeedingUpdate,
|
|
1895
|
-
source,
|
|
1896
|
-
sectionOrder
|
|
1897
|
-
);
|
|
1898
|
-
updateSessionData(sessionData, source, orderedSectionsToFix);
|
|
1899
|
-
yar.set(sessionKey, sessionData);
|
|
1900
|
-
return sessionData;
|
|
1901
|
-
};
|
|
1902
|
-
var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
|
|
1903
|
-
sessionData.orderedSectionsToFix = orderedSectionsToFix;
|
|
1904
|
-
delete sessionData.sectionsNeedingUpdate;
|
|
1905
|
-
delete sessionData.personalFixUpdates;
|
|
1906
|
-
delete sessionData.businessFixUpdates;
|
|
1907
|
-
if (source) {
|
|
1908
|
-
sessionData.source = source;
|
|
1909
|
-
}
|
|
1910
|
-
};
|
|
1911
|
-
var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
|
|
1912
|
-
const sections = SECTION_ORDER.filter((section) => {
|
|
1913
|
-
return sectionsNeedingUpdate.includes(section);
|
|
1914
|
-
});
|
|
1915
|
-
if (!source) {
|
|
1916
|
-
return sections;
|
|
1917
|
-
}
|
|
1918
|
-
if (!SECTION_ORDER.includes(source)) {
|
|
1919
|
-
return sections;
|
|
1920
|
-
}
|
|
1921
|
-
return [
|
|
1922
|
-
source,
|
|
1923
|
-
...sections.filter((section) => section !== source)
|
|
1924
|
-
];
|
|
1925
|
-
};
|
|
1926
|
-
|
|
1927
|
-
// src/services/validate-fix-details-service.js
|
|
1928
|
-
var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
|
|
1929
|
-
const errors = [];
|
|
1930
|
-
for (const section of orderedSectionsToFix) {
|
|
1931
|
-
const schema = schemas2[section];
|
|
1932
|
-
const result = schema.validate(payload, {
|
|
1933
|
-
abortEarly: false,
|
|
1934
|
-
allowUnknown: true
|
|
1935
|
-
});
|
|
1936
|
-
if (result.error) {
|
|
1937
|
-
errors.push(...result.error.details);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
if (errors.length > 0) {
|
|
1941
|
-
return {
|
|
1942
|
-
error: {
|
|
1943
|
-
details: errors
|
|
1944
|
-
}
|
|
1945
|
-
};
|
|
1946
|
-
}
|
|
1947
|
-
return { value: payload };
|
|
1948
|
-
};
|
|
1949
|
-
|
|
1950
|
-
// src/services/set-fix-session-data-service.js
|
|
1951
|
-
var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
|
|
1952
|
-
const orderedSectionsToFix = sessionData.orderedSectionsToFix;
|
|
1953
|
-
const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
|
|
1954
|
-
const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
|
|
1955
|
-
const fixUpdates = {};
|
|
1956
|
-
for (const section of orderedSectionsToFix) {
|
|
1957
|
-
const fields = SECTION_FIELD_ORDER[section];
|
|
1958
|
-
fixUpdates[section] = {};
|
|
1959
|
-
for (const field of fields) {
|
|
1960
|
-
fixUpdates[section][field] = payload[field] ?? "";
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
sessionData[updateKey] = fixUpdates;
|
|
1964
|
-
yar.set(journeyKey, sessionData);
|
|
1965
|
-
};
|
|
1966
|
-
|
|
1967
|
-
// src/services/build-fix-success-message-service.js
|
|
1968
|
-
var LABEL_MAPS = {
|
|
1969
|
-
personal: {
|
|
1970
|
-
name: "full name",
|
|
1971
|
-
email: "personal email address",
|
|
1972
|
-
phone: "personal phone numbers",
|
|
1973
|
-
dob: "date of birth",
|
|
1974
|
-
address: "personal address"
|
|
1975
|
-
},
|
|
1976
|
-
business: {
|
|
1977
|
-
name: "business name",
|
|
1978
|
-
email: "business email address",
|
|
1979
|
-
phone: "business phone numbers",
|
|
1980
|
-
vat: "business vat number",
|
|
1981
|
-
address: "business address"
|
|
1982
|
-
}
|
|
1983
|
-
};
|
|
1984
|
-
var PROPERTY_MAPS = {
|
|
1985
|
-
personal: {
|
|
1986
|
-
name: "changePersonalName",
|
|
1987
|
-
email: "changePersonalEmail",
|
|
1988
|
-
phone: "changePersonalPhoneNumbers",
|
|
1989
|
-
dob: "changePersonalDob",
|
|
1990
|
-
address: "changePersonalAddress"
|
|
1991
|
-
},
|
|
1992
|
-
business: {
|
|
1993
|
-
name: "changeBusinessName",
|
|
1994
|
-
email: "changeBusinessEmail",
|
|
1995
|
-
phone: "changeBusinessPhoneNumbers",
|
|
1996
|
-
vat: "changeBusinessVat",
|
|
1997
|
-
address: "changeBusinessAddress"
|
|
1998
|
-
}
|
|
1999
|
-
};
|
|
2000
|
-
var buildFixSuccessMessageService = (type, details) => {
|
|
2001
|
-
const { orderedSectionsToFix } = details;
|
|
2002
|
-
const changes = loopThroughSections(type, details, orderedSectionsToFix);
|
|
2003
|
-
if (changes.length === 0) {
|
|
2004
|
-
return null;
|
|
2005
|
-
}
|
|
2006
|
-
if (changes.length === 1) {
|
|
2007
|
-
return {
|
|
2008
|
-
type: "text",
|
|
2009
|
-
value: `You have updated your ${changes[0]}`
|
|
2010
|
-
};
|
|
2011
|
-
}
|
|
2012
|
-
return {
|
|
2013
|
-
type: "html",
|
|
2014
|
-
value: `
|
|
2015
|
-
<h3 class="govuk-notification-banner__heading">
|
|
2016
|
-
You have updated your:
|
|
2017
|
-
</h3>
|
|
2018
|
-
<ul class="govuk-list govuk-list--bullet">
|
|
2019
|
-
${changes.map((change) => `<li>${change}</li>`).join("")}
|
|
2020
|
-
</ul>
|
|
2021
|
-
`
|
|
2022
|
-
};
|
|
2023
|
-
};
|
|
2024
|
-
var loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
2025
|
-
const changes = [];
|
|
2026
|
-
const labelMap = LABEL_MAPS[type];
|
|
2027
|
-
const propertyMap = PROPERTY_MAPS[type];
|
|
2028
|
-
for (const section of orderedSectionsToFix) {
|
|
2029
|
-
if (details[propertyMap[section]]) {
|
|
2030
|
-
changes.push(labelMap[section]);
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
return changes;
|
|
2034
|
-
};
|
|
2035
|
-
|
|
2036
2030
|
// src/services/personal/build-customer-fix-update-variables-service.js
|
|
2037
2031
|
var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
2038
2032
|
const { orderedSectionsToFix, crn } = personalDetails;
|
|
@@ -2041,10 +2035,10 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
|
2041
2035
|
Object.assign(input, buildNameInput(personalDetails.changePersonalName));
|
|
2042
2036
|
}
|
|
2043
2037
|
if (orderedSectionsToFix.includes("email") && personalDetails.changePersonalEmail) {
|
|
2044
|
-
Object.assign(input,
|
|
2038
|
+
Object.assign(input, buildEmailInput2(personalDetails.changePersonalEmail));
|
|
2045
2039
|
}
|
|
2046
2040
|
if (orderedSectionsToFix.includes("phone") && personalDetails.changePersonalPhoneNumbers) {
|
|
2047
|
-
Object.assign(input,
|
|
2041
|
+
Object.assign(input, buildPhoneInput2(personalDetails.changePersonalPhoneNumbers));
|
|
2048
2042
|
}
|
|
2049
2043
|
if (orderedSectionsToFix.includes("dob") && personalDetails.changePersonalDob) {
|
|
2050
2044
|
Object.assign(input, buildDobInput(personalDetails.changePersonalDob));
|
|
@@ -2054,7 +2048,7 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
|
2054
2048
|
}
|
|
2055
2049
|
return { input };
|
|
2056
2050
|
};
|
|
2057
|
-
var
|
|
2051
|
+
var buildPhoneInput2 = (change) => {
|
|
2058
2052
|
return {
|
|
2059
2053
|
phone: {
|
|
2060
2054
|
landline: change.personalTelephone ?? null,
|
|
@@ -2062,7 +2056,7 @@ var buildPhoneInput = (change) => {
|
|
|
2062
2056
|
}
|
|
2063
2057
|
};
|
|
2064
2058
|
};
|
|
2065
|
-
var
|
|
2059
|
+
var buildEmailInput2 = (change) => {
|
|
2066
2060
|
return {
|
|
2067
2061
|
email: {
|
|
2068
2062
|
address: change.personalEmail
|
|
@@ -2084,17 +2078,58 @@ var buildDobInput = (change) => {
|
|
|
2084
2078
|
};
|
|
2085
2079
|
};
|
|
2086
2080
|
|
|
2081
|
+
// src/services/set-fix-session-data-service.js
|
|
2082
|
+
var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
|
|
2083
|
+
const orderedSectionsToFix = sessionData.orderedSectionsToFix;
|
|
2084
|
+
const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
|
|
2085
|
+
const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
|
|
2086
|
+
const fixUpdates = {};
|
|
2087
|
+
for (const section of orderedSectionsToFix) {
|
|
2088
|
+
const fields = SECTION_FIELD_ORDER[section];
|
|
2089
|
+
fixUpdates[section] = {};
|
|
2090
|
+
for (const field of fields) {
|
|
2091
|
+
fixUpdates[section][field] = payload[field] ?? "";
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
sessionData[updateKey] = fixUpdates;
|
|
2095
|
+
yar.set(journeyKey, sessionData);
|
|
2096
|
+
};
|
|
2097
|
+
|
|
2098
|
+
// src/services/validate-fix-details-service.js
|
|
2099
|
+
var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
|
|
2100
|
+
const errors = [];
|
|
2101
|
+
for (const section of orderedSectionsToFix) {
|
|
2102
|
+
const schema = schemas2[section];
|
|
2103
|
+
const result = schema.validate(payload, {
|
|
2104
|
+
abortEarly: false,
|
|
2105
|
+
allowUnknown: true
|
|
2106
|
+
});
|
|
2107
|
+
if (result.error) {
|
|
2108
|
+
errors.push(...result.error.details);
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
if (errors.length > 0) {
|
|
2112
|
+
return {
|
|
2113
|
+
error: {
|
|
2114
|
+
details: errors
|
|
2115
|
+
}
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
return { value: payload };
|
|
2119
|
+
};
|
|
2120
|
+
|
|
2087
2121
|
// src/services/services.js
|
|
2088
2122
|
var services = {
|
|
2089
2123
|
addressLookup: addressLookupService,
|
|
2090
|
-
|
|
2124
|
+
buildBusinessFixUpdateVariables: buildBusinessFixUpdateVariablesService,
|
|
2125
|
+
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService,
|
|
2126
|
+
buildFixSuccessMessage: buildFixSuccessMessageService,
|
|
2091
2127
|
buildManualAddress,
|
|
2128
|
+
buildUprnAddress,
|
|
2092
2129
|
checkInterrupterJourneySession: checkInterrupterJourneySessionService,
|
|
2093
2130
|
initialiseFixJourney: initialiseFixJourneyService,
|
|
2094
|
-
validateFixDetails: validateFixDetailsService,
|
|
2095
2131
|
setFixSessionData: setFixSessionDataService,
|
|
2096
|
-
|
|
2097
|
-
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
|
|
2132
|
+
validateFixDetails: validateFixDetailsService
|
|
2098
2133
|
};
|
|
2099
2134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2100
2135
|
0 && (module.exports = {
|