@defra/fcp-sfd-frontend-engine 0.34.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 CHANGED
@@ -346,81 +346,6 @@ var constants = {
346
346
  }
347
347
  };
348
348
 
349
- // src/mappers/personal-business-details-mapper.js
350
- var mapPersonalBusinessDetails = (value) => {
351
- return {
352
- userName: mappers.customerName(value.customer.info.name),
353
- business: {
354
- organisationId: value.business.organisationId ?? null,
355
- sbi: value.business.sbi ?? null,
356
- name: value.business.info.name ?? null
357
- }
358
- };
359
- };
360
-
361
- // src/mappers/address-mapper.js
362
- var mapAddress = (address = {}) => {
363
- return {
364
- lookup: {
365
- pafOrganisationName: address.pafOrganisationName,
366
- buildingNumberRange: address.buildingNumberRange,
367
- flatName: address.flatName,
368
- buildingName: address.buildingName,
369
- dependentLocality: address.dependentLocality,
370
- doubleDependentLocality: address.doubleDependentLocality,
371
- street: address.street,
372
- county: address.county,
373
- uprn: address.uprn
374
- },
375
- manual: {
376
- line1: address.line1,
377
- line2: address.line2,
378
- line3: address.line3,
379
- line4: address.line4,
380
- line5: address.line5
381
- },
382
- city: address.city,
383
- postcode: address.postalCode,
384
- country: address.country
385
- };
386
- };
387
-
388
- // src/mappers/customer-name-mapper.js
389
- var mapCustomerName = (name = {}) => {
390
- return [
391
- name.first,
392
- name.last
393
- ].filter(Boolean).join(" ");
394
- };
395
-
396
- // src/mappers/business-details-mapper.js
397
- var asNullable = (value) => value ?? null;
398
- var mapBusinessDetails = (value) => {
399
- var _a, _b, _c, _d, _e, _f;
400
- const business = (value == null ? void 0 : value.business) ?? {};
401
- const info = business.info ?? {};
402
- const registrationNumbers = info.registrationNumbers ?? {};
403
- return {
404
- sbi: business.sbi,
405
- businessName: asNullable(info.name),
406
- vat: asNullable(info.vat),
407
- traderNumber: asNullable(info.traderNumber),
408
- vendorNumber: asNullable(info.vendorNumber),
409
- legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
410
- legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
411
- registrationNumbers: {
412
- companiesHouse: asNullable(registrationNumbers.companiesHouse),
413
- charityCommission: asNullable(registrationNumbers.charityCommission)
414
- },
415
- type: asNullable((_c = info.type) == null ? void 0 : _c.type),
416
- countyParishHoldingNumbers: business.countyParishHoldings ?? [],
417
- address: mapAddress(info.address),
418
- email: asNullable((_d = info.email) == null ? void 0 : _d.address),
419
- landline: asNullable((_e = info.phone) == null ? void 0 : _e.landline),
420
- mobile: asNullable((_f = info.phone) == null ? void 0 : _f.mobile)
421
- };
422
- };
423
-
424
349
  // src/utils/joi.js
425
350
  var import_joi = __toESM(require("joi"), 1);
426
351
  var Joi = import_joi.default.extend((joi) => ({
@@ -925,127 +850,219 @@ var filterAndJoin = (addressesProperties) => {
925
850
  return addressesProperties.filter(Boolean).join(", ") || null;
926
851
  };
927
852
 
928
- // src/mappers/mappers.js
929
- var mappers = {
930
- personalBusinessDetails: mapPersonalBusinessDetails,
931
- address: mapAddress,
932
- customerName: mapCustomerName,
933
- businessDetails: mapBusinessDetails,
934
- addressLookup: addressLookupMapper
853
+ // src/mappers/address-mapper.js
854
+ var mapAddress = (address = {}) => {
855
+ return {
856
+ lookup: {
857
+ pafOrganisationName: address.pafOrganisationName,
858
+ buildingNumberRange: address.buildingNumberRange,
859
+ flatName: address.flatName,
860
+ buildingName: address.buildingName,
861
+ dependentLocality: address.dependentLocality,
862
+ doubleDependentLocality: address.doubleDependentLocality,
863
+ street: address.street,
864
+ county: address.county,
865
+ uprn: address.uprn
866
+ },
867
+ manual: {
868
+ line1: address.line1,
869
+ line2: address.line2,
870
+ line3: address.line3,
871
+ line4: address.line4,
872
+ line5: address.line5
873
+ },
874
+ city: address.city,
875
+ postcode: address.postalCode,
876
+ country: address.country
877
+ };
935
878
  };
936
879
 
937
- // src/mutations/business/update-business-email.js
938
- var updateBusinessEmailMutation = `
939
- mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
940
- updateBusinessEmail(input: $input) {
941
- business {
942
- info {
943
- email {
944
- address
945
- }
946
- }
947
- }
948
- success
949
- }
950
- }
951
- `;
880
+ // src/mappers/business-details-mapper.js
881
+ var asNullable = (value) => {
882
+ return value ?? null;
883
+ };
884
+ var mapBusinessDetails = (value) => {
885
+ var _a, _b, _c, _d, _e, _f;
886
+ const business = (value == null ? void 0 : value.business) ?? {};
887
+ const info = business.info ?? {};
888
+ const registrationNumbers = info.registrationNumbers ?? {};
889
+ return {
890
+ sbi: business.sbi,
891
+ businessName: asNullable(info.name),
892
+ vat: asNullable(info.vat),
893
+ traderNumber: asNullable(info.traderNumber),
894
+ vendorNumber: asNullable(info.vendorNumber),
895
+ legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
896
+ legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
897
+ registrationNumbers: {
898
+ companiesHouse: asNullable(registrationNumbers.companiesHouse),
899
+ charityCommission: asNullable(registrationNumbers.charityCommission)
900
+ },
901
+ type: asNullable((_c = info.type) == null ? void 0 : _c.type),
902
+ countyParishHoldingNumbers: business.countyParishHoldings ?? [],
903
+ address: mapAddress(info.address),
904
+ email: asNullable((_d = info.email) == null ? void 0 : _d.address),
905
+ landline: asNullable((_e = info.phone) == null ? void 0 : _e.landline),
906
+ mobile: asNullable((_f = info.phone) == null ? void 0 : _f.mobile)
907
+ };
908
+ };
952
909
 
953
- // src/mutations/business/update-business-name.js
954
- var updateBusinessNameMutation = `
955
- mutation UpdateBusinessName($input: UpdateBusinessNameInput!) {
956
- updateBusinessName(input: $input) {
957
- business {
958
- info {
959
- name
960
- }
961
- }
962
- success
963
- }
964
- }
965
- `;
910
+ // src/mappers/customer-name-mapper.js
911
+ var mapCustomerName = (name = {}) => {
912
+ return [
913
+ name.first,
914
+ name.last
915
+ ].filter(Boolean).join(" ");
916
+ };
966
917
 
967
- // src/mutations/business/update-business-phone-numbers.js
968
- var updateBusinessPhoneNumbersMutation = `
969
- mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneInput!) {
970
- updateBusinessPhone(input: $input) {
971
- business {
972
- info {
973
- phone {
974
- landline
975
- mobile
976
- }
977
- }
978
- }
918
+ // src/mappers/personal-business-details-mapper.js
919
+ var mapPersonalBusinessDetails = (value) => {
920
+ return {
921
+ userName: mappers.customerName(value.customer.info.name),
922
+ business: {
923
+ organisationId: value.business.organisationId ?? null,
924
+ sbi: value.business.sbi ?? null,
925
+ name: value.business.info.name ?? null
979
926
  }
980
- }
981
- `;
927
+ };
928
+ };
982
929
 
983
- // src/mutations/personal/update-customer-name.js
984
- var updateCustomerNameMutation = `
985
- mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
986
- updateCustomerName(input: $input) {
987
- customer {
988
- info {
989
- name {
990
- first
991
- last
992
- middle
993
- }
994
- }
995
- }
996
- }
997
- }
998
- `;
930
+ // src/utils/format-full-name.js
931
+ var formatFullName = (nameData) => {
932
+ return [
933
+ nameData.first,
934
+ nameData.middle,
935
+ nameData.last
936
+ ].filter(Boolean).join(" ");
937
+ };
999
938
 
1000
- // src/mutations/personal/update-customer-dob.js
1001
- var updateCustomerDobMutation = `
1002
- mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
1003
- updateCustomerDateOfBirth(input: $input) {
1004
- customer {
1005
- info {
1006
- dateOfBirth
939
+ // src/utils/format-validation-errors.js
940
+ var formatValidationErrors = (errors) => {
941
+ const formattedErrors = {};
942
+ errors.forEach((error) => {
943
+ const { type, context, message: text, path } = error;
944
+ if (Array.isArray(path) && path.length > 1) {
945
+ for (const field of path) {
946
+ if (!formattedErrors[field]) {
947
+ formattedErrors[field] = { text };
1007
948
  }
1008
949
  }
950
+ return;
1009
951
  }
1010
- }
1011
- `;
1012
-
1013
- // src/mutations/personal/update-customer-phone.js
1014
- var updateCustomerPhoneMutation = `
1015
- mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
1016
- updateCustomerPhone(input: $input) {
1017
- customer {
1018
- info {
1019
- phone {
1020
- landline
1021
- mobile
1022
- }
1023
- }
1024
- }
952
+ if (type === "object.missing" && Array.isArray(context == null ? void 0 : context.peers)) {
953
+ context.peers.forEach((peer) => {
954
+ formattedErrors[peer] = { text };
955
+ });
956
+ return;
1025
957
  }
1026
- }
1027
- `;
1028
-
1029
- // src/mutations/personal/update-customer-email.js
1030
- var updateCustomerEmailMutation = `
1031
- mutation UpdateCustomerEmail($input: UpdateCustomerEmailInput!) {
1032
- updateCustomerEmail(input: $input) {
1033
- customer {
1034
- info {
1035
- email {
1036
- address
1037
- }
1038
- }
1039
- }
958
+ if (!formattedErrors[path[0]]) {
959
+ formattedErrors[path[0]] = { text };
960
+ }
961
+ });
962
+ return formattedErrors;
963
+ };
964
+
965
+ // src/utils/build-update-business-email-variables.js
966
+ var buildUpdateBusinessEmailVariables = (email, sbi) => {
967
+ return { input: { email: { address: email }, sbi } };
968
+ };
969
+
970
+ // src/utils/build-update-business-name-variables.js
971
+ var buildUpdateBusinessNameVariables = (name, sbi) => {
972
+ return { input: { name, sbi } };
973
+ };
974
+
975
+ // src/utils/build-update-business-phone-numbers-variables.js
976
+ var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
977
+ return {
978
+ input: {
979
+ phone: {
980
+ landline: businessTelephone ?? null,
981
+ mobile: businessMobile ?? null
982
+ },
983
+ sbi
984
+ }
985
+ };
986
+ };
987
+
988
+ // src/utils/build-update-business-vat-variables.js
989
+ var buildUpdateBusinessVatVariables = (vat, sbi) => {
990
+ return {
991
+ input: {
992
+ vat,
993
+ sbi
1040
994
  }
995
+ };
996
+ };
997
+
998
+ // src/utils/utils.js
999
+ var utils = {
1000
+ formatFullName,
1001
+ formatValidationErrors,
1002
+ buildUpdateBusinessEmailVariables,
1003
+ buildUpdateBusinessNameVariables,
1004
+ buildUpdateBusinessPhoneNumbersVariables,
1005
+ buildUpdateBusinessVatVariables
1006
+ };
1007
+
1008
+ // src/mappers/personal-details-mapper.js
1009
+ var asNullable2 = (value) => {
1010
+ return value ?? null;
1011
+ };
1012
+ var mapPersonalDetails = (value) => {
1013
+ var _a, _b, _c;
1014
+ protectAgainstNull(value);
1015
+ const customerInfo = value.customer.info;
1016
+ const customerName = customerInfo.name;
1017
+ const [year, month, day] = customerInfo.dateOfBirth ? customerInfo.dateOfBirth.split("-") : [];
1018
+ return {
1019
+ crn: value.customer.crn ?? null,
1020
+ userName: customerName ? mapCustomerName(customerName) : null,
1021
+ fullName: {
1022
+ first: asNullable2(customerName == null ? void 0 : customerName.first),
1023
+ last: asNullable2(customerName == null ? void 0 : customerName.last),
1024
+ middle: asNullable2(customerName == null ? void 0 : customerName.middle)
1025
+ },
1026
+ fullNameJoined: customerName ? utils.formatFullName(customerName) : "",
1027
+ dateOfBirth: {
1028
+ full: asNullable2(customerInfo.dateOfBirth),
1029
+ day: asNullable2(day),
1030
+ month: asNullable2(month),
1031
+ year: asNullable2(year)
1032
+ },
1033
+ address: customerInfo.address ? mapAddress(customerInfo.address) : {},
1034
+ email: asNullable2((_a = customerInfo.email) == null ? void 0 : _a.address),
1035
+ telephone: asNullable2((_b = customerInfo.phone) == null ? void 0 : _b.landline),
1036
+ mobile: asNullable2((_c = customerInfo.phone) == null ? void 0 : _c.mobile)
1037
+ };
1038
+ };
1039
+ var protectAgainstNull = (value) => {
1040
+ if (value === null || value === void 0) {
1041
+ throw new Error("Personal details value cannot be null or undefined");
1041
1042
  }
1042
- `;
1043
+ if (!value.customer) {
1044
+ throw new Error("Personal details value must contain a customer object");
1045
+ }
1046
+ if (!value.customer.info) {
1047
+ throw new Error("Customer must contain an info object");
1048
+ }
1049
+ };
1043
1050
 
1044
- // src/mutations/personal/update-customer-address.js
1045
- var updateCustomerAddressMutation = `
1046
- mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
1047
- updateCustomerAddress(input: $input) {
1048
- customer {
1051
+ // src/mappers/mappers.js
1052
+ var mappers = {
1053
+ address: mapAddress,
1054
+ addressLookup: addressLookupMapper,
1055
+ businessDetails: mapBusinessDetails,
1056
+ customerName: mapCustomerName,
1057
+ personalBusinessDetails: mapPersonalBusinessDetails,
1058
+ personalDetails: mapPersonalDetails
1059
+ };
1060
+
1061
+ // src/mutations/business/update-business-address.js
1062
+ var updateBusinessAddressMutation = `
1063
+ mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
1064
+ updateBusinessAddress(input: $input) {
1065
+ business {
1049
1066
  info {
1050
1067
  address {
1051
1068
  line1
@@ -1069,30 +1086,91 @@ var updateCustomerAddressMutation = `
1069
1086
  }
1070
1087
  `;
1071
1088
 
1072
- // src/mutations/business/update-business-address.js
1073
- var updateBusinessAddressMutation = `
1074
- mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
1075
- updateBusinessAddress(input: $input) {
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
+
1098
+ // src/mutations/business/update-business-email.js
1099
+ var updateBusinessEmailMutation = `
1100
+ mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
1101
+ updateBusinessEmail(input: $input) {
1076
1102
  business {
1077
1103
  info {
1078
- address {
1079
- line1
1080
- line2
1081
- line3
1082
- line4
1083
- line5
1084
- postalCode
1085
- country
1086
- city
1087
- buildingNumberRange
1088
- buildingName
1089
- flatName
1090
- street
1091
- county
1092
- uprn
1104
+ email {
1105
+ address
1106
+ }
1107
+ }
1108
+ }
1109
+ success
1110
+ }
1111
+ }
1112
+ `;
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
+
1131
+ // src/mutations/business/update-business-name.js
1132
+ var updateBusinessNameMutation = `
1133
+ mutation UpdateBusinessName($input: UpdateBusinessNameInput!) {
1134
+ updateBusinessName(input: $input) {
1135
+ business {
1136
+ info {
1137
+ name
1138
+ }
1139
+ }
1140
+ success
1141
+ }
1142
+ }
1143
+ `;
1144
+
1145
+ // src/mutations/business/update-business-phone-numbers.js
1146
+ var updateBusinessPhoneNumbersMutation = `
1147
+ mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneInput!) {
1148
+ updateBusinessPhone(input: $input) {
1149
+ business {
1150
+ info {
1151
+ phone {
1152
+ landline
1153
+ mobile
1154
+ }
1155
+ }
1156
+ }
1157
+ }
1158
+ }
1159
+ `;
1160
+
1161
+ // src/mutations/business/update-business-registration-numbers.js
1162
+ var updateBusinessRegistrationNumbersMutation = `
1163
+ mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
1164
+ updateBusinessRegistrationNumbers(input: $input) {
1165
+ business {
1166
+ info {
1167
+ registrationNumbers {
1168
+ companiesHouse
1169
+ charityCommission
1093
1170
  }
1094
1171
  }
1095
1172
  }
1173
+ success
1096
1174
  }
1097
1175
  }
1098
1176
  `;
@@ -1111,40 +1189,26 @@ var updateBusinessVatMutation = `
1111
1189
  }
1112
1190
  `;
1113
1191
 
1114
- // src/mutations/personal/update-customer-details.js
1115
- var updateCustomerDetailsMutation = `
1116
- mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
1117
- updateCustomerAllFields(input: $input) {
1118
- success
1192
+ // src/mutations/personal/update-customer-address.js
1193
+ var updateCustomerAddressMutation = `
1194
+ mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
1195
+ updateCustomerAddress(input: $input) {
1119
1196
  customer {
1120
1197
  info {
1121
- name {
1122
- first
1123
- middle
1124
- last
1125
- }
1126
- dateOfBirth
1127
- phone {
1128
- mobile
1129
- landline
1130
- }
1131
- email {
1132
- address
1133
- }
1134
1198
  address {
1135
1199
  line1
1136
1200
  line2
1137
1201
  line3
1138
1202
  line4
1139
1203
  line5
1204
+ postalCode
1205
+ country
1206
+ city
1140
1207
  buildingNumberRange
1141
1208
  buildingName
1142
1209
  flatName
1143
1210
  street
1144
- city
1145
1211
  county
1146
- postalCode
1147
- country
1148
1212
  uprn
1149
1213
  }
1150
1214
  }
@@ -1153,55 +1217,92 @@ var updateCustomerDetailsMutation = `
1153
1217
  }
1154
1218
  `;
1155
1219
 
1156
- // src/mutations/business/update-business-legal-status.js
1157
- var updateBusinessLegalStatusMutation = `
1158
- mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
1159
- updateBusinessLegalStatus(input: $input) {
1160
- business {
1220
+ // src/mutations/personal/update-customer-details.js
1221
+ var updateCustomerDetailsMutation = `
1222
+ mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
1223
+ updateCustomerAllFields(input: $input) {
1224
+ success
1225
+ }
1226
+ }
1227
+ `;
1228
+
1229
+ // src/mutations/personal/update-customer-dob.js
1230
+ var updateCustomerDobMutation = `
1231
+ mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
1232
+ updateCustomerDateOfBirth(input: $input) {
1233
+ customer {
1161
1234
  info {
1162
- legalStatus {
1163
- code
1164
- type
1165
- }
1235
+ dateOfBirth
1166
1236
  }
1167
1237
  }
1168
- success
1169
1238
  }
1170
1239
  }
1171
1240
  `;
1172
1241
 
1173
- // src/mutations/business/update-business-registration-numbers.js
1174
- var updateBusinessRegistrationNumbersMutation = `
1175
- mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
1176
- updateBusinessRegistrationNumbers(input: $input) {
1177
- business {
1242
+ // src/mutations/personal/update-customer-email.js
1243
+ var updateCustomerEmailMutation = `
1244
+ mutation UpdateCustomerEmail($input: UpdateCustomerEmailInput!) {
1245
+ updateCustomerEmail(input: $input) {
1246
+ customer {
1178
1247
  info {
1179
- registrationNumbers {
1180
- companiesHouse
1181
- charityCommission
1248
+ email {
1249
+ address
1182
1250
  }
1183
1251
  }
1184
1252
  }
1185
- success
1186
1253
  }
1187
1254
  }
1188
1255
  `;
1189
1256
 
1190
- // src/mutations/mutations.js
1191
- var mutations = {
1192
- updateBusinessEmail: updateBusinessEmailMutation,
1257
+ // src/mutations/personal/update-customer-name.js
1258
+ var updateCustomerNameMutation = `
1259
+ mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
1260
+ updateCustomerName(input: $input) {
1261
+ customer {
1262
+ info {
1263
+ name {
1264
+ first
1265
+ last
1266
+ middle
1267
+ }
1268
+ }
1269
+ }
1270
+ }
1271
+ }
1272
+ `;
1273
+
1274
+ // src/mutations/personal/update-customer-phone.js
1275
+ var updateCustomerPhoneMutation = `
1276
+ mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
1277
+ updateCustomerPhone(input: $input) {
1278
+ customer {
1279
+ info {
1280
+ phone {
1281
+ landline
1282
+ mobile
1283
+ }
1284
+ }
1285
+ }
1286
+ }
1287
+ }
1288
+ `;
1289
+
1290
+ // src/mutations/mutations.js
1291
+ var mutations = {
1292
+ updateBusinessAddress: updateBusinessAddressMutation,
1293
+ updateBusinessDetails: updateBusinessDetailsMutation,
1294
+ updateBusinessEmail: updateBusinessEmailMutation,
1295
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1193
1296
  updateBusinessName: updateBusinessNameMutation,
1194
1297
  updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
1195
- updateBusinessAddress: updateBusinessAddressMutation,
1196
- updateCustomerName: updateCustomerNameMutation,
1197
- updateCustomerDob: updateCustomerDobMutation,
1198
- updateCustomerPhone: updateCustomerPhoneMutation,
1199
- updateCustomerEmail: updateCustomerEmailMutation,
1200
- updateCustomerAddress: updateCustomerAddressMutation,
1298
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation,
1201
1299
  updateBusinessVat: updateBusinessVatMutation,
1300
+ updateCustomerAddress: updateCustomerAddressMutation,
1202
1301
  updateCustomerDetails: updateCustomerDetailsMutation,
1203
- updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1204
- updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
1302
+ updateCustomerDob: updateCustomerDobMutation,
1303
+ updateCustomerEmail: updateCustomerEmailMutation,
1304
+ updateCustomerName: updateCustomerNameMutation,
1305
+ updateCustomerPhone: updateCustomerPhoneMutation
1205
1306
  };
1206
1307
 
1207
1308
  // src/presenters/base-presenter.js
@@ -1443,89 +1544,252 @@ var presenters = {
1443
1544
  addressChangeLink
1444
1545
  };
1445
1546
 
1446
- // src/utils/format-full-name.js
1447
- var formatFullName = (nameData) => {
1448
- return [
1449
- nameData.first,
1450
- nameData.middle,
1451
- nameData.last
1452
- ].filter(Boolean).join(" ");
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;
1453
1598
  };
1454
1599
 
1455
- // src/utils/format-validation-errors.js
1456
- var formatValidationErrors = (errors) => {
1457
- const formattedErrors = {};
1458
- errors.forEach((error) => {
1459
- const { type, context, message: text, path } = error;
1460
- if (Array.isArray(path) && path.length > 1) {
1461
- for (const field of path) {
1462
- if (!formattedErrors[field]) {
1463
- formattedErrors[field] = { text };
1464
- }
1465
- }
1466
- return;
1467
- }
1468
- if (type === "object.missing" && Array.isArray(context == null ? void 0 : context.peers)) {
1469
- context.peers.forEach((peer) => {
1470
- formattedErrors[peer] = { text };
1471
- });
1472
- return;
1473
- }
1474
- if (!formattedErrors[path[0]]) {
1475
- formattedErrors[path[0]] = { text };
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]);
1476
1664
  }
1477
- });
1478
- return formattedErrors;
1665
+ }
1666
+ return changes;
1479
1667
  };
1480
1668
 
1481
- // src/utils/build-update-business-email-variables.js
1482
- var buildUpdateBusinessEmailVariables = (email, sbi) => {
1483
- return { input: { email: { address: email }, sbi } };
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 };
1484
1677
  };
1485
-
1486
- // src/utils/build-update-business-name-variables.js
1487
- var buildUpdateBusinessNameVariables = (name, sbi) => {
1488
- return { input: { name, sbi } };
1678
+ var applyAddressSection = (input, businessDetails, orderedSectionsToFix) => {
1679
+ if (orderedSectionsToFix.includes("address") && businessDetails.changeBusinessAddress) {
1680
+ input.address = { withoutUprn: buildManualAddress(businessDetails.changeBusinessAddress) };
1681
+ }
1489
1682
  };
1490
-
1491
- // src/utils/build-update-business-phone-numbers-variables.js
1492
- var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
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) => {
1493
1711
  return {
1494
- input: {
1495
- phone: {
1496
- landline: businessTelephone ?? null,
1497
- mobile: businessMobile ?? null
1498
- },
1499
- sbi
1712
+ email: {
1713
+ address: change.businessEmail
1500
1714
  }
1501
1715
  };
1502
1716
  };
1503
-
1504
- // src/utils/build-update-business-vat-variables.js
1505
- var buildUpdateBusinessVatVariables = (vat, sbi) => {
1717
+ var buildPhoneInput = (change) => {
1506
1718
  return {
1507
- input: {
1508
- vat,
1509
- sbi
1719
+ phone: {
1720
+ landline: change.businessTelephone ?? null,
1721
+ mobile: change.businessMobile ?? null
1510
1722
  }
1511
1723
  };
1512
1724
  };
1513
1725
 
1514
- // src/utils/utils.js
1515
- var utils = {
1516
- formatFullName,
1517
- formatValidationErrors,
1518
- buildUpdateBusinessEmailVariables,
1519
- buildUpdateBusinessNameVariables,
1520
- buildUpdateBusinessPhoneNumbersVariables,
1521
- buildUpdateBusinessVatVariables
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;
1522
1736
  };
1523
1737
 
1524
- // src/services/os-places/address-lookup-service.js
1525
- var import_osdatahub = require("osdatahub");
1526
-
1527
- // src/mock-data/mock-os-places-addresses.js
1528
- var mockAddresses = [
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 = [
1529
1793
  {
1530
1794
  properties: {
1531
1795
  UPRN: "10000001",
@@ -1763,230 +2027,6 @@ var isRetryable = (error) => {
1763
2027
  return false;
1764
2028
  };
1765
2029
 
1766
- // src/services/build-address-variables-service.js
1767
- var buildUprnAddress = (change) => {
1768
- return {
1769
- pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
1770
- buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
1771
- buildingName: nullIfUndefined(change.buildingName),
1772
- flatName: nullIfUndefined(change.flatName),
1773
- street: nullIfUndefined(change.street),
1774
- city: nullIfUndefined(change.city),
1775
- county: nullIfUndefined(change.county),
1776
- postalCode: nullIfUndefined(change.postcode),
1777
- country: nullIfUndefined(change.country),
1778
- dependentLocality: nullIfUndefined(change.dependentLocality),
1779
- doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
1780
- line1: null,
1781
- line2: null,
1782
- line3: null,
1783
- line4: null,
1784
- line5: null,
1785
- uprn: change.uprn
1786
- // required for DAL/v1
1787
- };
1788
- };
1789
- var buildManualAddress = (change) => {
1790
- return {
1791
- pafOrganisationName: null,
1792
- buildingNumberRange: null,
1793
- buildingName: null,
1794
- flatName: null,
1795
- street: null,
1796
- dependentLocality: null,
1797
- doubleDependentLocality: null,
1798
- county: null,
1799
- uprn: null,
1800
- line1: change.address1,
1801
- // required for DAL/v1
1802
- line2: nullIfUndefined(change.address2),
1803
- line3: nullIfUndefined(change.address3),
1804
- line4: nullIfUndefined(change.county),
1805
- // manual county mapped for validation
1806
- line5: null,
1807
- city: change.city,
1808
- // required for DAL/v1
1809
- postalCode: change.postcode,
1810
- // required for DAL/v1
1811
- country: change.country
1812
- // required for DAL/v1
1813
- };
1814
- };
1815
- var nullIfUndefined = (value) => {
1816
- return value ?? null;
1817
- };
1818
-
1819
- // src/services/check-interrupter-journey-session-service.js
1820
- var checkInterrupterJourneySessionService = (yar, journeyKey) => {
1821
- const sessionData = yar.get(journeyKey);
1822
- if (!sessionData) {
1823
- return false;
1824
- }
1825
- if (Array.isArray(sessionData.orderedSectionsToFix)) {
1826
- return true;
1827
- }
1828
- return false;
1829
- };
1830
-
1831
- // src/services/initialise-fix-journey-service.js
1832
- var initialiseFixJourneyService = (yar, source, journeyType) => {
1833
- let sessionKey;
1834
- let sectionOrder = [];
1835
- if (journeyType === "business") {
1836
- sessionKey = "businessDetailsValidation";
1837
- sectionOrder = BUSINESS_SECTION_ORDER;
1838
- }
1839
- if (journeyType === "personal") {
1840
- sessionKey = "personalDetailsValidation";
1841
- sectionOrder = PERSONAL_SECTION_ORDER;
1842
- }
1843
- const sessionData = yar.get(sessionKey);
1844
- if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
1845
- return sessionData;
1846
- }
1847
- const orderedSectionsToFix = orderSectionsToFix(
1848
- sessionData.sectionsNeedingUpdate,
1849
- source,
1850
- sectionOrder
1851
- );
1852
- updateSessionData(sessionData, source, orderedSectionsToFix);
1853
- yar.set(sessionKey, sessionData);
1854
- return sessionData;
1855
- };
1856
- var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
1857
- sessionData.orderedSectionsToFix = orderedSectionsToFix;
1858
- delete sessionData.sectionsNeedingUpdate;
1859
- delete sessionData.personalFixUpdates;
1860
- delete sessionData.businessFixUpdates;
1861
- if (source) {
1862
- sessionData.source = source;
1863
- }
1864
- };
1865
- var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
1866
- const sections = SECTION_ORDER.filter((section) => {
1867
- return sectionsNeedingUpdate.includes(section);
1868
- });
1869
- if (!source) {
1870
- return sections;
1871
- }
1872
- if (!SECTION_ORDER.includes(source)) {
1873
- return sections;
1874
- }
1875
- return [
1876
- source,
1877
- ...sections.filter((section) => section !== source)
1878
- ];
1879
- };
1880
-
1881
- // src/services/validate-fix-details-service.js
1882
- var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
1883
- const errors = [];
1884
- for (const section of orderedSectionsToFix) {
1885
- const schema = schemas2[section];
1886
- const result = schema.validate(payload, {
1887
- abortEarly: false,
1888
- allowUnknown: true
1889
- });
1890
- if (result.error) {
1891
- errors.push(...result.error.details);
1892
- }
1893
- }
1894
- if (errors.length > 0) {
1895
- return {
1896
- error: {
1897
- details: errors
1898
- }
1899
- };
1900
- }
1901
- return { value: payload };
1902
- };
1903
-
1904
- // src/services/set-fix-session-data-service.js
1905
- var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
1906
- const orderedSectionsToFix = sessionData.orderedSectionsToFix;
1907
- const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
1908
- const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
1909
- const fixUpdates = {};
1910
- for (const section of orderedSectionsToFix) {
1911
- const fields = SECTION_FIELD_ORDER[section];
1912
- fixUpdates[section] = {};
1913
- for (const field of fields) {
1914
- fixUpdates[section][field] = payload[field] ?? "";
1915
- }
1916
- }
1917
- sessionData[updateKey] = fixUpdates;
1918
- yar.set(journeyKey, sessionData);
1919
- };
1920
-
1921
- // src/services/build-fix-success-message-service.js
1922
- var LABEL_MAPS = {
1923
- personal: {
1924
- name: "full name",
1925
- email: "personal email address",
1926
- phone: "personal phone numbers",
1927
- dob: "date of birth",
1928
- address: "personal address"
1929
- },
1930
- business: {
1931
- name: "business name",
1932
- email: "business email address",
1933
- phone: "business phone numbers",
1934
- vat: "business vat number",
1935
- address: "business address"
1936
- }
1937
- };
1938
- var PROPERTY_MAPS = {
1939
- personal: {
1940
- name: "changePersonalName",
1941
- email: "changePersonalEmail",
1942
- phone: "changePersonalPhoneNumbers",
1943
- dob: "changePersonalDob",
1944
- address: "changePersonalAddress"
1945
- },
1946
- business: {
1947
- name: "changeBusinessName",
1948
- email: "changeBusinessEmail",
1949
- phone: "changeBusinessPhoneNumbers",
1950
- vat: "changeBusinessVat",
1951
- address: "changeBusinessAddress"
1952
- }
1953
- };
1954
- var buildFixSuccessMessageService = (type, details) => {
1955
- const { orderedSectionsToFix } = details;
1956
- const changes = loopThroughSections(type, details, orderedSectionsToFix);
1957
- if (changes.length === 0) {
1958
- return null;
1959
- }
1960
- if (changes.length === 1) {
1961
- return {
1962
- type: "text",
1963
- value: `You have updated your ${changes[0]}`
1964
- };
1965
- }
1966
- return {
1967
- type: "html",
1968
- value: `
1969
- <h3 class="govuk-notification-banner__heading">
1970
- You have updated your:
1971
- </h3>
1972
- <ul class="govuk-list govuk-list--bullet">
1973
- ${changes.map((change) => `<li>${change}</li>`).join("")}
1974
- </ul>
1975
- `
1976
- };
1977
- };
1978
- var loopThroughSections = (type, details, orderedSectionsToFix) => {
1979
- const changes = [];
1980
- const labelMap = LABEL_MAPS[type];
1981
- const propertyMap = PROPERTY_MAPS[type];
1982
- for (const section of orderedSectionsToFix) {
1983
- if (details[propertyMap[section]]) {
1984
- changes.push(labelMap[section]);
1985
- }
1986
- }
1987
- return changes;
1988
- };
1989
-
1990
2030
  // src/services/personal/build-customer-fix-update-variables-service.js
1991
2031
  var buildCustomerFixUpdateVariablesService = (personalDetails) => {
1992
2032
  const { orderedSectionsToFix, crn } = personalDetails;
@@ -1995,10 +2035,10 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
1995
2035
  Object.assign(input, buildNameInput(personalDetails.changePersonalName));
1996
2036
  }
1997
2037
  if (orderedSectionsToFix.includes("email") && personalDetails.changePersonalEmail) {
1998
- Object.assign(input, buildEmailInput(personalDetails.changePersonalEmail));
2038
+ Object.assign(input, buildEmailInput2(personalDetails.changePersonalEmail));
1999
2039
  }
2000
2040
  if (orderedSectionsToFix.includes("phone") && personalDetails.changePersonalPhoneNumbers) {
2001
- Object.assign(input, buildPhoneInput(personalDetails.changePersonalPhoneNumbers));
2041
+ Object.assign(input, buildPhoneInput2(personalDetails.changePersonalPhoneNumbers));
2002
2042
  }
2003
2043
  if (orderedSectionsToFix.includes("dob") && personalDetails.changePersonalDob) {
2004
2044
  Object.assign(input, buildDobInput(personalDetails.changePersonalDob));
@@ -2008,7 +2048,7 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
2008
2048
  }
2009
2049
  return { input };
2010
2050
  };
2011
- var buildPhoneInput = (change) => {
2051
+ var buildPhoneInput2 = (change) => {
2012
2052
  return {
2013
2053
  phone: {
2014
2054
  landline: change.personalTelephone ?? null,
@@ -2016,7 +2056,7 @@ var buildPhoneInput = (change) => {
2016
2056
  }
2017
2057
  };
2018
2058
  };
2019
- var buildEmailInput = (change) => {
2059
+ var buildEmailInput2 = (change) => {
2020
2060
  return {
2021
2061
  email: {
2022
2062
  address: change.personalEmail
@@ -2038,17 +2078,58 @@ var buildDobInput = (change) => {
2038
2078
  };
2039
2079
  };
2040
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
+
2041
2121
  // src/services/services.js
2042
2122
  var services = {
2043
2123
  addressLookup: addressLookupService,
2044
- buildUprnAddress,
2124
+ buildBusinessFixUpdateVariables: buildBusinessFixUpdateVariablesService,
2125
+ buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService,
2126
+ buildFixSuccessMessage: buildFixSuccessMessageService,
2045
2127
  buildManualAddress,
2128
+ buildUprnAddress,
2046
2129
  checkInterrupterJourneySession: checkInterrupterJourneySessionService,
2047
2130
  initialiseFixJourney: initialiseFixJourneyService,
2048
- validateFixDetails: validateFixDetailsService,
2049
2131
  setFixSessionData: setFixSessionDataService,
2050
- buildFixSuccessMessage: buildFixSuccessMessageService,
2051
- buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
2132
+ validateFixDetails: validateFixDetailsService
2052
2133
  };
2053
2134
  // Annotate the CommonJS export names for ESM import in node:
2054
2135
  0 && (module.exports = {